From 2b23ed64c4fc234045d374fa5144b0582b1f66bb Mon Sep 17 00:00:00 2001 From: dufyfduck Date: Wed, 4 Feb 2026 00:52:04 +0100 Subject: [PATCH] added new view in contracts customer and contracts --- README.md | 20 + .../src/controllers/contract.controller.ts | 11 +- backend/src/services/contract.service.ts | 95 ++- frontend/dist/assets/index-CUVVQncv.css | 1 - frontend/dist/assets/index-CooZFd_R.js | 689 ++++++++++++++++++ frontend/dist/assets/index-DWDTTlpk.css | 1 + frontend/dist/assets/index-DxzmsVZ0.js | 678 ----------------- frontend/dist/index.html | 4 +- frontend/src/components/email/EmailDetail.tsx | 2 +- frontend/src/pages/contracts/ContractForm.tsx | 29 + .../src/pages/customers/CustomerDetail.tsx | 223 ++++-- frontend/src/services/api.ts | 27 +- 12 files changed, 1022 insertions(+), 758 deletions(-) delete mode 100644 frontend/dist/assets/index-CUVVQncv.css create mode 100644 frontend/dist/assets/index-CooZFd_R.js create mode 100644 frontend/dist/assets/index-DWDTTlpk.css delete mode 100644 frontend/dist/assets/index-DxzmsVZ0.js diff --git a/README.md b/README.md index a21aeee3..38bfde07 100644 --- a/README.md +++ b/README.md @@ -558,6 +558,26 @@ Der X-Button zum Aufheben der Vertragszuordnung erscheint nur bei **manuell zuge > - `isAutoAssigned = true`: E-Mail wurde direkt aus dem Vertragskontext gesendet → X-Button ausgeblendet > - `isAutoAssigned = false`: E-Mail wurde manuell dem Vertrag zugeordnet → X-Button sichtbar +### Vertragsbaum in Kundenansicht + +In der Kundendetailansicht werden Verträge als **Baumstruktur** mit Vorgänger-Verknüpfung dargestellt: + +``` +▼ GAS-ML781A4FYXU │ Gas │ ACTIVE │ 01.01.2025 - 31.12.2026 + └─ GAS-ML24GKR...│ Gas │ EXPIRED│ 05.05.2023 - 05.05.2025 (Vorgänger) + └─ GAS-OLD123 │ Gas │ EXPIRED│ 01.01.2021 - 04.05.2023 (Vorgänger) + +▶ MOB-ML77W560A73 │ Mobil│ DRAFT │ 02.01.2024 - 02.01.2026 +``` + +**Funktionsweise:** +- **Aktuellste Verträge oben** - Verträge ohne Nachfolger werden als Wurzelknoten angezeigt +- **Standardmäßig eingeklappt** - Klick auf ▶ zeigt die Vorgängerkette +- **Vorgänger eingerückt** - Mit grauem Rand und "(Vorgänger)" Label +- **Verknüpfung über `previousContractId`** - Wird beim Erstellen eines Folgevertrags automatisch gesetzt + +> **Hinweis:** In der Hauptvertragsliste (`/contracts`) wird weiterhin die flache Ansicht ohne Baumstruktur verwendet. + ## Lizenz MIT diff --git a/backend/src/controllers/contract.controller.ts b/backend/src/controllers/contract.controller.ts index e43cc9bb..19c387f5 100644 --- a/backend/src/controllers/contract.controller.ts +++ b/backend/src/controllers/contract.controller.ts @@ -5,7 +5,16 @@ import { ApiResponse, AuthRequest } from '../types/index.js'; export async function getContracts(req: AuthRequest, res: Response): Promise { try { - const { customerId, type, status, search, page, limit } = req.query; + const { customerId, type, status, search, page, limit, tree } = req.query; + + // Baumstruktur für Kundenansicht + if (tree === 'true' && customerId) { + const treeData = await contractService.getContractTreeForCustomer( + parseInt(customerId as string) + ); + res.json({ success: true, data: treeData } as ApiResponse); + return; + } // Für Kundenportal-Benutzer: nur eigene + vertretene Kunden-Verträge anzeigen let customerIds: number[] | undefined; diff --git a/backend/src/services/contract.service.ts b/backend/src/services/contract.service.ts index 8c10f49a..722a1fcf 100644 --- a/backend/src/services/contract.service.ts +++ b/backend/src/services/contract.service.ts @@ -77,7 +77,7 @@ export async function getAllContracts(filters: ContractFilters) { where, skip, take, - orderBy: [{ startDate: 'desc' }, { createdAt: 'desc' }], + orderBy: [{ createdAt: 'desc' }], include: { customer: { select: { @@ -778,3 +778,96 @@ export async function getSipCredentials(phoneNumberId: number): Promise<{ passwo return { password: null }; } } + +// ==================== VERTRAGSBAUM FÜR KUNDENANSICHT ==================== + +export interface ContractTreeNode { + contract: { + id: number; + contractNumber: string; + type: ContractType; + status: ContractStatus; + startDate: Date | null; + endDate: Date | null; + providerName: string | null; + tariffName: string | null; + previousContractId: number | null; + provider?: { id: number; name: string } | null; + tariff?: { id: number; name: string } | null; + contractCategory?: { id: number; name: string } | null; + }; + predecessors: ContractTreeNode[]; + hasHistory: boolean; +} + +/** + * Verträge eines Kunden als Baumstruktur abrufen. + * Wurzelknoten = Verträge ohne Nachfolger (aktuellste Verträge) + * Vorgänger werden rekursiv eingebettet. + */ +export async function getContractTreeForCustomer(customerId: number): Promise { + // Alle Verträge des Kunden laden (außer DEACTIVATED) + const allContracts = await prisma.contract.findMany({ + where: { + customerId, + status: { not: ContractStatus.DEACTIVATED }, + }, + select: { + id: true, + contractNumber: true, + type: true, + status: true, + startDate: true, + endDate: true, + providerName: true, + tariffName: true, + previousContractId: true, + provider: { select: { id: true, name: true } }, + tariff: { select: { id: true, name: true } }, + contractCategory: { select: { id: true, name: true } }, + }, + orderBy: [{ startDate: 'desc' }, { createdAt: 'desc' }], + }); + + // Map für schnellen Zugriff: contractId -> contract + const contractMap = new Map(allContracts.map(c => [c.id, c])); + + // Set der IDs die als Vorgänger referenziert werden + const predecessorIds = new Set( + allContracts + .filter(c => c.previousContractId !== null) + .map(c => c.previousContractId!) + ); + + // Wurzelverträge = Verträge die keinen Nachfolger haben + // (werden von keinem anderen Vertrag als previousContractId referenziert) + const rootContracts = allContracts.filter(c => !predecessorIds.has(c.id)); + + // Rekursive Funktion um Vorgängerkette aufzubauen + function buildPredecessorChain(contractId: number | null): ContractTreeNode[] { + if (contractId === null) return []; + + const contract = contractMap.get(contractId); + if (!contract) return []; + + const predecessors = buildPredecessorChain(contract.previousContractId); + + return [{ + contract, + predecessors, + hasHistory: predecessors.length > 0, + }]; + } + + // Baumstruktur für jeden Wurzelvertrag aufbauen + const tree: ContractTreeNode[] = rootContracts.map(contract => { + const predecessors = buildPredecessorChain(contract.previousContractId); + return { + contract, + predecessors, + hasHistory: predecessors.length > 0, + }; + }); + + return tree; +} diff --git a/frontend/dist/assets/index-CUVVQncv.css b/frontend/dist/assets/index-CUVVQncv.css deleted file mode 100644 index d1c4a852..00000000 --- a/frontend/dist/assets/index-CUVVQncv.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{top:0;bottom:0}.bottom-4{bottom:1rem}.bottom-6{bottom:1.5rem}.left-3{left:.75rem}.left-4{left:1rem}.right-0{right:0}.right-3{right:.75rem}.right-4{right:1rem}.right-6{right:1.5rem}.top-0{top:0}.top-1\/2{top:50%}.top-4{top:1rem}.z-10{z-index:10}.z-50{z-index:50}.col-span-2{grid-column:span 2 / span 2}.-mx-2{margin-left:-.5rem;margin-right:-.5rem}.-mx-6{margin-left:-1.5rem;margin-right:-1.5rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-3{margin-top:.75rem;margin-bottom:.75rem}.-mb-6{margin-bottom:-1.5rem}.-mb-px{margin-bottom:-1px}.-ml-1{margin-left:-.25rem}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-10{margin-left:2.5rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mr-4{margin-right:1rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-0\.5{height:.125rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-16{height:4rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-8{height:2rem}.h-\[85vh\]{height:85vh}.h-full{height:100%}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-\[600px\]{max-height:600px}.max-h-\[60vh\]{max-height:60vh}.max-h-\[90vh\]{max-height:90vh}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-1\/3{width:33.333333%}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-16{width:4rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-4{width:1rem}.w-40{width:10rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-8{width:2rem}.w-\[90vw\]{width:90vw}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[200px\]{min-width:200px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-none{max-width:none}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.space-x-8>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(2rem * var(--tw-space-x-reverse));margin-left:calc(2rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-200>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(229 231 235 / var(--tw-divide-opacity, 1))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-xl{border-radius:.75rem}.rounded-l-lg{border-top-left-radius:.5rem;border-bottom-left-radius:.5rem}.rounded-r-lg{border-top-right-radius:.5rem;border-bottom-right-radius:.5rem}.border{border-width:1px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-0{border-left-width:0px}.border-l-2{border-left-width:2px}.border-l-4{border-left-width:4px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-amber-300{--tw-border-opacity: 1;border-color:rgb(252 211 77 / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(219 234 254 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-gray-400{--tw-border-opacity: 1;border-color:rgb(156 163 175 / var(--tw-border-opacity, 1))}.border-gray-800{--tw-border-opacity: 1;border-color:rgb(31 41 55 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-green-300{--tw-border-opacity: 1;border-color:rgb(134 239 172 / var(--tw-border-opacity, 1))}.border-purple-300{--tw-border-opacity: 1;border-color:rgb(216 180 254 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-300{--tw-border-opacity: 1;border-color:rgb(252 165 165 / var(--tw-border-opacity, 1))}.border-red-400{--tw-border-opacity: 1;border-color:rgb(248 113 113 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-red-600{--tw-border-opacity: 1;border-color:rgb(220 38 38 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.border-yellow-300{--tw-border-opacity: 1;border-color:rgb(253 224 71 / var(--tw-border-opacity, 1))}.border-l-blue-500{--tw-border-opacity: 1;border-left-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-t-transparent{border-top-color:transparent}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:#00000080}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-gray-50\/50{background-color:#f9fafb80}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-orange-500{--tw-bg-opacity: 1;background-color:rgb(249 115 22 / var(--tw-bg-opacity, 1))}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(168 85 247 / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(147 51 234 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:transparent}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.bg-yellow-500{--tw-bg-opacity: 1;background-color:rgb(234 179 8 / var(--tw-bg-opacity, 1))}.bg-opacity-50{--tw-bg-opacity: .5}.fill-current{fill:currentColor}.\!p-4{padding:1rem!important}.p-0\.5{padding:.125rem}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-10{padding-left:2.5rem}.pl-3{padding-left:.75rem}.pr-10{padding-right:2.5rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-2xl{font-size:1.5rem;line-height:2rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-purple-300{--tw-text-opacity: 1;color:rgb(216 180 254 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.line-through{text-decoration-line:line-through}.opacity-0{opacity:0}.opacity-30{opacity:.3}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-400{--tw-ring-opacity: 1;--tw-ring-color: rgb(156 163 175 / var(--tw-ring-opacity, 1))}.ring-offset-2{--tw-ring-offset-width: 2px}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-300{transition-duration:.3s}body{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:h-5:after{content:var(--tw-content);height:1.25rem}.after\:w-5:after{content:var(--tw-content);width:1.25rem}.after\:rounded-full:after{content:var(--tw-content);border-radius:9999px}.after\:border:after{content:var(--tw-content);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.after\:bg-white:after{content:var(--tw-content);--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.after\:content-\[\'\'\]:after{--tw-content: "";content:var(--tw-content)}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(156 163 175 / var(--tw-border-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-300:hover{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.hover\:bg-opacity-50:hover{--tw-bg-opacity: .5}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\:text-blue-800:hover{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:text-red-700:hover{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.hover\:text-yellow-600:hover{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}.hover\:shadow-md:hover{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-blue-500:focus{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.focus\:border-red-500:focus{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.focus\:border-transparent:focus{border-color:transparent}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-blue-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity, 1))}.focus\:ring-gray-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(107 114 128 / var(--tw-ring-opacity, 1))}.focus\:ring-purple-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(168 85 247 / var(--tw-ring-opacity, 1))}.focus\:ring-red-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity, 1))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\:bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.group\/subtask:hover .group-hover\/subtask\:opacity-100,.group:hover .group-hover\:opacity-100{opacity:1}.peer:checked~.peer-checked\:bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.peer:checked~.peer-checked\:after\:translate-x-full:after{content:var(--tw-content);--tw-translate-x: 100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.peer:checked~.peer-checked\:after\:border-white:after{content:var(--tw-content);--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.peer:focus~.peer-focus\:outline-none{outline:2px solid transparent;outline-offset:2px}.peer:focus~.peer-focus\:ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.peer:focus~.peer-focus\:ring-blue-300{--tw-ring-opacity: 1;--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity, 1))}@media (min-width: 640px){.sm\:w-auto{width:auto}}@media (min-width: 768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:col-span-1{grid-column:span 1 / span 1}.lg\:col-span-2{grid-column:span 2 / span 2}.lg\:col-span-3{grid-column:span 3 / span 3}.lg\:block{display:block}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}} diff --git a/frontend/dist/assets/index-CooZFd_R.js b/frontend/dist/assets/index-CooZFd_R.js new file mode 100644 index 00000000..5a8ddd5d --- /dev/null +++ b/frontend/dist/assets/index-CooZFd_R.js @@ -0,0 +1,689 @@ +var $h=e=>{throw TypeError(e)};var Nc=(e,t,n)=>t.has(e)||$h("Cannot "+n);var M=(e,t,n)=>(Nc(e,t,"read from private field"),n?n.call(e):t.get(e)),fe=(e,t,n)=>t.has(e)?$h("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ae=(e,t,n,r)=>(Nc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),we=(e,t,n)=>(Nc(e,t,"access private method"),n);var jl=(e,t,n,r)=>({set _(a){ae(e,t,a,n)},get _(){return M(e,t,r)}});function rv(e,t){for(var n=0;nr[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 n(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=n(a);fetch(a.href,i)}})();function av(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vx={exports:{}},Ko={},jx={exports:{}},Ee={};/** + * @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 rl=Symbol.for("react.element"),iv=Symbol.for("react.portal"),lv=Symbol.for("react.fragment"),ov=Symbol.for("react.strict_mode"),cv=Symbol.for("react.profiler"),uv=Symbol.for("react.provider"),dv=Symbol.for("react.context"),mv=Symbol.for("react.forward_ref"),hv=Symbol.for("react.suspense"),fv=Symbol.for("react.memo"),pv=Symbol.for("react.lazy"),_h=Symbol.iterator;function xv(e){return e===null||typeof e!="object"?null:(e=_h&&e[_h]||e["@@iterator"],typeof e=="function"?e:null)}var bx={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Nx=Object.assign,wx={};function $a(e,t,n){this.props=e,this.context=t,this.refs=wx,this.updater=n||bx}$a.prototype.isReactComponent={};$a.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")};$a.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Sx(){}Sx.prototype=$a.prototype;function Ad(e,t,n){this.props=e,this.context=t,this.refs=wx,this.updater=n||bx}var Md=Ad.prototype=new Sx;Md.constructor=Ad;Nx(Md,$a.prototype);Md.isPureReactComponent=!0;var Kh=Array.isArray,kx=Object.prototype.hasOwnProperty,Fd={current:null},Cx={key:!0,ref:!0,__self:!0,__source:!0};function Ex(e,t,n){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)kx.call(t,r)&&!Cx.hasOwnProperty(r)&&(a[r]=t[r]);var o=arguments.length-2;if(o===1)a.children=n;else if(1>>1,le=z[pe];if(0>>1;pea(ke,ee))Pea(Ge,ke)?(z[pe]=Ge,z[Pe]=ee,pe=Pe):(z[pe]=ke,z[Q]=ee,pe=Q);else if(Pea(Ge,ee))z[pe]=Ge,z[Pe]=ee,pe=Pe;else break e}}return J}function a(z,J){var ee=z.sortIndex-J.sortIndex;return ee!==0?ee:z.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,h=null,p=3,m=!1,f=!1,g=!1,N=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(z){for(var J=n(u);J!==null;){if(J.callback===null)r(u);else if(J.startTime<=z)r(u),J.sortIndex=J.expirationTime,t(c,J);else break;J=n(u)}}function w(z){if(g=!1,v(z),!f)if(n(c)!==null)f=!0,P(k);else{var J=n(u);J!==null&&b(w,J.startTime-z)}}function k(z,J){f=!1,g&&(g=!1,x(S),S=-1),m=!0;var ee=p;try{for(v(J),h=n(c);h!==null&&(!(h.expirationTime>J)||z&&!$());){var pe=h.callback;if(typeof pe=="function"){h.callback=null,p=h.priorityLevel;var le=pe(h.expirationTime<=J);J=e.unstable_now(),typeof le=="function"?h.callback=le:h===n(c)&&r(c),v(J)}else r(c);h=n(c)}if(h!==null)var nt=!0;else{var Q=n(u);Q!==null&&b(w,Q.startTime-J),nt=!1}return nt}finally{h=null,p=ee,m=!1}}var C=!1,A=null,S=-1,E=5,D=-1;function $(){return!(e.unstable_now()-Dz||125pe?(z.sortIndex=ee,t(u,z),n(c)===null&&z===n(u)&&(g?(x(S),S=-1):g=!0,b(w,ee-pe))):(z.sortIndex=le,t(c,z),f||m||(f=!0,P(k))),z},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(z){var J=p;return function(){var ee=p;p=J;try{return z.apply(this,arguments)}finally{p=ee}}}})(Fx);Mx.exports=Fx;var Dv=Mx.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 Pv=j,ds=Dv;function G(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),lu=Object.prototype.hasOwnProperty,Av=/^[: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]*$/,Bh={},qh={};function Mv(e){return lu.call(qh,e)?!0:lu.call(Bh,e)?!1:Av.test(e)?qh[e]=!0:(Bh[e]=!0,!1)}function Fv(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Tv(e,t,n,r){if(t===null||typeof t>"u"||Fv(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.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 Ht(e,t,n,r,a,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Ft={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ft[e]=new Ht(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ft[t]=new Ht(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ft[e]=new Ht(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ft[e]=new Ht(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){Ft[e]=new Ht(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ft[e]=new Ht(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ft[e]=new Ht(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ft[e]=new Ht(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ft[e]=new Ht(e,5,!1,e.toLowerCase(),null,!1,!1)});var Id=/[\-:]([a-z])/g;function Ld(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(Id,Ld);Ft[t]=new Ht(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(Id,Ld);Ft[t]=new Ht(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(Id,Ld);Ft[t]=new Ht(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ft[e]=new Ht(e,1,!1,e.toLowerCase(),null,!1,!1)});Ft.xlinkHref=new Ht("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ft[e]=new Ht(e,1,!1,e.toLowerCase(),null,!0,!0)});function Rd(e,t,n,r){var a=Ft.hasOwnProperty(t)?Ft[t]:null;(a!==null?a.type!==0:r||!(2o||a[l]!==i[o]){var c=` +`+a[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{kc=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?oi(e):""}function Iv(e){switch(e.tag){case 5:return oi(e.type);case 16:return oi("Lazy");case 13:return oi("Suspense");case 19:return oi("SuspenseList");case 0:case 2:case 15:return e=Cc(e.type,!1),e;case 11:return e=Cc(e.type.render,!1),e;case 1:return e=Cc(e.type,!0),e;default:return""}}function du(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 Jr:return"Fragment";case Zr:return"Portal";case ou:return"Profiler";case Od:return"StrictMode";case cu:return"Suspense";case uu:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Lx:return(e.displayName||"Context")+".Consumer";case Ix:return(e._context.displayName||"Context")+".Provider";case zd:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $d:return t=e.displayName||null,t!==null?t:du(e.type)||"Memo";case An:t=e._payload,e=e._init;try{return du(e(t))}catch{}}return null}function Lv(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 du(t);case 8:return t===Od?"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 rr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ox(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Rv(e){var t=Ox(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var a=n.get,i=n.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:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wl(e){e._valueTracker||(e._valueTracker=Rv(e))}function zx(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Ox(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function io(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 mu(e,t){var n=t.checked;return tt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Qh(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=rr(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function $x(e,t){t=t.checked,t!=null&&Rd(e,"checked",t,!1)}function hu(e,t){$x(e,t);var n=rr(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?fu(e,t.type,n):t.hasOwnProperty("defaultValue")&&fu(e,t.type,rr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Hh(e,t,n){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,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function fu(e,t,n){(t!=="number"||io(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ci=Array.isArray;function ca(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a"+t.valueOf().toString()+"",t=Sl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ei(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var fi={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},Ov=["Webkit","ms","Moz","O"];Object.keys(fi).forEach(function(e){Ov.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),fi[t]=fi[e]})});function Bx(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||fi.hasOwnProperty(e)&&fi[e]?(""+t).trim():t+"px"}function qx(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=Bx(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var zv=tt({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 gu(e,t){if(t){if(zv[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(G(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(G(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(G(61))}if(t.style!=null&&typeof t.style!="object")throw Error(G(62))}}function yu(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 vu=null;function _d(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ju=null,ua=null,da=null;function Zh(e){if(e=ll(e)){if(typeof ju!="function")throw Error(G(280));var t=e.stateNode;t&&(t=Qo(t),ju(e.stateNode,e.type,t))}}function Vx(e){ua?da?da.push(e):da=[e]:ua=e}function Qx(){if(ua){var e=ua,t=da;if(da=ua=null,Zh(e),t)for(e=0;e>>=0,e===0?32:31-(Gv(e)/Zv|0)|0}var kl=64,Cl=4194304;function ui(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 uo(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~a;o!==0?r=ui(o):(i&=l,i!==0&&(r=ui(i)))}else l=n&~a,l!==0?r=ui(l):i!==0&&(r=ui(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|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function al(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Is(t),e[t]=n}function ej(e,t){var n=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=xi),af=" ",lf=!1;function mg(e,t){switch(e){case"keyup":return Dj.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function hg(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xr=!1;function Aj(e,t){switch(e){case"compositionend":return hg(t);case"keypress":return t.which!==32?null:(lf=!0,af);case"textInput":return e=t.data,e===af&&lf?null:e;default:return null}}function Mj(e,t){if(Xr)return e==="compositionend"||!Wd&&mg(e,t)?(e=ug(),Vl=Vd=Vn=null,Xr=!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)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=df(n)}}function gg(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?gg(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function yg(){for(var e=window,t=io();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=io(e.document)}return t}function Gd(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 _j(e){var t=yg(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&gg(n.ownerDocument.documentElement,n)){if(r!==null&&Gd(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=n.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=mf(n,i);var l=mf(n,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=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Yr=null,Cu=null,yi=null,Eu=!1;function hf(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Eu||Yr==null||Yr!==io(r)||(r=Yr,"selectionStart"in r&&Gd(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}),yi&&Ti(yi,r)||(yi=r,r=fo(Cu,"onSelect"),0sa||(e.current=Tu[sa],Tu[sa]=null,sa--)}function Be(e,t){sa++,Tu[sa]=e.current,e.current=t}var ar={},zt=lr(ar),ts=lr(!1),Ir=ar;function Aa(e,t){var n=e.type.contextTypes;if(!n)return ar;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in n)a[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function ss(e){return e=e.childContextTypes,e!=null}function xo(){Qe(ts),Qe(zt)}function jf(e,t,n){if(zt.current!==ar)throw Error(G(168));Be(zt,t),Be(ts,n)}function Eg(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(G(108,Lv(e)||"Unknown",a));return tt({},n,r)}function go(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ar,Ir=zt.current,Be(zt,e),Be(ts,ts.current),!0}function bf(e,t,n){var r=e.stateNode;if(!r)throw Error(G(169));n?(e=Eg(e,t,Ir),r.__reactInternalMemoizedMergedChildContext=e,Qe(ts),Qe(zt),Be(zt,e)):Qe(ts),Be(ts,n)}var on=null,Ho=!1,_c=!1;function Dg(e){on===null?on=[e]:on.push(e)}function Xj(e){Ho=!0,Dg(e)}function or(){if(!_c&&on!==null){_c=!0;var e=0,t=ze;try{var n=on;for(ze=1;e>=l,a-=l,fn=1<<32-Is(t)+a|n<S?(E=A,A=null):E=A.sibling;var D=p(x,A,v[S],w);if(D===null){A===null&&(A=E);break}e&&A&&D.alternate===null&&t(x,A),y=i(D,y,S),C===null?k=D:C.sibling=D,C=D,A=E}if(S===v.length)return n(x,A),We&&mr(x,S),k;if(A===null){for(;SS?(E=A,A=null):E=A.sibling;var $=p(x,A,D.value,w);if($===null){A===null&&(A=E);break}e&&A&&$.alternate===null&&t(x,A),y=i($,y,S),C===null?k=$:C.sibling=$,C=$,A=E}if(D.done)return n(x,A),We&&mr(x,S),k;if(A===null){for(;!D.done;S++,D=v.next())D=h(x,D.value,w),D!==null&&(y=i(D,y,S),C===null?k=D:C.sibling=D,C=D);return We&&mr(x,S),k}for(A=r(x,A);!D.done;S++,D=v.next())D=m(A,x,S,D.value,w),D!==null&&(e&&D.alternate!==null&&A.delete(D.key===null?S:D.key),y=i(D,y,S),C===null?k=D:C.sibling=D,C=D);return e&&A.forEach(function(L){return t(x,L)}),We&&mr(x,S),k}function N(x,y,v,w){if(typeof v=="object"&&v!==null&&v.type===Jr&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Nl:e:{for(var k=v.key,C=y;C!==null;){if(C.key===k){if(k=v.type,k===Jr){if(C.tag===7){n(x,C.sibling),y=a(C,v.props.children),y.return=x,x=y;break e}}else if(C.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===An&&Sf(k)===C.type){n(x,C.sibling),y=a(C,v.props),y.ref=ni(x,C,v),y.return=x,x=y;break e}n(x,C);break}else t(x,C);C=C.sibling}v.type===Jr?(y=Mr(v.props.children,x.mode,w,v.key),y.return=x,x=y):(w=Yl(v.type,v.key,v.props,null,x.mode,w),w.ref=ni(x,y,v),w.return=x,x=w)}return l(x);case Zr:e:{for(C=v.key;y!==null;){if(y.key===C)if(y.tag===4&&y.stateNode.containerInfo===v.containerInfo&&y.stateNode.implementation===v.implementation){n(x,y.sibling),y=a(y,v.children||[]),y.return=x,x=y;break e}else{n(x,y);break}else t(x,y);y=y.sibling}y=Wc(v,x.mode,w),y.return=x,x=y}return l(x);case An:return C=v._init,N(x,y,C(v._payload),w)}if(ci(v))return f(x,y,v,w);if(Xa(v))return g(x,y,v,w);Tl(x,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,y!==null&&y.tag===6?(n(x,y.sibling),y=a(y,v),y.return=x,x=y):(n(x,y),y=Hc(v,x.mode,w),y.return=x,x=y),l(x)):n(x,y)}return N}var Fa=Fg(!0),Tg=Fg(!1),jo=lr(null),bo=null,aa=null,Yd=null;function em(){Yd=aa=bo=null}function tm(e){var t=jo.current;Qe(jo),e._currentValue=t}function Ru(e,t,n){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===n)break;e=e.return}}function ha(e,t){bo=e,Yd=aa=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(es=!0),e.firstContext=null)}function bs(e){var t=e._currentValue;if(Yd!==e)if(e={context:e,memoizedValue:t,next:null},aa===null){if(bo===null)throw Error(G(308));aa=e,bo.dependencies={lanes:0,firstContext:e}}else aa=aa.next=e;return t}var xr=null;function sm(e){xr===null?xr=[e]:xr.push(e)}function Ig(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,sm(t)):(n.next=a.next,a.next=n),t.interleaved=n,bn(e,r)}function bn(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Mn=!1;function nm(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Lg(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 gn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Xn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Me&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,bn(e,n)}return a=r.interleaved,a===null?(t.next=t,sm(r)):(t.next=a.next,a.next=t),r.interleaved=t,bn(e,n)}function Hl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ud(e,n)}}function kf(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?a=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?a=i=t:i=i.next=t}else a=i=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function No(e,t,n,r){var a=e.updateQueue;Mn=!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 h=a.baseState;l=0,d=u=c=null,o=i;do{var p=o.lane,m=o.eventTime;if((r&p)===p){d!==null&&(d=d.next={eventTime:m,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var f=e,g=o;switch(p=t,m=n,g.tag){case 1:if(f=g.payload,typeof f=="function"){h=f.call(m,h,p);break e}h=f;break e;case 3:f.flags=f.flags&-65537|128;case 0:if(f=g.payload,p=typeof f=="function"?f.call(m,h,p):f,p==null)break e;h=tt({},h,p);break e;case 2:Mn=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=a.effects,p===null?a.effects=[o]:p.push(o))}else m={eventTime:m,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=m,c=h):d=d.next=m,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=h),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);Or|=l,e.lanes=l,e.memoizedState=h}}function Cf(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Uc.transition;Uc.transition={};try{e(!1),t()}finally{ze=n,Uc.transition=r}}function Xg(){return Ns().memoizedState}function sb(e,t,n){var r=er(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Yg(e))ey(t,n);else if(n=Ig(e,t,n,r),n!==null){var a=Vt();Ls(n,e,r,a),ty(n,t,r)}}function nb(e,t,n){var r=er(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Yg(e))ey(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,n);if(a.hasEagerState=!0,a.eagerState=o,Rs(o,l)){var c=t.interleaved;c===null?(a.next=a,sm(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=Ig(e,t,a,r),n!==null&&(a=Vt(),Ls(n,e,r,a),ty(n,t,r))}}function Yg(e){var t=e.alternate;return e===Ye||t!==null&&t===Ye}function ey(e,t){vi=So=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ty(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ud(e,n)}}var ko={readContext:bs,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},rb={readContext:bs,useCallback:function(e,t){return Us().memoizedState=[e,t===void 0?null:t],e},useContext:bs,useEffect:Df,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Gl(4194308,4,Hg.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Gl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Gl(4,2,e,t)},useMemo:function(e,t){var n=Us();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Us();return t=n!==void 0?n(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=sb.bind(null,Ye,e),[r.memoizedState,e]},useRef:function(e){var t=Us();return e={current:e},t.memoizedState=e},useState:Ef,useDebugValue:dm,useDeferredValue:function(e){return Us().memoizedState=e},useTransition:function(){var e=Ef(!1),t=e[0];return e=tb.bind(null,e[1]),Us().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ye,a=Us();if(We){if(n===void 0)throw Error(G(407));n=n()}else{if(n=t(),Ct===null)throw Error(G(349));Rr&30||$g(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,Df(Kg.bind(null,r,i,e),[e]),r.flags|=2048,Ki(9,_g.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Us(),t=Ct.identifierPrefix;if(We){var n=pn,r=fn;n=(r&~(1<<32-Is(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=$i++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Hs]=t,e[Ri]=r,dy(e,t,!1,!1),t.stateNode=e;e:{switch(l=yu(n,r),n){case"dialog":Ve("cancel",e),Ve("close",e),a=r;break;case"iframe":case"object":case"embed":Ve("load",e),a=r;break;case"video":case"audio":for(a=0;aLa&&(t.flags|=128,r=!0,ri(i,!1),t.lanes=4194304)}else{if(!r)if(e=wo(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ri(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!We)return Lt(t),null}else 2*dt()-i.renderingStartTime>La&&n!==1073741824&&(t.flags|=128,r=!0,ri(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=dt(),t.sibling=null,n=Je.current,Be(Je,r?n&1|2:n&1),t):(Lt(t),null);case 22:case 23:return gm(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?is&1073741824&&(Lt(t),t.subtreeFlags&6&&(t.flags|=8192)):Lt(t),null;case 24:return null;case 25:return null}throw Error(G(156,t.tag))}function mb(e,t){switch(Jd(t),t.tag){case 1:return ss(t.type)&&xo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ta(),Qe(ts),Qe(zt),im(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return am(t),null;case 13:if(Qe(Je),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(G(340));Ma()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Qe(Je),null;case 4:return Ta(),null;case 10:return tm(t.type._context),null;case 22:case 23:return gm(),null;case 24:return null;default:return null}}var Ll=!1,Rt=!1,hb=typeof WeakSet=="function"?WeakSet:Set,oe=null;function ia(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ot(e,t,r)}else n.current=null}function Vu(e,t,n){try{n()}catch(r){ot(e,t,r)}}var $f=!1;function fb(e,t){if(Du=mo,e=yg(),Gd(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,u=0,d=0,h=e,p=null;t:for(;;){for(var m;h!==n||a!==0&&h.nodeType!==3||(o=l+a),h!==i||r!==0&&h.nodeType!==3||(c=l+r),h.nodeType===3&&(l+=h.nodeValue.length),(m=h.firstChild)!==null;)p=h,h=m;for(;;){if(h===e)break t;if(p===n&&++u===a&&(o=l),p===i&&++d===r&&(c=l),(m=h.nextSibling)!==null)break;h=p,p=h.parentNode}h=m}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Pu={focusedElem:e,selectionRange:n},mo=!1,oe=t;oe!==null;)if(t=oe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,oe=e;else for(;oe!==null;){t=oe;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,N=f.memoizedState,x=t.stateNode,y=x.getSnapshotBeforeUpdate(t.elementType===t.type?g:Cs(t.type,g),N);x.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(G(163))}}catch(w){ot(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,oe=e;break}oe=t.return}return f=$f,$f=!1,f}function ji(e,t,n){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&&Vu(t,n,i)}a=a.next}while(a!==r)}}function Zo(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Qu(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function fy(e){var t=e.alternate;t!==null&&(e.alternate=null,fy(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Hs],delete t[Ri],delete t[Fu],delete t[Zj],delete t[Jj])),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 py(e){return e.tag===5||e.tag===3||e.tag===4}function _f(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||py(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 Hu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=po));else if(r!==4&&(e=e.child,e!==null))for(Hu(e,t,n),e=e.sibling;e!==null;)Hu(e,t,n),e=e.sibling}function Wu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Wu(e,t,n),e=e.sibling;e!==null;)Wu(e,t,n),e=e.sibling}var Dt=null,Ps=!1;function Dn(e,t,n){for(n=n.child;n!==null;)xy(e,t,n),n=n.sibling}function xy(e,t,n){if(Zs&&typeof Zs.onCommitFiberUnmount=="function")try{Zs.onCommitFiberUnmount(Uo,n)}catch{}switch(n.tag){case 5:Rt||ia(n,t);case 6:var r=Dt,a=Ps;Dt=null,Dn(e,t,n),Dt=r,Ps=a,Dt!==null&&(Ps?(e=Dt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Dt.removeChild(n.stateNode));break;case 18:Dt!==null&&(Ps?(e=Dt,n=n.stateNode,e.nodeType===8?$c(e.parentNode,n):e.nodeType===1&&$c(e,n),Mi(e)):$c(Dt,n.stateNode));break;case 4:r=Dt,a=Ps,Dt=n.stateNode.containerInfo,Ps=!0,Dn(e,t,n),Dt=r,Ps=a;break;case 0:case 11:case 14:case 15:if(!Rt&&(r=n.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)&&Vu(n,t,l),a=a.next}while(a!==r)}Dn(e,t,n);break;case 1:if(!Rt&&(ia(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ot(n,t,o)}Dn(e,t,n);break;case 21:Dn(e,t,n);break;case 22:n.mode&1?(Rt=(r=Rt)||n.memoizedState!==null,Dn(e,t,n),Rt=r):Dn(e,t,n);break;default:Dn(e,t,n)}}function Kf(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new hb),t.forEach(function(r){var a=wb.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function ks(e,t){var n=t.deletions;if(n!==null)for(var r=0;ra&&(a=l),r&=~i}if(r=a,r=dt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*xb(r/1960))-r,10e?16:e,Qn===null)var r=!1;else{if(e=Qn,Qn=null,Do=0,Me&6)throw Error(G(331));var a=Me;for(Me|=4,oe=e.current;oe!==null;){var i=oe,l=i.child;if(oe.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cdt()-pm?Ar(e,0):fm|=n),ns(e,t)}function Sy(e,t){t===0&&(e.mode&1?(t=Cl,Cl<<=1,!(Cl&130023424)&&(Cl=4194304)):t=1);var n=Vt();e=bn(e,t),e!==null&&(al(e,t,n),ns(e,n))}function Nb(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Sy(e,n)}function wb(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(G(314))}r!==null&&r.delete(t),Sy(e,n)}var ky;ky=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ts.current)es=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return es=!1,ub(e,t,n);es=!!(e.flags&131072)}else es=!1,We&&t.flags&1048576&&Pg(t,vo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Zl(e,t),e=t.pendingProps;var a=Aa(t,zt.current);ha(t,n),a=om(null,t,r,e,a,n);var i=cm();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,ss(r)?(i=!0,go(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,nm(t),a.updater=Go,t.stateNode=a,a._reactInternals=t,zu(t,r,e,n),t=Ku(null,t,r,!0,i,n)):(t.tag=0,We&&i&&Zd(t),Ut(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Zl(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=kb(r),e=Cs(r,e),a){case 0:t=_u(null,t,r,e,n);break e;case 1:t=Rf(null,t,r,e,n);break e;case 11:t=If(null,t,r,e,n);break e;case 14:t=Lf(null,t,r,Cs(r.type,e),n);break e}throw Error(G(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Cs(r,a),_u(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Cs(r,a),Rf(e,t,r,a,n);case 3:e:{if(oy(t),e===null)throw Error(G(387));r=t.pendingProps,i=t.memoizedState,a=i.element,Lg(e,t),No(t,r,null,n);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=Ia(Error(G(423)),t),t=Of(e,t,r,n,a);break e}else if(r!==a){a=Ia(Error(G(424)),t),t=Of(e,t,r,n,a);break e}else for(cs=Jn(t.stateNode.containerInfo.firstChild),us=t,We=!0,As=null,n=Tg(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ma(),r===a){t=Nn(e,t,n);break e}Ut(e,t,r,n)}t=t.child}return t;case 5:return Rg(t),e===null&&Lu(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,l=a.children,Au(r,a)?l=null:i!==null&&Au(r,i)&&(t.flags|=32),ly(e,t),Ut(e,t,l,n),t.child;case 6:return e===null&&Lu(t),null;case 13:return cy(e,t,n);case 4:return rm(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Fa(t,null,r,n):Ut(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Cs(r,a),If(e,t,r,a,n);case 7:return Ut(e,t,t.pendingProps,n),t.child;case 8:return Ut(e,t,t.pendingProps.children,n),t.child;case 12:return Ut(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,i=t.memoizedProps,l=a.value,Be(jo,r._currentValue),r._currentValue=l,i!==null)if(Rs(i.value,l)){if(i.children===a.children&&!ts.current){t=Nn(e,t,n);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=gn(-1,n&-n),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|=n,c=i.alternate,c!==null&&(c.lanes|=n),Ru(i.return,n,t),o.lanes|=n;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(G(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),Ru(l,n,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}Ut(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,ha(t,n),a=bs(a),r=r(a),t.flags|=1,Ut(e,t,r,n),t.child;case 14:return r=t.type,a=Cs(r,t.pendingProps),a=Cs(r.type,a),Lf(e,t,r,a,n);case 15:return ay(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Cs(r,a),Zl(e,t),t.tag=1,ss(r)?(e=!0,go(t)):e=!1,ha(t,n),sy(t,r,a),zu(t,r,a,n),Ku(null,t,r,!0,e,n);case 19:return uy(e,t,n);case 22:return iy(e,t,n)}throw Error(G(156,t.tag))};function Cy(e,t){return Yx(e,t)}function Sb(e,t,n,r){this.tag=e,this.key=n,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 ys(e,t,n,r){return new Sb(e,t,n,r)}function vm(e){return e=e.prototype,!(!e||!e.isReactComponent)}function kb(e){if(typeof e=="function")return vm(e)?1:0;if(e!=null){if(e=e.$$typeof,e===zd)return 11;if(e===$d)return 14}return 2}function tr(e,t){var n=e.alternate;return n===null?(n=ys(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Yl(e,t,n,r,a,i){var l=2;if(r=e,typeof e=="function")vm(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Jr:return Mr(n.children,a,i,t);case Od:l=8,a|=8;break;case ou:return e=ys(12,n,t,a|2),e.elementType=ou,e.lanes=i,e;case cu:return e=ys(13,n,t,a),e.elementType=cu,e.lanes=i,e;case uu:return e=ys(19,n,t,a),e.elementType=uu,e.lanes=i,e;case Rx:return Xo(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ix:l=10;break e;case Lx:l=9;break e;case zd:l=11;break e;case $d:l=14;break e;case An:l=16,r=null;break e}throw Error(G(130,e==null?e:typeof e,""))}return t=ys(l,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function Mr(e,t,n,r){return e=ys(7,e,r,t),e.lanes=n,e}function Xo(e,t,n,r){return e=ys(22,e,r,t),e.elementType=Rx,e.lanes=n,e.stateNode={isHidden:!1},e}function Hc(e,t,n){return e=ys(6,e,null,t),e.lanes=n,e}function Wc(e,t,n){return t=ys(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Cb(e,t,n,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=Dc(0),this.expirationTimes=Dc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dc(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function jm(e,t,n,r,a,i,l,o,c){return e=new Cb(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ys(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},nm(i),e}function Eb(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ay)}catch(e){console.error(e)}}Ay(),Ax.exports=ms;var Fb=Ax.exports,Gf=Fb;iu.createRoot=Gf.createRoot,iu.hydrateRoot=Gf.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 Bi(){return Bi=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Sm(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Ib(){return Math.random().toString(36).substr(2,8)}function Jf(e,t){return{usr:e.state,key:e.key,idx:t}}function Yu(e,t,n,r){return n===void 0&&(n=null),Bi({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Ua(t):t,{state:n,key:t&&t.key||r||Ib()})}function Mo(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function Ua(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function Lb(e,t,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,l=a.history,o=Hn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Bi({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function h(){o=Hn.Pop;let N=d(),x=N==null?null:N-u;u=N,c&&c({action:o,location:g.location,delta:x})}function p(N,x){o=Hn.Push;let y=Yu(g.location,N,x);u=d()+1;let v=Jf(y,u),w=g.createHref(y);try{l.pushState(v,"",w)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;a.location.assign(w)}i&&c&&c({action:o,location:g.location,delta:1})}function m(N,x){o=Hn.Replace;let y=Yu(g.location,N,x);u=d();let v=Jf(y,u),w=g.createHref(y);l.replaceState(v,"",w),i&&c&&c({action:o,location:g.location,delta:0})}function f(N){let x=a.location.origin!=="null"?a.location.origin:a.location.href,y=typeof N=="string"?N:Mo(N);return y=y.replace(/ $/,"%20"),et(x,"No window.location.(origin|href) available to create URL for href: "+y),new URL(y,x)}let g={get action(){return o},get location(){return e(a,l)},listen(N){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(Zf,h),c=N,()=>{a.removeEventListener(Zf,h),c=null}},createHref(N){return t(a,N)},createURL:f,encodeLocation(N){let x=f(N);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:p,replace:m,go(N){return l.go(N)}};return g}var Xf;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Xf||(Xf={}));function Rb(e,t,n){return n===void 0&&(n="/"),Ob(e,t,n)}function Ob(e,t,n,r){let a=typeof t=="string"?Ua(t):t,i=Ra(a.pathname||"/",n);if(i==null)return null;let l=My(e);zb(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(et(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=sr([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(et(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),My(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:Vb(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 Fy(i.path))a(i,l,c)}),t}function Fy(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let l=Fy(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 zb(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Qb(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const $b=/^:[\w-]+$/,_b=3,Kb=2,Ub=1,Bb=10,qb=-2,Yf=e=>e==="*";function Vb(e,t){let n=e.split("/"),r=n.length;return n.some(Yf)&&(r+=qb),t&&(r+=Kb),n.filter(a=>!Yf(a)).reduce((a,i)=>a+($b.test(i)?_b:i===""?Ub:Bb),r)}function Qb(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 Hb(e,t,n){let{routesMeta:r}=e,a={},i="/",l=[];for(let o=0;o{let{paramName:p,isOptional:m}=d;if(p==="*"){let g=o[h]||"";l=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const f=o[h];return m&&!f?u[p]=void 0:u[p]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function Wb(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Sm(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==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Gb(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Sm(!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 Ra(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Zb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Jb=e=>Zb.test(e);function Xb(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?Ua(e):e,i;if(n)if(Jb(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Sm(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=ep(n.substring(1),"/"):i=ep(n,t)}else i=t;return{pathname:i,search:tN(r),hash:sN(a)}}function ep(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Gc(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Yb(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function km(e,t){let n=Yb(e);return t?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Cm(e,t,n,r){r===void 0&&(r=!1);let a;typeof e=="string"?a=Ua(e):(a=Bi({},e),et(!a.pathname||!a.pathname.includes("?"),Gc("?","pathname","search",a)),et(!a.pathname||!a.pathname.includes("#"),Gc("#","pathname","hash",a)),et(!a.search||!a.search.includes("#"),Gc("#","search","hash",a)));let i=e===""||a.pathname==="",l=i?"/":a.pathname,o;if(l==null)o=n;else{let h=t.length-1;if(!r&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),h-=1;a.pathname=p.join("/")}o=h>=0?t[h]:"/"}let c=Xb(a,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const sr=e=>e.join("/").replace(/\/\/+/g,"/"),eN=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),tN=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,sN=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function nN(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Ty=["post","put","patch","delete"];new Set(Ty);const rN=["get",...Ty];new Set(rN);/** + * 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 qi(){return qi=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),j.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let h=Cm(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:sr([t,h.pathname])),(d.replace?r.replace:r.push)(h,d.state,d)},[t,r,l,i,e])}const lN=j.createContext(null);function oN(e){let t=j.useContext(en).outlet;return t&&j.createElement(lN.Provider,{value:e},t)}function ac(){let{matches:e}=j.useContext(en),t=e[e.length-1];return t?t.params:{}}function ic(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(Cn),{matches:a}=j.useContext(en),{pathname:i}=En(),l=JSON.stringify(km(a,r.v7_relativeSplatPath));return j.useMemo(()=>Cm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function cN(e,t){return uN(e,t)}function uN(e,t,n,r){Ba()||et(!1);let{navigator:a}=j.useContext(Cn),{matches:i}=j.useContext(en),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=En(),d;if(t){var h;let N=typeof t=="string"?Ua(t):t;c==="/"||(h=N.pathname)!=null&&h.startsWith(c)||et(!1),d=N}else d=u;let p=d.pathname||"/",m=p;if(c!=="/"){let N=c.replace(/^\//,"").split("/");m="/"+p.replace(/^\//,"").split("/").slice(N.length).join("/")}let f=Rb(e,{pathname:m}),g=pN(f&&f.map(N=>Object.assign({},N,{params:Object.assign({},o,N.params),pathname:sr([c,a.encodeLocation?a.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?c:sr([c,a.encodeLocation?a.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),i,n,r);return t&&g?j.createElement(rc.Provider,{value:{location:qi({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:Hn.Pop}},g):g}function dN(){let e=vN(),t=nN(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:a},n):null,null)}const mN=j.createElement(dN,null);class hN extends j.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,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(en.Provider,{value:this.props.routeContext},j.createElement(Ly.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function fN(e){let{routeContext:t,match:n,children:r}=e,a=j.useContext(nc);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(en.Provider,{value:t},r)}function pN(e,t,n,r){var a;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(a=n)==null?void 0:a.errors;if(o!=null){let d=l.findIndex(h=>h.route.id&&(o==null?void 0:o[h.route.id])!==void 0);d>=0||et(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,h,p)=>{let m,f=!1,g=null,N=null;n&&(m=o&&h.route.id?o[h.route.id]:void 0,g=h.route.errorElement||mN,c&&(u<0&&p===0?(bN("route-fallback"),f=!0,N=null):u===p&&(f=!0,N=h.route.hydrateFallbackElement||null)));let x=t.concat(l.slice(0,p+1)),y=()=>{let v;return m?v=g:f?v=N:h.route.Component?v=j.createElement(h.route.Component,null):h.route.element?v=h.route.element:v=d,j.createElement(fN,{match:h,routeContext:{outlet:d,matches:x,isDataRoute:n!=null},children:v})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?j.createElement(hN,{location:n.location,revalidation:n.revalidation,component:g,error:m,children:y(),routeContext:{outlet:null,matches:x,isDataRoute:!0}}):y()},null)}var Oy=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Oy||{}),zy=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}(zy||{});function xN(e){let t=j.useContext(nc);return t||et(!1),t}function gN(e){let t=j.useContext(Iy);return t||et(!1),t}function yN(e){let t=j.useContext(en);return t||et(!1),t}function $y(e){let t=yN(),n=t.matches[t.matches.length-1];return n.route.id||et(!1),n.route.id}function vN(){var e;let t=j.useContext(Ly),n=gN(),r=$y();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function jN(){let{router:e}=xN(Oy.UseNavigateStable),t=$y(zy.UseNavigateStable),n=j.useRef(!1);return Ry(()=>{n.current=!0}),j.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,qi({fromRouteId:t},i)))},[e,t])}const tp={};function bN(e,t,n){tp[e]||(tp[e]=!0)}function NN(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function oa(e){let{to:t,replace:n,state:r,relative:a}=e;Ba()||et(!1);let{future:i,static:l}=j.useContext(Cn),{matches:o}=j.useContext(en),{pathname:c}=En(),u=Wt(),d=Cm(t,km(o,i.v7_relativeSplatPath),c,a==="path"),h=JSON.stringify(d);return j.useEffect(()=>u(JSON.parse(h),{replace:n,state:r,relative:a}),[u,h,a,n,r]),null}function wN(e){return oN(e.context)}function Ie(e){et(!1)}function SN(e){let{basename:t="/",children:n=null,location:r,navigationType:a=Hn.Pop,navigator:i,static:l=!1,future:o}=e;Ba()&&et(!1);let c=t.replace(/^\/*/,"/"),u=j.useMemo(()=>({basename:c,navigator:i,static:l,future:qi({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=Ua(r));let{pathname:d="/",search:h="",hash:p="",state:m=null,key:f="default"}=r,g=j.useMemo(()=>{let N=Ra(d,c);return N==null?null:{location:{pathname:N,search:h,hash:p,state:m,key:f},navigationType:a}},[c,d,h,p,m,f,a]);return g==null?null:j.createElement(Cn.Provider,{value:u},j.createElement(rc.Provider,{children:n,value:g}))}function kN(e){let{children:t,location:n}=e;return cN(td(t),n)}new Promise(()=>{});function td(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,a)=>{if(!j.isValidElement(r))return;let i=[...t,a];if(r.type===j.Fragment){n.push.apply(n,td(r.props.children,i));return}r.type!==Ie&&et(!1),!r.props.index||!r.props.children||et(!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=td(r.props.children,i)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Fo(){return Fo=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[a]=e[a]);return n}function CN(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function EN(e,t){return e.button===0&&(!t||t==="_self")&&!CN(e)}function sd(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function DN(e,t){let n=sd(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}const PN=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],AN=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],MN="6";try{window.__reactRouterVersion=MN}catch{}const FN=j.createContext({isTransitioning:!1}),TN="startTransition",sp=bv[TN];function IN(e){let{basename:t,children:n,future:r,window:a}=e,i=j.useRef();i.current==null&&(i.current=Tb({window:a,v5Compat:!0}));let l=i.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=j.useCallback(h=>{u&&sp?sp(()=>c(h)):c(h)},[c,u]);return j.useLayoutEffect(()=>l.listen(d),[l,d]),j.useEffect(()=>NN(r),[r]),j.createElement(SN,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const LN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",RN=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Se=j.forwardRef(function(t,n){let{onClick:r,relative:a,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:h}=t,p=_y(t,PN),{basename:m}=j.useContext(Cn),f,g=!1;if(typeof u=="string"&&RN.test(u)&&(f=u,LN))try{let v=new URL(window.location.href),w=u.startsWith("//")?new URL(v.protocol+u):new URL(u),k=Ra(w.pathname,m);w.origin===v.origin&&k!=null?u=k+w.search+w.hash:g=!0}catch{}let N=aN(u,{relative:a}),x=zN(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:a,viewTransition:h});function y(v){r&&r(v),v.defaultPrevented||x(v)}return j.createElement("a",Fo({},p,{href:f||N,onClick:g||i?r:y,ref:n,target:c}))}),Zc=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:a=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,h=_y(t,AN),p=ic(c,{relative:h.relative}),m=En(),f=j.useContext(Iy),{navigator:g,basename:N}=j.useContext(Cn),x=f!=null&&$N(p)&&u===!0,y=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,v=m.pathname,w=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;a||(v=v.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&N&&(w=Ra(w,N)||w);const k=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let C=v===y||!l&&v.startsWith(y)&&v.charAt(k)==="/",A=w!=null&&(w===y||!l&&w.startsWith(y)&&w.charAt(y.length)==="/"),S={isActive:C,isPending:A,isTransitioning:x},E=C?r:void 0,D;typeof i=="function"?D=i(S):D=[i,C?"active":null,A?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let $=typeof o=="function"?o(S):o;return j.createElement(Se,Fo({},h,{"aria-current":E,className:D,ref:n,style:$,to:c,viewTransition:u}),typeof d=="function"?d(S):d)});var nd;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(nd||(nd={}));var np;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(np||(np={}));function ON(e){let t=j.useContext(nc);return t||et(!1),t}function zN(e,t){let{target:n,replace:r,state:a,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Wt(),u=En(),d=ic(e,{relative:l});return j.useCallback(h=>{if(EN(h,n)){h.preventDefault();let p=r!==void 0?r:Mo(u)===Mo(d);c(e,{replace:p,state:a,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,a,n,e,i,l,o])}function lc(e){let t=j.useRef(sd(e)),n=j.useRef(!1),r=En(),a=j.useMemo(()=>DN(r.search,n.current?null:t.current),[r.search]),i=Wt(),l=j.useCallback((o,c)=>{const u=sd(typeof o=="function"?o(a):o);n.current=!0,i("?"+u,c)},[i,a]);return[a,l]}function $N(e,t){t===void 0&&(t={});let n=j.useContext(FN);n==null&&et(!1);let{basename:r}=ON(nd.useViewTransitionState),a=ic(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Ra(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Ra(n.nextLocation.pathname,r)||n.nextLocation.pathname;return ed(a.pathname,l)!=null||ed(a.pathname,i)!=null}var qa=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(){}},_N={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Rn,Pd,ox,KN=(ox=class{constructor(){fe(this,Rn,_N);fe(this,Pd,!1)}setTimeoutProvider(e){ae(this,Rn,e)}setTimeout(e,t){return M(this,Rn).setTimeout(e,t)}clearTimeout(e){M(this,Rn).clearTimeout(e)}setInterval(e,t){return M(this,Rn).setInterval(e,t)}clearInterval(e){M(this,Rn).clearInterval(e)}},Rn=new WeakMap,Pd=new WeakMap,ox),yr=new KN;function UN(e){setTimeout(e,0)}var $r=typeof window>"u"||"Deno"in globalThis;function Bt(){}function BN(e,t){return typeof e=="function"?e(t):e}function rd(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ky(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nr(e,t){return typeof e=="function"?e(t):e}function ps(e,t){return typeof e=="function"?e(t):e}function rp(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Em(l,t.options))return!1}else if(!Vi(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||a&&a!==t.state.fetchStatus||i&&!i(t))}function ap(e,t){const{exact:n,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(_r(t.options.mutationKey)!==_r(i))return!1}else if(!Vi(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function Em(e,t){return((t==null?void 0:t.queryKeyHashFn)||_r)(e)}function _r(e){return JSON.stringify(e,(t,n)=>ad(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function Vi(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Vi(e[n],t[n])):!1}var qN=Object.prototype.hasOwnProperty;function Uy(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=ip(e)&&ip(t);if(!r&&!(ad(e)&&ad(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{yr.setTimeout(t,e)})}function id(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Uy(e,t):t}function QN(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function HN(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Dm=Symbol();function By(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Dm?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Pm(e,t){return typeof e=="function"?e(...t):!!e}function WN(e,t,n){let r=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),r||(r=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var br,On,ga,cx,GN=(cx=class extends qa{constructor(){super();fe(this,br);fe(this,On);fe(this,ga);ae(this,ga,t=>{if(!$r&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){M(this,On)||this.setEventListener(M(this,ga))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,On))==null||t.call(this),ae(this,On,void 0))}setEventListener(t){var n;ae(this,ga,t),(n=M(this,On))==null||n.call(this),ae(this,On,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){M(this,br)!==t&&(ae(this,br,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof M(this,br)=="boolean"?M(this,br):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},br=new WeakMap,On=new WeakMap,ga=new WeakMap,cx),Am=new GN;function ld(){let e,t;const n=new Promise((a,i)=>{e=a,t=i});n.status="pending",n.catch(()=>{});function r(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},n.reject=a=>{r({status:"rejected",reason:a}),t(a)},n}var ZN=UN;function JN(){let e=[],t=0,n=o=>{o()},r=o=>{o()},a=ZN;const i=o=>{t?e.push(o):a(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&a(()=>{r(()=>{o.forEach(c=>{n(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=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{a=o}}}var vt=JN(),ya,zn,va,ux,XN=(ux=class extends qa{constructor(){super();fe(this,ya,!0);fe(this,zn);fe(this,va);ae(this,va,t=>{if(!$r&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){M(this,zn)||this.setEventListener(M(this,va))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,zn))==null||t.call(this),ae(this,zn,void 0))}setEventListener(t){var n;ae(this,va,t),(n=M(this,zn))==null||n.call(this),ae(this,zn,t(this.setOnline.bind(this)))}setOnline(t){M(this,ya)!==t&&(ae(this,ya,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return M(this,ya)}},ya=new WeakMap,zn=new WeakMap,va=new WeakMap,ux),Io=new XN;function YN(e){return Math.min(1e3*2**e,3e4)}function qy(e){return(e??"online")==="online"?Io.isOnline():!0}var od=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Vy(e){let t=!1,n=0,r;const a=ld(),i=()=>a.status!=="pending",l=g=>{var N;if(!i()){const x=new od(g);p(x),(N=e.onCancel)==null||N.call(e,x)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Am.isFocused()&&(e.networkMode==="always"||Io.isOnline())&&e.canRun(),d=()=>qy(e.networkMode)&&e.canRun(),h=g=>{i()||(r==null||r(),a.resolve(g))},p=g=>{i()||(r==null||r(),a.reject(g))},m=()=>new Promise(g=>{var N;r=x=>{(i()||u())&&g(x)},(N=e.onPause)==null||N.call(e)}).then(()=>{var g;r=void 0,i()||(g=e.onContinue)==null||g.call(e)}),f=()=>{if(i())return;let g;const N=n===0?e.initialPromise:void 0;try{g=N??e.fn()}catch(x){g=Promise.reject(x)}Promise.resolve(g).then(h).catch(x=>{var C;if(i())return;const y=e.retry??($r?0:3),v=e.retryDelay??YN,w=typeof v=="function"?v(n,x):v,k=y===!0||typeof y=="number"&&nu()?void 0:m()).then(()=>{t?p(x):f()})})};return{promise:a,status:()=>a.status,cancel:l,continue:()=>(r==null||r(),a),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?f():m().then(f),a)}}var Nr,dx,Qy=(dx=class{constructor(){fe(this,Nr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rd(this.gcTime)&&ae(this,Nr,yr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??($r?1/0:5*60*1e3))}clearGcTimeout(){M(this,Nr)&&(yr.clearTimeout(M(this,Nr)),ae(this,Nr,void 0))}},Nr=new WeakMap,dx),wr,ja,fs,Sr,Nt,Yi,kr,Es,an,mx,ew=(mx=class extends Qy{constructor(t){super();fe(this,Es);fe(this,wr);fe(this,ja);fe(this,fs);fe(this,Sr);fe(this,Nt);fe(this,Yi);fe(this,kr);ae(this,kr,!1),ae(this,Yi,t.defaultOptions),this.setOptions(t.options),this.observers=[],ae(this,Sr,t.client),ae(this,fs,M(this,Sr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ae(this,wr,cp(this.options)),this.state=t.state??M(this,wr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=M(this,Nt))==null?void 0:t.promise}setOptions(t){if(this.options={...M(this,Yi),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=cp(this.options);n.data!==void 0&&(this.setState(op(n.data,n.dataUpdatedAt)),ae(this,wr,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&M(this,fs).remove(this)}setData(t,n){const r=id(this.state.data,t,this.options);return we(this,Es,an).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){we(this,Es,an).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,a;const n=(r=M(this,Nt))==null?void 0:r.promise;return(a=M(this,Nt))==null||a.cancel(t),n?n.then(Bt).catch(Bt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(M(this,wr))}isActive(){return this.observers.some(t=>ps(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Dm||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>nr(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:!Ky(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,Nt))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,Nt))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),M(this,fs).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(M(this,Nt)&&(M(this,kr)?M(this,Nt).cancel({revert:!0}):M(this,Nt).cancelRetry()),this.scheduleGc()),M(this,fs).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||we(this,Es,an).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,h,p,m,f,g,N,x,y,v;if(this.state.fetchStatus!=="idle"&&((c=M(this,Nt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(M(this,Nt))return M(this,Nt).continueRetry(),M(this,Nt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(k=>k.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,a=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(ae(this,kr,!0),r.signal)})},i=()=>{const w=By(this.options,n),C=(()=>{const A={client:M(this,Sr),queryKey:this.queryKey,meta:this.meta};return a(A),A})();return ae(this,kr,!1),this.options.persister?this.options.persister(w,C,this):w(C)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:M(this,Sr),state:this.state,fetchFn:i};return a(w),w})();(u=this.options.behavior)==null||u.onFetch(o,this),ae(this,ja,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&we(this,Es,an).call(this,{type:"fetch",meta:(h=o.fetchOptions)==null?void 0:h.meta}),ae(this,Nt,Vy({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof od&&w.revert&&this.setState({...M(this,ja),fetchStatus:"idle"}),r.abort()},onFail:(w,k)=>{we(this,Es,an).call(this,{type:"failed",failureCount:w,error:k})},onPause:()=>{we(this,Es,an).call(this,{type:"pause"})},onContinue:()=>{we(this,Es,an).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await M(this,Nt).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(m=(p=M(this,fs).config).onSuccess)==null||m.call(p,w,this),(g=(f=M(this,fs).config).onSettled)==null||g.call(f,w,this.state.error,this),w}catch(w){if(w instanceof od){if(w.silent)return M(this,Nt).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw we(this,Es,an).call(this,{type:"error",error:w}),(x=(N=M(this,fs).config).onError)==null||x.call(N,w,this),(v=(y=M(this,fs).config).onSettled)==null||v.call(y,this.state.data,w,this),w}finally{this.scheduleGc()}}},wr=new WeakMap,ja=new WeakMap,fs=new WeakMap,Sr=new WeakMap,Nt=new WeakMap,Yi=new WeakMap,kr=new WeakMap,Es=new WeakSet,an=function(t){const n=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,...op(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ae(this,ja,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=n(this.state),vt.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),M(this,fs).notify({query:this,type:"updated",action:t})})},mx);function Hy(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:qy(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function op(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function cp(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Zt,De,el,$t,Cr,ba,un,$n,tl,Na,wa,Er,Dr,_n,Sa,Re,mi,cd,ud,dd,md,hd,fd,pd,Wy,hx,tw=(hx=class extends qa{constructor(t,n){super();fe(this,Re);fe(this,Zt);fe(this,De);fe(this,el);fe(this,$t);fe(this,Cr);fe(this,ba);fe(this,un);fe(this,$n);fe(this,tl);fe(this,Na);fe(this,wa);fe(this,Er);fe(this,Dr);fe(this,_n);fe(this,Sa,new Set);this.options=n,ae(this,Zt,t),ae(this,$n,null),ae(this,un,ld()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(M(this,De).addObserver(this),up(M(this,De),this.options)?we(this,Re,mi).call(this):this.updateResult(),we(this,Re,md).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return xd(M(this,De),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return xd(M(this,De),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,we(this,Re,hd).call(this),we(this,Re,fd).call(this),M(this,De).removeObserver(this)}setOptions(t){const n=this.options,r=M(this,De);if(this.options=M(this,Zt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ps(this.options.enabled,M(this,De))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");we(this,Re,pd).call(this),M(this,De).setOptions(this.options),n._defaulted&&!To(this.options,n)&&M(this,Zt).getQueryCache().notify({type:"observerOptionsUpdated",query:M(this,De),observer:this});const a=this.hasListeners();a&&dp(M(this,De),r,this.options,n)&&we(this,Re,mi).call(this),this.updateResult(),a&&(M(this,De)!==r||ps(this.options.enabled,M(this,De))!==ps(n.enabled,M(this,De))||nr(this.options.staleTime,M(this,De))!==nr(n.staleTime,M(this,De)))&&we(this,Re,cd).call(this);const i=we(this,Re,ud).call(this);a&&(M(this,De)!==r||ps(this.options.enabled,M(this,De))!==ps(n.enabled,M(this,De))||i!==M(this,_n))&&we(this,Re,dd).call(this,i)}getOptimisticResult(t){const n=M(this,Zt).getQueryCache().build(M(this,Zt),t),r=this.createResult(n,t);return nw(this,r)&&(ae(this,$t,r),ae(this,ba,this.options),ae(this,Cr,M(this,De).state)),r}getCurrentResult(){return M(this,$t)}trackResult(t,n){return new Proxy(t,{get:(r,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&M(this,un).status==="pending"&&M(this,un).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){M(this,Sa).add(t)}getCurrentQuery(){return M(this,De)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=M(this,Zt).defaultQueryOptions(t),r=M(this,Zt).getQueryCache().build(M(this,Zt),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return we(this,Re,mi).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),M(this,$t)))}createResult(t,n){var E;const r=M(this,De),a=this.options,i=M(this,$t),l=M(this,Cr),o=M(this,ba),u=t!==r?t.state:M(this,el),{state:d}=t;let h={...d},p=!1,m;if(n._optimisticResults){const D=this.hasListeners(),$=!D&&up(t,n),L=D&&dp(t,r,n,a);($||L)&&(h={...h,...Hy(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:f,errorUpdatedAt:g,status:N}=h;m=h.data;let x=!1;if(n.placeholderData!==void 0&&m===void 0&&N==="pending"){let D;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(D=i.data,x=!0):D=typeof n.placeholderData=="function"?n.placeholderData((E=M(this,wa))==null?void 0:E.state.data,M(this,wa)):n.placeholderData,D!==void 0&&(N="success",m=id(i==null?void 0:i.data,D,n),p=!0)}if(n.select&&m!==void 0&&!x)if(i&&m===(l==null?void 0:l.data)&&n.select===M(this,tl))m=M(this,Na);else try{ae(this,tl,n.select),m=n.select(m),m=id(i==null?void 0:i.data,m,n),ae(this,Na,m),ae(this,$n,null)}catch(D){ae(this,$n,D)}M(this,$n)&&(f=M(this,$n),m=M(this,Na),g=Date.now(),N="error");const y=h.fetchStatus==="fetching",v=N==="pending",w=N==="error",k=v&&y,C=m!==void 0,S={status:N,fetchStatus:h.fetchStatus,isPending:v,isSuccess:N==="success",isError:w,isInitialLoading:k,isLoading:k,data:m,dataUpdatedAt:h.dataUpdatedAt,error:f,errorUpdatedAt:g,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:y,isRefetching:y&&!v,isLoadingError:w&&!C,isPaused:h.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:w&&C,isStale:Mm(t,n),refetch:this.refetch,promise:M(this,un),isEnabled:ps(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=S.data!==void 0,$=S.status==="error"&&!D,L=O=>{$?O.reject(S.error):D&&O.resolve(S.data)},U=()=>{const O=ae(this,un,S.promise=ld());L(O)},V=M(this,un);switch(V.status){case"pending":t.queryHash===r.queryHash&&L(V);break;case"fulfilled":($||S.data!==V.value)&&U();break;case"rejected":(!$||S.error!==V.reason)&&U();break}}return S}updateResult(){const t=M(this,$t),n=this.createResult(M(this,De),this.options);if(ae(this,Cr,M(this,De).state),ae(this,ba,this.options),M(this,Cr).data!==void 0&&ae(this,wa,M(this,De)),To(n,t))return;ae(this,$t,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!M(this,Sa).size)return!0;const l=new Set(i??M(this,Sa));return this.options.throwOnError&&l.add("error"),Object.keys(M(this,$t)).some(o=>{const c=o;return M(this,$t)[c]!==t[c]&&l.has(c)})};we(this,Re,Wy).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&we(this,Re,md).call(this)}},Zt=new WeakMap,De=new WeakMap,el=new WeakMap,$t=new WeakMap,Cr=new WeakMap,ba=new WeakMap,un=new WeakMap,$n=new WeakMap,tl=new WeakMap,Na=new WeakMap,wa=new WeakMap,Er=new WeakMap,Dr=new WeakMap,_n=new WeakMap,Sa=new WeakMap,Re=new WeakSet,mi=function(t){we(this,Re,pd).call(this);let n=M(this,De).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Bt)),n},cd=function(){we(this,Re,hd).call(this);const t=nr(this.options.staleTime,M(this,De));if($r||M(this,$t).isStale||!rd(t))return;const r=Ky(M(this,$t).dataUpdatedAt,t)+1;ae(this,Er,yr.setTimeout(()=>{M(this,$t).isStale||this.updateResult()},r))},ud=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(M(this,De)):this.options.refetchInterval)??!1},dd=function(t){we(this,Re,fd).call(this),ae(this,_n,t),!($r||ps(this.options.enabled,M(this,De))===!1||!rd(M(this,_n))||M(this,_n)===0)&&ae(this,Dr,yr.setInterval(()=>{(this.options.refetchIntervalInBackground||Am.isFocused())&&we(this,Re,mi).call(this)},M(this,_n)))},md=function(){we(this,Re,cd).call(this),we(this,Re,dd).call(this,we(this,Re,ud).call(this))},hd=function(){M(this,Er)&&(yr.clearTimeout(M(this,Er)),ae(this,Er,void 0))},fd=function(){M(this,Dr)&&(yr.clearInterval(M(this,Dr)),ae(this,Dr,void 0))},pd=function(){const t=M(this,Zt).getQueryCache().build(M(this,Zt),this.options);if(t===M(this,De))return;const n=M(this,De);ae(this,De,t),ae(this,el,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Wy=function(t){vt.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(M(this,$t))}),M(this,Zt).getQueryCache().notify({query:M(this,De),type:"observerResultsUpdated"})})},hx);function sw(e,t){return ps(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function up(e,t){return sw(e,t)||e.state.data!==void 0&&xd(e,t,t.refetchOnMount)}function xd(e,t,n){if(ps(t.enabled,e)!==!1&&nr(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Mm(e,t)}return!1}function dp(e,t,n,r){return(e!==t||ps(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Mm(e,n)}function Mm(e,t){return ps(t.enabled,e)!==!1&&e.isStaleByTime(nr(t.staleTime,e))}function nw(e,t){return!To(e.getCurrentResult(),t)}function mp(e){return{onFetch:(t,n)=>{var d,h,p,m,f;const r=t.options,a=(p=(h=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:p.direction,i=((m=t.state.data)==null?void 0:m.pages)||[],l=((f=t.state.data)==null?void 0:f.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let g=!1;const N=v=>{WN(v,()=>t.signal,()=>g=!0)},x=By(t.options,t.fetchOptions),y=async(v,w,k)=>{if(g)return Promise.reject();if(w==null&&v.pages.length)return Promise.resolve(v);const A=(()=>{const $={client:t.client,queryKey:t.queryKey,pageParam:w,direction:k?"backward":"forward",meta:t.options.meta};return N($),$})(),S=await x(A),{maxPages:E}=t.options,D=k?HN:QN;return{pages:D(v.pages,S,E),pageParams:D(v.pageParams,w,E)}};if(a&&i.length){const v=a==="backward",w=v?rw:hp,k={pages:i,pageParams:l},C=w(r,k);o=await y(k,C,v)}else{const v=e??i.length;do{const w=c===0?l[0]??r.initialPageParam:hp(r,o);if(c>0&&w==null)break;o=await y(o,w),c++}while(c{var g,N;return(N=(g=t.options).persister)==null?void 0:N.call(g,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function hp(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function rw(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var sl,qs,_t,Pr,Vs,Pn,fx,aw=(fx=class extends Qy{constructor(t){super();fe(this,Vs);fe(this,sl);fe(this,qs);fe(this,_t);fe(this,Pr);ae(this,sl,t.client),this.mutationId=t.mutationId,ae(this,_t,t.mutationCache),ae(this,qs,[]),this.state=t.state||Gy(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){M(this,qs).includes(t)||(M(this,qs).push(t),this.clearGcTimeout(),M(this,_t).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ae(this,qs,M(this,qs).filter(n=>n!==t)),this.scheduleGc(),M(this,_t).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){M(this,qs).length||(this.state.status==="pending"?this.scheduleGc():M(this,_t).remove(this))}continue(){var t;return((t=M(this,Pr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,h,p,m,f,g,N,x,y,v,w,k,C,A,S,E;const n=()=>{we(this,Vs,Pn).call(this,{type:"continue"})},r={client:M(this,sl),meta:this.options.meta,mutationKey:this.options.mutationKey};ae(this,Pr,Vy({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(D,$)=>{we(this,Vs,Pn).call(this,{type:"failed",failureCount:D,error:$})},onPause:()=>{we(this,Vs,Pn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>M(this,_t).canRun(this)}));const a=this.state.status==="pending",i=!M(this,Pr).canStart();try{if(a)n();else{we(this,Vs,Pn).call(this,{type:"pending",variables:t,isPaused:i}),await((o=(l=M(this,_t).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&&we(this,Vs,Pn).call(this,{type:"pending",context:$,variables:t,isPaused:i})}const D=await M(this,Pr).start();return await((h=(d=M(this,_t).config).onSuccess)==null?void 0:h.call(d,D,t,this.state.context,this,r)),await((m=(p=this.options).onSuccess)==null?void 0:m.call(p,D,t,this.state.context,r)),await((g=(f=M(this,_t).config).onSettled)==null?void 0:g.call(f,D,null,this.state.variables,this.state.context,this,r)),await((x=(N=this.options).onSettled)==null?void 0:x.call(N,D,null,t,this.state.context,r)),we(this,Vs,Pn).call(this,{type:"success",data:D}),D}catch(D){try{await((v=(y=M(this,_t).config).onError)==null?void 0:v.call(y,D,t,this.state.context,this,r))}catch($){Promise.reject($)}try{await((k=(w=this.options).onError)==null?void 0:k.call(w,D,t,this.state.context,r))}catch($){Promise.reject($)}try{await((A=(C=M(this,_t).config).onSettled)==null?void 0:A.call(C,void 0,D,this.state.variables,this.state.context,this,r))}catch($){Promise.reject($)}try{await((E=(S=this.options).onSettled)==null?void 0:E.call(S,void 0,D,t,this.state.context,r))}catch($){Promise.reject($)}throw we(this,Vs,Pn).call(this,{type:"error",error:D}),D}finally{M(this,_t).runNext(this)}}},sl=new WeakMap,qs=new WeakMap,_t=new WeakMap,Pr=new WeakMap,Vs=new WeakSet,Pn=function(t){const n=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=n(this.state),vt.batch(()=>{M(this,qs).forEach(r=>{r.onMutationUpdate(t)}),M(this,_t).notify({mutation:this,type:"updated",action:t})})},fx);function Gy(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var dn,Ds,nl,px,iw=(px=class extends qa{constructor(t={}){super();fe(this,dn);fe(this,Ds);fe(this,nl);this.config=t,ae(this,dn,new Set),ae(this,Ds,new Map),ae(this,nl,0)}build(t,n,r){const a=new aw({client:t,mutationCache:this,mutationId:++jl(this,nl)._,options:t.defaultMutationOptions(n),state:r});return this.add(a),a}add(t){M(this,dn).add(t);const n=zl(t);if(typeof n=="string"){const r=M(this,Ds).get(n);r?r.push(t):M(this,Ds).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(M(this,dn).delete(t)){const n=zl(t);if(typeof n=="string"){const r=M(this,Ds).get(n);if(r)if(r.length>1){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}else r[0]===t&&M(this,Ds).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=zl(t);if(typeof n=="string"){const r=M(this,Ds).get(n),a=r==null?void 0:r.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var r;const n=zl(t);if(typeof n=="string"){const a=(r=M(this,Ds).get(n))==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(){vt.batch(()=>{M(this,dn).forEach(t=>{this.notify({type:"removed",mutation:t})}),M(this,dn).clear(),M(this,Ds).clear()})}getAll(){return Array.from(M(this,dn))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ap(n,r))}findAll(t={}){return this.getAll().filter(n=>ap(t,n))}notify(t){vt.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return vt.batch(()=>Promise.all(t.map(n=>n.continue().catch(Bt))))}},dn=new WeakMap,Ds=new WeakMap,nl=new WeakMap,px);function zl(e){var t;return(t=e.options.scope)==null?void 0:t.id}var mn,Kn,Jt,hn,yn,eo,gd,xx,lw=(xx=class extends qa{constructor(n,r){super();fe(this,yn);fe(this,mn);fe(this,Kn);fe(this,Jt);fe(this,hn);ae(this,mn,n),this.setOptions(r),this.bindMethods(),we(this,yn,eo).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var a;const r=this.options;this.options=M(this,mn).defaultMutationOptions(n),To(this.options,r)||M(this,mn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:M(this,Jt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&_r(r.mutationKey)!==_r(this.options.mutationKey)?this.reset():((a=M(this,Jt))==null?void 0:a.state.status)==="pending"&&M(this,Jt).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=M(this,Jt))==null||n.removeObserver(this)}onMutationUpdate(n){we(this,yn,eo).call(this),we(this,yn,gd).call(this,n)}getCurrentResult(){return M(this,Kn)}reset(){var n;(n=M(this,Jt))==null||n.removeObserver(this),ae(this,Jt,void 0),we(this,yn,eo).call(this),we(this,yn,gd).call(this)}mutate(n,r){var a;return ae(this,hn,r),(a=M(this,Jt))==null||a.removeObserver(this),ae(this,Jt,M(this,mn).getMutationCache().build(M(this,mn),this.options)),M(this,Jt).addObserver(this),M(this,Jt).execute(n)}},mn=new WeakMap,Kn=new WeakMap,Jt=new WeakMap,hn=new WeakMap,yn=new WeakSet,eo=function(){var r;const n=((r=M(this,Jt))==null?void 0:r.state)??Gy();ae(this,Kn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},gd=function(n){vt.batch(()=>{var r,a,i,l,o,c,u,d;if(M(this,hn)&&this.hasListeners()){const h=M(this,Kn).variables,p=M(this,Kn).context,m={client:M(this,mn),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(a=(r=M(this,hn)).onSuccess)==null||a.call(r,n.data,h,p,m)}catch(f){Promise.reject(f)}try{(l=(i=M(this,hn)).onSettled)==null||l.call(i,n.data,null,h,p,m)}catch(f){Promise.reject(f)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=M(this,hn)).onError)==null||c.call(o,n.error,h,p,m)}catch(f){Promise.reject(f)}try{(d=(u=M(this,hn)).onSettled)==null||d.call(u,void 0,n.error,h,p,m)}catch(f){Promise.reject(f)}}}this.listeners.forEach(h=>{h(M(this,Kn))})})},xx),Qs,gx,ow=(gx=class extends qa{constructor(t={}){super();fe(this,Qs);this.config=t,ae(this,Qs,new Map)}build(t,n,r){const a=n.queryKey,i=n.queryHash??Em(a,n);let l=this.get(i);return l||(l=new ew({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(l)),l}add(t){M(this,Qs).has(t.queryHash)||(M(this,Qs).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=M(this,Qs).get(t.queryHash);n&&(t.destroy(),n===t&&M(this,Qs).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){vt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return M(this,Qs).get(t)}getAll(){return[...M(this,Qs).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>rp(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>rp(t,r)):n}notify(t){vt.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){vt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){vt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qs=new WeakMap,gx),it,Un,Bn,ka,Ca,qn,Ea,Da,yx,cw=(yx=class{constructor(e={}){fe(this,it);fe(this,Un);fe(this,Bn);fe(this,ka);fe(this,Ca);fe(this,qn);fe(this,Ea);fe(this,Da);ae(this,it,e.queryCache||new ow),ae(this,Un,e.mutationCache||new iw),ae(this,Bn,e.defaultOptions||{}),ae(this,ka,new Map),ae(this,Ca,new Map),ae(this,qn,0)}mount(){jl(this,qn)._++,M(this,qn)===1&&(ae(this,Ea,Am.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,it).onFocus())})),ae(this,Da,Io.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,it).onOnline())})))}unmount(){var e,t;jl(this,qn)._--,M(this,qn)===0&&((e=M(this,Ea))==null||e.call(this),ae(this,Ea,void 0),(t=M(this,Da))==null||t.call(this),ae(this,Da,void 0))}isFetching(e){return M(this,it).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return M(this,Un).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,it).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=M(this,it).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(nr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return M(this,it).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),a=M(this,it).get(r.queryHash),i=a==null?void 0:a.state.data,l=BN(t,i);if(l!==void 0)return M(this,it).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return vt.batch(()=>M(this,it).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,it).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=M(this,it);vt.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=M(this,it);return vt.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=vt.batch(()=>M(this,it).findAll(e).map(a=>a.cancel(n)));return Promise.all(r).then(Bt).catch(Bt)}invalidateQueries(e,t={}){return vt.batch(()=>(M(this,it).findAll(e).forEach(n=>{n.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 n={...t,cancelRefetch:t.cancelRefetch??!0},r=vt.batch(()=>M(this,it).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(Bt)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Bt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=M(this,it).build(this,t);return n.isStaleByTime(nr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Bt).catch(Bt)}fetchInfiniteQuery(e){return e.behavior=mp(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Bt).catch(Bt)}ensureInfiniteQueryData(e){return e.behavior=mp(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Io.isOnline()?M(this,Un).resumePausedMutations():Promise.resolve()}getQueryCache(){return M(this,it)}getMutationCache(){return M(this,Un)}getDefaultOptions(){return M(this,Bn)}setDefaultOptions(e){ae(this,Bn,e)}setQueryDefaults(e,t){M(this,ka).set(_r(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...M(this,ka).values()],n={};return t.forEach(r=>{Vi(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){M(this,Ca).set(_r(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...M(this,Ca).values()],n={};return t.forEach(r=>{Vi(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...M(this,Bn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Em(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===Dm&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...M(this,Bn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){M(this,it).clear(),M(this,Un).clear()}},it=new WeakMap,Un=new WeakMap,Bn=new WeakMap,ka=new WeakMap,Ca=new WeakMap,qn=new WeakMap,Ea=new WeakMap,Da=new WeakMap,yx),Zy=j.createContext(void 0),xe=e=>{const t=j.useContext(Zy);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},uw=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Zy.Provider,{value:e,children:t})),Jy=j.createContext(!1),dw=()=>j.useContext(Jy);Jy.Provider;function mw(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var hw=j.createContext(mw()),fw=()=>j.useContext(hw),pw=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Pm(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},xw=e=>{j.useEffect(()=>{e.clearReset()},[e])},gw=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||Pm(n,[e.error,r])),yw=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...a)=>n(r(...a)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},vw=(e,t)=>e.isLoading&&e.isFetching&&!t,jw=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,fp=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function bw(e,t,n){var p,m,f,g;const r=dw(),a=fw(),i=xe(),l=i.defaultQueryOptions(e);(m=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||m.call(p,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",yw(l),pw(l,a,o),xw(a);const c=!i.getQueryCache().get(l.queryHash),[u]=j.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),h=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(N=>{const x=h?u.subscribe(vt.batchCalls(N)):Bt;return u.updateResult(),x},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),j.useEffect(()=>{u.setOptions(l)},[l,u]),jw(l,d))throw fp(l,u,a);if(gw({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&&!$r&&vw(d,r)){const N=c?fp(l,u,a):o==null?void 0:o.promise;N==null||N.catch(Bt).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function de(e,t){return bw(e,tw)}function H(e,t){const n=xe(),[r]=j.useState(()=>new lw(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const a=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(vt.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=j.useCallback((l,o)=>{r.mutate(l,o).catch(Bt)},[r]);if(a.error&&Pm(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}let Nw={data:""},ww=e=>{if(typeof window=="object"){let t=(e?e.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return t.nonce=window.__nonce__,t.parentNode||(e||document.head).appendChild(t),t.firstChild}return e||Nw},Sw=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,kw=/\/\*[^]*?\*\/| +/g,pp=/\n+/g,In=(e,t)=>{let n="",r="",a="";for(let i in e){let l=e[i];i[0]=="@"?i[1]=="i"?n=i+" "+l+";":r+=i[1]=="f"?In(l,i):i+"{"+In(l,i[1]=="k"?"":t)+"}":typeof l=="object"?r+=In(l,t?t.replace(/([^,])+/g,o=>i.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,c=>/&/.test(c)?c.replace(/&/g,o):o?o+" "+c:c)):i):l!=null&&(i=/^--/.test(i)?i:i.replace(/[A-Z]/g,"-$&").toLowerCase(),a+=In.p?In.p(i,l):i+":"+l+";")}return n+(t&&a?t+"{"+a+"}":a)+r},nn={},Xy=e=>{if(typeof e=="object"){let t="";for(let n in e)t+=n+Xy(e[n]);return t}return e},Cw=(e,t,n,r,a)=>{let i=Xy(e),l=nn[i]||(nn[i]=(c=>{let u=0,d=11;for(;u>>0;return"go"+d})(i));if(!nn[l]){let c=i!==e?e:(u=>{let d,h,p=[{}];for(;d=Sw.exec(u.replace(kw,""));)d[4]?p.shift():d[3]?(h=d[3].replace(pp," ").trim(),p.unshift(p[0][h]=p[0][h]||{})):p[0][d[1]]=d[2].replace(pp," ").trim();return p[0]})(e);nn[l]=In(a?{["@keyframes "+l]:c}:c,n?"":"."+l)}let o=n&&nn.g?nn.g:null;return n&&(nn.g=nn[l]),((c,u,d,h)=>{h?u.data=u.data.replace(h,c):u.data.indexOf(c)===-1&&(u.data=d?c+u.data:u.data+c)})(nn[l],t,r,o),l},Ew=(e,t,n)=>e.reduce((r,a,i)=>{let l=t[i];if(l&&l.call){let o=l(n),c=o&&o.props&&o.props.className||/^go/.test(o)&&o;l=c?"."+c:o&&typeof o=="object"?o.props?"":In(o,""):o===!1?"":o}return r+a+(l??"")},"");function oc(e){let t=this||{},n=e.call?e(t.p):e;return Cw(n.unshift?n.raw?Ew(n,[].slice.call(arguments,1),t.p):n.reduce((r,a)=>Object.assign(r,a&&a.call?a(t.p):a),{}):n,ww(t.target),t.g,t.o,t.k)}let Yy,yd,vd;oc.bind({g:1});let wn=oc.bind({k:1});function Dw(e,t,n,r){In.p=t,Yy=e,yd=n,vd=r}function cr(e,t){let n=this||{};return function(){let r=arguments;function a(i,l){let o=Object.assign({},i),c=o.className||a.className;n.p=Object.assign({theme:yd&&yd()},o),n.o=/ *go\d+/.test(c),o.className=oc.apply(n,r)+(c?" "+c:"");let u=e;return e[0]&&(u=o.as||e,delete o.as),vd&&u[0]&&vd(o),Yy(u,o)}return a}}var Pw=e=>typeof e=="function",Lo=(e,t)=>Pw(e)?e(t):e,Aw=(()=>{let e=0;return()=>(++e).toString()})(),e0=(()=>{let e;return()=>{if(e===void 0&&typeof window<"u"){let t=matchMedia("(prefers-reduced-motion: reduce)");e=!t||t.matches}return e}})(),Mw=20,Fm="default",t0=(e,t)=>{let{toastLimit:n}=e.settings;switch(t.type){case 0:return{...e,toasts:[t.toast,...e.toasts].slice(0,n)};case 1:return{...e,toasts:e.toasts.map(l=>l.id===t.toast.id?{...l,...t.toast}:l)};case 2:let{toast:r}=t;return t0(e,{type:e.toasts.find(l=>l.id===r.id)?1:0,toast:r});case 3:let{toastId:a}=t;return{...e,toasts:e.toasts.map(l=>l.id===a||a===void 0?{...l,dismissed:!0,visible:!1}:l)};case 4:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(l=>l.id!==t.toastId)};case 5:return{...e,pausedAt:t.time};case 6:let i=t.time-(e.pausedAt||0);return{...e,pausedAt:void 0,toasts:e.toasts.map(l=>({...l,pauseDuration:l.pauseDuration+i}))}}},to=[],s0={toasts:[],pausedAt:void 0,settings:{toastLimit:Mw}},Ws={},n0=(e,t=Fm)=>{Ws[t]=t0(Ws[t]||s0,e),to.forEach(([n,r])=>{n===t&&r(Ws[t])})},r0=e=>Object.keys(Ws).forEach(t=>n0(e,t)),Fw=e=>Object.keys(Ws).find(t=>Ws[t].toasts.some(n=>n.id===e)),cc=(e=Fm)=>t=>{n0(t,e)},Tw={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Iw=(e={},t=Fm)=>{let[n,r]=j.useState(Ws[t]||s0),a=j.useRef(Ws[t]);j.useEffect(()=>(a.current!==Ws[t]&&r(Ws[t]),to.push([t,r]),()=>{let l=to.findIndex(([o])=>o===t);l>-1&&to.splice(l,1)}),[t]);let i=n.toasts.map(l=>{var o,c,u;return{...e,...e[l.type],...l,removeDelay:l.removeDelay||((o=e[l.type])==null?void 0:o.removeDelay)||(e==null?void 0:e.removeDelay),duration:l.duration||((c=e[l.type])==null?void 0:c.duration)||(e==null?void 0:e.duration)||Tw[l.type],style:{...e.style,...(u=e[l.type])==null?void 0:u.style,...l.style}}});return{...n,toasts:i}},Lw=(e,t="blank",n)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:t,ariaProps:{role:"status","aria-live":"polite"},message:e,pauseDuration:0,...n,id:(n==null?void 0:n.id)||Aw()}),cl=e=>(t,n)=>{let r=Lw(t,e,n);return cc(r.toasterId||Fw(r.id))({type:2,toast:r}),r.id},jt=(e,t)=>cl("blank")(e,t);jt.error=cl("error");jt.success=cl("success");jt.loading=cl("loading");jt.custom=cl("custom");jt.dismiss=(e,t)=>{let n={type:3,toastId:e};t?cc(t)(n):r0(n)};jt.dismissAll=e=>jt.dismiss(void 0,e);jt.remove=(e,t)=>{let n={type:4,toastId:e};t?cc(t)(n):r0(n)};jt.removeAll=e=>jt.remove(void 0,e);jt.promise=(e,t,n)=>{let r=jt.loading(t.loading,{...n,...n==null?void 0:n.loading});return typeof e=="function"&&(e=e()),e.then(a=>{let i=t.success?Lo(t.success,a):void 0;return i?jt.success(i,{id:r,...n,...n==null?void 0:n.success}):jt.dismiss(r),a}).catch(a=>{let i=t.error?Lo(t.error,a):void 0;i?jt.error(i,{id:r,...n,...n==null?void 0:n.error}):jt.dismiss(r)}),e};var Rw=1e3,Ow=(e,t="default")=>{let{toasts:n,pausedAt:r}=Iw(e,t),a=j.useRef(new Map).current,i=j.useCallback((h,p=Rw)=>{if(a.has(h))return;let m=setTimeout(()=>{a.delete(h),l({type:4,toastId:h})},p);a.set(h,m)},[]);j.useEffect(()=>{if(r)return;let h=Date.now(),p=n.map(m=>{if(m.duration===1/0)return;let f=(m.duration||0)+m.pauseDuration-(h-m.createdAt);if(f<0){m.visible&&jt.dismiss(m.id);return}return setTimeout(()=>jt.dismiss(m.id,t),f)});return()=>{p.forEach(m=>m&&clearTimeout(m))}},[n,r,t]);let l=j.useCallback(cc(t),[t]),o=j.useCallback(()=>{l({type:5,time:Date.now()})},[l]),c=j.useCallback((h,p)=>{l({type:1,toast:{id:h,height:p}})},[l]),u=j.useCallback(()=>{r&&l({type:6,time:Date.now()})},[r,l]),d=j.useCallback((h,p)=>{let{reverseOrder:m=!1,gutter:f=8,defaultPosition:g}=p||{},N=n.filter(v=>(v.position||g)===(h.position||g)&&v.height),x=N.findIndex(v=>v.id===h.id),y=N.filter((v,w)=>wv.visible).slice(...m?[y+1]:[0,y]).reduce((v,w)=>v+(w.height||0)+f,0)},[n]);return j.useEffect(()=>{n.forEach(h=>{if(h.dismissed)i(h.id,h.removeDelay);else{let p=a.get(h.id);p&&(clearTimeout(p),a.delete(h.id))}})},[n,i]),{toasts:n,handlers:{updateHeight:c,startPause:o,endPause:u,calculateOffset:d}}},zw=wn` +from { + transform: scale(0) rotate(45deg); + opacity: 0; +} +to { + transform: scale(1) rotate(45deg); + opacity: 1; +}`,$w=wn` +from { + transform: scale(0); + opacity: 0; +} +to { + transform: scale(1); + opacity: 1; +}`,_w=wn` +from { + transform: scale(0) rotate(90deg); + opacity: 0; +} +to { + transform: scale(1) rotate(90deg); + opacity: 1; +}`,Kw=cr("div")` + width: 20px; + opacity: 0; + height: 20px; + border-radius: 10px; + background: ${e=>e.primary||"#ff4b4b"}; + position: relative; + transform: rotate(45deg); + + animation: ${zw} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) + forwards; + animation-delay: 100ms; + + &:after, + &:before { + content: ''; + animation: ${$w} 0.15s ease-out forwards; + animation-delay: 150ms; + position: absolute; + border-radius: 3px; + opacity: 0; + background: ${e=>e.secondary||"#fff"}; + bottom: 9px; + left: 4px; + height: 2px; + width: 12px; + } + + &:before { + animation: ${_w} 0.15s ease-out forwards; + animation-delay: 180ms; + transform: rotate(90deg); + } +`,Uw=wn` + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +`,Bw=cr("div")` + width: 12px; + height: 12px; + box-sizing: border-box; + border: 2px solid; + border-radius: 100%; + border-color: ${e=>e.secondary||"#e0e0e0"}; + border-right-color: ${e=>e.primary||"#616161"}; + animation: ${Uw} 1s linear infinite; +`,qw=wn` +from { + transform: scale(0) rotate(45deg); + opacity: 0; +} +to { + transform: scale(1) rotate(45deg); + opacity: 1; +}`,Vw=wn` +0% { + height: 0; + width: 0; + opacity: 0; +} +40% { + height: 0; + width: 6px; + opacity: 1; +} +100% { + opacity: 1; + height: 10px; +}`,Qw=cr("div")` + width: 20px; + opacity: 0; + height: 20px; + border-radius: 10px; + background: ${e=>e.primary||"#61d345"}; + position: relative; + transform: rotate(45deg); + + animation: ${qw} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) + forwards; + animation-delay: 100ms; + &:after { + content: ''; + box-sizing: border-box; + animation: ${Vw} 0.2s ease-out forwards; + opacity: 0; + animation-delay: 200ms; + position: absolute; + border-right: 2px solid; + border-bottom: 2px solid; + border-color: ${e=>e.secondary||"#fff"}; + bottom: 6px; + left: 6px; + height: 10px; + width: 6px; + } +`,Hw=cr("div")` + position: absolute; +`,Ww=cr("div")` + position: relative; + display: flex; + justify-content: center; + align-items: center; + min-width: 20px; + min-height: 20px; +`,Gw=wn` +from { + transform: scale(0.6); + opacity: 0.4; +} +to { + transform: scale(1); + opacity: 1; +}`,Zw=cr("div")` + position: relative; + transform: scale(0.6); + opacity: 0.4; + min-width: 20px; + animation: ${Gw} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275) + forwards; +`,Jw=({toast:e})=>{let{icon:t,type:n,iconTheme:r}=e;return t!==void 0?typeof t=="string"?j.createElement(Zw,null,t):t:n==="blank"?null:j.createElement(Ww,null,j.createElement(Bw,{...r}),n!=="loading"&&j.createElement(Hw,null,n==="error"?j.createElement(Kw,{...r}):j.createElement(Qw,{...r})))},Xw=e=>` +0% {transform: translate3d(0,${e*-200}%,0) scale(.6); opacity:.5;} +100% {transform: translate3d(0,0,0) scale(1); opacity:1;} +`,Yw=e=>` +0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;} +100% {transform: translate3d(0,${e*-150}%,-1px) scale(.6); opacity:0;} +`,e1="0%{opacity:0;} 100%{opacity:1;}",t1="0%{opacity:1;} 100%{opacity:0;}",s1=cr("div")` + display: flex; + align-items: center; + background: #fff; + color: #363636; + line-height: 1.3; + will-change: transform; + box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05); + max-width: 350px; + pointer-events: auto; + padding: 8px 10px; + border-radius: 8px; +`,n1=cr("div")` + display: flex; + justify-content: center; + margin: 4px 10px; + color: inherit; + flex: 1 1 auto; + white-space: pre-line; +`,r1=(e,t)=>{let n=e.includes("top")?1:-1,[r,a]=e0()?[e1,t1]:[Xw(n),Yw(n)];return{animation:t?`${wn(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${wn(a)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},a1=j.memo(({toast:e,position:t,style:n,children:r})=>{let a=e.height?r1(e.position||t||"top-center",e.visible):{opacity:0},i=j.createElement(Jw,{toast:e}),l=j.createElement(n1,{...e.ariaProps},Lo(e.message,e));return j.createElement(s1,{className:e.className,style:{...a,...n,...e.style}},typeof r=="function"?r({icon:i,message:l}):j.createElement(j.Fragment,null,i,l))});Dw(j.createElement);var i1=({id:e,className:t,style:n,onHeightUpdate:r,children:a})=>{let i=j.useCallback(l=>{if(l){let o=()=>{let c=l.getBoundingClientRect().height;r(e,c)};o(),new MutationObserver(o).observe(l,{subtree:!0,childList:!0,characterData:!0})}},[e,r]);return j.createElement("div",{ref:i,className:t,style:n},a)},l1=(e,t)=>{let n=e.includes("top"),r=n?{top:0}:{bottom:0},a=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:e0()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...a}},o1=oc` + z-index: 9999; + > * { + pointer-events: auto; + } +`,$l=16,c1=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:a,toasterId:i,containerStyle:l,containerClassName:o})=>{let{toasts:c,handlers:u}=Ow(n,i);return j.createElement("div",{"data-rht-toaster":i||"",style:{position:"fixed",zIndex:9999,top:$l,left:$l,right:$l,bottom:$l,pointerEvents:"none",...l},className:o,onMouseEnter:u.startPause,onMouseLeave:u.endPause},c.map(d=>{let h=d.position||t,p=u.calculateOffset(d,{reverseOrder:e,gutter:r,defaultPosition:t}),m=l1(h,p);return j.createElement(i1,{id:d.id,key:d.id,onHeightUpdate:u.updateHeight,className:d.visible?o1:"",style:m},d.type==="custom"?Lo(d.message,d):a?a(d):j.createElement(a1,{toast:d,position:h}))}))},Ue=jt;function a0(e,t){return function(){return e.apply(t,arguments)}}const{toString:u1}=Object.prototype,{getPrototypeOf:Tm}=Object,{iterator:uc,toStringTag:i0}=Symbol,dc=(e=>t=>{const n=u1.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),zs=e=>(e=e.toLowerCase(),t=>dc(t)===e),mc=e=>t=>typeof t===e,{isArray:Va}=Array,Oa=mc("undefined");function ul(e){return e!==null&&!Oa(e)&&e.constructor!==null&&!Oa(e.constructor)&&rs(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const l0=zs("ArrayBuffer");function d1(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&l0(e.buffer),t}const m1=mc("string"),rs=mc("function"),o0=mc("number"),dl=e=>e!==null&&typeof e=="object",h1=e=>e===!0||e===!1,so=e=>{if(dc(e)!=="object")return!1;const t=Tm(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(i0 in e)&&!(uc in e)},f1=e=>{if(!dl(e)||ul(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},p1=zs("Date"),x1=zs("File"),g1=zs("Blob"),y1=zs("FileList"),v1=e=>dl(e)&&rs(e.pipe),j1=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||rs(e.append)&&((t=dc(e))==="formdata"||t==="object"&&rs(e.toString)&&e.toString()==="[object FormData]"))},b1=zs("URLSearchParams"),[N1,w1,S1,k1]=["ReadableStream","Request","Response","Headers"].map(zs),C1=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ml(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,a;if(typeof e!="object"&&(e=[e]),Va(e))for(r=0,a=e.length;r0;)if(a=n[r],t===a.toLowerCase())return a;return null}const vr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,u0=e=>!Oa(e)&&e!==vr;function jd(){const{caseless:e,skipUndefined:t}=u0(this)&&this||{},n={},r=(a,i)=>{const l=e&&c0(n,i)||i;so(n[l])&&so(a)?n[l]=jd(n[l],a):so(a)?n[l]=jd({},a):Va(a)?n[l]=a.slice():(!t||!Oa(a))&&(n[l]=a)};for(let a=0,i=arguments.length;a(ml(t,(a,i)=>{n&&rs(a)?e[i]=a0(a,n):e[i]=a},{allOwnKeys:r}),e),D1=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),P1=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},A1=(e,t,n,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=n!==!1&&Tm(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},M1=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},F1=e=>{if(!e)return null;if(Va(e))return e;let t=e.length;if(!o0(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},T1=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Tm(Uint8Array)),I1=(e,t)=>{const r=(e&&e[uc]).call(e);let a;for(;(a=r.next())&&!a.done;){const i=a.value;t.call(e,i[0],i[1])}},L1=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},R1=zs("HTMLFormElement"),O1=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),xp=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),z1=zs("RegExp"),d0=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};ml(n,(a,i)=>{let l;(l=t(a,i,e))!==!1&&(r[i]=l||a)}),Object.defineProperties(e,r)},$1=e=>{d0(e,(t,n)=>{if(rs(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(rs(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},_1=(e,t)=>{const n={},r=a=>{a.forEach(i=>{n[i]=!0})};return Va(e)?r(e):r(String(e).split(t)),n},K1=()=>{},U1=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function B1(e){return!!(e&&rs(e.append)&&e[i0]==="FormData"&&e[uc])}const q1=e=>{const t=new Array(10),n=(r,a)=>{if(dl(r)){if(t.indexOf(r)>=0)return;if(ul(r))return r;if(!("toJSON"in r)){t[a]=r;const i=Va(r)?[]:{};return ml(r,(l,o)=>{const c=n(l,a+1);!Oa(c)&&(i[o]=c)}),t[a]=void 0,i}}return r};return n(e,0)},V1=zs("AsyncFunction"),Q1=e=>e&&(dl(e)||rs(e))&&rs(e.then)&&rs(e.catch),m0=((e,t)=>e?setImmediate:t?((n,r)=>(vr.addEventListener("message",({source:a,data:i})=>{a===vr&&i===n&&r.length&&r.shift()()},!1),a=>{r.push(a),vr.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",rs(vr.postMessage)),H1=typeof queueMicrotask<"u"?queueMicrotask.bind(vr):typeof process<"u"&&process.nextTick||m0,W1=e=>e!=null&&rs(e[uc]),K={isArray:Va,isArrayBuffer:l0,isBuffer:ul,isFormData:j1,isArrayBufferView:d1,isString:m1,isNumber:o0,isBoolean:h1,isObject:dl,isPlainObject:so,isEmptyObject:f1,isReadableStream:N1,isRequest:w1,isResponse:S1,isHeaders:k1,isUndefined:Oa,isDate:p1,isFile:x1,isBlob:g1,isRegExp:z1,isFunction:rs,isStream:v1,isURLSearchParams:b1,isTypedArray:T1,isFileList:y1,forEach:ml,merge:jd,extend:E1,trim:C1,stripBOM:D1,inherits:P1,toFlatObject:A1,kindOf:dc,kindOfTest:zs,endsWith:M1,toArray:F1,forEachEntry:I1,matchAll:L1,isHTMLForm:R1,hasOwnProperty:xp,hasOwnProp:xp,reduceDescriptors:d0,freezeMethods:$1,toObjectSet:_1,toCamelCase:O1,noop:K1,toFiniteNumber:U1,findKey:c0,global:vr,isContextDefined:u0,isSpecCompliantForm:B1,toJSONObject:q1,isAsyncFn:V1,isThenable:Q1,setImmediate:m0,asap:H1,isIterable:W1};function Ne(e,t,n,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),n&&(this.config=n),r&&(this.request=r),a&&(this.response=a,this.status=a.status?a.status:null)}K.inherits(Ne,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:K.toJSONObject(this.config),code:this.code,status:this.status}}});const h0=Ne.prototype,f0={};["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=>{f0[e]={value:e}});Object.defineProperties(Ne,f0);Object.defineProperty(h0,"isAxiosError",{value:!0});Ne.from=(e,t,n,r,a,i)=>{const l=Object.create(h0);K.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 Ne.call(l,o,c,n,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 G1=null;function bd(e){return K.isPlainObject(e)||K.isArray(e)}function p0(e){return K.endsWith(e,"[]")?e.slice(0,-2):e}function gp(e,t,n){return e?e.concat(t).map(function(a,i){return a=p0(a),!n&&i?"["+a+"]":a}).join(n?".":""):t}function Z1(e){return K.isArray(e)&&!e.some(bd)}const J1=K.toFlatObject(K,{},null,function(t){return/^is[A-Z]/.test(t)});function hc(e,t,n){if(!K.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=K.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,N){return!K.isUndefined(N[g])});const r=n.metaTokens,a=n.visitor||d,i=n.dots,l=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&K.isSpecCompliantForm(t);if(!K.isFunction(a))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(K.isDate(f))return f.toISOString();if(K.isBoolean(f))return f.toString();if(!c&&K.isBlob(f))throw new Ne("Blob is not supported. Use a Buffer instead.");return K.isArrayBuffer(f)||K.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function d(f,g,N){let x=f;if(f&&!N&&typeof f=="object"){if(K.endsWith(g,"{}"))g=r?g:g.slice(0,-2),f=JSON.stringify(f);else if(K.isArray(f)&&Z1(f)||(K.isFileList(f)||K.endsWith(g,"[]"))&&(x=K.toArray(f)))return g=p0(g),x.forEach(function(v,w){!(K.isUndefined(v)||v===null)&&t.append(l===!0?gp([g],w,i):l===null?g:g+"[]",u(v))}),!1}return bd(f)?!0:(t.append(gp(N,g,i),u(f)),!1)}const h=[],p=Object.assign(J1,{defaultVisitor:d,convertValue:u,isVisitable:bd});function m(f,g){if(!K.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(f),K.forEach(f,function(x,y){(!(K.isUndefined(x)||x===null)&&a.call(t,x,K.isString(y)?y.trim():y,g,p))===!0&&m(x,g?g.concat(y):[y])}),h.pop()}}if(!K.isObject(e))throw new TypeError("data must be an object");return m(e),t}function yp(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Im(e,t){this._pairs=[],e&&hc(e,this,t)}const x0=Im.prototype;x0.append=function(t,n){this._pairs.push([t,n])};x0.toString=function(t){const n=t?function(r){return t.call(this,r,yp)}:yp;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function X1(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function g0(e,t,n){if(!t)return e;const r=n&&n.encode||X1;K.isFunction(n)&&(n={serialize:n});const a=n&&n.serialize;let i;if(a?i=a(t,n):i=K.isURLSearchParams(t)?t.toString():new Im(t,n).toString(r),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class vp{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,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){K.forEach(this.handlers,function(r){r!==null&&t(r)})}}const y0={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Y1=typeof URLSearchParams<"u"?URLSearchParams:Im,eS=typeof FormData<"u"?FormData:null,tS=typeof Blob<"u"?Blob:null,sS={isBrowser:!0,classes:{URLSearchParams:Y1,FormData:eS,Blob:tS},protocols:["http","https","file","blob","url","data"]},Lm=typeof window<"u"&&typeof document<"u",Nd=typeof navigator=="object"&&navigator||void 0,nS=Lm&&(!Nd||["ReactNative","NativeScript","NS"].indexOf(Nd.product)<0),rS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",aS=Lm&&window.location.href||"http://localhost",iS=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Lm,hasStandardBrowserEnv:nS,hasStandardBrowserWebWorkerEnv:rS,navigator:Nd,origin:aS},Symbol.toStringTag,{value:"Module"})),Ot={...iS,...sS};function lS(e,t){return hc(e,new Ot.classes.URLSearchParams,{visitor:function(n,r,a,i){return Ot.isNode&&K.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function oS(e){return K.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function cS(e){const t={},n=Object.keys(e);let r;const a=n.length;let i;for(r=0;r=n.length;return l=!l&&K.isArray(a)?a.length:l,c?(K.hasOwnProp(a,l)?a[l]=[a[l],r]:a[l]=r,!o):((!a[l]||!K.isObject(a[l]))&&(a[l]=[]),t(n,r,a[l],i)&&K.isArray(a[l])&&(a[l]=cS(a[l])),!o)}if(K.isFormData(e)&&K.isFunction(e.entries)){const n={};return K.forEachEntry(e,(r,a)=>{t(oS(r),a,n,0)}),n}return null}function uS(e,t,n){if(K.isString(e))try{return(t||JSON.parse)(e),K.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const hl={transitional:y0,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,i=K.isObject(t);if(i&&K.isHTMLForm(t)&&(t=new FormData(t)),K.isFormData(t))return a?JSON.stringify(v0(t)):t;if(K.isArrayBuffer(t)||K.isBuffer(t)||K.isStream(t)||K.isFile(t)||K.isBlob(t)||K.isReadableStream(t))return t;if(K.isArrayBufferView(t))return t.buffer;if(K.isURLSearchParams(t))return n.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 lS(t,this.formSerializer).toString();if((o=K.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return hc(o?{"files[]":t}:t,c&&new c,this.formSerializer)}}return i||a?(n.setContentType("application/json",!1),uS(t)):t}],transformResponse:[function(t){const n=this.transitional||hl.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(K.isResponse(t)||K.isReadableStream(t))return t;if(t&&K.isString(t)&&(r&&!this.responseType||a)){const l=!(n&&n.silentJSONParsing)&&a;try{return JSON.parse(t,this.parseReviver)}catch(o){if(l)throw o.name==="SyntaxError"?Ne.from(o,Ne.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:Ot.classes.FormData,Blob:Ot.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};K.forEach(["delete","get","head","post","put","patch"],e=>{hl.headers[e]={}});const dS=K.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"]),mS=e=>{const t={};let n,r,a;return e&&e.split(` +`).forEach(function(l){a=l.indexOf(":"),n=l.substring(0,a).trim().toLowerCase(),r=l.substring(a+1).trim(),!(!n||t[n]&&dS[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},jp=Symbol("internals");function ii(e){return e&&String(e).trim().toLowerCase()}function no(e){return e===!1||e==null?e:K.isArray(e)?e.map(no):String(e)}function hS(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const fS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Jc(e,t,n,r,a){if(K.isFunction(r))return r.call(this,t,n);if(a&&(t=n),!!K.isString(t)){if(K.isString(r))return t.indexOf(r)!==-1;if(K.isRegExp(r))return r.test(t)}}function pS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function xS(e,t){const n=K.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(a,i,l){return this[r].call(this,t,a,i,l)},configurable:!0})})}let as=class{constructor(t){t&&this.set(t)}set(t,n,r){const a=this;function i(o,c,u){const d=ii(c);if(!d)throw new Error("header name must be a non-empty string");const h=K.findKey(a,d);(!h||a[h]===void 0||u===!0||u===void 0&&a[h]!==!1)&&(a[h||c]=no(o))}const l=(o,c)=>K.forEach(o,(u,d)=>i(u,d,c));if(K.isPlainObject(t)||t instanceof this.constructor)l(t,n);else if(K.isString(t)&&(t=t.trim())&&!fS(t))l(mS(t),n);else if(K.isObject(t)&&K.isIterable(t)){let o={},c,u;for(const d of t){if(!K.isArray(d))throw TypeError("Object iterator must return a key-value pair");o[u=d[0]]=(c=o[u])?K.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}l(o,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=ii(t),t){const r=K.findKey(this,t);if(r){const a=this[r];if(!n)return a;if(n===!0)return hS(a);if(K.isFunction(n))return n.call(this,a,r);if(K.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=ii(t),t){const r=K.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Jc(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let a=!1;function i(l){if(l=ii(l),l){const o=K.findKey(r,l);o&&(!n||Jc(r,r[o],o,n))&&(delete r[o],a=!0)}}return K.isArray(t)?t.forEach(i):i(t),a}clear(t){const n=Object.keys(this);let r=n.length,a=!1;for(;r--;){const i=n[r];(!t||Jc(this,this[i],i,t,!0))&&(delete this[i],a=!0)}return a}normalize(t){const n=this,r={};return K.forEach(this,(a,i)=>{const l=K.findKey(r,i);if(l){n[l]=no(a),delete n[i];return}const o=t?pS(i):String(i).trim();o!==i&&delete n[i],n[o]=no(a),r[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return K.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=t&&K.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).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,...n){const r=new this(t);return n.forEach(a=>r.set(a)),r}static accessor(t){const r=(this[jp]=this[jp]={accessors:{}}).accessors,a=this.prototype;function i(l){const o=ii(l);r[o]||(xS(a,l),r[o]=!0)}return K.isArray(t)?t.forEach(i):i(t),this}};as.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);K.reduceDescriptors(as.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});K.freezeMethods(as);function Xc(e,t){const n=this||hl,r=t||n,a=as.from(r.headers);let i=r.data;return K.forEach(e,function(o){i=o.call(n,i,a.normalize(),t?t.status:void 0)}),a.normalize(),i}function j0(e){return!!(e&&e.__CANCEL__)}function Qa(e,t,n){Ne.call(this,e??"canceled",Ne.ERR_CANCELED,t,n),this.name="CanceledError"}K.inherits(Qa,Ne,{__CANCEL__:!0});function b0(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ne("Request failed with status code "+n.status,[Ne.ERR_BAD_REQUEST,Ne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function gS(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function yS(e,t){e=e||10;const n=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),n[a]=c,r[a]=u;let h=i,p=0;for(;h!==a;)p+=n[h++],h=h%e;if(a=(a+1)%e,a===i&&(i=(i+1)%e),u-l{n=d,a=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const d=Date.now(),h=d-n;h>=r?l(u,d):(a=u,i||(i=setTimeout(()=>{i=null,l(a)},r-h)))},()=>a&&l(a)]}const Ro=(e,t,n=3)=>{let r=0;const a=yS(50,250);return vS(i=>{const l=i.loaded,o=i.lengthComputable?i.total:void 0,c=l-r,u=a(c),d=l<=o;r=l;const h={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(h)},n)},bp=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Np=e=>(...t)=>K.asap(()=>e(...t)),jS=Ot.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ot.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ot.origin),Ot.navigator&&/(msie|trident)/i.test(Ot.navigator.userAgent)):()=>!0,bS=Ot.hasStandardBrowserEnv?{write(e,t,n,r,a,i,l){if(typeof document>"u")return;const o=[`${e}=${encodeURIComponent(t)}`];K.isNumber(n)&&o.push(`expires=${new Date(n).toUTCString()}`),K.isString(r)&&o.push(`path=${r}`),K.isString(a)&&o.push(`domain=${a}`),i===!0&&o.push("secure"),K.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 NS(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function wS(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function N0(e,t,n){let r=!NS(t);return e&&(r||n==!1)?wS(e,t):t}const wp=e=>e instanceof as?{...e}:e;function Kr(e,t){t=t||{};const n={};function r(u,d,h,p){return K.isPlainObject(u)&&K.isPlainObject(d)?K.merge.call({caseless:p},u,d):K.isPlainObject(d)?K.merge({},d):K.isArray(d)?d.slice():d}function a(u,d,h,p){if(K.isUndefined(d)){if(!K.isUndefined(u))return r(void 0,u,h,p)}else return r(u,d,h,p)}function i(u,d){if(!K.isUndefined(d))return r(void 0,d)}function l(u,d){if(K.isUndefined(d)){if(!K.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function o(u,d,h){if(h in t)return r(u,d);if(h 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,h)=>a(wp(u),wp(d),h,!0)};return K.forEach(Object.keys({...e,...t}),function(d){const h=c[d]||a,p=h(e[d],t[d],d);K.isUndefined(p)&&h!==o||(n[d]=p)}),n}const w0=e=>{const t=Kr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:i,headers:l,auth:o}=t;if(t.headers=l=as.from(l),t.url=g0(N0(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&l.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),K.isFormData(n)){if(Ot.hasStandardBrowserEnv||Ot.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(K.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,h])=>{u.includes(d.toLowerCase())&&l.set(d,h)})}}if(Ot.hasStandardBrowserEnv&&(r&&K.isFunction(r)&&(r=r(t)),r||r!==!1&&jS(t.url))){const c=a&&i&&bS.read(i);c&&l.set(a,c)}return t},SS=typeof XMLHttpRequest<"u",kS=SS&&function(e){return new Promise(function(n,r){const a=w0(e);let i=a.data;const l=as.from(a.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:u}=a,d,h,p,m,f;function g(){m&&m(),f&&f(),a.cancelToken&&a.cancelToken.unsubscribe(d),a.signal&&a.signal.removeEventListener("abort",d)}let N=new XMLHttpRequest;N.open(a.method.toUpperCase(),a.url,!0),N.timeout=a.timeout;function x(){if(!N)return;const v=as.from("getAllResponseHeaders"in N&&N.getAllResponseHeaders()),k={data:!o||o==="text"||o==="json"?N.responseText:N.response,status:N.status,statusText:N.statusText,headers:v,config:e,request:N};b0(function(A){n(A),g()},function(A){r(A),g()},k),N=null}"onloadend"in N?N.onloadend=x:N.onreadystatechange=function(){!N||N.readyState!==4||N.status===0&&!(N.responseURL&&N.responseURL.indexOf("file:")===0)||setTimeout(x)},N.onabort=function(){N&&(r(new Ne("Request aborted",Ne.ECONNABORTED,e,N)),N=null)},N.onerror=function(w){const k=w&&w.message?w.message:"Network Error",C=new Ne(k,Ne.ERR_NETWORK,e,N);C.event=w||null,r(C),N=null},N.ontimeout=function(){let w=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const k=a.transitional||y0;a.timeoutErrorMessage&&(w=a.timeoutErrorMessage),r(new Ne(w,k.clarifyTimeoutError?Ne.ETIMEDOUT:Ne.ECONNABORTED,e,N)),N=null},i===void 0&&l.setContentType(null),"setRequestHeader"in N&&K.forEach(l.toJSON(),function(w,k){N.setRequestHeader(k,w)}),K.isUndefined(a.withCredentials)||(N.withCredentials=!!a.withCredentials),o&&o!=="json"&&(N.responseType=a.responseType),u&&([p,f]=Ro(u,!0),N.addEventListener("progress",p)),c&&N.upload&&([h,m]=Ro(c),N.upload.addEventListener("progress",h),N.upload.addEventListener("loadend",m)),(a.cancelToken||a.signal)&&(d=v=>{N&&(r(!v||v.type?new Qa(null,e,N):v),N.abort(),N=null)},a.cancelToken&&a.cancelToken.subscribe(d),a.signal&&(a.signal.aborted?d():a.signal.addEventListener("abort",d)));const y=gS(a.url);if(y&&Ot.protocols.indexOf(y)===-1){r(new Ne("Unsupported protocol "+y+":",Ne.ERR_BAD_REQUEST,e));return}N.send(i||null)})},CS=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){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 Ne?d:new Qa(d instanceof Error?d.message:d))}};let l=t&&setTimeout(()=>{l=null,i(new Ne(`timeout ${t} of ms exceeded`,Ne.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=()=>K.asap(o),c}},ES=function*(e,t){let n=e.byteLength;if(n{const a=DS(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 h=d.byteLength;if(n){let p=i+=h;n(p)}c.enqueue(new Uint8Array(d))}catch(u){throw o(u),u}},cancel(c){return o(c),a.return()}},{highWaterMark:2})},kp=64*1024,{isFunction:_l}=K,AS=(({Request:e,Response:t})=>({Request:e,Response:t}))(K.global),{ReadableStream:Cp,TextEncoder:Ep}=K.global,Dp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},MS=e=>{e=K.merge.call({skipUndefined:!0},AS,e);const{fetch:t,Request:n,Response:r}=e,a=t?_l(t):typeof fetch=="function",i=_l(n),l=_l(r);if(!a)return!1;const o=a&&_l(Cp),c=a&&(typeof Ep=="function"?(f=>g=>f.encode(g))(new Ep):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=i&&o&&Dp(()=>{let f=!1;const g=new n(Ot.origin,{body:new Cp,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!g}),d=l&&o&&Dp(()=>K.isReadableStream(new r("").body)),h={stream:d&&(f=>f.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(g,N)=>{let x=g&&g[f];if(x)return x.call(g);throw new Ne(`Response type '${f}' is not supported`,Ne.ERR_NOT_SUPPORT,N)})});const p=async f=>{if(f==null)return 0;if(K.isBlob(f))return f.size;if(K.isSpecCompliantForm(f))return(await new n(Ot.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(K.isArrayBufferView(f)||K.isArrayBuffer(f))return f.byteLength;if(K.isURLSearchParams(f)&&(f=f+""),K.isString(f))return(await c(f)).byteLength},m=async(f,g)=>{const N=K.toFiniteNumber(f.getContentLength());return N??p(g)};return async f=>{let{url:g,method:N,data:x,signal:y,cancelToken:v,timeout:w,onDownloadProgress:k,onUploadProgress:C,responseType:A,headers:S,withCredentials:E="same-origin",fetchOptions:D}=w0(f),$=t||fetch;A=A?(A+"").toLowerCase():"text";let L=CS([y,v&&v.toAbortSignal()],w),U=null;const V=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let O;try{if(C&&u&&N!=="get"&&N!=="head"&&(O=await m(S,x))!==0){let pe=new n(g,{method:"POST",body:x,duplex:"half"}),le;if(K.isFormData(x)&&(le=pe.headers.get("content-type"))&&S.setContentType(le),pe.body){const[nt,Q]=bp(O,Ro(Np(C)));x=Sp(pe.body,kp,nt,Q)}}K.isString(E)||(E=E?"include":"omit");const P=i&&"credentials"in n.prototype,b={...D,signal:L,method:N.toUpperCase(),headers:S.normalize().toJSON(),body:x,duplex:"half",credentials:P?E:void 0};U=i&&new n(g,b);let z=await(i?$(U,D):$(g,b));const J=d&&(A==="stream"||A==="response");if(d&&(k||J&&V)){const pe={};["status","statusText","headers"].forEach(ke=>{pe[ke]=z[ke]});const le=K.toFiniteNumber(z.headers.get("content-length")),[nt,Q]=k&&bp(le,Ro(Np(k),!0))||[];z=new r(Sp(z.body,kp,nt,()=>{Q&&Q(),V&&V()}),pe)}A=A||"text";let ee=await h[K.findKey(h,A)||"text"](z,f);return!J&&V&&V(),await new Promise((pe,le)=>{b0(pe,le,{data:ee,headers:as.from(z.headers),status:z.status,statusText:z.statusText,config:f,request:U})})}catch(P){throw V&&V(),P&&P.name==="TypeError"&&/Load failed|fetch/i.test(P.message)?Object.assign(new Ne("Network Error",Ne.ERR_NETWORK,f,U),{cause:P.cause||P}):Ne.from(P,P&&P.code,f,U)}}},FS=new Map,S0=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:a}=t,i=[r,a,n];let l=i.length,o=l,c,u,d=FS;for(;o--;)c=i[o],u=d.get(c),u===void 0&&d.set(c,u=o?new Map:MS(t)),d=u;return u};S0();const Rm={http:G1,xhr:kS,fetch:{get:S0}};K.forEach(Rm,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Pp=e=>`- ${e}`,TS=e=>K.isFunction(e)||e===null||e===!1;function IS(e,t){e=K.isArray(e)?e:[e];const{length:n}=e;let r,a;const i={};for(let l=0;l`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=n?l.length>1?`since : +`+l.map(Pp).join(` +`):" "+Pp(l[0]):"as no adapter specified";throw new Ne("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return a}const k0={getAdapter:IS,adapters:Rm};function Yc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Qa(null,e)}function Ap(e){return Yc(e),e.headers=as.from(e.headers),e.data=Xc.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),k0.getAdapter(e.adapter||hl.adapter,e)(e).then(function(r){return Yc(e),r.data=Xc.call(e,e.transformResponse,r),r.headers=as.from(r.headers),r},function(r){return j0(r)||(Yc(e),r&&r.response&&(r.response.data=Xc.call(e,e.transformResponse,r.response),r.response.headers=as.from(r.response.headers))),Promise.reject(r)})}const C0="1.13.2",fc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{fc[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Mp={};fc.transitional=function(t,n,r){function a(i,l){return"[Axios v"+C0+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,o)=>{if(t===!1)throw new Ne(a(l," has been removed"+(n?" in "+n:"")),Ne.ERR_DEPRECATED);return n&&!Mp[l]&&(Mp[l]=!0,console.warn(a(l," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,l,o):!0}};fc.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function LS(e,t,n){if(typeof e!="object")throw new Ne("options must be an object",Ne.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 Ne("option "+i+" must be "+c,Ne.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ne("Unknown option "+i,Ne.ERR_BAD_OPTION)}}const ro={assertOptions:LS,validators:fc},Ks=ro.validators;let Fr=class{constructor(t){this.defaults=t||{},this.interceptors={request:new vp,response:new vp}}async request(t,n){try{return await this._request(t,n)}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,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Kr(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&ro.assertOptions(r,{silentJSONParsing:Ks.transitional(Ks.boolean),forcedJSONParsing:Ks.transitional(Ks.boolean),clarifyTimeoutError:Ks.transitional(Ks.boolean)},!1),a!=null&&(K.isFunction(a)?n.paramsSerializer={serialize:a}:ro.assertOptions(a,{encode:Ks.function,serialize:Ks.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ro.assertOptions(n,{baseUrl:Ks.spelling("baseURL"),withXsrfToken:Ks.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l=i&&K.merge(i.common,i[n.method]);i&&K.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),n.headers=as.concat(l,i);const o=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(c=c&&g.synchronous,o.unshift(g.fulfilled,g.rejected))});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let d,h=0,p;if(!c){const f=[Ap.bind(this),void 0];for(f.unshift(...o),f.push(...u),p=f.length,d=Promise.resolve(n);h{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 Qa(i,l,o),n(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 n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new E0(function(a){t=a}),cancel:t}}};function OS(e){return function(n){return e.apply(null,n)}}function zS(e){return K.isObject(e)&&e.isAxiosError===!0}const wd={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(wd).forEach(([e,t])=>{wd[t]=e});function D0(e){const t=new Fr(e),n=a0(Fr.prototype.request,t);return K.extend(n,Fr.prototype,t,{allOwnKeys:!0}),K.extend(n,t,null,{allOwnKeys:!0}),n.create=function(a){return D0(Kr(e,a))},n}const mt=D0(hl);mt.Axios=Fr;mt.CanceledError=Qa;mt.CancelToken=RS;mt.isCancel=j0;mt.VERSION=C0;mt.toFormData=hc;mt.AxiosError=Ne;mt.Cancel=mt.CanceledError;mt.all=function(t){return Promise.all(t)};mt.spread=OS;mt.isAxiosError=zS;mt.mergeConfig=Kr;mt.AxiosHeaders=as;mt.formToJSON=e=>v0(K.isHTMLForm(e)?new FormData(e):e);mt.getAdapter=k0.getAdapter;mt.HttpStatusCode=wd;mt.default=mt;const{Axios:hC,AxiosError:fC,CanceledError:pC,isCancel:xC,CancelToken:gC,VERSION:yC,all:vC,Cancel:jC,isAxiosError:bC,spread:NC,toFormData:wC,AxiosHeaders:SC,HttpStatusCode:kC,formToJSON:CC,getAdapter:EC,mergeConfig:DC}=mt,R=mt.create({baseURL:"/api",headers:{"Content-Type":"application/json"}});R.interceptors.request.use(e=>{const t=localStorage.getItem("token");return t&&(e.headers.Authorization=`Bearer ${t}`),e});R.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 n=((d=(u=e.response)==null?void 0:u.data)==null?void 0:d.error)||e.message||"Ein Fehler ist aufgetreten",r=new Error(n);return Promise.reject(r)});const Kl={login:async(e,t)=>(await R.post("/auth/login",{email:e,password:t})).data,customerLogin:async(e,t)=>(await R.post("/auth/customer-login",{email:e,password:t})).data,me:async()=>(await R.get("/auth/me")).data},kt={getAll:async e=>(await R.get("/customers",{params:e})).data,getById:async e=>(await R.get(`/customers/${e}`)).data,create:async e=>(await R.post("/customers",e)).data,update:async(e,t)=>(await R.put(`/customers/${e}`,t)).data,delete:async e=>(await R.delete(`/customers/${e}`)).data,getPortalSettings:async e=>(await R.get(`/customers/${e}/portal`)).data,updatePortalSettings:async(e,t)=>(await R.put(`/customers/${e}/portal`,t)).data,setPortalPassword:async(e,t)=>(await R.post(`/customers/${e}/portal/password`,{password:t})).data,getPortalPassword:async e=>(await R.get(`/customers/${e}/portal/password`)).data,getRepresentatives:async e=>(await R.get(`/customers/${e}/representatives`)).data,addRepresentative:async(e,t,n)=>(await R.post(`/customers/${e}/representatives`,{representativeId:t,notes:n})).data,removeRepresentative:async(e,t)=>(await R.delete(`/customers/${e}/representatives/${t}`)).data,searchForRepresentative:async(e,t)=>(await R.get(`/customers/${e}/representatives/search`,{params:{search:t}})).data},Sd={getByCustomer:async e=>(await R.get(`/customers/${e}/addresses`)).data,create:async(e,t)=>(await R.post(`/customers/${e}/addresses`,t)).data,update:async(e,t)=>(await R.put(`/addresses/${e}`,t)).data,delete:async e=>(await R.delete(`/addresses/${e}`)).data},Oo={getByCustomer:async(e,t=!1)=>(await R.get(`/customers/${e}/bank-cards`,{params:{showInactive:t}})).data,create:async(e,t)=>(await R.post(`/customers/${e}/bank-cards`,t)).data,update:async(e,t)=>(await R.put(`/bank-cards/${e}`,t)).data,delete:async e=>(await R.delete(`/bank-cards/${e}`)).data},zo={getByCustomer:async(e,t=!1)=>(await R.get(`/customers/${e}/documents`,{params:{showInactive:t}})).data,create:async(e,t)=>(await R.post(`/customers/${e}/documents`,t)).data,update:async(e,t)=>(await R.put(`/documents/${e}`,t)).data,delete:async e=>(await R.delete(`/documents/${e}`)).data},Xs={getByCustomer:async(e,t=!1)=>(await R.get(`/customers/${e}/meters`,{params:{showInactive:t}})).data,create:async(e,t)=>(await R.post(`/customers/${e}/meters`,t)).data,update:async(e,t)=>(await R.put(`/meters/${e}`,t)).data,delete:async e=>(await R.delete(`/meters/${e}`)).data,getReadings:async e=>(await R.get(`/meters/${e}/readings`)).data,addReading:async(e,t)=>(await R.post(`/meters/${e}/readings`,t)).data,updateReading:async(e,t,n)=>(await R.put(`/meters/${e}/readings/${t}`,n)).data,deleteReading:async(e,t)=>(await R.delete(`/meters/${e}/readings/${t}`)).data},ls={getByCustomer:async(e,t=!1)=>(await R.get(`/customers/${e}/stressfrei-emails`,{params:{includeInactive:t}})).data,create:async(e,t)=>(await R.post(`/customers/${e}/stressfrei-emails`,t)).data,update:async(e,t)=>(await R.put(`/stressfrei-emails/${e}`,t)).data,delete:async e=>(await R.delete(`/stressfrei-emails/${e}`)).data,enableMailbox:async e=>(await R.post(`/stressfrei-emails/${e}/enable-mailbox`)).data,syncMailboxStatus:async e=>(await R.post(`/stressfrei-emails/${e}/sync-mailbox-status`)).data,getMailboxCredentials:async e=>(await R.get(`/stressfrei-emails/${e}/credentials`)).data,resetPassword:async e=>(await R.post(`/stressfrei-emails/${e}/reset-password`)).data,syncEmails:async(e,t=!1)=>(await R.post(`/stressfrei-emails/${e}/sync`,{},{params:{full:t}})).data,sendEmail:async(e,t)=>(await R.post(`/stressfrei-emails/${e}/send`,t)).data,getFolderCounts:async e=>(await R.get(`/stressfrei-emails/${e}/folder-counts`)).data},Le={getForCustomer:async(e,t)=>(await R.get(`/customers/${e}/emails`,{params:t})).data,getForContract:async(e,t)=>(await R.get(`/contracts/${e}/emails`,{params:t})).data,getContractFolderCounts:async e=>(await R.get(`/contracts/${e}/emails/folder-counts`)).data,getMailboxAccounts:async e=>(await R.get(`/customers/${e}/mailbox-accounts`)).data,getById:async e=>(await R.get(`/emails/${e}`)).data,getThread:async e=>(await R.get(`/emails/${e}/thread`)).data,markAsRead:async(e,t)=>(await R.patch(`/emails/${e}/read`,{isRead:t})).data,toggleStar:async e=>(await R.post(`/emails/${e}/star`)).data,assignToContract:async(e,t)=>(await R.post(`/emails/${e}/assign`,{contractId:t})).data,unassignFromContract:async e=>(await R.delete(`/emails/${e}/assign`)).data,delete:async e=>(await R.delete(`/emails/${e}`)).data,getAttachmentUrl:(e,t,n)=>{const r=localStorage.getItem("token"),a=encodeURIComponent(t),i=n?"&view=true":"";return`${R.defaults.baseURL}/emails/${e}/attachments/${a}?token=${r}${i}`},getUnreadCount:async e=>(await R.get("/emails/unread-count",{params:e})).data,getTrash:async e=>(await R.get(`/customers/${e}/emails/trash`)).data,getTrashCount:async e=>(await R.get(`/customers/${e}/emails/trash/count`)).data,restore:async e=>(await R.post(`/emails/${e}/restore`)).data,permanentDelete:async e=>(await R.delete(`/emails/${e}/permanent`)).data,getAttachmentTargets:async e=>(await R.get(`/emails/${e}/attachment-targets`)).data,saveAttachmentTo:async(e,t,n)=>{const r=encodeURIComponent(t);return(await R.post(`/emails/${e}/attachments/${r}/save-to`,n)).data}},Ke={getAll:async e=>(await R.get("/contracts",{params:e})).data,getTreeForCustomer:async e=>(await R.get("/contracts",{params:{customerId:e,tree:"true"}})).data,getById:async e=>(await R.get(`/contracts/${e}`)).data,create:async e=>(await R.post("/contracts",e)).data,update:async(e,t)=>(await R.put(`/contracts/${e}`,t)).data,delete:async e=>(await R.delete(`/contracts/${e}`)).data,createFollowUp:async e=>(await R.post(`/contracts/${e}/follow-up`)).data,getPassword:async e=>(await R.get(`/contracts/${e}/password`)).data,getSimCardCredentials:async e=>(await R.get(`/contracts/simcard/${e}/credentials`)).data,getInternetCredentials:async e=>(await R.get(`/contracts/${e}/internet-credentials`)).data,getSipCredentials:async e=>(await R.get(`/contracts/phonenumber/${e}/sip-credentials`)).data,getCockpit:async()=>(await R.get("/contracts/cockpit")).data},ct={getAll:async e=>(await R.get("/tasks",{params:e})).data,getStats:async()=>(await R.get("/tasks/stats")).data,getByContract:async(e,t)=>(await R.get(`/contracts/${e}/tasks`,{params:{status:t}})).data,create:async(e,t)=>(await R.post(`/contracts/${e}/tasks`,t)).data,update:async(e,t)=>(await R.put(`/tasks/${e}`,t)).data,complete:async e=>(await R.post(`/tasks/${e}/complete`)).data,reopen:async e=>(await R.post(`/tasks/${e}/reopen`)).data,delete:async e=>(await R.delete(`/tasks/${e}`)).data,createSubtask:async(e,t)=>(await R.post(`/tasks/${e}/subtasks`,{title:t})).data,createReply:async(e,t)=>(await R.post(`/tasks/${e}/reply`,{title:t})).data,updateSubtask:async(e,t)=>(await R.put(`/subtasks/${e}`,{title:t})).data,completeSubtask:async e=>(await R.post(`/subtasks/${e}/complete`)).data,reopenSubtask:async e=>(await R.post(`/subtasks/${e}/reopen`)).data,deleteSubtask:async e=>(await R.delete(`/subtasks/${e}`)).data,createSupportTicket:async(e,t)=>(await R.post(`/contracts/${e}/support-ticket`,t)).data},Ur={getPublic:async()=>(await R.get("/settings/public")).data,getAll:async()=>(await R.get("/settings")).data,update:async e=>(await R.put("/settings",e)).data,updateOne:async(e,t)=>(await R.put(`/settings/${e}`,{value:t})).data},dr={list:async()=>(await R.get("/settings/backups")).data,create:async()=>(await R.post("/settings/backup")).data,restore:async e=>(await R.post(`/settings/backup/${e}/restore`)).data,delete:async e=>(await R.delete(`/settings/backup/${e}`)).data,getDownloadUrl:e=>`/api/settings/backup/${e}/download`,upload:async e=>{const t=new FormData;return t.append("backup",e),(await R.post("/settings/backup/upload",t,{headers:{"Content-Type":"multipart/form-data"}})).data},factoryReset:async()=>(await R.post("/settings/factory-reset")).data},Qi={getAll:async(e=!1)=>(await R.get("/platforms",{params:{includeInactive:e}})).data,getById:async e=>(await R.get(`/platforms/${e}`)).data,create:async e=>(await R.post("/platforms",e)).data,update:async(e,t)=>(await R.put(`/platforms/${e}`,t)).data,delete:async e=>(await R.delete(`/platforms/${e}`)).data},Hi={getAll:async(e=!1)=>(await R.get("/cancellation-periods",{params:{includeInactive:e}})).data,getById:async e=>(await R.get(`/cancellation-periods/${e}`)).data,create:async e=>(await R.post("/cancellation-periods",e)).data,update:async(e,t)=>(await R.put(`/cancellation-periods/${e}`,t)).data,delete:async e=>(await R.delete(`/cancellation-periods/${e}`)).data},Wi={getAll:async(e=!1)=>(await R.get("/contract-durations",{params:{includeInactive:e}})).data,getById:async e=>(await R.get(`/contract-durations/${e}`)).data,create:async e=>(await R.post("/contract-durations",e)).data,update:async(e,t)=>(await R.put(`/contract-durations/${e}`,t)).data,delete:async e=>(await R.delete(`/contract-durations/${e}`)).data},Gi={getAll:async(e=!1)=>(await R.get("/contract-categories",{params:{includeInactive:e}})).data,getById:async e=>(await R.get(`/contract-categories/${e}`)).data,create:async e=>(await R.post("/contract-categories",e)).data,update:async(e,t)=>(await R.put(`/contract-categories/${e}`,t)).data,delete:async e=>(await R.delete(`/contract-categories/${e}`)).data},za={getAll:async(e=!1)=>(await R.get("/providers",{params:{includeInactive:e}})).data,getById:async e=>(await R.get(`/providers/${e}`)).data,create:async e=>(await R.post("/providers",e)).data,update:async(e,t)=>(await R.put(`/providers/${e}`,t)).data,delete:async e=>(await R.delete(`/providers/${e}`)).data,getTariffs:async(e,t=!1)=>(await R.get(`/providers/${e}/tariffs`,{params:{includeInactive:t}})).data,createTariff:async(e,t)=>(await R.post(`/providers/${e}/tariffs`,t)).data},P0={getById:async e=>(await R.get(`/tariffs/${e}`)).data,update:async(e,t)=>(await R.put(`/tariffs/${e}`,t)).data,delete:async e=>(await R.delete(`/tariffs/${e}`)).data},lt={uploadBankCardDocument:async(e,t)=>{const n=new FormData;return n.append("document",t),(await R.post(`/upload/bank-cards/${e}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},uploadIdentityDocument:async(e,t)=>{const n=new FormData;return n.append("document",t),(await R.post(`/upload/documents/${e}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBankCardDocument:async e=>(await R.delete(`/upload/bank-cards/${e}`)).data,deleteIdentityDocument:async e=>(await R.delete(`/upload/documents/${e}`)).data,uploadBusinessRegistration:async(e,t)=>{const n=new FormData;return n.append("document",t),(await R.post(`/upload/customers/${e}/business-registration`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBusinessRegistration:async e=>(await R.delete(`/upload/customers/${e}/business-registration`)).data,uploadCommercialRegister:async(e,t)=>{const n=new FormData;return n.append("document",t),(await R.post(`/upload/customers/${e}/commercial-register`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCommercialRegister:async e=>(await R.delete(`/upload/customers/${e}/commercial-register`)).data,uploadPrivacyPolicy:async(e,t)=>{const n=new FormData;return n.append("document",t),(await R.post(`/upload/customers/${e}/privacy-policy`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deletePrivacyPolicy:async e=>(await R.delete(`/upload/customers/${e}/privacy-policy`)).data,uploadCancellationLetter:async(e,t)=>{const n=new FormData;return n.append("document",t),(await R.post(`/upload/contracts/${e}/cancellation-letter`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetter:async e=>(await R.delete(`/upload/contracts/${e}/cancellation-letter`)).data,uploadCancellationConfirmation:async(e,t)=>{const n=new FormData;return n.append("document",t),(await R.post(`/upload/contracts/${e}/cancellation-confirmation`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmation:async e=>(await R.delete(`/upload/contracts/${e}/cancellation-confirmation`)).data,uploadCancellationLetterOptions:async(e,t)=>{const n=new FormData;return n.append("document",t),(await R.post(`/upload/contracts/${e}/cancellation-letter-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetterOptions:async e=>(await R.delete(`/upload/contracts/${e}/cancellation-letter-options`)).data,uploadCancellationConfirmationOptions:async(e,t)=>{const n=new FormData;return n.append("document",t),(await R.post(`/upload/contracts/${e}/cancellation-confirmation-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmationOptions:async e=>(await R.delete(`/upload/contracts/${e}/cancellation-confirmation-options`)).data},wi={getAll:async e=>(await R.get("/users",{params:e})).data,getById:async e=>(await R.get(`/users/${e}`)).data,create:async e=>(await R.post("/users",e)).data,update:async(e,t)=>(await R.put(`/users/${e}`,t)).data,delete:async e=>(await R.delete(`/users/${e}`)).data,getRoles:async()=>(await R.get("/users/roles/list")).data},hi={getSchema:async()=>(await R.get("/developer/schema")).data,getTableData:async(e,t=1,n=50)=>(await R.get(`/developer/table/${e}`,{params:{page:t,limit:n}})).data,updateRow:async(e,t,n)=>(await R.put(`/developer/table/${e}/${t}`,n)).data,deleteRow:async(e,t)=>(await R.delete(`/developer/table/${e}/${t}`)).data,getReference:async e=>(await R.get(`/developer/reference/${e}`)).data},cn={getConfigs:async()=>(await R.get("/email-providers/configs")).data,getConfig:async e=>(await R.get(`/email-providers/configs/${e}`)).data,createConfig:async e=>(await R.post("/email-providers/configs",e)).data,updateConfig:async(e,t)=>(await R.put(`/email-providers/configs/${e}`,t)).data,deleteConfig:async e=>(await R.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 R.post("/email-providers/test-connection",t)).data},getDomain:async()=>(await R.get("/email-providers/domain")).data,checkEmailExists:async e=>(await R.get(`/email-providers/check/${e}`)).data,provisionEmail:async(e,t)=>(await R.post("/email-providers/provision",{localPart:e,customerEmail:t})).data,deprovisionEmail:async e=>(await R.delete(`/email-providers/deprovision/${e}`)).data},A0=j.createContext(null);function $S({children:e}){const[t,n]=j.useState(null),[r,a]=j.useState(!0),[i,l]=j.useState(()=>localStorage.getItem("developerMode")==="true"),o=g=>{l(g),localStorage.setItem("developerMode",String(g))};j.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]),j.useEffect(()=>{localStorage.getItem("token")?Kl.me().then(N=>{N.success&&N.data?n(N.data):localStorage.removeItem("token")}).catch(()=>{localStorage.removeItem("token")}).finally(()=>{a(!1)}):a(!1)},[]);const c=async(g,N)=>{const x=await Kl.login(g,N);if(x.success&&x.data)localStorage.setItem("token",x.data.token),n(x.data.user);else throw new Error(x.error||"Login fehlgeschlagen")},u=async(g,N)=>{const x=await Kl.customerLogin(g,N);if(x.success&&x.data)localStorage.setItem("token",x.data.token),n(x.data.user);else throw new Error(x.error||"Login fehlgeschlagen")},d=()=>{localStorage.removeItem("token"),n(null)},h=async()=>{var N;if(localStorage.getItem("token"))try{const x=await Kl.me();console.log("refreshUser response:",x),console.log("permissions:",(N=x.data)==null?void 0:N.permissions),x.success&&x.data&&n(x.data)}catch(x){console.error("refreshUser error:",x)}},p=g=>t?t.permissions.includes(g):!1,m=!!(t!=null&&t.customerId),f=!!(t!=null&&t.isCustomerPortal);return s.jsx(A0.Provider,{value:{user:t,isLoading:r,isAuthenticated:!!t,login:c,customerLogin:u,logout:d,hasPermission:p,isCustomer:m,isCustomerPortal:f,developerMode:i,setDeveloperMode:o,refreshUser:h},children:e})}function qe(){const e=j.useContext(A0);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}const eu={scrollToTopThreshold:.7},M0=j.createContext(void 0),Fp="opencrm_app_settings";function _S({children:e}){const[t,n]=j.useState(()=>{const a=localStorage.getItem(Fp);if(a)try{return{...eu,...JSON.parse(a)}}catch{return eu}return eu});j.useEffect(()=>{localStorage.setItem(Fp,JSON.stringify(t))},[t]);const r=a=>{n(i=>({...i,...a}))};return s.jsx(M0.Provider,{value:{settings:t,updateSettings:r},children:e})}function F0(){const e=j.useContext(M0);if(!e)throw new Error("useAppSettings must be used within AppSettingsProvider");return e}function KS(){const{pathname:e}=En();return j.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 US=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),T0=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var BS={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 qS=j.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:l,...o},c)=>j.createElement("svg",{ref:c,...BS,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:T0("lucide",a),...o},[...l.map(([u,d])=>j.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 ne=(e,t)=>{const n=j.forwardRef(({className:r,...a},i)=>j.createElement(qS,{ref:i,iconNode:t,className:T0(`lucide-${US(e)}`,r),...a}));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const VS=ne("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const tn=ne("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 I0=ne("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 QS=ne("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 HS=ne("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 L0=ne("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 R0=ne("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 Zi=ne("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 Ha=ne("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 WS=ne("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 qt=ne("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 O0=ne("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 xn=ne("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 vs=ne("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=ne("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 ao=ne("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 Ji=ne("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 Sn=ne("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 pc=ne("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 Om=ne("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 z0=ne("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 xc=ne("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 Ts=ne("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 zm=ne("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 At=ne("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 Ae=ne("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 Xe=ne("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 GS=ne("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 $0=ne("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 ZS=ne("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _0=ne("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 Ip=ne("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 $m=ne("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 JS=ne("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 Lp=ne("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const XS=ne("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tr=ne("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const YS=ne("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const e2=ne("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 t2=ne("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 Rp=ne("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const s2=ne("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 K0=ne("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gs=ne("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 n2=ne("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 r2=ne("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 Xi=ne("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 a2=ne("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 i2=ne("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gc=ne("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $e=ne("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 fr=ne("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const l2=ne("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const o2=ne("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const U0=ne("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 fl=ne("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 pl=ne("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 B0=ne("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 _m=ne("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 st=ne("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 Km=ne("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const c2=ne("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 u2=ne("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=ne("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 Ys=ne("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 q0=ne("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 V0=ne("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kd=ne("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 d2=ne("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 m2=ne("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 yc=ne("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 pa=ne("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 Op=ne("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 xa=ne("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 Os=ne("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 Um=ne("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 h2=ne("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 f2=ne("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 p2(){const{user:e,logout:t,hasPermission:n,isCustomer:r,developerMode:a}=qe(),i=[{to:"/",icon:t2,label:"Dashboard",show:!0,end:!0},{to:"/customers",icon:pa,label:"Kunden",show:n("customers:read")&&!r},{to:"/contracts",icon:Xe,label:"Verträge",show:n("contracts:read"),end:!0},{to:"/contracts/cockpit",icon:xn,label:"Vertrags-Cockpit",show:n("contracts:read")&&!r},{to:"/tasks",icon:r?Xi:Ji,label:r?"Support-Anfragen":"Aufgaben",show:n("contracts:read")}],l=[{to:"/developer/database",icon:xc,label:"Datenbankstruktur"}];return s.jsxs("aside",{className:"w-64 bg-gray-900 text-white min-h-screen flex flex-col",children:[s.jsx("div",{className:"p-4 border-b border-gray-800",children:s.jsx("h1",{className:"text-xl font-bold",children:"OpenCRM"})}),s.jsxs("nav",{className:"flex-1 p-4 overflow-y-auto",children:[s.jsx("ul",{className:"space-y-2",children:i.filter(o=>o.show).map(o=>s.jsx("li",{children:s.jsxs(Zc,{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:[s.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))}),a&&n("developer:access")&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-6 mb-2 px-4",children:s.jsxs("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider flex items-center gap-2",children:[s.jsx(pc,{className:"w-3 h-3"}),"Entwickler"]})}),s.jsx("ul",{className:"space-y-2",children:l.map(o=>s.jsx("li",{children:s.jsxs(Zc,{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:[s.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))})]}),s.jsx("div",{className:"mt-6 pt-6 border-t border-gray-800",children:s.jsxs(Zc,{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:[s.jsx(B0,{className:"w-5 h-5"}),"Einstellungen"]})})]}),s.jsxs("div",{className:"p-4 border-t border-gray-800",children:[s.jsxs("div",{className:"mb-4 text-sm",children:[s.jsx("p",{className:"text-gray-400",children:"Angemeldet als"}),s.jsxs("p",{className:"font-medium",children:[e==null?void 0:e.firstName," ",e==null?void 0:e.lastName]})]}),s.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:[s.jsx(s2,{className:"w-5 h-5"}),"Abmelden"]})]})]})}function x2(){const{settings:e}=F0(),[t,n]=j.useState(!1);j.useEffect(()=>{const a=()=>{window.scrollY>window.innerHeight*e.scrollToTopThreshold?n(!0):n(!1)};return window.addEventListener("scroll",a),()=>window.removeEventListener("scroll",a)},[e.scrollToTopThreshold]);const r=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?s.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:s.jsx(O0,{className:"w-5 h-5"})}):null}function g2(){return s.jsxs("div",{className:"flex min-h-screen",children:[s.jsx(p2,{}),s.jsx("main",{className:"flex-1 p-8 overflow-auto",children:s.jsx(wN,{})}),s.jsx(x2,{})]})}const T=j.forwardRef(({className:e="",variant:t="primary",size:n="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 s.jsx("button",{ref:l,className:`${o} ${c[t]} ${u[n]} ${e}`,disabled:a,...i,children:r})});T.displayName="Button";const q=j.forwardRef(({className:e="",label:t,error:n,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 s.jsxs("div",{className:"w-full",children:[t&&s.jsx("label",{htmlFor:o,className:"block text-sm font-medium text-gray-700 mb-1",children:t}),s.jsxs("div",{className:d?"flex gap-2":"",children:[s.jsx("input",{ref:l,id:o,className:`block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${n?"border-red-500":"border-gray-300"} ${e}`,...i}),d&&s.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:s.jsx(be,{className:"w-4 h-4"})})]}),n&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});q.displayName="Input";function Y({children:e,className:t="",title:n,actions:r}){return s.jsxs("div",{className:`bg-white rounded-lg shadow ${t}`,children:[(n||r)&&s.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 flex items-center justify-between",children:[n&&s.jsx("div",{className:"text-lg font-medium text-gray-900",children:n}),r&&s.jsx("div",{className:"flex items-center gap-2",children:r})]}),s.jsx("div",{className:"p-6",children:e})]})}function y2(){const[e,t]=j.useState(""),[n,r]=j.useState(""),[a,i]=j.useState(""),[l,o]=j.useState(!1),{login:c,customerLogin:u}=qe(),d=Wt(),h=async p=>{p.preventDefault(),i(""),o(!0);try{await c(e,n),d("/");return}catch{}try{await u(e,n),d("/")}catch{i("Ungültige Anmeldedaten"),o(!1)}};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:s.jsxs(Y,{className:"w-full max-w-md",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"OpenCRM"}),s.jsx("p",{className:"text-gray-600 mt-2",children:"Melden Sie sich an"})]}),a&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:a}),s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(q,{label:"E-Mail",type:"email",value:e,onChange:p=>t(p.target.value),required:!0,autoComplete:"email"}),s.jsx(q,{label:"Passwort",type:"password",value:n,onChange:p=>r(p.target.value),required:!0,autoComplete:"current-password"}),s.jsx(T,{type:"submit",className:"w-full",disabled:l,children:l?"Anmeldung...":"Anmelden"})]})]})})}function ut({isOpen:e,onClose:t,title:n,children:r,size:a="md"}){if(j.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 s.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:s.jsxs("div",{className:"flex min-h-full items-center justify-center p-4",children:[s.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:t}),s.jsxs("div",{className:`relative bg-white rounded-lg shadow-xl w-full ${i[a]}`,children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n}),s.jsx(T,{variant:"ghost",size:"sm",onClick:t,children:s.jsx(Os,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-6",children:r})]})]})})}function v2(){var S,E,D,$,L,U;const{user:e,isCustomer:t,isCustomerPortal:n}=qe(),[r,a]=j.useState(!1),{data:i,isLoading:l}=de({queryKey:["app-settings-public"],queryFn:()=>Ur.getPublic(),enabled:n,staleTime:0}),o=!l&&((S=i==null?void 0:i.data)==null?void 0:S.customerSupportTicketsEnabled)==="true",{data:c}=de({queryKey:["customers-count"],queryFn:()=>kt.getAll({limit:1}),enabled:!t}),{data:u}=de({queryKey:["contracts",t?e==null?void 0:e.customerId:void 0],queryFn:()=>Ke.getAll(t?{customerId:e==null?void 0:e.customerId}:{limit:1})}),{data:d}=de({queryKey:["contracts-active",t?e==null?void 0:e.customerId:void 0],queryFn:()=>Ke.getAll({status:"ACTIVE",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:h}=de({queryKey:["contracts-pending",t?e==null?void 0:e.customerId:void 0],queryFn:()=>Ke.getAll({status:"PENDING",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:p}=de({queryKey:["task-stats"],queryFn:()=>ct.getStats()}),{data:m}=de({queryKey:["contract-cockpit"],queryFn:()=>Ke.getCockpit(),enabled:!t,staleTime:0}),{ownContracts:f,representedContracts:g}=j.useMemo(()=>{if(!n||!(u!=null&&u.data))return{ownContracts:[],representedContracts:[]};const V=[],O={};for(const P of u.data)if(P.customerId===(e==null?void 0:e.customerId))V.push(P);else{const b=P.customerId;if(!O[b]){const z=P.customer?P.customer.companyName||`${P.customer.firstName} ${P.customer.lastName}`:`Kunde ${b}`;O[b]={customerName:z,contracts:[]}}O[b].contracts.push(P)}return{ownContracts:V,representedContracts:Object.values(O).sort((P,b)=>P.customerName.localeCompare(b.customerName))}},[u==null?void 0:u.data,n,e==null?void 0:e.customerId]),N=j.useMemo(()=>f.filter(V=>V.status==="ACTIVE").length,[f]),x=j.useMemo(()=>f.filter(V=>V.status==="PENDING").length,[f]),y=j.useMemo(()=>f.filter(V=>V.status==="EXPIRED").length,[f]),v=j.useMemo(()=>g.reduce((V,O)=>V+O.contracts.length,0),[g]),w=j.useMemo(()=>g.reduce((V,O)=>V+O.contracts.filter(P=>P.status==="ACTIVE").length,0),[g]),k=j.useMemo(()=>g.reduce((V,O)=>V+O.contracts.filter(P=>P.status==="EXPIRED").length,0),[g]),C=((E=p==null?void 0:p.data)==null?void 0:E.openCount)||0,A=V=>s.jsx(Y,{className:V.link?"cursor-pointer hover:shadow-md transition-shadow":"",children:V.link?s.jsx(Se,{to:V.link,className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${V.color}`,children:s.jsx(V.icon,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm text-gray-500",children:V.label}),s.jsx("p",{className:"text-2xl font-bold",children:V.value})]})]})}):s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${V.color}`,children:s.jsx(V.icon,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm text-gray-500",children:V.label}),s.jsx("p",{className:"text-2xl font-bold",children:V.value})]})]})},V.label);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("h1",{className:"text-2xl font-bold",children:["Willkommen, ",e==null?void 0:e.firstName,"!"]}),n&&o&&s.jsxs(T,{onClick:()=>a(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Support-Anfrage"]})]}),n?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(yc,{className:"w-5 h-5 text-blue-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Meine Verträge"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[A({label:"Eigene Verträge",value:f.length,icon:Xe,color:"bg-blue-500",link:"/contracts"}),A({label:"Davon aktiv",value:N,icon:vs,color:"bg-green-500"}),A({label:"Davon ausstehend",value:x,icon:Sn,color:"bg-yellow-500"}),A({label:"Davon abgelaufen",value:y,icon:Tp,color:"bg-red-500"})]})]}),v>0&&s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(pa,{className:"w-5 h-5 text-purple-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Fremdverträge"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[A({label:"Fremdverträge",value:v,icon:pa,color:"bg-purple-500",link:"/contracts"}),A({label:"Davon aktiv",value:w,icon:vs,color:"bg-green-500"}),s.jsx("div",{className:"hidden lg:block"}),A({label:"Davon abgelaufen",value:k,icon:Tp,color:"bg-red-500"})]})]}),s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Xi,{className:"w-5 h-5 text-orange-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Support-Anfragen"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:A({label:"Offene Anfragen",value:C,icon:Xi,color:"bg-orange-500",link:"/tasks"})})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6",children:[A({label:"Kunden",value:((D=c==null?void 0:c.pagination)==null?void 0:D.total)||0,icon:pa,color:"bg-blue-500",link:"/customers"}),A({label:"Verträge gesamt",value:(($=u==null?void 0:u.pagination)==null?void 0:$.total)||0,icon:Xe,color:"bg-purple-500",link:"/contracts"}),A({label:"Aktive Verträge",value:((L=d==null?void 0:d.pagination)==null?void 0:L.total)||0,icon:vs,color:"bg-green-500"}),A({label:"Ausstehende Verträge",value:((U=h==null?void 0:h.pagination)==null?void 0:U.total)||0,icon:xn,color:"bg-yellow-500"})]}),(m==null?void 0:m.data)&&s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xn,{className:"w-5 h-5 text-red-500"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Vertrags-Cockpit"})]}),s.jsx(Se,{to:"/contracts/cockpit",className:"text-sm text-blue-600 hover:underline",children:"Alle anzeigen"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsx(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Se,{to:"/contracts/cockpit?filter=critical",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-red-100",children:s.jsx(xn,{className:"w-6 h-6 text-red-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",m.data.thresholds.criticalDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-red-600",children:m.data.summary.criticalCount})]})]})})}),s.jsx(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Se,{to:"/contracts/cockpit?filter=warning",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-yellow-100",children:s.jsx(Ys,{className:"w-6 h-6 text-yellow-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",m.data.thresholds.warningDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:m.data.summary.warningCount})]})]})})}),s.jsx(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Se,{to:"/contracts/cockpit?filter=ok",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-green-100",children:s.jsx(vs,{className:"w-6 h-6 text-green-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",m.data.thresholds.okDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-green-600",children:m.data.summary.okCount})]})]})})}),s.jsx(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Se,{to:"/contracts/cockpit",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-gray-100",children:s.jsx(Xe,{className:"w-6 h-6 text-gray-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm text-gray-500",children:"Handlungsbedarf"}),s.jsx("p",{className:"text-2xl font-bold text-gray-600",children:m.data.summary.totalContracts})]})]})})})]})]}),s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Ji,{className:"w-5 h-5 text-orange-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Aufgaben"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:A({label:"Offene Aufgaben",value:C,icon:Ji,color:"bg-orange-500",link:"/tasks"})})]})]}),n&&s.jsx(j2,{isOpen:r,onClose:()=>a(!1)})]})}function j2({isOpen:e,onClose:t}){const{user:n}=qe(),r=Wt(),a=xe(),[i,l]=j.useState("own"),[o,c]=j.useState(null),[u,d]=j.useState(""),[h,p]=j.useState(""),[m,f]=j.useState(!1),[g,N]=j.useState(""),{data:x}=de({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>Ke.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),y=j.useMemo(()=>{if(!(x!=null&&x.data))return{own:[],represented:{}};const S=[],E={};for(const D of x.data)if(D.customerId===(n==null?void 0:n.customerId))S.push(D);else{if(!E[D.customerId]){const $=D.customer?D.customer.companyName||`${D.customer.firstName} ${D.customer.lastName}`:`Kunde ${D.customerId}`;E[D.customerId]={name:$,contracts:[]}}E[D.customerId].contracts.push(D)}return{own:S,represented:E}},[x==null?void 0:x.data,n==null?void 0:n.customerId]),v=Object.keys(y.represented).length>0,w=j.useMemo(()=>{var S;return i==="own"?y.own:((S=y.represented[i])==null?void 0:S.contracts)||[]},[i,y]),k=j.useMemo(()=>{if(!g)return w;const S=g.toLowerCase();return w.filter(E=>E.contractNumber.toLowerCase().includes(S)||(E.providerName||"").toLowerCase().includes(S)||(E.tariffName||"").toLowerCase().includes(S))},[w,g]),C=async()=>{if(!(!o||!u.trim())){f(!0);try{await ct.createSupportTicket(o,{title:u.trim(),description:h.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)}}},A=()=>{d(""),p(""),c(null),l("own"),N(""),t()};return s.jsx(ut,{isOpen:e,onClose:A,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[v&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),s.jsxs("select",{value:i,onChange:S=>{const E=S.target.value;l(E==="own"?"own":parseInt(E)),c(null),N("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(y.represented).map(([S,{name:E}])=>s.jsx("option",{value:S,children:E},S))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(q,{placeholder:"Vertrag suchen...",value:g,onChange:S=>N(S.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(S=>s.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:[s.jsx("div",{className:"font-medium",children:S.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[S.providerName||"Kein Anbieter",S.tariffName&&` - ${S.tariffName}`]})]},S.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(q,{value:u,onChange:S=>d(S.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:h,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"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:A,children:"Abbrechen"}),s.jsx(T,{onClick:C,disabled:!o||!u.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function ve({children:e,variant:t="default",className:n="",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 s.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${a[t]} ${n}`,onClick:r,children:e})}function b2(){const[e,t]=j.useState(""),[n,r]=j.useState(""),[a,i]=j.useState(1),{hasPermission:l}=qe(),{data:o,isLoading:c}=de({queryKey:["customers",e,n,a],queryFn:()=>kt.getAll({search:e,type:n||void 0,page:a,limit:20})});return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Kunden"}),l("customers:create")&&s.jsx(Se,{to:"/customers/new",children:s.jsxs(T,{children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Neuer Kunde"]})})]}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(q,{placeholder:"Suchen...",value:e,onChange:u=>t(u.target.value),className:"flex-1"}),s.jsxs("select",{value:n,onChange:u=>r(u.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg w-28 flex-shrink-0",children:[s.jsx("option",{value:"",children:"Alle"}),s.jsx("option",{value:"PRIVATE",children:"Privat"}),s.jsx("option",{value:"BUSINESS",children:"Firma"})]}),s.jsx(T,{variant:"secondary",className:"flex-shrink-0",children:s.jsx(fl,{className:"w-4 h-4"})})]})}),s.jsx(Y,{children:c?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):o!=null&&o.data&&o.data.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kundennr."}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Verträge"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:o.data.map(u=>{var d;return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:u.customerNumber}),s.jsx("td",{className:"py-3 px-4",children:u.type==="BUSINESS"&&u.companyName?u.companyName:`${u.firstName} ${u.lastName}`}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:u.type==="BUSINESS"?"info":"default",children:u.type==="BUSINESS"?"Firma":"Privat"})}),s.jsx("td",{className:"py-3 px-4",children:u.email||"-"}),s.jsx("td",{className:"py-3 px-4",children:((d=u._count)==null?void 0:d.contracts)||0}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Se,{to:`/customers/${u.id}`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Ae,{className:"w-4 h-4"})})}),l("customers:update")&&s.jsx(Se,{to:`/customers/${u.id}/edit`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(st,{className:"w-4 h-4"})})})]})})]},u.id)})})]})}),o.pagination&&o.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",o.pagination.page," von ",o.pagination.totalPages," (",o.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>i(u=>Math.max(1,u-1)),disabled:a===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>i(u=>u+1),disabled:a>=o.pagination.totalPages,children:"Weiter"})]})]})]}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kunden gefunden."})})]})}function N2({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailDeleted:r,isLoading:a,folder:i="INBOX",accountId:l}){const o=i==="SENT",[c,u]=j.useState(null),{hasPermission:d}=qe(),h=E=>{if(o)try{const D=JSON.parse(E.toAddresses);if(D.length>0)return`An: ${D[0]}${D.length>1?` (+${D.length-1})`:""}`}catch{return"An: (Unbekannt)"}return E.fromName||E.fromAddress},p=xe(),m=H({mutationFn:E=>Le.toggleStar(E),onSuccess:(E,D)=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["email",D]})}}),f=H({mutationFn:({emailId:E,isRead:D})=>Le.markAsRead(E,D),onSuccess:(E,D)=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["email",D.emailId]}),l&&p.invalidateQueries({queryKey:["folder-counts",l]})}}),g=H({mutationFn:E=>Le.delete(E),onSuccess:(E,D)=>{p.invalidateQueries({queryKey:["emails"]}),l&&p.invalidateQueries({queryKey:["folder-counts",l]}),Ue.success("E-Mail in Papierkorb verschoben"),u(null),r==null||r(D)},onError:E=>{console.error("Delete error:",E),Ue.error(E.message||"Fehler beim Löschen der E-Mail"),u(null)}}),N=H({mutationFn:E=>Le.unassignFromContract(E),onSuccess:()=>{p.invalidateQueries({queryKey:["emails"]}),Ue.success("Vertragszuordnung aufgehoben")},onError:E=>{console.error("Unassign error:",E),Ue.error(E.message||"Fehler beim Aufheben der Zuordnung")}}),x=(E,D)=>{E.stopPropagation(),N.mutate(D)},y=(E,D)=>{E.stopPropagation(),u(D)},v=E=>{E.stopPropagation(),c&&g.mutate(c)},w=E=>{E.stopPropagation(),u(null)},k=E=>{const D=new Date(E),$=new Date;return D.toDateString()===$.toDateString()?D.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):D.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},C=(E,D)=>{E.stopPropagation(),m.mutate(D)},A=(E,D)=>{E.stopPropagation(),f.mutate({emailId:D.id,isRead:!D.isRead})},S=E=>{E.isRead||f.mutate({emailId:E.id,isRead:!0}),n(E)};return a?s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[s.jsx(Gs,{className:"w-12 h-12 mb-2 opacity-50"}),s.jsx("p",{children:"Keine E-Mails vorhanden"})]}):s.jsxs("div",{className:"divide-y divide-gray-200",children:[e.map(E=>s.jsxs("div",{onClick:()=>S(E),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",t===E.id?"bg-blue-100":["hover:bg-gray-100",E.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:t===E.id?"4px solid #2563eb":"4px solid transparent"},children:[s.jsx("button",{onClick:D=>A(D,E),className:` + flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200 + ${E.isRead?"text-gray-400":"text-blue-600"} + `,title:E.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:E.isRead?s.jsx(K0,{className:"w-4 h-4"}):s.jsx(Gs,{className:"w-4 h-4"})}),s.jsx("button",{onClick:D=>C(D,E.id),className:` + flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200 + ${E.isStarred?"text-yellow-500":"text-gray-400"} + `,title:E.isStarred?"Stern entfernen":"Als wichtig markieren",children:s.jsx(Km,{className:`w-4 h-4 ${E.isStarred?"fill-current":""}`})}),d("emails:delete")&&s.jsx("button",{onClick:D=>y(D,E.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"E-Mail löschen",children:s.jsx(be,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("span",{className:`text-sm truncate ${E.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:h(E)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:k(E.receivedAt)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm truncate ${E.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:E.subject||"(Kein Betreff)"}),E.hasAttachments&&s.jsx(gc,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),E.contract&&s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[s.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:E.contract.contractNumber}),(i==="INBOX"||i==="SENT"&&!E.isAutoAssigned)&&s.jsx("button",{onClick:D=>x(D,E.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:N.isPending,children:s.jsx(Os,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(qt,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},E.id)),c&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:w,disabled:g.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:v,disabled:g.isPending,children:g.isPending?"Löschen...":"Löschen"})]})]})})]})}function w2({isOpen:e,onClose:t,emailId:n,attachmentFilename:r,onSuccess:a}){const[i,l]=j.useState(null),[o,c]=j.useState(new Set(["customer"])),u=xe(),{data:d,isLoading:h,error:p}=de({queryKey:["attachment-targets",n],queryFn:()=>Le.getAttachmentTargets(n),enabled:e}),m=d==null?void 0:d.data,f=H({mutationFn:()=>{if(!i)throw new Error("Kein Ziel ausgewählt");return Le.saveAttachmentTo(n,r,{entityType:i.entityType,entityId:i.entityId,targetKey:i.targetKey})},onSuccess:()=>{var k,C;Ue.success("Anhang gespeichert"),u.invalidateQueries({queryKey:["attachment-targets",n]}),u.invalidateQueries({queryKey:["customers"]}),u.invalidateQueries({queryKey:["contracts"]}),(k=m==null?void 0:m.customer)!=null&&k.id&&u.invalidateQueries({queryKey:["customer",m.customer.id.toString()]}),(C=m==null?void 0:m.contract)!=null&&C.id&&u.invalidateQueries({queryKey:["contract",m.contract.id.toString()]}),a==null||a(),g()},onError:k=>{Ue.error(k.message||"Fehler beim Speichern")}}),g=()=>{l(null),t()},N=k=>{const C=new Set(o);C.has(k)?C.delete(k):C.add(k),c(C)},x=(k,C,A,S)=>{l({entityType:k,entityId:A,targetKey:C.key,hasDocument:C.hasDocument,label:S?`${S} → ${C.label}`:C.label})},y=(k,C,A,S)=>k.map(E=>{const D=(i==null?void 0:i.entityType)===C&&(i==null?void 0:i.entityId)===A&&(i==null?void 0:i.targetKey)===E.key;return s.jsxs("div",{onClick:()=>x(C,E,A,S),className:` + flex items-center gap-3 p-3 cursor-pointer transition-colors rounded-lg ml-4 + ${D?"bg-blue-100 ring-2 ring-blue-500":"hover:bg-gray-100"} + `,children:[s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-gray-900",children:E.label}),E.hasDocument&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-yellow-100 text-yellow-800",children:[s.jsx(Ys,{className:"w-3 h-3"}),"Vorhanden"]})]})}),D&&s.jsx(Zi,{className:"w-5 h-5 text-blue-600"})]},E.key)}),v=(k,C)=>s.jsxs("div",{className:"mb-2",children:[s.jsx("div",{className:"text-sm font-medium text-gray-700 px-3 py-1 bg-gray-50 rounded",children:k.label}),y(k.slots,C,k.id,k.label)]},k.id),w=(k,C,A,S,E=!1)=>{const D=o.has(C);return s.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>N(C),className:"w-full flex items-center gap-2 p-3 bg-gray-50 hover:bg-gray-100 transition-colors",children:[D?s.jsx(Ha,{className:"w-4 h-4 text-gray-500"}):s.jsx(qt,{className:"w-4 h-4 text-gray-500"}),A,s.jsx("span",{className:"font-medium text-gray-900",children:k})]}),D&&s.jsx("div",{className:"p-2",children:E?s.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"Keine Einträge vorhanden"}):S})]})};return s.jsx(ut,{isOpen:e,onClose:g,title:"Anhang speichern unter",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"p-3 bg-gray-50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("span",{className:"font-medium",children:"Datei:"})," ",r]})}),h&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}),p&&s.jsx("div",{className:"p-4 bg-red-50 text-red-700 rounded-lg",children:"Fehler beim Laden der Dokumentziele"}),m&&s.jsxs("div",{className:"space-y-3 max-h-96 overflow-auto",children:[w(`Kunde: ${m.customer.name}`,"customer",s.jsx(yc,{className:"w-4 h-4 text-blue-600"}),y(m.customer.slots,"customer"),m.customer.slots.length===0),w("Ausweisdokumente","identityDocuments",s.jsx(XS,{className:"w-4 h-4 text-green-600"}),m.identityDocuments.map(k=>v(k,"identityDocument")),m.identityDocuments.length===0),w("Bankkarten","bankCards",s.jsx(z0,{className:"w-4 h-4 text-purple-600"}),m.bankCards.map(k=>v(k,"bankCard")),m.bankCards.length===0),m.contract&&w(`Vertrag: ${m.contract.contractNumber}`,"contract",s.jsx(Xe,{className:"w-4 h-4 text-orange-600"}),y(m.contract.slots,"contract"),m.contract.slots.length===0),!m.contract&&s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg text-sm text-gray-600",children:[s.jsx(Xe,{className:"w-4 h-4 inline-block mr-2 text-gray-400"}),"E-Mail ist keinem Vertrag zugeordnet. Ordnen Sie die E-Mail einem Vertrag zu, um Vertragsdokumente als Ziel auswählen zu können."]})]}),(i==null?void 0:i.hasDocument)&&s.jsxs("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg flex items-start gap-2",children:[s.jsx(Ys,{className:"w-5 h-5 text-yellow-600 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-yellow-800",children:[s.jsx("strong",{children:"Achtung:"})," An diesem Feld ist bereits ein Dokument hinterlegt. Das vorhandene Dokument wird durch den neuen Anhang ersetzt."]})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:g,children:"Abbrechen"}),s.jsx(T,{onClick:()=>f.mutate(),disabled:!i||f.isPending,children:f.isPending?"Wird gespeichert...":"Speichern"})]})]})})}function Q0({email:e,onReply:t,onAssignContract:n,onDeleted:r,isSentFolder:a=!1,isContractView:i=!1,isTrashView:l=!1,onRestored:o,accountId:c}){const[u,d]=j.useState(!0),[h,p]=j.useState(e.isStarred),[m,f]=j.useState(!1),[g,N]=j.useState(!1),[x,y]=j.useState(!1),[v,w]=j.useState(null),k=xe(),{hasPermission:C}=qe();j.useEffect(()=>{p(e.isStarred)},[e.id,e.isStarred]);const A=H({mutationFn:()=>Le.toggleStar(e.id),onMutate:()=>{p(z=>!z)},onSuccess:()=>{k.invalidateQueries({queryKey:["emails"]}),k.invalidateQueries({queryKey:["email",e.id]})},onError:()=>{p(e.isStarred)}}),S=H({mutationFn:()=>Le.unassignFromContract(e.id),onSuccess:()=>{k.invalidateQueries({queryKey:["emails"]}),k.invalidateQueries({queryKey:["email",e.id]}),e.contractId&&k.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Ue.success("Vertragszuordnung aufgehoben")},onError:z=>{console.error("Unassign error:",z),Ue.error(z.message||"Fehler beim Aufheben der Zuordnung")}}),E=H({mutationFn:()=>Le.delete(e.id),onSuccess:()=>{k.invalidateQueries({queryKey:["emails"]}),c&&k.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&k.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Ue.success("E-Mail in Papierkorb verschoben"),f(!1),r==null||r()},onError:z=>{console.error("Delete error:",z),Ue.error(z.message||"Fehler beim Löschen der E-Mail"),f(!1)}}),D=H({mutationFn:()=>Le.restore(e.id),onSuccess:()=>{k.invalidateQueries({queryKey:["emails"]}),c&&k.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&k.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Ue.success("E-Mail wiederhergestellt"),N(!1),o==null||o()},onError:z=>{console.error("Restore error:",z),Ue.error(z.message||"Fehler beim Wiederherstellen der E-Mail"),N(!1)}}),$=H({mutationFn:()=>Le.permanentDelete(e.id),onSuccess:()=>{k.invalidateQueries({queryKey:["emails"]}),c&&k.invalidateQueries({queryKey:["folder-counts",c]}),Ue.success("E-Mail endgültig gelöscht"),y(!1),r==null||r()},onError:z=>{console.error("Permanent delete error:",z),Ue.error(z.message||"Fehler beim endgültigen Löschen der E-Mail"),y(!1)}}),L=z=>new Date(z).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),U=z=>{try{return JSON.parse(z)}catch{return[]}},V=z=>{if(!z)return[];try{return JSON.parse(z)}catch{return[]}},O=U(e.toAddresses),P=e.ccAddresses?U(e.ccAddresses):[],b=V(e.attachmentNames);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"p-4 border-b border-gray-200 space-y-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:e.subject||"(Kein Betreff)"}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:l?s.jsxs(s.Fragment,{children:[s.jsxs(T,{variant:"secondary",size:"sm",onClick:()=>N(!0),title:"Wiederherstellen",children:[s.jsx(V0,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsxs(T,{variant:"danger",size:"sm",onClick:()=>y(!0),title:"Endgültig löschen",children:[s.jsx(be,{className:"w-4 h-4 mr-1"}),"Endgültig löschen"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>A.mutate(),className:`p-2 rounded-lg hover:bg-gray-100 ${h?"text-yellow-500":"text-gray-400"}`,title:h?"Stern entfernen":"Als wichtig markieren",children:s.jsx(Km,{className:`w-5 h-5 ${h?"fill-current":""}`})}),s.jsxs(T,{variant:"secondary",size:"sm",onClick:t,children:[s.jsx(l2,{className:"w-4 h-4 mr-1"}),"Antworten"]}),C("emails:delete")&&s.jsx(T,{variant:"danger",size:"sm",onClick:()=>f(!0),title:"E-Mail löschen",children:s.jsx(be,{className:"w-4 h-4"})})]})})]}),s.jsxs("div",{className:"text-sm space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"Von:"}),s.jsxs("span",{className:"font-medium text-gray-900",children:[e.fromName&&`${e.fromName} `,s.jsxs("span",{className:"text-gray-600",children:["<",e.fromAddress,">"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"An:"}),s.jsx("span",{className:"text-gray-700",children:O.join(", ")})]}),P.length>0&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"CC:"}),s.jsx("span",{className:"text-gray-700",children:P.join(", ")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"Am:"}),s.jsx("span",{className:"text-gray-700",children:L(e.receivedAt)})]})]}),s.jsx("div",{className:"flex items-center gap-2 pt-2",children:e.contract?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-50 border border-green-200 rounded-lg",children:[s.jsx(Rp,{className:"w-4 h-4 text-green-600"}),s.jsxs("span",{className:"text-sm text-green-800",children:["Zugeordnet zu:"," ",s.jsx(Se,{to:`/contracts/${e.contract.id}`,className:"font-medium hover:underline",children:e.contract.contractNumber})]}),!e.isAutoAssigned&&s.jsx("button",{onClick:()=>S.mutate(),className:"ml-2 p-1 hover:bg-green-100 rounded",title:"Zuordnung aufheben",children:s.jsx(Os,{className:"w-4 h-4 text-green-600"})})]}):!i&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:n,children:[s.jsx(Rp,{className:"w-4 h-4 mr-1"}),"Vertrag zuordnen"]})}),b.length>0&&s.jsxs("div",{className:"pt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(gc,{className:"w-4 h-4 text-gray-400"}),s.jsxs("span",{className:"text-sm text-gray-500",children:[b.length," Anhang",b.length>1?"e":""]})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((z,J)=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-3 py-2 bg-gray-100 rounded-lg text-sm text-gray-700",children:[s.jsx("span",{className:"max-w-[200px] truncate mr-1",children:z}),s.jsx("a",{href:Le.getAttachmentUrl(e.id,z,!0),target:"_blank",rel:"noopener noreferrer",className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${z} öffnen`,children:s.jsx(zm,{className:"w-4 h-4 text-gray-500"})}),s.jsx("a",{href:Le.getAttachmentUrl(e.id,z),download:z,className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${z} herunterladen`,children:s.jsx(Ts,{className:"w-4 h-4 text-gray-500"})}),!l&&s.jsx("button",{onClick:()=>w(z),className:"p-1 hover:bg-blue-100 rounded transition-colors",title:`${z} speichern unter...`,children:s.jsx(U0,{className:"w-4 h-4 text-blue-500"})})]},J))})]})]}),e.htmlBody&&e.textBody&&s.jsxs("div",{className:"px-4 py-2 border-b border-gray-200 flex items-center gap-2",children:[s.jsx("button",{onClick:()=>d(!0),className:`px-3 py-1 text-sm rounded ${u?"bg-blue-100 text-blue-700":"text-gray-600 hover:bg-gray-100"}`,children:"HTML"}),s.jsx("button",{onClick:()=>d(!1),className:`px-3 py-1 text-sm rounded ${u?"text-gray-600 hover:bg-gray-100":"bg-blue-100 text-blue-700"}`,children:"Text"})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:u&&e.htmlBody?s.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.htmlBody}}):s.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-700 font-sans",children:e.textBody||"Kein Inhalt"})}),m&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>f(!1),disabled:E.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>E.mutate(),disabled:E.isPending,children:E.isPending?"Löschen...":"Löschen"})]})]})}),g&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail wiederherstellen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Die E-Mail wird wieder in den ursprünglichen Ordner (",e.folder==="SENT"?"Gesendet":"Posteingang",") verschoben."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>N(!1),disabled:D.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"primary",onClick:()=>D.mutate(),disabled:D.isPending,children:D.isPending?"Wird wiederhergestellt...":"Wiederherstellen"})]})]})}),x&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail endgültig löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Diese Aktion kann nicht rückgängig gemacht werden. Die E-Mail wird unwiderruflich gelöscht."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>y(!1),disabled:$.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>$.mutate(),disabled:$.isPending,children:$.isPending?"Wird gelöscht...":"Endgültig löschen"})]})]})}),v&&s.jsx(w2,{isOpen:!0,onClose:()=>w(null),emailId:e.id,attachmentFilename:v})]})}function H0({isOpen:e,onClose:t,account:n,replyTo:r,onSuccess:a,contractId:i}){const[l,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(""),[p,m]=j.useState(""),[f,g]=j.useState([]),[N,x]=j.useState(null),y=j.useRef(null);j.useEffect(()=>{if(e){if(r){o(r.fromAddress||"");const L=r.subject||"",U=/^(Re|Aw|Fwd|Wg):\s*/i.test(L);h(U?L:`Re: ${L}`);const V=new Date(r.receivedAt).toLocaleString("de-DE"),O=r.textBody?` + +--- Ursprüngliche Nachricht --- +Von: ${r.fromName||r.fromAddress} +Am: ${V} + +${r.textBody}`:"";m(O)}else o(""),h(""),m("");u(""),g([]),x(null)}},[e,r]);const v=10*1024*1024,w=25*1024*1024,k=L=>new Promise((U,V)=>{const O=new FileReader;O.readAsDataURL(L),O.onload=()=>{const b=O.result.split(",")[1];U(b)},O.onerror=V}),C=async L=>{const U=L.target.files;if(!U)return;const V=[];let O=f.reduce((P,b)=>P+b.content.length*.75,0);for(const P of Array.from(U)){if(P.size>v){x(`Datei "${P.name}" ist zu groß (max. 10 MB)`);continue}if(O+P.size>w){x("Maximale Gesamtgröße der Anhänge erreicht (25 MB)");break}try{const b=await k(P);V.push({filename:P.name,content:b,contentType:P.type||"application/octet-stream"}),O+=P.size}catch{x(`Fehler beim Lesen von "${P.name}"`)}}V.length>0&&g(P=>[...P,...V]),y.current&&(y.current.value="")},A=L=>{g(U=>U.filter((V,O)=>O!==L))},S=L=>{const U=L.length*.75;return U<1024?`${Math.round(U)} B`:U<1024*1024?`${(U/1024).toFixed(1)} KB`:`${(U/(1024*1024)).toFixed(1)} MB`},E=H({mutationFn:()=>ls.sendEmail(n.id,{to:l.split(",").map(L=>L.trim()).filter(Boolean),cc:c?c.split(",").map(L=>L.trim()).filter(Boolean):void 0,subject:d,text:p,inReplyTo:r==null?void 0:r.messageId,references:r!=null&&r.messageId?[r.messageId]:void 0,attachments:f.length>0?f:void 0,contractId:i}),onSuccess:()=>{a==null||a(),D()},onError:L=>{x(L instanceof Error?L.message:"Fehler beim Senden")}}),D=()=>{t()},$=()=>{if(!l.trim()){x("Bitte Empfänger angeben");return}if(!d.trim()){x("Bitte Betreff angeben");return}x(null),E.mutate()};return s.jsx(ut,{isOpen:e,onClose:D,title:r?"Antworten":"Neue E-Mail",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Von"}),s.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg text-sm text-gray-700",children:n.email})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["An ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:l,onChange:L=>o(L.target.value),placeholder:"empfaenger@example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Mehrere Empfänger mit Komma trennen"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"CC"}),s.jsx("input",{type:"text",value:c,onChange:L=>u(L.target.value),placeholder:"cc@example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Betreff ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:d,onChange:L=>h(L.target.value),placeholder:"Betreff eingeben",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Nachricht"}),s.jsx("textarea",{value:p,onChange:L=>m(L.target.value),rows:10,placeholder:"Ihre Nachricht...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Anhänge"}),s.jsx("input",{type:"file",ref:y,onChange:C,multiple:!0,className:"hidden"}),s.jsxs("button",{type:"button",onClick:()=>{var L;return(L=y.current)==null?void 0:L.click()},className:"inline-flex items-center px-3 py-2 text-sm border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:[s.jsx(gc,{className:"w-4 h-4 mr-2"}),"Datei anhängen"]}),f.length>0&&s.jsx("div",{className:"mt-2 space-y-2",children:f.map((L,U)=>s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 rounded-lg",children:[s.jsxs("div",{className:"flex items-center min-w-0",children:[s.jsx(Xe,{className:"w-4 h-4 text-gray-500 mr-2 flex-shrink-0"}),s.jsx("span",{className:"text-sm text-gray-700 truncate",children:L.filename}),s.jsxs("span",{className:"ml-2 text-xs text-gray-500 flex-shrink-0",children:["(",S(L.content),")"]})]}),s.jsx("button",{type:"button",onClick:()=>A(U),className:"ml-2 p-1 text-gray-400 hover:text-red-500 transition-colors",title:"Anhang entfernen",children:s.jsx(Os,{className:"w-4 h-4"})})]},U))}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Max. 10 MB pro Datei, 25 MB gesamt"})]}),N&&s.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:N}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:D,children:"Abbrechen"}),s.jsxs(T,{onClick:$,disabled:E.isPending,children:[s.jsx(pl,{className:"w-4 h-4 mr-2"}),E.isPending?"Wird gesendet...":"Senden"]})]})]})})}function S2({isOpen:e,onClose:t,email:n,customerId:r,onSuccess:a}){const[i,l]=j.useState(""),[o,c]=j.useState(null),u=xe(),{data:d,isLoading:h}=de({queryKey:["contracts","customer",r],queryFn:()=>Ke.getAll({customerId:r}),enabled:e}),m=((d==null?void 0:d.data)||[]).filter(y=>{var w,k,C,A;if(!i)return!0;const v=i.toLowerCase();return y.contractNumber.toLowerCase().includes(v)||((k=(w=y.contractCategory)==null?void 0:w.name)==null?void 0:k.toLowerCase().includes(v))||((A=(C=y.provider)==null?void 0:C.name)==null?void 0:A.toLowerCase().includes(v))}),f=H({mutationFn:y=>Le.assignToContract(n.id,y),onSuccess:(y,v)=>{u.invalidateQueries({queryKey:["emails"]}),u.invalidateQueries({queryKey:["email",n.id]}),u.invalidateQueries({queryKey:["contract-folder-counts",v]}),a==null||a(),g()}}),g=()=>{l(""),c(null),t()},N=()=>{o&&f.mutate(o)},x=y=>y?new Date(y).toLocaleDateString("de-DE"):"-";return s.jsx(ut,{isOpen:e,onClose:g,title:"E-Mail Vertrag zuordnen",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("span",{className:"font-medium",children:"Betreff:"})," ",n.subject||"(Kein Betreff)"]}),s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("span",{className:"font-medium",children:"Von:"})," ",n.fromAddress]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(fl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx("input",{type:"text",value:i,onChange:y=>l(y.target.value),placeholder:"Vertrag suchen...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),s.jsx("div",{className:"border border-gray-200 rounded-lg max-h-80 overflow-auto",children:h?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):m.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(Xe,{className:"w-8 h-8 mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:"Keine Verträge gefunden"})]}):s.jsx("div",{className:"divide-y divide-gray-200",children:m.map(y=>{var v;return s.jsx("div",{onClick:()=>c(y.id),className:` + flex items-center gap-3 p-3 cursor-pointer transition-colors + ${o===y.id?"bg-blue-50 border-l-2 border-l-blue-500":"hover:bg-gray-50"} + `,children:s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-medium text-gray-900",children:y.contractNumber}),s.jsx("span",{className:` + px-2 py-0.5 text-xs rounded-full + ${y.status==="ACTIVE"?"bg-green-100 text-green-800":y.status==="PENDING"?"bg-yellow-100 text-yellow-800":y.status==="CANCELLED"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"} + `,children:y.status})]}),s.jsxs("div",{className:"text-sm text-gray-600 truncate",children:[(v=y.contractCategory)==null?void 0:v.name,y.provider&&` - ${y.provider.name}`]}),s.jsxs("div",{className:"text-xs text-gray-500",children:["Start: ",x(y.startDate)]})]})},y.id)})})}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:g,children:"Abbrechen"}),s.jsx(T,{onClick:N,disabled:!o||f.isPending,children:f.isPending?"Wird zugeordnet...":"Zuordnen"})]})]})})}function W0({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailRestored:r,onEmailDeleted:a,isLoading:i}){const[l,o]=j.useState(null),[c,u]=j.useState(null),d=xe(),h=C=>{if(C.folder==="SENT")try{const A=JSON.parse(C.toAddresses);if(A.length>0)return`An: ${A[0]}${A.length>1?` (+${A.length-1})`:""}`}catch{return"An: (Unbekannt)"}return C.fromName||C.fromAddress},p=H({mutationFn:C=>Le.restore(C),onSuccess:(C,A)=>{d.invalidateQueries({queryKey:["emails"]}),Ue.success("E-Mail wiederhergestellt"),o(null),u(null),r==null||r(A)},onError:C=>{console.error("Restore error:",C),Ue.error(C.message||"Fehler beim Wiederherstellen"),o(null),u(null)}}),m=H({mutationFn:C=>Le.permanentDelete(C),onSuccess:(C,A)=>{d.invalidateQueries({queryKey:["emails"]}),Ue.success("E-Mail endgültig gelöscht"),o(null),u(null),a==null||a(A)},onError:C=>{console.error("Permanent delete error:",C),Ue.error(C.message||"Fehler beim endgültigen Löschen"),o(null),u(null)}}),f=H({mutationFn:C=>Le.unassignFromContract(C),onSuccess:()=>{d.invalidateQueries({queryKey:["emails"]}),Ue.success("Vertragszuordnung aufgehoben")},onError:C=>{console.error("Unassign error:",C),Ue.error(C.message||"Fehler beim Aufheben der Zuordnung")}}),g=(C,A)=>{C.stopPropagation(),f.mutate(A)},N=(C,A)=>{C.stopPropagation(),o(A),u("restore")},x=(C,A)=>{C.stopPropagation(),o(A),u("delete")},y=C=>{C.stopPropagation(),l&&c&&(c==="restore"?p.mutate(l):m.mutate(l))},v=C=>{C.stopPropagation(),o(null),u(null)},w=C=>new Date(C).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"}),k=C=>{if(!C)return"";const A=new Date(C),S=new Date;return A.toDateString()===S.toDateString()?`Gelöscht um ${A.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}`:`Gelöscht am ${A.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})}`};return i?s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-red-600"})}):e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[s.jsx(be,{className:"w-12 h-12 mb-2 opacity-50"}),s.jsx("p",{children:"Papierkorb ist leer"})]}):s.jsxs("div",{className:"divide-y divide-gray-200",children:[e.map(C=>s.jsxs("div",{onClick:()=>n(C),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",t===C.id?"bg-red-100":"hover:bg-gray-100 bg-gray-50/50"].join(" "),style:{borderLeft:t===C.id?"4px solid #dc2626":"4px solid transparent"},children:[s.jsx("div",{className:"flex-shrink-0 mt-1 p-1 -ml-1 text-gray-400",title:C.folder==="SENT"?"Aus Gesendet":"Aus Posteingang",children:C.folder==="SENT"?s.jsx(pl,{className:"w-4 h-4"}):s.jsx(Tr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:A=>N(A,C.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-green-100 text-gray-400 hover:text-green-600",title:"Wiederherstellen",children:s.jsx(V0,{className:"w-4 h-4"})}),s.jsx("button",{onClick:A=>x(A,C.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"Endgültig löschen",children:s.jsx(be,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("span",{className:"text-sm truncate text-gray-700",children:h(C)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:w(C.receivedAt)})]}),s.jsx("div",{className:"text-sm truncate text-gray-600",children:C.subject||"(Kein Betreff)"}),s.jsx("div",{className:"text-xs text-red-500 mt-1",children:k(C.deletedAt)}),C.contract&&s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[s.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:C.contract.contractNumber}),(C.folder==="INBOX"||C.folder==="SENT"&&!C.isAutoAssigned)&&s.jsx("button",{onClick:A=>g(A,C.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:f.isPending,children:s.jsx(Os,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(qt,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},C.id)),l&&c&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:c==="restore"?"E-Mail wiederherstellen?":"E-Mail endgültig löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:c==="restore"?"Die E-Mail wird wieder in den ursprünglichen Ordner verschoben.":"Die E-Mail wird unwiderruflich gelöscht. Diese Aktion kann nicht rückgängig gemacht werden."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:v,disabled:p.isPending||m.isPending,children:"Abbrechen"}),s.jsx(T,{variant:c==="restore"?"primary":"danger",onClick:y,disabled:p.isPending||m.isPending,children:p.isPending||m.isPending?"Wird ausgeführt...":c==="restore"?"Wiederherstellen":"Endgültig löschen"})]})]})})]})}function k2({customerId:e}){const[t,n]=j.useState(null),[r,a]=j.useState("INBOX"),[i,l]=j.useState(null),[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,p]=j.useState(null),m=xe(),{hasPermission:f}=qe(),g=f("emails:delete"),{data:N,isLoading:x}=de({queryKey:["mailbox-accounts",e],queryFn:()=>Le.getMailboxAccounts(e)}),y=(N==null?void 0:N.data)||[];j.useEffect(()=>{y.length>0&&!t&&n(y[0].id)},[y,t]);const v=y.find(le=>le.id===t),{data:w,isLoading:k,refetch:C}=de({queryKey:["emails","customer",e,t,r],queryFn:()=>Le.getForCustomer(e,{accountId:t||void 0,folder:r}),enabled:!!t&&r!=="TRASH"}),A=(w==null?void 0:w.data)||[],{data:S,isLoading:E}=de({queryKey:["emails","trash",e],queryFn:()=>Le.getTrash(e),enabled:r==="TRASH"&&g}),D=(S==null?void 0:S.data)||[],{data:$}=de({queryKey:["folder-counts",t],queryFn:()=>ls.getFolderCounts(t),enabled:!!t}),L=($==null?void 0:$.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0,trash:0,trashUnread:0},{data:U}=de({queryKey:["email",i==null?void 0:i.id],queryFn:()=>Le.getById(i.id),enabled:!!(i!=null&&i.id)}),V=(U==null?void 0:U.data)||i,O=H({mutationFn:le=>ls.syncEmails(le),onSuccess:()=>{m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),m.invalidateQueries({queryKey:["mailbox-accounts",e]})}}),P=()=>{t&&O.mutate(t)},b=le=>{l(le)},z=()=>{p(V||null),c(!0)},J=()=>{p(null),c(!0)},ee=()=>{d(!0)};if(!x&&y.length===0)return s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Gs,{className:"w-16 h-16 mb-4 opacity-30"}),s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Keine E-Mail-Konten vorhanden"}),s.jsx("p",{className:"text-sm text-center max-w-md",children:"Erstellen Sie eine Stressfrei-Wechseln E-Mail-Adresse mit aktivierter Mailbox, um E-Mails hier empfangen und versenden zu können."})]});const pe=le=>{a(le),l(null)};return s.jsxs("div",{className:"flex flex-col h-full",style:{minHeight:"600px"},children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 p-4 border-b border-gray-200 bg-gray-50",children:[y.length>1?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Tr,{className:"w-5 h-5 text-gray-500"}),s.jsx("select",{value:t||"",onChange:le=>{n(Number(le.target.value)),l(null)},className:"px-3 py-2 border border-gray-300 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm",children:y.map(le=>s.jsx("option",{value:le.id,children:le.email},le.id))})]}):s.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-600",children:[s.jsx(Tr,{className:"w-5 h-5 text-gray-500"}),s.jsx("span",{children:v==null?void 0:v.email})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>pe("INBOX"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Tr,{className:"w-4 h-4"}),"Posteingang",L.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${L.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${L.inboxUnread} ungelesen / ${L.inbox} gesamt`,children:L.inboxUnread>0?`${L.inboxUnread}/${L.inbox}`:L.inbox})]}),s.jsxs("button",{onClick:()=>pe("SENT"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(pl,{className:"w-4 h-4"}),"Gesendet",L.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${L.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${L.sentUnread} ungelesen / ${L.sent} gesamt`,children:L.sentUnread>0?`${L.sentUnread}/${L.sent}`:L.sent})]}),g&&s.jsxs("button",{onClick:()=>pe("TRASH"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="TRASH"?"bg-white text-red-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(be,{className:"w-4 h-4"}),"Papierkorb",L.trash>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${L.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${L.trashUnread} ungelesen / ${L.trash} gesamt`,children:L.trashUnread>0?`${L.trashUnread}/${L.trash}`:L.trash})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r!=="TRASH"&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:P,disabled:O.isPending||!t,children:[s.jsx(fr,{className:`w-4 h-4 mr-1 ${O.isPending?"animate-spin":""}`}),O.isPending?"Sync...":"Synchronisieren"]}),s.jsxs(T,{size:"sm",onClick:J,disabled:!v,children:[s.jsx($e,{className:"w-4 h-4 mr-1"}),"Neue E-Mail"]})]})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.jsx("div",{className:"w-1/3 border-r border-gray-200 overflow-auto",children:r==="TRASH"?s.jsx(W0,{emails:D,selectedEmailId:i==null?void 0:i.id,onSelectEmail:b,onEmailRestored:le=>{(i==null?void 0:i.id)===le&&l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},onEmailDeleted:le=>{(i==null?void 0:i.id)===le&&l(null),m.invalidateQueries({queryKey:["emails","trash"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:E}):s.jsx(N2,{emails:A,selectedEmailId:i==null?void 0:i.id,onSelectEmail:b,onEmailDeleted:le=>{(i==null?void 0:i.id)===le&&l(null),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:k,folder:r,accountId:t})}),s.jsx("div",{className:"flex-1 overflow-auto",children:V?s.jsx(Q0,{email:V,onReply:z,onAssignContract:ee,onDeleted:()=>{l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},isSentFolder:r==="SENT",isTrashView:r==="TRASH",onRestored:()=>{l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},accountId:t||void 0}):s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[s.jsx(Gs,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),v&&s.jsx(H0,{isOpen:o,onClose:()=>{c(!1),p(null)},account:v,replyTo:h||void 0,onSuccess:()=>{m.invalidateQueries({queryKey:["emails","customer",e,t,"SENT"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),r==="SENT"&&C()}}),V&&s.jsx(S2,{isOpen:u,onClose:()=>d(!1),email:V,customerId:e,onSuccess:()=>{C()}})]})}function C2({contractId:e,customerId:t}){const[n,r]=j.useState(null),[a,i]=j.useState("INBOX"),[l,o]=j.useState(null),[c,u]=j.useState(!1),[d,h]=j.useState(null),[p,m]=j.useState(null),f=xe(),{hasPermission:g}=qe(),N=g("emails:delete"),{data:x,isLoading:y}=de({queryKey:["mailbox-accounts",t],queryFn:()=>Le.getMailboxAccounts(t)}),v=(x==null?void 0:x.data)||[];j.useEffect(()=>{v.length>0&&!n&&r(v[0].id)},[v,n]);const w=v.find(X=>X.id===n),{data:k,isLoading:C,refetch:A}=de({queryKey:["emails","contract",e,a],queryFn:()=>Le.getForContract(e,{folder:a}),enabled:a!=="TRASH"}),S=(k==null?void 0:k.data)||[],{data:E,isLoading:D}=de({queryKey:["emails","trash",t],queryFn:()=>Le.getTrash(t),enabled:a==="TRASH"&&N}),$=(E==null?void 0:E.data)||[],{data:L}=de({queryKey:["contract-folder-counts",e],queryFn:()=>Le.getContractFolderCounts(e)}),U=(L==null?void 0:L.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0},{data:V}=de({queryKey:["folder-counts",n],queryFn:()=>ls.getFolderCounts(n),enabled:!!n&&N}),O=(V==null?void 0:V.data)||{trash:0,trashUnread:0},{data:P}=de({queryKey:["email",l==null?void 0:l.id],queryFn:()=>Le.getById(l.id),enabled:!!(l!=null&&l.id)}),b=(P==null?void 0:P.data)||l,z=H({mutationFn:X=>ls.syncEmails(X),onSuccess:()=>{f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]}),Ue.success("Synchronisation abgeschlossen")},onError:X=>{Ue.error(X.message||"Synchronisation fehlgeschlagen")}}),J=H({mutationFn:X=>Le.toggleStar(X),onSuccess:(X,ge)=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["email",ge]})}}),ee=H({mutationFn:({emailId:X,isRead:ge})=>Le.markAsRead(X,ge),onSuccess:(X,ge)=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["email",ge.emailId]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})}}),pe=H({mutationFn:X=>Le.unassignFromContract(X),onSuccess:()=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),o(null),Ue.success("Zuordnung aufgehoben")},onError:X=>{Ue.error(X.message||"Fehler beim Aufheben der Zuordnung")}}),le=H({mutationFn:X=>Le.delete(X),onSuccess:(X,ge)=>{f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]}),Ue.success("E-Mail in Papierkorb verschoben"),m(null),(l==null?void 0:l.id)===ge&&o(null)},onError:X=>{Ue.error(X.message||"Fehler beim Löschen der E-Mail"),m(null)}}),nt=()=>{n&&z.mutate(n)},Q=X=>{const ge=new Date(X),Wa=new Date;return ge.toDateString()===Wa.toDateString()?ge.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):ge.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},ke=(X,ge)=>{X.stopPropagation(),J.mutate(ge)},Pe=(X,ge)=>{X.stopPropagation(),ee.mutate({emailId:ge.id,isRead:!ge.isRead})},Ge=X=>{X.isRead||ee.mutate({emailId:X.id,isRead:!0}),o(X)},ht=()=>{h(b||null),u(!0)},Tt=()=>{h(null),u(!0)},W=(X,ge)=>{X.stopPropagation(),(l==null?void 0:l.id)===ge&&o(null),pe.mutate(ge)},_e=(X,ge)=>{X.stopPropagation(),m(ge)},Et=X=>{X.stopPropagation(),p&&le.mutate(p)},$s=X=>{X.stopPropagation(),m(null)},ws=X=>{i(X),o(null)},ur=X=>{if(a==="SENT")try{const ge=JSON.parse(X.toAddresses);if(ge.length>0)return`An: ${ge[0]}${ge.length>1?` (+${ge.length-1})`:""}`}catch{return"An: (Unbekannt)"}return X.fromName||X.fromAddress};return!y&&v.length===0?s.jsx(Y,{title:"E-Mails",children:s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(Gs,{className:"w-10 h-10 mb-2 opacity-30"}),s.jsx("p",{className:"text-sm",children:"Keine E-Mail-Konten vorhanden"}),s.jsx("p",{className:"text-xs mt-1",children:"Erstellen Sie eine E-Mail-Adresse beim Kunden mit aktivierter Mailbox"})]})}):s.jsxs(Y,{title:s.jsx("div",{className:"flex items-center gap-4",children:s.jsx("span",{children:"E-Mails"})}),actions:s.jsxs("div",{className:"flex items-center gap-2",children:[a!=="TRASH"&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:nt,disabled:z.isPending||!n,children:[s.jsx(fr,{className:`w-4 h-4 mr-1 ${z.isPending?"animate-spin":""}`}),z.isPending?"Sync...":"Sync"]}),w&&s.jsxs(T,{size:"sm",onClick:Tt,children:[s.jsx($e,{className:"w-4 h-4 mr-1"}),"Neue E-Mail"]})]}),children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4 border-b border-gray-200 -mt-2",children:[v.length>1?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Tr,{className:"w-4 h-4 text-gray-500"}),s.jsx("select",{value:n||"",onChange:X=>{r(Number(X.target.value)),o(null)},className:"px-2 py-1.5 border border-gray-300 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm",children:v.map(X=>s.jsx("option",{value:X.id,children:X.email},X.id))})]}):s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[s.jsx(Tr,{className:"w-4 h-4 text-gray-500"}),s.jsx("span",{children:w==null?void 0:w.email})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>ws("INBOX"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${a==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Tr,{className:"w-4 h-4"}),"Posteingang",U.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${U.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${U.inboxUnread} ungelesen / ${U.inbox} gesamt`,children:U.inboxUnread>0?`${U.inboxUnread}/${U.inbox}`:U.inbox})]}),s.jsxs("button",{onClick:()=>ws("SENT"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${a==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(pl,{className:"w-4 h-4"}),"Gesendet",U.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${U.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${U.sentUnread} ungelesen / ${U.sent} gesamt`,children:U.sentUnread>0?`${U.sentUnread}/${U.sent}`:U.sent})]}),N&&s.jsxs("button",{onClick:()=>ws("TRASH"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${a==="TRASH"?"bg-white text-red-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(be,{className:"w-4 h-4"}),"Papierkorb",O.trash>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${O.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${O.trashUnread} ungelesen / ${O.trash} gesamt`,children:O.trashUnread>0?`${O.trashUnread}/${O.trash}`:O.trash})]})]})]}),(a==="TRASH"?D:C)?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):(a==="TRASH"?$.length===0:S.length===0)?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(Gs,{className:"w-10 h-10 mb-2 opacity-30"}),s.jsx("p",{className:"text-sm",children:a==="INBOX"?"Keine E-Mails zugeordnet":a==="SENT"?"Keine E-Mails über diesen Vertrag gesendet":"Papierkorb ist leer"}),a==="INBOX"&&s.jsx("p",{className:"text-xs mt-1",children:"E-Mails können im E-Mail-Tab des Kunden zugeordnet werden"})]}):s.jsxs("div",{className:"flex -mx-6 -mb-6",style:{minHeight:"400px"},children:[s.jsx("div",{className:"w-1/3 border-r border-gray-200 overflow-auto",children:a==="TRASH"?s.jsx(W0,{emails:$,selectedEmailId:l==null?void 0:l.id,onSelectEmail:Ge,onEmailRestored:X=>{(l==null?void 0:l.id)===X&&o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["folder-counts",n]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]})},onEmailDeleted:X=>{(l==null?void 0:l.id)===X&&o(null),f.invalidateQueries({queryKey:["emails","trash"]}),f.invalidateQueries({queryKey:["folder-counts",n]})},isLoading:D}):s.jsx("div",{className:"divide-y divide-gray-200",children:S.map(X=>s.jsxs("div",{onClick:()=>Ge(X),className:["flex items-start gap-2 p-3 cursor-pointer transition-colors",(l==null?void 0:l.id)===X.id?"bg-blue-100":["hover:bg-gray-100",X.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:(l==null?void 0:l.id)===X.id?"4px solid #2563eb":"4px solid transparent"},children:[s.jsx("button",{onClick:ge=>Pe(ge,X),className:` + flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200 + ${X.isRead?"text-gray-400":"text-blue-600"} + `,title:X.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:X.isRead?s.jsx(K0,{className:"w-4 h-4"}):s.jsx(Gs,{className:"w-4 h-4"})}),s.jsx("button",{onClick:ge=>ke(ge,X.id),className:` + flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200 + ${X.isStarred?"text-yellow-500":"text-gray-400"} + `,title:X.isStarred?"Stern entfernen":"Als wichtig markieren",children:s.jsx(Km,{className:`w-4 h-4 ${X.isStarred?"fill-current":""}`})}),g("emails:delete")&&s.jsx("button",{onClick:ge=>_e(ge,X.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"E-Mail löschen",children:s.jsx(be,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("span",{className:`text-sm truncate ${X.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:ur(X)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:Q(X.receivedAt)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm truncate ${X.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:X.subject||"(Kein Betreff)"}),X.hasAttachments&&s.jsx(gc,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),X.contract&&s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[s.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:X.contract.contractNumber}),(a==="INBOX"||a==="SENT"&&!X.isAutoAssigned)&&s.jsx("button",{onClick:ge=>W(ge,X.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:pe.isPending,children:s.jsx(Os,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(qt,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},X.id))})}),s.jsx("div",{className:"flex-1 overflow-auto",children:b&&l?s.jsx(Q0,{email:b,onReply:ht,onAssignContract:()=>{},onDeleted:()=>{o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})},isSentFolder:a==="SENT",isContractView:a!=="TRASH",isTrashView:a==="TRASH",onRestored:()=>{o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})},accountId:b==null?void 0:b.stressfreiEmailId}):s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[s.jsx(Gs,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),p&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:$s,disabled:le.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:Et,disabled:le.isPending,children:le.isPending?"Löschen...":"Löschen"})]})]})}),w&&s.jsx(H0,{isOpen:c,onClose:()=>{u(!1),h(null)},account:w,replyTo:d||void 0,contractId:e,onSuccess:()=>{f.invalidateQueries({queryKey:["emails","contract",e,"SENT"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),a==="SENT"&&A()}})]})}function E2({tabs:e,defaultTab:t}){var a,i;const[n,r]=j.useState(t||((a=e[0])==null?void 0:a.id));return s.jsxs("div",{children:[s.jsx("div",{className:"border-b border-gray-200",children:s.jsx("nav",{className:"flex -mb-px space-x-8",children:e.map(l=>s.jsx("button",{onClick:()=>r(l.id),className:`py-4 px-1 border-b-2 font-medium text-sm whitespace-nowrap ${n===l.id?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:l.label},l.id))})}),s.jsx("div",{className:"mt-4",children:(i=e.find(l=>l.id===n))==null?void 0:i.content})]})}const Oe=j.forwardRef(({className:e="",label:t,error:n,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 s.jsxs("div",{className:u?e:"w-full",children:[t&&s.jsx("label",{htmlFor:c,className:"block text-sm font-medium text-gray-700 mb-1",children:t}),s.jsxs("select",{ref:o,id:c,className:`block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${n?"border-red-500":"border-gray-300"}`,...l,children:[s.jsx("option",{value:"",children:i}),r.map(d=>s.jsx("option",{value:d.value,children:d.label},d.value))]}),n&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});Oe.displayName="Select";function St({onUpload:e,existingFile:t,accept:n=".pdf,.jpg,.jpeg,.png",label:r="Dokument hochladen",disabled:a=!1}){const i=j.useRef(null),[l,o]=j.useState(!1),[c,u]=j.useState(!1),d=async g=>{if(g){o(!0);try{await e(g)}catch(N){console.error("Upload failed:",N),alert("Upload fehlgeschlagen")}finally{o(!1)}}},h=g=>{var x;const N=(x=g.target.files)==null?void 0:x[0];N&&d(N)},p=g=>{var x;g.preventDefault(),u(!1);const N=(x=g.dataTransfer.files)==null?void 0:x[0];N&&d(N)},m=g=>{g.preventDefault(),u(!0)},f=()=>{u(!1)};return s.jsxs("div",{className:"space-y-2",children:[t?!a&&s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>{var g;return(g=i.current)==null?void 0:g.click()},disabled:l,children:l?"Wird hochgeladen...":"Ersetzen"}):s.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:m,onDragLeave:a?void 0:f,children:l?s.jsxs("div",{className:"text-gray-500",children:[s.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..."]}):s.jsxs(s.Fragment,{children:[s.jsx(kd,{className:"w-6 h-6 text-gray-400 mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-gray-600",children:r}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"PDF, JPG oder PNG (max. 10MB)"})]})}),s.jsx("input",{ref:i,type:"file",accept:n,onChange:h,className:"hidden",disabled:a||l})]})}function me({value:e,className:t="",size:n="sm",title:r="In Zwischenablage kopieren"}){const[a,i]=j.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=n==="sm"?"w-3.5 h-3.5":"w-4 h-4";return s.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?s.jsx(Zi,{className:o}):s.jsx(Om,{className:o})})}function G0({values:e,separator:t=` +`,children:n,className:r=""}){const a=e.filter(i=>i!=null&&i!=="").map(String).join(t);return a?s.jsxs("div",{className:`relative group ${r}`,children:[n,s.jsx(me,{value:a,className:"absolute top-0 right-0 opacity-60 group-hover:opacity-100",title:"Alles kopieren"})]}):s.jsx(s.Fragment,{children:n})}function D2(){var z,J;const{id:e}=ac(),t=Wt(),n=xe(),{hasPermission:r}=qe(),[a]=lc(),i=parseInt(e),l=a.get("tab")||"addresses",[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,p]=j.useState(!1),[m,f]=j.useState(!1),[g,N]=j.useState(!1),[x,y]=j.useState(!1),[v,w]=j.useState(null),[k,C]=j.useState(null),[A,S]=j.useState(null),[E,D]=j.useState(null),[$,L]=j.useState(null),{data:U,isLoading:V}=de({queryKey:["customer",e],queryFn:()=>kt.getById(i)}),O=H({mutationFn:()=>kt.delete(i),onSuccess:()=>{t("/customers")}});if(V)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(U!=null&&U.data))return s.jsx("div",{className:"text-center py-8 text-red-600",children:"Kunde nicht gefunden"});const P=U.data,b=[{id:"addresses",label:"Adressen",content:s.jsx(M2,{customerId:i,addresses:P.addresses||[],canEdit:r("customers:update"),onAdd:()=>c(!0),onEdit:ee=>S(ee)})},{id:"bankcards",label:"Bankkarten",content:s.jsx(F2,{customerId:i,bankCards:P.bankCards||[],canEdit:r("customers:update"),showInactive:x,onToggleInactive:()=>y(!x),onAdd:()=>d(!0),onEdit:ee=>w(ee)})},{id:"documents",label:"Ausweise",content:s.jsx(T2,{customerId:i,documents:P.identityDocuments||[],canEdit:r("customers:update"),showInactive:x,onToggleInactive:()=>y(!x),onAdd:()=>p(!0),onEdit:ee=>C(ee)})},{id:"meters",label:"Zähler",content:s.jsx(I2,{customerId:i,meters:P.meters||[],canEdit:r("customers:update"),showInactive:x,onToggleInactive:()=>y(!x),onAdd:()=>f(!0),onEdit:ee=>D(ee)})},{id:"stressfrei",label:"Stressfrei-Wechseln",content:s.jsx(z2,{customerId:i,emails:P.stressfreiEmails||[],canEdit:r("customers:update"),showInactive:x,onToggleInactive:()=>y(!x),onAdd:()=>N(!0),onEdit:ee=>L(ee)})},{id:"emails",label:"E-Mail-Postfach",content:s.jsx(k2,{customerId:i})},{id:"contracts",label:"Verträge",content:s.jsx(L2,{customerId:i})},...r("customers:update")?[{id:"portal",label:"Portal",content:s.jsx(O2,{customerId:i,canEdit:r("customers:update")})}]:[]];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:P.type==="BUSINESS"&&P.companyName?P.companyName:`${P.firstName} ${P.lastName}`}),s.jsxs("p",{className:"text-gray-500 font-mono flex items-center gap-1",children:[P.customerNumber,s.jsx(me,{value:P.customerNumber})]})]}),s.jsxs("div",{className:"flex gap-2",children:[r("customers:update")&&s.jsx(Se,{to:`/customers/${e}/edit`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(st,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),r("customers:delete")&&s.jsxs(T,{variant:"danger",onClick:()=>{confirm("Kunde wirklich löschen?")&&O.mutate()},children:[s.jsx(be,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[s.jsx(Y,{title:"Stammdaten",className:"lg:col-span-2",children:s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Typ"}),s.jsx("dd",{children:s.jsx(ve,{variant:P.type==="BUSINESS"?"info":"default",children:P.type==="BUSINESS"?"Geschäftskunde":"Privatkunde"})})]}),P.salutation&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anrede"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[P.salutation,s.jsx(me,{value:P.salutation})]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorname"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[P.firstName,s.jsx(me,{value:P.firstName})]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Nachname"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[P.lastName,s.jsx(me,{value:P.lastName})]})]}),P.companyName&&s.jsxs("div",{className:"col-span-2",children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Firma"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[P.companyName,s.jsx(me,{value:P.companyName})]})]}),P.foundingDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Gründungsdatum"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(P.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(me,{value:new Date(P.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),P.birthDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsdatum"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(P.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(me,{value:new Date(P.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),P.birthPlace&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsort"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[P.birthPlace,s.jsx(me,{value:P.birthPlace})]})]})]})}),s.jsx(Y,{title:"Kontakt",children:s.jsxs("dl",{className:"space-y-3",children:[P.email&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"E-Mail"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[s.jsx("a",{href:`mailto:${P.email}`,className:"text-blue-600 hover:underline",children:P.email}),s.jsx(me,{value:P.email})]})]}),P.phone&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Telefon"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[s.jsx("a",{href:`tel:${P.phone}`,className:"text-blue-600 hover:underline",children:P.phone}),s.jsx(me,{value:P.phone})]})]}),P.mobile&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Mobil"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[s.jsx("a",{href:`tel:${P.mobile}`,className:"text-blue-600 hover:underline",children:P.mobile}),s.jsx(me,{value:P.mobile})]})]})]})})]}),P.type==="BUSINESS"&&s.jsx(P2,{customer:P,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),s.jsx(A2,{customer:P,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),P.notes&&s.jsx(Y,{title:"Notizen",className:"mb-6",children:s.jsx("p",{className:"whitespace-pre-wrap",children:P.notes})}),s.jsx(Y,{children:s.jsx(E2,{tabs:b,defaultTab:l})}),s.jsx(zp,{isOpen:o,onClose:()=>c(!1),customerId:i}),s.jsx(zp,{isOpen:!!A,onClose:()=>S(null),customerId:i,address:A}),s.jsx($p,{isOpen:u,onClose:()=>d(!1),customerId:i}),s.jsx($p,{isOpen:!!v,onClose:()=>w(null),customerId:i,bankCard:v}),s.jsx(_p,{isOpen:h,onClose:()=>p(!1),customerId:i}),s.jsx(_p,{isOpen:!!k,onClose:()=>C(null),customerId:i,document:k}),s.jsx(Kp,{isOpen:m,onClose:()=>f(!1),customerId:i}),s.jsx(Kp,{isOpen:!!E,onClose:()=>D(null),customerId:i,meter:E}),s.jsx(Bp,{isOpen:g,onClose:()=>N(!1),customerId:i,customerEmail:(z=U==null?void 0:U.data)==null?void 0:z.email}),s.jsx(Bp,{isOpen:!!$,onClose:()=>L(null),customerId:i,email:$,customerEmail:(J=U==null?void 0:U.data)==null?void 0:J.email})]})}function P2({customer:e,canEdit:t,onUpdate:n}){const r=async c=>{try{await lt.uploadBusinessRegistration(e.id,c),n()}catch(u){console.error("Upload fehlgeschlagen:",u),alert("Upload fehlgeschlagen")}},a=async()=>{if(confirm("Gewerbeanmeldung wirklich löschen?"))try{await lt.deleteBusinessRegistration(e.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}},i=async c=>{try{await lt.uploadCommercialRegister(e.id,c),n()}catch(u){console.error("Upload fehlgeschlagen:",u),alert("Upload fehlgeschlagen")}},l=async()=>{if(confirm("Handelsregisterauszug wirklich löschen?"))try{await lt.deleteCommercialRegister(e.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}};return!(e.taxNumber||e.commercialRegisterNumber||e.businessRegistrationPath||e.commercialRegisterPath)&&!t?null:s.jsxs(Y,{title:"Geschäftsdaten",className:"mb-6",children:[s.jsxs("dl",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.taxNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Steuernummer"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[e.taxNumber,s.jsx(me,{value:e.taxNumber})]})]}),e.commercialRegisterNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Handelsregisternummer"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[e.commercialRegisterNumber,s.jsx(me,{value:e.commercialRegisterNumber})]})]})]}),s.jsxs("div",{className:"mt-4 pt-4 border-t grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Gewerbeanmeldung"}),e.businessRegistrationPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.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:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${e.businessRegistrationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ts,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:r,existingFile:e.businessRegistrationPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:a,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(St,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Handelsregisterauszug"}),e.commercialRegisterPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.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:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${e.commercialRegisterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ts,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:i,existingFile:e.commercialRegisterPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:l,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(St,{onUpload:i,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})]})]})}function A2({customer:e,canEdit:t,onUpdate:n}){const r=async i=>{try{await lt.uploadPrivacyPolicy(e.id,i),n()}catch(l){console.error("Upload fehlgeschlagen:",l),alert("Upload fehlgeschlagen")}},a=async()=>{if(confirm("Datenschutzerklärung wirklich löschen?"))try{await lt.deletePrivacyPolicy(e.id),n()}catch(i){console.error("Löschen fehlgeschlagen:",i),alert("Löschen fehlgeschlagen")}};return!e.privacyPolicyPath&&!t?null:s.jsx(Y,{title:"Dokumente",className:"mb-6",children:s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Datenschutzerklärung"}),e.privacyPolicyPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.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:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${e.privacyPolicyPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ts,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:r,existingFile:e.privacyPolicyPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:a,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(St,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})})}function M2({customerId:e,addresses:t,canEdit:n,onAdd:r,onEdit:a}){const i=xe(),l=H({mutationFn:Sd.delete,onSuccess:()=>i.invalidateQueries({queryKey:["customer",e.toString()]})});return s.jsxs("div",{children:[n&&s.jsx("div",{className:"mb-4",children:s.jsxs(T,{size:"sm",onClick:r,children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]})}),t.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.map(o=>s.jsxs("div",{className:"border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(n2,{className:"w-4 h-4 text-gray-400"}),s.jsx(ve,{variant:o.type==="BILLING"?"info":"default",children:o.type==="BILLING"?"Rechnung":"Liefer-/Meldeadresse"}),o.isDefault&&s.jsx(ve,{variant:"success",children:"Standard"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>a(o),title:"Bearbeiten",children:s.jsx(st,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&l.mutate(o.id)},title:"Löschen",children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs(G0,{values:[`${o.street} ${o.houseNumber}`,`${o.postalCode} ${o.city}`,o.country],children:[s.jsxs("p",{children:[o.street," ",o.houseNumber]}),s.jsxs("p",{children:[o.postalCode," ",o.city]}),s.jsx("p",{className:"text-gray-500",children:o.country})]})]},o.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Adressen vorhanden."})]})}function F2({customerId:e,bankCards:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=xe(),c=H({mutationFn:({id:m,data:f})=>Oo.update(m,f),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=H({mutationFn:Oo.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=async(m,f)=>{try{await lt.uploadBankCardDocument(m,f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(g){console.error("Upload fehlgeschlagen:",g),alert("Upload fehlgeschlagen")}},h=async m=>{if(confirm("Dokument wirklich löschen?"))try{await lt.deleteBankCardDocument(m),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(f){console.error("Löschen fehlgeschlagen:",f),alert("Löschen fehlgeschlagen")}},p=r?t:t.filter(m=>m.isActive);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Bankkarte hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),p.length>0?s.jsx("div",{className:"space-y-4",children:p.map(m=>s.jsxs("div",{className:`border rounded-lg p-4 ${m.isActive?"":"opacity-50 bg-gray-50"}`,children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(z0,{className:"w-4 h-4 text-gray-400"}),!m.isActive&&s.jsx(ve,{variant:"danger",children:"Inaktiv"}),m.expiryDate&&new Date(m.expiryDate)l(m),title:"Bearbeiten",children:s.jsx(st,{className:"w-4 h-4"})}),m.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte deaktivieren?")&&c.mutate({id:m.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(At,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wieder aktivieren?")&&c.mutate({id:m.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wirklich löschen?")&&u.mutate(m.id)},title:"Löschen",children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-medium flex items-center gap-1",children:[m.accountHolder,s.jsx(me,{value:m.accountHolder})]}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[m.iban,s.jsx(me,{value:m.iban})]}),m.bic&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["BIC: ",m.bic,s.jsx(me,{value:m.bic})]}),m.bankName&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:[m.bankName,s.jsx(me,{value:m.bankName})]}),m.expiryDate&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Gültig bis: ",new Date(m.expiryDate).toLocaleDateString("de-DE")]}),s.jsx("div",{className:"mt-3 pt-3 border-t",children:m.documentPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("a",{href:`/api${m.documentPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${m.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ts,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:f=>d(m.id,f),existingFile:m.documentPath,accept:".pdf",label:"Ersetzen",disabled:!m.isActive}),s.jsxs("button",{onClick:()=>h(m.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[s.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&m.isActive&&s.jsx(St,{onUpload:f=>d(m.id,f),accept:".pdf",label:"PDF hochladen"})})]},m.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Bankkarten vorhanden."})]})}function T2({customerId:e,documents:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=xe(),c=H({mutationFn:({id:f,data:g})=>zo.update(f,g),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=H({mutationFn:zo.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=async(f,g)=>{try{await lt.uploadIdentityDocument(f,g),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(N){console.error("Upload fehlgeschlagen:",N),alert("Upload fehlgeschlagen")}},h=async f=>{if(confirm("Dokument wirklich löschen?"))try{await lt.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),m={ID_CARD:"Personalausweis",PASSPORT:"Reisepass",DRIVERS_LICENSE:"Führerschein",OTHER:"Sonstiges"};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Ausweis hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),p.length>0?s.jsx("div",{className:"space-y-4",children:p.map(f=>s.jsxs("div",{className:`border rounded-lg p-4 ${f.isActive?"":"opacity-50 bg-gray-50"}`,children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Xe,{className:"w-4 h-4 text-gray-400"}),s.jsx(ve,{children:m[f.type]}),!f.isActive&&s.jsx(ve,{variant:"danger",children:"Inaktiv"}),f.expiryDate&&new Date(f.expiryDate)l(f),title:"Bearbeiten",children:s.jsx(st,{className:"w-4 h-4"})}),f.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis deaktivieren?")&&c.mutate({id:f.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(At,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wieder aktivieren?")&&c.mutate({id:f.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wirklich löschen?")&&u.mutate(f.id)},title:"Löschen",children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[f.documentNumber,s.jsx(me,{value:f.documentNumber})]}),f.issuingAuthority&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Ausgestellt von: ",f.issuingAuthority,s.jsx(me,{value:f.issuingAuthority})]}),f.expiryDate&&s.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&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Klassen: ",f.licenseClasses,s.jsx(me,{value:f.licenseClasses})]}),f.type==="DRIVERS_LICENSE"&&f.licenseIssueDate&&s.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"})]}),s.jsx("div",{className:"mt-3 pt-3 border-t",children:f.documentPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.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:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${f.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ts,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:g=>d(f.id,g),existingFile:f.documentPath,accept:".pdf",label:"Ersetzen",disabled:!f.isActive}),s.jsxs("button",{onClick:()=>h(f.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[s.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&f.isActive&&s.jsx(St,{onUpload:g=>d(f.id,g),accept:".pdf",label:"PDF hochladen"})})]},f.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Ausweise vorhanden."})]})}function I2({customerId:e,meters:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const[o,c]=j.useState(null),[u,d]=j.useState(null),[h,p]=j.useState(null),m=xe(),f=H({mutationFn:({id:v,data:w})=>Xs.update(v,w),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),g=H({mutationFn:Xs.delete,onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),N=H({mutationFn:({meterId:v,readingId:w})=>Xs.deleteReading(v,w),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),x=r?t:t.filter(v=>v.isActive),y=v=>v?[...v].sort((w,k)=>new Date(k.readingDate).getTime()-new Date(w.readingDate).getTime()):[];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Zähler hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),x.length>0?s.jsx("div",{className:"space-y-4",children:x.map(v=>{const w=y(v.readings),k=u===v.id;return s.jsxs("div",{className:`border rounded-lg p-4 ${v.isActive?"":"opacity-50 bg-gray-50"}`,children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(_0,{className:"w-4 h-4 text-gray-400"}),s.jsx(ve,{variant:v.type==="ELECTRICITY"?"warning":"info",children:v.type==="ELECTRICITY"?"Strom":"Gas"}),!v.isActive&&s.jsx(ve,{variant:"danger",children:"Inaktiv"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[v.isActive&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>c(v.id),title:"Zählerstand hinzufügen",children:s.jsx($e,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(v),title:"Bearbeiten",children:s.jsx(st,{className:"w-4 h-4"})}),v.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler deaktivieren?")&&f.mutate({id:v.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(At,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wieder aktivieren?")&&f.mutate({id:v.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wirklich löschen? Alle Zählerstände werden ebenfalls gelöscht.")&&g.mutate(v.id)},title:"Löschen",children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-mono text-lg flex items-center gap-1",children:[v.meterNumber,s.jsx(me,{value:v.meterNumber})]}),v.location&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Standort: ",v.location,s.jsx(me,{value:v.location})]}),w.length>0&&s.jsxs("div",{className:"mt-3 pt-3 border-t",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("p",{className:"text-sm font-medium",children:"Zählerstände:"}),w.length>3&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>d(k?null:v.id),children:k?"Weniger anzeigen":`Alle ${w.length} anzeigen`})]}),s.jsx("div",{className:"space-y-1",children:(k?w:w.slice(0,3)).map(C=>s.jsxs("div",{className:"flex justify-between items-center text-sm group",children:[s.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(C.readingDate).toLocaleDateString("de-DE"),s.jsx(me,{value:new Date(C.readingDate).toLocaleDateString("de-DE")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[C.value.toLocaleString("de-DE")," ",C.unit,s.jsx(me,{value:C.value.toString(),title:"Nur Wert kopieren"}),s.jsx(me,{value:`${C.value.toLocaleString("de-DE")} ${C.unit}`,title:"Mit Einheit kopieren"})]}),n&&s.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[s.jsx("button",{onClick:()=>p({meterId:v.id,reading:C}),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(st,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&N.mutate({meterId:v.id,readingId:C.id})},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:s.jsx(be,{className:"w-3 h-3"})})]})]})]},C.id))})]})]},v.id)})}):s.jsx("p",{className:"text-gray-500",children:"Keine Zähler vorhanden."}),o&&s.jsx(Up,{isOpen:!0,onClose:()=>c(null),meterId:o,customerId:e}),h&&s.jsx(Up,{isOpen:!0,onClose:()=>p(null),meterId:h.meterId,customerId:e,reading:h.reading})]})}function L2({customerId:e}){const{hasPermission:t}=qe(),n=Wt(),r=xe(),[a,i]=j.useState(new Set),{data:l,isLoading:o}=de({queryKey:["contract-tree",e],queryFn:()=>Ke.getTreeForCustomer(e)}),c=(l==null?void 0:l.data)||[],u=H({mutationFn:Ke.delete,onSuccess:()=>{r.invalidateQueries({queryKey:["customer",e.toString()]}),r.invalidateQueries({queryKey:["customers"]}),r.invalidateQueries({queryKey:["contracts"]}),r.invalidateQueries({queryKey:["contract-tree",e]})},onError:g=>{alert((g==null?void 0:g.message)||"Fehler beim Löschen des Vertrags")}}),d={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},h={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"},p=g=>{i(N=>{const x=new Set(N);return x.has(g)?x.delete(g):x.add(g),x})},m=(g,N)=>g.map(x=>s.jsx("div",{children:f(x,N)},x.contract.id)),f=(g,N=0)=>{var C,A,S,E,D,$,L;const{contract:x,predecessors:y,hasHistory:v}=g,w=a.has(x.id),k=N>0;return s.jsxs("div",{children:[s.jsxs("div",{className:` + border rounded-lg p-4 transition-colors + ${k?"ml-6 border-l-4 border-l-gray-300 bg-gray-50":"hover:bg-gray-50"} + `,children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[!k&&v?s.jsx("button",{onClick:()=>p(x.id),className:"p-1 hover:bg-gray-200 rounded transition-colors",title:w?"Einklappen":"Vorgänger anzeigen",children:w?s.jsx(Ha,{className:"w-4 h-4 text-gray-500"}):s.jsx(qt,{className:"w-4 h-4 text-gray-500"})}):k?null:s.jsx("div",{className:"w-6"}),s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[x.contractNumber,s.jsx(me,{value:x.contractNumber})]}),s.jsx(ve,{children:d[x.type]||x.type}),s.jsx(ve,{variant:h[x.status]||"default",children:x.status}),k&&s.jsx("span",{className:"text-xs text-gray-500 ml-2",children:"(Vorgänger)"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${x.id}`,{state:{from:"customer",customerId:e.toString()}}),title:"Ansehen",children:s.jsx(Ae,{className:"w-4 h-4"})}),t("contracts:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${x.id}/edit`),title:"Bearbeiten",children:s.jsx(st,{className:"w-4 h-4"})}),t("contracts:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&u.mutate(x.id)},title:"Löschen",children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),(x.providerName||((C=x.provider)==null?void 0:C.name))&&s.jsxs("p",{className:`flex items-center gap-1 ${k?"ml-6":""}`,children:[x.providerName||((A=x.provider)==null?void 0:A.name),(x.tariffName||((S=x.tariff)==null?void 0:S.name))&&` - ${x.tariffName||((E=x.tariff)==null?void 0:E.name)}`,s.jsx(me,{value:(x.providerName||((D=x.provider)==null?void 0:D.name)||"")+(x.tariffName||($=x.tariff)!=null&&$.name?` - ${x.tariffName||((L=x.tariff)==null?void 0:L.name)}`:"")})]}),x.startDate&&s.jsxs("p",{className:`text-sm text-gray-500 ${k?"ml-6":""}`,children:["Beginn: ",new Date(x.startDate).toLocaleDateString("de-DE"),x.endDate&&` | Ende: ${new Date(x.endDate).toLocaleDateString("de-DE")}`]})]}),(N===0&&w||N>0)&&y.length>0&&s.jsx("div",{className:"mt-2",children:m(y,N+1)})]},x.id)};return o?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):s.jsxs("div",{children:[t("contracts:create")&&s.jsx("div",{className:"mb-4",children:s.jsx(Se,{to:`/contracts/new?customerId=${e}`,children:s.jsxs(T,{size:"sm",children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Vertrag anlegen"]})})}),c.length>0?s.jsx("div",{className:"space-y-4",children:c.map(g=>f(g,0))}):s.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."})]})}function R2({customerId:e}){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[i,l]=j.useState(!1),o=async()=>{var c;if(t){n(!1);return}l(!0);try{const u=await kt.getPortalPassword(e);a(((c=u.data)==null?void 0:c.password)||null),n(!0)}catch(u){console.error("Fehler beim Laden des Passworts:",u),alert("Fehler beim Laden des Passworts")}finally{l(!1)}};return s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx("p",{className:"text-xs text-green-600",children:"Passwort ist gesetzt"}),s.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?s.jsxs(s.Fragment,{children:[s.jsx(At,{className:"w-3 h-3"}),"Verbergen"]}):s.jsxs(s.Fragment,{children:[s.jsx(Ae,{className:"w-3 h-3"}),"Anzeigen"]})}),t&&r&&s.jsxs("span",{className:"text-xs font-mono bg-gray-100 px-2 py-1 rounded flex items-center gap-1",children:[r,s.jsx(me,{value:r})]}),t&&!r&&s.jsx("span",{className:"text-xs text-gray-500",children:"(Passwort nicht verfügbar)"})]})}function O2({customerId:e,canEdit:t}){const n=xe(),[r,a]=j.useState(!1),[i,l]=j.useState(""),[o,c]=j.useState(""),[u,d]=j.useState([]),[h,p]=j.useState(!1),{data:m,isLoading:f}=de({queryKey:["customer-portal",e],queryFn:()=>kt.getPortalSettings(e)}),{data:g,isLoading:N}=de({queryKey:["customer-representatives",e],queryFn:()=>kt.getRepresentatives(e)}),x=H({mutationFn:S=>kt.updatePortalSettings(e,S),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-portal",e]})}}),y=H({mutationFn:S=>kt.setPortalPassword(e,S),onSuccess:()=>{l(""),n.invalidateQueries({queryKey:["customer-portal",e]}),alert("Passwort wurde gesetzt")},onError:S=>{alert(S.message)}}),v=H({mutationFn:S=>kt.addRepresentative(e,S),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]}),c(""),d([])},onError:S=>{alert(S.message)}}),w=H({mutationFn:S=>kt.removeRepresentative(e,S),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]})}}),k=async()=>{if(!(o.length<2)){p(!0);try{const S=await kt.searchForRepresentative(e,o);d(S.data||[])}catch(S){console.error("Suche fehlgeschlagen:",S)}finally{p(!1)}}};if(f||N)return s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."});const C=m==null?void 0:m.data,A=(g==null?void 0:g.data)||[];return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx($m,{className:"w-5 h-5 text-gray-400"}),s.jsx("h3",{className:"font-medium",children:"Portal-Zugang"})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("label",{className:"flex items-center gap-3",children:[s.jsx("input",{type:"checkbox",checked:(C==null?void 0:C.portalEnabled)||!1,onChange:S=>x.mutate({portalEnabled:S.target.checked}),className:"rounded w-5 h-5",disabled:!t}),s.jsx("span",{children:"Portal aktiviert"}),(C==null?void 0:C.portalEnabled)&&s.jsx(ve,{variant:"success",children:"Aktiv"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Portal E-Mail"}),s.jsx("div",{className:"flex gap-2",children:s.jsx(q,{value:(C==null?void 0:C.portalEmail)||"",onChange:S=>x.mutate({portalEmail:S.target.value||null}),placeholder:"portal@example.com",disabled:!t||!(C!=null&&C.portalEnabled),className:"flex-1"})}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Diese E-Mail wird für den Login ins Kundenportal verwendet."})]}),(C==null?void 0:C.portalEnabled)&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:C!=null&&C.hasPassword?"Neues Passwort setzen":"Passwort setzen"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(q,{type:r?"text":"password",value:i,onChange:S=>l(S.target.value),placeholder:"Mindestens 6 Zeichen",disabled:!t}),s.jsx("button",{type:"button",onClick:()=>a(!r),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400",children:r?s.jsx(At,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]}),s.jsx(T,{onClick:()=>y.mutate(i),disabled:!t||i.length<6||y.isPending,children:y.isPending?"Speichern...":"Setzen"})]}),(C==null?void 0:C.hasPassword)&&s.jsx(R2,{customerId:e})]}),(C==null?void 0:C.portalLastLogin)&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Letzte Anmeldung: ",new Date(C.portalLastLogin).toLocaleString("de-DE")]})]})]}),s.jsxs("div",{className:"border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(m2,{className:"w-5 h-5 text-gray-400"}),s.jsx("h3",{className:"font-medium",children:"Vertreter (können Verträge einsehen)"})]}),s.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&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(q,{value:o,onChange:S=>c(S.target.value),placeholder:"Kunden suchen (Name, Kundennummer)...",onKeyDown:S=>S.key==="Enter"&&k(),className:"flex-1"}),s.jsx(T,{variant:"secondary",onClick:k,disabled:o.length<2||h,children:s.jsx(fl,{className:"w-4 h-4"})})]}),s.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&&s.jsx("div",{className:"mt-2 border rounded-lg divide-y",children:u.map(S=>s.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-gray-50",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:S.companyName||`${S.firstName} ${S.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:S.customerNumber})]}),s.jsxs(T,{size:"sm",onClick:()=>v.mutate(S.id),disabled:v.isPending,children:[s.jsx($e,{className:"w-4 h-4 mr-1"}),"Hinzufügen"]})]},S.id))})]}),A.length>0?s.jsx("div",{className:"space-y-2",children:A.map(S=>{var E,D,$,L;return s.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:((E=S.representative)==null?void 0:E.companyName)||`${(D=S.representative)==null?void 0:D.firstName} ${($=S.representative)==null?void 0:$.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:(L=S.representative)==null?void 0:L.customerNumber})]}),t&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertreter wirklich entfernen?")&&w.mutate(S.representativeId)},children:s.jsx(Os,{className:"w-4 h-4 text-red-500"})})]},S.id)})}):s.jsx("p",{className:"text-gray-500 text-sm",children:"Keine Vertreter konfiguriert."})]})]})}function zp({isOpen:e,onClose:t,customerId:n,address:r}){const a=xe(),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]=j.useState(l),u=H({mutationFn:m=>Sd.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({type:"DELIVERY_RESIDENCE",street:"",houseNumber:"",postalCode:"",city:"",country:"Deutschland",isDefault:!1})}}),d=H({mutationFn:m=>Sd.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?d.mutate(o):u.mutate(o)},p=u.isPending||d.isPending;return i&&o.street!==r.street&&c(l()),s.jsx(ut,{isOpen:e,onClose:t,title:i?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(Oe,{label:"Adresstyp",value:o.type,onChange:m=>c({...o,type:m.target.value}),options:[{value:"DELIVERY_RESIDENCE",label:"Liefer-/Meldeadresse"},{value:"BILLING",label:"Rechnungsadresse"}]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(q,{label:"Straße",value:o.street,onChange:m=>c({...o,street:m.target.value}),required:!0})}),s.jsx(q,{label:"Hausnr.",value:o.houseNumber,onChange:m=>c({...o,houseNumber:m.target.value}),required:!0})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx(q,{label:"PLZ",value:o.postalCode,onChange:m=>c({...o,postalCode:m.target.value}),required:!0}),s.jsx("div",{className:"col-span-2",children:s.jsx(q,{label:"Ort",value:o.city,onChange:m=>c({...o,city:m.target.value}),required:!0})})]}),s.jsx(q,{label:"Land",value:o.country,onChange:m=>c({...o,country:m.target.value})}),s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isDefault,onChange:m=>c({...o,isDefault:m.target.checked}),className:"rounded"}),"Als Standard setzen"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function $p({isOpen:e,onClose:t,customerId:n,bankCard:r}){const a=xe(),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]=j.useState(l);j.useState(()=>{c(l())});const u=H({mutationFn:m=>Oo.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({accountHolder:"",iban:"",bic:"",bankName:"",expiryDate:"",isActive:!0})}}),d=H({mutationFn:m=>Oo.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.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()),s.jsx(ut,{isOpen:e,onClose:t,title:i?"Bankkarte bearbeiten":"Bankkarte hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(q,{label:"Kontoinhaber",value:o.accountHolder,onChange:m=>c({...o,accountHolder:m.target.value}),required:!0}),s.jsx(q,{label:"IBAN",value:o.iban,onChange:m=>c({...o,iban:m.target.value}),required:!0}),s.jsx(q,{label:"BIC",value:o.bic,onChange:m=>c({...o,bic:m.target.value})}),s.jsx(q,{label:"Bank",value:o.bankName,onChange:m=>c({...o,bankName:m.target.value})}),s.jsx(q,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:m=>c({...o,expiryDate:m.target.value}),onClear:()=>c({...o,expiryDate:""})}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&s.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."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function _p({isOpen:e,onClose:t,customerId:n,document:r}){const a=xe(),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]=j.useState(l),u=H({mutationFn:m=>zo.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({type:"ID_CARD",documentNumber:"",issuingAuthority:"",issueDate:"",expiryDate:"",isActive:!0,licenseClasses:"",licenseIssueDate:""})}}),d=H({mutationFn:m=>zo.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.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()),s.jsx(ut,{isOpen:e,onClose:t,title:i?"Ausweis bearbeiten":"Ausweis hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(Oe,{label:"Ausweistyp",value:o.type,onChange:m=>c({...o,type:m.target.value}),options:[{value:"ID_CARD",label:"Personalausweis"},{value:"PASSPORT",label:"Reisepass"},{value:"DRIVERS_LICENSE",label:"Führerschein"},{value:"OTHER",label:"Sonstiges"}]}),s.jsx(q,{label:"Ausweisnummer",value:o.documentNumber,onChange:m=>c({...o,documentNumber:m.target.value}),required:!0}),s.jsx(q,{label:"Ausstellende Behörde",value:o.issuingAuthority,onChange:m=>c({...o,issuingAuthority:m.target.value})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(q,{label:"Ausstellungsdatum",type:"date",value:o.issueDate,onChange:m=>c({...o,issueDate:m.target.value}),onClear:()=>c({...o,issueDate:""})}),s.jsx(q,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:m=>c({...o,expiryDate:m.target.value}),onClear:()=>c({...o,expiryDate:""})})]}),o.type==="DRIVERS_LICENSE"&&s.jsxs(s.Fragment,{children:[s.jsx(q,{label:"Führerscheinklassen",value:o.licenseClasses,onChange:m=>c({...o,licenseClasses:m.target.value}),placeholder:"z.B. B, BE, AM, L"}),s.jsx(q,{label:"Erwerb Klasse B (Pkw)",type:"date",value:o.licenseIssueDate,onChange:m=>c({...o,licenseIssueDate:m.target.value}),onClear:()=>c({...o,licenseIssueDate:""})})]}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&s.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."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function Kp({isOpen:e,onClose:t,customerId:n,meter:r}){const a=xe(),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]=j.useState(l),u=H({mutationFn:m=>Xs.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({meterNumber:"",type:"ELECTRICITY",location:"",isActive:!0})}}),d=H({mutationFn:m=>Xs.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?d.mutate(o):u.mutate(o)},p=u.isPending||d.isPending;return i&&o.meterNumber!==r.meterNumber&&c(l()),s.jsx(ut,{isOpen:e,onClose:t,title:i?"Zähler bearbeiten":"Zähler hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(q,{label:"Zählernummer",value:o.meterNumber,onChange:m=>c({...o,meterNumber:m.target.value}),required:!0}),s.jsx(Oe,{label:"Zählertyp",value:o.type,onChange:m=>c({...o,type:m.target.value}),options:[{value:"ELECTRICITY",label:"Strom"},{value:"GAS",label:"Gas"}]}),s.jsx(q,{label:"Standort",value:o.location,onChange:m=>c({...o,location:m.target.value}),placeholder:"z.B. Keller, Wohnung"}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function Up({isOpen:e,onClose:t,meterId:n,customerId:r,reading:a}){const i=xe(),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]=j.useState(o),d=H({mutationFn:f=>Xs.addReading(n,f),onSuccess:()=>{i.invalidateQueries({queryKey:["customer",r.toString()]}),t()}}),h=H({mutationFn:f=>Xs.updateReading(n,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?h.mutate(g):d.mutate(g)},m=d.isPending||h.isPending;return l&&c.value!==a.value.toString()&&u(o()),s.jsx(ut,{isOpen:e,onClose:t,title:l?"Zählerstand bearbeiten":"Zählerstand erfassen",children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(q,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:f=>u({...c,readingDate:f.target.value}),required:!0}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(q,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:f=>u({...c,value:f.target.value}),required:!0})}),s.jsx(Oe,{label:"Einheit",value:c.unit,onChange:f=>u({...c,unit:f.target.value}),options:[{value:"kWh",label:"kWh"},{value:"m³",label:"m³"}]})]}),s.jsx(q,{label:"Notizen",value:c.notes,onChange:f=>u({...c,notes:f.target.value}),placeholder:"Optionale Notizen..."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m,children:m?"Speichern...":"Speichern"})]})]})})}const tu="@stressfrei-wechseln.de";function z2({customerId:e,emails:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=xe(),c=H({mutationFn:({id:h,data:p})=>ls.update(h,p),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=H({mutationFn:ls.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=r?t:t.filter(h=>h.isActive);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.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?s.jsx("div",{className:"space-y-3",children:d.map(h=>s.jsx("div",{className:`border rounded-lg p-4 ${h.isActive?"":"opacity-50 bg-gray-50"}`,children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Gs,{className:"w-4 h-4 text-gray-400"}),s.jsx("span",{className:"font-mono text-sm",children:h.email}),s.jsx(me,{value:h.email}),!h.isActive&&s.jsx(ve,{variant:"danger",children:"Inaktiv"})]}),h.notes&&s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-gray-500",children:[s.jsx(Xe,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:h.notes})]})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(h),title:"Bearbeiten",children:s.jsx(st,{className:"w-4 h-4"})}),h.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse deaktivieren?")&&c.mutate({id:h.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(At,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wieder aktivieren?")&&c.mutate({id:h.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&u.mutate(h.id)},title:"Löschen",children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]})},h.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Stressfrei-Wechseln Adressen vorhanden."})]})}function $2({credentials:e,onHide:t,onResetPassword:n,isResettingPassword:r}){const[a,i]=j.useState(null),l=async(d,h)=>{try{await navigator.clipboard.writeText(d),i(h),setTimeout(()=>i(null),2e3)}catch{const p=document.createElement("textarea");p.value=d,document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p),i(h),setTimeout(()=>i(null),2e3)}},o=({text:d,fieldName:h})=>s.jsx("button",{type:"button",onClick:()=>l(d,h),className:"p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors",title:"In Zwischenablage kopieren",children:a===h?s.jsx(Zi,{className:"w-4 h-4 text-green-600"}):s.jsx(Om,{className:"w-4 h-4"})}),c=e.imap?`${e.imap.server}:${e.imap.port}`:"",u=e.smtp?`${e.smtp.server}:${e.smtp.port}`:"";return s.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4 space-y-3",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Zugangsdaten"}),s.jsx("button",{type:"button",onClick:t,className:"text-gray-400 hover:text-gray-600 p-1 hover:bg-gray-200 rounded",title:"Zugangsdaten ausblenden",children:s.jsx(At,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Benutzername"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1 break-all",children:e.email}),s.jsx(o,{text:e.email,fieldName:"email"})]})]}),s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Passwort"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1 break-all",children:e.password}),s.jsx(o,{text:e.password,fieldName:"password"})]}),s.jsx("button",{type:"button",onClick:n,disabled:r,className:"mt-2 text-xs text-blue-600 hover:text-blue-800 disabled:opacity-50",children:r?"Generiere...":"Neu generieren"})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.imap&&s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"IMAP (Empfang)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1",children:c}),s.jsx(o,{text:c,fieldName:"imap"})]}),s.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:e.imap.encryption})]}),e.smtp&&s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"SMTP (Versand)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1",children:u}),s.jsx(o,{text:u,fieldName:"smtp"})]}),s.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:e.smtp.encryption})]})]})]})}function Bp({isOpen:e,onClose:t,customerId:n,email:r,customerEmail:a}){const[i,l]=j.useState(""),[o,c]=j.useState(""),[u,d]=j.useState(!1),[h,p]=j.useState(!1),[m,f]=j.useState(null),[g,N]=j.useState("idle"),[x,y]=j.useState(!1),[v,w]=j.useState(!1),[k,C]=j.useState(!1),[A,S]=j.useState(!1),[E,D]=j.useState(null),[$,L]=j.useState(!1),[U,V]=j.useState(!1),O=xe(),P=!!r,{data:b}=de({queryKey:["email-provider-configs"],queryFn:()=>cn.getConfigs(),enabled:e}),z=((b==null?void 0:b.data)||[]).some(W=>W.isActive&&W.isDefault),J=W=>{if(!W)return"";const _e=W.indexOf("@");return _e>0?W.substring(0,_e):W},ee=async W=>{var _e;if(!(!z||!W)){N("checking");try{const Et=await cn.checkEmailExists(W);N((_e=Et.data)!=null&&_e.exists?"exists":"not_exists")}catch{N("error")}}},pe=async()=>{var W,_e;if(!(!a||!i)){y(!0),f(null);try{const Et=await cn.provisionEmail(i,a);(W=Et.data)!=null&&W.success?N("exists"):f(((_e=Et.data)==null?void 0:_e.error)||"Provisionierung fehlgeschlagen")}catch(Et){f(Et instanceof Error?Et.message:"Fehler bei der Provisionierung")}finally{y(!1)}}},le=async()=>{if(r){w(!0),f(null);try{const W=await ls.enableMailbox(r.id);W.success?(C(!0),O.invalidateQueries({queryKey:["customer",n.toString()]}),O.invalidateQueries({queryKey:["mailbox-accounts",n]})):f(W.error||"Mailbox-Aktivierung fehlgeschlagen")}catch(W){f(W instanceof Error?W.message:"Fehler bei der Mailbox-Aktivierung")}finally{w(!1)}}},nt=async()=>{if(r)try{const W=await ls.syncMailboxStatus(r.id);W.success&&W.data&&(C(W.data.hasMailbox),W.data.wasUpdated&&O.invalidateQueries({queryKey:["customer",n.toString()]}))}catch(W){console.error("Fehler beim Synchronisieren des Mailbox-Status:",W)}},Q=async()=>{if(r){L(!0);try{const W=await ls.getMailboxCredentials(r.id);W.success&&W.data&&(D(W.data),S(!0))}catch(W){console.error("Fehler beim Laden der Zugangsdaten:",W)}finally{L(!1)}}},ke=async()=>{if(r&&confirm("Neues Passwort generieren? Das alte Passwort wird ungültig.")){V(!0);try{const W=await ls.resetPassword(r.id);W.success&&W.data?(E&&D({...E,password:W.data.password}),alert("Passwort wurde erfolgreich zurückgesetzt.")):alert(W.error||"Fehler beim Zurücksetzen des Passworts")}catch(W){console.error("Fehler beim Zurücksetzen des Passworts:",W),alert(W instanceof Error?W.message:"Fehler beim Zurücksetzen des Passworts")}finally{V(!1)}}};j.useEffect(()=>{if(e){if(r){const W=J(r.email);l(W),c(r.notes||""),N("idle"),C(r.hasMailbox||!1),z&&(ee(W),nt())}else l(""),c(""),d(!1),p(!1),N("idle"),C(!1);f(null),S(!1),D(null)}},[e,r,z]);const Pe=H({mutationFn:async W=>ls.create(n,{email:W.email,notes:W.notes,provisionAtProvider:W.provision,createMailbox:W.createMailbox}),onSuccess:()=>{O.invalidateQueries({queryKey:["customer",n.toString()]}),O.invalidateQueries({queryKey:["mailbox-accounts",n]}),l(""),c(""),d(!1),p(!1),t()},onError:W=>{f(W instanceof Error?W.message:"Fehler bei der Provisionierung")}}),Ge=H({mutationFn:W=>ls.update(r.id,W),onSuccess:()=>{O.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),ht=W=>{W.preventDefault(),f(null);const _e=i+tu;P?Ge.mutate({email:_e,notes:o||void 0}):Pe.mutate({email:_e,notes:o||void 0,provision:u,createMailbox:u&&h})},Tt=Pe.isPending||Ge.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:P?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:ht,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"E-Mail-Adresse"}),s.jsxs("div",{className:"flex",children:[s.jsx("input",{type:"text",value:i,onChange:W=>l(W.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"}),s.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:tu})]}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Vollständige Adresse: ",s.jsxs("span",{className:"font-mono",children:[i||"...",tu]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Notizen (optional)"}),s.jsx("textarea",{value:o,onChange:W=>c(W.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..."})]}),z&&a&&s.jsx("div",{className:"bg-blue-50 p-3 rounded-lg",children:P?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"E-Mail-Provider Status"}),g==="checking"&&s.jsx("span",{className:"text-xs text-gray-500",children:"Prüfe..."}),g==="exists"&&s.jsxs("span",{className:"text-xs text-green-600 flex items-center gap-1",children:[s.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),"Beim Provider vorhanden"]}),g==="not_exists"&&s.jsx("span",{className:"text-xs text-orange-600",children:"Nicht beim Provider angelegt"}),g==="error"&&s.jsx("span",{className:"text-xs text-red-600",children:"Status konnte nicht geprüft werden"})]}),g==="not_exists"&&s.jsxs("div",{className:"pt-2 border-t border-blue-100",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["Die E-Mail-Weiterleitung ist noch nicht auf dem Server eingerichtet. Weiterleitungsziel: ",a]}),s.jsx(T,{type:"button",size:"sm",onClick:pe,disabled:x,children:x?"Wird angelegt...":"Jetzt beim Provider anlegen"})]}),g==="error"&&s.jsx(T,{type:"button",size:"sm",variant:"secondary",onClick:()=>ee(i),children:"Erneut prüfen"}),g==="exists"&&s.jsxs("div",{className:"pt-3 mt-3 border-t border-blue-100",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Mailbox (IMAP/SMTP)"}),k?s.jsxs("span",{className:"text-xs text-green-600 flex items-center gap-1",children:[s.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),"Mailbox aktiv"]}):s.jsx("span",{className:"text-xs text-orange-600",children:"Keine Mailbox"})]}),!k&&s.jsxs("div",{className:"mt-2",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Aktiviere eine echte Mailbox um E-Mails direkt im CRM zu empfangen und zu versenden."}),s.jsx(T,{type:"button",size:"sm",onClick:le,disabled:v,children:v?"Wird aktiviert...":"Mailbox aktivieren"})]}),k&&s.jsx("div",{className:"mt-3",children:A?E&&s.jsx($2,{credentials:E,onHide:()=>S(!1),onResetPassword:ke,isResettingPassword:U}):s.jsx(T,{type:"button",size:"sm",variant:"secondary",onClick:Q,disabled:$,children:$?"Laden...":s.jsxs(s.Fragment,{children:[s.jsx(Ae,{className:"w-4 h-4 mr-1"}),"Zugangsdaten anzeigen"]})})})]})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:W=>{d(W.target.checked),W.target.checked||p(!1)},className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Beim E-Mail-Provider anlegen"}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Die E-Mail-Weiterleitung wird automatisch auf dem konfigurierten Server erstellt. Weiterleitungsziel: ",a]})]})]}),u&&s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer ml-6",children:[s.jsx("input",{type:"checkbox",checked:h,onChange:W=>p(W.target.checked),className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Echte Mailbox erstellen (IMAP/SMTP-Zugang)"}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Ermöglicht E-Mails direkt im CRM zu empfangen und zu versenden."})]})]})]})}),m&&s.jsx("div",{className:"bg-red-50 p-3 rounded-lg text-red-700 text-sm",children:m}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:Tt||!i,children:Tt?"Speichern...":"Speichern"})]})]})})}var xl=e=>e.type==="checkbox",jr=e=>e instanceof Date,Xt=e=>e==null;const Z0=e=>typeof e=="object";var xt=e=>!Xt(e)&&!Array.isArray(e)&&Z0(e)&&!jr(e),_2=e=>xt(e)&&e.target?xl(e.target)?e.target.checked:e.target.value:e,K2=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,U2=(e,t)=>e.has(K2(t)),B2=e=>{const t=e.constructor&&e.constructor.prototype;return xt(t)&&t.hasOwnProperty("isPrototypeOf")},Bm=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function gt(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Bm&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(xt(e)&&B2(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=gt(e[a]));return r}var vc=e=>/^\w*$/.test(e),Ze=e=>e===void 0,qm=e=>Array.isArray(e)?e.filter(Boolean):[],Vm=e=>qm(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ue=(e,t,n)=>{if(!t||!xt(e))return n;const r=(vc(t)?[t]:Vm(t)).reduce((a,i)=>Xt(a)?a:a[i],e);return Ze(r)||r===e?Ze(e[t])?n:e[t]:r},Bs=e=>typeof e=="boolean",Ms=e=>typeof e=="function",He=(e,t,n)=>{let r=-1;const a=vc(t)?[t]:Vm(t),i=a.length,l=i-1;for(;++r{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const l=i;return t._proxyFormState[l]!==Fs.all&&(t._proxyFormState[l]=!r||Fs.all),e[l]}});return a};const Q2=typeof window<"u"?Pt.useLayoutEffect:Pt.useEffect;var os=e=>typeof e=="string",H2=(e,t,n,r,a)=>os(e)?(r&&t.watch.add(e),ue(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),ue(n,i))):(r&&(t.watchAll=!0),n),Cd=e=>Xt(e)||!Z0(e);function Ln(e,t,n=new WeakSet){if(Cd(e)||Cd(t))return Object.is(e,t);if(jr(e)&&jr(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(n.has(e)||n.has(t))return!0;n.add(e),n.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(jr(l)&&jr(o)||xt(l)&&xt(o)||Array.isArray(l)&&Array.isArray(o)?!Ln(l,o,n):!Object.is(l,o))return!1}}return!0}const W2=Pt.createContext(null);W2.displayName="HookFormContext";var G2=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},Si=e=>Array.isArray(e)?e:[e],Vp=()=>{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 J0(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&xt(a)&&i){const l=J0(a,i);xt(l)&&(n[r]=l)}else e[r]&&(n[r]=i)}return n}var Kt=e=>xt(e)&&!Object.keys(e).length,Qm=e=>e.type==="file",$o=e=>{if(!Bm)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},X0=e=>e.type==="select-multiple",Hm=e=>e.type==="radio",Z2=e=>Hm(e)||xl(e),su=e=>$o(e)&&e.isConnected;function J2(e,t){const n=t.slice(0,-1).length;let r=0;for(;r{for(const t in e)if(Ms(e[t]))return!0;return!1};function Y0(e){return Array.isArray(e)||xt(e)&&!Y2(e)}function Ed(e,t={}){for(const n in e){const r=e[n];Y0(r)?(t[n]=Array.isArray(r)?[]:{},Ed(r,t[n])):Ze(r)||(t[n]=!0)}return t}function Gr(e,t,n){n||(n=Ed(t));for(const r in e){const a=e[r];if(Y0(a))Ze(t)||Cd(n[r])?n[r]=Ed(a,Array.isArray(a)?[]:{}):Gr(a,Xt(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Ln(a,i)}}return n}const Qp={value:!1,isValid:!1},Hp={value:!0,isValid:!0};var ev=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ze(e[0].attributes.value)?Ze(e[0].value)||e[0].value===""?Hp:{value:e[0].value,isValid:!0}:Hp:Qp}return Qp},tv=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ze(e)?e:t?e===""?NaN:e&&+e:n&&os(e)?new Date(e):r?r(e):e;const Wp={isValid:!1,value:null};var sv=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Wp):Wp;function Gp(e){const t=e.ref;return Qm(t)?t.files:Hm(t)?sv(e.refs).value:X0(t)?[...t.selectedOptions].map(({value:n})=>n):xl(t)?ev(e.refs).value:tv(Ze(t.value)?e.ref.value:t.value,e)}var ek=(e,t,n,r)=>{const a={};for(const i of e){const l=ue(t,i);l&&He(a,i,l._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},_o=e=>e instanceof RegExp,li=e=>Ze(e)?e:_o(e)?e.source:xt(e)?_o(e.value)?e.value.source:e.value:e,Zp=e=>({isOnSubmit:!e||e===Fs.onSubmit,isOnBlur:e===Fs.onBlur,isOnChange:e===Fs.onChange,isOnAll:e===Fs.all,isOnTouch:e===Fs.onTouched});const Jp="AsyncFunction";var tk=e=>!!e&&!!e.validate&&!!(Ms(e.validate)&&e.validate.constructor.name===Jp||xt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Jp)),sk=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Xp=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const ki=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=ue(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(ki(o,t))break}else if(xt(o)&&ki(o,t))break}}};function Yp(e,t,n){const r=ue(e,n);if(r||vc(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),l=ue(t,i),o=ue(e,i);if(l&&!Array.isArray(l)&&n!==i)return{name:n};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:n}}var nk=(e,t,n,r)=>{n(e);const{name:a,...i}=e;return Kt(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(l=>t[l]===(!r||Fs.all))},rk=(e,t,n)=>!e||!t||e===t||Si(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),ak=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,ik=(e,t)=>!qm(ue(e,t)).length&&ft(e,t),lk=(e,t,n)=>{const r=Si(ue(e,n));return He(r,"root",t[n]),He(e,n,r),e};function ex(e,t,n="validate"){if(os(e)||Array.isArray(e)&&e.every(os)||Bs(e)&&!e)return{type:n,message:os(e)?e:"",ref:t}}var Wr=e=>xt(e)&&!_o(e)?e:{value:e,message:""},tx=async(e,t,n,r,a,i)=>{const{ref:l,refs:o,required:c,maxLength:u,minLength:d,min:h,max:p,pattern:m,validate:f,name:g,valueAsNumber:N,mount:x}=e._f,y=ue(n,g);if(!x||t.has(g))return{};const v=o?o[0]:l,w=L=>{a&&v.reportValidity&&(v.setCustomValidity(Bs(L)?"":L||""),v.reportValidity())},k={},C=Hm(l),A=xl(l),S=C||A,E=(N||Qm(l))&&Ze(l.value)&&Ze(y)||$o(l)&&l.value===""||y===""||Array.isArray(y)&&!y.length,D=G2.bind(null,g,r,k),$=(L,U,V,O=rn.maxLength,P=rn.minLength)=>{const b=L?U:V;k[g]={type:L?O:P,message:b,ref:l,...D(L?O:P,b)}};if(i?!Array.isArray(y)||!y.length:c&&(!S&&(E||Xt(y))||Bs(y)&&!y||A&&!ev(o).isValid||C&&!sv(o).isValid)){const{value:L,message:U}=os(c)?{value:!!c,message:c}:Wr(c);if(L&&(k[g]={type:rn.required,message:U,ref:v,...D(rn.required,U)},!r))return w(U),k}if(!E&&(!Xt(h)||!Xt(p))){let L,U;const V=Wr(p),O=Wr(h);if(!Xt(y)&&!isNaN(y)){const P=l.valueAsNumber||y&&+y;Xt(V.value)||(L=P>V.value),Xt(O.value)||(U=Pnew Date(new Date().toDateString()+" "+ee),z=l.type=="time",J=l.type=="week";os(V.value)&&y&&(L=z?b(y)>b(V.value):J?y>V.value:P>new Date(V.value)),os(O.value)&&y&&(U=z?b(y)+L.value,O=!Xt(U.value)&&y.length<+U.value;if((V||O)&&($(V,L.message,U.message),!r))return w(k[g].message),k}if(m&&!E&&os(y)){const{value:L,message:U}=Wr(m);if(_o(L)&&!y.match(L)&&(k[g]={type:rn.pattern,message:U,ref:l,...D(rn.pattern,U)},!r))return w(U),k}if(f){if(Ms(f)){const L=await f(y,n),U=ex(L,v);if(U&&(k[g]={...U,...D(rn.validate,U.message)},!r))return w(U.message),k}else if(xt(f)){let L={};for(const U in f){if(!Kt(L)&&!r)break;const V=ex(await f[U](y,n),v,U);V&&(L={...V,...D(U,V.message)},w(V.message),r&&(k[g]=L))}if(!Kt(L)&&(k[g]={ref:v,...L},!r))return k}}return w(!0),k};const ok={mode:Fs.onSubmit,reValidateMode:Fs.onChange,shouldFocusError:!0};function ck(e={}){let t={...ok,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ms(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},a=xt(t.defaultValues)||xt(t.values)?gt(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:gt(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},h={...d};let p={...h};const m={array:Vp(),state:Vp()},f=t.criteriaMode===Fs.all,g=F=>_=>{clearTimeout(u),u=setTimeout(F,_)},N=async F=>{if(!l.keepIsValid&&!t.disabled&&(h.isValid||p.isValid||F)){let _;t.resolver?(_=Kt((await S()).errors),x()):_=await D(r,!0),_!==n.isValid&&m.state.next({isValid:_})}},x=(F,_)=>{!t.disabled&&(h.isValidating||h.validatingFields||p.isValidating||p.validatingFields)&&((F||Array.from(o.mount)).forEach(B=>{B&&(_?He(n.validatingFields,B,_):ft(n.validatingFields,B))}),m.state.next({validatingFields:n.validatingFields,isValidating:!Kt(n.validatingFields)}))},y=(F,_=[],B,ie,te=!0,Z=!0)=>{if(ie&&B&&!t.disabled){if(l.action=!0,Z&&Array.isArray(ue(r,F))){const he=B(ue(r,F),ie.argA,ie.argB);te&&He(r,F,he)}if(Z&&Array.isArray(ue(n.errors,F))){const he=B(ue(n.errors,F),ie.argA,ie.argB);te&&He(n.errors,F,he),ik(n.errors,F)}if((h.touchedFields||p.touchedFields)&&Z&&Array.isArray(ue(n.touchedFields,F))){const he=B(ue(n.touchedFields,F),ie.argA,ie.argB);te&&He(n.touchedFields,F,he)}(h.dirtyFields||p.dirtyFields)&&(n.dirtyFields=Gr(a,i)),m.state.next({name:F,isDirty:L(F,_),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else He(i,F,_)},v=(F,_)=>{He(n.errors,F,_),m.state.next({errors:n.errors})},w=F=>{n.errors=F,m.state.next({errors:n.errors,isValid:!1})},k=(F,_,B,ie)=>{const te=ue(r,F);if(te){const Z=ue(i,F,Ze(B)?ue(a,F):B);Ze(Z)||ie&&ie.defaultChecked||_?He(i,F,_?Z:Gp(te._f)):O(F,Z),l.mount&&!l.action&&N()}},C=(F,_,B,ie,te)=>{let Z=!1,he=!1;const Fe={name:F};if(!t.disabled){if(!B||ie){(h.isDirty||p.isDirty)&&(he=n.isDirty,n.isDirty=Fe.isDirty=L(),Z=he!==Fe.isDirty);const Te=Ln(ue(a,F),_);he=!!ue(n.dirtyFields,F),Te?ft(n.dirtyFields,F):He(n.dirtyFields,F,!0),Fe.dirtyFields=n.dirtyFields,Z=Z||(h.dirtyFields||p.dirtyFields)&&he!==!Te}if(B){const Te=ue(n.touchedFields,F);Te||(He(n.touchedFields,F,B),Fe.touchedFields=n.touchedFields,Z=Z||(h.touchedFields||p.touchedFields)&&Te!==B)}Z&&te&&m.state.next(Fe)}return Z?Fe:{}},A=(F,_,B,ie)=>{const te=ue(n.errors,F),Z=(h.isValid||p.isValid)&&Bs(_)&&n.isValid!==_;if(t.delayError&&B?(c=g(()=>v(F,B)),c(t.delayError)):(clearTimeout(u),c=null,B?He(n.errors,F,B):ft(n.errors,F)),(B?!Ln(te,B):te)||!Kt(ie)||Z){const he={...ie,...Z&&Bs(_)?{isValid:_}:{},errors:n.errors,name:F};n={...n,...he},m.state.next(he)}},S=async F=>(x(F,!0),await t.resolver(i,t.context,ek(F||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),E=async F=>{const{errors:_}=await S(F);if(x(F),F)for(const B of F){const ie=ue(_,B);ie?He(n.errors,B,ie):ft(n.errors,B)}else n.errors=_;return _},D=async(F,_,B={valid:!0})=>{for(const ie in F){const te=F[ie];if(te){const{_f:Z,...he}=te;if(Z){const Fe=o.array.has(Z.name),Te=te._f&&tk(te._f);Te&&h.validatingFields&&x([Z.name],!0);const rt=await tx(te,o.disabled,i,f,t.shouldUseNativeValidation&&!_,Fe);if(Te&&h.validatingFields&&x([Z.name]),rt[Z.name]&&(B.valid=!1,_||e.shouldUseNativeValidation))break;!_&&(ue(rt,Z.name)?Fe?lk(n.errors,rt,Z.name):He(n.errors,Z.name,rt[Z.name]):ft(n.errors,Z.name))}!Kt(he)&&await D(he,_,B)}}return B.valid},$=()=>{for(const F of o.unMount){const _=ue(r,F);_&&(_._f.refs?_._f.refs.every(B=>!su(B)):!su(_._f.ref))&&ht(F)}o.unMount=new Set},L=(F,_)=>!t.disabled&&(F&&_&&He(i,F,_),!Ln(pe(),a)),U=(F,_,B)=>H2(F,o,{...l.mount?i:Ze(_)?a:os(F)?{[F]:_}:_},B,_),V=F=>qm(ue(l.mount?i:a,F,t.shouldUnregister?ue(a,F,[]):[])),O=(F,_,B={})=>{const ie=ue(r,F);let te=_;if(ie){const Z=ie._f;Z&&(!Z.disabled&&He(i,F,tv(_,Z)),te=$o(Z.ref)&&Xt(_)?"":_,X0(Z.ref)?[...Z.ref.options].forEach(he=>he.selected=te.includes(he.value)):Z.refs?xl(Z.ref)?Z.refs.forEach(he=>{(!he.defaultChecked||!he.disabled)&&(Array.isArray(te)?he.checked=!!te.find(Fe=>Fe===he.value):he.checked=te===he.value||!!te)}):Z.refs.forEach(he=>he.checked=he.value===te):Qm(Z.ref)?Z.ref.value="":(Z.ref.value=te,Z.ref.type||m.state.next({name:F,values:gt(i)})))}(B.shouldDirty||B.shouldTouch)&&C(F,te,B.shouldTouch,B.shouldDirty,!0),B.shouldValidate&&ee(F)},P=(F,_,B)=>{for(const ie in _){if(!_.hasOwnProperty(ie))return;const te=_[ie],Z=F+"."+ie,he=ue(r,Z);(o.array.has(F)||xt(te)||he&&!he._f)&&!jr(te)?P(Z,te,B):O(Z,te,B)}},b=(F,_,B={})=>{const ie=ue(r,F),te=o.array.has(F),Z=gt(_);He(i,F,Z),te?(m.array.next({name:F,values:gt(i)}),(h.isDirty||h.dirtyFields||p.isDirty||p.dirtyFields)&&B.shouldDirty&&m.state.next({name:F,dirtyFields:Gr(a,i),isDirty:L(F,Z)})):ie&&!ie._f&&!Xt(Z)?P(F,Z,B):O(F,Z,B),Xp(F,o)?m.state.next({...n,name:F,values:gt(i)}):m.state.next({name:l.mount?F:void 0,values:gt(i)})},z=async F=>{l.mount=!0;const _=F.target;let B=_.name,ie=!0;const te=ue(r,B),Z=Te=>{ie=Number.isNaN(Te)||jr(Te)&&isNaN(Te.getTime())||Ln(Te,ue(i,B,Te))},he=Zp(t.mode),Fe=Zp(t.reValidateMode);if(te){let Te,rt;const sn=_.type?Gp(te._f):_2(F),Ss=F.type===qp.BLUR||F.type===qp.FOCUS_OUT,bc=!sk(te._f)&&!t.resolver&&!ue(n.errors,B)&&!te._f.deps||ak(Ss,ue(n.touchedFields,B),n.isSubmitted,Fe,he),Vr=Xp(B,o,Ss);He(i,B,sn),Ss?(!_||!_.readOnly)&&(te._f.onBlur&&te._f.onBlur(F),c&&c(0)):te._f.onChange&&te._f.onChange(F);const Qr=C(B,sn,Ss),yl=!Kt(Qr)||Vr;if(!Ss&&m.state.next({name:B,type:F.type,values:gt(i)}),bc)return(h.isValid||p.isValid)&&(t.mode==="onBlur"?Ss&&N():Ss||N()),yl&&m.state.next({name:B,...Vr?{}:Qr});if(!Ss&&Vr&&m.state.next({...n}),t.resolver){const{errors:Ga}=await S([B]);if(x([B]),Z(sn),ie){const vl=Yp(n.errors,r,B),Za=Yp(Ga,r,vl.name||B);Te=Za.error,B=Za.name,rt=Kt(Ga)}}else x([B],!0),Te=(await tx(te,o.disabled,i,f,t.shouldUseNativeValidation))[B],x([B]),Z(sn),ie&&(Te?rt=!1:(h.isValid||p.isValid)&&(rt=await D(r,!0)));ie&&(te._f.deps&&(!Array.isArray(te._f.deps)||te._f.deps.length>0)&&ee(te._f.deps),A(B,rt,Te,Qr))}},J=(F,_)=>{if(ue(n.errors,_)&&F.focus)return F.focus(),1},ee=async(F,_={})=>{let B,ie;const te=Si(F);if(t.resolver){const Z=await E(Ze(F)?F:te);B=Kt(Z),ie=F?!te.some(he=>ue(Z,he)):B}else F?(ie=(await Promise.all(te.map(async Z=>{const he=ue(r,Z);return await D(he&&he._f?{[Z]:he}:he)}))).every(Boolean),!(!ie&&!n.isValid)&&N()):ie=B=await D(r);return m.state.next({...!os(F)||(h.isValid||p.isValid)&&B!==n.isValid?{}:{name:F},...t.resolver||!F?{isValid:B}:{},errors:n.errors}),_.shouldFocus&&!ie&&ki(r,J,F?te:o.mount),ie},pe=(F,_)=>{let B={...l.mount?i:a};return _&&(B=J0(_.dirtyFields?n.dirtyFields:n.touchedFields,B)),Ze(F)?B:os(F)?ue(B,F):F.map(ie=>ue(B,ie))},le=(F,_)=>({invalid:!!ue((_||n).errors,F),isDirty:!!ue((_||n).dirtyFields,F),error:ue((_||n).errors,F),isValidating:!!ue(n.validatingFields,F),isTouched:!!ue((_||n).touchedFields,F)}),nt=F=>{F&&Si(F).forEach(_=>ft(n.errors,_)),m.state.next({errors:F?n.errors:{}})},Q=(F,_,B)=>{const ie=(ue(r,F,{_f:{}})._f||{}).ref,te=ue(n.errors,F)||{},{ref:Z,message:he,type:Fe,...Te}=te;He(n.errors,F,{...Te,..._,ref:ie}),m.state.next({name:F,errors:n.errors,isValid:!1}),B&&B.shouldFocus&&ie&&ie.focus&&ie.focus()},ke=(F,_)=>Ms(F)?m.state.subscribe({next:B=>"values"in B&&F(U(void 0,_),B)}):U(F,_,!0),Pe=F=>m.state.subscribe({next:_=>{rk(F.name,_.name,F.exact)&&nk(_,F.formState||h,Wa,F.reRenderRoot)&&F.callback({values:{...i},...n,..._,defaultValues:a})}}).unsubscribe,Ge=F=>(l.mount=!0,p={...p,...F.formState},Pe({...F,formState:{...d,...F.formState}})),ht=(F,_={})=>{for(const B of F?Si(F):o.mount)o.mount.delete(B),o.array.delete(B),_.keepValue||(ft(r,B),ft(i,B)),!_.keepError&&ft(n.errors,B),!_.keepDirty&&ft(n.dirtyFields,B),!_.keepTouched&&ft(n.touchedFields,B),!_.keepIsValidating&&ft(n.validatingFields,B),!t.shouldUnregister&&!_.keepDefaultValue&&ft(a,B);m.state.next({values:gt(i)}),m.state.next({...n,..._.keepDirty?{isDirty:L()}:{}}),!_.keepIsValid&&N()},Tt=({disabled:F,name:_})=>{if(Bs(F)&&l.mount||F||o.disabled.has(_)){const te=o.disabled.has(_)!==!!F;F?o.disabled.add(_):o.disabled.delete(_),te&&l.mount&&!l.action&&N()}},W=(F,_={})=>{let B=ue(r,F);const ie=Bs(_.disabled)||Bs(t.disabled);return He(r,F,{...B||{},_f:{...B&&B._f?B._f:{ref:{name:F}},name:F,mount:!0,..._}}),o.mount.add(F),B?Tt({disabled:Bs(_.disabled)?_.disabled:t.disabled,name:F}):k(F,!0,_.value),{...ie?{disabled:_.disabled||t.disabled}:{},...t.progressive?{required:!!_.required,min:li(_.min),max:li(_.max),minLength:li(_.minLength),maxLength:li(_.maxLength),pattern:li(_.pattern)}:{},name:F,onChange:z,onBlur:z,ref:te=>{if(te){W(F,_),B=ue(r,F);const Z=Ze(te.value)&&te.querySelectorAll&&te.querySelectorAll("input,select,textarea")[0]||te,he=Z2(Z),Fe=B._f.refs||[];if(he?Fe.find(Te=>Te===Z):Z===B._f.ref)return;He(r,F,{_f:{...B._f,...he?{refs:[...Fe.filter(su),Z,...Array.isArray(ue(a,F))?[{}]:[]],ref:{type:Z.type,name:F}}:{ref:Z}}}),k(F,!1,void 0,Z)}else B=ue(r,F,{}),B._f&&(B._f.mount=!1),(t.shouldUnregister||_.shouldUnregister)&&!(U2(o.array,F)&&l.action)&&o.unMount.add(F)}}},_e=()=>t.shouldFocusError&&ki(r,J,o.mount),Et=F=>{Bs(F)&&(m.state.next({disabled:F}),ki(r,(_,B)=>{const ie=ue(r,B);ie&&(_.disabled=ie._f.disabled||F,Array.isArray(ie._f.refs)&&ie._f.refs.forEach(te=>{te.disabled=ie._f.disabled||F}))},0,!1))},$s=(F,_)=>async B=>{let ie;B&&(B.preventDefault&&B.preventDefault(),B.persist&&B.persist());let te=gt(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:Z,values:he}=await S();x(),n.errors=Z,te=gt(he)}else await D(r);if(o.disabled.size)for(const Z of o.disabled)ft(te,Z);if(ft(n.errors,"root"),Kt(n.errors)){m.state.next({errors:{}});try{await F(te,B)}catch(Z){ie=Z}}else _&&await _({...n.errors},B),_e(),setTimeout(_e);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Kt(n.errors)&&!ie,submitCount:n.submitCount+1,errors:n.errors}),ie)throw ie},ws=(F,_={})=>{ue(r,F)&&(Ze(_.defaultValue)?b(F,gt(ue(a,F))):(b(F,_.defaultValue),He(a,F,gt(_.defaultValue))),_.keepTouched||ft(n.touchedFields,F),_.keepDirty||(ft(n.dirtyFields,F),n.isDirty=_.defaultValue?L(F,gt(ue(a,F))):L()),_.keepError||(ft(n.errors,F),h.isValid&&N()),m.state.next({...n}))},ur=(F,_={})=>{const B=F?gt(F):a,ie=gt(B),te=Kt(F),Z=te?a:ie;if(_.keepDefaultValues||(a=B),!_.keepValues){if(_.keepDirtyValues){const he=new Set([...o.mount,...Object.keys(Gr(a,i))]);for(const Fe of Array.from(he)){const Te=ue(n.dirtyFields,Fe),rt=ue(i,Fe),sn=ue(Z,Fe);Te&&!Ze(rt)?He(Z,Fe,rt):!Te&&!Ze(sn)&&b(Fe,sn)}}else{if(Bm&&Ze(F))for(const he of o.mount){const Fe=ue(r,he);if(Fe&&Fe._f){const Te=Array.isArray(Fe._f.refs)?Fe._f.refs[0]:Fe._f.ref;if($o(Te)){const rt=Te.closest("form");if(rt){rt.reset();break}}}}if(_.keepFieldsRef)for(const he of o.mount)b(he,ue(Z,he));else r={}}i=t.shouldUnregister?_.keepDefaultValues?gt(a):{}:gt(Z),m.array.next({values:{...Z}}),m.state.next({values:{...Z}})}o={mount:_.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!h.isValid||!!_.keepIsValid||!!_.keepDirtyValues||!t.shouldUnregister&&!Kt(Z),l.watch=!!t.shouldUnregister,l.keepIsValid=!!_.keepIsValid,l.action=!1,_.keepErrors||(n.errors={}),m.state.next({submitCount:_.keepSubmitCount?n.submitCount:0,isDirty:te?!1:_.keepDirty?n.isDirty:!!(_.keepDefaultValues&&!Ln(F,a)),isSubmitted:_.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:te?{}:_.keepDirtyValues?_.keepDefaultValues&&i?Gr(a,i):n.dirtyFields:_.keepDefaultValues&&F?Gr(a,F):_.keepDirty?n.dirtyFields:{},touchedFields:_.keepTouched?n.touchedFields:{},errors:_.keepErrors?n.errors:{},isSubmitSuccessful:_.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},X=(F,_)=>ur(Ms(F)?F(i):F,{...t.resetOptions,..._}),ge=(F,_={})=>{const B=ue(r,F),ie=B&&B._f;if(ie){const te=ie.refs?ie.refs[0]:ie.ref;te.focus&&setTimeout(()=>{te.focus(),_.shouldSelect&&Ms(te.select)&&te.select()})}},Wa=F=>{n={...n,...F}},gl={control:{register:W,unregister:ht,getFieldState:le,handleSubmit:$s,setError:Q,_subscribe:Pe,_runSchema:S,_updateIsValidating:x,_focusError:_e,_getWatch:U,_getDirty:L,_setValid:N,_setFieldArray:y,_setDisabledField:Tt,_setErrors:w,_getFieldArray:V,_reset:ur,_resetDefaultValues:()=>Ms(t.defaultValues)&&t.defaultValues().then(F=>{X(F,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:$,_disableForm:Et,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return l},set _state(F){l=F},get _defaultValues(){return a},get _names(){return o},set _names(F){o=F},get _formState(){return n},get _options(){return t},set _options(F){t={...t,...F}}},subscribe:Ge,trigger:ee,register:W,handleSubmit:$s,watch:ke,setValue:b,getValues:pe,reset:X,resetField:ws,clearErrors:nt,unregister:ht,setError:Q,setFocus:ge,getFieldState:le};return{...gl,formControl:gl}}function nv(e={}){const t=Pt.useRef(void 0),n=Pt.useRef(void 0),[r,a]=Pt.useState({isDirty:!1,isValidating:!1,isLoading:Ms(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:Ms(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Ms(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=ck(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,Q2(()=>{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]),Pt.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),Pt.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),Pt.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),Pt.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),Pt.useEffect(()=>{if(i._proxyFormState.isDirty){const l=i._getDirty();l!==r.isDirty&&i._subjects.state.next({isDirty:l})}},[i,r.isDirty]),Pt.useEffect(()=>{var l;e.values&&!Ln(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((l=i._options.resetOptions)===null||l===void 0)&&l.keepIsValid||i._setValid(),n.current=e.values,a(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),Pt.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=Pt.useMemo(()=>V2(r,i),[i,r]),t.current}function sx(){var x,y;const{id:e}=ac(),t=Wt(),n=xe(),r=!!e,{register:a,handleSubmit:i,reset:l,watch:o,setValue:c,formState:{errors:u}}=nv(),d=o("type"),{data:h}=de({queryKey:["customer",e],queryFn:()=>kt.getById(parseInt(e)),enabled:r});j.useEffect(()=>{if(h!=null&&h.data){const v={...h.data};v.birthDate&&(v.birthDate=v.birthDate.split("T")[0]),v.foundingDate&&(v.foundingDate=v.foundingDate.split("T")[0]),l(v)}},[h,l]);const p=H({mutationFn:kt.create,onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),t("/customers")}}),m=H({mutationFn:v=>kt.update(parseInt(e),v),onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),n.invalidateQueries({queryKey:["customer",e]}),t(`/customers/${e}`)}}),f=v=>{const w={type:v.type,salutation:v.salutation||void 0,firstName:v.firstName,lastName:v.lastName,companyName:v.companyName||void 0,email:v.email||void 0,phone:v.phone||void 0,mobile:v.mobile||void 0,taxNumber:v.taxNumber||void 0,commercialRegisterNumber:v.commercialRegisterNumber||void 0,notes:v.notes||void 0,birthPlace:v.birthPlace||void 0};v.birthDate&&typeof v.birthDate=="string"&&v.birthDate.trim()!==""?w.birthDate=new Date(v.birthDate).toISOString():w.birthDate=null,v.foundingDate&&typeof v.foundingDate=="string"&&v.foundingDate.trim()!==""?w.foundingDate=new Date(v.foundingDate).toISOString():w.foundingDate=null,r?m.mutate(w):p.mutate(w)},g=p.isPending||m.isPending,N=p.error||m.error;return s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:r?"Kunde bearbeiten":"Neuer Kunde"}),N&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:N instanceof Error?N.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:i(f),children:[s.jsx(Y,{className:"mb-6",title:"Stammdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Oe,{label:"Kundentyp",...a("type"),options:[{value:"PRIVATE",label:"Privatkunde"},{value:"BUSINESS",label:"Geschäftskunde"}]}),s.jsx(Oe,{label:"Anrede",...a("salutation"),options:[{value:"Herr",label:"Herr"},{value:"Frau",label:"Frau"},{value:"Divers",label:"Divers"}]}),s.jsx(q,{label:"Vorname",...a("firstName",{required:"Vorname erforderlich"}),error:(x=u.firstName)==null?void 0:x.message}),s.jsx(q,{label:"Nachname",...a("lastName",{required:"Nachname erforderlich"}),error:(y=u.lastName)==null?void 0:y.message}),d==="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(q,{label:"Firmenname",...a("companyName"),className:"md:col-span-2"}),s.jsx(q,{label:"Gründungsdatum",type:"date",...a("foundingDate"),value:o("foundingDate")||"",onClear:()=>c("foundingDate","")})]}),d!=="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(q,{label:"Geburtsdatum",type:"date",...a("birthDate"),value:o("birthDate")||"",onClear:()=>c("birthDate","")}),s.jsx(q,{label:"Geburtsort",...a("birthPlace")})]})]})}),s.jsx(Y,{className:"mb-6",title:"Kontaktdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"E-Mail",type:"email",...a("email")}),s.jsx(q,{label:"Telefon",...a("phone")}),s.jsx(q,{label:"Mobil",...a("mobile")})]})}),d==="BUSINESS"&&s.jsxs(Y,{className:"mb-6",title:"Geschäftsdaten",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Steuernummer",...a("taxNumber")}),s.jsx(q,{label:"Handelsregisternummer",...a("commercialRegisterNumber"),placeholder:"z.B. HRB 12345"})]}),r&&s.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Dokumente (Gewerbeanmeldung, Handelsregisterauszug) können nach dem Speichern in der Kundendetailansicht hochgeladen werden."})]}),s.jsx(Y,{className:"mb-6",title:"Notizen",children:s.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..."})}),s.jsxs("div",{className:"flex justify-end gap-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:()=>t(-1),children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:g,children:g?"Speichern...":"Speichern"})]})]})]})}const nu={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},ru={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},nx={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function uk(){const[e,t]=lc(),n=Wt(),[r,a]=j.useState(e.get("search")||""),[i,l]=j.useState(e.get("type")||""),[o,c]=j.useState(e.get("status")||""),[u,d]=j.useState(parseInt(e.get("page")||"1",10)),{hasPermission:h,isCustomer:p,isCustomerPortal:m,user:f}=qe(),g=xe();j.useEffect(()=>{const w=new URLSearchParams;r&&w.set("search",r),i&&w.set("type",i),o&&w.set("status",o),u>1&&w.set("page",u.toString()),t(w,{replace:!0})},[r,i,o,u,t]);const N=H({mutationFn:Ke.delete,onSuccess:()=>{g.invalidateQueries({queryKey:["contracts"]})}}),{data:x,isLoading:y}=de({queryKey:["contracts",r,i,o,u,p?f==null?void 0:f.customerId:null],queryFn:()=>Ke.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})}),v=j.useMemo(()=>{if(!m||!(x!=null&&x.data))return null;const w={};for(const k of x.data){const C=k.customerId;if(!w[C]){const A=k.customer?k.customer.companyName||`${k.customer.firstName} ${k.customer.lastName}`:`Kunde ${C}`;w[C]={customerName:A,isOwn:C===(f==null?void 0:f.customerId),contracts:[]}}w[C].contracts.push(k)}return Object.values(w).sort((k,C)=>k.isOwn&&!C.isOwn?-1:!k.isOwn&&C.isOwn?1:k.customerName.localeCompare(C.customerName))},[x==null?void 0:x.data,m,f==null?void 0:f.customerId]);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Verträge"}),h("contracts:create")&&!p&&s.jsx(Se,{to:"/contracts/new",children:s.jsxs(T,{children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Neuer Vertrag"]})})]}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-4 flex-wrap",children:[s.jsx("div",{className:"flex-1 min-w-[200px]",children:s.jsx(q,{placeholder:"Suchen...",value:r,onChange:w=>a(w.target.value)})}),s.jsx(Oe,{value:i,onChange:w=>l(w.target.value),options:Object.entries(nu).map(([w,k])=>({value:w,label:k})),className:"w-48"}),s.jsx(Oe,{value:o,onChange:w=>c(w.target.value),options:Object.entries(ru).map(([w,k])=>({value:w,label:k})),className:"w-48"}),s.jsx(T,{variant:"secondary",children:s.jsx(fl,{className:"w-4 h-4"})})]})}),y?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):x!=null&&x.data&&x.data.length>0?s.jsx(s.Fragment,{children:m&&v?s.jsx("div",{className:"space-y-6",children:v.map(w=>s.jsxs(Y,{children:[s.jsx("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:w.isOwn?s.jsxs(s.Fragment,{children:[s.jsx(yc,{className:"w-5 h-5 text-blue-600"}),s.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Meine Verträge"}),s.jsx(ve,{variant:"default",children:w.contracts.length})]}):s.jsxs(s.Fragment,{children:[s.jsx(pa,{className:"w-5 h-5 text-purple-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Verträge von ",w.customerName]}),s.jsx(ve,{variant:"default",children:w.contracts.length})]})}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Vertragsnr."}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Anbieter / Tarif"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beginn"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:w.contracts.map(k=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:k.contractNumber}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{children:nu[k.type]})}),s.jsxs("td",{className:"py-3 px-4",children:[k.providerName||"-",k.tariffName&&s.jsxs("span",{className:"text-gray-500",children:[" / ",k.tariffName]})]}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:nx[k.status],children:ru[k.status]})}),s.jsx("td",{className:"py-3 px-4",children:k.startDate?new Date(k.startDate).toLocaleDateString("de-DE"):"-"}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${k.id}`,{state:{from:"contracts"}}),children:s.jsx(Ae,{className:"w-4 h-4"})})})]},k.id))})]})})]},w.isOwn?"own":w.customerName))}):s.jsxs(Y,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Vertragsnr."}),!p&&s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kunde"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Anbieter / Tarif"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beginn"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:x.data.map(w=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:w.contractNumber}),!p&&s.jsx("td",{className:"py-3 px-4",children:w.customer&&s.jsx(Se,{to:`/customers/${w.customer.id}`,className:"text-blue-600 hover:underline",children:w.customer.companyName||`${w.customer.firstName} ${w.customer.lastName}`})}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{children:nu[w.type]})}),s.jsxs("td",{className:"py-3 px-4",children:[w.providerName||"-",w.tariffName&&s.jsxs("span",{className:"text-gray-500",children:[" / ",w.tariffName]})]}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:nx[w.status],children:ru[w.status]})}),s.jsx("td",{className:"py-3 px-4",children:w.startDate?new Date(w.startDate).toLocaleDateString("de-DE"):"-"}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${w.id}`,{state:{from:"contracts"}}),children:s.jsx(Ae,{className:"w-4 h-4"})}),h("contracts:update")&&!p&&s.jsx(Se,{to:`/contracts/${w.id}/edit`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(st,{className:"w-4 h-4"})})}),h("contracts:delete")&&!p&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&N.mutate(w.id)},children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},w.id))})]})}),x.pagination&&x.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",x.pagination.page," von ",x.pagination.totalPages," (",x.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>d(w=>Math.max(1,w-1)),disabled:u===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>d(w=>w+1),disabled:u>=x.pagination.totalPages,children:"Weiter"})]})]})]})}):s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Verträge gefunden."})})]})}const dk={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},mk={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},hk={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function fk(e){const t=e.match(/^(\d+)([TMWJ])$/);if(!t)return!1;const n=parseInt(t[1]),r=t[2];let a=0;return r==="T"?a=n:r==="W"?a=n*7:r==="M"?a=n*30:r==="J"&&(a=n*365),a<=30}function pk({simCard:e}){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[i,l]=j.useState(!1),o=async()=>{if(t)n(!1),a(null);else{l(!0);try{const c=await Ke.getSimCardCredentials(e.id);c.data&&(a(c.data),n(!0))}catch{alert("PIN/PUK konnte nicht geladen werden")}finally{l(!1)}}};return s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg border",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.isMain&&s.jsx(ve,{variant:"success",children:"Hauptkarte"}),e.isMultisim&&s.jsx(ve,{variant:"warning",children:"Multisim"})]}),s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[e.phoneNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Rufnummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[e.phoneNumber,s.jsx(me,{value:e.phoneNumber})]})]}),e.simCardNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIM-Nr."}),s.jsxs("dd",{className:"font-mono text-xs flex items-center gap-1",children:[e.simCardNumber,s.jsx(me,{value:e.simCardNumber})]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"PIN"}),s.jsx("dd",{className:"font-mono flex items-center gap-1",children:t&&(r!=null&&r.pin)?s.jsxs(s.Fragment,{children:[r.pin,s.jsx(me,{value:r.pin})]}):"••••"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"PUK"}),s.jsx("dd",{className:"font-mono flex items-center gap-1",children:t&&(r!=null&&r.puk)?s.jsxs(s.Fragment,{children:[r.puk,s.jsx(me,{value:r.puk})]}):"••••••••"})]})]}),s.jsx("div",{className:"mt-2",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:o,disabled:i,children:i?"Laden...":t?s.jsxs(s.Fragment,{children:[s.jsx(At,{className:"w-4 h-4 mr-1"})," PIN/PUK verbergen"]}):s.jsxs(s.Fragment,{children:[s.jsx(Ae,{className:"w-4 h-4 mr-1"})," PIN/PUK anzeigen"]})})})]})}function xk({meterId:e,meterType:t,readings:n,contractId:r,canEdit:a}){const[i,l]=j.useState(!1),[o,c]=j.useState(!1),[u,d]=j.useState(null),h=xe(),p=H({mutationFn:g=>Xs.deleteReading(e,g),onSuccess:()=>{h.invalidateQueries({queryKey:["contract",r.toString()]})}}),m=[...n].sort((g,N)=>new Date(N.readingDate).getTime()-new Date(g.readingDate).getTime()),f=t==="ELECTRICITY"?"kWh":"m³";return s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_0,{className:"w-4 h-4 text-gray-500"}),s.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Zählerstände"}),s.jsx(ve,{variant:"default",children:n.length})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[a&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>c(!0),title:"Zählerstand erfassen",children:s.jsx($e,{className:"w-4 h-4"})}),n.length>0&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(!i),children:i?s.jsx(O0,{className:"w-4 h-4"}):s.jsx(Ha,{className:"w-4 h-4"})})]})]}),i&&n.length>0&&s.jsx("div",{className:"space-y-2 bg-gray-50 rounded-lg p-3",children:m.map(g=>s.jsxs("div",{className:"flex justify-between items-center text-sm group py-1 border-b border-gray-200 last:border-0",children:[s.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(g.readingDate).toLocaleDateString("de-DE"),s.jsx(me,{value:new Date(g.readingDate).toLocaleDateString("de-DE")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[g.value.toLocaleString("de-DE")," ",g.unit,s.jsx(me,{value:g.value.toString(),title:"Nur Wert kopieren"})]}),a&&s.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[s.jsx("button",{onClick:()=>d(g),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(st,{className:"w-3 h-3"})}),s.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:s.jsx(be,{className:"w-3 h-3"})})]})]})]},g.id))}),!i&&n.length>0&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Letzter Stand: ",m[0].value.toLocaleString("de-DE")," ",m[0].unit," (",new Date(m[0].readingDate).toLocaleDateString("de-DE"),")"]}),n.length===0&&s.jsx("p",{className:"text-sm text-gray-500",children:"Keine Zählerstände vorhanden."}),(o||u)&&s.jsx(gk,{isOpen:!0,onClose:()=>{c(!1),d(null)},meterId:e,contractId:r,reading:u,defaultUnit:f})]})}function gk({isOpen:e,onClose:t,meterId:n,contractId:r,reading:a,defaultUnit:i}){var f;const l=xe(),o=!!a,[c,u]=j.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=H({mutationFn:g=>Xs.addReading(n,g),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),h=H({mutationFn:g=>Xs.updateReading(n,a.id,g),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),p=g=>{g.preventDefault();const N={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:c.unit,notes:c.notes||void 0};o?h.mutate(N):d.mutate(N)},m=d.isPending||h.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:o?"Zählerstand bearbeiten":"Zählerstand erfassen",children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(q,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:g=>u({...c,readingDate:g.target.value}),required:!0}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(q,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:g=>u({...c,value:g.target.value}),required:!0})}),s.jsx(Oe,{label:"Einheit",value:c.unit,onChange:g=>u({...c,unit:g.target.value}),options:[{value:"kWh",label:"kWh"},{value:"m³",label:"m³"}]})]}),s.jsx(q,{label:"Notizen (optional)",value:c.notes,onChange:g=>u({...c,notes:g.target.value})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m||!c.value,children:m?"Speichern...":o?"Speichern":"Erfassen"})]})]})})}function rx({task:e,contractId:t,canEdit:n,isCustomerPortal:r,isCompleted:a,onEdit:i}){const[l,o]=j.useState(""),[c,u]=j.useState(!1),[d,h]=j.useState(null),[p,m]=j.useState(""),f=xe(),g=H({mutationFn:b=>ct.complete(b),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),N=H({mutationFn:b=>ct.reopen(b),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),x=H({mutationFn:b=>ct.delete(b),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),y=H({mutationFn:b=>ct.createSubtask(e.id,b),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),u(!1)},onError:b=>{console.error("Fehler beim Erstellen der Unteraufgabe:",b),alert("Fehler beim Erstellen der Unteraufgabe. Bitte versuchen Sie es erneut.")}}),v=H({mutationFn:b=>ct.createReply(e.id,b),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),u(!1)},onError:b=>{console.error("Fehler beim Erstellen der Antwort:",b),alert("Fehler beim Erstellen der Antwort. Bitte versuchen Sie es erneut.")}}),w=H({mutationFn:({id:b,title:z})=>ct.updateSubtask(b,z),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),h(null),m("")}}),k=H({mutationFn:b=>ct.completeSubtask(b),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),C=H({mutationFn:b=>ct.reopenSubtask(b),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),A=H({mutationFn:b=>ct.deleteSubtask(b),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),S=b=>{b.preventDefault(),l.trim()&&(r?v.mutate(l.trim()):y.mutate(l.trim()))},E=b=>{b.preventDefault(),p.trim()&&d&&w.mutate({id:d,title:p.trim()})},D=(b,z)=>{h(b),m(z)},$=()=>{h(null),m("")},L=e.subtasks||[],U=L.filter(b=>b.status==="OPEN"),V=L.filter(b=>b.status==="COMPLETED"),O=r?{singular:"Antwort",placeholder:"Antwort...",deleteConfirm:"Antwort löschen?"}:{singular:"Unteraufgabe",placeholder:"Unteraufgabe...",deleteConfirm:"Unteraufgabe löschen?"},P=(b,z)=>d===b.id?s.jsx("div",{className:"py-1",children:s.jsxs("form",{onSubmit:E,className:"flex items-center gap-2",children:[s.jsx(ao,{className:"w-4 h-4 text-gray-300 flex-shrink-0"}),s.jsx("input",{type:"text",value:p,onChange:ee=>m(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}),s.jsx(T,{type:"submit",size:"sm",disabled:!p.trim()||w.isPending,children:"✓"}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:$,children:"×"})]})},b.id):s.jsx("div",{className:`py-1 group/subtask ${z?"opacity-60":""}`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("button",{onClick:()=>z?C.mutate(b.id):k.mutate(b.id),disabled:k.isPending||C.isPending||r,className:`flex-shrink-0 mt-0.5 ${r?"cursor-default":z?"hover:text-yellow-600":"hover:text-green-600"}`,children:z?s.jsx(vs,{className:"w-4 h-4 text-green-500"}):s.jsx(ao,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:`text-sm ${z?"line-through text-gray-500":""}`,children:b.title}),n&&!r&&!z&&s.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover/subtask:opacity-100",children:[s.jsx("button",{onClick:()=>D(b.id,b.title),className:"text-gray-400 hover:text-blue-600 p-0.5",title:"Bearbeiten",children:s.jsx(st,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm(O.deleteConfirm)&&A.mutate(b.id)},className:"text-gray-400 hover:text-red-600 p-0.5",title:"Löschen",children:s.jsx(be,{className:"w-3 h-3"})})]}),n&&!r&&z&&s.jsx("button",{onClick:()=>{confirm(O.deleteConfirm)&&A.mutate(b.id)},className:"text-gray-400 hover:text-red-600 p-0.5 opacity-0 group-hover/subtask:opacity-100",title:"Löschen",children:s.jsx(be,{className:"w-3 h-3"})})]}),s.jsxs("p",{className:"text-xs text-gray-400",children:[b.createdBy&&`${b.createdBy} • `,z?`Erledigt am ${b.completedAt?new Date(b.completedAt).toLocaleDateString("de-DE"):new Date(b.updatedAt).toLocaleDateString("de-DE")}`:new Date(b.createdAt).toLocaleDateString("de-DE")]})]})]})},b.id);return s.jsx("div",{className:`p-3 bg-gray-50 rounded-lg group ${a?"bg-gray-50/50 opacity-70":""}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>a?N.mutate(e.id):g.mutate(e.id),disabled:g.isPending||N.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?s.jsx(vs,{className:"w-5 h-5 text-green-500"}):s.jsx(ao,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`font-medium ${a?"line-through text-gray-500":""}`,children:e.title}),e.visibleInPortal&&s.jsx(ve,{variant:"default",className:"text-xs",children:"Portal"}),L.length>0&&s.jsxs("span",{className:"text-xs text-gray-400",children:["(",V.length,"/",L.length,")"]})]}),e.description&&s.jsx("p",{className:`text-sm mt-1 whitespace-pre-wrap ${a?"text-gray-500":"text-gray-600"}`,children:e.description}),s.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")]}),L.length>0&&s.jsxs("div",{className:"mt-3 ml-2 space-y-0 border-l-2 border-gray-200 pl-3",children:[U.map(b=>P(b,!1)),V.map(b=>P(b,!0))]}),!a&&(n&&!r||r)&&s.jsx("div",{className:"mt-2 ml-2",children:c?s.jsxs("form",{onSubmit:S,className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:l,onChange:b=>o(b.target.value),placeholder:O.placeholder,className:"flex-1 text-sm px-2 py-1 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500",autoFocus:!0}),s.jsx(T,{type:"submit",size:"sm",disabled:!l.trim()||y.isPending||v.isPending,children:s.jsx($e,{className:"w-3 h-3"})}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{u(!1),o("")},children:"×"})]}):s.jsxs("button",{onClick:()=>u(!0),className:"text-xs text-gray-400 hover:text-blue-600 flex items-center gap-1",children:[s.jsx($e,{className:"w-3 h-3"}),O.singular]})})]}),n&&!r&&s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100",children:[!a&&s.jsx("button",{onClick:i,className:"text-gray-400 hover:text-blue-600 p-1",title:"Bearbeiten",children:s.jsx(st,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm("Aufgabe wirklich löschen?")&&x.mutate(e.id)},className:"text-gray-400 hover:text-red-600 p-1",title:"Löschen",children:s.jsx(be,{className:"w-4 h-4"})})]})]})})}function yk({contractId:e,canEdit:t,isCustomerPortal:n}){var v;const[r,a]=j.useState(!1),[i,l]=j.useState(null),{data:o,isLoading:c}=de({queryKey:["contract-tasks",e],queryFn:()=>ct.getByContract(e),staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:u,isLoading:d}=de({queryKey:["app-settings-public"],queryFn:()=>Ur.getPublic(),enabled:n,staleTime:0}),h=!d&&((v=u==null?void 0:u.data)==null?void 0:v.customerSupportTicketsEnabled)==="true",p=(o==null?void 0:o.data)||[],m=p.filter(w=>w.status==="OPEN"),f=p.filter(w=>w.status==="COMPLETED"),g=n?{title:"Support-Anfragen",button:"Anfrage erstellen",empty:"Keine Support-Anfragen vorhanden."}:{title:"Aufgaben",button:"Aufgabe",empty:"Keine Aufgaben vorhanden."},N=n?Xi:Ji;if(c||n&&d)return s.jsx(Y,{className:"mb-6",title:g.title,children:s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."})});const y=t&&!n||n&&h;return s.jsxs(Y,{className:"mb-6",title:g.title,children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(N,{className:"w-5 h-5 text-gray-500"}),s.jsxs("span",{className:"text-sm text-gray-600",children:[m.length," offen, ",f.length," erledigt"]})]}),y&&s.jsxs(T,{size:"sm",onClick:()=>a(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-1"}),g.button]})]}),p.length===0?s.jsx("p",{className:"text-center py-4 text-gray-500",children:g.empty}):s.jsxs("div",{className:"space-y-2",children:[m.map(w=>s.jsx(rx,{task:w,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!1,onEdit:()=>l(w)},w.id)),f.length>0&&m.length>0&&s.jsx("div",{className:"border-t my-3"}),f.map(w=>s.jsx(rx,{task:w,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!0,onEdit:()=>{}},w.id))]}),(r||i)&&s.jsx(vk,{isOpen:!0,onClose:()=>{a(!1),l(null)},contractId:e,task:i,isCustomerPortal:n})]})}function vk({isOpen:e,onClose:t,contractId:n,task:r,isCustomerPortal:a=!1}){const i=xe(),l=!!r,[o,c]=j.useState({title:(r==null?void 0:r.title)||"",description:(r==null?void 0:r.description)||"",visibleInPortal:(r==null?void 0:r.visibleInPortal)||!1});j.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=H({mutationFn:g=>ct.create(n,g),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),d=H({mutationFn:g=>ct.createSupportTicket(n,g),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),h=H({mutationFn:g=>ct.update(r.id,g),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),p=g=>{g.preventDefault(),l?h.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})},m=u.isPending||d.isPending||h.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 s.jsx(ut,{isOpen:e,onClose:t,title:f.modalTitle,children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(q,{label:f.titleLabel,value:o.title,onChange:g=>c({...o,title:g.target.value}),required:!0,placeholder:f.titlePlaceholder}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:f.descLabel}),s.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&&s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.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"}),s.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m||!o.title.trim(),children:m?"Speichern...":f.submitBtn})]})]})})}function jk(){var z,J,ee,pe,le,nt;const{id:e}=ac(),t=Wt(),r=En().state,a=xe(),{hasPermission:i,isCustomer:l,isCustomerPortal:o}=qe(),c=parseInt(e),[u,d]=j.useState(!1),[h,p]=j.useState(null),[m,f]=j.useState(!1),[g,N]=j.useState(!1),[x,y]=j.useState(null),[v,w]=j.useState({}),[k,C]=j.useState({}),{data:A,isLoading:S}=de({queryKey:["contract",e],queryFn:()=>Ke.getById(c)}),E=H({mutationFn:()=>Ke.delete(c),onSuccess:()=>{t("/contracts")}}),D=H({mutationFn:()=>Ke.createFollowUp(c),onSuccess:Q=>{Q.data?t(`/contracts/${Q.data.id}/edit`):alert("Folgevertrag wurde erstellt, aber keine ID zurückgegeben")},onError:Q=>{console.error("Folgevertrag Fehler:",Q),alert(`Fehler beim Erstellen des Folgevertrags: ${Q instanceof Error?Q.message:"Unbekannter Fehler"}`)}}),$=H({mutationFn:Q=>{const Pe={cancellationConfirmationDate:Q?new Date(Q).toISOString():null};return Ke.update(c,Pe)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:Q=>{console.error("Fehler beim Speichern des Datums:",Q),alert("Fehler beim Speichern des Datums")}}),L=H({mutationFn:Q=>{const Pe={cancellationConfirmationOptionsDate:Q?new Date(Q).toISOString():null};return Ke.update(c,Pe)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:Q=>{console.error("Fehler beim Speichern des Datums:",Q),alert("Fehler beim Speichern des Datums")}}),U=async()=>{var Q;if(u)d(!1),p(null);else try{const ke=await Ke.getPassword(c);(Q=ke.data)!=null&&Q.password&&(p(ke.data.password),d(!0))}catch{alert("Passwort konnte nicht entschlüsselt werden")}},V=async()=>{var Q;if(g)N(!1),y(null);else try{const ke=await Ke.getInternetCredentials(c);(Q=ke.data)!=null&&Q.password&&(y(ke.data.password),N(!0))}catch{alert("Internet-Passwort konnte nicht entschlüsselt werden")}},O=async Q=>{var ke;if(v[Q])w(Pe=>({...Pe,[Q]:!1})),C(Pe=>({...Pe,[Q]:null}));else try{const Ge=(ke=(await Ke.getSipCredentials(Q)).data)==null?void 0:ke.password;Ge&&(C(ht=>({...ht,[Q]:Ge})),w(ht=>({...ht,[Q]:!0})))}catch{alert("SIP-Passwort konnte nicht entschlüsselt werden")}},P=async()=>{var Pe,Ge,ht;const Q=A==null?void 0:A.data,ke=((Pe=Q==null?void 0:Q.stressfreiEmail)==null?void 0:Pe.email)||(Q==null?void 0:Q.portalUsername);if(!((Ge=Q==null?void 0:Q.provider)!=null&&Ge.portalUrl)||!ke){alert("Portal-URL oder Benutzername fehlt");return}f(!0);try{const Tt=await Ke.getPassword(c);if(!((ht=Tt.data)!=null&&ht.password)){alert("Passwort konnte nicht entschlüsselt werden");return}const W=Q.provider,_e=W.portalUrl,Et=W.usernameFieldName||"username",$s=W.passwordFieldName||"password",ws=new URL(_e);ws.searchParams.set(Et,ke),ws.searchParams.set($s,Tt.data.password),window.open(ws.toString(),"_blank")}catch{alert("Fehler beim Auto-Login")}finally{f(!1)}};if(S)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(A!=null&&A.data))return s.jsx("div",{className:"text-center py-8 text-red-600",children:"Vertrag nicht gefunden"});const b=A.data;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[s.jsx(T,{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 Q=r.filter?`?filter=${r.filter}`:"";t(`/contracts/cockpit${Q}`)}else(r==null?void 0:r.from)==="contracts"?t("/contracts"):b.customer?t(`/customers/${b.customer.id}?tab=contracts`):t("/contracts")},children:s.jsx(tn,{className:"w-4 h-4"})}),s.jsx("h1",{className:"text-2xl font-bold",children:b.contractNumber}),s.jsx(ve,{children:dk[b.type]}),s.jsx(ve,{variant:hk[b.status],children:mk[b.status]})]}),b.customer&&s.jsxs("p",{className:"text-gray-500 ml-10",children:["Kunde:"," ",s.jsx(Se,{to:`/customers/${b.customer.id}`,className:"text-blue-600 hover:underline",children:b.customer.companyName||`${b.customer.firstName} ${b.customer.lastName}`})]})]}),!l&&s.jsxs("div",{className:"flex gap-2",children:[i("contracts:create")&&!b.followUpContract&&s.jsxs(T,{variant:"secondary",onClick:()=>D.mutate(),disabled:D.isPending,children:[s.jsx(Om,{className:"w-4 h-4 mr-2"}),D.isPending?"Erstelle...":"Folgevertrag anlegen"]}),b.followUpContract&&s.jsx(Se,{to:`/contracts/${b.followUpContract.id}`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(I0,{className:"w-4 h-4 mr-2"}),"Folgevertrag anzeigen"]})}),i("contracts:update")&&s.jsx(Se,{to:`/contracts/${e}/edit`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(st,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),i("contracts:delete")&&s.jsxs(T,{variant:"danger",onClick:()=>{confirm("Vertrag wirklich löschen?")&&E.mutate()},children:[s.jsx(be,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),b.previousContract&&s.jsx(Y,{className:"mb-6 border-l-4 border-l-blue-500",title:"Vorgängervertrag",children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),s.jsx("dd",{children:s.jsx(Se,{to:`/contracts/${b.previousContract.id}`,className:"text-blue-600 hover:underline",children:b.previousContract.contractNumber})})]}),b.previousContract.providerName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{children:b.previousContract.providerName})]}),b.previousContract.customerNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),s.jsx("dd",{className:"font-mono",children:b.previousContract.customerNumberAtProvider})]}),b.previousContract.portalUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Zugangsdaten"}),s.jsx("dd",{children:b.previousContract.portalUsername})]})]})}),b.cancellationConfirmationDate&&s.jsxs("div",{className:"mb-6 p-4 bg-red-50 border-2 border-red-400 rounded-lg flex items-start gap-3",children:[s.jsx("span",{className:"text-red-600 text-xl font-bold",children:"!"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-red-800",children:"Kündigungsbestätigung vorhanden"}),s.jsxs("p",{className:"text-sm text-red-700 mt-1",children:["Dieser Vertrag hat eine Kündigungsbestätigung vom"," ",s.jsx("strong",{children:new Date(b.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),".",b.cancellationConfirmationOptionsDate&&s.jsxs(s.Fragment,{children:[" Optionen-Bestätigung: ",s.jsx("strong",{children:new Date(b.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),"."]})]})]})]}),b.type==="MOBILE"&&((z=b.mobileDetails)==null?void 0:z.requiresMultisim)&&s.jsxs("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-300 rounded-lg flex items-start gap-3",children:[s.jsx("span",{className:"text-amber-600 text-xl font-bold",children:"!"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-amber-800",children:"Multisim erforderlich"}),s.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."})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[s.jsx(Y,{title:"Anbieter & Tarif",children:s.jsxs("dl",{className:"space-y-3",children:[(b.provider||b.providerName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{className:"font-medium",children:((J=b.provider)==null?void 0:J.name)||b.providerName})]}),(b.tariff||b.tariffName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Tarif"}),s.jsx("dd",{children:((ee=b.tariff)==null?void 0:ee.name)||b.tariffName})]}),b.customerNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.customerNumberAtProvider,s.jsx(me,{value:b.customerNumberAtProvider})]})]}),b.salesPlatform&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertriebsplattform"}),s.jsx("dd",{children:b.salesPlatform.name})]}),b.commission!==null&&b.commission!==void 0&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Provision"}),s.jsx("dd",{children:b.commission.toLocaleString("de-DE",{style:"currency",currency:"EUR"})})]}),b.priceFirst12Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis erste 12 Monate"}),s.jsx("dd",{children:b.priceFirst12Months})]}),b.priceFrom13Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis ab 13. Monat"}),s.jsx("dd",{children:b.priceFrom13Months})]}),b.priceAfter24Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis nach 24 Monaten"}),s.jsx("dd",{children:b.priceAfter24Months})]})]})}),s.jsxs(Y,{title:"Laufzeit und Kündigung",className:b.cancellationConfirmationDate?"border-2 border-red-400":"",children:[b.contractDuration&&fk(b.contractDuration.code)&&s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.jsx("strong",{children:"Hinweis:"})," Dieser Vertrag gilt als unbefristet mit der jeweiligen Kündigungsfrist."]}),s.jsxs("dl",{className:"space-y-3",children:[b.startDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsbeginn"}),s.jsx("dd",{children:new Date(b.startDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),b.endDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsende"}),s.jsx("dd",{children:new Date(b.endDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),b.contractDuration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragslaufzeit"}),s.jsx("dd",{children:b.contractDuration.description})]}),b.cancellationPeriod&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsfrist"}),s.jsx("dd",{children:b.cancellationPeriod.description})]}),b.cancellationConfirmationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsdatum"}),s.jsx("dd",{children:new Date(b.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),b.cancellationConfirmationOptionsDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsoptionendatum"}),s.jsx("dd",{children:new Date(b.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),b.wasSpecialCancellation&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Sonderkündigung"}),s.jsx("dd",{children:s.jsx(ve,{variant:"warning",children:"Ja"})})]})]}),i("contracts:update")&&s.jsxs("div",{className:"mt-6 pt-6 border-t",children:[s.jsx("h4",{className:"font-medium mb-4",children:"Kündigungsdokumente"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben"}),b.cancellationLetterPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${b.cancellationLetterPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${b.cancellationLetterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ts,{className:"w-4 h-4"}),"Download"]}),s.jsx(St,{onUpload:async Q=>{await lt.uploadCancellationLetter(c,Q),a.invalidateQueries({queryKey:["contract",e]})},existingFile:b.cancellationLetterPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await lt.deleteCancellationLetter(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]}):s.jsx(St,{onUpload:async Q=>{await lt.uploadCancellationLetter(c,Q),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung"}),b.cancellationConfirmationPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${b.cancellationConfirmationPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${b.cancellationConfirmationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ts,{className:"w-4 h-4"}),"Download"]}),s.jsx(St,{onUpload:async Q=>{await lt.uploadCancellationConfirmation(c,Q),a.invalidateQueries({queryKey:["contract",e]})},existingFile:b.cancellationConfirmationPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await lt.deleteCancellationConfirmation(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"date",value:b.cancellationConfirmationDate?b.cancellationConfirmationDate.split("T")[0]:"",onChange:Q=>{const ke=Q.target.value||null;$.mutate(ke)},className:"block w-full max-w-[180px] px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"}),b.cancellationConfirmationDate&&s.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:s.jsx(be,{className:"w-4 h-4"})})]})]})]}):s.jsx(St,{onUpload:async Q=>{await lt.uploadCancellationConfirmation(c,Q),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben Optionen"}),b.cancellationLetterOptionsPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${b.cancellationLetterOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${b.cancellationLetterOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ts,{className:"w-4 h-4"}),"Download"]}),s.jsx(St,{onUpload:async Q=>{await lt.uploadCancellationLetterOptions(c,Q),a.invalidateQueries({queryKey:["contract",e]})},existingFile:b.cancellationLetterOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await lt.deleteCancellationLetterOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]}):s.jsx(St,{onUpload:async Q=>{await lt.uploadCancellationLetterOptions(c,Q),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung Optionen"}),b.cancellationConfirmationOptionsPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${b.cancellationConfirmationOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${b.cancellationConfirmationOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ts,{className:"w-4 h-4"}),"Download"]}),s.jsx(St,{onUpload:async Q=>{await lt.uploadCancellationConfirmationOptions(c,Q),a.invalidateQueries({queryKey:["contract",e]})},existingFile:b.cancellationConfirmationOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await lt.deleteCancellationConfirmationOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"date",value:b.cancellationConfirmationOptionsDate?b.cancellationConfirmationOptionsDate.split("T")[0]:"",onChange:Q=>{const ke=Q.target.value||null;L.mutate(ke)},className:"block w-full max-w-[180px] px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"}),b.cancellationConfirmationOptionsDate&&s.jsx("button",{onClick:()=>L.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:s.jsx(be,{className:"w-4 h-4"})})]})]})]}):s.jsx(St,{onUpload:async Q=>{await lt.uploadCancellationConfirmationOptions(c,Q),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]})]})]})]})]}),(b.portalUsername||b.stressfreiEmail||b.portalPasswordEncrypted)&&s.jsxs(Y,{className:"mb-6",title:"Zugangsdaten",children:[s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[(b.portalUsername||b.stressfreiEmail)&&s.jsxs("div",{children:[s.jsxs("dt",{className:"text-sm text-gray-500",children:["Benutzername",b.stressfreiEmail&&s.jsx("span",{className:"ml-2 text-xs text-blue-600",children:"(Stressfrei-Wechseln)"})]}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[((pe=b.stressfreiEmail)==null?void 0:pe.email)||b.portalUsername,s.jsx(me,{value:((le=b.stressfreiEmail)==null?void 0:le.email)||b.portalUsername||""})]})]}),b.portalPasswordEncrypted&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),s.jsxs("dd",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono",children:u&&h?h:"••••••••"}),u&&h&&s.jsx(me,{value:h}),s.jsx(T,{variant:"ghost",size:"sm",onClick:U,children:u?s.jsx(At,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]}),((nt=b.provider)==null?void 0:nt.portalUrl)&&(b.portalUsername||b.stressfreiEmail)&&b.portalPasswordEncrypted&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs(T,{onClick:P,disabled:m,className:"w-full sm:w-auto",children:[s.jsx(zm,{className:"w-4 h-4 mr-2"}),m?"Wird geöffnet...":"Zum Kundenportal (Auto-Login)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Öffnet das Portal mit vorausgefüllten Zugangsdaten"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[b.address&&s.jsx(Y,{title:"Adresse",children:s.jsxs(G0,{values:[`${b.address.street} ${b.address.houseNumber}`,`${b.address.postalCode} ${b.address.city}`,b.address.country],children:[s.jsxs("p",{children:[b.address.street," ",b.address.houseNumber]}),s.jsxs("p",{children:[b.address.postalCode," ",b.address.city]}),s.jsx("p",{className:"text-gray-500",children:b.address.country})]})}),b.bankCard&&s.jsxs(Y,{title:"Bankkarte",children:[s.jsx("p",{className:"font-medium",children:b.bankCard.accountHolder}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[b.bankCard.iban,s.jsx(me,{value:b.bankCard.iban})]}),b.bankCard.bankName&&s.jsx("p",{className:"text-gray-500",children:b.bankCard.bankName})]}),b.identityDocument&&s.jsxs(Y,{title:"Ausweis",children:[s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[b.identityDocument.documentNumber,s.jsx(me,{value:b.identityDocument.documentNumber})]}),s.jsx("p",{className:"text-gray-500",children:b.identityDocument.type})]})]}),b.energyDetails&&s.jsxs(Y,{className:"mb-6",title:b.type==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[b.energyDetails.meter&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Zählernummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.energyDetails.meter.meterNumber,s.jsx(me,{value:b.energyDetails.meter.meterNumber})]})]}),b.energyDetails.annualConsumption&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Jahresverbrauch"}),s.jsxs("dd",{children:[b.energyDetails.annualConsumption.toLocaleString("de-DE")," ",b.type==="ELECTRICITY"?"kWh":"m³"]})]}),b.energyDetails.basePrice&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Grundpreis"}),s.jsxs("dd",{children:[b.energyDetails.basePrice.toLocaleString("de-DE")," €/Monat"]})]}),b.energyDetails.unitPrice&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Arbeitspreis"}),s.jsxs("dd",{children:[b.energyDetails.unitPrice.toLocaleString("de-DE")," ct/",b.type==="ELECTRICITY"?"kWh":"m³"]})]}),b.energyDetails.bonus&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Bonus"}),s.jsxs("dd",{children:[b.energyDetails.bonus.toLocaleString("de-DE")," €"]})]}),b.energyDetails.previousProviderName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversorger"}),s.jsx("dd",{children:b.energyDetails.previousProviderName})]}),b.energyDetails.previousCustomerNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorherige Kundennr."}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.energyDetails.previousCustomerNumber,s.jsx(me,{value:b.energyDetails.previousCustomerNumber})]})]})]}),b.energyDetails.meter&&s.jsx(xk,{meterId:b.energyDetails.meter.id,meterType:b.energyDetails.meter.type,readings:b.energyDetails.meter.readings||[],contractId:c,canEdit:i("contracts:update")&&!l})]}),b.internetDetails&&s.jsxs(Y,{className:"mb-6",title:b.type==="DSL"?"DSL-Details":b.type==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[b.internetDetails.downloadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Download"}),s.jsxs("dd",{children:[b.internetDetails.downloadSpeed," Mbit/s"]})]}),b.internetDetails.uploadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Upload"}),s.jsxs("dd",{children:[b.internetDetails.uploadSpeed," Mbit/s"]})]}),b.internetDetails.routerModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Router"}),s.jsx("dd",{children:b.internetDetails.routerModel})]}),b.internetDetails.routerSerialNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Router S/N"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.internetDetails.routerSerialNumber,s.jsx(me,{value:b.internetDetails.routerSerialNumber})]})]}),b.internetDetails.installationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Installation"}),s.jsx("dd",{children:new Date(b.internetDetails.installationDate).toLocaleDateString("de-DE")})]}),b.internetDetails.homeId&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Home-ID"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.internetDetails.homeId,s.jsx(me,{value:b.internetDetails.homeId})]})]}),b.internetDetails.activationCode&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Aktivierungscode"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.internetDetails.activationCode,s.jsx(me,{value:b.internetDetails.activationCode})]})]})]}),(b.internetDetails.internetUsername||b.internetDetails.internetPasswordEncrypted)&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Internet-Zugangsdaten"}),s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[b.internetDetails.internetUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Benutzername"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.internetDetails.internetUsername,s.jsx(me,{value:b.internetDetails.internetUsername})]})]}),b.internetDetails.internetPasswordEncrypted&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),s.jsxs("dd",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono",children:g&&x?x:"••••••••"}),g&&x&&s.jsx(me,{value:x}),s.jsx(T,{variant:"ghost",size:"sm",onClick:V,children:g?s.jsx(At,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})]}),b.internetDetails.phoneNumbers&&b.internetDetails.phoneNumbers.length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Rufnummern & SIP-Zugangsdaten"}),s.jsx("div",{className:"space-y-3",children:b.internetDetails.phoneNumbers.map(Q=>s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsxs("span",{className:"font-mono font-medium flex items-center gap-1",children:[Q.phoneNumber,s.jsx(me,{value:Q.phoneNumber})]}),Q.isMain&&s.jsx(ve,{variant:"success",children:"Hauptnummer"})]}),(Q.sipUsername||Q.sipPasswordEncrypted||Q.sipServer)&&s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[Q.sipUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIP-Benutzer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[Q.sipUsername,s.jsx(me,{value:Q.sipUsername})]})]}),Q.sipPasswordEncrypted&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIP-Passwort"}),s.jsxs("dd",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono",children:v[Q.id]&&k[Q.id]?k[Q.id]:"••••••••"}),v[Q.id]&&k[Q.id]&&s.jsx(me,{value:k[Q.id]}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>O(Q.id),children:v[Q.id]?s.jsx(At,{className:"w-3 h-3"}):s.jsx(Ae,{className:"w-3 h-3"})})]})]}),Q.sipServer&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIP-Server"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[Q.sipServer,s.jsx(me,{value:Q.sipServer})]})]})]})]},Q.id))})]})]}),b.mobileDetails&&s.jsxs(Y,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[b.mobileDetails.dataVolume&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Datenvolumen"}),s.jsxs("dd",{children:[b.mobileDetails.dataVolume," GB"]})]}),b.mobileDetails.includedMinutes&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-Minuten"}),s.jsx("dd",{children:b.mobileDetails.includedMinutes})]}),b.mobileDetails.includedSMS&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-SMS"}),s.jsx("dd",{children:b.mobileDetails.includedSMS})]}),b.mobileDetails.deviceModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Gerät"}),s.jsx("dd",{children:b.mobileDetails.deviceModel})]}),b.mobileDetails.deviceImei&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"IMEI"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.mobileDetails.deviceImei,s.jsx(me,{value:b.mobileDetails.deviceImei})]})]}),b.mobileDetails.requiresMultisim&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Multisim"}),s.jsx("dd",{children:s.jsx(ve,{variant:"warning",children:"Erforderlich"})})]})]}),b.mobileDetails.simCards&&b.mobileDetails.simCards.length>0&&s.jsxs("div",{className:"mt-6 pt-6 border-t",children:[s.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karten"}),s.jsx("div",{className:"space-y-3",children:b.mobileDetails.simCards.map(Q=>s.jsx(pk,{simCard:Q},Q.id))})]}),(!b.mobileDetails.simCards||b.mobileDetails.simCards.length===0)&&(b.mobileDetails.phoneNumber||b.mobileDetails.simCardNumber)&&s.jsxs("div",{className:"mt-6 pt-6 border-t",children:[s.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karte (Legacy)"}),s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[b.mobileDetails.phoneNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Rufnummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.mobileDetails.phoneNumber,s.jsx(me,{value:b.mobileDetails.phoneNumber})]})]}),b.mobileDetails.simCardNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SIM-Kartennummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.mobileDetails.simCardNumber,s.jsx(me,{value:b.mobileDetails.simCardNumber})]})]})]})]})]}),b.tvDetails&&s.jsx(Y,{className:"mb-6",title:"TV-Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[b.tvDetails.receiverModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Receiver"}),s.jsx("dd",{children:b.tvDetails.receiverModel})]}),b.tvDetails.smartcardNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Smartcard"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.tvDetails.smartcardNumber,s.jsx(me,{value:b.tvDetails.smartcardNumber})]})]}),b.tvDetails.package&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Paket"}),s.jsx("dd",{children:b.tvDetails.package})]})]})}),b.carInsuranceDetails&&s.jsx(Y,{className:"mb-6",title:"KFZ-Versicherung Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[b.carInsuranceDetails.licensePlate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kennzeichen"}),s.jsxs("dd",{className:"font-mono font-bold flex items-center gap-1",children:[b.carInsuranceDetails.licensePlate,s.jsx(me,{value:b.carInsuranceDetails.licensePlate})]})]}),b.carInsuranceDetails.vehicleType&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Fahrzeug"}),s.jsx("dd",{children:b.carInsuranceDetails.vehicleType})]}),b.carInsuranceDetails.hsn&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"HSN/TSN"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.carInsuranceDetails.hsn,"/",b.carInsuranceDetails.tsn,s.jsx(me,{value:`${b.carInsuranceDetails.hsn}/${b.carInsuranceDetails.tsn}`})]})]}),b.carInsuranceDetails.vin&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"FIN"}),s.jsxs("dd",{className:"font-mono text-sm flex items-center gap-1",children:[b.carInsuranceDetails.vin,s.jsx(me,{value:b.carInsuranceDetails.vin})]})]}),b.carInsuranceDetails.firstRegistration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Erstzulassung"}),s.jsx("dd",{children:new Date(b.carInsuranceDetails.firstRegistration).toLocaleDateString("de-DE")})]}),b.carInsuranceDetails.noClaimsClass&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SF-Klasse"}),s.jsx("dd",{children:b.carInsuranceDetails.noClaimsClass})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsart"}),s.jsx("dd",{children:s.jsx(ve,{variant:b.carInsuranceDetails.insuranceType==="FULL"?"success":b.carInsuranceDetails.insuranceType==="PARTIAL"?"warning":"default",children:b.carInsuranceDetails.insuranceType==="FULL"?"Vollkasko":b.carInsuranceDetails.insuranceType==="PARTIAL"?"Teilkasko":"Haftpflicht"})})]}),b.carInsuranceDetails.deductiblePartial&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Teilkasko"}),s.jsxs("dd",{children:[b.carInsuranceDetails.deductiblePartial," €"]})]}),b.carInsuranceDetails.deductibleFull&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Vollkasko"}),s.jsxs("dd",{children:[b.carInsuranceDetails.deductibleFull," €"]})]}),b.carInsuranceDetails.policyNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsschein-Nr."}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[b.carInsuranceDetails.policyNumber,s.jsx(me,{value:b.carInsuranceDetails.policyNumber})]})]}),b.carInsuranceDetails.previousInsurer&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversicherer"}),s.jsx("dd",{children:b.carInsuranceDetails.previousInsurer})]})]})}),s.jsx(yk,{contractId:c,canEdit:i("contracts:update"),isCustomerPortal:o}),!o&&i("contracts:read")&&b.customerId&&s.jsx(C2,{contractId:c,customerId:b.customerId}),b.notes&&s.jsx(Y,{title:"Notizen",children:s.jsx("p",{className:"whitespace-pre-wrap",children:b.notes})})]})}const bk=[{value:"DRAFT",label:"Entwurf"},{value:"PENDING",label:"Ausstehend"},{value:"ACTIVE",label:"Aktiv"},{value:"CANCELLED",label:"Gekündigt"},{value:"EXPIRED",label:"Abgelaufen"},{value:"DEACTIVATED",label:"Deaktiviert"}];function ax(){var Vr,Qr,yl,Ga,vl,Za,Wm,Gm,Zm;const{id:e}=ac(),[t]=lc(),n=Wt(),r=xe(),a=!!e,i=t.get("customerId"),{register:l,handleSubmit:o,reset:c,watch:u,setValue:d,formState:{errors:h}}=nv({defaultValues:{customerId:i||"",type:"ELECTRICITY",status:"DRAFT",previousContractId:""}}),p=u("type"),m=u("customerId"),{data:f}=de({queryKey:["contract",e],queryFn:()=>Ke.getById(parseInt(e)),enabled:a}),{data:g}=de({queryKey:["customers-all"],queryFn:()=>kt.getAll({limit:1e3})}),{data:N}=de({queryKey:["customer",m],queryFn:()=>kt.getById(parseInt(m)),enabled:!!m}),{data:x}=de({queryKey:["customer-contracts-for-predecessor",m],queryFn:()=>Ke.getAll({customerId:parseInt(m),limit:1e3}),enabled:!!m}),{data:y}=de({queryKey:["platforms"],queryFn:()=>Qi.getAll()}),{data:v}=de({queryKey:["cancellation-periods"],queryFn:()=>Hi.getAll()}),{data:w}=de({queryKey:["contract-durations"],queryFn:()=>Wi.getAll()}),{data:k}=de({queryKey:["providers"],queryFn:()=>za.getAll()}),{data:C}=de({queryKey:["contract-categories"],queryFn:()=>Gi.getAll()}),A=u("providerId"),[S,E]=j.useState(null),[D,$]=j.useState([]),[L,U]=j.useState([]),[V,O]=j.useState(!1),[P,b]=j.useState("manual"),[z,J]=j.useState(""),[ee,pe]=j.useState(!1),[le,nt]=j.useState(!1),[Q,ke]=j.useState({}),[Pe,Ge]=j.useState({}),[ht,Tt]=j.useState({});j.useEffect(()=>{a||O(!0)},[a]),j.useEffect(()=>{!a&&i&&(g!=null&&g.data)&&g.data.some(re=>re.id.toString()===i)&&d("customerId",i)},[a,i,g,d]),j.useEffect(()=>{V&&S!==null&&A!==S&&d("tariffId",""),E(A)},[A,S,d,V]),j.useEffect(()=>{if(!a&&(C!=null&&C.data)&&C.data.length>0){const I=u("type"),re=C.data.filter(ce=>ce.isActive),je=re.some(ce=>ce.code===I);if(!I||!je){const ce=re.sort((ye,at)=>ye.sortOrder-at.sortOrder)[0];ce&&d("type",ce.code)}}},[C,a,d,u]),j.useEffect(()=>{var I,re,je,ce,ye,at,Ce,Ja,Jm,Xm,Ym,eh,th,sh,nh,rh,ah,ih,lh,oh,ch,uh,dh,mh,hh,fh,ph,xh,gh,yh,vh,jh,bh,Nh,wh,Sh,kh,Ch,Eh,Dh,Ph,Ah,Mh,Fh,Th,Ih,Lh,Rh,Oh,zh;if(f!=null&&f.data&&(y!=null&&y.data)&&(C!=null&&C.data)){const se=f.data;c({customerId:se.customerId.toString(),type:se.type,status:se.status,addressId:((I=se.addressId)==null?void 0:I.toString())||"",bankCardId:((re=se.bankCardId)==null?void 0:re.toString())||"",identityDocumentId:((je=se.identityDocumentId)==null?void 0:je.toString())||"",salesPlatformId:((ce=se.salesPlatformId)==null?void 0:ce.toString())||"",providerId:((ye=se.providerId)==null?void 0:ye.toString())||"",tariffId:((at=se.tariffId)==null?void 0:at.toString())||"",providerName:se.providerName||"",tariffName:se.tariffName||"",customerNumberAtProvider:se.customerNumberAtProvider||"",priceFirst12Months:se.priceFirst12Months||"",priceFrom13Months:se.priceFrom13Months||"",priceAfter24Months:se.priceAfter24Months||"",startDate:se.startDate?se.startDate.split("T")[0]:"",endDate:se.endDate?se.endDate.split("T")[0]:"",cancellationPeriodId:((Ce=se.cancellationPeriodId)==null?void 0:Ce.toString())||"",contractDurationId:((Ja=se.contractDurationId)==null?void 0:Ja.toString())||"",commission:se.commission||"",portalUsername:se.portalUsername||"",notes:se.notes||"",meterId:((Xm=(Jm=se.energyDetails)==null?void 0:Jm.meterId)==null?void 0:Xm.toString())||"",annualConsumption:((Ym=se.energyDetails)==null?void 0:Ym.annualConsumption)||"",basePrice:((eh=se.energyDetails)==null?void 0:eh.basePrice)||"",unitPrice:((th=se.energyDetails)==null?void 0:th.unitPrice)||"",bonus:((sh=se.energyDetails)==null?void 0:sh.bonus)||"",previousProviderName:((nh=se.energyDetails)==null?void 0:nh.previousProviderName)||"",previousCustomerNumber:((rh=se.energyDetails)==null?void 0:rh.previousCustomerNumber)||"",downloadSpeed:((ah=se.internetDetails)==null?void 0:ah.downloadSpeed)||"",uploadSpeed:((ih=se.internetDetails)==null?void 0:ih.uploadSpeed)||"",routerModel:((lh=se.internetDetails)==null?void 0:lh.routerModel)||"",routerSerialNumber:((oh=se.internetDetails)==null?void 0:oh.routerSerialNumber)||"",installationDate:(ch=se.internetDetails)!=null&&ch.installationDate?se.internetDetails.installationDate.split("T")[0]:"",internetUsername:((uh=se.internetDetails)==null?void 0:uh.internetUsername)||"",homeId:((dh=se.internetDetails)==null?void 0:dh.homeId)||"",activationCode:((mh=se.internetDetails)==null?void 0:mh.activationCode)||"",requiresMultisim:((hh=se.mobileDetails)==null?void 0:hh.requiresMultisim)||!1,dataVolume:((fh=se.mobileDetails)==null?void 0:fh.dataVolume)||"",includedMinutes:((ph=se.mobileDetails)==null?void 0:ph.includedMinutes)||"",includedSMS:((xh=se.mobileDetails)==null?void 0:xh.includedSMS)||"",deviceModel:((gh=se.mobileDetails)==null?void 0:gh.deviceModel)||"",deviceImei:((yh=se.mobileDetails)==null?void 0:yh.deviceImei)||"",phoneNumber:((vh=se.mobileDetails)==null?void 0:vh.phoneNumber)||"",simCardNumber:((jh=se.mobileDetails)==null?void 0:jh.simCardNumber)||"",receiverModel:((bh=se.tvDetails)==null?void 0:bh.receiverModel)||"",smartcardNumber:((Nh=se.tvDetails)==null?void 0:Nh.smartcardNumber)||"",tvPackage:((wh=se.tvDetails)==null?void 0:wh.package)||"",licensePlate:((Sh=se.carInsuranceDetails)==null?void 0:Sh.licensePlate)||"",hsn:((kh=se.carInsuranceDetails)==null?void 0:kh.hsn)||"",tsn:((Ch=se.carInsuranceDetails)==null?void 0:Ch.tsn)||"",vin:((Eh=se.carInsuranceDetails)==null?void 0:Eh.vin)||"",vehicleType:((Dh=se.carInsuranceDetails)==null?void 0:Dh.vehicleType)||"",firstRegistration:(Ph=se.carInsuranceDetails)!=null&&Ph.firstRegistration?se.carInsuranceDetails.firstRegistration.split("T")[0]:"",noClaimsClass:((Ah=se.carInsuranceDetails)==null?void 0:Ah.noClaimsClass)||"",insuranceType:((Mh=se.carInsuranceDetails)==null?void 0:Mh.insuranceType)||"LIABILITY",deductiblePartial:((Fh=se.carInsuranceDetails)==null?void 0:Fh.deductiblePartial)||"",deductibleFull:((Th=se.carInsuranceDetails)==null?void 0:Th.deductibleFull)||"",policyNumber:((Ih=se.carInsuranceDetails)==null?void 0:Ih.policyNumber)||"",previousInsurer:((Lh=se.carInsuranceDetails)==null?void 0:Lh.previousInsurer)||"",cancellationConfirmationDate:se.cancellationConfirmationDate?se.cancellationConfirmationDate.split("T")[0]:"",cancellationConfirmationOptionsDate:se.cancellationConfirmationOptionsDate?se.cancellationConfirmationOptionsDate.split("T")[0]:"",wasSpecialCancellation:se.wasSpecialCancellation||!1,previousContractId:((Rh=se.previousContractId)==null?void 0:Rh.toString())||""}),(Oh=se.mobileDetails)!=null&&Oh.simCards&&se.mobileDetails.simCards.length>0?$(se.mobileDetails.simCards.map(Gt=>({id:Gt.id,phoneNumber:Gt.phoneNumber||"",simCardNumber:Gt.simCardNumber||"",pin:"",puk:"",hasExistingPin:!!Gt.pin,hasExistingPuk:!!Gt.puk,isMultisim:Gt.isMultisim,isMain:Gt.isMain}))):$([]),(zh=se.internetDetails)!=null&&zh.phoneNumbers&&se.internetDetails.phoneNumbers.length>0?U(se.internetDetails.phoneNumbers.map(Gt=>({id:Gt.id,phoneNumber:Gt.phoneNumber||"",sipUsername:Gt.sipUsername||"",sipPassword:"",hasExistingSipPassword:!!Gt.sipPasswordEncrypted,sipServer:Gt.sipServer||"",isMain:Gt.isMain}))):U([]),se.stressfreiEmailId?(b("stressfrei"),J(se.stressfreiEmailId.toString())):(b("manual"),J("")),O(!0)}},[f,c,y,C]);const W=u("startDate"),_e=u("contractDurationId");j.useEffect(()=>{if(W&&_e&&(w!=null&&w.data)){const I=w.data.find(re=>re.id===parseInt(_e));if(I){const re=new Date(W),ce=I.code.match(/^(\d+)([MTJ])$/);if(ce){const ye=parseInt(ce[1]),at=ce[2];let Ce=new Date(re);at==="T"?Ce.setDate(Ce.getDate()+ye):at==="M"?Ce.setMonth(Ce.getMonth()+ye):at==="J"&&Ce.setFullYear(Ce.getFullYear()+ye),d("endDate",Ce.toISOString().split("T")[0])}}}},[W,_e,w,d]);const Et=H({mutationFn:Ke.create,onSuccess:(I,re)=>{r.invalidateQueries({queryKey:["contracts"]}),re.customerId&&r.invalidateQueries({queryKey:["customer",re.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),n(i?`/customers/${i}?tab=contracts`:"/contracts")}}),$s=H({mutationFn:I=>Ke.update(parseInt(e),I),onSuccess:(I,re)=>{r.invalidateQueries({queryKey:["contracts"]}),r.invalidateQueries({queryKey:["contract",e]}),re.customerId&&r.invalidateQueries({queryKey:["customer",re.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),n(`/contracts/${e}`)}}),ws=I=>{const re=Ce=>{if(Ce==null||Ce==="")return;const Ja=parseInt(String(Ce));return isNaN(Ja)?void 0:Ja},je=he.find(Ce=>Ce.code===I.type),ce=re(I.customerId);if(!ce){alert("Bitte wählen Sie einen Kunden aus");return}if(!I.type||!je){alert("Bitte wählen Sie einen Vertragstyp aus");return}const ye=Ce=>Ce==null||Ce===""?null:Ce,at={customerId:ce,type:I.type,contractCategoryId:je.id,status:I.status,addressId:re(I.addressId)??null,bankCardId:re(I.bankCardId)??null,identityDocumentId:re(I.identityDocumentId)??null,salesPlatformId:re(I.salesPlatformId)??null,providerId:re(I.providerId)??null,tariffId:re(I.tariffId)??null,providerName:ye(I.providerName),tariffName:ye(I.tariffName),customerNumberAtProvider:ye(I.customerNumberAtProvider),priceFirst12Months:ye(I.priceFirst12Months),priceFrom13Months:ye(I.priceFrom13Months),priceAfter24Months:ye(I.priceAfter24Months),startDate:I.startDate?new Date(I.startDate):null,endDate:I.endDate?new Date(I.endDate):null,cancellationPeriodId:re(I.cancellationPeriodId)??null,contractDurationId:re(I.contractDurationId)??null,commission:I.commission?parseFloat(I.commission):null,portalUsername:P==="manual"?ye(I.portalUsername):null,stressfreiEmailId:P==="stressfrei"&&z?parseInt(z):null,portalPassword:I.portalPassword||void 0,notes:ye(I.notes),cancellationConfirmationDate:I.cancellationConfirmationDate?new Date(I.cancellationConfirmationDate):null,cancellationConfirmationOptionsDate:I.cancellationConfirmationOptionsDate?new Date(I.cancellationConfirmationOptionsDate):null,wasSpecialCancellation:I.wasSpecialCancellation||!1,previousContractId:re(I.previousContractId)??null};["ELECTRICITY","GAS"].includes(I.type)&&(at.energyDetails={meterId:re(I.meterId)??null,annualConsumption:I.annualConsumption?parseFloat(I.annualConsumption):null,basePrice:I.basePrice?parseFloat(I.basePrice):null,unitPrice:I.unitPrice?parseFloat(I.unitPrice):null,bonus:I.bonus?parseFloat(I.bonus):null,previousProviderName:ye(I.previousProviderName),previousCustomerNumber:ye(I.previousCustomerNumber)}),["DSL","CABLE","FIBER"].includes(I.type)&&(at.internetDetails={downloadSpeed:re(I.downloadSpeed)??null,uploadSpeed:re(I.uploadSpeed)??null,routerModel:ye(I.routerModel),routerSerialNumber:ye(I.routerSerialNumber),installationDate:I.installationDate?new Date(I.installationDate):null,internetUsername:ye(I.internetUsername),internetPassword:I.internetPassword||void 0,homeId:ye(I.homeId),activationCode:ye(I.activationCode),phoneNumbers:L.length>0?L.map(Ce=>({id:Ce.id,phoneNumber:Ce.phoneNumber||"",isMain:Ce.isMain??!1,sipUsername:ye(Ce.sipUsername),sipPassword:Ce.sipPassword||void 0,sipServer:ye(Ce.sipServer)})):void 0}),I.type==="MOBILE"&&(at.mobileDetails={requiresMultisim:I.requiresMultisim||!1,dataVolume:I.dataVolume?parseFloat(I.dataVolume):null,includedMinutes:re(I.includedMinutes)??null,includedSMS:re(I.includedSMS)??null,deviceModel:ye(I.deviceModel),deviceImei:ye(I.deviceImei),phoneNumber:ye(I.phoneNumber),simCardNumber:ye(I.simCardNumber),simCards:D.length>0?D.map(Ce=>({id:Ce.id,phoneNumber:ye(Ce.phoneNumber),simCardNumber:ye(Ce.simCardNumber),pin:Ce.pin||void 0,puk:Ce.puk||void 0,isMultisim:Ce.isMultisim,isMain:Ce.isMain})):void 0}),I.type==="TV"&&(at.tvDetails={receiverModel:ye(I.receiverModel),smartcardNumber:ye(I.smartcardNumber),package:ye(I.tvPackage)}),I.type==="CAR_INSURANCE"&&(at.carInsuranceDetails={licensePlate:ye(I.licensePlate),hsn:ye(I.hsn),tsn:ye(I.tsn),vin:ye(I.vin),vehicleType:ye(I.vehicleType),firstRegistration:I.firstRegistration?new Date(I.firstRegistration):null,noClaimsClass:ye(I.noClaimsClass),insuranceType:I.insuranceType,deductiblePartial:I.deductiblePartial?parseFloat(I.deductiblePartial):null,deductibleFull:I.deductibleFull?parseFloat(I.deductibleFull):null,policyNumber:ye(I.policyNumber),previousInsurer:ye(I.previousInsurer)}),a?$s.mutate(at):Et.mutate(at)},ur=Et.isPending||$s.isPending,X=Et.error||$s.error,ge=N==null?void 0:N.data,Wa=(ge==null?void 0:ge.addresses)||[],jc=((Vr=ge==null?void 0:ge.bankCards)==null?void 0:Vr.filter(I=>I.isActive))||[],gl=((Qr=ge==null?void 0:ge.identityDocuments)==null?void 0:Qr.filter(I=>I.isActive))||[],F=((yl=ge==null?void 0:ge.meters)==null?void 0:yl.filter(I=>I.isActive))||[],_=((Ga=ge==null?void 0:ge.stressfreiEmails)==null?void 0:Ga.filter(I=>I.isActive))||[],B=(y==null?void 0:y.data)||[],ie=(v==null?void 0:v.data)||[],te=(w==null?void 0:w.data)||[],Z=((vl=k==null?void 0:k.data)==null?void 0:vl.filter(I=>I.isActive))||[],he=((Za=C==null?void 0:C.data)==null?void 0:Za.filter(I=>I.isActive).sort((I,re)=>I.sortOrder-re.sortOrder))||[],Fe=he.map(I=>({value:I.code,label:I.name})),Te=((x==null?void 0:x.data)||[]).filter(I=>!a||I.id!==parseInt(e)).sort((I,re)=>new Date(re.startDate||0).getTime()-new Date(I.startDate||0).getTime()),rt=Z.find(I=>I.id===parseInt(A||"0")),sn=((Wm=rt==null?void 0:rt.tariffs)==null?void 0:Wm.filter(I=>I.isActive))||[],Ss=I=>{const re=I.companyName||`${I.firstName} ${I.lastName}`,je=I.birthDate?` (geb. ${new Date(I.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})`:"";return`${I.customerNumber} - ${re}${je}`},bc=(()=>{var je;const re=((g==null?void 0:g.data)||[]).map(ce=>({value:ce.id.toString(),label:Ss(ce)}));if(a&&((je=f==null?void 0:f.data)!=null&&je.customer)){const ce=f.data.customer;re.some(at=>at.value===ce.id.toString())||re.unshift({value:ce.id.toString(),label:Ss(ce)})}return re})();return s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:a?"Vertrag bearbeiten":"Neuer Vertrag"}),X&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:X instanceof Error?X.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:o(ws),children:[s.jsx(Y,{className:"mb-6",title:"Vertragsdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Oe,{label:"Kunde *",...l("customerId",{required:"Kunde erforderlich"}),options:bc,error:(Gm=h.customerId)==null?void 0:Gm.message}),s.jsx(Oe,{label:"Vertragstyp *",...l("type",{required:"Typ erforderlich"}),options:Fe}),s.jsx(Oe,{label:"Status",...l("status"),options:bk}),s.jsx(Oe,{label:"Vertriebsplattform",...l("salesPlatformId"),options:B.map(I=>({value:I.id,label:I.name}))}),m&&s.jsx(Oe,{label:"Vorgänger-Vertrag",...l("previousContractId"),options:Te.map(I=>({value:I.id,label:`${I.contractNumber} (${I.type}${I.startDate?` - ${new Date(I.startDate).toLocaleDateString("de-DE")}`:""})`})),placeholder:"Keinen Vorgänger auswählen"})]})}),m&&s.jsx(Y,{className:"mb-6",title:"Kundendaten verknüpfen",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Oe,{label:"Adresse",...l("addressId"),options:Wa.map(I=>({value:I.id,label:`${I.street} ${I.houseNumber}, ${I.postalCode} ${I.city} (${I.type==="BILLING"?"Rechnung":"Liefer"})`}))}),s.jsx(Oe,{label:"Bankkarte",...l("bankCardId"),options:jc.map(I=>({value:I.id,label:`${I.iban} (${I.accountHolder})`}))}),s.jsx(Oe,{label:"Ausweis",...l("identityDocumentId"),options:gl.map(I=>({value:I.id,label:`${I.documentNumber} (${I.type})`}))})]})}),s.jsx(Y,{className:"mb-6",title:"Anbieter & Tarif",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Oe,{label:"Anbieter",...l("providerId"),options:Z.map(I=>({value:I.id,label:I.name}))}),s.jsx(Oe,{label:"Tarif",...l("tariffId"),options:sn.map(I=>({value:I.id,label:I.name})),disabled:!A}),s.jsx(q,{label:"Kundennummer beim Anbieter",...l("customerNumberAtProvider")}),s.jsx(q,{label:"Provision (€)",type:"number",step:"0.01",...l("commission")}),s.jsx(q,{label:"Preis erste 12 Monate",...l("priceFirst12Months"),placeholder:"z.B. 29,99 €/Monat"}),s.jsx(q,{label:"Preis ab 13. Monat",...l("priceFrom13Months"),placeholder:"z.B. 39,99 €/Monat"}),s.jsx(q,{label:"Preis nach 24 Monaten",...l("priceAfter24Months"),placeholder:"z.B. 49,99 €/Monat"})]})}),s.jsxs(Y,{className:"mb-6",title:"Laufzeit und Kündigung",children:[s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.jsx("strong",{children:"Hinweis:"})," Ist die Laufzeit ≤ 4 Wochen, 1 Monat oder 30 Tage, gilt der Vertrag als unbefristet mit der jeweiligen Kündigungsfrist."]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Vertragsbeginn",type:"date",...l("startDate"),value:u("startDate")||"",onClear:()=>d("startDate","")}),s.jsx(q,{label:"Vertragsende (berechnet)",type:"date",...l("endDate"),disabled:!0,className:"bg-gray-50"}),s.jsx(Oe,{label:"Vertragslaufzeit",...l("contractDurationId"),options:te.map(I=>({value:I.id,label:I.description}))}),s.jsx(Oe,{label:"Kündigungsfrist",...l("cancellationPeriodId"),options:ie.map(I=>({value:I.id,label:I.description}))}),s.jsx(q,{label:"Kündigungsbestätigungsdatum",type:"date",...l("cancellationConfirmationDate"),value:u("cancellationConfirmationDate")||"",onClear:()=>d("cancellationConfirmationDate","")}),s.jsx(q,{label:"Kündigungsbestätigungsoptionendatum",type:"date",...l("cancellationConfirmationOptionsDate"),value:u("cancellationConfirmationOptionsDate")||"",onClear:()=>d("cancellationConfirmationOptionsDate","")}),s.jsx("div",{className:"col-span-2",children:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",...l("wasSpecialCancellation"),className:"rounded border-gray-300"}),s.jsx("span",{children:"Wurde sondergekündigt?"})]})})]})]}),s.jsx(Y,{className:"mb-6",title:"Zugangsdaten (verschlüsselt gespeichert)",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Portal Benutzername"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"usernameType",checked:P==="manual",onChange:()=>{b("manual"),J("")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Manuell eingeben"})]}),P==="manual"&&s.jsx(q,{...l("portalUsername"),placeholder:"Benutzername eingeben..."}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"usernameType",checked:P==="stressfrei",onChange:()=>{b("stressfrei"),d("portalUsername","")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Stressfrei-Wechseln Adresse"})]}),P==="stressfrei"&&s.jsx(Oe,{value:z,onChange:I=>J(I.target.value),options:_.map(I=>({value:I.id,label:I.email+(I.notes?` (${I.notes})`:"")})),placeholder:_.length===0?"Keine Stressfrei-Adressen vorhanden":"Adresse auswählen..."}),P==="stressfrei"&&_.length===0&&s.jsx("p",{className:"text-xs text-amber-600",children:"Keine Stressfrei-Wechseln Adressen für diesen Kunden vorhanden. Bitte zuerst beim Kunden anlegen."})]})]}),s.jsxs("div",{className:"mt-8",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer lassen = unverändert)":"Portal Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:ee?"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"}),s.jsx("button",{type:"button",onClick:()=>pe(!ee),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:ee?s.jsx(At,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})}),["ELECTRICITY","GAS"].includes(p)&&s.jsx(Y,{className:"mb-6",title:p==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Oe,{label:"Zähler",...l("meterId"),options:F.filter(I=>I.type===p).map(I=>({value:I.id,label:`${I.meterNumber}${I.location?` (${I.location})`:""}`}))}),s.jsx(q,{label:`Jahresverbrauch (${p==="ELECTRICITY"?"kWh":"m³"})`,type:"number",...l("annualConsumption")}),s.jsx(q,{label:"Grundpreis (€/Monat)",type:"number",step:"0.01",...l("basePrice")}),s.jsx(q,{label:`Arbeitspreis (ct/${p==="ELECTRICITY"?"kWh":"m³"})`,type:"number",step:"0.01",...l("unitPrice")}),s.jsx(q,{label:"Bonus (€)",type:"number",step:"0.01",...l("bonus")}),s.jsx(q,{label:"Vorversorger",...l("previousProviderName")}),s.jsx(q,{label:"Kundennr. beim Vorversorger",...l("previousCustomerNumber")})]})}),["DSL","CABLE","FIBER"].includes(p)&&s.jsxs(s.Fragment,{children:[s.jsx(Y,{className:"mb-6",title:p==="DSL"?"DSL-Details":p==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Download (Mbit/s)",type:"number",...l("downloadSpeed")}),s.jsx(q,{label:"Upload (Mbit/s)",type:"number",...l("uploadSpeed")}),s.jsx(q,{label:"Router Modell",...l("routerModel")}),s.jsx(q,{label:"Router Seriennummer",...l("routerSerialNumber")}),s.jsx(q,{label:"Installationsdatum",type:"date",...l("installationDate"),value:u("installationDate")||"",onClear:()=>d("installationDate","")}),p==="FIBER"&&s.jsx(q,{label:"Home-ID",...l("homeId")}),((Zm=rt==null?void 0:rt.name)==null?void 0:Zm.toLowerCase().includes("vodafone"))&&["DSL","CABLE"].includes(p)&&s.jsx(q,{label:"Aktivierungscode",...l("activationCode")})]})}),s.jsx(Y,{className:"mb-6",title:"Internet-Zugangsdaten (verschlüsselt)",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Benutzername",...l("internetUsername")}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer = beibehalten)":"Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:le?"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"}),s.jsx("button",{type:"button",onClick:()=>nt(!le),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:le?s.jsx(At,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})}),s.jsxs(Y,{className:"mb-6",title:"Rufnummern & SIP-Zugangsdaten",children:[s.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie Festnetz-Rufnummern mit SIP-Zugangsdaten erfassen."}),L.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:L.map((I,re)=>s.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("span",{className:"font-medium",children:["Rufnummer ",re+1]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:I.isMain,onChange:je=>{const ce=[...L];je.target.checked?ce.forEach((ye,at)=>ye.isMain=at===re):ce[re].isMain=!1,U(ce)},className:"rounded border-gray-300"}),"Hauptnummer"]})]}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{U(L.filter((je,ce)=>ce!==re))},children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[s.jsx(q,{label:"Rufnummer",value:I.phoneNumber,onChange:je=>{const ce=[...L];ce[re].phoneNumber=je.target.value,U(ce)},placeholder:"z.B. 030 123456"}),s.jsx(q,{label:"SIP-Benutzername",value:I.sipUsername,onChange:je=>{const ce=[...L];ce[re].sipUsername=je.target.value,U(ce)}}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:I.hasExistingSipPassword?"SIP-Passwort (bereits hinterlegt)":"SIP-Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Q[re]?"text":"password",value:I.sipPassword,onChange:je=>{const ce=[...L];ce[re].sipPassword=je.target.value,U(ce)},placeholder:I.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"}),s.jsx("button",{type:"button",onClick:()=>ke(je=>({...je,[re]:!je[re]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Q[re]?s.jsx(At,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]}),s.jsx(q,{label:"SIP-Server",value:I.sipServer,onChange:je=>{const ce=[...L];ce[re].sipServer=je.target.value,U(ce)},placeholder:"z.B. sip.provider.de"})]})]},re))}),s.jsxs(T,{type:"button",variant:"secondary",onClick:()=>{U([...L,{phoneNumber:"",sipUsername:"",sipPassword:"",sipServer:"",isMain:L.length===0}])},children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Rufnummer hinzufügen"]})]})]}),p==="MOBILE"&&s.jsxs(s.Fragment,{children:[s.jsxs(Y,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Datenvolumen (GB)",type:"number",...l("dataVolume")}),s.jsx(q,{label:"Inklusiv-Minuten",type:"number",...l("includedMinutes")}),s.jsx(q,{label:"Inklusiv-SMS",type:"number",...l("includedSMS")}),s.jsx(q,{label:"Gerät (Modell)",...l("deviceModel")}),s.jsx(q,{label:"Gerät (IMEI)",...l("deviceImei")})]}),s.jsx("div",{className:"mt-4 pt-4 border-t",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",...l("requiresMultisim"),className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium",children:"Multisim erforderlich"}),s.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."})]})]})})]}),s.jsxs(Y,{className:"mb-6",title:"SIM-Karten",children:[s.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)."}),D.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:D.map((I,re)=>s.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("span",{className:"font-medium",children:["SIM-Karte ",re+1]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:I.isMain,onChange:je=>{const ce=[...D];je.target.checked?ce.forEach((ye,at)=>ye.isMain=at===re):ce[re].isMain=!1,$(ce)},className:"rounded border-gray-300"}),"Hauptkarte"]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:I.isMultisim,onChange:je=>{const ce=[...D];ce[re].isMultisim=je.target.checked,$(ce)},className:"rounded border-gray-300"}),"Multisim"]})]}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{$(D.filter((je,ce)=>ce!==re))},children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[s.jsx(q,{label:"Rufnummer",value:I.phoneNumber,onChange:je=>{const ce=[...D];ce[re].phoneNumber=je.target.value,$(ce)},placeholder:"z.B. 0171 1234567"}),s.jsx(q,{label:"SIM-Kartennummer",value:I.simCardNumber,onChange:je=>{const ce=[...D];ce[re].simCardNumber=je.target.value,$(ce)},placeholder:"ICCID"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:I.hasExistingPin?"PIN (bereits hinterlegt)":"PIN"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Pe[re]?"text":"password",value:I.pin,onChange:je=>{const ce=[...D];ce[re].pin=je.target.value,$(ce)},placeholder:I.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"}),s.jsx("button",{type:"button",onClick:()=>Ge(je=>({...je,[re]:!je[re]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Pe[re]?s.jsx(At,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:I.hasExistingPuk?"PUK (bereits hinterlegt)":"PUK"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:ht[re]?"text":"password",value:I.puk,onChange:je=>{const ce=[...D];ce[re].puk=je.target.value,$(ce)},placeholder:I.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"}),s.jsx("button",{type:"button",onClick:()=>Tt(je=>({...je,[re]:!je[re]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:ht[re]?s.jsx(At,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})]},re))}),s.jsxs(T,{type:"button",variant:"secondary",onClick:()=>{$([...D,{phoneNumber:"",simCardNumber:"",pin:"",puk:"",isMultisim:!1,isMain:D.length===0}])},children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"SIM-Karte hinzufügen"]})]})]}),p==="TV"&&s.jsx(Y,{className:"mb-6",title:"TV-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Receiver Modell",...l("receiverModel")}),s.jsx(q,{label:"Smartcard-Nummer",...l("smartcardNumber")}),s.jsx(q,{label:"Paket",...l("tvPackage"),placeholder:"z.B. Basis, Premium, Sport"})]})}),p==="CAR_INSURANCE"&&s.jsx(Y,{className:"mb-6",title:"KFZ-Versicherung Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(q,{label:"Kennzeichen",...l("licensePlate")}),s.jsx(q,{label:"HSN",...l("hsn")}),s.jsx(q,{label:"TSN",...l("tsn")}),s.jsx(q,{label:"FIN (VIN)",...l("vin")}),s.jsx(q,{label:"Fahrzeugtyp",...l("vehicleType")}),s.jsx(q,{label:"Erstzulassung",type:"date",...l("firstRegistration"),value:u("firstRegistration")||"",onClear:()=>d("firstRegistration","")}),s.jsx(q,{label:"SF-Klasse",...l("noClaimsClass")}),s.jsx(Oe,{label:"Versicherungsart",...l("insuranceType"),options:[{value:"LIABILITY",label:"Haftpflicht"},{value:"PARTIAL",label:"Teilkasko"},{value:"FULL",label:"Vollkasko"}]}),s.jsx(q,{label:"SB Teilkasko (€)",type:"number",...l("deductiblePartial")}),s.jsx(q,{label:"SB Vollkasko (€)",type:"number",...l("deductibleFull")}),s.jsx(q,{label:"Versicherungsscheinnummer",...l("policyNumber")}),s.jsx(q,{label:"Vorversicherer",...l("previousInsurer")})]})}),s.jsx(Y,{className:"mb-6",title:"Notizen",children:s.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..."})}),s.jsxs("div",{className:"flex justify-end gap-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:()=>n(-1),children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:ur,children:ur?"Speichern...":"Speichern"})]})]})]})}const Nk={ELECTRICITY:Um,GAS:$0,DSL:xa,CABLE:xa,FIBER:xa,MOBILE:_m,TV:q0,CAR_INSURANCE:R0},wk={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabel",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ"},Sk={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"},kk={critical:"danger",warning:"warning",ok:"success",none:"default"},Ck={cancellation_deadline:L0,contract_ending:Sn,missing_cancellation_letter:Xe,missing_cancellation_confirmation:Xe,missing_portal_credentials:e2,missing_customer_number:Xe,missing_provider:Xe,missing_address:Xe,missing_bank:Xe,missing_meter:Um,missing_sim:_m,open_tasks:Ji,pending_status:Sn,draft_status:Xe},Ek={cancellationDeadlines:"Kündigungsfristen",contractEnding:"Vertragsenden",missingCredentials:"Fehlende Zugangsdaten",missingData:"Fehlende Daten",openTasks:"Offene Aufgaben",pendingContracts:"Wartende Verträge"};function Dk(){var g;const[e,t]=lc(),[n,r]=j.useState(new Set),a=e.get("filter"),[i,l]=j.useState(a||"all");j.useEffect(()=>{i==="all"?e.delete("filter"):e.set("filter",i),t(e,{replace:!0})},[i,e,t]);const{data:o,isLoading:c,error:u}=de({queryKey:["contract-cockpit"],queryFn:()=>Ke.getCockpit(),staleTime:0}),d=N=>{r(x=>{const y=new Set(x);return y.has(N)?y.delete(N):y.add(N),y})},h=j.useMemo(()=>{var x;if(!((x=o==null?void 0:o.data)!=null&&x.contracts))return[];const N=o.data.contracts;switch(i){case"critical":return N.filter(y=>y.highestUrgency==="critical");case"warning":return N.filter(y=>y.highestUrgency==="warning");case"ok":return N.filter(y=>y.highestUrgency==="ok");case"deadlines":return N.filter(y=>y.issues.some(v=>["cancellation_deadline","contract_ending"].includes(v.type)));case"credentials":return N.filter(y=>y.issues.some(v=>v.type.includes("credentials")));case"data":return N.filter(y=>y.issues.some(v=>v.type.startsWith("missing_")&&!v.type.includes("credentials")));case"tasks":return N.filter(y=>y.issues.some(v=>["open_tasks","pending_status","draft_status"].includes(v.type)));default:return N}},[(g=o==null?void 0:o.data)==null?void 0:g.contracts,i]);if(c)return s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})});if(u||!(o!=null&&o.data))return s.jsx("div",{className:"text-center py-12",children:s.jsx("p",{className:"text-red-500",children:"Fehler beim Laden des Cockpits"})});const{summary:p,thresholds:m}=o.data,f=N=>{var v,w,k,C;const x=n.has(N.id),y=Nk[N.type]||Xe;return s.jsxs("div",{className:`border rounded-lg mb-2 ${Sk[N.highestUrgency]}`,children:[s.jsxs("div",{className:"flex items-center p-4 cursor-pointer hover:bg-opacity-50",onClick:()=>d(N.id),children:[s.jsx("div",{className:"w-6 mr-2",children:x?s.jsx(Ha,{className:"w-5 h-5"}):s.jsx(qt,{className:"w-5 h-5"})}),s.jsx(y,{className:"w-5 h-5 mr-3"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Se,{to:`/contracts/${N.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"font-medium hover:underline",onClick:A=>A.stopPropagation(),children:N.contractNumber}),s.jsxs(ve,{variant:kk[N.highestUrgency],children:[N.issues.length," ",N.highestUrgency==="ok"?N.issues.length===1?"Hinweis":"Hinweise":N.issues.length===1?"Problem":"Probleme"]}),s.jsx("span",{className:"text-sm",children:wk[N.type]})]}),s.jsxs("div",{className:"text-sm mt-1",children:[s.jsxs(Se,{to:`/customers/${N.customer.id}`,className:"hover:underline",onClick:A=>A.stopPropagation(),children:[N.customer.customerNumber," - ",N.customer.name]}),(((v=N.provider)==null?void 0:v.name)||N.providerName)&&s.jsxs("span",{className:"ml-2",children:["| ",((w=N.provider)==null?void 0:w.name)||N.providerName,(((k=N.tariff)==null?void 0:k.name)||N.tariffName)&&` - ${((C=N.tariff)==null?void 0:C.name)||N.tariffName}`]})]})]}),s.jsx(Se,{to:`/contracts/${N.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"ml-4 p-2 hover:bg-white hover:bg-opacity-50 rounded",onClick:A=>A.stopPropagation(),title:"Zum Vertrag",children:s.jsx(Ae,{className:"w-4 h-4"})})]}),x&&s.jsx("div",{className:"border-t px-4 py-3 bg-white bg-opacity-50",children:s.jsx("div",{className:"space-y-2",children:N.issues.map((A,S)=>{const E=Ck[A.type]||xn,D=A.urgency==="critical"?xn:A.urgency==="warning"?Ys:A.urgency==="ok"?vs:Sn;return s.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[s.jsx(D,{className:`w-4 h-4 mt-0.5 flex-shrink-0 ${A.urgency==="critical"?"text-red-500":A.urgency==="warning"?"text-yellow-500":A.urgency==="ok"?"text-green-500":"text-gray-500"}`}),s.jsx(E,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-gray-500"}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium",children:A.label}),A.details&&s.jsx("span",{className:"text-gray-600 ml-2",children:A.details})]})]},S)})})})]},N.id)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(xn,{className:"w-6 h-6 text-red-500"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Vertrags-Cockpit"})]}),s.jsx(Se,{to:"/settings/deadlines",className:"text-sm text-blue-600 hover:underline",children:"Fristenschwellen anpassen"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[s.jsx(Y,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(xn,{className:"w-6 h-6 text-red-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-red-600",children:p.criticalCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",m.criticalDays," Tage)"]})]})]})}),s.jsx(Y,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-yellow-100 rounded-lg",children:s.jsx(Ys,{className:"w-6 h-6 text-yellow-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:p.warningCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",m.warningDays," Tage)"]})]})]})}),s.jsx(Y,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-green-100 rounded-lg",children:s.jsx(vs,{className:"w-6 h-6 text-green-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-green-600",children:p.okCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",m.okDays," Tage)"]})]})]})}),s.jsx(Y,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-gray-100 rounded-lg",children:s.jsx(Xe,{className:"w-6 h-6 text-gray-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-gray-600",children:p.totalContracts}),s.jsx("p",{className:"text-sm text-gray-500",children:"Verträge mit Handlungsbedarf"})]})]})})]}),s.jsx(Y,{className:"mb-6",children:s.jsx("div",{className:"flex flex-wrap gap-4",children:Object.entries(p.byCategory).map(([N,x])=>x>0&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("span",{className:"font-medium",children:[Ek[N]||N,":"]}),s.jsx(ve,{variant:"default",children:x})]},N))})}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Filter:"}),s.jsx(Oe,{value:i,onChange:N=>l(N.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"}),s.jsxs("span",{className:"text-sm text-gray-500",children:[h.length," Verträge angezeigt"]})]})}),h.length===0?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:i==="all"?s.jsxs(s.Fragment,{children:[s.jsx(vs,{className:"w-12 h-12 mx-auto mb-4 text-green-500"}),s.jsx("p",{className:"text-lg font-medium",children:"Alles in Ordnung!"}),s.jsx("p",{children:"Keine Verträge mit Handlungsbedarf gefunden."})]}):s.jsx("p",{children:"Keine Verträge für diesen Filter gefunden."})})}):s.jsx("div",{children:h.map(f)})]})}const ix={OPEN:"Offen",COMPLETED:"Erledigt"},Pk={OPEN:"warning",COMPLETED:"success"};function Ak(){var V;const e=Wt(),t=xe(),{isCustomerPortal:n,user:r,hasPermission:a}=qe(),[i,l]=j.useState("OPEN"),[o,c]=j.useState(new Set),[u,d]=j.useState(!1),[h,p]=j.useState({}),m=n?"Support-Anfragen":"Aufgaben",f=n?"Anfrage":"Aufgabe",{data:g,isLoading:N}=de({queryKey:["app-settings-public"],queryFn:()=>Ur.getPublic(),enabled:n,staleTime:0}),x=!N&&((V=g==null?void 0:g.data)==null?void 0:V.customerSupportTicketsEnabled)==="true",{data:y,isLoading:v}=de({queryKey:["all-tasks",i],queryFn:()=>ct.getAll({status:i||void 0}),staleTime:0}),w=H({mutationFn:O=>ct.completeSubtask(O),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),k=H({mutationFn:O=>ct.reopenSubtask(O),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),C=H({mutationFn:({taskId:O,title:P})=>n?ct.createReply(O,P):ct.createSubtask(O,P),onSuccess:(O,{taskId:P})=>{t.invalidateQueries({queryKey:["all-tasks"]}),p(b=>({...b,[P]:""}))}}),A=j.useMemo(()=>{var z;if(!(y!=null&&y.data))return{ownTasks:[],representedTasks:[],allTasks:[]};const O=y.data;if(!n)return{allTasks:O,ownTasks:[],representedTasks:[]};const P=[],b=[];for(const J of O)((z=J.contract)==null?void 0:z.customerId)===(r==null?void 0:r.customerId)?P.push(J):b.push(J);return{ownTasks:P,representedTasks:b,allTasks:[]}},[y==null?void 0:y.data,n,r==null?void 0:r.customerId]),S=O=>{c(P=>{const b=new Set(P);return b.has(O)?b.delete(O):b.add(O),b})},E=O=>{w.isPending||k.isPending||(O.status==="COMPLETED"?k.mutate(O.id):w.mutate(O.id))},D=O=>{var b;const P=(b=h[O])==null?void 0:b.trim();P&&C.mutate({taskId:O,title:P})},$=!n&&a("contracts:update"),L=(O,P=!1)=>{var Q,ke,Pe,Ge,ht,Tt;const b=o.has(O.id),z=O.subtasks&&O.subtasks.length>0,J=((Q=O.subtasks)==null?void 0:Q.filter(W=>W.status==="COMPLETED").length)||0,ee=((ke=O.subtasks)==null?void 0:ke.length)||0,pe=O.status==="COMPLETED",le=O.contract?`${O.contract.contractNumber} - ${((Pe=O.contract.provider)==null?void 0:Pe.name)||O.contract.providerName||"Kein Anbieter"}`:`Vertrag #${O.contractId}`,nt=(Ge=O.contract)!=null&&Ge.customer?O.contract.customer.companyName||`${O.contract.customer.firstName} ${O.contract.customer.lastName}`:"";return s.jsxs("div",{className:"border rounded-lg mb-2",children:[s.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50 cursor-pointer",onClick:()=>S(O.id),children:[s.jsx("div",{className:"w-6 mr-2",children:b?s.jsx(Ha,{className:"w-5 h-5 text-gray-400"}):s.jsx(qt,{className:"w-5 h-5 text-gray-400"})}),s.jsx("div",{className:"mr-3",children:O.status==="COMPLETED"?s.jsx(vs,{className:"w-5 h-5 text-green-500"}):s.jsx(Sn,{className:"w-5 h-5 text-yellow-500"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium",children:O.title}),s.jsx(ve,{variant:Pk[O.status],children:ix[O.status]}),z&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",J,"/",ee," erledigt)"]})]}),s.jsxs("div",{className:"text-sm text-gray-500 mt-1 flex items-center gap-2",children:[s.jsx(Xe,{className:"w-4 h-4"}),s.jsx(Se,{to:`/contracts/${O.contractId}`,className:"text-blue-600 hover:underline",onClick:W=>W.stopPropagation(),children:le}),P&&nt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-gray-400",children:"|"}),s.jsx("span",{children:nt})]})]}),O.description&&s.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:O.description})]}),s.jsx("div",{className:"ml-4 flex gap-2",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:W=>{W.stopPropagation(),e(`/contracts/${O.contractId}`)},title:"Zum Vertrag",children:s.jsx(Ae,{className:"w-4 h-4"})})})]}),b&&s.jsxs("div",{className:"border-t bg-gray-50 px-4 py-3",children:[z&&s.jsx("div",{className:"space-y-2 mb-4",children:(ht=O.subtasks)==null?void 0:ht.map(W=>{const _e=new Date(W.createdAt).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"});return s.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:$?()=>E(W):void 0,children:[s.jsx("span",{className:"flex-shrink-0 mt-0.5",children:W.status==="COMPLETED"?s.jsx(vs,{className:"w-4 h-4 text-green-500"}):s.jsx(ao,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:W.status==="COMPLETED"?"text-gray-500 line-through":"",children:[W.title,s.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[W.createdBy," • ",_e]})]})]},W.id)})}),!pe&&($||n)&&s.jsxs("div",{className:"flex gap-2 ml-6",children:[s.jsx(q,{placeholder:n?"Antwort schreiben...":"Neue Unteraufgabe...",value:h[O.id]||"",onChange:W=>p(_e=>({..._e,[O.id]:W.target.value})),onKeyDown:W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),D(O.id))},className:"flex-1"}),s.jsx(T,{size:"sm",onClick:()=>D(O.id),disabled:!((Tt=h[O.id])!=null&&Tt.trim())||C.isPending,children:s.jsx(pl,{className:"w-4 h-4"})})]}),!z&&pe&&s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"Keine Unteraufgaben vorhanden."})]})]},O.id)},U=n?x:a("contracts:update");return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:m}),U&&s.jsxs(T,{onClick:()=>d(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Neue ",f]})]}),s.jsx(Y,{className:"mb-6",children:s.jsx("div",{className:"flex gap-4 flex-wrap items-center",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Status:"}),s.jsx(Oe,{value:i,onChange:O=>l(O.target.value),options:[{value:"",label:"Alle"},...Object.entries(ix).map(([O,P])=>({value:O,label:P}))],className:"w-40"})]})})}),v?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):s.jsx(s.Fragment,{children:n?s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Y,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(yc,{className:"w-5 h-5 text-blue-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Meine ",m]}),s.jsx(ve,{variant:"default",children:A.ownTasks.length})]}),A.ownTasks.length>0?s.jsx("div",{children:A.ownTasks.map(O=>L(O,!1))}):s.jsxs("p",{className:"text-gray-500 text-center py-4",children:["Keine eigenen ",m.toLowerCase()," vorhanden."]})]}),A.representedTasks.length>0&&s.jsxs(Y,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(pa,{className:"w-5 h-5 text-purple-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:[m," freigegebener Kunden"]}),s.jsx(ve,{variant:"default",children:A.representedTasks.length})]}),s.jsx("div",{children:A.representedTasks.map(O=>L(O,!0))})]})]}):s.jsx(Y,{children:A.allTasks&&A.allTasks.length>0?s.jsx("div",{children:A.allTasks.map(O=>L(O,!0))}):s.jsxs("div",{className:"text-center py-8 text-gray-500",children:["Keine ",m.toLowerCase()," gefunden."]})})}),n?s.jsx(Mk,{isOpen:u,onClose:()=>d(!1)}):s.jsx(Fk,{isOpen:u,onClose:()=>d(!1)})]})}function Mk({isOpen:e,onClose:t}){const{user:n}=qe(),r=Wt(),a=xe(),[i,l]=j.useState("own"),[o,c]=j.useState(null),[u,d]=j.useState(""),[h,p]=j.useState(""),[m,f]=j.useState(!1),[g,N]=j.useState(""),{data:x}=de({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>Ke.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),y=j.useMemo(()=>{if(!(x!=null&&x.data))return{own:[],represented:{}};const S=[],E={};for(const D of x.data)if(D.customerId===(n==null?void 0:n.customerId))S.push(D);else{if(!E[D.customerId]){const $=D.customer?D.customer.companyName||`${D.customer.firstName} ${D.customer.lastName}`:`Kunde ${D.customerId}`;E[D.customerId]={name:$,contracts:[]}}E[D.customerId].contracts.push(D)}return{own:S,represented:E}},[x==null?void 0:x.data,n==null?void 0:n.customerId]),v=Object.keys(y.represented).length>0,w=j.useMemo(()=>{var S;return i==="own"?y.own:((S=y.represented[i])==null?void 0:S.contracts)||[]},[i,y]),k=j.useMemo(()=>{if(!g)return w;const S=g.toLowerCase();return w.filter(E=>E.contractNumber.toLowerCase().includes(S)||(E.providerName||"").toLowerCase().includes(S)||(E.tariffName||"").toLowerCase().includes(S))},[w,g]),C=async()=>{if(!(!o||!u.trim())){f(!0);try{await ct.createSupportTicket(o,{title:u.trim(),description:h.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)}}},A=()=>{d(""),p(""),c(null),l("own"),N(""),t()};return s.jsx(ut,{isOpen:e,onClose:A,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[v&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),s.jsxs("select",{value:i,onChange:S=>{const E=S.target.value;l(E==="own"?"own":parseInt(E)),c(null),N("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(y.represented).map(([S,{name:E}])=>s.jsx("option",{value:S,children:E},S))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(q,{placeholder:"Vertrag suchen...",value:g,onChange:S=>N(S.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(S=>s.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:[s.jsx("div",{className:"font-medium",children:S.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[S.providerName||"Kein Anbieter",S.tariffName&&` - ${S.tariffName}`]})]},S.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(q,{value:u,onChange:S=>d(S.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:h,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"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:A,children:"Abbrechen"}),s.jsx(T,{onClick:C,disabled:!o||!u.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function Fk({isOpen:e,onClose:t}){const n=Wt(),r=xe(),[a,i]=j.useState(null),[l,o]=j.useState(null),[c,u]=j.useState(""),[d,h]=j.useState(""),[p,m]=j.useState(!1),[f,g]=j.useState(!1),[N,x]=j.useState(""),[y,v]=j.useState(""),{data:w}=de({queryKey:["customers-for-task"],queryFn:()=>kt.getAll({limit:100}),enabled:e}),{data:k}=de({queryKey:["contracts-for-task",a],queryFn:()=>Ke.getAll({customerId:a}),enabled:e&&a!==null}),C=j.useMemo(()=>{if(!(w!=null&&w.data))return[];if(!N)return w.data;const $=N.toLowerCase();return w.data.filter(L=>L.customerNumber.toLowerCase().includes($)||L.firstName.toLowerCase().includes($)||L.lastName.toLowerCase().includes($)||(L.companyName||"").toLowerCase().includes($))},[w==null?void 0:w.data,N]),A=j.useMemo(()=>{if(!(k!=null&&k.data))return[];if(!y)return k.data;const $=y.toLowerCase();return k.data.filter(L=>L.contractNumber.toLowerCase().includes($)||(L.providerName||"").toLowerCase().includes($)||(L.tariffName||"").toLowerCase().includes($))},[k==null?void 0:k.data,y]),S=async()=>{if(!(!l||!c.trim())){g(!0);try{await ct.create(l,{title:c.trim(),description:d.trim()||void 0,visibleInPortal:p}),r.invalidateQueries({queryKey:["all-tasks"]}),r.invalidateQueries({queryKey:["task-stats"]}),t(),u(""),h(""),m(!1),o(null),i(null),n(`/contracts/${l}`)}catch($){console.error("Fehler beim Erstellen der Aufgabe:",$),alert("Fehler beim Erstellen der Aufgabe. Bitte versuchen Sie es erneut.")}finally{g(!1)}}},E=()=>{u(""),h(""),m(!1),o(null),i(null),x(""),v(""),t()},D=$=>{const L=$.companyName||`${$.firstName} ${$.lastName}`;return`${$.customerNumber} - ${L}`};return s.jsx(ut,{isOpen:e,onClose:E,title:"Neue Aufgabe",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde *"}),s.jsx(q,{placeholder:"Kunde suchen...",value:N,onChange:$=>x($.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:C.length>0?C.map($=>s.jsx("div",{onClick:()=>{i($.id),o(null),v("")},className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${a===$.id?"bg-blue-50 border-blue-200":""}`,children:s.jsx("div",{className:"font-medium",children:D($)})},$.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Kunden gefunden."})})]}),a&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(q,{placeholder:"Vertrag suchen...",value:y,onChange:$=>v($.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:A.length>0?A.map($=>s.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:[s.jsx("div",{className:"font-medium",children:$.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[$.providerName||"Kein Anbieter",$.tariffName&&` - ${$.tariffName}`]})]},$.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:k?"Keine Verträge gefunden.":"Laden..."})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(q,{value:c,onChange:$=>u($.target.value),placeholder:"Aufgabentitel"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:d,onChange:$=>h($.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsx("div",{children:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:p,onChange:$=>m($.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),s.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:E,children:"Abbrechen"}),s.jsx(T,{onClick:S,disabled:!l||!c.trim()||f,children:f?"Wird erstellt...":"Aufgabe erstellen"})]})]})})}function Tk(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=qe(),o=xe(),{data:c,isLoading:u}=de({queryKey:["platforms",a],queryFn:()=>Qi.getAll(a)}),d=H({mutationFn:Qi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["platforms"]})}}),h=m=>{r(m),t(!0)},p=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Vertriebsplattformen"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Neue Plattform"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),u?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kontakt"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:c.data.map(m=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-medium",children:m.name}),s.jsx("td",{className:"py-3 px-4 text-gray-500",children:m.contactInfo||"-"}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(st,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Plattform wirklich löschen?")&&d.mutate(m.id)},children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},m.id))})]})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Plattformen vorhanden."})]}),s.jsx(Ik,{isOpen:e,onClose:p,platform:n})]})}function Ik({isOpen:e,onClose:t,platform:n}){const r=xe(),[a,i]=j.useState({name:"",contactInfo:"",isActive:!0});j.useState(()=>{i(n?{name:n.name,contactInfo:n.contactInfo||"",isActive:n.isActive}:{name:"",contactInfo:"",isActive:!0})}),n&&a.name!==n.name?i({name:n.name,contactInfo:n.contactInfo||"",isActive:n.isActive}):!n&&a.name;const l=H({mutationFn:Qi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t(),i({name:"",contactInfo:"",isActive:!0})}}),o=H({mutationFn:d=>Qi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t()}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Plattform bearbeiten":"Neue Plattform",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{label:"Name *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kontaktinformationen"}),s.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..."})]}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Lk(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=qe(),o=xe(),{data:c,isLoading:u}=de({queryKey:["cancellation-periods",a],queryFn:()=>Hi.getAll(a)}),d=H({mutationFn:Hi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["cancellation-periods"]})}}),h=m=>{r(m),t(!0)},p=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(tn,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Kündigungsfristen"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Neue Frist"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),s.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[s.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",s.jsx("br",{}),s.jsx("strong",{children:"Beispiele:"})," 14T = 14 Tage, 3M = 3 Monate, 1J = 1 Jahr"]}),u?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:c.data.map(m=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:m.code}),s.jsx("td",{className:"py-3 px-4",children:m.description}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(st,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Kündigungsfrist wirklich löschen?")&&d.mutate(m.id)},children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},m.id))})]})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kündigungsfristen vorhanden."})]}),s.jsx(Rk,{isOpen:e,onClose:p,period:n})]})}function Rk({isOpen:e,onClose:t,period:n}){const r=xe(),[a,i]=j.useState({code:"",description:"",isActive:!0});j.useEffect(()=>{e&&i(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[e,n]);const l=H({mutationFn:Hi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t(),i({code:"",description:"",isActive:!0})}}),o=H({mutationFn:d=>Hi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t()}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Kündigungsfrist bearbeiten":"Neue Kündigungsfrist",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{label:"Code *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 14T, 3M, 1J"}),s.jsx(q,{label:"Beschreibung *",value:a.description,onChange:d=>i({...a,description:d.target.value}),required:!0,placeholder:"z.B. 14 Tage, 3 Monate, 1 Jahr"}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Ok(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=qe(),o=xe(),{data:c,isLoading:u}=de({queryKey:["contract-durations",a],queryFn:()=>Wi.getAll(a)}),d=H({mutationFn:Wi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-durations"]})}}),h=m=>{r(m),t(!0)},p=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(tn,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragslaufzeiten"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Neue Laufzeit"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),s.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[s.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",s.jsx("br",{}),s.jsx("strong",{children:"Beispiele:"})," 12M = 12 Monate, 24M = 24 Monate, 2J = 2 Jahre"]}),u?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:c.data.map(m=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:m.code}),s.jsx("td",{className:"py-3 px-4",children:m.description}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(st,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Laufzeit wirklich löschen?")&&d.mutate(m.id)},children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},m.id))})]})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Laufzeiten vorhanden."})]}),s.jsx(zk,{isOpen:e,onClose:p,duration:n})]})}function zk({isOpen:e,onClose:t,duration:n}){const r=xe(),[a,i]=j.useState({code:"",description:"",isActive:!0});j.useEffect(()=>{e&&i(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[e,n]);const l=H({mutationFn:Wi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t(),i({code:"",description:"",isActive:!0})}}),o=H({mutationFn:d=>Wi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t()}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Laufzeit bearbeiten":"Neue Laufzeit",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{label:"Code *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 12M, 24M, 2J"}),s.jsx(q,{label:"Beschreibung *",value:a.description,onChange:d=>i({...a,description:d.target.value}),required:!0,placeholder:"z.B. 12 Monate, 24 Monate, 2 Jahre"}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function $k(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),[l,o]=j.useState(new Set),{hasPermission:c}=qe(),u=xe(),{data:d,isLoading:h}=de({queryKey:["providers",a],queryFn:()=>za.getAll(a)}),p=H({mutationFn:za.delete,onSuccess:()=>{u.invalidateQueries({queryKey:["providers"]})},onError:N=>{alert(N.message)}}),m=N=>{o(x=>{const y=new Set(x);return y.has(N)?y.delete(N):y.add(N),y})},f=N=>{r(N),t(!0)},g=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(tn,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Anbieter & Tarife"}),c("providers:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Neuer Anbieter"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:N=>i(N.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),h?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):d!=null&&d.data&&d.data.length>0?s.jsx("div",{className:"space-y-2",children:d.data.map(N=>s.jsx(_k,{provider:N,isExpanded:l.has(N.id),onToggle:()=>m(N.id),onEdit:()=>f(N),onDelete:()=>{confirm("Anbieter wirklich löschen?")&&p.mutate(N.id)},hasPermission:c,showInactive:a},N.id))}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Anbieter vorhanden."})]}),s.jsx(Kk,{isOpen:e,onClose:g,provider:n})]})}function _k({provider:e,isExpanded:t,onToggle:n,onEdit:r,onDelete:a,hasPermission:i,showInactive:l}){var f,g;const[o,c]=j.useState(!1),[u,d]=j.useState(null),h=xe(),p=H({mutationFn:P0.delete,onSuccess:()=>{h.invalidateQueries({queryKey:["providers"]})},onError:N=>{alert(N.message)}}),m=((f=e.tariffs)==null?void 0:f.filter(N=>l||N.isActive))||[];return s.jsxs("div",{className:"border rounded-lg",children:[s.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50",children:[s.jsx("button",{onClick:n,className:"mr-3 p-1 hover:bg-gray-200 rounded",children:t?s.jsx(Ha,{className:"w-5 h-5 text-gray-400"}):s.jsx(qt,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium",children:e.name}),s.jsx(ve,{variant:e.isActive?"success":"danger",children:e.isActive?"Aktiv":"Inaktiv"}),s.jsxs("span",{className:"text-sm text-gray-500",children:["(",m.length," Tarife, ",((g=e._count)==null?void 0:g.contracts)||0," Verträge)"]})]}),e.portalUrl&&s.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:[s.jsx(zm,{className:"w-3 h-3"}),e.portalUrl]})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[i("providers:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:r,title:"Bearbeiten",children:s.jsx(st,{className:"w-4 h-4"})}),i("providers:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:a,title:"Löschen",children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),t&&s.jsxs("div",{className:"border-t bg-gray-50 p-4",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h4",{className:"font-medium text-gray-700",children:"Tarife"}),i("providers:create")&&s.jsxs(T,{size:"sm",onClick:()=>c(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-1"}),"Tarif hinzufügen"]})]}),m.length>0?s.jsx("div",{className:"space-y-2",children:m.map(N=>{var x;return s.jsxs("div",{className:"flex items-center justify-between bg-white p-3 rounded border",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{children:N.name}),s.jsx(ve,{variant:N.isActive?"success":"danger",className:"text-xs",children:N.isActive?"Aktiv":"Inaktiv"}),((x=N._count)==null?void 0:x.contracts)!==void 0&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",N._count.contracts," Verträge)"]})]}),s.jsxs("div",{className:"flex gap-1",children:[i("providers:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{d(N),c(!0)},title:"Bearbeiten",children:s.jsx(st,{className:"w-3 h-3"})}),i("providers:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Tarif wirklich löschen?")&&p.mutate(N.id)},title:"Löschen",children:s.jsx(be,{className:"w-3 h-3 text-red-500"})})]})]},N.id)})}):s.jsx("p",{className:"text-sm text-gray-500",children:"Keine Tarife vorhanden."})]}),s.jsx(Uk,{isOpen:o,onClose:()=>{c(!1),d(null)},providerId:e.id,tariff:u})]})}function Kk({isOpen:e,onClose:t,provider:n}){const r=xe(),[a,i]=j.useState({name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0});j.useEffect(()=>{e&&i(n?{name:n.name,portalUrl:n.portalUrl||"",usernameFieldName:n.usernameFieldName||"",passwordFieldName:n.passwordFieldName||"",isActive:n.isActive}:{name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0})},[e,n]);const l=H({mutationFn:za.create,onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:d=>{alert(d.message)}}),o=H({mutationFn:d=>za.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:d=>{alert(d.message)}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Anbieter bearbeiten":"Neuer Anbieter",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{label:"Anbietername *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0,placeholder:"z.B. Vodafone, E.ON, Allianz"}),s.jsx(q,{label:"Portal-URL (Login-Seite)",value:a.portalUrl,onChange:d=>i({...a,portalUrl:d.target.value}),placeholder:"https://kundenportal.anbieter.de/login"}),s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg space-y-3",children:[s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("strong",{children:"Auto-Login Felder"})," (optional)",s.jsx("br",{}),"Feldnamen für URL-Parameter beim Auto-Login:"]}),s.jsx(q,{label:"Benutzername-Feldname",value:a.usernameFieldName,onChange:d=>i({...a,usernameFieldName:d.target.value}),placeholder:"z.B. username, email, login"}),s.jsx(q,{label:"Passwort-Feldname",value:a.passwordFieldName,onChange:d=>i({...a,passwordFieldName:d.target.value}),placeholder:"z.B. password, pwd, kennwort"})]}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Uk({isOpen:e,onClose:t,providerId:n,tariff:r}){const a=xe(),[i,l]=j.useState({name:"",isActive:!0});j.useEffect(()=>{e&&l(r?{name:r.name,isActive:r.isActive}:{name:"",isActive:!0})},[e,r]);const o=H({mutationFn:h=>za.createTariff(n,h),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:h=>{alert(h.message)}}),c=H({mutationFn:h=>P0.update(r.id,h),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:h=>{alert(h.message)}}),u=h=>{h.preventDefault(),r?c.mutate(i):o.mutate(i)},d=o.isPending||c.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:r?"Tarif bearbeiten":"Neuer Tarif",children:s.jsxs("form",{onSubmit:u,className:"space-y-4",children:[s.jsx(q,{label:"Tarifname *",value:i.name,onChange:h=>l({...i,name:h.target.value}),required:!0,placeholder:"z.B. Comfort Plus, Basic 100"}),r&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:i.isActive,onChange:h=>l({...i,isActive:h.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}const Dd={Zap:s.jsx(Um,{className:"w-5 h-5"}),Flame:s.jsx($0,{className:"w-5 h-5"}),Wifi:s.jsx(xa,{className:"w-5 h-5"}),Cable:s.jsx(HS,{className:"w-5 h-5"}),Network:s.jsx(i2,{className:"w-5 h-5"}),Smartphone:s.jsx(_m,{className:"w-5 h-5"}),Tv:s.jsx(q0,{className:"w-5 h-5"}),Car:s.jsx(R0,{className:"w-5 h-5"}),FileText:s.jsx(Xe,{className:"w-5 h-5"})},Bk=[{value:"Zap",label:"Blitz (Strom)"},{value:"Flame",label:"Flamme (Gas)"},{value:"Wifi",label:"WLAN (DSL)"},{value:"Cable",label:"Kabel"},{value:"Network",label:"Netzwerk (Glasfaser)"},{value:"Smartphone",label:"Smartphone (Mobilfunk)"},{value:"Tv",label:"TV"},{value:"Car",label:"Auto (KFZ)"},{value:"FileText",label:"Dokument (Sonstige)"}],qk=[{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 Vk(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=qe(),o=xe(),{data:c,isLoading:u}=de({queryKey:["contract-categories",a],queryFn:()=>Gi.getAll(a)}),d=H({mutationFn:Gi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-categories"]})},onError:m=>{alert(m.message)}}),h=m=>{r(m),t(!0)},p=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(tn,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragstypen"}),l("developer:access")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Neuer Vertragstyp"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),u?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"space-y-2",children:c.data.map(m=>{var f;return s.jsxs("div",{className:"flex items-center p-4 border rounded-lg hover:bg-gray-50",children:[s.jsx("div",{className:"mr-3 text-gray-400",children:s.jsx(JS,{className:"w-5 h-5"})}),s.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center mr-4",style:{backgroundColor:m.color||"#E5E7EB",color:"#fff"},children:m.icon&&Dd[m.icon]?Dd[m.icon]:s.jsx(Xe,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium",children:m.name}),s.jsx(ve,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"}),s.jsxs("span",{className:"text-sm text-gray-500",children:["(",((f=m._count)==null?void 0:f.contracts)||0," Verträge)"]})]}),s.jsxs("div",{className:"text-sm text-gray-500",children:["Code: ",s.jsx("span",{className:"font-mono",children:m.code})]})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[l("developer:access")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),title:"Bearbeiten",children:s.jsx(st,{className:"w-4 h-4"})}),l("developer:access")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertragstyp wirklich löschen?")&&d.mutate(m.id)},title:"Löschen",children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]},m.id)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Vertragstypen vorhanden."})]}),s.jsx(Qk,{isOpen:e,onClose:p,category:n})]})}function Qk({isOpen:e,onClose:t,category:n}){const r=xe(),[a,i]=j.useState({code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0});j.useEffect(()=>{e&&i(n?{code:n.code,name:n.name,icon:n.icon||"FileText",color:n.color||"#607D8B",sortOrder:n.sortOrder,isActive:n.isActive}:{code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0})},[e,n]);const l=H({mutationFn:Gi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:d=>{alert(d.message)}}),o=H({mutationFn:d=>Gi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:d=>{alert(d.message)}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Vertragstyp bearbeiten":"Neuer Vertragstyp",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{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:!!n}),s.jsx(q,{label:"Anzeigename *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0,placeholder:"z.B. Strom, Mobilfunk Business"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Icon"}),s.jsx("div",{className:"grid grid-cols-4 gap-2",children:Bk.map(d=>s.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:[Dd[d.value],s.jsx("span",{className:"truncate w-full text-center",children:d.label.split(" ")[0]})]},d.value))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Farbe"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:qk.map(d=>s.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))})]}),s.jsx(q,{label:"Sortierung",type:"number",value:a.sortOrder,onChange:d=>i({...a,sortOrder:parseInt(d.target.value)||0}),placeholder:"0"}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}const Hk=[{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 Wk(){const{settings:e,updateSettings:t}=F0();return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(tn,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ae,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Ansicht"})]})]}),s.jsx(Y,{title:"Scroll-Verhalten",children:s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Nach-oben-Button"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Ab welcher Scroll-Position der Button unten rechts erscheinen soll"})]}),s.jsx("div",{className:"w-48",children:s.jsx(Oe,{options:Hk,value:e.scrollToTopThreshold.toString(),onChange:n=>t({scrollToTopThreshold:parseFloat(n.target.value)})})})]})})})]})}function Gk(){const e=xe(),{data:t,isLoading:n}=de({queryKey:["app-settings"],queryFn:()=>Ur.getAll()}),[r,a]=j.useState(!1);j.useEffect(()=>{t!=null&&t.data&&a(t.data.customerSupportTicketsEnabled==="true")},[t]);const i=H({mutationFn:o=>Ur.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 n?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(tn,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($m,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Kundenportal"})]})]}),s.jsxs(Y,{title:"Support-Anfragen",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Xi,{className:"w-5 h-5 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Kunden können Support-Anfragen erstellen"}),s.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."})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:o=>l(o.target.checked),disabled:i.isPending,className:"sr-only peer"}),s.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&&s.jsx("div",{className:"mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:s.jsxs("p",{className:"text-sm text-blue-800",children:[s.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 Zk(){const e=xe(),{data:t,isLoading:n}=de({queryKey:["app-settings"],queryFn:()=>Ur.getAll()}),[r,a]=j.useState("14"),[i,l]=j.useState("42"),[o,c]=j.useState("90"),[u,d]=j.useState(!1);j.useEffect(()=>{t!=null&&t.data&&(a(t.data.deadlineCriticalDays||"14"),l(t.data.deadlineWarningDays||"42"),c(t.data.deadlineOkDays||"90"),d(!1))},[t]);const h=H({mutationFn:f=>Ur.update(f),onSuccess:()=>{e.invalidateQueries({queryKey:["app-settings"]}),e.invalidateQueries({queryKey:["contract-cockpit"]}),d(!1)}}),p=()=>{const f=parseInt(r),g=parseInt(i),N=parseInt(o);if(isNaN(f)||isNaN(g)||isNaN(N)){alert("Bitte gültige Zahlen eingeben");return}if(f>=g||g>=N){alert("Die Werte müssen aufsteigend sein: Kritisch < Warnung < OK");return}h.mutate({deadlineCriticalDays:r,deadlineWarningDays:i,deadlineOkDays:o})},m=(f,g)=>{f(g),d(!0)};return n?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(tn,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Sn,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Fristenschwellen"})]})]}),s.jsxs(Y,{title:"Farbkodierung für Fristen",children:[s.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."}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-red-50 border border-red-200 rounded-lg",children:[s.jsx(xn,{className:"w-8 h-8 text-red-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block font-medium text-red-800 mb-1",children:"Kritisch (Rot)"}),s.jsx("p",{className:"text-sm text-red-600 mb-2",children:"Fristen mit weniger als X Tagen werden rot markiert"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{type:"number",min:"1",value:r,onChange:f=>m(a,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-red-700",children:"Tage"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-yellow-50 border border-yellow-200 rounded-lg",children:[s.jsx(Ys,{className:"w-8 h-8 text-yellow-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block font-medium text-yellow-800 mb-1",children:"Warnung (Gelb)"}),s.jsx("p",{className:"text-sm text-yellow-600 mb-2",children:"Fristen mit weniger als X Tagen werden gelb markiert"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{type:"number",min:"1",value:i,onChange:f=>m(l,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-yellow-700",children:"Tage"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-green-50 border border-green-200 rounded-lg",children:[s.jsx(vs,{className:"w-8 h-8 text-green-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block font-medium text-green-800 mb-1",children:"OK (Grün)"}),s.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)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{type:"number",min:"1",value:o,onChange:f=>m(c,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-green-700",children:"Tage"})]})]})]})]}),s.jsxs("div",{className:"mt-6 pt-4 border-t flex justify-between items-center",children:[s.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."}),s.jsx(T,{onClick:p,disabled:!u||h.isPending,children:h.isPending?"Speichere...":"Speichern"})]})]})]})}const Jk=[{value:"PLESK",label:"Plesk"},{value:"CPANEL",label:"cPanel"},{value:"DIRECTADMIN",label:"DirectAdmin"}],lx=[{value:"SSL",label:"SSL/TLS",description:"Verschlüsselung von Anfang an"},{value:"STARTTLS",label:"STARTTLS",description:"Startet unverschlüsselt, dann Upgrade"},{value:"NONE",label:"Keine",description:"Keine Verschlüsselung"}],au={name:"",type:"PLESK",apiUrl:"",apiKey:"",username:"",password:"",domain:"stressfrei-wechseln.de",defaultForwardEmail:"",imapEncryption:"SSL",smtpEncryption:"SSL",allowSelfSignedCerts:!1,isActive:!0,isDefault:!1};function Xk(){const e=Wt(),t=xe(),[n,r]=j.useState(!1),[a,i]=j.useState(null),[l,o]=j.useState(au),[c,u]=j.useState(!1),[d,h]=j.useState(null),[p,m]=j.useState(!1),[f,g]=j.useState({}),[N,x]=j.useState(null),{data:y,isLoading:v}=de({queryKey:["email-provider-configs"],queryFn:()=>cn.getConfigs()}),w=H({mutationFn:P=>cn.createConfig(P),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),D()}}),k=H({mutationFn:({id:P,data:b})=>cn.updateConfig(P,b),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),D()}}),C=H({mutationFn:P=>cn.deleteConfig(P),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]})}}),A=(y==null?void 0:y.data)||[],S=()=>{o(au),i(null),u(!1),h(null),r(!0)},E=P=>{o({name:P.name,type:P.type,apiUrl:P.apiUrl,apiKey:P.apiKey||"",username:P.username||"",password:"",domain:P.domain,defaultForwardEmail:P.defaultForwardEmail||"",imapEncryption:P.imapEncryption??"SSL",smtpEncryption:P.smtpEncryption??"SSL",allowSelfSignedCerts:P.allowSelfSignedCerts??!1,isActive:P.isActive,isDefault:P.isDefault}),i(P.id),u(!1),h(null),r(!0)},D=()=>{r(!1),i(null),o(au),u(!1),h(null)},$=async P=>{var b,z,J;x(P.id),g(ee=>({...ee,[P.id]:null}));try{const ee=await cn.testConnection({id:P.id}),pe={success:((b=ee.data)==null?void 0:b.success)||!1,message:(z=ee.data)==null?void 0:z.message,error:(J=ee.data)==null?void 0:J.error};g(le=>({...le,[P.id]:pe}))}catch(ee){g(pe=>({...pe,[P.id]:{success:!1,error:ee instanceof Error?ee.message:"Unbekannter Fehler beim Testen"}}))}finally{x(null)}},L=async()=>{var P,b,z;if(!l.apiUrl||!l.domain){h({success:!1,error:"Bitte geben Sie API-URL und Domain ein."});return}m(!0),h(null);try{const J=await cn.testConnection({testData:{type:l.type,apiUrl:l.apiUrl,apiKey:l.apiKey||void 0,username:l.username||void 0,password:l.password||void 0,domain:l.domain}});h({success:((P=J.data)==null?void 0:P.success)||!1,message:(b=J.data)==null?void 0:b.message,error:(z=J.data)==null?void 0:z.error})}catch(J){h({success:!1,error:J instanceof Error?J.message:"Unbekannter Fehler beim Verbindungstest"})}finally{m(!1)}},U=P=>{P.preventDefault();const b={name:l.name,type:l.type,apiUrl:l.apiUrl,apiKey:l.apiKey,username:l.username,domain:l.domain,defaultForwardEmail:l.defaultForwardEmail,imapEncryption:l.imapEncryption,smtpEncryption:l.smtpEncryption,allowSelfSignedCerts:l.allowSelfSignedCerts,isActive:l.isActive,isDefault:l.isDefault};l.password&&(b.password=l.password),a?k.mutate({id:a,data:b}):w.mutate(b)},V=(P,b)=>{confirm(`Möchten Sie den Provider "${b}" wirklich löschen?`)&&C.mutate(P)},O=P=>P.error?P.error:P.message?P.message:"Verbindung fehlgeschlagen";return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs(T,{variant:"ghost",onClick:()=>e("/settings"),children:[s.jsx(tn,{className:"w-4 h-4 mr-2"}),"Zurück"]}),s.jsx("h1",{className:"text-2xl font-bold",children:"Email-Provisionierung"})]}),s.jsxs(Y,{className:"mb-6",children:[s.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.'}),s.jsxs(T,{onClick:S,children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Provider hinzufügen"]})]}),v?s.jsx("div",{className:"text-center py-8",children:"Laden..."}):A.length===0?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Noch keine Email-Provider konfiguriert."})}):s.jsx("div",{className:"space-y-4",children:A.map(P=>{const b=f[P.id],z=N===P.id;return s.jsx(Y,{children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"font-semibold text-lg",children:P.name}),s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-blue-100 text-blue-800",children:P.type}),P.isDefault&&s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-green-100 text-green-800",children:"Standard"}),!P.isActive&&s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-gray-100 text-gray-600",children:"Inaktiv"})]}),s.jsxs("dl",{className:"mt-3 grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"API-URL"}),s.jsx("dd",{className:"font-mono text-xs truncate",children:P.apiUrl})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Domain"}),s.jsx("dd",{children:P.domain})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Benutzer"}),s.jsx("dd",{children:P.username||"-"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Standard-Weiterleitung"}),s.jsx("dd",{className:"truncate",children:P.defaultForwardEmail||"-"})]})]}),b&&s.jsx("div",{className:`mt-3 p-3 rounded-lg text-sm ${b.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:b.success?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zi,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:"Verbindung erfolgreich!"})]}):s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Op,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:O(b)})]})})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>$(P),disabled:z,title:"Verbindung testen",children:z?s.jsx("span",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}):s.jsx(xa,{className:"w-4 h-4 text-blue-500"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>E(P),children:s.jsx(st,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>V(P.id,P.name),children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]})},P.id)})}),n&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h2",{className:"text-xl font-semibold",children:a?"Provider bearbeiten":"Neuer Provider"}),s.jsx("button",{onClick:D,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Os,{className:"w-5 h-5"})})]}),(w.error||k.error)&&s.jsx("div",{className:"mb-4 p-3 rounded-lg bg-red-50 text-red-800 text-sm",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Os,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:w.error instanceof Error?w.error.message:k.error instanceof Error?k.error.message:"Fehler beim Speichern"})]})}),s.jsxs("form",{onSubmit:U,className:"space-y-4",children:[s.jsx(q,{label:"Name *",value:l.name,onChange:P=>o({...l,name:P.target.value}),placeholder:"z.B. Plesk Hauptserver",required:!0}),s.jsx(Oe,{label:"Provider-Typ *",value:l.type,onChange:P=>o({...l,type:P.target.value}),options:Jk}),s.jsx(q,{label:"API-URL *",value:l.apiUrl,onChange:P=>o({...l,apiUrl:P.target.value}),placeholder:"https://server.de:8443",required:!0}),s.jsx(q,{label:"API-Key",value:l.apiKey,onChange:P=>o({...l,apiKey:P.target.value}),placeholder:"Optional - alternativ zu Benutzername/Passwort"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(q,{label:"Benutzername",value:l.username,onChange:P=>o({...l,username:P.target.value}),placeholder:"admin"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer = beibehalten)":"Passwort"}),s.jsxs("div",{className:"relative",children:[s.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"}),s.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?s.jsx(At,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]}),s.jsx(q,{label:"Domain *",value:l.domain,onChange:P=>o({...l,domain:P.target.value}),placeholder:"stressfrei-wechseln.de",required:!0}),s.jsx(q,{label:"Standard-Weiterleitungsadresse",value:l.defaultForwardEmail,onChange:P=>o({...l,defaultForwardEmail:P.target.value}),placeholder:"info@meinefirma.de",type:"email"}),s.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."}),s.jsxs("div",{className:"pt-4 border-t",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"E-Mail-Verbindungseinstellungen"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["IMAP Verschlüsselung",s.jsxs("span",{className:"text-gray-400 font-normal ml-1",children:["(Port ",l.imapEncryption==="SSL"?"993":"143",")"]})]}),s.jsx("select",{value:l.imapEncryption,onChange:P=>o({...l,imapEncryption:P.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:lx.map(P=>s.jsxs("option",{value:P.value,children:[P.label," - ",P.description]},P.value))})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["SMTP Verschlüsselung",s.jsxs("span",{className:"text-gray-400 font-normal ml-1",children:["(Port ",l.smtpEncryption==="SSL"?"465":l.smtpEncryption==="STARTTLS"?"587":"25",")"]})]}),s.jsx("select",{value:l.smtpEncryption,onChange:P=>o({...l,smtpEncryption:P.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:lx.map(P=>s.jsxs("option",{value:P.value,children:[P.label," - ",P.description]},P.value))})]})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.allowSelfSignedCerts,onChange:P=>o({...l,allowSelfSignedCerts:P.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Selbstsignierte Zertifikate erlauben"})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"Aktivieren Sie diese Option für Testumgebungen mit selbstsignierten SSL-Zertifikaten."})]})]}),s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.isActive,onChange:P=>o({...l,isActive:P.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Aktiv"})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.isDefault,onChange:P=>o({...l,isDefault:P.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Als Standard verwenden"})]})]}),s.jsxs("div",{className:"pt-4 border-t",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:L,disabled:p,className:"w-full",children:p?"Teste Verbindung...":s.jsxs(s.Fragment,{children:[s.jsx(xa,{className:"w-4 h-4 mr-2"}),"Verbindung testen"]})}),d&&s.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?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zi,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:"Verbindung erfolgreich!"})]}):s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Op,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:O(d)})]})})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:D,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:w.isPending||k.isPending,children:w.isPending||k.isPending?"Speichern...":"Speichern"})]})]})]})})})]})}function Yk(){const[e,t]=j.useState(null),[n,r]=j.useState(null),[a,i]=j.useState(!1),[l,o]=j.useState(""),[c,u]=j.useState(null),d=j.useRef(null),h=xe(),{logout:p}=qe(),{data:m,isLoading:f}=de({queryKey:["backups"],queryFn:()=>dr.list()}),g=(m==null?void 0:m.data)||[],N=H({mutationFn:()=>dr.create(),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]})}}),x=H({mutationFn:E=>dr.restore(E),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),t(null)}}),y=H({mutationFn:E=>dr.delete(E),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),r(null)}}),v=H({mutationFn:E=>dr.upload(E),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),u(null),d.current&&(d.current.value="")},onError:E=>{u(E.message||"Upload fehlgeschlagen")}}),w=H({mutationFn:()=>dr.factoryReset(),onSuccess:()=>{i(!1),o(""),p()}}),k=E=>{var $;const D=($=E.target.files)==null?void 0:$[0];if(D){if(!D.name.endsWith(".zip")){u("Nur ZIP-Dateien sind erlaubt");return}u(null),v.mutate(D)}},C=async E=>{const D=localStorage.getItem("token"),$=dr.getDownloadUrl(E);try{const L=await fetch($,{headers:{Authorization:`Bearer ${D}`}});if(!L.ok)throw new Error("Download fehlgeschlagen");const U=await L.blob(),V=window.URL.createObjectURL(U),O=document.createElement("a");O.href=V,O.download=`opencrm-backup-${E}.zip`,document.body.appendChild(O),O.click(),document.body.removeChild(O),window.URL.revokeObjectURL(V)}catch(L){console.error("Download error:",L)}},A=E=>new Date(E).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),S=E=>E<1024?`${E} B`:E<1024*1024?`${(E/1024).toFixed(1)} KB`:`${(E/(1024*1024)).toFixed(1)} MB`;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-gray-900 flex items-center gap-2",children:[s.jsx(xc,{className:"w-5 h-5"}),"Datenbank & Zurücksetzen"]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Backups erstellen, wiederherstellen oder auf Werkseinstellungen zurücksetzen."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"file",ref:d,accept:".zip",onChange:k,className:"hidden"}),s.jsx(T,{variant:"secondary",onClick:()=>{var E;return(E=d.current)==null?void 0:E.click()},disabled:v.isPending,children:v.isPending?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"w-4 h-4 mr-2 animate-spin"}),"Hochladen..."]}):s.jsxs(s.Fragment,{children:[s.jsx(kd,{className:"w-4 h-4 mr-2"}),"Backup hochladen"]})}),s.jsx(T,{onClick:()=>N.mutate(),disabled:N.isPending,children:N.isPending?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird erstellt..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ts,{className:"w-4 h-4 mr-2"}),"Neues Backup"]})})]})]}),c&&s.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-700",children:c}),s.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-blue-800 mb-2",children:"Hinweise zur Datensicherung"}),s.jsxs("ul",{className:"text-sm text-blue-700 space-y-1 list-disc list-inside",children:[s.jsx("li",{children:"Backups enthalten alle Datenbankdaten und hochgeladene Dokumente"}),s.jsx("li",{children:"Erstellen Sie vor Datenbankmigrationen immer ein Backup"}),s.jsx("li",{children:"Backups können als ZIP heruntergeladen und auf einem anderen System wiederhergestellt werden"}),s.jsx("li",{children:"Bei der Wiederherstellung werden bestehende Daten mit dem Backup-Stand überschrieben"})]})]}),s.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 overflow-hidden",children:[s.jsx("div",{className:"px-4 py-3 bg-gray-50 border-b border-gray-200",children:s.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Verfügbare Backups"})}),f?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(fr,{className:"w-6 h-6 animate-spin text-gray-400"})}):g.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Lp,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Keine Backups vorhanden"}),s.jsx("p",{className:"text-sm mt-1",children:"Erstellen Sie Ihr erstes Backup"})]}):s.jsx("div",{className:"divide-y divide-gray-200",children:g.map(E=>s.jsx("div",{className:"p-4 hover:bg-gray-50",children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[s.jsx("span",{className:"font-mono text-sm bg-gray-100 px-2 py-1 rounded",children:E.name}),s.jsxs("span",{className:"text-sm text-gray-500 flex items-center gap-1",children:[s.jsx(Sn,{className:"w-4 h-4"}),A(E.timestamp)]})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Xe,{className:"w-4 h-4"}),E.totalRecords.toLocaleString("de-DE")," Datensätze"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Lp,{className:"w-4 h-4"}),S(E.sizeBytes)]}),E.hasUploads&&s.jsxs("span",{className:"flex items-center gap-1 text-green-600",children:[s.jsx(ZS,{className:"w-4 h-4"}),"Dokumente (",S(E.uploadSizeBytes),")"]})]}),s.jsxs("details",{className:"mt-2",children:[s.jsxs("summary",{className:"text-xs text-gray-500 cursor-pointer hover:text-gray-700",children:["Tabellen anzeigen (",E.tables.filter(D=>D.count>0).length," mit Daten)"]}),s.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:E.tables.filter(D=>D.count>0).map(D=>s.jsxs("span",{className:"text-xs bg-gray-100 px-2 py-0.5 rounded",children:[D.table,": ",D.count]},D.table))})]})]}),s.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>C(E.name),title:"Als ZIP herunterladen",children:s.jsx(VS,{className:"w-4 h-4"})}),s.jsxs(T,{variant:"secondary",size:"sm",onClick:()=>t(E.name),disabled:x.isPending,children:[s.jsx(kd,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsx(T,{variant:"danger",size:"sm",onClick:()=>r(E.name),disabled:y.isPending,children:s.jsx(be,{className:"w-4 h-4"})})]})]})},E.name))})]}),e&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup wiederherstellen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",s.jsx("strong",{children:e})," wirklich wiederherstellen?"]}),s.jsxs("p",{className:"text-amber-600 text-sm mb-4 bg-amber-50 p-3 rounded-lg",children:[s.jsx("strong",{children:"Achtung:"})," Bestehende Daten und Dokumente werden mit dem Backup-Stand überschrieben. Dies kann nicht rückgängig gemacht werden."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>t(null),disabled:x.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"primary",onClick:()=>x.mutate(e),disabled:x.isPending,children:x.isPending?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird wiederhergestellt..."]}):"Ja, wiederherstellen"})]})]})}),n&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup löschen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",s.jsx("strong",{children:n})," wirklich löschen? Dies kann nicht rückgängig gemacht werden."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>r(null),disabled:y.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>y.mutate(n),disabled:y.isPending,children:y.isPending?"Wird gelöscht...":"Ja, löschen"})]})]})}),s.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 mt-8",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(Ys,{className:"w-6 h-6 text-red-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-red-800 mb-2",children:"Werkseinstellungen"}),s.jsxs("p",{className:"text-sm text-red-700 mb-4",children:["Setzt das System auf den Ausgangszustand zurück. ",s.jsx("strong",{children:"Alle Daten werden unwiderruflich gelöscht"})," - Kunden, Verträge, Benutzer, Dokumente und Einstellungen. Nur die hier gespeicherten Backups bleiben erhalten."]}),s.jsxs("ul",{className:"text-sm text-red-700 mb-4 list-disc list-inside space-y-1",children:[s.jsx("li",{children:"Alle Kunden und Verträge werden gelöscht"}),s.jsx("li",{children:"Alle Benutzer werden gelöscht"}),s.jsx("li",{children:"Alle hochgeladenen Dokumente werden gelöscht"}),s.jsx("li",{children:"Ein neuer Admin-Benutzer wird erstellt (admin@admin.com / admin)"}),s.jsxs("li",{children:[s.jsx("strong",{children:"Backups bleiben erhalten"})," und können danach wiederhergestellt werden"]})]}),s.jsxs(T,{variant:"danger",onClick:()=>i(!0),children:[s.jsx(o2,{className:"w-4 h-4 mr-2"}),"Werkseinstellungen"]})]})]})}),a&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-lg mx-4",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(Ys,{className:"w-6 h-6 text-red-600"})}),s.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Wirklich auf Werkseinstellungen zurücksetzen?"})]}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Diese Aktion löscht ",s.jsx("strong",{children:"alle Daten unwiderruflich"}),". Es gibt kein Zurück!"]}),s.jsxs("p",{className:"text-sm text-gray-600 mb-4",children:["Geben Sie zur Bestätigung ",s.jsx("strong",{className:"font-mono bg-gray-100 px-1",children:"LÖSCHEN"})," ein:"]}),s.jsx("input",{type:"text",value:l,onChange:E=>o(E.target.value),placeholder:"LÖSCHEN",className:"w-full px-3 py-2 border border-gray-300 rounded-lg mb-4 focus:ring-2 focus:ring-red-500 focus:border-red-500"}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>{i(!1),o("")},disabled:w.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>w.mutate(),disabled:l!=="LÖSCHEN"||w.isPending,children:w.isPending?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird zurückgesetzt..."]}):"Ja, alles löschen"})]})]})})]})}function eC(){var y;const[e,t]=j.useState(""),[n,r]=j.useState(1),[a,i]=j.useState(!1),[l,o]=j.useState(null),c=xe(),{refreshUser:u}=qe(),{data:d,isLoading:h}=de({queryKey:["users",e,n],queryFn:()=>wi.getAll({search:e||void 0,page:n,limit:20})}),{data:p}=de({queryKey:["roles"],queryFn:()=>wi.getRoles()}),m=H({mutationFn:wi.delete,onSuccess:()=>{c.invalidateQueries({queryKey:["users"]})},onError:v=>{alert((v==null?void 0:v.message)||"Fehler beim Löschen des Benutzers")}}),f=v=>{var w;return(w=v.roles)==null?void 0:w.some(k=>k.name==="Admin")},g=((y=d==null?void 0:d.data)==null?void 0:y.filter(v=>v.isActive&&f(v)).length)||0,N=v=>{o(v),i(!0)},x=()=>{i(!1),o(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(tn,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Benutzer"}),s.jsxs(T,{onClick:()=>i(!0),children:[s.jsx($e,{className:"w-4 h-4 mr-2"}),"Neuer Benutzer"]})]}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx(q,{placeholder:"Suchen...",value:e,onChange:v=>t(v.target.value)})}),s.jsx(T,{variant:"secondary",children:s.jsx(fl,{className:"w-4 h-4"})})]})}),s.jsxs("div",{className:"mb-6 bg-blue-50 border border-blue-200 rounded-lg p-4 flex items-start gap-3",children:[s.jsx(YS,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-blue-800",children:[s.jsx("strong",{children:"Hinweis:"})," Bei Änderungen an Rollen oder Berechtigungen wird der betroffene Benutzer automatisch ausgeloggt und muss sich erneut anmelden."]})]}),s.jsx(Y,{children:h?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):d!=null&&d.data&&d.data.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Rollen"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:d.data.map(v=>{var w;return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsxs("td",{className:"py-3 px-4",children:[v.firstName," ",v.lastName]}),s.jsx("td",{className:"py-3 px-4",children:v.email}),s.jsx("td",{className:"py-3 px-4",children:s.jsx("div",{className:"flex gap-1 flex-wrap",children:(w=v.roles)==null?void 0:w.filter(k=>k.name!=="Developer").map(k=>s.jsx(ve,{variant:"info",children:k.name},k.id||k.name))})}),s.jsx("td",{className:"py-3 px-4",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ve,{variant:v.isActive?"success":"danger",children:v.isActive?"Aktiv":"Inaktiv"}),v.hasDeveloperAccess&&s.jsxs(ve,{variant:"warning",className:"flex items-center gap-1",children:[s.jsx(pc,{className:"w-3 h-3"}),"Dev"]})]})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>N(v),children:s.jsx(st,{className:"w-4 h-4"})}),(()=>{const k=f(v)&&v.isActive&&g<=1;return s.jsx(T,{variant:"ghost",size:"sm",disabled:k,title:k?"Letzter Administrator kann nicht gelöscht werden":void 0,onClick:()=>{confirm("Benutzer wirklich löschen?")&&m.mutate(v.id)},children:s.jsx(be,{className:`w-4 h-4 ${k?"text-gray-300":"text-red-500"}`})})})()]})})]},v.id)})})]})}),d.pagination&&d.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",d.pagination.page," von ",d.pagination.totalPages]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(v=>Math.max(1,v-1)),disabled:n===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(v=>v+1),disabled:n>=d.pagination.totalPages,children:"Weiter"})]})]})]}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Benutzer gefunden."})}),s.jsx(tC,{isOpen:a,onClose:x,user:l,roles:(p==null?void 0:p.data)||[],onUserUpdated:u})]})}function tC({isOpen:e,onClose:t,user:n,roles:r,onUserUpdated:a}){const i=xe(),[l,o]=j.useState(null),[c,u]=j.useState({email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1});j.useEffect(()=>{var g;e&&(o(null),u(n?{email:n.email,password:"",firstName:n.firstName,lastName:n.lastName,roleIds:((g=n.roles)==null?void 0:g.filter(N=>N.name!=="Developer").map(N=>N.id))||[],isActive:n.isActive??!0,hasDeveloperAccess:n.hasDeveloperAccess??!1}:{email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1}))},[e,n]);const d=H({mutationFn:wi.create,onSuccess:()=>{i.invalidateQueries({queryKey:["users"]}),t()},onError:g=>{o((g==null?void 0:g.message)||"Fehler beim Erstellen des Benutzers")}}),h=H({mutationFn:g=>wi.update(n.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(),n){const N={email:c.email,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,isActive:c.isActive,hasDeveloperAccess:c.hasDeveloperAccess};c.password&&(N.password=c.password),h.mutate(N)}else d.mutate({email:c.email,password:c.password,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,hasDeveloperAccess:c.hasDeveloperAccess})},m=g=>{u(N=>({...N,roleIds:N.roleIds.includes(g)?N.roleIds.filter(x=>x!==g):[...N.roleIds,g]}))},f=d.isPending||h.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Benutzer bearbeiten":"Neuer Benutzer",children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[l&&s.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 flex items-start gap-2",children:[s.jsx(Ys,{className:"w-5 h-5 text-red-500 flex-shrink-0 mt-0.5"}),s.jsx("p",{className:"text-red-700 text-sm",children:l})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(q,{label:"Vorname *",value:c.firstName,onChange:g=>u({...c,firstName:g.target.value}),required:!0}),s.jsx(q,{label:"Nachname *",value:c.lastName,onChange:g=>u({...c,lastName:g.target.value}),required:!0})]}),s.jsx(q,{label:"E-Mail *",type:"email",value:c.email,onChange:g=>u({...c,email:g.target.value}),required:!0}),s.jsx(q,{label:n?"Neues Passwort (leer = unverändert)":"Passwort *",type:"password",value:c.password,onChange:g=>u({...c,password:g.target.value}),required:!n}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Rollen"}),s.jsxs("div",{className:"space-y-2",children:[r.filter(g=>g.name!=="Developer").map(g=>s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.roleIds.includes(g.id),onChange:()=>m(g.id),className:"rounded"}),s.jsx("span",{children:g.name}),g.description&&s.jsxs("span",{className:"text-sm text-gray-500",children:["(",g.description,")"]})]},g.id)),s.jsxs("label",{className:"flex items-center gap-2",children:[s.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"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(pc,{className:"w-4 h-4 text-purple-600"}),"Entwicklerzugriff"]}),s.jsx("span",{className:"text-sm text-gray-500",children:"(Datenbanktools)"})]})]}),n&&s.jsxs("p",{className:"mt-2 text-xs text-amber-600 flex items-center gap-1",children:[s.jsx(Ys,{className:"w-3 h-3"}),"Bei Rollenänderung wird der Benutzer automatisch ausgeloggt."]})]}),n&&s.jsx("div",{className:"space-y-3 pt-3 border-t",children:s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.isActive,onChange:g=>u({...c,isActive:g.target.checked}),className:"rounded"}),"Aktiv"]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:f,children:f?"Speichern...":"Speichern"})]})]})})}function sC(){const{hasPermission:e,developerMode:t,setDeveloperMode:n}=qe(),r=[{to:"/settings/users",icon:d2,title:"Benutzer",description:"Verwalten Sie Benutzerkonten, Rollen und Berechtigungen.",show:e("users:read")},{to:"/settings/platforms",icon:c2,title:"Vertriebsplattformen",description:"Verwalten Sie die Plattformen, über die Verträge abgeschlossen werden.",show:e("platforms:read")},{to:"/settings/cancellation-periods",icon:Sn,title:"Kündigungsfristen",description:"Konfigurieren Sie die verfügbaren Kündigungsfristen für Verträge.",show:e("platforms:read")},{to:"/settings/contract-durations",icon:L0,title:"Vertragslaufzeiten",description:"Konfigurieren Sie die verfügbaren Laufzeiten für Verträge.",show:e("platforms:read")},{to:"/settings/providers",icon:QS,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:GS,title:"Vertragstypen",description:"Konfigurieren Sie die verfügbaren Vertragstypen (Strom, Gas, Mobilfunk, etc.).",show:e("platforms:read")}];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx(B0,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Einstellungen"})]}),s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Stammdaten"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:r.filter(a=>a.show).map(a=>s.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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(a.icon,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:[a.title,s.jsx(qt,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:a.description})]})]})},a.to))})]}),e("settings:update")&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"System"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx($m,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Kundenportal",s.jsx(qt,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie das Kundenportal und Support-Anfragen."})]})]})}),s.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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(Sn,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Fristenschwellen",s.jsx(qt,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die Farbkodierung für Vertragsfristen im Cockpit."})]})]})}),s.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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(Gs,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Email-Provisionierung",s.jsx(qt,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die automatische E-Mail-Erstellung für Stressfrei-Wechseln Adressen."})]})]})}),s.jsx(Se,{to:"/settings/database-backup",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(xc,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Datenbank & Zurücksetzen",s.jsx(qt,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Backups erstellen, wiederherstellen oder auf Werkseinstellungen zurücksetzen."})]})]})})]})]}),s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Persönlich"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:s.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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(Ae,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Ansicht",s.jsx(qt,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Passen Sie die Darstellung der Anwendung an."})]})]})})})]}),e("developer:access")&&s.jsxs(Y,{title:"Entwickleroptionen",className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(pc,{className:"w-5 h-5 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Entwicklermodus"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Aktiviert erweiterte Funktionen wie direkten Datenbankzugriff"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:a=>n(a.target.checked),className:"sr-only peer"}),s.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&&s.jsx("div",{className:"mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:s.jsxs("p",{className:"text-sm text-yellow-800",children:[s.jsx("strong",{children:"Warnung:"})," Der Entwicklermodus ermöglicht direkten Zugriff auf die Datenbank. Unsachgemäße Änderungen können zu Datenverlust oder Inkonsistenzen führen."]})})]}),s.jsx(Y,{title:"Über",children:s.jsxs("dl",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Version"}),s.jsx("dd",{children:"1.0.0"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"System"}),s.jsx("dd",{children:"OpenCRM"})]})]})})]})}function nC({onSelectTable:e}){const t=j.useRef(null),[n,r]=j.useState(1),[a,i]=j.useState({x:0,y:0}),[l,o]=j.useState(!1),[c,u]=j.useState({x:0,y:0}),[d,h]=j.useState({}),[p,m]=j.useState(null),{data:f,isLoading:g}=de({queryKey:["developer-schema"],queryFn:hi.getSchema}),N=(f==null?void 0:f.data)||[];j.useEffect(()=>{if(N.length>0&&Object.keys(d).length===0){const S=Math.ceil(Math.sqrt(N.length)),E={x:280,y:200},D={};N.forEach(($,L)=>{const U=L%S,V=Math.floor(L/S);D[$.name]={x:50+U*E.x,y:50+V*E.y}}),h(D)}},[N,d]);const x=j.useCallback(S=>{(S.target===S.currentTarget||S.target.tagName==="svg")&&(o(!0),u({x:S.clientX-a.x,y:S.clientY-a.y}))},[a]),y=j.useCallback(S=>{var E;if(l&&!p)i({x:S.clientX-c.x,y:S.clientY-c.y});else if(p){const D=(E=t.current)==null?void 0:E.getBoundingClientRect();D&&h($=>({...$,[p]:{x:(S.clientX-D.left-a.x)/n-100,y:(S.clientY-D.top-a.y)/n-20}}))}},[l,p,c,a,n]),v=j.useCallback(()=>{o(!1),m(null)},[]),w=S=>{r(E=>Math.min(2,Math.max(.3,E+S)))},k=()=>{r(1),i({x:0,y:0})},C=j.useCallback(()=>{const S=[];return N.forEach(E=>{const D=d[E.name];D&&E.foreignKeys.forEach($=>{const L=d[$.targetTable];if(!L)return;const U=N.find(O=>O.name===$.targetTable),V=U==null?void 0:U.relations.find(O=>O.targetTable===E.name);S.push({from:{table:E.name,x:D.x+100,y:D.y+60},to:{table:$.targetTable,x:L.x+100,y:L.y+60},type:(V==null?void 0:V.type)||"one",label:$.field})})}),S},[N,d]);if(g)return s.jsx("div",{className:"flex items-center justify-center h-full",children:"Laden..."});const A=C();return s.jsxs("div",{className:"relative h-full w-full bg-gray-50 overflow-hidden",ref:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex gap-2 bg-white rounded-lg shadow-md p-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>w(.1),title:"Vergrößern",children:s.jsx(h2,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>w(-.1),title:"Verkleinern",children:s.jsx(f2,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:k,title:"Zurücksetzen",children:s.jsx(r2,{className:"w-4 h-4"})}),s.jsxs("div",{className:"text-xs text-gray-500 flex items-center px-2",children:[Math.round(n*100),"%"]})]}),s.jsxs("div",{className:"absolute top-4 left-4 z-10 bg-white rounded-lg shadow-md p-2 text-xs text-gray-500",children:[s.jsx(a2,{className:"w-3 h-3 inline mr-1"}),"Tabellen ziehen zum Verschieben"]}),s.jsx("svg",{className:"w-full h-full cursor-grab",style:{cursor:l?"grabbing":"grab"},onMouseDown:x,onMouseMove:y,onMouseUp:v,onMouseLeave:v,children:s.jsxs("g",{transform:`translate(${a.x}, ${a.y}) scale(${n})`,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6b7280"})}),s.jsx("marker",{id:"many-marker",markerWidth:"12",markerHeight:"12",refX:"6",refY:"6",orient:"auto",children:s.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"#6b7280"})})]}),A.map((S,E)=>{const D=S.to.x-S.from.x,$=S.to.y-S.from.y,L=S.from.x+D/2,U=S.from.y+$/2,V=S.from.x+D*.25,O=S.from.y,P=S.from.x+D*.75,b=S.to.y;return s.jsxs("g",{children:[s.jsx("path",{d:`M ${S.from.x} ${S.from.y} C ${V} ${O}, ${P} ${b}, ${S.to.x} ${S.to.y}`,fill:"none",stroke:"#9ca3af",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),s.jsx("text",{x:L,y:U-8,fontSize:"10",fill:"#6b7280",textAnchor:"middle",className:"select-none",children:S.type==="many"?"1:n":"1:1"})]},E)}),N.map(S=>{const E=d[S.name];if(!E)return null;const D=200,$=32,L=20,U=[...new Set([S.primaryKey,...S.foreignKeys.map(O=>O.field)])],V=$+Math.min(U.length,5)*L+8;return s.jsxs("g",{transform:`translate(${E.x}, ${E.y})`,style:{cursor:"move"},onMouseDown:O=>{O.stopPropagation(),m(S.name)},children:[s.jsx("rect",{x:"3",y:"3",width:D,height:V,rx:"6",fill:"rgba(0,0,0,0.1)"}),s.jsx("rect",{x:"0",y:"0",width:D,height:V,rx:"6",fill:"white",stroke:"#e5e7eb",strokeWidth:"1"}),s.jsx("rect",{x:"0",y:"0",width:D,height:$,rx:"6",fill:"#3b82f6",className:"cursor-pointer",onClick:()=>e==null?void 0:e(S.name)}),s.jsx("rect",{x:"0",y:$-6,width:D,height:"6",fill:"#3b82f6"}),s.jsx("text",{x:D/2,y:"21",fontSize:"13",fontWeight:"bold",fill:"white",textAnchor:"middle",className:"select-none pointer-events-none",children:S.name}),U.slice(0,5).map((O,P)=>{const b=O===S.primaryKey||S.primaryKey.includes(O),z=S.foreignKeys.some(J=>J.field===O);return s.jsx("g",{transform:`translate(8, ${$+4+P*L})`,children:s.jsxs("text",{x:"0",y:"14",fontSize:"11",fill:b?"#dc2626":z?"#2563eb":"#374151",fontFamily:"monospace",className:"select-none",children:[b&&"🔑 ",z&&!b&&"🔗 ",O]})},O)}),U.length>5&&s.jsxs("text",{x:D/2,y:V-4,fontSize:"10",fill:"#9ca3af",textAnchor:"middle",className:"select-none",children:["+",U.length-5," mehr..."]})]},S.name)})]})}),s.jsxs("div",{className:"absolute bottom-4 left-4 bg-white rounded-lg shadow-md p-3 text-xs",children:[s.jsx("div",{className:"font-medium mb-2",children:"Legende"}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-red-600",children:"🔑"}),s.jsx("span",{children:"Primary Key"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-blue-600",children:"🔗"}),s.jsx("span",{children:"Foreign Key"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-6 h-0.5 bg-gray-400"}),s.jsx("span",{children:"Beziehung"})]})]})]})]})}function rC(){var A;const[e,t]=j.useState(null),[n,r]=j.useState(1),[a,i]=j.useState(null),[l,o]=j.useState(!1),c=xe(),{data:u,isLoading:d,error:h}=de({queryKey:["developer-schema"],queryFn:hi.getSchema});console.log("Schema data:",u),console.log("Schema error:",h);const{data:p,isLoading:m}=de({queryKey:["developer-table",e,n],queryFn:()=>hi.getTableData(e,n),enabled:!!e}),f=H({mutationFn:({tableName:S,id:E,data:D})=>hi.updateRow(S,E,D),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]}),i(null)},onError:S=>{var E,D;alert(((D=(E=S.response)==null?void 0:E.data)==null?void 0:D.error)||"Fehler beim Speichern")}}),g=H({mutationFn:({tableName:S,id:E})=>hi.deleteRow(S,E),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]})},onError:S=>{var E,D;alert(((D=(E=S.response)==null?void 0:E.data)==null?void 0:D.error)||"Fehler beim Löschen")}}),N=(u==null?void 0:u.data)||[],x=N.find(S=>S.name===e),y=(S,E)=>E.primaryKey.includes(",")?E.primaryKey.split(",").map(D=>S[D]).join("-"):String(S[E.primaryKey]),v=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),w=()=>{!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 s.jsx("div",{className:"text-center py-8",children:"Laden..."});const C=S=>{t(S),r(1),o(!1)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(xc,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Datenbankstruktur"})]}),s.jsxs(T,{onClick:()=>o(!0),children:[s.jsx(Ip,{className:"w-4 h-4 mr-2"}),"ER-Diagramm"]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[s.jsx(Y,{title:"Tabellen",className:"lg:col-span-1",children:s.jsx("div",{className:"space-y-1 max-h-[600px] overflow-y-auto",children:N.map(S=>s.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:[s.jsx(u2,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-mono",children:S.name})]},S.name))})}),s.jsx("div",{className:"lg:col-span-3 space-y-6",children:e&&x?s.jsxs(s.Fragment,{children:[s.jsxs(Y,{title:`${e} - Beziehungen`,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Fremdschlüssel (referenziert)"}),x.foreignKeys.length>0?s.jsx("div",{className:"space-y-1",children:x.foreignKeys.map(S=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:S.field}),s.jsx(I0,{className:"w-4 h-4 text-gray-400"}),s.jsx(ve,{variant:"info",className:"cursor-pointer",onClick:()=>{t(S.targetTable),r(1)},children:S.targetTable})]},S.field))}):s.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Relationen (wird referenziert von)"}),x.relations.length>0?s.jsx("div",{className:"space-y-1",children:x.relations.map(S=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:S.field}),s.jsx(ve,{variant:S.type==="many"?"warning":"default",children:S.type==="many"?"1:n":"1:1"}),s.jsx(ve,{variant:"info",className:"cursor-pointer",onClick:()=>{t(S.targetTable),r(1)},children:S.targetTable})]},S.field))}):s.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]})]}),s.jsx("div",{className:"mt-4 pt-4 border-t",children:s.jsxs("div",{className:"flex gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Primary Key:"})," ",s.jsx("span",{className:"font-mono",children:x.primaryKey})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Readonly:"})," ",s.jsx("span",{className:"font-mono text-red-600",children:x.readonlyFields.join(", ")||"-"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Required:"})," ",s.jsx("span",{className:"font-mono text-green-600",children:x.requiredFields.join(", ")||"-"})]})]})})]}),s.jsx(Y,{title:`${e} - Daten`,children:m?s.jsx("div",{className:"text-center py-4",children:"Laden..."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.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=>s.jsxs("th",{className:"text-left py-2 px-3 font-medium text-gray-600 whitespace-nowrap",children:[S,x.readonlyFields.includes(S)&&s.jsx("span",{className:"ml-1 text-red-400 text-xs",children:"*"}),x.requiredFields.includes(S)&&s.jsx("span",{className:"ml-1 text-green-400 text-xs",children:"!"})]},S)),s.jsx("th",{className:"text-right py-2 px-3 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsxs("tbody",{children:[(A=p==null?void 0:p.data)==null?void 0:A.map(S=>{const E=y(S,x);return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[Object.entries(S).map(([D,$])=>s.jsx("td",{className:"py-2 px-3 font-mono text-xs max-w-[200px] truncate",children:v($)},D)),s.jsx("td",{className:"py-2 px-3 text-right whitespace-nowrap",children:s.jsxs("div",{className:"flex justify-end gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>i({id:E,data:{...S}}),children:s.jsx(st,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>k(E),children:s.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},E)}),(!(p!=null&&p.data)||p.data.length===0)&&s.jsx("tr",{children:s.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&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",p.pagination.page," von ",p.pagination.totalPages," (",p.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(S=>Math.max(1,S-1)),disabled:n===1,children:s.jsx(WS,{className:"w-4 h-4"})}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(S=>S+1),disabled:n>=p.pagination.totalPages,children:s.jsx(qt,{className:"w-4 h-4"})})]})]})]})})]}):s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Wähle eine Tabelle aus der Liste aus"})})})]}),s.jsx(ut,{isOpen:!!a,onClose:()=>i(null),title:`${e} bearbeiten`,children:a&&x&&s.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[Object.entries(a.data).map(([S,E])=>{const D=x.readonlyFields.includes(S),$=x.requiredFields.includes(S);return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[S,D&&s.jsx("span",{className:"ml-1 text-red-400",children:"(readonly)"}),$&&s.jsx("span",{className:"ml-1 text-green-600",children:"*"})]}),D?s.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg font-mono text-sm",children:v(E)}):typeof E=="boolean"?s.jsxs("select",{value:String(a.data[S]),onChange:L=>i({...a,data:{...a.data,[S]:L.target.value==="true"}}),className:"w-full px-3 py-2 border rounded-lg",children:[s.jsx("option",{value:"true",children:"Ja"}),s.jsx("option",{value:"false",children:"Nein"})]}):s.jsx("input",{type:typeof E=="number"?"number":"text",value:a.data[S]??"",onChange:L=>i({...a,data:{...a.data,[S]:typeof E=="number"?L.target.value?Number(L.target.value):null:L.target.value||null}}),className:"w-full px-3 py-2 border rounded-lg font-mono text-sm",disabled:D})]},S)}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[s.jsxs(T,{variant:"secondary",onClick:()=>i(null),children:[s.jsx(Os,{className:"w-4 h-4 mr-2"}),"Abbrechen"]}),s.jsxs(T,{onClick:w,disabled:f.isPending,children:[s.jsx(U0,{className:"w-4 h-4 mr-2"}),f.isPending?"Speichern...":"Speichern"]})]})]})}),l&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>o(!1)}),s.jsxs("div",{className:"relative bg-white rounded-xl shadow-2xl w-[90vw] h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ip,{className:"w-5 h-5 text-blue-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"ER-Diagramm - Datenbankbeziehungen"})]}),s.jsx("button",{onClick:()=>o(!1),className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(Os,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(nC,{onSelectTable:C})})]})]})]})}function aC({children:e}){const{isAuthenticated:t,isLoading:n}=qe();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):t?s.jsx(s.Fragment,{children:e}):s.jsx(oa,{to:"/login",replace:!0})}function iC({children:e}){const{hasPermission:t,developerMode:n}=qe();return!t("developer:access")||!n?s.jsx(oa,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:e})}function lC(){const{isAuthenticated:e,isLoading:t}=qe();return t?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):s.jsxs(s.Fragment,{children:[s.jsx(KS,{}),s.jsxs(kN,{children:[s.jsx(Ie,{path:"/login",element:e?s.jsx(oa,{to:"/",replace:!0}):s.jsx(y2,{})}),s.jsxs(Ie,{path:"/",element:s.jsx(aC,{children:s.jsx(g2,{})}),children:[s.jsx(Ie,{index:!0,element:s.jsx(v2,{})}),s.jsx(Ie,{path:"customers",element:s.jsx(b2,{})}),s.jsx(Ie,{path:"customers/new",element:s.jsx(sx,{})}),s.jsx(Ie,{path:"customers/:id",element:s.jsx(D2,{})}),s.jsx(Ie,{path:"customers/:id/edit",element:s.jsx(sx,{})}),s.jsx(Ie,{path:"contracts",element:s.jsx(uk,{})}),s.jsx(Ie,{path:"contracts/cockpit",element:s.jsx(Dk,{})}),s.jsx(Ie,{path:"contracts/new",element:s.jsx(ax,{})}),s.jsx(Ie,{path:"contracts/:id",element:s.jsx(jk,{})}),s.jsx(Ie,{path:"contracts/:id/edit",element:s.jsx(ax,{})}),s.jsx(Ie,{path:"tasks",element:s.jsx(Ak,{})}),s.jsx(Ie,{path:"settings",element:s.jsx(sC,{})}),s.jsx(Ie,{path:"settings/users",element:s.jsx(eC,{})}),s.jsx(Ie,{path:"settings/platforms",element:s.jsx(Tk,{})}),s.jsx(Ie,{path:"settings/cancellation-periods",element:s.jsx(Lk,{})}),s.jsx(Ie,{path:"settings/contract-durations",element:s.jsx(Ok,{})}),s.jsx(Ie,{path:"settings/providers",element:s.jsx($k,{})}),s.jsx(Ie,{path:"settings/contract-categories",element:s.jsx(Vk,{})}),s.jsx(Ie,{path:"settings/view",element:s.jsx(Wk,{})}),s.jsx(Ie,{path:"settings/portal",element:s.jsx(Gk,{})}),s.jsx(Ie,{path:"settings/deadlines",element:s.jsx(Zk,{})}),s.jsx(Ie,{path:"settings/email-providers",element:s.jsx(Xk,{})}),s.jsx(Ie,{path:"settings/database-backup",element:s.jsx(Yk,{})}),s.jsx(Ie,{path:"users",element:s.jsx(oa,{to:"/settings/users",replace:!0})}),s.jsx(Ie,{path:"platforms",element:s.jsx(oa,{to:"/settings/platforms",replace:!0})}),s.jsx(Ie,{path:"developer/database",element:s.jsx(iC,{children:s.jsx(rC,{})})})]}),s.jsx(Ie,{path:"*",element:s.jsx(oa,{to:"/",replace:!0})})]})]})}const oC=new cw({defaultOptions:{queries:{retry:1,staleTime:0,gcTime:0,refetchOnMount:"always"}}});iu.createRoot(document.getElementById("root")).render(s.jsx(Pt.StrictMode,{children:s.jsx(uw,{client:oC,children:s.jsx(IN,{children:s.jsx(_S,{children:s.jsxs($S,{children:[s.jsx(lC,{}),s.jsx(c1,{position:"top-right",toastOptions:{duration:4e3,style:{background:"#363636",color:"#fff"},success:{iconTheme:{primary:"#10b981",secondary:"#fff"}},error:{iconTheme:{primary:"#ef4444",secondary:"#fff"}}}})]})})})})})); diff --git a/frontend/dist/assets/index-DWDTTlpk.css b/frontend/dist/assets/index-DWDTTlpk.css new file mode 100644 index 00000000..5cb41ab0 --- /dev/null +++ b/frontend/dist/assets/index-DWDTTlpk.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{top:0;bottom:0}.bottom-4{bottom:1rem}.bottom-6{bottom:1.5rem}.left-3{left:.75rem}.left-4{left:1rem}.right-0{right:0}.right-3{right:.75rem}.right-4{right:1rem}.right-6{right:1.5rem}.top-0{top:0}.top-1\/2{top:50%}.top-4{top:1rem}.z-10{z-index:10}.z-50{z-index:50}.col-span-2{grid-column:span 2 / span 2}.-mx-2{margin-left:-.5rem;margin-right:-.5rem}.-mx-6{margin-left:-1.5rem;margin-right:-1.5rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-3{margin-top:.75rem;margin-bottom:.75rem}.-mb-6{margin-bottom:-1.5rem}.-mb-px{margin-bottom:-1px}.-ml-1{margin-left:-.25rem}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-10{margin-left:2.5rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mr-4{margin-right:1rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-0\.5{height:.125rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-16{height:4rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-8{height:2rem}.h-\[85vh\]{height:85vh}.h-full{height:100%}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[600px\]{max-height:600px}.max-h-\[60vh\]{max-height:60vh}.max-h-\[90vh\]{max-height:90vh}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-1\/3{width:33.333333%}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-16{width:4rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-4{width:1rem}.w-40{width:10rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-8{width:2rem}.w-\[90vw\]{width:90vw}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[200px\]{min-width:200px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-none{max-width:none}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.space-x-8>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(2rem * var(--tw-space-x-reverse));margin-left:calc(2rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-200>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(229 231 235 / var(--tw-divide-opacity, 1))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-xl{border-radius:.75rem}.rounded-l-lg{border-top-left-radius:.5rem;border-bottom-left-radius:.5rem}.rounded-r-lg{border-top-right-radius:.5rem;border-bottom-right-radius:.5rem}.border{border-width:1px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-0{border-left-width:0px}.border-l-2{border-left-width:2px}.border-l-4{border-left-width:4px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-amber-300{--tw-border-opacity: 1;border-color:rgb(252 211 77 / var(--tw-border-opacity, 1))}.border-blue-100{--tw-border-opacity: 1;border-color:rgb(219 234 254 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-gray-400{--tw-border-opacity: 1;border-color:rgb(156 163 175 / var(--tw-border-opacity, 1))}.border-gray-800{--tw-border-opacity: 1;border-color:rgb(31 41 55 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-green-300{--tw-border-opacity: 1;border-color:rgb(134 239 172 / var(--tw-border-opacity, 1))}.border-purple-300{--tw-border-opacity: 1;border-color:rgb(216 180 254 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-300{--tw-border-opacity: 1;border-color:rgb(252 165 165 / var(--tw-border-opacity, 1))}.border-red-400{--tw-border-opacity: 1;border-color:rgb(248 113 113 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-red-600{--tw-border-opacity: 1;border-color:rgb(220 38 38 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.border-yellow-300{--tw-border-opacity: 1;border-color:rgb(253 224 71 / var(--tw-border-opacity, 1))}.border-l-blue-500{--tw-border-opacity: 1;border-left-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-l-gray-300{--tw-border-opacity: 1;border-left-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-t-transparent{border-top-color:transparent}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:#00000080}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-gray-50\/50{background-color:#f9fafb80}.bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-orange-500{--tw-bg-opacity: 1;background-color:rgb(249 115 22 / var(--tw-bg-opacity, 1))}.bg-purple-500{--tw-bg-opacity: 1;background-color:rgb(168 85 247 / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(147 51 234 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:transparent}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.bg-yellow-500{--tw-bg-opacity: 1;background-color:rgb(234 179 8 / var(--tw-bg-opacity, 1))}.bg-opacity-50{--tw-bg-opacity: .5}.fill-current{fill:currentColor}.\!p-4{padding:1rem!important}.p-0\.5{padding:.125rem}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-10{padding-left:2.5rem}.pl-3{padding-left:.75rem}.pr-10{padding-right:2.5rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-2xl{font-size:1.5rem;line-height:2rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-purple-300{--tw-text-opacity: 1;color:rgb(216 180 254 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.line-through{text-decoration-line:line-through}.opacity-0{opacity:0}.opacity-30{opacity:.3}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-blue-500{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity, 1))}.ring-gray-400{--tw-ring-opacity: 1;--tw-ring-color: rgb(156 163 175 / var(--tw-ring-opacity, 1))}.ring-offset-2{--tw-ring-offset-width: 2px}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-300{transition-duration:.3s}body{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:h-5:after{content:var(--tw-content);height:1.25rem}.after\:w-5:after{content:var(--tw-content);width:1.25rem}.after\:rounded-full:after{content:var(--tw-content);border-radius:9999px}.after\:border:after{content:var(--tw-content);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.after\:bg-white:after{content:var(--tw-content);--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.after\:content-\[\'\'\]:after{--tw-content: "";content:var(--tw-content)}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-blue-300:hover{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.hover\:border-gray-300:hover{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.hover\:border-gray-400:hover{--tw-border-opacity: 1;border-color:rgb(156 163 175 / var(--tw-border-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-300:hover{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.hover\:bg-opacity-50:hover{--tw-bg-opacity: .5}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\:text-blue-800:hover{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\:text-green-600:hover{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:text-red-700:hover{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.hover\:text-yellow-600:hover{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}.hover\:shadow-md:hover{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-blue-500:focus{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.focus\:border-red-500:focus{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.focus\:border-transparent:focus{border-color:transparent}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-blue-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity, 1))}.focus\:ring-gray-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(107 114 128 / var(--tw-ring-opacity, 1))}.focus\:ring-purple-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(168 85 247 / var(--tw-ring-opacity, 1))}.focus\:ring-red-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity, 1))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\:bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.group:hover .group-hover\:text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.group\/subtask:hover .group-hover\/subtask\:opacity-100,.group:hover .group-hover\:opacity-100{opacity:1}.peer:checked~.peer-checked\:bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.peer:checked~.peer-checked\:after\:translate-x-full:after{content:var(--tw-content);--tw-translate-x: 100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.peer:checked~.peer-checked\:after\:border-white:after{content:var(--tw-content);--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.peer:focus~.peer-focus\:outline-none{outline:2px solid transparent;outline-offset:2px}.peer:focus~.peer-focus\:ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.peer:focus~.peer-focus\:ring-blue-300{--tw-ring-opacity: 1;--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity, 1))}@media (min-width: 640px){.sm\:w-auto{width:auto}}@media (min-width: 768px){.md\:col-span-2{grid-column:span 2 / span 2}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:col-span-1{grid-column:span 1 / span 1}.lg\:col-span-2{grid-column:span 2 / span 2}.lg\:col-span-3{grid-column:span 3 / span 3}.lg\:block{display:block}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}} diff --git a/frontend/dist/assets/index-DxzmsVZ0.js b/frontend/dist/assets/index-DxzmsVZ0.js deleted file mode 100644 index 1e4ebc5b..00000000 --- a/frontend/dist/assets/index-DxzmsVZ0.js +++ /dev/null @@ -1,678 +0,0 @@ -var Rh=e=>{throw TypeError(e)};var bc=(e,t,n)=>t.has(e)||Rh("Cannot "+n);var D=(e,t,n)=>(bc(e,t,"read from private field"),n?n.call(e):t.get(e)),fe=(e,t,n)=>t.has(e)?Rh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ae=(e,t,n,r)=>(bc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ne=(e,t,n)=>(bc(e,t,"access private method"),n);var vl=(e,t,n,r)=>({set _(a){ae(e,t,a,n)},get _(){return D(e,t,r)}});function Y0(e,t){for(var n=0;nr[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 n(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=n(a);fetch(a.href,i)}})();function ev(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xx={exports:{}},Ko={},gx={exports:{}},Ee={};/** - * @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 sl=Symbol.for("react.element"),tv=Symbol.for("react.portal"),sv=Symbol.for("react.fragment"),nv=Symbol.for("react.strict_mode"),rv=Symbol.for("react.profiler"),av=Symbol.for("react.provider"),iv=Symbol.for("react.context"),lv=Symbol.for("react.forward_ref"),ov=Symbol.for("react.suspense"),cv=Symbol.for("react.memo"),uv=Symbol.for("react.lazy"),Oh=Symbol.iterator;function dv(e){return e===null||typeof e!="object"?null:(e=Oh&&e[Oh]||e["@@iterator"],typeof e=="function"?e:null)}var yx={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},vx=Object.assign,jx={};function $a(e,t,n){this.props=e,this.context=t,this.refs=jx,this.updater=n||yx}$a.prototype.isReactComponent={};$a.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")};$a.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function bx(){}bx.prototype=$a.prototype;function Pd(e,t,n){this.props=e,this.context=t,this.refs=jx,this.updater=n||yx}var Ad=Pd.prototype=new bx;Ad.constructor=Pd;vx(Ad,$a.prototype);Ad.isPureReactComponent=!0;var zh=Array.isArray,Nx=Object.prototype.hasOwnProperty,Md={current:null},wx={key:!0,ref:!0,__self:!0,__source:!0};function Sx(e,t,n){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)Nx.call(t,r)&&!wx.hasOwnProperty(r)&&(a[r]=t[r]);var o=arguments.length-2;if(o===1)a.children=n;else if(1>>1,oe=K[pe];if(0>>1;pea(Se,te))Mea(Qe,Se)?(K[pe]=Qe,K[Me]=te,pe=Me):(K[pe]=Se,K[Q]=te,pe=Q);else if(Mea(Qe,te))K[pe]=Qe,K[Me]=te,pe=Me;else break e}}return X}function a(K,X){var te=K.sortIndex-X.sortIndex;return te!==0?te:K.id-X.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,h=null,p=3,m=!1,f=!1,y=!1,w=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,g=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(K){for(var X=n(u);X!==null;){if(X.callback===null)r(u);else if(X.startTime<=K)r(u),X.sortIndex=X.expirationTime,t(c,X);else break;X=n(u)}}function b(K){if(y=!1,x(K),!f)if(n(c)!==null)f=!0,C(k);else{var X=n(u);X!==null&&N(b,X.startTime-K)}}function k(K,X){f=!1,y&&(y=!1,v(S),S=-1),m=!0;var te=p;try{for(x(X),h=n(c);h!==null&&(!(h.expirationTime>X)||K&&!z());){var pe=h.callback;if(typeof pe=="function"){h.callback=null,p=h.priorityLevel;var oe=pe(h.expirationTime<=X);X=e.unstable_now(),typeof oe=="function"?h.callback=oe:h===n(c)&&r(c),x(X)}else r(c);h=n(c)}if(h!==null)var Ge=!0;else{var Q=n(u);Q!==null&&N(b,Q.startTime-X),Ge=!1}return Ge}finally{h=null,p=te,m=!1}}var F=!1,E=null,S=-1,M=5,P=-1;function z(){return!(e.unstable_now()-PK||125pe?(K.sortIndex=te,t(u,K),n(c)===null&&K===n(u)&&(y?(v(S),S=-1):y=!0,N(b,te-pe))):(K.sortIndex=oe,t(c,K),f||m||(f=!0,C(k))),K},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(K){var X=p;return function(){var te=p;p=X;try{return K.apply(this,arguments)}finally{p=te}}}})(Px);Dx.exports=Px;var wv=Dx.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 Sv=j,ds=wv;function Z(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),iu=Object.prototype.hasOwnProperty,kv=/^[: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]*$/,_h={},Kh={};function Cv(e){return iu.call(Kh,e)?!0:iu.call(_h,e)?!1:kv.test(e)?Kh[e]=!0:(_h[e]=!0,!1)}function Ev(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Dv(e,t,n,r){if(t===null||typeof t>"u"||Ev(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.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 Qt(e,t,n,r,a,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Ft={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ft[e]=new Qt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ft[t]=new Qt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ft[e]=new Qt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ft[e]=new Qt(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){Ft[e]=new Qt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ft[e]=new Qt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ft[e]=new Qt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ft[e]=new Qt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ft[e]=new Qt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Fd=/[\-:]([a-z])/g;function Id(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(Fd,Id);Ft[t]=new Qt(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(Fd,Id);Ft[t]=new Qt(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(Fd,Id);Ft[t]=new Qt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ft[e]=new Qt(e,1,!1,e.toLowerCase(),null,!1,!1)});Ft.xlinkHref=new Qt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ft[e]=new Qt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ld(e,t,n,r){var a=Ft.hasOwnProperty(t)?Ft[t]:null;(a!==null?a.type!==0:r||!(2o||a[l]!==i[o]){var c=` -`+a[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Sc=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?li(e):""}function Pv(e){switch(e.tag){case 5:return li(e.type);case 16:return li("Lazy");case 13:return li("Suspense");case 19:return li("SuspenseList");case 0:case 2:case 15:return e=kc(e.type,!1),e;case 11:return e=kc(e.type.render,!1),e;case 1:return e=kc(e.type,!0),e;default:return""}}function uu(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 Jr:return"Fragment";case Zr:return"Portal";case lu:return"Profiler";case Rd:return"StrictMode";case ou:return"Suspense";case cu:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Tx:return(e.displayName||"Context")+".Consumer";case Mx:return(e._context.displayName||"Context")+".Provider";case Od:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case zd:return t=e.displayName||null,t!==null?t:uu(e.type)||"Memo";case An:t=e._payload,e=e._init;try{return uu(e(t))}catch{}}return null}function Av(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 uu(t);case 8:return t===Rd?"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 rr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ix(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Mv(e){var t=Ix(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var a=n.get,i=n.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:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Nl(e){e._valueTracker||(e._valueTracker=Mv(e))}function Lx(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Ix(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function ao(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 du(e,t){var n=t.checked;return et({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Bh(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=rr(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Rx(e,t){t=t.checked,t!=null&&Ld(e,"checked",t,!1)}function mu(e,t){Rx(e,t);var n=rr(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?hu(e,t.type,n):t.hasOwnProperty("defaultValue")&&hu(e,t.type,rr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function qh(e,t,n){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,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function hu(e,t,n){(t!=="number"||ao(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var oi=Array.isArray;function ca(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a"+t.valueOf().toString()+"",t=wl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ci(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var hi={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},Tv=["Webkit","ms","Moz","O"];Object.keys(hi).forEach(function(e){Tv.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),hi[t]=hi[e]})});function _x(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||hi.hasOwnProperty(e)&&hi[e]?(""+t).trim():t+"px"}function Kx(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=_x(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var Fv=et({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 xu(e,t){if(t){if(Fv[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Z(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Z(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Z(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Z(62))}}function gu(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 yu=null;function $d(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var vu=null,ua=null,da=null;function Hh(e){if(e=al(e)){if(typeof vu!="function")throw Error(Z(280));var t=e.stateNode;t&&(t=Qo(t),vu(e.stateNode,e.type,t))}}function Ux(e){ua?da?da.push(e):da=[e]:ua=e}function Bx(){if(ua){var e=ua,t=da;if(da=ua=null,Hh(e),t)for(e=0;e>>=0,e===0?32:31-(qv(e)/Vv|0)|0}var Sl=64,kl=4194304;function ci(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 co(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~a;o!==0?r=ci(o):(i&=l,i!==0&&(r=ci(i)))}else l=n&~a,l!==0?r=ci(l):i!==0&&(r=ci(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|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function nl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Is(t),e[t]=n}function Gv(e,t){var n=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=pi),sf=" ",nf=!1;function cg(e,t){switch(e){case"keyup":return wj.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ug(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xr=!1;function kj(e,t){switch(e){case"compositionend":return ug(t);case"keypress":return t.which!==32?null:(nf=!0,sf);case"textInput":return e=t.data,e===sf&&nf?null:e;default:return null}}function Cj(e,t){if(Xr)return e==="compositionend"||!Hd&&cg(e,t)?(e=lg(),ql=qd=Vn=null,Xr=!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)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=of(n)}}function fg(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?fg(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function pg(){for(var e=window,t=ao();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=ao(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 Lj(e){var t=pg(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&fg(n.ownerDocument.documentElement,n)){if(r!==null&&Wd(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=n.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=cf(n,i);var l=cf(n,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=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Yr=null,ku=null,gi=null,Cu=!1;function uf(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Cu||Yr==null||Yr!==ao(r)||(r=Yr,"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}),gi&&Ti(gi,r)||(gi=r,r=ho(ku,"onSelect"),0sa||(e.current=Tu[sa],Tu[sa]=null,sa--)}function Ke(e,t){sa++,Tu[sa]=e.current,e.current=t}var ar={},zt=or(ar),es=or(!1),Ir=ar;function Aa(e,t){var n=e.type.contextTypes;if(!n)return ar;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in n)a[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function ts(e){return e=e.childContextTypes,e!=null}function po(){Ve(es),Ve(zt)}function gf(e,t,n){if(zt.current!==ar)throw Error(Z(168));Ke(zt,t),Ke(es,n)}function Sg(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(Z(108,Av(e)||"Unknown",a));return et({},n,r)}function xo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ar,Ir=zt.current,Ke(zt,e),Ke(es,es.current),!0}function yf(e,t,n){var r=e.stateNode;if(!r)throw Error(Z(169));n?(e=Sg(e,t,Ir),r.__reactInternalMemoizedMergedChildContext=e,Ve(es),Ve(zt),Ke(zt,e)):Ve(es),Ke(es,n)}var rn=null,Ho=!1,$c=!1;function kg(e){rn===null?rn=[e]:rn.push(e)}function Hj(e){Ho=!0,kg(e)}function cr(){if(!$c&&rn!==null){$c=!0;var e=0,t=Re;try{var n=rn;for(Re=1;e>=l,a-=l,dn=1<<32-Is(t)+a|n<S?(M=E,E=null):M=E.sibling;var P=p(v,E,x[S],b);if(P===null){E===null&&(E=M);break}e&&E&&P.alternate===null&&t(v,E),g=i(P,g,S),F===null?k=P:F.sibling=P,F=P,E=M}if(S===x.length)return n(v,E),We&&mr(v,S),k;if(E===null){for(;SS?(M=E,E=null):M=E.sibling;var z=p(v,E,P.value,b);if(z===null){E===null&&(E=M);break}e&&E&&z.alternate===null&&t(v,E),g=i(z,g,S),F===null?k=z:F.sibling=z,F=z,E=M}if(P.done)return n(v,E),We&&mr(v,S),k;if(E===null){for(;!P.done;S++,P=x.next())P=h(v,P.value,b),P!==null&&(g=i(P,g,S),F===null?k=P:F.sibling=P,F=P);return We&&mr(v,S),k}for(E=r(v,E);!P.done;S++,P=x.next())P=m(E,v,S,P.value,b),P!==null&&(e&&P.alternate!==null&&E.delete(P.key===null?S:P.key),g=i(P,g,S),F===null?k=P:F.sibling=P,F=P);return e&&E.forEach(function(L){return t(v,L)}),We&&mr(v,S),k}function w(v,g,x,b){if(typeof x=="object"&&x!==null&&x.type===Jr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case bl:e:{for(var k=x.key,F=g;F!==null;){if(F.key===k){if(k=x.type,k===Jr){if(F.tag===7){n(v,F.sibling),g=a(F,x.props.children),g.return=v,v=g;break e}}else if(F.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===An&&bf(k)===F.type){n(v,F.sibling),g=a(F,x.props),g.ref=si(v,F,x),g.return=v,v=g;break e}n(v,F);break}else t(v,F);F=F.sibling}x.type===Jr?(g=Mr(x.props.children,v.mode,b,x.key),g.return=v,v=g):(b=Xl(x.type,x.key,x.props,null,v.mode,b),b.ref=si(v,g,x),b.return=v,v=b)}return l(v);case Zr:e:{for(F=x.key;g!==null;){if(g.key===F)if(g.tag===4&&g.stateNode.containerInfo===x.containerInfo&&g.stateNode.implementation===x.implementation){n(v,g.sibling),g=a(g,x.children||[]),g.return=v,v=g;break e}else{n(v,g);break}else t(v,g);g=g.sibling}g=Hc(x,v.mode,b),g.return=v,v=g}return l(v);case An:return F=x._init,w(v,g,F(x._payload),b)}if(oi(x))return f(v,g,x,b);if(Ja(x))return y(v,g,x,b);Tl(v,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,g!==null&&g.tag===6?(n(v,g.sibling),g=a(g,x),g.return=v,v=g):(n(v,g),g=Qc(x,v.mode,b),g.return=v,v=g),l(v)):n(v,g)}return w}var Ta=Pg(!0),Ag=Pg(!1),vo=or(null),jo=null,aa=null,Xd=null;function Yd(){Xd=aa=jo=null}function em(e){var t=vo.current;Ve(vo),e._currentValue=t}function Lu(e,t,n){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===n)break;e=e.return}}function ha(e,t){jo=e,Xd=aa=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Yt=!0),e.firstContext=null)}function Ns(e){var t=e._currentValue;if(Xd!==e)if(e={context:e,memoizedValue:t,next:null},aa===null){if(jo===null)throw Error(Z(308));aa=e,jo.dependencies={lanes:0,firstContext:e}}else aa=aa.next=e;return t}var xr=null;function tm(e){xr===null?xr=[e]:xr.push(e)}function Mg(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,tm(t)):(n.next=a.next,a.next=n),t.interleaved=n,yn(e,r)}function yn(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Mn=!1;function sm(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Tg(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 fn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Xn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Te&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,yn(e,n)}return a=r.interleaved,a===null?(t.next=t,tm(r)):(t.next=a.next,a.next=t),r.interleaved=t,yn(e,n)}function Ql(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Kd(e,n)}}function Nf(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?a=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?a=i=t:i=i.next=t}else a=i=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function bo(e,t,n,r){var a=e.updateQueue;Mn=!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 h=a.baseState;l=0,d=u=c=null,o=i;do{var p=o.lane,m=o.eventTime;if((r&p)===p){d!==null&&(d=d.next={eventTime:m,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var f=e,y=o;switch(p=t,m=n,y.tag){case 1:if(f=y.payload,typeof f=="function"){h=f.call(m,h,p);break e}h=f;break e;case 3:f.flags=f.flags&-65537|128;case 0:if(f=y.payload,p=typeof f=="function"?f.call(m,h,p):f,p==null)break e;h=et({},h,p);break e;case 2:Mn=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=a.effects,p===null?a.effects=[o]:p.push(o))}else m={eventTime:m,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=m,c=h):d=d.next=m,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=h),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);Or|=l,e.lanes=l,e.memoizedState=h}}function wf(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Kc.transition;Kc.transition={};try{e(!1),t()}finally{Re=n,Kc.transition=r}}function Gg(){return ws().memoizedState}function Jj(e,t,n){var r=er(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Zg(e))Jg(t,n);else if(n=Mg(e,t,n,r),n!==null){var a=qt();Ls(n,e,r,a),Xg(n,t,r)}}function Xj(e,t,n){var r=er(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Zg(e))Jg(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,n);if(a.hasEagerState=!0,a.eagerState=o,Rs(o,l)){var c=t.interleaved;c===null?(a.next=a,tm(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=Mg(e,t,a,r),n!==null&&(a=qt(),Ls(n,e,r,a),Xg(n,t,r))}}function Zg(e){var t=e.alternate;return e===Xe||t!==null&&t===Xe}function Jg(e,t){yi=wo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Xg(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Kd(e,n)}}var So={readContext:Ns,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Yj={readContext:Ns,useCallback:function(e,t){return _s().memoizedState=[e,t===void 0?null:t],e},useContext:Ns,useEffect:kf,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Wl(4194308,4,qg.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Wl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Wl(4,2,e,t)},useMemo:function(e,t){var n=_s();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=_s();return t=n!==void 0?n(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=Jj.bind(null,Xe,e),[r.memoizedState,e]},useRef:function(e){var t=_s();return e={current:e},t.memoizedState=e},useState:Sf,useDebugValue:um,useDeferredValue:function(e){return _s().memoizedState=e},useTransition:function(){var e=Sf(!1),t=e[0];return e=Zj.bind(null,e[1]),_s().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Xe,a=_s();if(We){if(n===void 0)throw Error(Z(407));n=n()}else{if(n=t(),Et===null)throw Error(Z(349));Rr&30||Rg(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,kf(zg.bind(null,r,i,e),[e]),r.flags|=2048,_i(9,Og.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=_s(),t=Et.identifierPrefix;if(We){var n=mn,r=dn;n=(r&~(1<<32-Is(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=zi++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Vs]=t,e[Li]=r,oy(e,t,!1,!1),t.stateNode=e;e:{switch(l=gu(n,r),n){case"dialog":Be("cancel",e),Be("close",e),a=r;break;case"iframe":case"object":case"embed":Be("load",e),a=r;break;case"video":case"audio":for(a=0;aLa&&(t.flags|=128,r=!0,ni(i,!1),t.lanes=4194304)}else{if(!r)if(e=No(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ni(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!We)return Lt(t),null}else 2*ot()-i.renderingStartTime>La&&n!==1073741824&&(t.flags|=128,r=!0,ni(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=ot(),t.sibling=null,n=Je.current,Ke(Je,r?n&1|2:n&1),t):(Lt(t),null);case 22:case 23:return xm(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?as&1073741824&&(Lt(t),t.subtreeFlags&6&&(t.flags|=8192)):Lt(t),null;case 24:return null;case 25:return null}throw Error(Z(156,t.tag))}function lb(e,t){switch(Zd(t),t.tag){case 1:return ts(t.type)&&po(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Fa(),Ve(es),Ve(zt),am(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return rm(t),null;case 13:if(Ve(Je),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Z(340));Ma()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ve(Je),null;case 4:return Fa(),null;case 10:return em(t.type._context),null;case 22:case 23:return xm(),null;case 24:return null;default:return null}}var Il=!1,Rt=!1,ob=typeof WeakSet=="function"?WeakSet:Set,le=null;function ia(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){at(e,t,r)}else n.current=null}function qu(e,t,n){try{n()}catch(r){at(e,t,r)}}var Rf=!1;function cb(e,t){if(Eu=uo,e=pg(),Wd(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,u=0,d=0,h=e,p=null;t:for(;;){for(var m;h!==n||a!==0&&h.nodeType!==3||(o=l+a),h!==i||r!==0&&h.nodeType!==3||(c=l+r),h.nodeType===3&&(l+=h.nodeValue.length),(m=h.firstChild)!==null;)p=h,h=m;for(;;){if(h===e)break t;if(p===n&&++u===a&&(o=l),p===i&&++d===r&&(c=l),(m=h.nextSibling)!==null)break;h=p,p=h.parentNode}h=m}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Du={focusedElem:e,selectionRange:n},uo=!1,le=t;le!==null;)if(t=le,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,le=e;else for(;le!==null;){t=le;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 y=f.memoizedProps,w=f.memoizedState,v=t.stateNode,g=v.getSnapshotBeforeUpdate(t.elementType===t.type?y:Cs(t.type,y),w);v.__reactInternalSnapshotBeforeUpdate=g}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(Z(163))}}catch(b){at(t,t.return,b)}if(e=t.sibling,e!==null){e.return=t.return,le=e;break}le=t.return}return f=Rf,Rf=!1,f}function vi(e,t,n){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&&qu(t,n,i)}a=a.next}while(a!==r)}}function Zo(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Vu(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function dy(e){var t=e.alternate;t!==null&&(e.alternate=null,dy(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Vs],delete t[Li],delete t[Mu],delete t[Vj],delete t[Qj])),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 my(e){return e.tag===5||e.tag===3||e.tag===4}function Of(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||my(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 Qu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=fo));else if(r!==4&&(e=e.child,e!==null))for(Qu(e,t,n),e=e.sibling;e!==null;)Qu(e,t,n),e=e.sibling}function Hu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Hu(e,t,n),e=e.sibling;e!==null;)Hu(e,t,n),e=e.sibling}var Pt=null,Ps=!1;function Dn(e,t,n){for(n=n.child;n!==null;)hy(e,t,n),n=n.sibling}function hy(e,t,n){if(Ws&&typeof Ws.onCommitFiberUnmount=="function")try{Ws.onCommitFiberUnmount(Uo,n)}catch{}switch(n.tag){case 5:Rt||ia(n,t);case 6:var r=Pt,a=Ps;Pt=null,Dn(e,t,n),Pt=r,Ps=a,Pt!==null&&(Ps?(e=Pt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pt.removeChild(n.stateNode));break;case 18:Pt!==null&&(Ps?(e=Pt,n=n.stateNode,e.nodeType===8?zc(e.parentNode,n):e.nodeType===1&&zc(e,n),Ai(e)):zc(Pt,n.stateNode));break;case 4:r=Pt,a=Ps,Pt=n.stateNode.containerInfo,Ps=!0,Dn(e,t,n),Pt=r,Ps=a;break;case 0:case 11:case 14:case 15:if(!Rt&&(r=n.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)&&qu(n,t,l),a=a.next}while(a!==r)}Dn(e,t,n);break;case 1:if(!Rt&&(ia(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){at(n,t,o)}Dn(e,t,n);break;case 21:Dn(e,t,n);break;case 22:n.mode&1?(Rt=(r=Rt)||n.memoizedState!==null,Dn(e,t,n),Rt=r):Dn(e,t,n);break;default:Dn(e,t,n)}}function zf(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ob),t.forEach(function(r){var a=yb.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function ks(e,t){var n=t.deletions;if(n!==null)for(var r=0;ra&&(a=l),r&=~i}if(r=a,r=ot()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*db(r/1960))-r,10e?16:e,Qn===null)var r=!1;else{if(e=Qn,Qn=null,Eo=0,Te&6)throw Error(Z(331));var a=Te;for(Te|=4,le=e.current;le!==null;){var i=le,l=i.child;if(le.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cot()-fm?Ar(e,0):hm|=n),ss(e,t)}function by(e,t){t===0&&(e.mode&1?(t=kl,kl<<=1,!(kl&130023424)&&(kl=4194304)):t=1);var n=qt();e=yn(e,t),e!==null&&(nl(e,t,n),ss(e,n))}function gb(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),by(e,n)}function yb(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Z(314))}r!==null&&r.delete(t),by(e,n)}var Ny;Ny=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||es.current)Yt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Yt=!1,ab(e,t,n);Yt=!!(e.flags&131072)}else Yt=!1,We&&t.flags&1048576&&Cg(t,yo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Gl(e,t),e=t.pendingProps;var a=Aa(t,zt.current);ha(t,n),a=lm(null,t,r,e,a,n);var i=om();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,ts(r)?(i=!0,xo(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,sm(t),a.updater=Go,t.stateNode=a,a._reactInternals=t,Ou(t,r,e,n),t=_u(null,t,r,!0,i,n)):(t.tag=0,We&&i&&Gd(t),Ut(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Gl(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=jb(r),e=Cs(r,e),a){case 0:t=$u(null,t,r,e,n);break e;case 1:t=Ff(null,t,r,e,n);break e;case 11:t=Mf(null,t,r,e,n);break e;case 14:t=Tf(null,t,r,Cs(r.type,e),n);break e}throw Error(Z(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Cs(r,a),$u(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Cs(r,a),Ff(e,t,r,a,n);case 3:e:{if(ay(t),e===null)throw Error(Z(387));r=t.pendingProps,i=t.memoizedState,a=i.element,Tg(e,t),bo(t,r,null,n);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=Ia(Error(Z(423)),t),t=If(e,t,r,n,a);break e}else if(r!==a){a=Ia(Error(Z(424)),t),t=If(e,t,r,n,a);break e}else for(cs=Jn(t.stateNode.containerInfo.firstChild),us=t,We=!0,As=null,n=Ag(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ma(),r===a){t=vn(e,t,n);break e}Ut(e,t,r,n)}t=t.child}return t;case 5:return Fg(t),e===null&&Iu(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,l=a.children,Pu(r,a)?l=null:i!==null&&Pu(r,i)&&(t.flags|=32),ry(e,t),Ut(e,t,l,n),t.child;case 6:return e===null&&Iu(t),null;case 13:return iy(e,t,n);case 4:return nm(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ta(t,null,r,n):Ut(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Cs(r,a),Mf(e,t,r,a,n);case 7:return Ut(e,t,t.pendingProps,n),t.child;case 8:return Ut(e,t,t.pendingProps.children,n),t.child;case 12:return Ut(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,i=t.memoizedProps,l=a.value,Ke(vo,r._currentValue),r._currentValue=l,i!==null)if(Rs(i.value,l)){if(i.children===a.children&&!es.current){t=vn(e,t,n);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=fn(-1,n&-n),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|=n,c=i.alternate,c!==null&&(c.lanes|=n),Lu(i.return,n,t),o.lanes|=n;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(Z(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),Lu(l,n,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}Ut(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,ha(t,n),a=Ns(a),r=r(a),t.flags|=1,Ut(e,t,r,n),t.child;case 14:return r=t.type,a=Cs(r,t.pendingProps),a=Cs(r.type,a),Tf(e,t,r,a,n);case 15:return sy(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Cs(r,a),Gl(e,t),t.tag=1,ts(r)?(e=!0,xo(t)):e=!1,ha(t,n),Yg(t,r,a),Ou(t,r,a,n),_u(null,t,r,!0,e,n);case 19:return ly(e,t,n);case 22:return ny(e,t,n)}throw Error(Z(156,t.tag))};function wy(e,t){return Zx(e,t)}function vb(e,t,n,r){this.tag=e,this.key=n,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 vs(e,t,n,r){return new vb(e,t,n,r)}function ym(e){return e=e.prototype,!(!e||!e.isReactComponent)}function jb(e){if(typeof e=="function")return ym(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Od)return 11;if(e===zd)return 14}return 2}function tr(e,t){var n=e.alternate;return n===null?(n=vs(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Xl(e,t,n,r,a,i){var l=2;if(r=e,typeof e=="function")ym(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Jr:return Mr(n.children,a,i,t);case Rd:l=8,a|=8;break;case lu:return e=vs(12,n,t,a|2),e.elementType=lu,e.lanes=i,e;case ou:return e=vs(13,n,t,a),e.elementType=ou,e.lanes=i,e;case cu:return e=vs(19,n,t,a),e.elementType=cu,e.lanes=i,e;case Fx:return Xo(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Mx:l=10;break e;case Tx:l=9;break e;case Od:l=11;break e;case zd:l=14;break e;case An:l=16,r=null;break e}throw Error(Z(130,e==null?e:typeof e,""))}return t=vs(l,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function Mr(e,t,n,r){return e=vs(7,e,r,t),e.lanes=n,e}function Xo(e,t,n,r){return e=vs(22,e,r,t),e.elementType=Fx,e.lanes=n,e.stateNode={isHidden:!1},e}function Qc(e,t,n){return e=vs(6,e,null,t),e.lanes=n,e}function Hc(e,t,n){return t=vs(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function bb(e,t,n,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=Ec(0),this.expirationTimes=Ec(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ec(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function vm(e,t,n,r,a,i,l,o,c){return e=new bb(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=vs(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},sm(i),e}function Nb(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ey)}catch(e){console.error(e)}}Ey(),Ex.exports=ms;var Eb=Ex.exports,Qf=Eb;au.createRoot=Qf.createRoot,au.hydrateRoot=Qf.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 Ui(){return Ui=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function wm(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Pb(){return Math.random().toString(36).substr(2,8)}function Wf(e,t){return{usr:e.state,key:e.key,idx:t}}function Xu(e,t,n,r){return n===void 0&&(n=null),Ui({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Ua(t):t,{state:n,key:t&&t.key||r||Pb()})}function Ao(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function Ua(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function Ab(e,t,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,l=a.history,o=Hn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Ui({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function h(){o=Hn.Pop;let w=d(),v=w==null?null:w-u;u=w,c&&c({action:o,location:y.location,delta:v})}function p(w,v){o=Hn.Push;let g=Xu(y.location,w,v);u=d()+1;let x=Wf(g,u),b=y.createHref(g);try{l.pushState(x,"",b)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;a.location.assign(b)}i&&c&&c({action:o,location:y.location,delta:1})}function m(w,v){o=Hn.Replace;let g=Xu(y.location,w,v);u=d();let x=Wf(g,u),b=y.createHref(g);l.replaceState(x,"",b),i&&c&&c({action:o,location:y.location,delta:0})}function f(w){let v=a.location.origin!=="null"?a.location.origin:a.location.href,g=typeof w=="string"?w:Ao(w);return g=g.replace(/ $/,"%20"),Ye(v,"No window.location.(origin|href) available to create URL for href: "+g),new URL(g,v)}let y={get action(){return o},get location(){return e(a,l)},listen(w){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(Hf,h),c=w,()=>{a.removeEventListener(Hf,h),c=null}},createHref(w){return t(a,w)},createURL:f,encodeLocation(w){let v=f(w);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:p,replace:m,go(w){return l.go(w)}};return y}var Gf;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Gf||(Gf={}));function Mb(e,t,n){return n===void 0&&(n="/"),Tb(e,t,n)}function Tb(e,t,n,r){let a=typeof t=="string"?Ua(t):t,i=Ra(a.pathname||"/",n);if(i==null)return null;let l=Dy(e);Fb(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(Ye(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=sr([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(Ye(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),Dy(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:_b(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 Py(i.path))a(i,l,c)}),t}function Py(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let l=Py(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 Fb(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Kb(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const Ib=/^:[\w-]+$/,Lb=3,Rb=2,Ob=1,zb=10,$b=-2,Zf=e=>e==="*";function _b(e,t){let n=e.split("/"),r=n.length;return n.some(Zf)&&(r+=$b),t&&(r+=Rb),n.filter(a=>!Zf(a)).reduce((a,i)=>a+(Ib.test(i)?Lb:i===""?Ob:zb),r)}function Kb(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 Ub(e,t,n){let{routesMeta:r}=e,a={},i="/",l=[];for(let o=0;o{let{paramName:p,isOptional:m}=d;if(p==="*"){let y=o[h]||"";l=i.slice(0,i.length-y.length).replace(/(.)\/+$/,"$1")}const f=o[h];return m&&!f?u[p]=void 0:u[p]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function Bb(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),wm(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==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function qb(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return wm(!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 Ra(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Vb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Qb=e=>Vb.test(e);function Hb(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?Ua(e):e,i;if(n)if(Qb(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),wm(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=Jf(n.substring(1),"/"):i=Jf(n,t)}else i=t;return{pathname:i,search:Zb(r),hash:Jb(a)}}function Jf(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Wc(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Wb(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Sm(e,t){let n=Wb(e);return t?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function km(e,t,n,r){r===void 0&&(r=!1);let a;typeof e=="string"?a=Ua(e):(a=Ui({},e),Ye(!a.pathname||!a.pathname.includes("?"),Wc("?","pathname","search",a)),Ye(!a.pathname||!a.pathname.includes("#"),Wc("#","pathname","hash",a)),Ye(!a.search||!a.search.includes("#"),Wc("#","search","hash",a)));let i=e===""||a.pathname==="",l=i?"/":a.pathname,o;if(l==null)o=n;else{let h=t.length-1;if(!r&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),h-=1;a.pathname=p.join("/")}o=h>=0?t[h]:"/"}let c=Hb(a,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const sr=e=>e.join("/").replace(/\/\/+/g,"/"),Gb=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Zb=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Jb=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Xb(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Ay=["post","put","patch","delete"];new Set(Ay);const Yb=["get",...Ay];new Set(Yb);/** - * 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 Bi(){return Bi=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),j.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let h=km(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:sr([t,h.pathname])),(d.replace?r.replace:r.push)(h,d.state,d)},[t,r,l,i,e])}const sN=j.createContext(null);function nN(e){let t=j.useContext(Js).outlet;return t&&j.createElement(sN.Provider,{value:e},t)}function ac(){let{matches:e}=j.useContext(Js),t=e[e.length-1];return t?t.params:{}}function ic(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(Sn),{matches:a}=j.useContext(Js),{pathname:i}=kn(),l=JSON.stringify(Sm(a,r.v7_relativeSplatPath));return j.useMemo(()=>km(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function rN(e,t){return aN(e,t)}function aN(e,t,n,r){Ba()||Ye(!1);let{navigator:a}=j.useContext(Sn),{matches:i}=j.useContext(Js),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=kn(),d;if(t){var h;let w=typeof t=="string"?Ua(t):t;c==="/"||(h=w.pathname)!=null&&h.startsWith(c)||Ye(!1),d=w}else d=u;let p=d.pathname||"/",m=p;if(c!=="/"){let w=c.replace(/^\//,"").split("/");m="/"+p.replace(/^\//,"").split("/").slice(w.length).join("/")}let f=Mb(e,{pathname:m}),y=uN(f&&f.map(w=>Object.assign({},w,{params:Object.assign({},o,w.params),pathname:sr([c,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?c:sr([c,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),i,n,r);return t&&y?j.createElement(rc.Provider,{value:{location:Bi({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:Hn.Pop}},y):y}function iN(){let e=fN(),t=Xb(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:a},n):null,null)}const lN=j.createElement(iN,null);class oN extends j.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,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(Js.Provider,{value:this.props.routeContext},j.createElement(Ty.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function cN(e){let{routeContext:t,match:n,children:r}=e,a=j.useContext(nc);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(Js.Provider,{value:t},r)}function uN(e,t,n,r){var a;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(a=n)==null?void 0:a.errors;if(o!=null){let d=l.findIndex(h=>h.route.id&&(o==null?void 0:o[h.route.id])!==void 0);d>=0||Ye(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,h,p)=>{let m,f=!1,y=null,w=null;n&&(m=o&&h.route.id?o[h.route.id]:void 0,y=h.route.errorElement||lN,c&&(u<0&&p===0?(xN("route-fallback"),f=!0,w=null):u===p&&(f=!0,w=h.route.hydrateFallbackElement||null)));let v=t.concat(l.slice(0,p+1)),g=()=>{let x;return m?x=y:f?x=w:h.route.Component?x=j.createElement(h.route.Component,null):h.route.element?x=h.route.element:x=d,j.createElement(cN,{match:h,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:x})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?j.createElement(oN,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:g(),routeContext:{outlet:null,matches:v,isDataRoute:!0}}):g()},null)}var Iy=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Iy||{}),Ly=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}(Ly||{});function dN(e){let t=j.useContext(nc);return t||Ye(!1),t}function mN(e){let t=j.useContext(My);return t||Ye(!1),t}function hN(e){let t=j.useContext(Js);return t||Ye(!1),t}function Ry(e){let t=hN(),n=t.matches[t.matches.length-1];return n.route.id||Ye(!1),n.route.id}function fN(){var e;let t=j.useContext(Ty),n=mN(),r=Ry();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function pN(){let{router:e}=dN(Iy.UseNavigateStable),t=Ry(Ly.UseNavigateStable),n=j.useRef(!1);return Fy(()=>{n.current=!0}),j.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,Bi({fromRouteId:t},i)))},[e,t])}const Xf={};function xN(e,t,n){Xf[e]||(Xf[e]=!0)}function gN(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function oa(e){let{to:t,replace:n,state:r,relative:a}=e;Ba()||Ye(!1);let{future:i,static:l}=j.useContext(Sn),{matches:o}=j.useContext(Js),{pathname:c}=kn(),u=Ht(),d=km(t,Sm(o,i.v7_relativeSplatPath),c,a==="path"),h=JSON.stringify(d);return j.useEffect(()=>u(JSON.parse(h),{replace:n,state:r,relative:a}),[u,h,a,n,r]),null}function yN(e){return nN(e.context)}function Ie(e){Ye(!1)}function vN(e){let{basename:t="/",children:n=null,location:r,navigationType:a=Hn.Pop,navigator:i,static:l=!1,future:o}=e;Ba()&&Ye(!1);let c=t.replace(/^\/*/,"/"),u=j.useMemo(()=>({basename:c,navigator:i,static:l,future:Bi({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=Ua(r));let{pathname:d="/",search:h="",hash:p="",state:m=null,key:f="default"}=r,y=j.useMemo(()=>{let w=Ra(d,c);return w==null?null:{location:{pathname:w,search:h,hash:p,state:m,key:f},navigationType:a}},[c,d,h,p,m,f,a]);return y==null?null:j.createElement(Sn.Provider,{value:u},j.createElement(rc.Provider,{children:n,value:y}))}function jN(e){let{children:t,location:n}=e;return rN(ed(t),n)}new Promise(()=>{});function ed(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,a)=>{if(!j.isValidElement(r))return;let i=[...t,a];if(r.type===j.Fragment){n.push.apply(n,ed(r.props.children,i));return}r.type!==Ie&&Ye(!1),!r.props.index||!r.props.children||Ye(!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=ed(r.props.children,i)),n.push(l)}),n}/** - * React Router DOM v6.30.3 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function Mo(){return Mo=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[a]=e[a]);return n}function bN(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function NN(e,t){return e.button===0&&(!t||t==="_self")&&!bN(e)}function td(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function wN(e,t){let n=td(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}const SN=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],kN=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],CN="6";try{window.__reactRouterVersion=CN}catch{}const EN=j.createContext({isTransitioning:!1}),DN="startTransition",Yf=xv[DN];function PN(e){let{basename:t,children:n,future:r,window:a}=e,i=j.useRef();i.current==null&&(i.current=Db({window:a,v5Compat:!0}));let l=i.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=j.useCallback(h=>{u&&Yf?Yf(()=>c(h)):c(h)},[c,u]);return j.useLayoutEffect(()=>l.listen(d),[l,d]),j.useEffect(()=>gN(r),[r]),j.createElement(vN,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const AN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",MN=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,we=j.forwardRef(function(t,n){let{onClick:r,relative:a,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:h}=t,p=Oy(t,SN),{basename:m}=j.useContext(Sn),f,y=!1;if(typeof u=="string"&&MN.test(u)&&(f=u,AN))try{let x=new URL(window.location.href),b=u.startsWith("//")?new URL(x.protocol+u):new URL(u),k=Ra(b.pathname,m);b.origin===x.origin&&k!=null?u=k+b.search+b.hash:y=!0}catch{}let w=eN(u,{relative:a}),v=FN(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:a,viewTransition:h});function g(x){r&&r(x),x.defaultPrevented||v(x)}return j.createElement("a",Mo({},p,{href:f||w,onClick:y||i?r:g,ref:n,target:c}))}),Gc=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:a=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,h=Oy(t,kN),p=ic(c,{relative:h.relative}),m=kn(),f=j.useContext(My),{navigator:y,basename:w}=j.useContext(Sn),v=f!=null&&IN(p)&&u===!0,g=y.encodeLocation?y.encodeLocation(p).pathname:p.pathname,x=m.pathname,b=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;a||(x=x.toLowerCase(),b=b?b.toLowerCase():null,g=g.toLowerCase()),b&&w&&(b=Ra(b,w)||b);const k=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let F=x===g||!l&&x.startsWith(g)&&x.charAt(k)==="/",E=b!=null&&(b===g||!l&&b.startsWith(g)&&b.charAt(g.length)==="/"),S={isActive:F,isPending:E,isTransitioning:v},M=F?r:void 0,P;typeof i=="function"?P=i(S):P=[i,F?"active":null,E?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let z=typeof o=="function"?o(S):o;return j.createElement(we,Mo({},h,{"aria-current":M,className:P,ref:n,style:z,to:c,viewTransition:u}),typeof d=="function"?d(S):d)});var sd;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(sd||(sd={}));var ep;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(ep||(ep={}));function TN(e){let t=j.useContext(nc);return t||Ye(!1),t}function FN(e,t){let{target:n,replace:r,state:a,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Ht(),u=kn(),d=ic(e,{relative:l});return j.useCallback(h=>{if(NN(h,n)){h.preventDefault();let p=r!==void 0?r:Ao(u)===Ao(d);c(e,{replace:p,state:a,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,a,n,e,i,l,o])}function lc(e){let t=j.useRef(td(e)),n=j.useRef(!1),r=kn(),a=j.useMemo(()=>wN(r.search,n.current?null:t.current),[r.search]),i=Ht(),l=j.useCallback((o,c)=>{const u=td(typeof o=="function"?o(a):o);n.current=!0,i("?"+u,c)},[i,a]);return[a,l]}function IN(e,t){t===void 0&&(t={});let n=j.useContext(EN);n==null&&Ye(!1);let{basename:r}=TN(sd.useViewTransitionState),a=ic(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Ra(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Ra(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Yu(a.pathname,l)!=null||Yu(a.pathname,i)!=null}var qa=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(){}},LN={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Rn,Dd,ax,RN=(ax=class{constructor(){fe(this,Rn,LN);fe(this,Dd,!1)}setTimeoutProvider(e){ae(this,Rn,e)}setTimeout(e,t){return D(this,Rn).setTimeout(e,t)}clearTimeout(e){D(this,Rn).clearTimeout(e)}setInterval(e,t){return D(this,Rn).setInterval(e,t)}clearInterval(e){D(this,Rn).clearInterval(e)}},Rn=new WeakMap,Dd=new WeakMap,ax),yr=new RN;function ON(e){setTimeout(e,0)}var $r=typeof window>"u"||"Deno"in globalThis;function Bt(){}function zN(e,t){return typeof e=="function"?e(t):e}function nd(e){return typeof e=="number"&&e>=0&&e!==1/0}function zy(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nr(e,t){return typeof e=="function"?e(t):e}function xs(e,t){return typeof e=="function"?e(t):e}function tp(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Cm(l,t.options))return!1}else if(!qi(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||a&&a!==t.state.fetchStatus||i&&!i(t))}function sp(e,t){const{exact:n,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(_r(t.options.mutationKey)!==_r(i))return!1}else if(!qi(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function Cm(e,t){return((t==null?void 0:t.queryKeyHashFn)||_r)(e)}function _r(e){return JSON.stringify(e,(t,n)=>rd(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function qi(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>qi(e[n],t[n])):!1}var $N=Object.prototype.hasOwnProperty;function $y(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=np(e)&&np(t);if(!r&&!(rd(e)&&rd(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{yr.setTimeout(t,e)})}function ad(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?$y(e,t):t}function KN(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function UN(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Em=Symbol();function _y(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Em?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Dm(e,t){return typeof e=="function"?e(...t):!!e}function BN(e,t,n){let r=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),r||(r=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var br,On,ga,ix,qN=(ix=class extends qa{constructor(){super();fe(this,br);fe(this,On);fe(this,ga);ae(this,ga,t=>{if(!$r&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){D(this,On)||this.setEventListener(D(this,ga))}onUnsubscribe(){var t;this.hasListeners()||((t=D(this,On))==null||t.call(this),ae(this,On,void 0))}setEventListener(t){var n;ae(this,ga,t),(n=D(this,On))==null||n.call(this),ae(this,On,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){D(this,br)!==t&&(ae(this,br,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof D(this,br)=="boolean"?D(this,br):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},br=new WeakMap,On=new WeakMap,ga=new WeakMap,ix),Pm=new qN;function id(){let e,t;const n=new Promise((a,i)=>{e=a,t=i});n.status="pending",n.catch(()=>{});function r(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},n.reject=a=>{r({status:"rejected",reason:a}),t(a)},n}var VN=ON;function QN(){let e=[],t=0,n=o=>{o()},r=o=>{o()},a=VN;const i=o=>{t?e.push(o):a(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&a(()=>{r(()=>{o.forEach(c=>{n(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=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{a=o}}}var gt=QN(),ya,zn,va,lx,HN=(lx=class extends qa{constructor(){super();fe(this,ya,!0);fe(this,zn);fe(this,va);ae(this,va,t=>{if(!$r&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){D(this,zn)||this.setEventListener(D(this,va))}onUnsubscribe(){var t;this.hasListeners()||((t=D(this,zn))==null||t.call(this),ae(this,zn,void 0))}setEventListener(t){var n;ae(this,va,t),(n=D(this,zn))==null||n.call(this),ae(this,zn,t(this.setOnline.bind(this)))}setOnline(t){D(this,ya)!==t&&(ae(this,ya,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return D(this,ya)}},ya=new WeakMap,zn=new WeakMap,va=new WeakMap,lx),Fo=new HN;function WN(e){return Math.min(1e3*2**e,3e4)}function Ky(e){return(e??"online")==="online"?Fo.isOnline():!0}var ld=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,n=0,r;const a=id(),i=()=>a.status!=="pending",l=y=>{var w;if(!i()){const v=new ld(y);p(v),(w=e.onCancel)==null||w.call(e,v)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Pm.isFocused()&&(e.networkMode==="always"||Fo.isOnline())&&e.canRun(),d=()=>Ky(e.networkMode)&&e.canRun(),h=y=>{i()||(r==null||r(),a.resolve(y))},p=y=>{i()||(r==null||r(),a.reject(y))},m=()=>new Promise(y=>{var w;r=v=>{(i()||u())&&y(v)},(w=e.onPause)==null||w.call(e)}).then(()=>{var y;r=void 0,i()||(y=e.onContinue)==null||y.call(e)}),f=()=>{if(i())return;let y;const w=n===0?e.initialPromise:void 0;try{y=w??e.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(h).catch(v=>{var F;if(i())return;const g=e.retry??($r?0:3),x=e.retryDelay??WN,b=typeof x=="function"?x(n,v):x,k=g===!0||typeof g=="number"&&nu()?void 0:m()).then(()=>{t?p(v):f()})})};return{promise:a,status:()=>a.status,cancel:l,continue:()=>(r==null||r(),a),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?f():m().then(f),a)}}var Nr,ox,By=(ox=class{constructor(){fe(this,Nr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),nd(this.gcTime)&&ae(this,Nr,yr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??($r?1/0:5*60*1e3))}clearGcTimeout(){D(this,Nr)&&(yr.clearTimeout(D(this,Nr)),ae(this,Nr,void 0))}},Nr=new WeakMap,ox),wr,ja,ps,Sr,Nt,Ji,kr,Es,sn,cx,GN=(cx=class extends By{constructor(t){super();fe(this,Es);fe(this,wr);fe(this,ja);fe(this,ps);fe(this,Sr);fe(this,Nt);fe(this,Ji);fe(this,kr);ae(this,kr,!1),ae(this,Ji,t.defaultOptions),this.setOptions(t.options),this.observers=[],ae(this,Sr,t.client),ae(this,ps,D(this,Sr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ae(this,wr,ip(this.options)),this.state=t.state??D(this,wr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=D(this,Nt))==null?void 0:t.promise}setOptions(t){if(this.options={...D(this,Ji),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=ip(this.options);n.data!==void 0&&(this.setState(ap(n.data,n.dataUpdatedAt)),ae(this,wr,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&D(this,ps).remove(this)}setData(t,n){const r=ad(this.state.data,t,this.options);return Ne(this,Es,sn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ne(this,Es,sn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,a;const n=(r=D(this,Nt))==null?void 0:r.promise;return(a=D(this,Nt))==null||a.cancel(t),n?n.then(Bt).catch(Bt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(D(this,wr))}isActive(){return this.observers.some(t=>xs(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Em||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>nr(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:!zy(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=D(this,Nt))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=D(this,Nt))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),D(this,ps).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(D(this,Nt)&&(D(this,kr)?D(this,Nt).cancel({revert:!0}):D(this,Nt).cancelRetry()),this.scheduleGc()),D(this,ps).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ne(this,Es,sn).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,h,p,m,f,y,w,v,g,x;if(this.state.fetchStatus!=="idle"&&((c=D(this,Nt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(D(this,Nt))return D(this,Nt).continueRetry(),D(this,Nt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const b=this.observers.find(k=>k.options.queryFn);b&&this.setOptions(b.options)}const r=new AbortController,a=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(ae(this,kr,!0),r.signal)})},i=()=>{const b=_y(this.options,n),F=(()=>{const E={client:D(this,Sr),queryKey:this.queryKey,meta:this.meta};return a(E),E})();return ae(this,kr,!1),this.options.persister?this.options.persister(b,F,this):b(F)},o=(()=>{const b={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:D(this,Sr),state:this.state,fetchFn:i};return a(b),b})();(u=this.options.behavior)==null||u.onFetch(o,this),ae(this,ja,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&Ne(this,Es,sn).call(this,{type:"fetch",meta:(h=o.fetchOptions)==null?void 0:h.meta}),ae(this,Nt,Uy({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:b=>{b instanceof ld&&b.revert&&this.setState({...D(this,ja),fetchStatus:"idle"}),r.abort()},onFail:(b,k)=>{Ne(this,Es,sn).call(this,{type:"failed",failureCount:b,error:k})},onPause:()=>{Ne(this,Es,sn).call(this,{type:"pause"})},onContinue:()=>{Ne(this,Es,sn).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const b=await D(this,Nt).start();if(b===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(b),(m=(p=D(this,ps).config).onSuccess)==null||m.call(p,b,this),(y=(f=D(this,ps).config).onSettled)==null||y.call(f,b,this.state.error,this),b}catch(b){if(b instanceof ld){if(b.silent)return D(this,Nt).promise;if(b.revert){if(this.state.data===void 0)throw b;return this.state.data}}throw Ne(this,Es,sn).call(this,{type:"error",error:b}),(v=(w=D(this,ps).config).onError)==null||v.call(w,b,this),(x=(g=D(this,ps).config).onSettled)==null||x.call(g,this.state.data,b,this),b}finally{this.scheduleGc()}}},wr=new WeakMap,ja=new WeakMap,ps=new WeakMap,Sr=new WeakMap,Nt=new WeakMap,Ji=new WeakMap,kr=new WeakMap,Es=new WeakSet,sn=function(t){const n=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,...qy(r.data,this.options),fetchMeta:t.meta??null};case"success":const a={...r,...ap(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ae(this,ja,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=n(this.state),gt.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),D(this,ps).notify({query:this,type:"updated",action:t})})},cx);function qy(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ky(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ap(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ip(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Gt,Pe,Xi,$t,Cr,ba,ln,$n,Yi,Na,wa,Er,Dr,_n,Sa,Le,di,od,cd,ud,dd,md,hd,fd,Vy,ux,ZN=(ux=class extends qa{constructor(t,n){super();fe(this,Le);fe(this,Gt);fe(this,Pe);fe(this,Xi);fe(this,$t);fe(this,Cr);fe(this,ba);fe(this,ln);fe(this,$n);fe(this,Yi);fe(this,Na);fe(this,wa);fe(this,Er);fe(this,Dr);fe(this,_n);fe(this,Sa,new Set);this.options=n,ae(this,Gt,t),ae(this,$n,null),ae(this,ln,id()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(D(this,Pe).addObserver(this),lp(D(this,Pe),this.options)?Ne(this,Le,di).call(this):this.updateResult(),Ne(this,Le,dd).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return pd(D(this,Pe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return pd(D(this,Pe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ne(this,Le,md).call(this),Ne(this,Le,hd).call(this),D(this,Pe).removeObserver(this)}setOptions(t){const n=this.options,r=D(this,Pe);if(this.options=D(this,Gt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof xs(this.options.enabled,D(this,Pe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ne(this,Le,fd).call(this),D(this,Pe).setOptions(this.options),n._defaulted&&!To(this.options,n)&&D(this,Gt).getQueryCache().notify({type:"observerOptionsUpdated",query:D(this,Pe),observer:this});const a=this.hasListeners();a&&op(D(this,Pe),r,this.options,n)&&Ne(this,Le,di).call(this),this.updateResult(),a&&(D(this,Pe)!==r||xs(this.options.enabled,D(this,Pe))!==xs(n.enabled,D(this,Pe))||nr(this.options.staleTime,D(this,Pe))!==nr(n.staleTime,D(this,Pe)))&&Ne(this,Le,od).call(this);const i=Ne(this,Le,cd).call(this);a&&(D(this,Pe)!==r||xs(this.options.enabled,D(this,Pe))!==xs(n.enabled,D(this,Pe))||i!==D(this,_n))&&Ne(this,Le,ud).call(this,i)}getOptimisticResult(t){const n=D(this,Gt).getQueryCache().build(D(this,Gt),t),r=this.createResult(n,t);return XN(this,r)&&(ae(this,$t,r),ae(this,ba,this.options),ae(this,Cr,D(this,Pe).state)),r}getCurrentResult(){return D(this,$t)}trackResult(t,n){return new Proxy(t,{get:(r,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&D(this,ln).status==="pending"&&D(this,ln).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){D(this,Sa).add(t)}getCurrentQuery(){return D(this,Pe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=D(this,Gt).defaultQueryOptions(t),r=D(this,Gt).getQueryCache().build(D(this,Gt),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Ne(this,Le,di).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),D(this,$t)))}createResult(t,n){var M;const r=D(this,Pe),a=this.options,i=D(this,$t),l=D(this,Cr),o=D(this,ba),u=t!==r?t.state:D(this,Xi),{state:d}=t;let h={...d},p=!1,m;if(n._optimisticResults){const P=this.hasListeners(),z=!P&&lp(t,n),L=P&&op(t,r,n,a);(z||L)&&(h={...h,...qy(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:f,errorUpdatedAt:y,status:w}=h;m=h.data;let v=!1;if(n.placeholderData!==void 0&&m===void 0&&w==="pending"){let P;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(P=i.data,v=!0):P=typeof n.placeholderData=="function"?n.placeholderData((M=D(this,wa))==null?void 0:M.state.data,D(this,wa)):n.placeholderData,P!==void 0&&(w="success",m=ad(i==null?void 0:i.data,P,n),p=!0)}if(n.select&&m!==void 0&&!v)if(i&&m===(l==null?void 0:l.data)&&n.select===D(this,Yi))m=D(this,Na);else try{ae(this,Yi,n.select),m=n.select(m),m=ad(i==null?void 0:i.data,m,n),ae(this,Na,m),ae(this,$n,null)}catch(P){ae(this,$n,P)}D(this,$n)&&(f=D(this,$n),m=D(this,Na),y=Date.now(),w="error");const g=h.fetchStatus==="fetching",x=w==="pending",b=w==="error",k=x&&g,F=m!==void 0,S={status:w,fetchStatus:h.fetchStatus,isPending:x,isSuccess:w==="success",isError:b,isInitialLoading:k,isLoading:k,data:m,dataUpdatedAt:h.dataUpdatedAt,error:f,errorUpdatedAt:y,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:g,isRefetching:g&&!x,isLoadingError:b&&!F,isPaused:h.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:b&&F,isStale:Am(t,n),refetch:this.refetch,promise:D(this,ln),isEnabled:xs(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const P=S.data!==void 0,z=S.status==="error"&&!P,L=R=>{z?R.reject(S.error):P&&R.resolve(S.data)},U=()=>{const R=ae(this,ln,S.promise=id());L(R)},V=D(this,ln);switch(V.status){case"pending":t.queryHash===r.queryHash&&L(V);break;case"fulfilled":(z||S.data!==V.value)&&U();break;case"rejected":(!z||S.error!==V.reason)&&U();break}}return S}updateResult(){const t=D(this,$t),n=this.createResult(D(this,Pe),this.options);if(ae(this,Cr,D(this,Pe).state),ae(this,ba,this.options),D(this,Cr).data!==void 0&&ae(this,wa,D(this,Pe)),To(n,t))return;ae(this,$t,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!D(this,Sa).size)return!0;const l=new Set(i??D(this,Sa));return this.options.throwOnError&&l.add("error"),Object.keys(D(this,$t)).some(o=>{const c=o;return D(this,$t)[c]!==t[c]&&l.has(c)})};Ne(this,Le,Vy).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ne(this,Le,dd).call(this)}},Gt=new WeakMap,Pe=new WeakMap,Xi=new WeakMap,$t=new WeakMap,Cr=new WeakMap,ba=new WeakMap,ln=new WeakMap,$n=new WeakMap,Yi=new WeakMap,Na=new WeakMap,wa=new WeakMap,Er=new WeakMap,Dr=new WeakMap,_n=new WeakMap,Sa=new WeakMap,Le=new WeakSet,di=function(t){Ne(this,Le,fd).call(this);let n=D(this,Pe).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Bt)),n},od=function(){Ne(this,Le,md).call(this);const t=nr(this.options.staleTime,D(this,Pe));if($r||D(this,$t).isStale||!nd(t))return;const r=zy(D(this,$t).dataUpdatedAt,t)+1;ae(this,Er,yr.setTimeout(()=>{D(this,$t).isStale||this.updateResult()},r))},cd=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(D(this,Pe)):this.options.refetchInterval)??!1},ud=function(t){Ne(this,Le,hd).call(this),ae(this,_n,t),!($r||xs(this.options.enabled,D(this,Pe))===!1||!nd(D(this,_n))||D(this,_n)===0)&&ae(this,Dr,yr.setInterval(()=>{(this.options.refetchIntervalInBackground||Pm.isFocused())&&Ne(this,Le,di).call(this)},D(this,_n)))},dd=function(){Ne(this,Le,od).call(this),Ne(this,Le,ud).call(this,Ne(this,Le,cd).call(this))},md=function(){D(this,Er)&&(yr.clearTimeout(D(this,Er)),ae(this,Er,void 0))},hd=function(){D(this,Dr)&&(yr.clearInterval(D(this,Dr)),ae(this,Dr,void 0))},fd=function(){const t=D(this,Gt).getQueryCache().build(D(this,Gt),this.options);if(t===D(this,Pe))return;const n=D(this,Pe);ae(this,Pe,t),ae(this,Xi,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Vy=function(t){gt.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(D(this,$t))}),D(this,Gt).getQueryCache().notify({query:D(this,Pe),type:"observerResultsUpdated"})})},ux);function JN(e,t){return xs(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function lp(e,t){return JN(e,t)||e.state.data!==void 0&&pd(e,t,t.refetchOnMount)}function pd(e,t,n){if(xs(t.enabled,e)!==!1&&nr(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Am(e,t)}return!1}function op(e,t,n,r){return(e!==t||xs(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Am(e,n)}function Am(e,t){return xs(t.enabled,e)!==!1&&e.isStaleByTime(nr(t.staleTime,e))}function XN(e,t){return!To(e.getCurrentResult(),t)}function cp(e){return{onFetch:(t,n)=>{var d,h,p,m,f;const r=t.options,a=(p=(h=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:p.direction,i=((m=t.state.data)==null?void 0:m.pages)||[],l=((f=t.state.data)==null?void 0:f.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let y=!1;const w=x=>{BN(x,()=>t.signal,()=>y=!0)},v=_y(t.options,t.fetchOptions),g=async(x,b,k)=>{if(y)return Promise.reject();if(b==null&&x.pages.length)return Promise.resolve(x);const E=(()=>{const z={client:t.client,queryKey:t.queryKey,pageParam:b,direction:k?"backward":"forward",meta:t.options.meta};return w(z),z})(),S=await v(E),{maxPages:M}=t.options,P=k?UN:KN;return{pages:P(x.pages,S,M),pageParams:P(x.pageParams,b,M)}};if(a&&i.length){const x=a==="backward",b=x?YN:up,k={pages:i,pageParams:l},F=b(r,k);o=await g(k,F,x)}else{const x=e??i.length;do{const b=c===0?l[0]??r.initialPageParam:up(r,o);if(c>0&&b==null)break;o=await g(o,b),c++}while(c{var y,w;return(w=(y=t.options).persister)==null?void 0:w.call(y,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function up(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function YN(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var el,Us,_t,Pr,Bs,Pn,dx,ew=(dx=class extends By{constructor(t){super();fe(this,Bs);fe(this,el);fe(this,Us);fe(this,_t);fe(this,Pr);ae(this,el,t.client),this.mutationId=t.mutationId,ae(this,_t,t.mutationCache),ae(this,Us,[]),this.state=t.state||Qy(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){D(this,Us).includes(t)||(D(this,Us).push(t),this.clearGcTimeout(),D(this,_t).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ae(this,Us,D(this,Us).filter(n=>n!==t)),this.scheduleGc(),D(this,_t).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){D(this,Us).length||(this.state.status==="pending"?this.scheduleGc():D(this,_t).remove(this))}continue(){var t;return((t=D(this,Pr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,h,p,m,f,y,w,v,g,x,b,k,F,E,S,M;const n=()=>{Ne(this,Bs,Pn).call(this,{type:"continue"})},r={client:D(this,el),meta:this.options.meta,mutationKey:this.options.mutationKey};ae(this,Pr,Uy({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(P,z)=>{Ne(this,Bs,Pn).call(this,{type:"failed",failureCount:P,error:z})},onPause:()=>{Ne(this,Bs,Pn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>D(this,_t).canRun(this)}));const a=this.state.status==="pending",i=!D(this,Pr).canStart();try{if(a)n();else{Ne(this,Bs,Pn).call(this,{type:"pending",variables:t,isPaused:i}),await((o=(l=D(this,_t).config).onMutate)==null?void 0:o.call(l,t,this,r));const z=await((u=(c=this.options).onMutate)==null?void 0:u.call(c,t,r));z!==this.state.context&&Ne(this,Bs,Pn).call(this,{type:"pending",context:z,variables:t,isPaused:i})}const P=await D(this,Pr).start();return await((h=(d=D(this,_t).config).onSuccess)==null?void 0:h.call(d,P,t,this.state.context,this,r)),await((m=(p=this.options).onSuccess)==null?void 0:m.call(p,P,t,this.state.context,r)),await((y=(f=D(this,_t).config).onSettled)==null?void 0:y.call(f,P,null,this.state.variables,this.state.context,this,r)),await((v=(w=this.options).onSettled)==null?void 0:v.call(w,P,null,t,this.state.context,r)),Ne(this,Bs,Pn).call(this,{type:"success",data:P}),P}catch(P){try{await((x=(g=D(this,_t).config).onError)==null?void 0:x.call(g,P,t,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((k=(b=this.options).onError)==null?void 0:k.call(b,P,t,this.state.context,r))}catch(z){Promise.reject(z)}try{await((E=(F=D(this,_t).config).onSettled)==null?void 0:E.call(F,void 0,P,this.state.variables,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((M=(S=this.options).onSettled)==null?void 0:M.call(S,void 0,P,t,this.state.context,r))}catch(z){Promise.reject(z)}throw Ne(this,Bs,Pn).call(this,{type:"error",error:P}),P}finally{D(this,_t).runNext(this)}}},el=new WeakMap,Us=new WeakMap,_t=new WeakMap,Pr=new WeakMap,Bs=new WeakSet,Pn=function(t){const n=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=n(this.state),gt.batch(()=>{D(this,Us).forEach(r=>{r.onMutationUpdate(t)}),D(this,_t).notify({mutation:this,type:"updated",action:t})})},dx);function Qy(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var on,Ds,tl,mx,tw=(mx=class extends qa{constructor(t={}){super();fe(this,on);fe(this,Ds);fe(this,tl);this.config=t,ae(this,on,new Set),ae(this,Ds,new Map),ae(this,tl,0)}build(t,n,r){const a=new ew({client:t,mutationCache:this,mutationId:++vl(this,tl)._,options:t.defaultMutationOptions(n),state:r});return this.add(a),a}add(t){D(this,on).add(t);const n=Ol(t);if(typeof n=="string"){const r=D(this,Ds).get(n);r?r.push(t):D(this,Ds).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(D(this,on).delete(t)){const n=Ol(t);if(typeof n=="string"){const r=D(this,Ds).get(n);if(r)if(r.length>1){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}else r[0]===t&&D(this,Ds).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ol(t);if(typeof n=="string"){const r=D(this,Ds).get(n),a=r==null?void 0:r.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var r;const n=Ol(t);if(typeof n=="string"){const a=(r=D(this,Ds).get(n))==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(){gt.batch(()=>{D(this,on).forEach(t=>{this.notify({type:"removed",mutation:t})}),D(this,on).clear(),D(this,Ds).clear()})}getAll(){return Array.from(D(this,on))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>sp(n,r))}findAll(t={}){return this.getAll().filter(n=>sp(t,n))}notify(t){gt.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return gt.batch(()=>Promise.all(t.map(n=>n.continue().catch(Bt))))}},on=new WeakMap,Ds=new WeakMap,tl=new WeakMap,mx);function Ol(e){var t;return(t=e.options.scope)==null?void 0:t.id}var cn,Kn,Zt,un,pn,Yl,xd,hx,sw=(hx=class extends qa{constructor(n,r){super();fe(this,pn);fe(this,cn);fe(this,Kn);fe(this,Zt);fe(this,un);ae(this,cn,n),this.setOptions(r),this.bindMethods(),Ne(this,pn,Yl).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var a;const r=this.options;this.options=D(this,cn).defaultMutationOptions(n),To(this.options,r)||D(this,cn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:D(this,Zt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&_r(r.mutationKey)!==_r(this.options.mutationKey)?this.reset():((a=D(this,Zt))==null?void 0:a.state.status)==="pending"&&D(this,Zt).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=D(this,Zt))==null||n.removeObserver(this)}onMutationUpdate(n){Ne(this,pn,Yl).call(this),Ne(this,pn,xd).call(this,n)}getCurrentResult(){return D(this,Kn)}reset(){var n;(n=D(this,Zt))==null||n.removeObserver(this),ae(this,Zt,void 0),Ne(this,pn,Yl).call(this),Ne(this,pn,xd).call(this)}mutate(n,r){var a;return ae(this,un,r),(a=D(this,Zt))==null||a.removeObserver(this),ae(this,Zt,D(this,cn).getMutationCache().build(D(this,cn),this.options)),D(this,Zt).addObserver(this),D(this,Zt).execute(n)}},cn=new WeakMap,Kn=new WeakMap,Zt=new WeakMap,un=new WeakMap,pn=new WeakSet,Yl=function(){var r;const n=((r=D(this,Zt))==null?void 0:r.state)??Qy();ae(this,Kn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},xd=function(n){gt.batch(()=>{var r,a,i,l,o,c,u,d;if(D(this,un)&&this.hasListeners()){const h=D(this,Kn).variables,p=D(this,Kn).context,m={client:D(this,cn),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(a=(r=D(this,un)).onSuccess)==null||a.call(r,n.data,h,p,m)}catch(f){Promise.reject(f)}try{(l=(i=D(this,un)).onSettled)==null||l.call(i,n.data,null,h,p,m)}catch(f){Promise.reject(f)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=D(this,un)).onError)==null||c.call(o,n.error,h,p,m)}catch(f){Promise.reject(f)}try{(d=(u=D(this,un)).onSettled)==null||d.call(u,void 0,n.error,h,p,m)}catch(f){Promise.reject(f)}}}this.listeners.forEach(h=>{h(D(this,Kn))})})},hx),qs,fx,nw=(fx=class extends qa{constructor(t={}){super();fe(this,qs);this.config=t,ae(this,qs,new Map)}build(t,n,r){const a=n.queryKey,i=n.queryHash??Cm(a,n);let l=this.get(i);return l||(l=new GN({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(l)),l}add(t){D(this,qs).has(t.queryHash)||(D(this,qs).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=D(this,qs).get(t.queryHash);n&&(t.destroy(),n===t&&D(this,qs).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){gt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return D(this,qs).get(t)}getAll(){return[...D(this,qs).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>tp(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>tp(t,r)):n}notify(t){gt.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){gt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){gt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},qs=new WeakMap,fx),nt,Un,Bn,ka,Ca,qn,Ea,Da,px,rw=(px=class{constructor(e={}){fe(this,nt);fe(this,Un);fe(this,Bn);fe(this,ka);fe(this,Ca);fe(this,qn);fe(this,Ea);fe(this,Da);ae(this,nt,e.queryCache||new nw),ae(this,Un,e.mutationCache||new tw),ae(this,Bn,e.defaultOptions||{}),ae(this,ka,new Map),ae(this,Ca,new Map),ae(this,qn,0)}mount(){vl(this,qn)._++,D(this,qn)===1&&(ae(this,Ea,Pm.subscribe(async e=>{e&&(await this.resumePausedMutations(),D(this,nt).onFocus())})),ae(this,Da,Fo.subscribe(async e=>{e&&(await this.resumePausedMutations(),D(this,nt).onOnline())})))}unmount(){var e,t;vl(this,qn)._--,D(this,qn)===0&&((e=D(this,Ea))==null||e.call(this),ae(this,Ea,void 0),(t=D(this,Da))==null||t.call(this),ae(this,Da,void 0))}isFetching(e){return D(this,nt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return D(this,Un).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=D(this,nt).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=D(this,nt).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(nr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return D(this,nt).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),a=D(this,nt).get(r.queryHash),i=a==null?void 0:a.state.data,l=zN(t,i);if(l!==void 0)return D(this,nt).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return gt.batch(()=>D(this,nt).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=D(this,nt).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=D(this,nt);gt.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=D(this,nt);return gt.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=gt.batch(()=>D(this,nt).findAll(e).map(a=>a.cancel(n)));return Promise.all(r).then(Bt).catch(Bt)}invalidateQueries(e,t={}){return gt.batch(()=>(D(this,nt).findAll(e).forEach(n=>{n.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 n={...t,cancelRefetch:t.cancelRefetch??!0},r=gt.batch(()=>D(this,nt).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(Bt)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Bt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=D(this,nt).build(this,t);return n.isStaleByTime(nr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Bt).catch(Bt)}fetchInfiniteQuery(e){return e.behavior=cp(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Bt).catch(Bt)}ensureInfiniteQueryData(e){return e.behavior=cp(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Fo.isOnline()?D(this,Un).resumePausedMutations():Promise.resolve()}getQueryCache(){return D(this,nt)}getMutationCache(){return D(this,Un)}getDefaultOptions(){return D(this,Bn)}setDefaultOptions(e){ae(this,Bn,e)}setQueryDefaults(e,t){D(this,ka).set(_r(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...D(this,ka).values()],n={};return t.forEach(r=>{qi(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){D(this,Ca).set(_r(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...D(this,Ca).values()],n={};return t.forEach(r=>{qi(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...D(this,Bn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Cm(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===Em&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...D(this,Bn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){D(this,nt).clear(),D(this,Un).clear()}},nt=new WeakMap,Un=new WeakMap,Bn=new WeakMap,ka=new WeakMap,Ca=new WeakMap,qn=new WeakMap,Ea=new WeakMap,Da=new WeakMap,px),Hy=j.createContext(void 0),xe=e=>{const t=j.useContext(Hy);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},aw=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Hy.Provider,{value:e,children:t})),Wy=j.createContext(!1),iw=()=>j.useContext(Wy);Wy.Provider;function lw(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ow=j.createContext(lw()),cw=()=>j.useContext(ow),uw=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Dm(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},dw=e=>{j.useEffect(()=>{e.clearReset()},[e])},mw=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||Dm(n,[e.error,r])),hw=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...a)=>n(r(...a)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},fw=(e,t)=>e.isLoading&&e.isFetching&&!t,pw=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,dp=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function xw(e,t,n){var p,m,f,y;const r=iw(),a=cw(),i=xe(),l=i.defaultQueryOptions(e);(m=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||m.call(p,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",hw(l),uw(l,a,o),dw(a);const c=!i.getQueryCache().get(l.queryHash),[u]=j.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),h=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(w=>{const v=h?u.subscribe(gt.batchCalls(w)):Bt;return u.updateResult(),v},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),j.useEffect(()=>{u.setOptions(l)},[l,u]),pw(l,d))throw dp(l,u,a);if(mw({result:d,errorResetBoundary:a,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((y=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||y.call(f,l,d),l.experimental_prefetchInRender&&!$r&&fw(d,r)){const w=c?dp(l,u,a):o==null?void 0:o.promise;w==null||w.catch(Bt).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function me(e,t){return xw(e,ZN)}function H(e,t){const n=xe(),[r]=j.useState(()=>new sw(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const a=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(gt.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=j.useCallback((l,o)=>{r.mutate(l,o).catch(Bt)},[r]);if(a.error&&Dm(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}let gw={data:""},yw=e=>{if(typeof window=="object"){let t=(e?e.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return t.nonce=window.__nonce__,t.parentNode||(e||document.head).appendChild(t),t.firstChild}return e||gw},vw=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,jw=/\/\*[^]*?\*\/| +/g,mp=/\n+/g,In=(e,t)=>{let n="",r="",a="";for(let i in e){let l=e[i];i[0]=="@"?i[1]=="i"?n=i+" "+l+";":r+=i[1]=="f"?In(l,i):i+"{"+In(l,i[1]=="k"?"":t)+"}":typeof l=="object"?r+=In(l,t?t.replace(/([^,])+/g,o=>i.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,c=>/&/.test(c)?c.replace(/&/g,o):o?o+" "+c:c)):i):l!=null&&(i=/^--/.test(i)?i:i.replace(/[A-Z]/g,"-$&").toLowerCase(),a+=In.p?In.p(i,l):i+":"+l+";")}return n+(t&&a?t+"{"+a+"}":a)+r},en={},Gy=e=>{if(typeof e=="object"){let t="";for(let n in e)t+=n+Gy(e[n]);return t}return e},bw=(e,t,n,r,a)=>{let i=Gy(e),l=en[i]||(en[i]=(c=>{let u=0,d=11;for(;u>>0;return"go"+d})(i));if(!en[l]){let c=i!==e?e:(u=>{let d,h,p=[{}];for(;d=vw.exec(u.replace(jw,""));)d[4]?p.shift():d[3]?(h=d[3].replace(mp," ").trim(),p.unshift(p[0][h]=p[0][h]||{})):p[0][d[1]]=d[2].replace(mp," ").trim();return p[0]})(e);en[l]=In(a?{["@keyframes "+l]:c}:c,n?"":"."+l)}let o=n&&en.g?en.g:null;return n&&(en.g=en[l]),((c,u,d,h)=>{h?u.data=u.data.replace(h,c):u.data.indexOf(c)===-1&&(u.data=d?c+u.data:u.data+c)})(en[l],t,r,o),l},Nw=(e,t,n)=>e.reduce((r,a,i)=>{let l=t[i];if(l&&l.call){let o=l(n),c=o&&o.props&&o.props.className||/^go/.test(o)&&o;l=c?"."+c:o&&typeof o=="object"?o.props?"":In(o,""):o===!1?"":o}return r+a+(l??"")},"");function oc(e){let t=this||{},n=e.call?e(t.p):e;return bw(n.unshift?n.raw?Nw(n,[].slice.call(arguments,1),t.p):n.reduce((r,a)=>Object.assign(r,a&&a.call?a(t.p):a),{}):n,yw(t.target),t.g,t.o,t.k)}let Zy,gd,yd;oc.bind({g:1});let jn=oc.bind({k:1});function ww(e,t,n,r){In.p=t,Zy=e,gd=n,yd=r}function ur(e,t){let n=this||{};return function(){let r=arguments;function a(i,l){let o=Object.assign({},i),c=o.className||a.className;n.p=Object.assign({theme:gd&&gd()},o),n.o=/ *go\d+/.test(c),o.className=oc.apply(n,r)+(c?" "+c:"");let u=e;return e[0]&&(u=o.as||e,delete o.as),yd&&u[0]&&yd(o),Zy(u,o)}return a}}var Sw=e=>typeof e=="function",Io=(e,t)=>Sw(e)?e(t):e,kw=(()=>{let e=0;return()=>(++e).toString()})(),Jy=(()=>{let e;return()=>{if(e===void 0&&typeof window<"u"){let t=matchMedia("(prefers-reduced-motion: reduce)");e=!t||t.matches}return e}})(),Cw=20,Mm="default",Xy=(e,t)=>{let{toastLimit:n}=e.settings;switch(t.type){case 0:return{...e,toasts:[t.toast,...e.toasts].slice(0,n)};case 1:return{...e,toasts:e.toasts.map(l=>l.id===t.toast.id?{...l,...t.toast}:l)};case 2:let{toast:r}=t;return Xy(e,{type:e.toasts.find(l=>l.id===r.id)?1:0,toast:r});case 3:let{toastId:a}=t;return{...e,toasts:e.toasts.map(l=>l.id===a||a===void 0?{...l,dismissed:!0,visible:!1}:l)};case 4:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(l=>l.id!==t.toastId)};case 5:return{...e,pausedAt:t.time};case 6:let i=t.time-(e.pausedAt||0);return{...e,pausedAt:void 0,toasts:e.toasts.map(l=>({...l,pauseDuration:l.pauseDuration+i}))}}},eo=[],Yy={toasts:[],pausedAt:void 0,settings:{toastLimit:Cw}},Qs={},e0=(e,t=Mm)=>{Qs[t]=Xy(Qs[t]||Yy,e),eo.forEach(([n,r])=>{n===t&&r(Qs[t])})},t0=e=>Object.keys(Qs).forEach(t=>e0(e,t)),Ew=e=>Object.keys(Qs).find(t=>Qs[t].toasts.some(n=>n.id===e)),cc=(e=Mm)=>t=>{e0(t,e)},Dw={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Pw=(e={},t=Mm)=>{let[n,r]=j.useState(Qs[t]||Yy),a=j.useRef(Qs[t]);j.useEffect(()=>(a.current!==Qs[t]&&r(Qs[t]),eo.push([t,r]),()=>{let l=eo.findIndex(([o])=>o===t);l>-1&&eo.splice(l,1)}),[t]);let i=n.toasts.map(l=>{var o,c,u;return{...e,...e[l.type],...l,removeDelay:l.removeDelay||((o=e[l.type])==null?void 0:o.removeDelay)||(e==null?void 0:e.removeDelay),duration:l.duration||((c=e[l.type])==null?void 0:c.duration)||(e==null?void 0:e.duration)||Dw[l.type],style:{...e.style,...(u=e[l.type])==null?void 0:u.style,...l.style}}});return{...n,toasts:i}},Aw=(e,t="blank",n)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:t,ariaProps:{role:"status","aria-live":"polite"},message:e,pauseDuration:0,...n,id:(n==null?void 0:n.id)||kw()}),ll=e=>(t,n)=>{let r=Aw(t,e,n);return cc(r.toasterId||Ew(r.id))({type:2,toast:r}),r.id},yt=(e,t)=>ll("blank")(e,t);yt.error=ll("error");yt.success=ll("success");yt.loading=ll("loading");yt.custom=ll("custom");yt.dismiss=(e,t)=>{let n={type:3,toastId:e};t?cc(t)(n):t0(n)};yt.dismissAll=e=>yt.dismiss(void 0,e);yt.remove=(e,t)=>{let n={type:4,toastId:e};t?cc(t)(n):t0(n)};yt.removeAll=e=>yt.remove(void 0,e);yt.promise=(e,t,n)=>{let r=yt.loading(t.loading,{...n,...n==null?void 0:n.loading});return typeof e=="function"&&(e=e()),e.then(a=>{let i=t.success?Io(t.success,a):void 0;return i?yt.success(i,{id:r,...n,...n==null?void 0:n.success}):yt.dismiss(r),a}).catch(a=>{let i=t.error?Io(t.error,a):void 0;i?yt.error(i,{id:r,...n,...n==null?void 0:n.error}):yt.dismiss(r)}),e};var Mw=1e3,Tw=(e,t="default")=>{let{toasts:n,pausedAt:r}=Pw(e,t),a=j.useRef(new Map).current,i=j.useCallback((h,p=Mw)=>{if(a.has(h))return;let m=setTimeout(()=>{a.delete(h),l({type:4,toastId:h})},p);a.set(h,m)},[]);j.useEffect(()=>{if(r)return;let h=Date.now(),p=n.map(m=>{if(m.duration===1/0)return;let f=(m.duration||0)+m.pauseDuration-(h-m.createdAt);if(f<0){m.visible&&yt.dismiss(m.id);return}return setTimeout(()=>yt.dismiss(m.id,t),f)});return()=>{p.forEach(m=>m&&clearTimeout(m))}},[n,r,t]);let l=j.useCallback(cc(t),[t]),o=j.useCallback(()=>{l({type:5,time:Date.now()})},[l]),c=j.useCallback((h,p)=>{l({type:1,toast:{id:h,height:p}})},[l]),u=j.useCallback(()=>{r&&l({type:6,time:Date.now()})},[r,l]),d=j.useCallback((h,p)=>{let{reverseOrder:m=!1,gutter:f=8,defaultPosition:y}=p||{},w=n.filter(x=>(x.position||y)===(h.position||y)&&x.height),v=w.findIndex(x=>x.id===h.id),g=w.filter((x,b)=>bx.visible).slice(...m?[g+1]:[0,g]).reduce((x,b)=>x+(b.height||0)+f,0)},[n]);return j.useEffect(()=>{n.forEach(h=>{if(h.dismissed)i(h.id,h.removeDelay);else{let p=a.get(h.id);p&&(clearTimeout(p),a.delete(h.id))}})},[n,i]),{toasts:n,handlers:{updateHeight:c,startPause:o,endPause:u,calculateOffset:d}}},Fw=jn` -from { - transform: scale(0) rotate(45deg); - opacity: 0; -} -to { - transform: scale(1) rotate(45deg); - opacity: 1; -}`,Iw=jn` -from { - transform: scale(0); - opacity: 0; -} -to { - transform: scale(1); - opacity: 1; -}`,Lw=jn` -from { - transform: scale(0) rotate(90deg); - opacity: 0; -} -to { - transform: scale(1) rotate(90deg); - opacity: 1; -}`,Rw=ur("div")` - width: 20px; - opacity: 0; - height: 20px; - border-radius: 10px; - background: ${e=>e.primary||"#ff4b4b"}; - position: relative; - transform: rotate(45deg); - - animation: ${Fw} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) - forwards; - animation-delay: 100ms; - - &:after, - &:before { - content: ''; - animation: ${Iw} 0.15s ease-out forwards; - animation-delay: 150ms; - position: absolute; - border-radius: 3px; - opacity: 0; - background: ${e=>e.secondary||"#fff"}; - bottom: 9px; - left: 4px; - height: 2px; - width: 12px; - } - - &:before { - animation: ${Lw} 0.15s ease-out forwards; - animation-delay: 180ms; - transform: rotate(90deg); - } -`,Ow=jn` - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -`,zw=ur("div")` - width: 12px; - height: 12px; - box-sizing: border-box; - border: 2px solid; - border-radius: 100%; - border-color: ${e=>e.secondary||"#e0e0e0"}; - border-right-color: ${e=>e.primary||"#616161"}; - animation: ${Ow} 1s linear infinite; -`,$w=jn` -from { - transform: scale(0) rotate(45deg); - opacity: 0; -} -to { - transform: scale(1) rotate(45deg); - opacity: 1; -}`,_w=jn` -0% { - height: 0; - width: 0; - opacity: 0; -} -40% { - height: 0; - width: 6px; - opacity: 1; -} -100% { - opacity: 1; - height: 10px; -}`,Kw=ur("div")` - width: 20px; - opacity: 0; - height: 20px; - border-radius: 10px; - background: ${e=>e.primary||"#61d345"}; - position: relative; - transform: rotate(45deg); - - animation: ${$w} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) - forwards; - animation-delay: 100ms; - &:after { - content: ''; - box-sizing: border-box; - animation: ${_w} 0.2s ease-out forwards; - opacity: 0; - animation-delay: 200ms; - position: absolute; - border-right: 2px solid; - border-bottom: 2px solid; - border-color: ${e=>e.secondary||"#fff"}; - bottom: 6px; - left: 6px; - height: 10px; - width: 6px; - } -`,Uw=ur("div")` - position: absolute; -`,Bw=ur("div")` - position: relative; - display: flex; - justify-content: center; - align-items: center; - min-width: 20px; - min-height: 20px; -`,qw=jn` -from { - transform: scale(0.6); - opacity: 0.4; -} -to { - transform: scale(1); - opacity: 1; -}`,Vw=ur("div")` - position: relative; - transform: scale(0.6); - opacity: 0.4; - min-width: 20px; - animation: ${qw} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275) - forwards; -`,Qw=({toast:e})=>{let{icon:t,type:n,iconTheme:r}=e;return t!==void 0?typeof t=="string"?j.createElement(Vw,null,t):t:n==="blank"?null:j.createElement(Bw,null,j.createElement(zw,{...r}),n!=="loading"&&j.createElement(Uw,null,n==="error"?j.createElement(Rw,{...r}):j.createElement(Kw,{...r})))},Hw=e=>` -0% {transform: translate3d(0,${e*-200}%,0) scale(.6); opacity:.5;} -100% {transform: translate3d(0,0,0) scale(1); opacity:1;} -`,Ww=e=>` -0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;} -100% {transform: translate3d(0,${e*-150}%,-1px) scale(.6); opacity:0;} -`,Gw="0%{opacity:0;} 100%{opacity:1;}",Zw="0%{opacity:1;} 100%{opacity:0;}",Jw=ur("div")` - display: flex; - align-items: center; - background: #fff; - color: #363636; - line-height: 1.3; - will-change: transform; - box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05); - max-width: 350px; - pointer-events: auto; - padding: 8px 10px; - border-radius: 8px; -`,Xw=ur("div")` - display: flex; - justify-content: center; - margin: 4px 10px; - color: inherit; - flex: 1 1 auto; - white-space: pre-line; -`,Yw=(e,t)=>{let n=e.includes("top")?1:-1,[r,a]=Jy()?[Gw,Zw]:[Hw(n),Ww(n)];return{animation:t?`${jn(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${jn(a)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},e1=j.memo(({toast:e,position:t,style:n,children:r})=>{let a=e.height?Yw(e.position||t||"top-center",e.visible):{opacity:0},i=j.createElement(Qw,{toast:e}),l=j.createElement(Xw,{...e.ariaProps},Io(e.message,e));return j.createElement(Jw,{className:e.className,style:{...a,...n,...e.style}},typeof r=="function"?r({icon:i,message:l}):j.createElement(j.Fragment,null,i,l))});ww(j.createElement);var t1=({id:e,className:t,style:n,onHeightUpdate:r,children:a})=>{let i=j.useCallback(l=>{if(l){let o=()=>{let c=l.getBoundingClientRect().height;r(e,c)};o(),new MutationObserver(o).observe(l,{subtree:!0,childList:!0,characterData:!0})}},[e,r]);return j.createElement("div",{ref:i,className:t,style:n},a)},s1=(e,t)=>{let n=e.includes("top"),r=n?{top:0}:{bottom:0},a=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:Jy()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...a}},n1=oc` - z-index: 9999; - > * { - pointer-events: auto; - } -`,zl=16,r1=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:a,toasterId:i,containerStyle:l,containerClassName:o})=>{let{toasts:c,handlers:u}=Tw(n,i);return j.createElement("div",{"data-rht-toaster":i||"",style:{position:"fixed",zIndex:9999,top:zl,left:zl,right:zl,bottom:zl,pointerEvents:"none",...l},className:o,onMouseEnter:u.startPause,onMouseLeave:u.endPause},c.map(d=>{let h=d.position||t,p=u.calculateOffset(d,{reverseOrder:e,gutter:r,defaultPosition:t}),m=s1(h,p);return j.createElement(t1,{id:d.id,key:d.id,onHeightUpdate:u.updateHeight,className:d.visible?n1:"",style:m},d.type==="custom"?Io(d.message,d):a?a(d):j.createElement(e1,{toast:d,position:h}))}))},Ct=yt;function s0(e,t){return function(){return e.apply(t,arguments)}}const{toString:a1}=Object.prototype,{getPrototypeOf:Tm}=Object,{iterator:uc,toStringTag:n0}=Symbol,dc=(e=>t=>{const n=a1.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Os=e=>(e=e.toLowerCase(),t=>dc(t)===e),mc=e=>t=>typeof t===e,{isArray:Va}=Array,Oa=mc("undefined");function ol(e){return e!==null&&!Oa(e)&&e.constructor!==null&&!Oa(e.constructor)&&ns(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const r0=Os("ArrayBuffer");function i1(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&r0(e.buffer),t}const l1=mc("string"),ns=mc("function"),a0=mc("number"),cl=e=>e!==null&&typeof e=="object",o1=e=>e===!0||e===!1,to=e=>{if(dc(e)!=="object")return!1;const t=Tm(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(n0 in e)&&!(uc in e)},c1=e=>{if(!cl(e)||ol(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},u1=Os("Date"),d1=Os("File"),m1=Os("Blob"),h1=Os("FileList"),f1=e=>cl(e)&&ns(e.pipe),p1=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||ns(e.append)&&((t=dc(e))==="formdata"||t==="object"&&ns(e.toString)&&e.toString()==="[object FormData]"))},x1=Os("URLSearchParams"),[g1,y1,v1,j1]=["ReadableStream","Request","Response","Headers"].map(Os),b1=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ul(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,a;if(typeof e!="object"&&(e=[e]),Va(e))for(r=0,a=e.length;r0;)if(a=n[r],t===a.toLowerCase())return a;return null}const vr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,l0=e=>!Oa(e)&&e!==vr;function vd(){const{caseless:e,skipUndefined:t}=l0(this)&&this||{},n={},r=(a,i)=>{const l=e&&i0(n,i)||i;to(n[l])&&to(a)?n[l]=vd(n[l],a):to(a)?n[l]=vd({},a):Va(a)?n[l]=a.slice():(!t||!Oa(a))&&(n[l]=a)};for(let a=0,i=arguments.length;a(ul(t,(a,i)=>{n&&ns(a)?e[i]=s0(a,n):e[i]=a},{allOwnKeys:r}),e),w1=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),S1=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},k1=(e,t,n,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=n!==!1&&Tm(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},C1=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},E1=e=>{if(!e)return null;if(Va(e))return e;let t=e.length;if(!a0(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},D1=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Tm(Uint8Array)),P1=(e,t)=>{const r=(e&&e[uc]).call(e);let a;for(;(a=r.next())&&!a.done;){const i=a.value;t.call(e,i[0],i[1])}},A1=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},M1=Os("HTMLFormElement"),T1=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),hp=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),F1=Os("RegExp"),o0=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};ul(n,(a,i)=>{let l;(l=t(a,i,e))!==!1&&(r[i]=l||a)}),Object.defineProperties(e,r)},I1=e=>{o0(e,(t,n)=>{if(ns(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(ns(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},L1=(e,t)=>{const n={},r=a=>{a.forEach(i=>{n[i]=!0})};return Va(e)?r(e):r(String(e).split(t)),n},R1=()=>{},O1=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function z1(e){return!!(e&&ns(e.append)&&e[n0]==="FormData"&&e[uc])}const $1=e=>{const t=new Array(10),n=(r,a)=>{if(cl(r)){if(t.indexOf(r)>=0)return;if(ol(r))return r;if(!("toJSON"in r)){t[a]=r;const i=Va(r)?[]:{};return ul(r,(l,o)=>{const c=n(l,a+1);!Oa(c)&&(i[o]=c)}),t[a]=void 0,i}}return r};return n(e,0)},_1=Os("AsyncFunction"),K1=e=>e&&(cl(e)||ns(e))&&ns(e.then)&&ns(e.catch),c0=((e,t)=>e?setImmediate:t?((n,r)=>(vr.addEventListener("message",({source:a,data:i})=>{a===vr&&i===n&&r.length&&r.shift()()},!1),a=>{r.push(a),vr.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ns(vr.postMessage)),U1=typeof queueMicrotask<"u"?queueMicrotask.bind(vr):typeof process<"u"&&process.nextTick||c0,B1=e=>e!=null&&ns(e[uc]),_={isArray:Va,isArrayBuffer:r0,isBuffer:ol,isFormData:p1,isArrayBufferView:i1,isString:l1,isNumber:a0,isBoolean:o1,isObject:cl,isPlainObject:to,isEmptyObject:c1,isReadableStream:g1,isRequest:y1,isResponse:v1,isHeaders:j1,isUndefined:Oa,isDate:u1,isFile:d1,isBlob:m1,isRegExp:F1,isFunction:ns,isStream:f1,isURLSearchParams:x1,isTypedArray:D1,isFileList:h1,forEach:ul,merge:vd,extend:N1,trim:b1,stripBOM:w1,inherits:S1,toFlatObject:k1,kindOf:dc,kindOfTest:Os,endsWith:C1,toArray:E1,forEachEntry:P1,matchAll:A1,isHTMLForm:M1,hasOwnProperty:hp,hasOwnProp:hp,reduceDescriptors:o0,freezeMethods:I1,toObjectSet:L1,toCamelCase:T1,noop:R1,toFiniteNumber:O1,findKey:i0,global:vr,isContextDefined:l0,isSpecCompliantForm:z1,toJSONObject:$1,isAsyncFn:_1,isThenable:K1,setImmediate:c0,asap:U1,isIterable:B1};function be(e,t,n,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),n&&(this.config=n),r&&(this.request=r),a&&(this.response=a,this.status=a.status?a.status:null)}_.inherits(be,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:_.toJSONObject(this.config),code:this.code,status:this.status}}});const u0=be.prototype,d0={};["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=>{d0[e]={value:e}});Object.defineProperties(be,d0);Object.defineProperty(u0,"isAxiosError",{value:!0});be.from=(e,t,n,r,a,i)=>{const l=Object.create(u0);_.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 be.call(l,o,c,n,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 q1=null;function jd(e){return _.isPlainObject(e)||_.isArray(e)}function m0(e){return _.endsWith(e,"[]")?e.slice(0,-2):e}function fp(e,t,n){return e?e.concat(t).map(function(a,i){return a=m0(a),!n&&i?"["+a+"]":a}).join(n?".":""):t}function V1(e){return _.isArray(e)&&!e.some(jd)}const Q1=_.toFlatObject(_,{},null,function(t){return/^is[A-Z]/.test(t)});function hc(e,t,n){if(!_.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=_.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,w){return!_.isUndefined(w[y])});const r=n.metaTokens,a=n.visitor||d,i=n.dots,l=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(t);if(!_.isFunction(a))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(_.isDate(f))return f.toISOString();if(_.isBoolean(f))return f.toString();if(!c&&_.isBlob(f))throw new be("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(f)||_.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function d(f,y,w){let v=f;if(f&&!w&&typeof f=="object"){if(_.endsWith(y,"{}"))y=r?y:y.slice(0,-2),f=JSON.stringify(f);else if(_.isArray(f)&&V1(f)||(_.isFileList(f)||_.endsWith(y,"[]"))&&(v=_.toArray(f)))return y=m0(y),v.forEach(function(x,b){!(_.isUndefined(x)||x===null)&&t.append(l===!0?fp([y],b,i):l===null?y:y+"[]",u(x))}),!1}return jd(f)?!0:(t.append(fp(w,y,i),u(f)),!1)}const h=[],p=Object.assign(Q1,{defaultVisitor:d,convertValue:u,isVisitable:jd});function m(f,y){if(!_.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+y.join("."));h.push(f),_.forEach(f,function(v,g){(!(_.isUndefined(v)||v===null)&&a.call(t,v,_.isString(g)?g.trim():g,y,p))===!0&&m(v,y?y.concat(g):[g])}),h.pop()}}if(!_.isObject(e))throw new TypeError("data must be an object");return m(e),t}function pp(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Fm(e,t){this._pairs=[],e&&hc(e,this,t)}const h0=Fm.prototype;h0.append=function(t,n){this._pairs.push([t,n])};h0.toString=function(t){const n=t?function(r){return t.call(this,r,pp)}:pp;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function H1(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function f0(e,t,n){if(!t)return e;const r=n&&n.encode||H1;_.isFunction(n)&&(n={serialize:n});const a=n&&n.serialize;let i;if(a?i=a(t,n):i=_.isURLSearchParams(t)?t.toString():new Fm(t,n).toString(r),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class xp{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,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){_.forEach(this.handlers,function(r){r!==null&&t(r)})}}const p0={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},W1=typeof URLSearchParams<"u"?URLSearchParams:Fm,G1=typeof FormData<"u"?FormData:null,Z1=typeof Blob<"u"?Blob:null,J1={isBrowser:!0,classes:{URLSearchParams:W1,FormData:G1,Blob:Z1},protocols:["http","https","file","blob","url","data"]},Im=typeof window<"u"&&typeof document<"u",bd=typeof navigator=="object"&&navigator||void 0,X1=Im&&(!bd||["ReactNative","NativeScript","NS"].indexOf(bd.product)<0),Y1=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",eS=Im&&window.location.href||"http://localhost",tS=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Im,hasStandardBrowserEnv:X1,hasStandardBrowserWebWorkerEnv:Y1,navigator:bd,origin:eS},Symbol.toStringTag,{value:"Module"})),Ot={...tS,...J1};function sS(e,t){return hc(e,new Ot.classes.URLSearchParams,{visitor:function(n,r,a,i){return Ot.isNode&&_.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function nS(e){return _.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function rS(e){const t={},n=Object.keys(e);let r;const a=n.length;let i;for(r=0;r=n.length;return l=!l&&_.isArray(a)?a.length:l,c?(_.hasOwnProp(a,l)?a[l]=[a[l],r]:a[l]=r,!o):((!a[l]||!_.isObject(a[l]))&&(a[l]=[]),t(n,r,a[l],i)&&_.isArray(a[l])&&(a[l]=rS(a[l])),!o)}if(_.isFormData(e)&&_.isFunction(e.entries)){const n={};return _.forEachEntry(e,(r,a)=>{t(nS(r),a,n,0)}),n}return null}function aS(e,t,n){if(_.isString(e))try{return(t||JSON.parse)(e),_.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const dl={transitional:p0,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,i=_.isObject(t);if(i&&_.isHTMLForm(t)&&(t=new FormData(t)),_.isFormData(t))return a?JSON.stringify(x0(t)):t;if(_.isArrayBuffer(t)||_.isBuffer(t)||_.isStream(t)||_.isFile(t)||_.isBlob(t)||_.isReadableStream(t))return t;if(_.isArrayBufferView(t))return t.buffer;if(_.isURLSearchParams(t))return n.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 sS(t,this.formSerializer).toString();if((o=_.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return hc(o?{"files[]":t}:t,c&&new c,this.formSerializer)}}return i||a?(n.setContentType("application/json",!1),aS(t)):t}],transformResponse:[function(t){const n=this.transitional||dl.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(_.isResponse(t)||_.isReadableStream(t))return t;if(t&&_.isString(t)&&(r&&!this.responseType||a)){const l=!(n&&n.silentJSONParsing)&&a;try{return JSON.parse(t,this.parseReviver)}catch(o){if(l)throw o.name==="SyntaxError"?be.from(o,be.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:Ot.classes.FormData,Blob:Ot.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],e=>{dl.headers[e]={}});const iS=_.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"]),lS=e=>{const t={};let n,r,a;return e&&e.split(` -`).forEach(function(l){a=l.indexOf(":"),n=l.substring(0,a).trim().toLowerCase(),r=l.substring(a+1).trim(),!(!n||t[n]&&iS[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},gp=Symbol("internals");function ai(e){return e&&String(e).trim().toLowerCase()}function so(e){return e===!1||e==null?e:_.isArray(e)?e.map(so):String(e)}function oS(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const cS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Zc(e,t,n,r,a){if(_.isFunction(r))return r.call(this,t,n);if(a&&(t=n),!!_.isString(t)){if(_.isString(r))return t.indexOf(r)!==-1;if(_.isRegExp(r))return r.test(t)}}function uS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function dS(e,t){const n=_.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(a,i,l){return this[r].call(this,t,a,i,l)},configurable:!0})})}let rs=class{constructor(t){t&&this.set(t)}set(t,n,r){const a=this;function i(o,c,u){const d=ai(c);if(!d)throw new Error("header name must be a non-empty string");const h=_.findKey(a,d);(!h||a[h]===void 0||u===!0||u===void 0&&a[h]!==!1)&&(a[h||c]=so(o))}const l=(o,c)=>_.forEach(o,(u,d)=>i(u,d,c));if(_.isPlainObject(t)||t instanceof this.constructor)l(t,n);else if(_.isString(t)&&(t=t.trim())&&!cS(t))l(lS(t),n);else if(_.isObject(t)&&_.isIterable(t)){let o={},c,u;for(const d of t){if(!_.isArray(d))throw TypeError("Object iterator must return a key-value pair");o[u=d[0]]=(c=o[u])?_.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}l(o,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=ai(t),t){const r=_.findKey(this,t);if(r){const a=this[r];if(!n)return a;if(n===!0)return oS(a);if(_.isFunction(n))return n.call(this,a,r);if(_.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=ai(t),t){const r=_.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Zc(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let a=!1;function i(l){if(l=ai(l),l){const o=_.findKey(r,l);o&&(!n||Zc(r,r[o],o,n))&&(delete r[o],a=!0)}}return _.isArray(t)?t.forEach(i):i(t),a}clear(t){const n=Object.keys(this);let r=n.length,a=!1;for(;r--;){const i=n[r];(!t||Zc(this,this[i],i,t,!0))&&(delete this[i],a=!0)}return a}normalize(t){const n=this,r={};return _.forEach(this,(a,i)=>{const l=_.findKey(r,i);if(l){n[l]=so(a),delete n[i];return}const o=t?uS(i):String(i).trim();o!==i&&delete n[i],n[o]=so(a),r[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return _.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=t&&_.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).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,...n){const r=new this(t);return n.forEach(a=>r.set(a)),r}static accessor(t){const r=(this[gp]=this[gp]={accessors:{}}).accessors,a=this.prototype;function i(l){const o=ai(l);r[o]||(dS(a,l),r[o]=!0)}return _.isArray(t)?t.forEach(i):i(t),this}};rs.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);_.reduceDescriptors(rs.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});_.freezeMethods(rs);function Jc(e,t){const n=this||dl,r=t||n,a=rs.from(r.headers);let i=r.data;return _.forEach(e,function(o){i=o.call(n,i,a.normalize(),t?t.status:void 0)}),a.normalize(),i}function g0(e){return!!(e&&e.__CANCEL__)}function Qa(e,t,n){be.call(this,e??"canceled",be.ERR_CANCELED,t,n),this.name="CanceledError"}_.inherits(Qa,be,{__CANCEL__:!0});function y0(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new be("Request failed with status code "+n.status,[be.ERR_BAD_REQUEST,be.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function mS(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function hS(e,t){e=e||10;const n=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),n[a]=c,r[a]=u;let h=i,p=0;for(;h!==a;)p+=n[h++],h=h%e;if(a=(a+1)%e,a===i&&(i=(i+1)%e),u-l{n=d,a=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const d=Date.now(),h=d-n;h>=r?l(u,d):(a=u,i||(i=setTimeout(()=>{i=null,l(a)},r-h)))},()=>a&&l(a)]}const Lo=(e,t,n=3)=>{let r=0;const a=hS(50,250);return fS(i=>{const l=i.loaded,o=i.lengthComputable?i.total:void 0,c=l-r,u=a(c),d=l<=o;r=l;const h={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(h)},n)},yp=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},vp=e=>(...t)=>_.asap(()=>e(...t)),pS=Ot.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ot.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ot.origin),Ot.navigator&&/(msie|trident)/i.test(Ot.navigator.userAgent)):()=>!0,xS=Ot.hasStandardBrowserEnv?{write(e,t,n,r,a,i,l){if(typeof document>"u")return;const o=[`${e}=${encodeURIComponent(t)}`];_.isNumber(n)&&o.push(`expires=${new Date(n).toUTCString()}`),_.isString(r)&&o.push(`path=${r}`),_.isString(a)&&o.push(`domain=${a}`),i===!0&&o.push("secure"),_.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 gS(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function yS(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function v0(e,t,n){let r=!gS(t);return e&&(r||n==!1)?yS(e,t):t}const jp=e=>e instanceof rs?{...e}:e;function Kr(e,t){t=t||{};const n={};function r(u,d,h,p){return _.isPlainObject(u)&&_.isPlainObject(d)?_.merge.call({caseless:p},u,d):_.isPlainObject(d)?_.merge({},d):_.isArray(d)?d.slice():d}function a(u,d,h,p){if(_.isUndefined(d)){if(!_.isUndefined(u))return r(void 0,u,h,p)}else return r(u,d,h,p)}function i(u,d){if(!_.isUndefined(d))return r(void 0,d)}function l(u,d){if(_.isUndefined(d)){if(!_.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function o(u,d,h){if(h in t)return r(u,d);if(h 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,h)=>a(jp(u),jp(d),h,!0)};return _.forEach(Object.keys({...e,...t}),function(d){const h=c[d]||a,p=h(e[d],t[d],d);_.isUndefined(p)&&h!==o||(n[d]=p)}),n}const j0=e=>{const t=Kr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:i,headers:l,auth:o}=t;if(t.headers=l=rs.from(l),t.url=f0(v0(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&l.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),_.isFormData(n)){if(Ot.hasStandardBrowserEnv||Ot.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(_.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,h])=>{u.includes(d.toLowerCase())&&l.set(d,h)})}}if(Ot.hasStandardBrowserEnv&&(r&&_.isFunction(r)&&(r=r(t)),r||r!==!1&&pS(t.url))){const c=a&&i&&xS.read(i);c&&l.set(a,c)}return t},vS=typeof XMLHttpRequest<"u",jS=vS&&function(e){return new Promise(function(n,r){const a=j0(e);let i=a.data;const l=rs.from(a.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:u}=a,d,h,p,m,f;function y(){m&&m(),f&&f(),a.cancelToken&&a.cancelToken.unsubscribe(d),a.signal&&a.signal.removeEventListener("abort",d)}let w=new XMLHttpRequest;w.open(a.method.toUpperCase(),a.url,!0),w.timeout=a.timeout;function v(){if(!w)return;const x=rs.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),k={data:!o||o==="text"||o==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:x,config:e,request:w};y0(function(E){n(E),y()},function(E){r(E),y()},k),w=null}"onloadend"in w?w.onloadend=v:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(v)},w.onabort=function(){w&&(r(new be("Request aborted",be.ECONNABORTED,e,w)),w=null)},w.onerror=function(b){const k=b&&b.message?b.message:"Network Error",F=new be(k,be.ERR_NETWORK,e,w);F.event=b||null,r(F),w=null},w.ontimeout=function(){let b=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const k=a.transitional||p0;a.timeoutErrorMessage&&(b=a.timeoutErrorMessage),r(new be(b,k.clarifyTimeoutError?be.ETIMEDOUT:be.ECONNABORTED,e,w)),w=null},i===void 0&&l.setContentType(null),"setRequestHeader"in w&&_.forEach(l.toJSON(),function(b,k){w.setRequestHeader(k,b)}),_.isUndefined(a.withCredentials)||(w.withCredentials=!!a.withCredentials),o&&o!=="json"&&(w.responseType=a.responseType),u&&([p,f]=Lo(u,!0),w.addEventListener("progress",p)),c&&w.upload&&([h,m]=Lo(c),w.upload.addEventListener("progress",h),w.upload.addEventListener("loadend",m)),(a.cancelToken||a.signal)&&(d=x=>{w&&(r(!x||x.type?new Qa(null,e,w):x),w.abort(),w=null)},a.cancelToken&&a.cancelToken.subscribe(d),a.signal&&(a.signal.aborted?d():a.signal.addEventListener("abort",d)));const g=mS(a.url);if(g&&Ot.protocols.indexOf(g)===-1){r(new be("Unsupported protocol "+g+":",be.ERR_BAD_REQUEST,e));return}w.send(i||null)})},bS=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){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 be?d:new Qa(d instanceof Error?d.message:d))}};let l=t&&setTimeout(()=>{l=null,i(new be(`timeout ${t} of ms exceeded`,be.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=()=>_.asap(o),c}},NS=function*(e,t){let n=e.byteLength;if(n{const a=wS(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 h=d.byteLength;if(n){let p=i+=h;n(p)}c.enqueue(new Uint8Array(d))}catch(u){throw o(u),u}},cancel(c){return o(c),a.return()}},{highWaterMark:2})},Np=64*1024,{isFunction:$l}=_,kS=(({Request:e,Response:t})=>({Request:e,Response:t}))(_.global),{ReadableStream:wp,TextEncoder:Sp}=_.global,kp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},CS=e=>{e=_.merge.call({skipUndefined:!0},kS,e);const{fetch:t,Request:n,Response:r}=e,a=t?$l(t):typeof fetch=="function",i=$l(n),l=$l(r);if(!a)return!1;const o=a&&$l(wp),c=a&&(typeof Sp=="function"?(f=>y=>f.encode(y))(new Sp):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=i&&o&&kp(()=>{let f=!1;const y=new n(Ot.origin,{body:new wp,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!y}),d=l&&o&&kp(()=>_.isReadableStream(new r("").body)),h={stream:d&&(f=>f.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(y,w)=>{let v=y&&y[f];if(v)return v.call(y);throw new be(`Response type '${f}' is not supported`,be.ERR_NOT_SUPPORT,w)})});const p=async f=>{if(f==null)return 0;if(_.isBlob(f))return f.size;if(_.isSpecCompliantForm(f))return(await new n(Ot.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(_.isArrayBufferView(f)||_.isArrayBuffer(f))return f.byteLength;if(_.isURLSearchParams(f)&&(f=f+""),_.isString(f))return(await c(f)).byteLength},m=async(f,y)=>{const w=_.toFiniteNumber(f.getContentLength());return w??p(y)};return async f=>{let{url:y,method:w,data:v,signal:g,cancelToken:x,timeout:b,onDownloadProgress:k,onUploadProgress:F,responseType:E,headers:S,withCredentials:M="same-origin",fetchOptions:P}=j0(f),z=t||fetch;E=E?(E+"").toLowerCase():"text";let L=bS([g,x&&x.toAbortSignal()],b),U=null;const V=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let R;try{if(F&&u&&w!=="get"&&w!=="head"&&(R=await m(S,v))!==0){let pe=new n(y,{method:"POST",body:v,duplex:"half"}),oe;if(_.isFormData(v)&&(oe=pe.headers.get("content-type"))&&S.setContentType(oe),pe.body){const[Ge,Q]=yp(R,Lo(vp(F)));v=bp(pe.body,Np,Ge,Q)}}_.isString(M)||(M=M?"include":"omit");const C=i&&"credentials"in n.prototype,N={...P,signal:L,method:w.toUpperCase(),headers:S.normalize().toJSON(),body:v,duplex:"half",credentials:C?M:void 0};U=i&&new n(y,N);let K=await(i?z(U,P):z(y,N));const X=d&&(E==="stream"||E==="response");if(d&&(k||X&&V)){const pe={};["status","statusText","headers"].forEach(Se=>{pe[Se]=K[Se]});const oe=_.toFiniteNumber(K.headers.get("content-length")),[Ge,Q]=k&&yp(oe,Lo(vp(k),!0))||[];K=new r(bp(K.body,Np,Ge,()=>{Q&&Q(),V&&V()}),pe)}E=E||"text";let te=await h[_.findKey(h,E)||"text"](K,f);return!X&&V&&V(),await new Promise((pe,oe)=>{y0(pe,oe,{data:te,headers:rs.from(K.headers),status:K.status,statusText:K.statusText,config:f,request:U})})}catch(C){throw V&&V(),C&&C.name==="TypeError"&&/Load failed|fetch/i.test(C.message)?Object.assign(new be("Network Error",be.ERR_NETWORK,f,U),{cause:C.cause||C}):be.from(C,C&&C.code,f,U)}}},ES=new Map,b0=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:a}=t,i=[r,a,n];let l=i.length,o=l,c,u,d=ES;for(;o--;)c=i[o],u=d.get(c),u===void 0&&d.set(c,u=o?new Map:CS(t)),d=u;return u};b0();const Lm={http:q1,xhr:jS,fetch:{get:b0}};_.forEach(Lm,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Cp=e=>`- ${e}`,DS=e=>_.isFunction(e)||e===null||e===!1;function PS(e,t){e=_.isArray(e)?e:[e];const{length:n}=e;let r,a;const i={};for(let l=0;l`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=n?l.length>1?`since : -`+l.map(Cp).join(` -`):" "+Cp(l[0]):"as no adapter specified";throw new be("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return a}const N0={getAdapter:PS,adapters:Lm};function Xc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Qa(null,e)}function Ep(e){return Xc(e),e.headers=rs.from(e.headers),e.data=Jc.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),N0.getAdapter(e.adapter||dl.adapter,e)(e).then(function(r){return Xc(e),r.data=Jc.call(e,e.transformResponse,r),r.headers=rs.from(r.headers),r},function(r){return g0(r)||(Xc(e),r&&r.response&&(r.response.data=Jc.call(e,e.transformResponse,r.response),r.response.headers=rs.from(r.response.headers))),Promise.reject(r)})}const w0="1.13.2",fc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{fc[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Dp={};fc.transitional=function(t,n,r){function a(i,l){return"[Axios v"+w0+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,o)=>{if(t===!1)throw new be(a(l," has been removed"+(n?" in "+n:"")),be.ERR_DEPRECATED);return n&&!Dp[l]&&(Dp[l]=!0,console.warn(a(l," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,l,o):!0}};fc.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function AS(e,t,n){if(typeof e!="object")throw new be("options must be an object",be.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 be("option "+i+" must be "+c,be.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new be("Unknown option "+i,be.ERR_BAD_OPTION)}}const no={assertOptions:AS,validators:fc},$s=no.validators;let Tr=class{constructor(t){this.defaults=t||{},this.interceptors={request:new xp,response:new xp}}async request(t,n){try{return await this._request(t,n)}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,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Kr(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&no.assertOptions(r,{silentJSONParsing:$s.transitional($s.boolean),forcedJSONParsing:$s.transitional($s.boolean),clarifyTimeoutError:$s.transitional($s.boolean)},!1),a!=null&&(_.isFunction(a)?n.paramsSerializer={serialize:a}:no.assertOptions(a,{encode:$s.function,serialize:$s.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),no.assertOptions(n,{baseUrl:$s.spelling("baseURL"),withXsrfToken:$s.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l=i&&_.merge(i.common,i[n.method]);i&&_.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),n.headers=rs.concat(l,i);const o=[];let c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(n)===!1||(c=c&&y.synchronous,o.unshift(y.fulfilled,y.rejected))});const u=[];this.interceptors.response.forEach(function(y){u.push(y.fulfilled,y.rejected)});let d,h=0,p;if(!c){const f=[Ep.bind(this),void 0];for(f.unshift(...o),f.push(...u),p=f.length,d=Promise.resolve(n);h{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 Qa(i,l,o),n(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 n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new S0(function(a){t=a}),cancel:t}}};function TS(e){return function(n){return e.apply(null,n)}}function FS(e){return _.isObject(e)&&e.isAxiosError===!0}const Nd={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(Nd).forEach(([e,t])=>{Nd[t]=e});function k0(e){const t=new Tr(e),n=s0(Tr.prototype.request,t);return _.extend(n,Tr.prototype,t,{allOwnKeys:!0}),_.extend(n,t,null,{allOwnKeys:!0}),n.create=function(a){return k0(Kr(e,a))},n}const ct=k0(dl);ct.Axios=Tr;ct.CanceledError=Qa;ct.CancelToken=MS;ct.isCancel=g0;ct.VERSION=w0;ct.toFormData=hc;ct.AxiosError=be;ct.Cancel=ct.CanceledError;ct.all=function(t){return Promise.all(t)};ct.spread=TS;ct.isAxiosError=FS;ct.mergeConfig=Kr;ct.AxiosHeaders=rs;ct.formToJSON=e=>x0(_.isHTMLForm(e)?new FormData(e):e);ct.getAdapter=N0.getAdapter;ct.HttpStatusCode=Nd;ct.default=ct;const{Axios:oC,AxiosError:cC,CanceledError:uC,isCancel:dC,CancelToken:mC,VERSION:hC,all:fC,Cancel:pC,isAxiosError:xC,spread:gC,toFormData:yC,AxiosHeaders:vC,HttpStatusCode:jC,formToJSON:bC,getAdapter:NC,mergeConfig:wC}=ct,O=ct.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 n=((d=(u=e.response)==null?void 0:u.data)==null?void 0:d.error)||e.message||"Ein Fehler ist aufgetreten",r=new Error(n);return Promise.reject(r)});const _l={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},kt={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,n)=>(await O.post(`/customers/${e}/representatives`,{representativeId:t,notes:n})).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},wd={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},Ro={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},Oo={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,n)=>(await O.put(`/meters/${e}/readings/${t}`,n)).data,deleteReading:async(e,t)=>(await O.delete(`/meters/${e}/readings/${t}`)).data},is={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,enableMailbox:async e=>(await O.post(`/stressfrei-emails/${e}/enable-mailbox`)).data,syncMailboxStatus:async e=>(await O.post(`/stressfrei-emails/${e}/sync-mailbox-status`)).data,getMailboxCredentials:async e=>(await O.get(`/stressfrei-emails/${e}/credentials`)).data,resetPassword:async e=>(await O.post(`/stressfrei-emails/${e}/reset-password`)).data,syncEmails:async(e,t=!1)=>(await O.post(`/stressfrei-emails/${e}/sync`,{},{params:{full:t}})).data,sendEmail:async(e,t)=>(await O.post(`/stressfrei-emails/${e}/send`,t)).data,getFolderCounts:async e=>(await O.get(`/stressfrei-emails/${e}/folder-counts`)).data},_e={getForCustomer:async(e,t)=>(await O.get(`/customers/${e}/emails`,{params:t})).data,getForContract:async(e,t)=>(await O.get(`/contracts/${e}/emails`,{params:t})).data,getContractFolderCounts:async e=>(await O.get(`/contracts/${e}/emails/folder-counts`)).data,getMailboxAccounts:async e=>(await O.get(`/customers/${e}/mailbox-accounts`)).data,getById:async e=>(await O.get(`/emails/${e}`)).data,getThread:async e=>(await O.get(`/emails/${e}/thread`)).data,markAsRead:async(e,t)=>(await O.patch(`/emails/${e}/read`,{isRead:t})).data,toggleStar:async e=>(await O.post(`/emails/${e}/star`)).data,assignToContract:async(e,t)=>(await O.post(`/emails/${e}/assign`,{contractId:t})).data,unassignFromContract:async e=>(await O.delete(`/emails/${e}/assign`)).data,delete:async e=>(await O.delete(`/emails/${e}`)).data,getAttachmentUrl:(e,t,n)=>{const r=localStorage.getItem("token"),a=encodeURIComponent(t),i=n?"&view=true":"";return`${O.defaults.baseURL}/emails/${e}/attachments/${a}?token=${r}${i}`},getUnreadCount:async e=>(await O.get("/emails/unread-count",{params:e})).data,getTrash:async e=>(await O.get(`/customers/${e}/emails/trash`)).data,getTrashCount:async e=>(await O.get(`/customers/${e}/emails/trash/count`)).data,restore:async e=>(await O.post(`/emails/${e}/restore`)).data,permanentDelete:async e=>(await O.delete(`/emails/${e}/permanent`)).data},qe={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},it={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},Ur={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},dr={list:async()=>(await O.get("/settings/backups")).data,create:async()=>(await O.post("/settings/backup")).data,restore:async e=>(await O.post(`/settings/backup/${e}/restore`)).data,delete:async e=>(await O.delete(`/settings/backup/${e}`)).data,getDownloadUrl:e=>`/api/settings/backup/${e}/download`,upload:async e=>{const t=new FormData;return t.append("backup",e),(await O.post("/settings/backup/upload",t,{headers:{"Content-Type":"multipart/form-data"}})).data},factoryReset:async()=>(await O.post("/settings/factory-reset")).data},Vi={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},Qi={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},Hi={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},Wi={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},za={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},C0={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},rt={uploadBankCardDocument:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/bank-cards/${e}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},uploadIdentityDocument:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/documents/${e}`,n,{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 n=new FormData;return n.append("document",t),(await O.post(`/upload/customers/${e}/business-registration`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBusinessRegistration:async e=>(await O.delete(`/upload/customers/${e}/business-registration`)).data,uploadCommercialRegister:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/customers/${e}/commercial-register`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCommercialRegister:async e=>(await O.delete(`/upload/customers/${e}/commercial-register`)).data,uploadPrivacyPolicy:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/customers/${e}/privacy-policy`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deletePrivacyPolicy:async e=>(await O.delete(`/upload/customers/${e}/privacy-policy`)).data,uploadCancellationLetter:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-letter`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetter:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-letter`)).data,uploadCancellationConfirmation:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-confirmation`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmation:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-confirmation`)).data,uploadCancellationLetterOptions:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-letter-options`,n,{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 n=new FormData;return n.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-confirmation-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmationOptions:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-confirmation-options`)).data},Ni={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},mi={getSchema:async()=>(await O.get("/developer/schema")).data,getTableData:async(e,t=1,n=50)=>(await O.get(`/developer/table/${e}`,{params:{page:t,limit:n}})).data,updateRow:async(e,t,n)=>(await O.put(`/developer/table/${e}/${t}`,n)).data,deleteRow:async(e,t)=>(await O.delete(`/developer/table/${e}/${t}`)).data,getReference:async e=>(await O.get(`/developer/reference/${e}`)).data},an={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},E0=j.createContext(null);function IS({children:e}){const[t,n]=j.useState(null),[r,a]=j.useState(!0),[i,l]=j.useState(()=>localStorage.getItem("developerMode")==="true"),o=y=>{l(y),localStorage.setItem("developerMode",String(y))};j.useEffect(()=>{var y;console.log("useEffect check - user:",t==null?void 0:t.email,"developerMode:",i,"has developer:access:",(y=t==null?void 0:t.permissions)==null?void 0:y.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]),j.useEffect(()=>{localStorage.getItem("token")?_l.me().then(w=>{w.success&&w.data?n(w.data):localStorage.removeItem("token")}).catch(()=>{localStorage.removeItem("token")}).finally(()=>{a(!1)}):a(!1)},[]);const c=async(y,w)=>{const v=await _l.login(y,w);if(v.success&&v.data)localStorage.setItem("token",v.data.token),n(v.data.user);else throw new Error(v.error||"Login fehlgeschlagen")},u=async(y,w)=>{const v=await _l.customerLogin(y,w);if(v.success&&v.data)localStorage.setItem("token",v.data.token),n(v.data.user);else throw new Error(v.error||"Login fehlgeschlagen")},d=()=>{localStorage.removeItem("token"),n(null)},h=async()=>{var w;if(localStorage.getItem("token"))try{const v=await _l.me();console.log("refreshUser response:",v),console.log("permissions:",(w=v.data)==null?void 0:w.permissions),v.success&&v.data&&n(v.data)}catch(v){console.error("refreshUser error:",v)}},p=y=>t?t.permissions.includes(y):!1,m=!!(t!=null&&t.customerId),f=!!(t!=null&&t.isCustomerPortal);return s.jsx(E0.Provider,{value:{user:t,isLoading:r,isAuthenticated:!!t,login:c,customerLogin:u,logout:d,hasPermission:p,isCustomer:m,isCustomerPortal:f,developerMode:i,setDeveloperMode:o,refreshUser:h},children:e})}function Ue(){const e=j.useContext(E0);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}const Yc={scrollToTopThreshold:.7},D0=j.createContext(void 0),Pp="opencrm_app_settings";function LS({children:e}){const[t,n]=j.useState(()=>{const a=localStorage.getItem(Pp);if(a)try{return{...Yc,...JSON.parse(a)}}catch{return Yc}return Yc});j.useEffect(()=>{localStorage.setItem(Pp,JSON.stringify(t))},[t]);const r=a=>{n(i=>({...i,...a}))};return s.jsx(D0.Provider,{value:{settings:t,updateSettings:r},children:e})}function P0(){const e=j.useContext(D0);if(!e)throw new Error("useAppSettings must be used within AppSettingsProvider");return e}function RS(){const{pathname:e}=kn();return j.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 OS=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),A0=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var zS={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 $S=j.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:l,...o},c)=>j.createElement("svg",{ref:c,...zS,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:A0("lucide",a),...o},[...l.map(([u,d])=>j.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 ne=(e,t)=>{const n=j.forwardRef(({className:r,...a},i)=>j.createElement($S,{ref:i,iconNode:t,className:A0(`lucide-${OS(e)}`,r),...a}));return n.displayName=`${e}`,n};/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _S=ne("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Xs=ne("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 M0=ne("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 KS=ne("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 US=ne("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 T0=ne("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 F0=ne("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 zo=ne("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 pc=ne("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 BS=ne("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 ls=ne("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 I0=ne("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 hn=ne("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 js=ne("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 Ap=ne("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 ro=ne("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 Gi=ne("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 bn=ne("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 xc=ne("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 Rm=ne("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 qS=ne("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 gc=ne("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 Fs=ne("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 Om=ne("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 Mt=ne("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 Ae=ne("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 lt=ne("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 VS=ne("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 L0=ne("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 QS=ne("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const R0=ne("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 Mp=ne("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 zm=ne("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 HS=ne("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 Tp=ne("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Fr=ne("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const WS=ne("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const GS=ne("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 ZS=ne("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 Fp=ne("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const JS=ne("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 O0=ne("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Hs=ne("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 XS=ne("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 YS=ne("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 Zi=ne("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 e2=ne("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 t2=ne("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yc=ne("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ze=ne("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 fr=ne("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const s2=ne("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const n2=ne("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const r2=ne("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 ml=ne("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 hl=ne("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 z0=ne("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 $m=ne("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 tt=ne("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 _m=ne("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const a2=ne("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 i2=ne("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 je=ne("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 ir=ne("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 $0=ne("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 _0=ne("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Sd=ne("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 l2=ne("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 o2=ne("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 Km=ne("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 pa=ne("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 Ip=ne("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 xa=ne("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Nn=ne("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 Um=ne("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 c2=ne("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 u2=ne("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 d2(){const{user:e,logout:t,hasPermission:n,isCustomer:r,developerMode:a}=Ue(),i=[{to:"/",icon:ZS,label:"Dashboard",show:!0,end:!0},{to:"/customers",icon:pa,label:"Kunden",show:n("customers:read")&&!r},{to:"/contracts",icon:lt,label:"Verträge",show:n("contracts:read"),end:!0},{to:"/contracts/cockpit",icon:hn,label:"Vertrags-Cockpit",show:n("contracts:read")&&!r},{to:"/tasks",icon:r?Zi:Gi,label:r?"Support-Anfragen":"Aufgaben",show:n("contracts:read")}],l=[{to:"/developer/database",icon:gc,label:"Datenbankstruktur"}];return s.jsxs("aside",{className:"w-64 bg-gray-900 text-white min-h-screen flex flex-col",children:[s.jsx("div",{className:"p-4 border-b border-gray-800",children:s.jsx("h1",{className:"text-xl font-bold",children:"OpenCRM"})}),s.jsxs("nav",{className:"flex-1 p-4 overflow-y-auto",children:[s.jsx("ul",{className:"space-y-2",children:i.filter(o=>o.show).map(o=>s.jsx("li",{children:s.jsxs(Gc,{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:[s.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))}),a&&n("developer:access")&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-6 mb-2 px-4",children:s.jsxs("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider flex items-center gap-2",children:[s.jsx(xc,{className:"w-3 h-3"}),"Entwickler"]})}),s.jsx("ul",{className:"space-y-2",children:l.map(o=>s.jsx("li",{children:s.jsxs(Gc,{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:[s.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))})]}),s.jsx("div",{className:"mt-6 pt-6 border-t border-gray-800",children:s.jsxs(Gc,{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:[s.jsx(z0,{className:"w-5 h-5"}),"Einstellungen"]})})]}),s.jsxs("div",{className:"p-4 border-t border-gray-800",children:[s.jsxs("div",{className:"mb-4 text-sm",children:[s.jsx("p",{className:"text-gray-400",children:"Angemeldet als"}),s.jsxs("p",{className:"font-medium",children:[e==null?void 0:e.firstName," ",e==null?void 0:e.lastName]})]}),s.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:[s.jsx(JS,{className:"w-5 h-5"}),"Abmelden"]})]})]})}function m2(){const{settings:e}=P0(),[t,n]=j.useState(!1);j.useEffect(()=>{const a=()=>{window.scrollY>window.innerHeight*e.scrollToTopThreshold?n(!0):n(!1)};return window.addEventListener("scroll",a),()=>window.removeEventListener("scroll",a)},[e.scrollToTopThreshold]);const r=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?s.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:s.jsx(I0,{className:"w-5 h-5"})}):null}function h2(){return s.jsxs("div",{className:"flex min-h-screen",children:[s.jsx(d2,{}),s.jsx("main",{className:"flex-1 p-8 overflow-auto",children:s.jsx(yN,{})}),s.jsx(m2,{})]})}const T=j.forwardRef(({className:e="",variant:t="primary",size:n="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 s.jsx("button",{ref:l,className:`${o} ${c[t]} ${u[n]} ${e}`,disabled:a,...i,children:r})});T.displayName="Button";const q=j.forwardRef(({className:e="",label:t,error:n,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 s.jsxs("div",{className:"w-full",children:[t&&s.jsx("label",{htmlFor:o,className:"block text-sm font-medium text-gray-700 mb-1",children:t}),s.jsxs("div",{className:d?"flex gap-2":"",children:[s.jsx("input",{ref:l,id:o,className:`block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${n?"border-red-500":"border-gray-300"} ${e}`,...i}),d&&s.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:s.jsx(je,{className:"w-4 h-4"})})]}),n&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});q.displayName="Input";function Y({children:e,className:t="",title:n,actions:r}){return s.jsxs("div",{className:`bg-white rounded-lg shadow ${t}`,children:[(n||r)&&s.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 flex items-center justify-between",children:[n&&s.jsx("div",{className:"text-lg font-medium text-gray-900",children:n}),r&&s.jsx("div",{className:"flex items-center gap-2",children:r})]}),s.jsx("div",{className:"p-6",children:e})]})}function f2(){const[e,t]=j.useState(""),[n,r]=j.useState(""),[a,i]=j.useState(""),[l,o]=j.useState(!1),{login:c,customerLogin:u}=Ue(),d=Ht(),h=async p=>{p.preventDefault(),i(""),o(!0);try{await c(e,n),d("/");return}catch{}try{await u(e,n),d("/")}catch{i("Ungültige Anmeldedaten"),o(!1)}};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:s.jsxs(Y,{className:"w-full max-w-md",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"OpenCRM"}),s.jsx("p",{className:"text-gray-600 mt-2",children:"Melden Sie sich an"})]}),a&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:a}),s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(q,{label:"E-Mail",type:"email",value:e,onChange:p=>t(p.target.value),required:!0,autoComplete:"email"}),s.jsx(q,{label:"Passwort",type:"password",value:n,onChange:p=>r(p.target.value),required:!0,autoComplete:"current-password"}),s.jsx(T,{type:"submit",className:"w-full",disabled:l,children:l?"Anmeldung...":"Anmelden"})]})]})})}function ut({isOpen:e,onClose:t,title:n,children:r,size:a="md"}){if(j.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 s.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:s.jsxs("div",{className:"flex min-h-full items-center justify-center p-4",children:[s.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:t}),s.jsxs("div",{className:`relative bg-white rounded-lg shadow-xl w-full ${i[a]}`,children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n}),s.jsx(T,{variant:"ghost",size:"sm",onClick:t,children:s.jsx(Nn,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-6",children:r})]})]})})}function p2(){var S,M,P,z,L,U;const{user:e,isCustomer:t,isCustomerPortal:n}=Ue(),[r,a]=j.useState(!1),{data:i,isLoading:l}=me({queryKey:["app-settings-public"],queryFn:()=>Ur.getPublic(),enabled:n,staleTime:0}),o=!l&&((S=i==null?void 0:i.data)==null?void 0:S.customerSupportTicketsEnabled)==="true",{data:c}=me({queryKey:["customers-count"],queryFn:()=>kt.getAll({limit:1}),enabled:!t}),{data:u}=me({queryKey:["contracts",t?e==null?void 0:e.customerId:void 0],queryFn:()=>qe.getAll(t?{customerId:e==null?void 0:e.customerId}:{limit:1})}),{data:d}=me({queryKey:["contracts-active",t?e==null?void 0:e.customerId:void 0],queryFn:()=>qe.getAll({status:"ACTIVE",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:h}=me({queryKey:["contracts-pending",t?e==null?void 0:e.customerId:void 0],queryFn:()=>qe.getAll({status:"PENDING",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:p}=me({queryKey:["task-stats"],queryFn:()=>it.getStats()}),{data:m}=me({queryKey:["contract-cockpit"],queryFn:()=>qe.getCockpit(),enabled:!t,staleTime:0}),{ownContracts:f,representedContracts:y}=j.useMemo(()=>{if(!n||!(u!=null&&u.data))return{ownContracts:[],representedContracts:[]};const V=[],R={};for(const C of u.data)if(C.customerId===(e==null?void 0:e.customerId))V.push(C);else{const N=C.customerId;if(!R[N]){const K=C.customer?C.customer.companyName||`${C.customer.firstName} ${C.customer.lastName}`:`Kunde ${N}`;R[N]={customerName:K,contracts:[]}}R[N].contracts.push(C)}return{ownContracts:V,representedContracts:Object.values(R).sort((C,N)=>C.customerName.localeCompare(N.customerName))}},[u==null?void 0:u.data,n,e==null?void 0:e.customerId]),w=j.useMemo(()=>f.filter(V=>V.status==="ACTIVE").length,[f]),v=j.useMemo(()=>f.filter(V=>V.status==="PENDING").length,[f]),g=j.useMemo(()=>f.filter(V=>V.status==="EXPIRED").length,[f]),x=j.useMemo(()=>y.reduce((V,R)=>V+R.contracts.length,0),[y]),b=j.useMemo(()=>y.reduce((V,R)=>V+R.contracts.filter(C=>C.status==="ACTIVE").length,0),[y]),k=j.useMemo(()=>y.reduce((V,R)=>V+R.contracts.filter(C=>C.status==="EXPIRED").length,0),[y]),F=((M=p==null?void 0:p.data)==null?void 0:M.openCount)||0,E=V=>s.jsx(Y,{className:V.link?"cursor-pointer hover:shadow-md transition-shadow":"",children:V.link?s.jsx(we,{to:V.link,className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${V.color}`,children:s.jsx(V.icon,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm text-gray-500",children:V.label}),s.jsx("p",{className:"text-2xl font-bold",children:V.value})]})]})}):s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${V.color}`,children:s.jsx(V.icon,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm text-gray-500",children:V.label}),s.jsx("p",{className:"text-2xl font-bold",children:V.value})]})]})},V.label);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("h1",{className:"text-2xl font-bold",children:["Willkommen, ",e==null?void 0:e.firstName,"!"]}),n&&o&&s.jsxs(T,{onClick:()=>a(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Support-Anfrage"]})]}),n?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Km,{className:"w-5 h-5 text-blue-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Meine Verträge"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[E({label:"Eigene Verträge",value:f.length,icon:lt,color:"bg-blue-500",link:"/contracts"}),E({label:"Davon aktiv",value:w,icon:js,color:"bg-green-500"}),E({label:"Davon ausstehend",value:v,icon:bn,color:"bg-yellow-500"}),E({label:"Davon abgelaufen",value:g,icon:Ap,color:"bg-red-500"})]})]}),x>0&&s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(pa,{className:"w-5 h-5 text-purple-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Fremdverträge"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[E({label:"Fremdverträge",value:x,icon:pa,color:"bg-purple-500",link:"/contracts"}),E({label:"Davon aktiv",value:b,icon:js,color:"bg-green-500"}),s.jsx("div",{className:"hidden lg:block"}),E({label:"Davon abgelaufen",value:k,icon:Ap,color:"bg-red-500"})]})]}),s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Zi,{className:"w-5 h-5 text-orange-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Support-Anfragen"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:E({label:"Offene Anfragen",value:F,icon:Zi,color:"bg-orange-500",link:"/tasks"})})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6",children:[E({label:"Kunden",value:((P=c==null?void 0:c.pagination)==null?void 0:P.total)||0,icon:pa,color:"bg-blue-500",link:"/customers"}),E({label:"Verträge gesamt",value:((z=u==null?void 0:u.pagination)==null?void 0:z.total)||0,icon:lt,color:"bg-purple-500",link:"/contracts"}),E({label:"Aktive Verträge",value:((L=d==null?void 0:d.pagination)==null?void 0:L.total)||0,icon:js,color:"bg-green-500"}),E({label:"Ausstehende Verträge",value:((U=h==null?void 0:h.pagination)==null?void 0:U.total)||0,icon:hn,color:"bg-yellow-500"})]}),(m==null?void 0:m.data)&&s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(hn,{className:"w-5 h-5 text-red-500"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Vertrags-Cockpit"})]}),s.jsx(we,{to:"/contracts/cockpit",className:"text-sm text-blue-600 hover:underline",children:"Alle anzeigen"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsx(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(we,{to:"/contracts/cockpit?filter=critical",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-red-100",children:s.jsx(hn,{className:"w-6 h-6 text-red-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",m.data.thresholds.criticalDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-red-600",children:m.data.summary.criticalCount})]})]})})}),s.jsx(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(we,{to:"/contracts/cockpit?filter=warning",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-yellow-100",children:s.jsx(ir,{className:"w-6 h-6 text-yellow-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",m.data.thresholds.warningDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:m.data.summary.warningCount})]})]})})}),s.jsx(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(we,{to:"/contracts/cockpit?filter=ok",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-green-100",children:s.jsx(js,{className:"w-6 h-6 text-green-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",m.data.thresholds.okDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-green-600",children:m.data.summary.okCount})]})]})})}),s.jsx(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(we,{to:"/contracts/cockpit",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-gray-100",children:s.jsx(lt,{className:"w-6 h-6 text-gray-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm text-gray-500",children:"Handlungsbedarf"}),s.jsx("p",{className:"text-2xl font-bold text-gray-600",children:m.data.summary.totalContracts})]})]})})})]})]}),s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Gi,{className:"w-5 h-5 text-orange-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Aufgaben"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:E({label:"Offene Aufgaben",value:F,icon:Gi,color:"bg-orange-500",link:"/tasks"})})]})]}),n&&s.jsx(x2,{isOpen:r,onClose:()=>a(!1)})]})}function x2({isOpen:e,onClose:t}){const{user:n}=Ue(),r=Ht(),a=xe(),[i,l]=j.useState("own"),[o,c]=j.useState(null),[u,d]=j.useState(""),[h,p]=j.useState(""),[m,f]=j.useState(!1),[y,w]=j.useState(""),{data:v}=me({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>qe.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),g=j.useMemo(()=>{if(!(v!=null&&v.data))return{own:[],represented:{}};const S=[],M={};for(const P of v.data)if(P.customerId===(n==null?void 0:n.customerId))S.push(P);else{if(!M[P.customerId]){const z=P.customer?P.customer.companyName||`${P.customer.firstName} ${P.customer.lastName}`:`Kunde ${P.customerId}`;M[P.customerId]={name:z,contracts:[]}}M[P.customerId].contracts.push(P)}return{own:S,represented:M}},[v==null?void 0:v.data,n==null?void 0:n.customerId]),x=Object.keys(g.represented).length>0,b=j.useMemo(()=>{var S;return i==="own"?g.own:((S=g.represented[i])==null?void 0:S.contracts)||[]},[i,g]),k=j.useMemo(()=>{if(!y)return b;const S=y.toLowerCase();return b.filter(M=>M.contractNumber.toLowerCase().includes(S)||(M.providerName||"").toLowerCase().includes(S)||(M.tariffName||"").toLowerCase().includes(S))},[b,y]),F=async()=>{if(!(!o||!u.trim())){f(!0);try{await it.createSupportTicket(o,{title:u.trim(),description:h.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)}}},E=()=>{d(""),p(""),c(null),l("own"),w(""),t()};return s.jsx(ut,{isOpen:e,onClose:E,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[x&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),s.jsxs("select",{value:i,onChange:S=>{const M=S.target.value;l(M==="own"?"own":parseInt(M)),c(null),w("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(g.represented).map(([S,{name:M}])=>s.jsx("option",{value:S,children:M},S))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(q,{placeholder:"Vertrag suchen...",value:y,onChange:S=>w(S.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(S=>s.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:[s.jsx("div",{className:"font-medium",children:S.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[S.providerName||"Kein Anbieter",S.tariffName&&` - ${S.tariffName}`]})]},S.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(q,{value:u,onChange:S=>d(S.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:h,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"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:E,children:"Abbrechen"}),s.jsx(T,{onClick:F,disabled:!o||!u.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function ye({children:e,variant:t="default",className:n="",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 s.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${a[t]} ${n}`,onClick:r,children:e})}function g2(){const[e,t]=j.useState(""),[n,r]=j.useState(""),[a,i]=j.useState(1),{hasPermission:l}=Ue(),{data:o,isLoading:c}=me({queryKey:["customers",e,n,a],queryFn:()=>kt.getAll({search:e,type:n||void 0,page:a,limit:20})});return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Kunden"}),l("customers:create")&&s.jsx(we,{to:"/customers/new",children:s.jsxs(T,{children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Neuer Kunde"]})})]}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(q,{placeholder:"Suchen...",value:e,onChange:u=>t(u.target.value),className:"flex-1"}),s.jsxs("select",{value:n,onChange:u=>r(u.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg w-28 flex-shrink-0",children:[s.jsx("option",{value:"",children:"Alle"}),s.jsx("option",{value:"PRIVATE",children:"Privat"}),s.jsx("option",{value:"BUSINESS",children:"Firma"})]}),s.jsx(T,{variant:"secondary",className:"flex-shrink-0",children:s.jsx(ml,{className:"w-4 h-4"})})]})}),s.jsx(Y,{children:c?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):o!=null&&o.data&&o.data.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kundennr."}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Verträge"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:o.data.map(u=>{var d;return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:u.customerNumber}),s.jsx("td",{className:"py-3 px-4",children:u.type==="BUSINESS"&&u.companyName?u.companyName:`${u.firstName} ${u.lastName}`}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ye,{variant:u.type==="BUSINESS"?"info":"default",children:u.type==="BUSINESS"?"Firma":"Privat"})}),s.jsx("td",{className:"py-3 px-4",children:u.email||"-"}),s.jsx("td",{className:"py-3 px-4",children:((d=u._count)==null?void 0:d.contracts)||0}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(we,{to:`/customers/${u.id}`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Ae,{className:"w-4 h-4"})})}),l("customers:update")&&s.jsx(we,{to:`/customers/${u.id}/edit`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(tt,{className:"w-4 h-4"})})})]})})]},u.id)})})]})}),o.pagination&&o.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",o.pagination.page," von ",o.pagination.totalPages," (",o.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>i(u=>Math.max(1,u-1)),disabled:a===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>i(u=>u+1),disabled:a>=o.pagination.totalPages,children:"Weiter"})]})]})]}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kunden gefunden."})})]})}function y2({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailDeleted:r,isLoading:a,folder:i="INBOX",accountId:l}){const o=i==="SENT",[c,u]=j.useState(null),{hasPermission:d}=Ue(),h=E=>{if(o)try{const S=JSON.parse(E.toAddresses);if(S.length>0)return`An: ${S[0]}${S.length>1?` (+${S.length-1})`:""}`}catch{return"An: (Unbekannt)"}return E.fromName||E.fromAddress},p=xe(),m=H({mutationFn:E=>_e.toggleStar(E),onSuccess:(E,S)=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["email",S]})}}),f=H({mutationFn:({emailId:E,isRead:S})=>_e.markAsRead(E,S),onSuccess:(E,S)=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["email",S.emailId]}),l&&p.invalidateQueries({queryKey:["folder-counts",l]})}}),y=H({mutationFn:E=>_e.delete(E),onSuccess:(E,S)=>{p.invalidateQueries({queryKey:["emails"]}),l&&p.invalidateQueries({queryKey:["folder-counts",l]}),Ct.success("E-Mail in Papierkorb verschoben"),u(null),r==null||r(S)},onError:E=>{console.error("Delete error:",E),Ct.error(E.message||"Fehler beim Löschen der E-Mail"),u(null)}}),w=(E,S)=>{E.stopPropagation(),u(S)},v=E=>{E.stopPropagation(),c&&y.mutate(c)},g=E=>{E.stopPropagation(),u(null)},x=E=>{const S=new Date(E),M=new Date;return S.toDateString()===M.toDateString()?S.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):S.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},b=(E,S)=>{E.stopPropagation(),m.mutate(S)},k=(E,S)=>{E.stopPropagation(),f.mutate({emailId:S.id,isRead:!S.isRead})},F=E=>{E.isRead||f.mutate({emailId:E.id,isRead:!0}),n(E)};return a?s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[s.jsx(Hs,{className:"w-12 h-12 mb-2 opacity-50"}),s.jsx("p",{children:"Keine E-Mails vorhanden"})]}):s.jsxs("div",{className:"divide-y divide-gray-200",children:[e.map(E=>s.jsxs("div",{onClick:()=>F(E),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",t===E.id?"bg-blue-100":["hover:bg-gray-100",E.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:t===E.id?"4px solid #2563eb":"4px solid transparent"},children:[s.jsx("button",{onClick:S=>k(S,E),className:` - flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200 - ${E.isRead?"text-gray-400":"text-blue-600"} - `,title:E.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:E.isRead?s.jsx(O0,{className:"w-4 h-4"}):s.jsx(Hs,{className:"w-4 h-4"})}),s.jsx("button",{onClick:S=>b(S,E.id),className:` - flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200 - ${E.isStarred?"text-yellow-500":"text-gray-400"} - `,title:E.isStarred?"Stern entfernen":"Als wichtig markieren",children:s.jsx(_m,{className:`w-4 h-4 ${E.isStarred?"fill-current":""}`})}),d("emails:delete")&&s.jsx("button",{onClick:S=>w(S,E.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"E-Mail löschen",children:s.jsx(je,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("span",{className:`text-sm truncate ${E.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:h(E)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:x(E.receivedAt)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm truncate ${E.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:E.subject||"(Kein Betreff)"}),E.hasAttachments&&s.jsx(yc,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),E.contract&&s.jsx("div",{className:"mt-1",children:s.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:E.contract.contractNumber})})]}),s.jsx(ls,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},E.id)),c&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:g,disabled:y.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:v,disabled:y.isPending,children:y.isPending?"Löschen...":"Löschen"})]})]})})]})}function K0({email:e,onReply:t,onAssignContract:n,onDeleted:r,isSentFolder:a=!1,isContractView:i=!1,isTrashView:l=!1,onRestored:o,accountId:c}){const[u,d]=j.useState(!0),[h,p]=j.useState(e.isStarred),[m,f]=j.useState(!1),[y,w]=j.useState(!1),[v,g]=j.useState(!1),x=xe(),{hasPermission:b}=Ue();j.useEffect(()=>{p(e.isStarred)},[e.id,e.isStarred]);const k=H({mutationFn:()=>_e.toggleStar(e.id),onMutate:()=>{p(C=>!C)},onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),x.invalidateQueries({queryKey:["email",e.id]})},onError:()=>{p(e.isStarred)}}),F=H({mutationFn:()=>_e.unassignFromContract(e.id),onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),x.invalidateQueries({queryKey:["email",e.id]})}}),E=H({mutationFn:()=>_e.delete(e.id),onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),c&&x.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&x.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Ct.success("E-Mail in Papierkorb verschoben"),f(!1),r==null||r()},onError:C=>{console.error("Delete error:",C),Ct.error(C.message||"Fehler beim Löschen der E-Mail"),f(!1)}}),S=H({mutationFn:()=>_e.restore(e.id),onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),c&&x.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&x.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Ct.success("E-Mail wiederhergestellt"),w(!1),o==null||o()},onError:C=>{console.error("Restore error:",C),Ct.error(C.message||"Fehler beim Wiederherstellen der E-Mail"),w(!1)}}),M=H({mutationFn:()=>_e.permanentDelete(e.id),onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),c&&x.invalidateQueries({queryKey:["folder-counts",c]}),Ct.success("E-Mail endgültig gelöscht"),g(!1),r==null||r()},onError:C=>{console.error("Permanent delete error:",C),Ct.error(C.message||"Fehler beim endgültigen Löschen der E-Mail"),g(!1)}}),P=C=>new Date(C).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),z=C=>{try{return JSON.parse(C)}catch{return[]}},L=C=>{if(!C)return[];try{return JSON.parse(C)}catch{return[]}},U=z(e.toAddresses),V=e.ccAddresses?z(e.ccAddresses):[],R=L(e.attachmentNames);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"p-4 border-b border-gray-200 space-y-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:e.subject||"(Kein Betreff)"}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:l?s.jsxs(s.Fragment,{children:[s.jsxs(T,{variant:"secondary",size:"sm",onClick:()=>w(!0),title:"Wiederherstellen",children:[s.jsx(_0,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsxs(T,{variant:"danger",size:"sm",onClick:()=>g(!0),title:"Endgültig löschen",children:[s.jsx(je,{className:"w-4 h-4 mr-1"}),"Endgültig löschen"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>k.mutate(),className:`p-2 rounded-lg hover:bg-gray-100 ${h?"text-yellow-500":"text-gray-400"}`,title:h?"Stern entfernen":"Als wichtig markieren",children:s.jsx(_m,{className:`w-5 h-5 ${h?"fill-current":""}`})}),s.jsxs(T,{variant:"secondary",size:"sm",onClick:t,children:[s.jsx(s2,{className:"w-4 h-4 mr-1"}),"Antworten"]}),b("emails:delete")&&s.jsx(T,{variant:"danger",size:"sm",onClick:()=>f(!0),title:"E-Mail löschen",children:s.jsx(je,{className:"w-4 h-4"})})]})})]}),s.jsxs("div",{className:"text-sm space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"Von:"}),s.jsxs("span",{className:"font-medium text-gray-900",children:[e.fromName&&`${e.fromName} `,s.jsxs("span",{className:"text-gray-600",children:["<",e.fromAddress,">"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"An:"}),s.jsx("span",{className:"text-gray-700",children:U.join(", ")})]}),V.length>0&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"CC:"}),s.jsx("span",{className:"text-gray-700",children:V.join(", ")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"Am:"}),s.jsx("span",{className:"text-gray-700",children:P(e.receivedAt)})]})]}),s.jsx("div",{className:"flex items-center gap-2 pt-2",children:e.contract?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-50 border border-green-200 rounded-lg",children:[s.jsx(Fp,{className:"w-4 h-4 text-green-600"}),s.jsxs("span",{className:"text-sm text-green-800",children:["Zugeordnet zu:"," ",s.jsx(we,{to:`/contracts/${e.contract.id}`,className:"font-medium hover:underline",children:e.contract.contractNumber})]}),!(i&&a)&&!e.isAutoAssigned&&s.jsx("button",{onClick:()=>F.mutate(),className:"ml-2 p-1 hover:bg-green-100 rounded",title:"Zuordnung aufheben",children:s.jsx(Nn,{className:"w-4 h-4 text-green-600"})})]}):!i&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:n,children:[s.jsx(Fp,{className:"w-4 h-4 mr-1"}),"Vertrag zuordnen"]})}),R.length>0&&s.jsxs("div",{className:"pt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(yc,{className:"w-4 h-4 text-gray-400"}),s.jsxs("span",{className:"text-sm text-gray-500",children:[R.length," Anhang",R.length>1?"e":""]})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:R.map((C,N)=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-3 py-2 bg-gray-100 rounded-lg text-sm text-gray-700",children:[s.jsx("span",{className:"max-w-[200px] truncate mr-1",children:C}),s.jsx("a",{href:_e.getAttachmentUrl(e.id,C,!0),target:"_blank",rel:"noopener noreferrer",className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${C} öffnen`,children:s.jsx(Om,{className:"w-4 h-4 text-gray-500"})}),s.jsx("a",{href:_e.getAttachmentUrl(e.id,C),download:C,className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${C} herunterladen`,children:s.jsx(Fs,{className:"w-4 h-4 text-gray-500"})})]},N))})]})]}),e.htmlBody&&e.textBody&&s.jsxs("div",{className:"px-4 py-2 border-b border-gray-200 flex items-center gap-2",children:[s.jsx("button",{onClick:()=>d(!0),className:`px-3 py-1 text-sm rounded ${u?"bg-blue-100 text-blue-700":"text-gray-600 hover:bg-gray-100"}`,children:"HTML"}),s.jsx("button",{onClick:()=>d(!1),className:`px-3 py-1 text-sm rounded ${u?"text-gray-600 hover:bg-gray-100":"bg-blue-100 text-blue-700"}`,children:"Text"})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:u&&e.htmlBody?s.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.htmlBody}}):s.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-700 font-sans",children:e.textBody||"Kein Inhalt"})}),m&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>f(!1),disabled:E.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>E.mutate(),disabled:E.isPending,children:E.isPending?"Löschen...":"Löschen"})]})]})}),y&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail wiederherstellen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Die E-Mail wird wieder in den ursprünglichen Ordner (",e.folder==="SENT"?"Gesendet":"Posteingang",") verschoben."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>w(!1),disabled:S.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"primary",onClick:()=>S.mutate(),disabled:S.isPending,children:S.isPending?"Wird wiederhergestellt...":"Wiederherstellen"})]})]})}),v&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail endgültig löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Diese Aktion kann nicht rückgängig gemacht werden. Die E-Mail wird unwiderruflich gelöscht."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>g(!1),disabled:M.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>M.mutate(),disabled:M.isPending,children:M.isPending?"Wird gelöscht...":"Endgültig löschen"})]})]})})]})}function U0({isOpen:e,onClose:t,account:n,replyTo:r,onSuccess:a,contractId:i}){const[l,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(""),[p,m]=j.useState(""),[f,y]=j.useState([]),[w,v]=j.useState(null),g=j.useRef(null);j.useEffect(()=>{if(e){if(r){o(r.fromAddress||"");const L=r.subject||"",U=/^(Re|Aw|Fwd|Wg):\s*/i.test(L);h(U?L:`Re: ${L}`);const V=new Date(r.receivedAt).toLocaleString("de-DE"),R=r.textBody?` - ---- Ursprüngliche Nachricht --- -Von: ${r.fromName||r.fromAddress} -Am: ${V} - -${r.textBody}`:"";m(R)}else o(""),h(""),m("");u(""),y([]),v(null)}},[e,r]);const x=10*1024*1024,b=25*1024*1024,k=L=>new Promise((U,V)=>{const R=new FileReader;R.readAsDataURL(L),R.onload=()=>{const N=R.result.split(",")[1];U(N)},R.onerror=V}),F=async L=>{const U=L.target.files;if(!U)return;const V=[];let R=f.reduce((C,N)=>C+N.content.length*.75,0);for(const C of Array.from(U)){if(C.size>x){v(`Datei "${C.name}" ist zu groß (max. 10 MB)`);continue}if(R+C.size>b){v("Maximale Gesamtgröße der Anhänge erreicht (25 MB)");break}try{const N=await k(C);V.push({filename:C.name,content:N,contentType:C.type||"application/octet-stream"}),R+=C.size}catch{v(`Fehler beim Lesen von "${C.name}"`)}}V.length>0&&y(C=>[...C,...V]),g.current&&(g.current.value="")},E=L=>{y(U=>U.filter((V,R)=>R!==L))},S=L=>{const U=L.length*.75;return U<1024?`${Math.round(U)} B`:U<1024*1024?`${(U/1024).toFixed(1)} KB`:`${(U/(1024*1024)).toFixed(1)} MB`},M=H({mutationFn:()=>is.sendEmail(n.id,{to:l.split(",").map(L=>L.trim()).filter(Boolean),cc:c?c.split(",").map(L=>L.trim()).filter(Boolean):void 0,subject:d,text:p,inReplyTo:r==null?void 0:r.messageId,references:r!=null&&r.messageId?[r.messageId]:void 0,attachments:f.length>0?f:void 0,contractId:i}),onSuccess:()=>{a==null||a(),P()},onError:L=>{v(L instanceof Error?L.message:"Fehler beim Senden")}}),P=()=>{t()},z=()=>{if(!l.trim()){v("Bitte Empfänger angeben");return}if(!d.trim()){v("Bitte Betreff angeben");return}v(null),M.mutate()};return s.jsx(ut,{isOpen:e,onClose:P,title:r?"Antworten":"Neue E-Mail",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Von"}),s.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg text-sm text-gray-700",children:n.email})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["An ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:l,onChange:L=>o(L.target.value),placeholder:"empfaenger@example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Mehrere Empfänger mit Komma trennen"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"CC"}),s.jsx("input",{type:"text",value:c,onChange:L=>u(L.target.value),placeholder:"cc@example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Betreff ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:d,onChange:L=>h(L.target.value),placeholder:"Betreff eingeben",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Nachricht"}),s.jsx("textarea",{value:p,onChange:L=>m(L.target.value),rows:10,placeholder:"Ihre Nachricht...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Anhänge"}),s.jsx("input",{type:"file",ref:g,onChange:F,multiple:!0,className:"hidden"}),s.jsxs("button",{type:"button",onClick:()=>{var L;return(L=g.current)==null?void 0:L.click()},className:"inline-flex items-center px-3 py-2 text-sm border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:[s.jsx(yc,{className:"w-4 h-4 mr-2"}),"Datei anhängen"]}),f.length>0&&s.jsx("div",{className:"mt-2 space-y-2",children:f.map((L,U)=>s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 rounded-lg",children:[s.jsxs("div",{className:"flex items-center min-w-0",children:[s.jsx(lt,{className:"w-4 h-4 text-gray-500 mr-2 flex-shrink-0"}),s.jsx("span",{className:"text-sm text-gray-700 truncate",children:L.filename}),s.jsxs("span",{className:"ml-2 text-xs text-gray-500 flex-shrink-0",children:["(",S(L.content),")"]})]}),s.jsx("button",{type:"button",onClick:()=>E(U),className:"ml-2 p-1 text-gray-400 hover:text-red-500 transition-colors",title:"Anhang entfernen",children:s.jsx(Nn,{className:"w-4 h-4"})})]},U))}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Max. 10 MB pro Datei, 25 MB gesamt"})]}),w&&s.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:w}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:P,children:"Abbrechen"}),s.jsxs(T,{onClick:z,disabled:M.isPending,children:[s.jsx(hl,{className:"w-4 h-4 mr-2"}),M.isPending?"Wird gesendet...":"Senden"]})]})]})})}function v2({isOpen:e,onClose:t,email:n,customerId:r,onSuccess:a}){const[i,l]=j.useState(""),[o,c]=j.useState(null),u=xe(),{data:d,isLoading:h}=me({queryKey:["contracts","customer",r],queryFn:()=>qe.getAll({customerId:r}),enabled:e}),m=((d==null?void 0:d.data)||[]).filter(g=>{var b,k,F,E;if(!i)return!0;const x=i.toLowerCase();return g.contractNumber.toLowerCase().includes(x)||((k=(b=g.contractCategory)==null?void 0:b.name)==null?void 0:k.toLowerCase().includes(x))||((E=(F=g.provider)==null?void 0:F.name)==null?void 0:E.toLowerCase().includes(x))}),f=H({mutationFn:g=>_e.assignToContract(n.id,g),onSuccess:(g,x)=>{u.invalidateQueries({queryKey:["emails"]}),u.invalidateQueries({queryKey:["email",n.id]}),u.invalidateQueries({queryKey:["contract-folder-counts",x]}),a==null||a(),y()}}),y=()=>{l(""),c(null),t()},w=()=>{o&&f.mutate(o)},v=g=>g?new Date(g).toLocaleDateString("de-DE"):"-";return s.jsx(ut,{isOpen:e,onClose:y,title:"E-Mail Vertrag zuordnen",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("span",{className:"font-medium",children:"Betreff:"})," ",n.subject||"(Kein Betreff)"]}),s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("span",{className:"font-medium",children:"Von:"})," ",n.fromAddress]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(ml,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx("input",{type:"text",value:i,onChange:g=>l(g.target.value),placeholder:"Vertrag suchen...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),s.jsx("div",{className:"border border-gray-200 rounded-lg max-h-80 overflow-auto",children:h?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):m.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(lt,{className:"w-8 h-8 mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:"Keine Verträge gefunden"})]}):s.jsx("div",{className:"divide-y divide-gray-200",children:m.map(g=>{var x;return s.jsx("div",{onClick:()=>c(g.id),className:` - flex items-center gap-3 p-3 cursor-pointer transition-colors - ${o===g.id?"bg-blue-50 border-l-2 border-l-blue-500":"hover:bg-gray-50"} - `,children:s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-medium text-gray-900",children:g.contractNumber}),s.jsx("span",{className:` - px-2 py-0.5 text-xs rounded-full - ${g.status==="ACTIVE"?"bg-green-100 text-green-800":g.status==="PENDING"?"bg-yellow-100 text-yellow-800":g.status==="CANCELLED"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"} - `,children:g.status})]}),s.jsxs("div",{className:"text-sm text-gray-600 truncate",children:[(x=g.contractCategory)==null?void 0:x.name,g.provider&&` - ${g.provider.name}`]}),s.jsxs("div",{className:"text-xs text-gray-500",children:["Start: ",v(g.startDate)]})]})},g.id)})})}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:y,children:"Abbrechen"}),s.jsx(T,{onClick:w,disabled:!o||f.isPending,children:f.isPending?"Wird zugeordnet...":"Zuordnen"})]})]})})}function B0({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailRestored:r,onEmailDeleted:a,isLoading:i}){const[l,o]=j.useState(null),[c,u]=j.useState(null),d=xe(),h=b=>{if(b.folder==="SENT")try{const k=JSON.parse(b.toAddresses);if(k.length>0)return`An: ${k[0]}${k.length>1?` (+${k.length-1})`:""}`}catch{return"An: (Unbekannt)"}return b.fromName||b.fromAddress},p=H({mutationFn:b=>_e.restore(b),onSuccess:(b,k)=>{d.invalidateQueries({queryKey:["emails"]}),Ct.success("E-Mail wiederhergestellt"),o(null),u(null),r==null||r(k)},onError:b=>{console.error("Restore error:",b),Ct.error(b.message||"Fehler beim Wiederherstellen"),o(null),u(null)}}),m=H({mutationFn:b=>_e.permanentDelete(b),onSuccess:(b,k)=>{d.invalidateQueries({queryKey:["emails"]}),Ct.success("E-Mail endgültig gelöscht"),o(null),u(null),a==null||a(k)},onError:b=>{console.error("Permanent delete error:",b),Ct.error(b.message||"Fehler beim endgültigen Löschen"),o(null),u(null)}}),f=(b,k)=>{b.stopPropagation(),o(k),u("restore")},y=(b,k)=>{b.stopPropagation(),o(k),u("delete")},w=b=>{b.stopPropagation(),l&&c&&(c==="restore"?p.mutate(l):m.mutate(l))},v=b=>{b.stopPropagation(),o(null),u(null)},g=b=>new Date(b).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"}),x=b=>{if(!b)return"";const k=new Date(b),F=new Date;return k.toDateString()===F.toDateString()?`Gelöscht um ${k.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}`:`Gelöscht am ${k.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})}`};return i?s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-red-600"})}):e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[s.jsx(je,{className:"w-12 h-12 mb-2 opacity-50"}),s.jsx("p",{children:"Papierkorb ist leer"})]}):s.jsxs("div",{className:"divide-y divide-gray-200",children:[e.map(b=>s.jsxs("div",{onClick:()=>n(b),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",t===b.id?"bg-red-100":"hover:bg-gray-100 bg-gray-50/50"].join(" "),style:{borderLeft:t===b.id?"4px solid #dc2626":"4px solid transparent"},children:[s.jsx("div",{className:"flex-shrink-0 mt-1 p-1 -ml-1 text-gray-400",title:b.folder==="SENT"?"Aus Gesendet":"Aus Posteingang",children:b.folder==="SENT"?s.jsx(hl,{className:"w-4 h-4"}):s.jsx(Fr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:k=>f(k,b.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-green-100 text-gray-400 hover:text-green-600",title:"Wiederherstellen",children:s.jsx(_0,{className:"w-4 h-4"})}),s.jsx("button",{onClick:k=>y(k,b.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"Endgültig löschen",children:s.jsx(je,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("span",{className:"text-sm truncate text-gray-700",children:h(b)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:g(b.receivedAt)})]}),s.jsx("div",{className:"text-sm truncate text-gray-600",children:b.subject||"(Kein Betreff)"}),s.jsx("div",{className:"text-xs text-red-500 mt-1",children:x(b.deletedAt)})]}),s.jsx(ls,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},b.id)),l&&c&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:c==="restore"?"E-Mail wiederherstellen?":"E-Mail endgültig löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:c==="restore"?"Die E-Mail wird wieder in den ursprünglichen Ordner verschoben.":"Die E-Mail wird unwiderruflich gelöscht. Diese Aktion kann nicht rückgängig gemacht werden."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:v,disabled:p.isPending||m.isPending,children:"Abbrechen"}),s.jsx(T,{variant:c==="restore"?"primary":"danger",onClick:w,disabled:p.isPending||m.isPending,children:p.isPending||m.isPending?"Wird ausgeführt...":c==="restore"?"Wiederherstellen":"Endgültig löschen"})]})]})})]})}function j2({customerId:e}){const[t,n]=j.useState(null),[r,a]=j.useState("INBOX"),[i,l]=j.useState(null),[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,p]=j.useState(null),m=xe(),{hasPermission:f}=Ue(),y=f("emails:delete"),{data:w,isLoading:v}=me({queryKey:["mailbox-accounts",e],queryFn:()=>_e.getMailboxAccounts(e)}),g=(w==null?void 0:w.data)||[];j.useEffect(()=>{g.length>0&&!t&&n(g[0].id)},[g,t]);const x=g.find(oe=>oe.id===t),{data:b,isLoading:k,refetch:F}=me({queryKey:["emails","customer",e,t,r],queryFn:()=>_e.getForCustomer(e,{accountId:t||void 0,folder:r}),enabled:!!t&&r!=="TRASH"}),E=(b==null?void 0:b.data)||[],{data:S,isLoading:M}=me({queryKey:["emails","trash",e],queryFn:()=>_e.getTrash(e),enabled:r==="TRASH"&&y}),P=(S==null?void 0:S.data)||[],{data:z}=me({queryKey:["folder-counts",t],queryFn:()=>is.getFolderCounts(t),enabled:!!t}),L=(z==null?void 0:z.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0,trash:0,trashUnread:0},{data:U}=me({queryKey:["email",i==null?void 0:i.id],queryFn:()=>_e.getById(i.id),enabled:!!(i!=null&&i.id)}),V=(U==null?void 0:U.data)||i,R=H({mutationFn:oe=>is.syncEmails(oe),onSuccess:()=>{m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),m.invalidateQueries({queryKey:["mailbox-accounts",e]})}}),C=()=>{t&&R.mutate(t)},N=oe=>{l(oe)},K=()=>{p(V||null),c(!0)},X=()=>{p(null),c(!0)},te=()=>{d(!0)};if(!v&&g.length===0)return s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Hs,{className:"w-16 h-16 mb-4 opacity-30"}),s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Keine E-Mail-Konten vorhanden"}),s.jsx("p",{className:"text-sm text-center max-w-md",children:"Erstellen Sie eine Stressfrei-Wechseln E-Mail-Adresse mit aktivierter Mailbox, um E-Mails hier empfangen und versenden zu können."})]});const pe=oe=>{a(oe),l(null)};return s.jsxs("div",{className:"flex flex-col h-full",style:{minHeight:"600px"},children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 p-4 border-b border-gray-200 bg-gray-50",children:[g.length>1?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Fr,{className:"w-5 h-5 text-gray-500"}),s.jsx("select",{value:t||"",onChange:oe=>{n(Number(oe.target.value)),l(null)},className:"px-3 py-2 border border-gray-300 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm",children:g.map(oe=>s.jsx("option",{value:oe.id,children:oe.email},oe.id))})]}):s.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-600",children:[s.jsx(Fr,{className:"w-5 h-5 text-gray-500"}),s.jsx("span",{children:x==null?void 0:x.email})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>pe("INBOX"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Fr,{className:"w-4 h-4"}),"Posteingang",L.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${L.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${L.inboxUnread} ungelesen / ${L.inbox} gesamt`,children:L.inboxUnread>0?`${L.inboxUnread}/${L.inbox}`:L.inbox})]}),s.jsxs("button",{onClick:()=>pe("SENT"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(hl,{className:"w-4 h-4"}),"Gesendet",L.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${L.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${L.sentUnread} ungelesen / ${L.sent} gesamt`,children:L.sentUnread>0?`${L.sentUnread}/${L.sent}`:L.sent})]}),y&&s.jsxs("button",{onClick:()=>pe("TRASH"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="TRASH"?"bg-white text-red-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(je,{className:"w-4 h-4"}),"Papierkorb",L.trash>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${L.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${L.trashUnread} ungelesen / ${L.trash} gesamt`,children:L.trashUnread>0?`${L.trashUnread}/${L.trash}`:L.trash})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r!=="TRASH"&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:C,disabled:R.isPending||!t,children:[s.jsx(fr,{className:`w-4 h-4 mr-1 ${R.isPending?"animate-spin":""}`}),R.isPending?"Sync...":"Synchronisieren"]}),s.jsxs(T,{size:"sm",onClick:X,disabled:!x,children:[s.jsx(ze,{className:"w-4 h-4 mr-1"}),"Neue E-Mail"]})]})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.jsx("div",{className:"w-1/3 border-r border-gray-200 overflow-auto",children:r==="TRASH"?s.jsx(B0,{emails:P,selectedEmailId:i==null?void 0:i.id,onSelectEmail:N,onEmailRestored:oe=>{(i==null?void 0:i.id)===oe&&l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},onEmailDeleted:oe=>{(i==null?void 0:i.id)===oe&&l(null),m.invalidateQueries({queryKey:["emails","trash"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:M}):s.jsx(y2,{emails:E,selectedEmailId:i==null?void 0:i.id,onSelectEmail:N,onEmailDeleted:oe=>{(i==null?void 0:i.id)===oe&&l(null),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:k,folder:r,accountId:t})}),s.jsx("div",{className:"flex-1 overflow-auto",children:V?s.jsx(K0,{email:V,onReply:K,onAssignContract:te,onDeleted:()=>{l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},isSentFolder:r==="SENT",isTrashView:r==="TRASH",onRestored:()=>{l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},accountId:t||void 0}):s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[s.jsx(Hs,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),x&&s.jsx(U0,{isOpen:o,onClose:()=>{c(!1),p(null)},account:x,replyTo:h||void 0,onSuccess:()=>{m.invalidateQueries({queryKey:["emails","customer",e,t,"SENT"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),r==="SENT"&&F()}}),V&&s.jsx(v2,{isOpen:u,onClose:()=>d(!1),email:V,customerId:e,onSuccess:()=>{F()}})]})}function b2({contractId:e,customerId:t}){const[n,r]=j.useState(null),[a,i]=j.useState("INBOX"),[l,o]=j.useState(null),[c,u]=j.useState(!1),[d,h]=j.useState(null),[p,m]=j.useState(null),f=xe(),{hasPermission:y}=Ue(),w=y("emails:delete"),{data:v,isLoading:g}=me({queryKey:["mailbox-accounts",t],queryFn:()=>_e.getMailboxAccounts(t)}),x=(v==null?void 0:v.data)||[];j.useEffect(()=>{x.length>0&&!n&&r(x[0].id)},[x,n]);const b=x.find(G=>G.id===n),{data:k,isLoading:F,refetch:E}=me({queryKey:["emails","contract",e,a],queryFn:()=>_e.getForContract(e,{folder:a}),enabled:a!=="TRASH"}),S=(k==null?void 0:k.data)||[],{data:M,isLoading:P}=me({queryKey:["emails","trash",t],queryFn:()=>_e.getTrash(t),enabled:a==="TRASH"&&w}),z=(M==null?void 0:M.data)||[],{data:L}=me({queryKey:["contract-folder-counts",e],queryFn:()=>_e.getContractFolderCounts(e)}),U=(L==null?void 0:L.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0},{data:V}=me({queryKey:["folder-counts",n],queryFn:()=>is.getFolderCounts(n),enabled:!!n&&w}),R=(V==null?void 0:V.data)||{trash:0,trashUnread:0},{data:C}=me({queryKey:["email",l==null?void 0:l.id],queryFn:()=>_e.getById(l.id),enabled:!!(l!=null&&l.id)}),N=(C==null?void 0:C.data)||l,K=H({mutationFn:G=>is.syncEmails(G),onSuccess:()=>{f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]}),Ct.success("Synchronisation abgeschlossen")},onError:G=>{Ct.error(G.message||"Synchronisation fehlgeschlagen")}}),X=H({mutationFn:G=>_e.toggleStar(G),onSuccess:(G,ke)=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["email",ke]})}}),te=H({mutationFn:({emailId:G,isRead:ke})=>_e.markAsRead(G,ke),onSuccess:(G,ke)=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["email",ke.emailId]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})}}),pe=H({mutationFn:G=>_e.unassignFromContract(G),onSuccess:()=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),o(null),Ct.success("Zuordnung aufgehoben")},onError:G=>{Ct.error(G.message||"Fehler beim Aufheben der Zuordnung")}}),oe=H({mutationFn:G=>_e.delete(G),onSuccess:(G,ke)=>{f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]}),Ct.success("E-Mail in Papierkorb verschoben"),m(null),(l==null?void 0:l.id)===ke&&o(null)},onError:G=>{Ct.error(G.message||"Fehler beim Löschen der E-Mail"),m(null)}}),Ge=()=>{n&&K.mutate(n)},Q=G=>{const ke=new Date(G),Ha=new Date;return ke.toDateString()===Ha.toDateString()?ke.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):ke.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},Se=(G,ke)=>{G.stopPropagation(),X.mutate(ke)},Me=(G,ke)=>{G.stopPropagation(),te.mutate({emailId:ke.id,isRead:!ke.isRead})},Qe=G=>{G.isRead||te.mutate({emailId:G.id,isRead:!0}),o(G)},ft=()=>{h(N||null),u(!0)},jt=()=>{h(null),u(!0)},W=(G,ke)=>{G.stopPropagation(),(l==null?void 0:l.id)===ke&&o(null),pe.mutate(ke)},$e=(G,ke)=>{G.stopPropagation(),m(ke)},Dt=G=>{G.stopPropagation(),p&&oe.mutate(p)},Cn=G=>{G.stopPropagation(),m(null)},fs=G=>{i(G),o(null)},En=G=>{if(a==="SENT")try{const ke=JSON.parse(G.toAddresses);if(ke.length>0)return`An: ${ke[0]}${ke.length>1?` (+${ke.length-1})`:""}`}catch{return"An: (Unbekannt)"}return G.fromName||G.fromAddress};return!g&&x.length===0?s.jsx(Y,{title:"E-Mails",children:s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(Hs,{className:"w-10 h-10 mb-2 opacity-30"}),s.jsx("p",{className:"text-sm",children:"Keine E-Mail-Konten vorhanden"}),s.jsx("p",{className:"text-xs mt-1",children:"Erstellen Sie eine E-Mail-Adresse beim Kunden mit aktivierter Mailbox"})]})}):s.jsxs(Y,{title:s.jsx("div",{className:"flex items-center gap-4",children:s.jsx("span",{children:"E-Mails"})}),actions:s.jsxs("div",{className:"flex items-center gap-2",children:[a!=="TRASH"&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:Ge,disabled:K.isPending||!n,children:[s.jsx(fr,{className:`w-4 h-4 mr-1 ${K.isPending?"animate-spin":""}`}),K.isPending?"Sync...":"Sync"]}),b&&s.jsxs(T,{size:"sm",onClick:jt,children:[s.jsx(ze,{className:"w-4 h-4 mr-1"}),"Neue E-Mail"]})]}),children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4 border-b border-gray-200 -mt-2",children:[x.length>1?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Fr,{className:"w-4 h-4 text-gray-500"}),s.jsx("select",{value:n||"",onChange:G=>{r(Number(G.target.value)),o(null)},className:"px-2 py-1.5 border border-gray-300 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm",children:x.map(G=>s.jsx("option",{value:G.id,children:G.email},G.id))})]}):s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[s.jsx(Fr,{className:"w-4 h-4 text-gray-500"}),s.jsx("span",{children:b==null?void 0:b.email})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>fs("INBOX"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${a==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Fr,{className:"w-4 h-4"}),"Posteingang",U.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${U.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${U.inboxUnread} ungelesen / ${U.inbox} gesamt`,children:U.inboxUnread>0?`${U.inboxUnread}/${U.inbox}`:U.inbox})]}),s.jsxs("button",{onClick:()=>fs("SENT"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${a==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(hl,{className:"w-4 h-4"}),"Gesendet",U.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${U.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${U.sentUnread} ungelesen / ${U.sent} gesamt`,children:U.sentUnread>0?`${U.sentUnread}/${U.sent}`:U.sent})]}),w&&s.jsxs("button",{onClick:()=>fs("TRASH"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${a==="TRASH"?"bg-white text-red-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(je,{className:"w-4 h-4"}),"Papierkorb",R.trash>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${R.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${R.trashUnread} ungelesen / ${R.trash} gesamt`,children:R.trashUnread>0?`${R.trashUnread}/${R.trash}`:R.trash})]})]})]}),(a==="TRASH"?P:F)?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):(a==="TRASH"?z.length===0:S.length===0)?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(Hs,{className:"w-10 h-10 mb-2 opacity-30"}),s.jsx("p",{className:"text-sm",children:a==="INBOX"?"Keine E-Mails zugeordnet":a==="SENT"?"Keine E-Mails über diesen Vertrag gesendet":"Papierkorb ist leer"}),a==="INBOX"&&s.jsx("p",{className:"text-xs mt-1",children:"E-Mails können im E-Mail-Tab des Kunden zugeordnet werden"})]}):s.jsxs("div",{className:"flex -mx-6 -mb-6",style:{minHeight:"400px"},children:[s.jsx("div",{className:"w-1/3 border-r border-gray-200 overflow-auto",children:a==="TRASH"?s.jsx(B0,{emails:z,selectedEmailId:l==null?void 0:l.id,onSelectEmail:Qe,onEmailRestored:G=>{(l==null?void 0:l.id)===G&&o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["folder-counts",n]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]})},onEmailDeleted:G=>{(l==null?void 0:l.id)===G&&o(null),f.invalidateQueries({queryKey:["emails","trash"]}),f.invalidateQueries({queryKey:["folder-counts",n]})},isLoading:P}):s.jsx("div",{className:"divide-y divide-gray-200",children:S.map(G=>s.jsxs("div",{onClick:()=>Qe(G),className:["flex items-start gap-2 p-3 cursor-pointer transition-colors",(l==null?void 0:l.id)===G.id?"bg-blue-100":["hover:bg-gray-100",G.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:(l==null?void 0:l.id)===G.id?"4px solid #2563eb":"4px solid transparent"},children:[s.jsx("button",{onClick:ke=>Me(ke,G),className:` - flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200 - ${G.isRead?"text-gray-400":"text-blue-600"} - `,title:G.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:G.isRead?s.jsx(O0,{className:"w-4 h-4"}):s.jsx(Hs,{className:"w-4 h-4"})}),s.jsx("button",{onClick:ke=>Se(ke,G.id),className:` - flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200 - ${G.isStarred?"text-yellow-500":"text-gray-400"} - `,title:G.isStarred?"Stern entfernen":"Als wichtig markieren",children:s.jsx(_m,{className:`w-4 h-4 ${G.isStarred?"fill-current":""}`})}),y("emails:delete")&&s.jsx("button",{onClick:ke=>$e(ke,G.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"E-Mail löschen",children:s.jsx(je,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("span",{className:`text-sm truncate ${G.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:En(G)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:Q(G.receivedAt)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm truncate ${G.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:G.subject||"(Kein Betreff)"}),G.hasAttachments&&s.jsx(yc,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]})]}),(a==="INBOX"||a==="SENT"&&!G.isAutoAssigned)&&s.jsx("button",{onClick:ke=>W(ke,G.id),className:"flex-shrink-0 mt-1 p-1 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",children:s.jsx(Nn,{className:"w-4 h-4"})}),s.jsx(ls,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},G.id))})}),s.jsx("div",{className:"flex-1 overflow-auto",children:N&&l?s.jsx(K0,{email:N,onReply:ft,onAssignContract:()=>{},onDeleted:()=>{o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})},isSentFolder:a==="SENT",isContractView:a!=="TRASH",isTrashView:a==="TRASH",onRestored:()=>{o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})},accountId:N==null?void 0:N.stressfreiEmailId}):s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[s.jsx(Hs,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),p&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:Cn,disabled:oe.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:Dt,disabled:oe.isPending,children:oe.isPending?"Löschen...":"Löschen"})]})]})}),b&&s.jsx(U0,{isOpen:c,onClose:()=>{u(!1),h(null)},account:b,replyTo:d||void 0,contractId:e,onSuccess:()=>{f.invalidateQueries({queryKey:["emails","contract",e,"SENT"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),a==="SENT"&&E()}})]})}function N2({tabs:e,defaultTab:t}){var a,i;const[n,r]=j.useState(t||((a=e[0])==null?void 0:a.id));return s.jsxs("div",{children:[s.jsx("div",{className:"border-b border-gray-200",children:s.jsx("nav",{className:"flex -mb-px space-x-8",children:e.map(l=>s.jsx("button",{onClick:()=>r(l.id),className:`py-4 px-1 border-b-2 font-medium text-sm whitespace-nowrap ${n===l.id?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:l.label},l.id))})}),s.jsx("div",{className:"mt-4",children:(i=e.find(l=>l.id===n))==null?void 0:i.content})]})}const Oe=j.forwardRef(({className:e="",label:t,error:n,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 s.jsxs("div",{className:u?e:"w-full",children:[t&&s.jsx("label",{htmlFor:c,className:"block text-sm font-medium text-gray-700 mb-1",children:t}),s.jsxs("select",{ref:o,id:c,className:`block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${n?"border-red-500":"border-gray-300"}`,...l,children:[s.jsx("option",{value:"",children:i}),r.map(d=>s.jsx("option",{value:d.value,children:d.label},d.value))]}),n&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});Oe.displayName="Select";function St({onUpload:e,existingFile:t,accept:n=".pdf,.jpg,.jpeg,.png",label:r="Dokument hochladen",disabled:a=!1}){const i=j.useRef(null),[l,o]=j.useState(!1),[c,u]=j.useState(!1),d=async y=>{if(y){o(!0);try{await e(y)}catch(w){console.error("Upload failed:",w),alert("Upload fehlgeschlagen")}finally{o(!1)}}},h=y=>{var v;const w=(v=y.target.files)==null?void 0:v[0];w&&d(w)},p=y=>{var v;y.preventDefault(),u(!1);const w=(v=y.dataTransfer.files)==null?void 0:v[0];w&&d(w)},m=y=>{y.preventDefault(),u(!0)},f=()=>{u(!1)};return s.jsxs("div",{className:"space-y-2",children:[t?!a&&s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>{var y;return(y=i.current)==null?void 0:y.click()},disabled:l,children:l?"Wird hochgeladen...":"Ersetzen"}):s.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 y;return!a&&((y=i.current)==null?void 0:y.click())},onDrop:a?void 0:p,onDragOver:a?void 0:m,onDragLeave:a?void 0:f,children:l?s.jsxs("div",{className:"text-gray-500",children:[s.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..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Sd,{className:"w-6 h-6 text-gray-400 mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-gray-600",children:r}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"PDF, JPG oder PNG (max. 10MB)"})]})}),s.jsx("input",{ref:i,type:"file",accept:n,onChange:h,className:"hidden",disabled:a||l})]})}function de({value:e,className:t="",size:n="sm",title:r="In Zwischenablage kopieren"}){const[a,i]=j.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=n==="sm"?"w-3.5 h-3.5":"w-4 h-4";return s.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?s.jsx(zo,{className:o}):s.jsx(Rm,{className:o})})}function q0({values:e,separator:t=` -`,children:n,className:r=""}){const a=e.filter(i=>i!=null&&i!=="").map(String).join(t);return a?s.jsxs("div",{className:`relative group ${r}`,children:[n,s.jsx(de,{value:a,className:"absolute top-0 right-0 opacity-60 group-hover:opacity-100",title:"Alles kopieren"})]}):s.jsx(s.Fragment,{children:n})}function w2(){var K,X;const{id:e}=ac(),t=Ht(),n=xe(),{hasPermission:r}=Ue(),[a]=lc(),i=parseInt(e),l=a.get("tab")||"addresses",[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,p]=j.useState(!1),[m,f]=j.useState(!1),[y,w]=j.useState(!1),[v,g]=j.useState(!1),[x,b]=j.useState(null),[k,F]=j.useState(null),[E,S]=j.useState(null),[M,P]=j.useState(null),[z,L]=j.useState(null),{data:U,isLoading:V}=me({queryKey:["customer",e],queryFn:()=>kt.getById(i)}),R=H({mutationFn:()=>kt.delete(i),onSuccess:()=>{t("/customers")}});if(V)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(U!=null&&U.data))return s.jsx("div",{className:"text-center py-8 text-red-600",children:"Kunde nicht gefunden"});const C=U.data,N=[{id:"addresses",label:"Adressen",content:s.jsx(C2,{customerId:i,addresses:C.addresses||[],canEdit:r("customers:update"),onAdd:()=>c(!0),onEdit:te=>S(te)})},{id:"bankcards",label:"Bankkarten",content:s.jsx(E2,{customerId:i,bankCards:C.bankCards||[],canEdit:r("customers:update"),showInactive:v,onToggleInactive:()=>g(!v),onAdd:()=>d(!0),onEdit:te=>b(te)})},{id:"documents",label:"Ausweise",content:s.jsx(D2,{customerId:i,documents:C.identityDocuments||[],canEdit:r("customers:update"),showInactive:v,onToggleInactive:()=>g(!v),onAdd:()=>p(!0),onEdit:te=>F(te)})},{id:"meters",label:"Zähler",content:s.jsx(P2,{customerId:i,meters:C.meters||[],canEdit:r("customers:update"),showInactive:v,onToggleInactive:()=>g(!v),onAdd:()=>f(!0),onEdit:te=>P(te)})},{id:"stressfrei",label:"Stressfrei-Wechseln",content:s.jsx(F2,{customerId:i,emails:C.stressfreiEmails||[],canEdit:r("customers:update"),showInactive:v,onToggleInactive:()=>g(!v),onAdd:()=>w(!0),onEdit:te=>L(te)})},{id:"emails",label:"E-Mail-Postfach",content:s.jsx(j2,{customerId:i})},{id:"contracts",label:"Verträge",content:s.jsx(A2,{customerId:i,contracts:C.contracts||[]})},...r("customers:update")?[{id:"portal",label:"Portal",content:s.jsx(T2,{customerId:i,canEdit:r("customers:update")})}]:[]];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:C.type==="BUSINESS"&&C.companyName?C.companyName:`${C.firstName} ${C.lastName}`}),s.jsxs("p",{className:"text-gray-500 font-mono flex items-center gap-1",children:[C.customerNumber,s.jsx(de,{value:C.customerNumber})]})]}),s.jsxs("div",{className:"flex gap-2",children:[r("customers:update")&&s.jsx(we,{to:`/customers/${e}/edit`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(tt,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),r("customers:delete")&&s.jsxs(T,{variant:"danger",onClick:()=>{confirm("Kunde wirklich löschen?")&&R.mutate()},children:[s.jsx(je,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[s.jsx(Y,{title:"Stammdaten",className:"lg:col-span-2",children:s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Typ"}),s.jsx("dd",{children:s.jsx(ye,{variant:C.type==="BUSINESS"?"info":"default",children:C.type==="BUSINESS"?"Geschäftskunde":"Privatkunde"})})]}),C.salutation&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anrede"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[C.salutation,s.jsx(de,{value:C.salutation})]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorname"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[C.firstName,s.jsx(de,{value:C.firstName})]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Nachname"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[C.lastName,s.jsx(de,{value:C.lastName})]})]}),C.companyName&&s.jsxs("div",{className:"col-span-2",children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Firma"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[C.companyName,s.jsx(de,{value:C.companyName})]})]}),C.foundingDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Gründungsdatum"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(C.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(de,{value:new Date(C.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),C.birthDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsdatum"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(C.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(de,{value:new Date(C.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),C.birthPlace&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsort"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[C.birthPlace,s.jsx(de,{value:C.birthPlace})]})]})]})}),s.jsx(Y,{title:"Kontakt",children:s.jsxs("dl",{className:"space-y-3",children:[C.email&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"E-Mail"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[s.jsx("a",{href:`mailto:${C.email}`,className:"text-blue-600 hover:underline",children:C.email}),s.jsx(de,{value:C.email})]})]}),C.phone&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Telefon"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[s.jsx("a",{href:`tel:${C.phone}`,className:"text-blue-600 hover:underline",children:C.phone}),s.jsx(de,{value:C.phone})]})]}),C.mobile&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Mobil"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[s.jsx("a",{href:`tel:${C.mobile}`,className:"text-blue-600 hover:underline",children:C.mobile}),s.jsx(de,{value:C.mobile})]})]})]})})]}),C.type==="BUSINESS"&&s.jsx(S2,{customer:C,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),s.jsx(k2,{customer:C,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),C.notes&&s.jsx(Y,{title:"Notizen",className:"mb-6",children:s.jsx("p",{className:"whitespace-pre-wrap",children:C.notes})}),s.jsx(Y,{children:s.jsx(N2,{tabs:N,defaultTab:l})}),s.jsx(Lp,{isOpen:o,onClose:()=>c(!1),customerId:i}),s.jsx(Lp,{isOpen:!!E,onClose:()=>S(null),customerId:i,address:E}),s.jsx(Rp,{isOpen:u,onClose:()=>d(!1),customerId:i}),s.jsx(Rp,{isOpen:!!x,onClose:()=>b(null),customerId:i,bankCard:x}),s.jsx(Op,{isOpen:h,onClose:()=>p(!1),customerId:i}),s.jsx(Op,{isOpen:!!k,onClose:()=>F(null),customerId:i,document:k}),s.jsx(zp,{isOpen:m,onClose:()=>f(!1),customerId:i}),s.jsx(zp,{isOpen:!!M,onClose:()=>P(null),customerId:i,meter:M}),s.jsx(_p,{isOpen:y,onClose:()=>w(!1),customerId:i,customerEmail:(K=U==null?void 0:U.data)==null?void 0:K.email}),s.jsx(_p,{isOpen:!!z,onClose:()=>L(null),customerId:i,email:z,customerEmail:(X=U==null?void 0:U.data)==null?void 0:X.email})]})}function S2({customer:e,canEdit:t,onUpdate:n}){const r=async c=>{try{await rt.uploadBusinessRegistration(e.id,c),n()}catch(u){console.error("Upload fehlgeschlagen:",u),alert("Upload fehlgeschlagen")}},a=async()=>{if(confirm("Gewerbeanmeldung wirklich löschen?"))try{await rt.deleteBusinessRegistration(e.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}},i=async c=>{try{await rt.uploadCommercialRegister(e.id,c),n()}catch(u){console.error("Upload fehlgeschlagen:",u),alert("Upload fehlgeschlagen")}},l=async()=>{if(confirm("Handelsregisterauszug wirklich löschen?"))try{await rt.deleteCommercialRegister(e.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}};return!(e.taxNumber||e.commercialRegisterNumber||e.businessRegistrationPath||e.commercialRegisterPath)&&!t?null:s.jsxs(Y,{title:"Geschäftsdaten",className:"mb-6",children:[s.jsxs("dl",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.taxNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Steuernummer"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[e.taxNumber,s.jsx(de,{value:e.taxNumber})]})]}),e.commercialRegisterNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Handelsregisternummer"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[e.commercialRegisterNumber,s.jsx(de,{value:e.commercialRegisterNumber})]})]})]}),s.jsxs("div",{className:"mt-4 pt-4 border-t grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Gewerbeanmeldung"}),e.businessRegistrationPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.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:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${e.businessRegistrationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Fs,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:r,existingFile:e.businessRegistrationPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:a,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(je,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(St,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Handelsregisterauszug"}),e.commercialRegisterPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.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:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${e.commercialRegisterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Fs,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:i,existingFile:e.commercialRegisterPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:l,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(je,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(St,{onUpload:i,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})]})]})}function k2({customer:e,canEdit:t,onUpdate:n}){const r=async i=>{try{await rt.uploadPrivacyPolicy(e.id,i),n()}catch(l){console.error("Upload fehlgeschlagen:",l),alert("Upload fehlgeschlagen")}},a=async()=>{if(confirm("Datenschutzerklärung wirklich löschen?"))try{await rt.deletePrivacyPolicy(e.id),n()}catch(i){console.error("Löschen fehlgeschlagen:",i),alert("Löschen fehlgeschlagen")}};return!e.privacyPolicyPath&&!t?null:s.jsx(Y,{title:"Dokumente",className:"mb-6",children:s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Datenschutzerklärung"}),e.privacyPolicyPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.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:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${e.privacyPolicyPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Fs,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:r,existingFile:e.privacyPolicyPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:a,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(je,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(St,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})})}function C2({customerId:e,addresses:t,canEdit:n,onAdd:r,onEdit:a}){const i=xe(),l=H({mutationFn:wd.delete,onSuccess:()=>i.invalidateQueries({queryKey:["customer",e.toString()]})});return s.jsxs("div",{children:[n&&s.jsx("div",{className:"mb-4",children:s.jsxs(T,{size:"sm",onClick:r,children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]})}),t.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.map(o=>s.jsxs("div",{className:"border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(XS,{className:"w-4 h-4 text-gray-400"}),s.jsx(ye,{variant:o.type==="BILLING"?"info":"default",children:o.type==="BILLING"?"Rechnung":"Liefer-/Meldeadresse"}),o.isDefault&&s.jsx(ye,{variant:"success",children:"Standard"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>a(o),title:"Bearbeiten",children:s.jsx(tt,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&l.mutate(o.id)},title:"Löschen",children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs(q0,{values:[`${o.street} ${o.houseNumber}`,`${o.postalCode} ${o.city}`,o.country],children:[s.jsxs("p",{children:[o.street," ",o.houseNumber]}),s.jsxs("p",{children:[o.postalCode," ",o.city]}),s.jsx("p",{className:"text-gray-500",children:o.country})]})]},o.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Adressen vorhanden."})]})}function E2({customerId:e,bankCards:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=xe(),c=H({mutationFn:({id:m,data:f})=>Ro.update(m,f),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=H({mutationFn:Ro.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=async(m,f)=>{try{await rt.uploadBankCardDocument(m,f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(y){console.error("Upload fehlgeschlagen:",y),alert("Upload fehlgeschlagen")}},h=async m=>{if(confirm("Dokument wirklich löschen?"))try{await rt.deleteBankCardDocument(m),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(f){console.error("Löschen fehlgeschlagen:",f),alert("Löschen fehlgeschlagen")}},p=r?t:t.filter(m=>m.isActive);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Bankkarte hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),p.length>0?s.jsx("div",{className:"space-y-4",children:p.map(m=>s.jsxs("div",{className:`border rounded-lg p-4 ${m.isActive?"":"opacity-50 bg-gray-50"}`,children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(qS,{className:"w-4 h-4 text-gray-400"}),!m.isActive&&s.jsx(ye,{variant:"danger",children:"Inaktiv"}),m.expiryDate&&new Date(m.expiryDate)l(m),title:"Bearbeiten",children:s.jsx(tt,{className:"w-4 h-4"})}),m.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte deaktivieren?")&&c.mutate({id:m.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Mt,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wieder aktivieren?")&&c.mutate({id:m.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wirklich löschen?")&&u.mutate(m.id)},title:"Löschen",children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-medium flex items-center gap-1",children:[m.accountHolder,s.jsx(de,{value:m.accountHolder})]}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[m.iban,s.jsx(de,{value:m.iban})]}),m.bic&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["BIC: ",m.bic,s.jsx(de,{value:m.bic})]}),m.bankName&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:[m.bankName,s.jsx(de,{value:m.bankName})]}),m.expiryDate&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Gültig bis: ",new Date(m.expiryDate).toLocaleDateString("de-DE")]}),s.jsx("div",{className:"mt-3 pt-3 border-t",children:m.documentPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("a",{href:`/api${m.documentPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${m.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Fs,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:f=>d(m.id,f),existingFile:m.documentPath,accept:".pdf",label:"Ersetzen",disabled:!m.isActive}),s.jsxs("button",{onClick:()=>h(m.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[s.jsx(je,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&m.isActive&&s.jsx(St,{onUpload:f=>d(m.id,f),accept:".pdf",label:"PDF hochladen"})})]},m.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Bankkarten vorhanden."})]})}function D2({customerId:e,documents:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=xe(),c=H({mutationFn:({id:f,data:y})=>Oo.update(f,y),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=H({mutationFn:Oo.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=async(f,y)=>{try{await rt.uploadIdentityDocument(f,y),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(w){console.error("Upload fehlgeschlagen:",w),alert("Upload fehlgeschlagen")}},h=async f=>{if(confirm("Dokument wirklich löschen?"))try{await rt.deleteIdentityDocument(f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(y){console.error("Löschen fehlgeschlagen:",y),alert("Löschen fehlgeschlagen")}},p=r?t:t.filter(f=>f.isActive),m={ID_CARD:"Personalausweis",PASSPORT:"Reisepass",DRIVERS_LICENSE:"Führerschein",OTHER:"Sonstiges"};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Ausweis hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),p.length>0?s.jsx("div",{className:"space-y-4",children:p.map(f=>s.jsxs("div",{className:`border rounded-lg p-4 ${f.isActive?"":"opacity-50 bg-gray-50"}`,children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(lt,{className:"w-4 h-4 text-gray-400"}),s.jsx(ye,{children:m[f.type]}),!f.isActive&&s.jsx(ye,{variant:"danger",children:"Inaktiv"}),f.expiryDate&&new Date(f.expiryDate)l(f),title:"Bearbeiten",children:s.jsx(tt,{className:"w-4 h-4"})}),f.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis deaktivieren?")&&c.mutate({id:f.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Mt,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wieder aktivieren?")&&c.mutate({id:f.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wirklich löschen?")&&u.mutate(f.id)},title:"Löschen",children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[f.documentNumber,s.jsx(de,{value:f.documentNumber})]}),f.issuingAuthority&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Ausgestellt von: ",f.issuingAuthority,s.jsx(de,{value:f.issuingAuthority})]}),f.expiryDate&&s.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&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Klassen: ",f.licenseClasses,s.jsx(de,{value:f.licenseClasses})]}),f.type==="DRIVERS_LICENSE"&&f.licenseIssueDate&&s.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"})]}),s.jsx("div",{className:"mt-3 pt-3 border-t",children:f.documentPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.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:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${f.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Fs,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(St,{onUpload:y=>d(f.id,y),existingFile:f.documentPath,accept:".pdf",label:"Ersetzen",disabled:!f.isActive}),s.jsxs("button",{onClick:()=>h(f.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[s.jsx(je,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&f.isActive&&s.jsx(St,{onUpload:y=>d(f.id,y),accept:".pdf",label:"PDF hochladen"})})]},f.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Ausweise vorhanden."})]})}function P2({customerId:e,meters:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const[o,c]=j.useState(null),[u,d]=j.useState(null),[h,p]=j.useState(null),m=xe(),f=H({mutationFn:({id:x,data:b})=>Zs.update(x,b),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),y=H({mutationFn:Zs.delete,onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),w=H({mutationFn:({meterId:x,readingId:b})=>Zs.deleteReading(x,b),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),v=r?t:t.filter(x=>x.isActive),g=x=>x?[...x].sort((b,k)=>new Date(k.readingDate).getTime()-new Date(b.readingDate).getTime()):[];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Zähler hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),v.length>0?s.jsx("div",{className:"space-y-4",children:v.map(x=>{const b=g(x.readings),k=u===x.id;return s.jsxs("div",{className:`border rounded-lg p-4 ${x.isActive?"":"opacity-50 bg-gray-50"}`,children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(R0,{className:"w-4 h-4 text-gray-400"}),s.jsx(ye,{variant:x.type==="ELECTRICITY"?"warning":"info",children:x.type==="ELECTRICITY"?"Strom":"Gas"}),!x.isActive&&s.jsx(ye,{variant:"danger",children:"Inaktiv"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[x.isActive&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>c(x.id),title:"Zählerstand hinzufügen",children:s.jsx(ze,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(x),title:"Bearbeiten",children:s.jsx(tt,{className:"w-4 h-4"})}),x.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler deaktivieren?")&&f.mutate({id:x.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Mt,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wieder aktivieren?")&&f.mutate({id:x.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wirklich löschen? Alle Zählerstände werden ebenfalls gelöscht.")&&y.mutate(x.id)},title:"Löschen",children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-mono text-lg flex items-center gap-1",children:[x.meterNumber,s.jsx(de,{value:x.meterNumber})]}),x.location&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Standort: ",x.location,s.jsx(de,{value:x.location})]}),b.length>0&&s.jsxs("div",{className:"mt-3 pt-3 border-t",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("p",{className:"text-sm font-medium",children:"Zählerstände:"}),b.length>3&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>d(k?null:x.id),children:k?"Weniger anzeigen":`Alle ${b.length} anzeigen`})]}),s.jsx("div",{className:"space-y-1",children:(k?b:b.slice(0,3)).map(F=>s.jsxs("div",{className:"flex justify-between items-center text-sm group",children:[s.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(F.readingDate).toLocaleDateString("de-DE"),s.jsx(de,{value:new Date(F.readingDate).toLocaleDateString("de-DE")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[F.value.toLocaleString("de-DE")," ",F.unit,s.jsx(de,{value:F.value.toString(),title:"Nur Wert kopieren"}),s.jsx(de,{value:`${F.value.toLocaleString("de-DE")} ${F.unit}`,title:"Mit Einheit kopieren"})]}),n&&s.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[s.jsx("button",{onClick:()=>p({meterId:x.id,reading:F}),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(tt,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&w.mutate({meterId:x.id,readingId:F.id})},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:s.jsx(je,{className:"w-3 h-3"})})]})]})]},F.id))})]})]},x.id)})}):s.jsx("p",{className:"text-gray-500",children:"Keine Zähler vorhanden."}),o&&s.jsx($p,{isOpen:!0,onClose:()=>c(null),meterId:o,customerId:e}),h&&s.jsx($p,{isOpen:!0,onClose:()=>p(null),meterId:h.meterId,customerId:e,reading:h.reading})]})}function A2({customerId:e,contracts:t}){const{hasPermission:n}=Ue(),r=Ht(),a=xe(),i=H({mutationFn:qe.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",DEACTIVATED:"default"};return s.jsxs("div",{children:[n("contracts:create")&&s.jsx("div",{className:"mb-4",children:s.jsx(we,{to:`/contracts/new?customerId=${e}`,children:s.jsxs(T,{size:"sm",children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Vertrag anlegen"]})})}),t.length>0?s.jsx("div",{className:"space-y-4",children:t.map(c=>s.jsxs("div",{className:"border rounded-lg p-4 hover:bg-gray-50 transition-colors",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[c.contractNumber,s.jsx(de,{value:c.contractNumber})]}),s.jsx(ye,{children:l[c.type]}),s.jsx(ye,{variant:o[c.status],children:c.status})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>r(`/contracts/${c.id}`,{state:{from:"customer",customerId:e.toString()}}),title:"Ansehen",children:s.jsx(Ae,{className:"w-4 h-4"})}),n("contracts:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>r(`/contracts/${c.id}/edit`),title:"Bearbeiten",children:s.jsx(tt,{className:"w-4 h-4"})}),n("contracts:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&i.mutate(c.id)},title:"Löschen",children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})]}),c.providerName&&s.jsxs("p",{className:"flex items-center gap-1",children:[c.providerName,c.tariffName&&` - ${c.tariffName}`,s.jsx(de,{value:c.providerName+(c.tariffName?` - ${c.tariffName}`:"")})]}),c.startDate&&s.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))}):s.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."})]})}function M2({customerId:e}){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[i,l]=j.useState(!1),o=async()=>{var c;if(t){n(!1);return}l(!0);try{const u=await kt.getPortalPassword(e);a(((c=u.data)==null?void 0:c.password)||null),n(!0)}catch(u){console.error("Fehler beim Laden des Passworts:",u),alert("Fehler beim Laden des Passworts")}finally{l(!1)}};return s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx("p",{className:"text-xs text-green-600",children:"Passwort ist gesetzt"}),s.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?s.jsxs(s.Fragment,{children:[s.jsx(Mt,{className:"w-3 h-3"}),"Verbergen"]}):s.jsxs(s.Fragment,{children:[s.jsx(Ae,{className:"w-3 h-3"}),"Anzeigen"]})}),t&&r&&s.jsxs("span",{className:"text-xs font-mono bg-gray-100 px-2 py-1 rounded flex items-center gap-1",children:[r,s.jsx(de,{value:r})]}),t&&!r&&s.jsx("span",{className:"text-xs text-gray-500",children:"(Passwort nicht verfügbar)"})]})}function T2({customerId:e,canEdit:t}){const n=xe(),[r,a]=j.useState(!1),[i,l]=j.useState(""),[o,c]=j.useState(""),[u,d]=j.useState([]),[h,p]=j.useState(!1),{data:m,isLoading:f}=me({queryKey:["customer-portal",e],queryFn:()=>kt.getPortalSettings(e)}),{data:y,isLoading:w}=me({queryKey:["customer-representatives",e],queryFn:()=>kt.getRepresentatives(e)}),v=H({mutationFn:S=>kt.updatePortalSettings(e,S),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-portal",e]})}}),g=H({mutationFn:S=>kt.setPortalPassword(e,S),onSuccess:()=>{l(""),n.invalidateQueries({queryKey:["customer-portal",e]}),alert("Passwort wurde gesetzt")},onError:S=>{alert(S.message)}}),x=H({mutationFn:S=>kt.addRepresentative(e,S),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]}),c(""),d([])},onError:S=>{alert(S.message)}}),b=H({mutationFn:S=>kt.removeRepresentative(e,S),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]})}}),k=async()=>{if(!(o.length<2)){p(!0);try{const S=await kt.searchForRepresentative(e,o);d(S.data||[])}catch(S){console.error("Suche fehlgeschlagen:",S)}finally{p(!1)}}};if(f||w)return s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."});const F=m==null?void 0:m.data,E=(y==null?void 0:y.data)||[];return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(zm,{className:"w-5 h-5 text-gray-400"}),s.jsx("h3",{className:"font-medium",children:"Portal-Zugang"})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("label",{className:"flex items-center gap-3",children:[s.jsx("input",{type:"checkbox",checked:(F==null?void 0:F.portalEnabled)||!1,onChange:S=>v.mutate({portalEnabled:S.target.checked}),className:"rounded w-5 h-5",disabled:!t}),s.jsx("span",{children:"Portal aktiviert"}),(F==null?void 0:F.portalEnabled)&&s.jsx(ye,{variant:"success",children:"Aktiv"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Portal E-Mail"}),s.jsx("div",{className:"flex gap-2",children:s.jsx(q,{value:(F==null?void 0:F.portalEmail)||"",onChange:S=>v.mutate({portalEmail:S.target.value||null}),placeholder:"portal@example.com",disabled:!t||!(F!=null&&F.portalEnabled),className:"flex-1"})}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Diese E-Mail wird für den Login ins Kundenportal verwendet."})]}),(F==null?void 0:F.portalEnabled)&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:F!=null&&F.hasPassword?"Neues Passwort setzen":"Passwort setzen"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(q,{type:r?"text":"password",value:i,onChange:S=>l(S.target.value),placeholder:"Mindestens 6 Zeichen",disabled:!t}),s.jsx("button",{type:"button",onClick:()=>a(!r),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400",children:r?s.jsx(Mt,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]}),s.jsx(T,{onClick:()=>g.mutate(i),disabled:!t||i.length<6||g.isPending,children:g.isPending?"Speichern...":"Setzen"})]}),(F==null?void 0:F.hasPassword)&&s.jsx(M2,{customerId:e})]}),(F==null?void 0:F.portalLastLogin)&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Letzte Anmeldung: ",new Date(F.portalLastLogin).toLocaleString("de-DE")]})]})]}),s.jsxs("div",{className:"border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(o2,{className:"w-5 h-5 text-gray-400"}),s.jsx("h3",{className:"font-medium",children:"Vertreter (können Verträge einsehen)"})]}),s.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&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(q,{value:o,onChange:S=>c(S.target.value),placeholder:"Kunden suchen (Name, Kundennummer)...",onKeyDown:S=>S.key==="Enter"&&k(),className:"flex-1"}),s.jsx(T,{variant:"secondary",onClick:k,disabled:o.length<2||h,children:s.jsx(ml,{className:"w-4 h-4"})})]}),s.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&&s.jsx("div",{className:"mt-2 border rounded-lg divide-y",children:u.map(S=>s.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-gray-50",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:S.companyName||`${S.firstName} ${S.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:S.customerNumber})]}),s.jsxs(T,{size:"sm",onClick:()=>x.mutate(S.id),disabled:x.isPending,children:[s.jsx(ze,{className:"w-4 h-4 mr-1"}),"Hinzufügen"]})]},S.id))})]}),E.length>0?s.jsx("div",{className:"space-y-2",children:E.map(S=>{var M,P,z,L;return s.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:((M=S.representative)==null?void 0:M.companyName)||`${(P=S.representative)==null?void 0:P.firstName} ${(z=S.representative)==null?void 0:z.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:(L=S.representative)==null?void 0:L.customerNumber})]}),t&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertreter wirklich entfernen?")&&b.mutate(S.representativeId)},children:s.jsx(Nn,{className:"w-4 h-4 text-red-500"})})]},S.id)})}):s.jsx("p",{className:"text-gray-500 text-sm",children:"Keine Vertreter konfiguriert."})]})]})}function Lp({isOpen:e,onClose:t,customerId:n,address:r}){const a=xe(),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]=j.useState(l),u=H({mutationFn:m=>wd.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({type:"DELIVERY_RESIDENCE",street:"",houseNumber:"",postalCode:"",city:"",country:"Deutschland",isDefault:!1})}}),d=H({mutationFn:m=>wd.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?d.mutate(o):u.mutate(o)},p=u.isPending||d.isPending;return i&&o.street!==r.street&&c(l()),s.jsx(ut,{isOpen:e,onClose:t,title:i?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(Oe,{label:"Adresstyp",value:o.type,onChange:m=>c({...o,type:m.target.value}),options:[{value:"DELIVERY_RESIDENCE",label:"Liefer-/Meldeadresse"},{value:"BILLING",label:"Rechnungsadresse"}]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(q,{label:"Straße",value:o.street,onChange:m=>c({...o,street:m.target.value}),required:!0})}),s.jsx(q,{label:"Hausnr.",value:o.houseNumber,onChange:m=>c({...o,houseNumber:m.target.value}),required:!0})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx(q,{label:"PLZ",value:o.postalCode,onChange:m=>c({...o,postalCode:m.target.value}),required:!0}),s.jsx("div",{className:"col-span-2",children:s.jsx(q,{label:"Ort",value:o.city,onChange:m=>c({...o,city:m.target.value}),required:!0})})]}),s.jsx(q,{label:"Land",value:o.country,onChange:m=>c({...o,country:m.target.value})}),s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isDefault,onChange:m=>c({...o,isDefault:m.target.checked}),className:"rounded"}),"Als Standard setzen"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function Rp({isOpen:e,onClose:t,customerId:n,bankCard:r}){const a=xe(),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]=j.useState(l);j.useState(()=>{c(l())});const u=H({mutationFn:m=>Ro.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({accountHolder:"",iban:"",bic:"",bankName:"",expiryDate:"",isActive:!0})}}),d=H({mutationFn:m=>Ro.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.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()),s.jsx(ut,{isOpen:e,onClose:t,title:i?"Bankkarte bearbeiten":"Bankkarte hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(q,{label:"Kontoinhaber",value:o.accountHolder,onChange:m=>c({...o,accountHolder:m.target.value}),required:!0}),s.jsx(q,{label:"IBAN",value:o.iban,onChange:m=>c({...o,iban:m.target.value}),required:!0}),s.jsx(q,{label:"BIC",value:o.bic,onChange:m=>c({...o,bic:m.target.value})}),s.jsx(q,{label:"Bank",value:o.bankName,onChange:m=>c({...o,bankName:m.target.value})}),s.jsx(q,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:m=>c({...o,expiryDate:m.target.value}),onClear:()=>c({...o,expiryDate:""})}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&s.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."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function Op({isOpen:e,onClose:t,customerId:n,document:r}){const a=xe(),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]=j.useState(l),u=H({mutationFn:m=>Oo.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({type:"ID_CARD",documentNumber:"",issuingAuthority:"",issueDate:"",expiryDate:"",isActive:!0,licenseClasses:"",licenseIssueDate:""})}}),d=H({mutationFn:m=>Oo.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.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()),s.jsx(ut,{isOpen:e,onClose:t,title:i?"Ausweis bearbeiten":"Ausweis hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(Oe,{label:"Ausweistyp",value:o.type,onChange:m=>c({...o,type:m.target.value}),options:[{value:"ID_CARD",label:"Personalausweis"},{value:"PASSPORT",label:"Reisepass"},{value:"DRIVERS_LICENSE",label:"Führerschein"},{value:"OTHER",label:"Sonstiges"}]}),s.jsx(q,{label:"Ausweisnummer",value:o.documentNumber,onChange:m=>c({...o,documentNumber:m.target.value}),required:!0}),s.jsx(q,{label:"Ausstellende Behörde",value:o.issuingAuthority,onChange:m=>c({...o,issuingAuthority:m.target.value})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(q,{label:"Ausstellungsdatum",type:"date",value:o.issueDate,onChange:m=>c({...o,issueDate:m.target.value}),onClear:()=>c({...o,issueDate:""})}),s.jsx(q,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:m=>c({...o,expiryDate:m.target.value}),onClear:()=>c({...o,expiryDate:""})})]}),o.type==="DRIVERS_LICENSE"&&s.jsxs(s.Fragment,{children:[s.jsx(q,{label:"Führerscheinklassen",value:o.licenseClasses,onChange:m=>c({...o,licenseClasses:m.target.value}),placeholder:"z.B. B, BE, AM, L"}),s.jsx(q,{label:"Erwerb Klasse B (Pkw)",type:"date",value:o.licenseIssueDate,onChange:m=>c({...o,licenseIssueDate:m.target.value}),onClear:()=>c({...o,licenseIssueDate:""})})]}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&s.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."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function zp({isOpen:e,onClose:t,customerId:n,meter:r}){const a=xe(),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]=j.useState(l),u=H({mutationFn:m=>Zs.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({meterNumber:"",type:"ELECTRICITY",location:"",isActive:!0})}}),d=H({mutationFn:m=>Zs.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?d.mutate(o):u.mutate(o)},p=u.isPending||d.isPending;return i&&o.meterNumber!==r.meterNumber&&c(l()),s.jsx(ut,{isOpen:e,onClose:t,title:i?"Zähler bearbeiten":"Zähler hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(q,{label:"Zählernummer",value:o.meterNumber,onChange:m=>c({...o,meterNumber:m.target.value}),required:!0}),s.jsx(Oe,{label:"Zählertyp",value:o.type,onChange:m=>c({...o,type:m.target.value}),options:[{value:"ELECTRICITY",label:"Strom"},{value:"GAS",label:"Gas"}]}),s.jsx(q,{label:"Standort",value:o.location,onChange:m=>c({...o,location:m.target.value}),placeholder:"z.B. Keller, Wohnung"}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function $p({isOpen:e,onClose:t,meterId:n,customerId:r,reading:a}){const i=xe(),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]=j.useState(o),d=H({mutationFn:f=>Zs.addReading(n,f),onSuccess:()=>{i.invalidateQueries({queryKey:["customer",r.toString()]}),t()}}),h=H({mutationFn:f=>Zs.updateReading(n,a.id,f),onSuccess:()=>{i.invalidateQueries({queryKey:["customer",r.toString()]}),t()}}),p=f=>{f.preventDefault();const y={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:c.unit,notes:c.notes||void 0};l?h.mutate(y):d.mutate(y)},m=d.isPending||h.isPending;return l&&c.value!==a.value.toString()&&u(o()),s.jsx(ut,{isOpen:e,onClose:t,title:l?"Zählerstand bearbeiten":"Zählerstand erfassen",children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(q,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:f=>u({...c,readingDate:f.target.value}),required:!0}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(q,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:f=>u({...c,value:f.target.value}),required:!0})}),s.jsx(Oe,{label:"Einheit",value:c.unit,onChange:f=>u({...c,unit:f.target.value}),options:[{value:"kWh",label:"kWh"},{value:"m³",label:"m³"}]})]}),s.jsx(q,{label:"Notizen",value:c.notes,onChange:f=>u({...c,notes:f.target.value}),placeholder:"Optionale Notizen..."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m,children:m?"Speichern...":"Speichern"})]})]})})}const eu="@stressfrei-wechseln.de";function F2({customerId:e,emails:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=xe(),c=H({mutationFn:({id:h,data:p})=>is.update(h,p),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=H({mutationFn:is.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=r?t:t.filter(h=>h.isActive);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.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?s.jsx("div",{className:"space-y-3",children:d.map(h=>s.jsx("div",{className:`border rounded-lg p-4 ${h.isActive?"":"opacity-50 bg-gray-50"}`,children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hs,{className:"w-4 h-4 text-gray-400"}),s.jsx("span",{className:"font-mono text-sm",children:h.email}),s.jsx(de,{value:h.email}),!h.isActive&&s.jsx(ye,{variant:"danger",children:"Inaktiv"})]}),h.notes&&s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-gray-500",children:[s.jsx(lt,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:h.notes})]})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(h),title:"Bearbeiten",children:s.jsx(tt,{className:"w-4 h-4"})}),h.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse deaktivieren?")&&c.mutate({id:h.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Mt,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wieder aktivieren?")&&c.mutate({id:h.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&u.mutate(h.id)},title:"Löschen",children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})]})},h.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Stressfrei-Wechseln Adressen vorhanden."})]})}function I2({credentials:e,onHide:t,onResetPassword:n,isResettingPassword:r}){const[a,i]=j.useState(null),l=async(d,h)=>{try{await navigator.clipboard.writeText(d),i(h),setTimeout(()=>i(null),2e3)}catch{const p=document.createElement("textarea");p.value=d,document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p),i(h),setTimeout(()=>i(null),2e3)}},o=({text:d,fieldName:h})=>s.jsx("button",{type:"button",onClick:()=>l(d,h),className:"p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors",title:"In Zwischenablage kopieren",children:a===h?s.jsx(zo,{className:"w-4 h-4 text-green-600"}):s.jsx(Rm,{className:"w-4 h-4"})}),c=e.imap?`${e.imap.server}:${e.imap.port}`:"",u=e.smtp?`${e.smtp.server}:${e.smtp.port}`:"";return s.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4 space-y-3",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Zugangsdaten"}),s.jsx("button",{type:"button",onClick:t,className:"text-gray-400 hover:text-gray-600 p-1 hover:bg-gray-200 rounded",title:"Zugangsdaten ausblenden",children:s.jsx(Mt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Benutzername"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1 break-all",children:e.email}),s.jsx(o,{text:e.email,fieldName:"email"})]})]}),s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Passwort"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1 break-all",children:e.password}),s.jsx(o,{text:e.password,fieldName:"password"})]}),s.jsx("button",{type:"button",onClick:n,disabled:r,className:"mt-2 text-xs text-blue-600 hover:text-blue-800 disabled:opacity-50",children:r?"Generiere...":"Neu generieren"})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.imap&&s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"IMAP (Empfang)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1",children:c}),s.jsx(o,{text:c,fieldName:"imap"})]}),s.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:e.imap.encryption})]}),e.smtp&&s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"SMTP (Versand)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1",children:u}),s.jsx(o,{text:u,fieldName:"smtp"})]}),s.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:e.smtp.encryption})]})]})]})}function _p({isOpen:e,onClose:t,customerId:n,email:r,customerEmail:a}){const[i,l]=j.useState(""),[o,c]=j.useState(""),[u,d]=j.useState(!1),[h,p]=j.useState(!1),[m,f]=j.useState(null),[y,w]=j.useState("idle"),[v,g]=j.useState(!1),[x,b]=j.useState(!1),[k,F]=j.useState(!1),[E,S]=j.useState(!1),[M,P]=j.useState(null),[z,L]=j.useState(!1),[U,V]=j.useState(!1),R=xe(),C=!!r,{data:N}=me({queryKey:["email-provider-configs"],queryFn:()=>an.getConfigs(),enabled:e}),K=((N==null?void 0:N.data)||[]).some(W=>W.isActive&&W.isDefault),X=W=>{if(!W)return"";const $e=W.indexOf("@");return $e>0?W.substring(0,$e):W},te=async W=>{var $e;if(!(!K||!W)){w("checking");try{const Dt=await an.checkEmailExists(W);w(($e=Dt.data)!=null&&$e.exists?"exists":"not_exists")}catch{w("error")}}},pe=async()=>{var W,$e;if(!(!a||!i)){g(!0),f(null);try{const Dt=await an.provisionEmail(i,a);(W=Dt.data)!=null&&W.success?w("exists"):f((($e=Dt.data)==null?void 0:$e.error)||"Provisionierung fehlgeschlagen")}catch(Dt){f(Dt instanceof Error?Dt.message:"Fehler bei der Provisionierung")}finally{g(!1)}}},oe=async()=>{if(r){b(!0),f(null);try{const W=await is.enableMailbox(r.id);W.success?(F(!0),R.invalidateQueries({queryKey:["customer",n.toString()]}),R.invalidateQueries({queryKey:["mailbox-accounts",n]})):f(W.error||"Mailbox-Aktivierung fehlgeschlagen")}catch(W){f(W instanceof Error?W.message:"Fehler bei der Mailbox-Aktivierung")}finally{b(!1)}}},Ge=async()=>{if(r)try{const W=await is.syncMailboxStatus(r.id);W.success&&W.data&&(F(W.data.hasMailbox),W.data.wasUpdated&&R.invalidateQueries({queryKey:["customer",n.toString()]}))}catch(W){console.error("Fehler beim Synchronisieren des Mailbox-Status:",W)}},Q=async()=>{if(r){L(!0);try{const W=await is.getMailboxCredentials(r.id);W.success&&W.data&&(P(W.data),S(!0))}catch(W){console.error("Fehler beim Laden der Zugangsdaten:",W)}finally{L(!1)}}},Se=async()=>{if(r&&confirm("Neues Passwort generieren? Das alte Passwort wird ungültig.")){V(!0);try{const W=await is.resetPassword(r.id);W.success&&W.data?(M&&P({...M,password:W.data.password}),alert("Passwort wurde erfolgreich zurückgesetzt.")):alert(W.error||"Fehler beim Zurücksetzen des Passworts")}catch(W){console.error("Fehler beim Zurücksetzen des Passworts:",W),alert(W instanceof Error?W.message:"Fehler beim Zurücksetzen des Passworts")}finally{V(!1)}}};j.useEffect(()=>{if(e){if(r){const W=X(r.email);l(W),c(r.notes||""),w("idle"),F(r.hasMailbox||!1),K&&(te(W),Ge())}else l(""),c(""),d(!1),p(!1),w("idle"),F(!1);f(null),S(!1),P(null)}},[e,r,K]);const Me=H({mutationFn:async W=>is.create(n,{email:W.email,notes:W.notes,provisionAtProvider:W.provision,createMailbox:W.createMailbox}),onSuccess:()=>{R.invalidateQueries({queryKey:["customer",n.toString()]}),R.invalidateQueries({queryKey:["mailbox-accounts",n]}),l(""),c(""),d(!1),p(!1),t()},onError:W=>{f(W instanceof Error?W.message:"Fehler bei der Provisionierung")}}),Qe=H({mutationFn:W=>is.update(r.id,W),onSuccess:()=>{R.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),ft=W=>{W.preventDefault(),f(null);const $e=i+eu;C?Qe.mutate({email:$e,notes:o||void 0}):Me.mutate({email:$e,notes:o||void 0,provision:u,createMailbox:u&&h})},jt=Me.isPending||Qe.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:C?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:ft,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"E-Mail-Adresse"}),s.jsxs("div",{className:"flex",children:[s.jsx("input",{type:"text",value:i,onChange:W=>l(W.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"}),s.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:eu})]}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Vollständige Adresse: ",s.jsxs("span",{className:"font-mono",children:[i||"...",eu]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Notizen (optional)"}),s.jsx("textarea",{value:o,onChange:W=>c(W.target.value),rows:3,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"z.B. für Freenet-Konten, für Klarmobil..."})]}),K&&a&&s.jsx("div",{className:"bg-blue-50 p-3 rounded-lg",children:C?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"E-Mail-Provider Status"}),y==="checking"&&s.jsx("span",{className:"text-xs text-gray-500",children:"Prüfe..."}),y==="exists"&&s.jsxs("span",{className:"text-xs text-green-600 flex items-center gap-1",children:[s.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),"Beim Provider vorhanden"]}),y==="not_exists"&&s.jsx("span",{className:"text-xs text-orange-600",children:"Nicht beim Provider angelegt"}),y==="error"&&s.jsx("span",{className:"text-xs text-red-600",children:"Status konnte nicht geprüft werden"})]}),y==="not_exists"&&s.jsxs("div",{className:"pt-2 border-t border-blue-100",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["Die E-Mail-Weiterleitung ist noch nicht auf dem Server eingerichtet. Weiterleitungsziel: ",a]}),s.jsx(T,{type:"button",size:"sm",onClick:pe,disabled:v,children:v?"Wird angelegt...":"Jetzt beim Provider anlegen"})]}),y==="error"&&s.jsx(T,{type:"button",size:"sm",variant:"secondary",onClick:()=>te(i),children:"Erneut prüfen"}),y==="exists"&&s.jsxs("div",{className:"pt-3 mt-3 border-t border-blue-100",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Mailbox (IMAP/SMTP)"}),k?s.jsxs("span",{className:"text-xs text-green-600 flex items-center gap-1",children:[s.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),"Mailbox aktiv"]}):s.jsx("span",{className:"text-xs text-orange-600",children:"Keine Mailbox"})]}),!k&&s.jsxs("div",{className:"mt-2",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Aktiviere eine echte Mailbox um E-Mails direkt im CRM zu empfangen und zu versenden."}),s.jsx(T,{type:"button",size:"sm",onClick:oe,disabled:x,children:x?"Wird aktiviert...":"Mailbox aktivieren"})]}),k&&s.jsx("div",{className:"mt-3",children:E?M&&s.jsx(I2,{credentials:M,onHide:()=>S(!1),onResetPassword:Se,isResettingPassword:U}):s.jsx(T,{type:"button",size:"sm",variant:"secondary",onClick:Q,disabled:z,children:z?"Laden...":s.jsxs(s.Fragment,{children:[s.jsx(Ae,{className:"w-4 h-4 mr-1"}),"Zugangsdaten anzeigen"]})})})]})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:W=>{d(W.target.checked),W.target.checked||p(!1)},className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Beim E-Mail-Provider anlegen"}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Die E-Mail-Weiterleitung wird automatisch auf dem konfigurierten Server erstellt. Weiterleitungsziel: ",a]})]})]}),u&&s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer ml-6",children:[s.jsx("input",{type:"checkbox",checked:h,onChange:W=>p(W.target.checked),className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Echte Mailbox erstellen (IMAP/SMTP-Zugang)"}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Ermöglicht E-Mails direkt im CRM zu empfangen und zu versenden."})]})]})]})}),m&&s.jsx("div",{className:"bg-red-50 p-3 rounded-lg text-red-700 text-sm",children:m}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:jt||!i,children:jt?"Speichern...":"Speichern"})]})]})})}var fl=e=>e.type==="checkbox",jr=e=>e instanceof Date,Jt=e=>e==null;const V0=e=>typeof e=="object";var ht=e=>!Jt(e)&&!Array.isArray(e)&&V0(e)&&!jr(e),L2=e=>ht(e)&&e.target?fl(e.target)?e.target.checked:e.target.value:e,R2=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,O2=(e,t)=>e.has(R2(t)),z2=e=>{const t=e.constructor&&e.constructor.prototype;return ht(t)&&t.hasOwnProperty("isPrototypeOf")},Bm=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function pt(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Bm&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(ht(e)&&z2(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=pt(e[a]));return r}var vc=e=>/^\w*$/.test(e),Ze=e=>e===void 0,qm=e=>Array.isArray(e)?e.filter(Boolean):[],Vm=e=>qm(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ue=(e,t,n)=>{if(!t||!ht(e))return n;const r=(vc(t)?[t]:Vm(t)).reduce((a,i)=>Jt(a)?a:a[i],e);return Ze(r)||r===e?Ze(e[t])?n:e[t]:r},Ks=e=>typeof e=="boolean",Ms=e=>typeof e=="function",He=(e,t,n)=>{let r=-1;const a=vc(t)?[t]:Vm(t),i=a.length,l=i-1;for(;++r{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const l=i;return t._proxyFormState[l]!==Ts.all&&(t._proxyFormState[l]=!r||Ts.all),e[l]}});return a};const K2=typeof window<"u"?At.useLayoutEffect:At.useEffect;var os=e=>typeof e=="string",U2=(e,t,n,r,a)=>os(e)?(r&&t.watch.add(e),ue(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),ue(n,i))):(r&&(t.watchAll=!0),n),kd=e=>Jt(e)||!V0(e);function Ln(e,t,n=new WeakSet){if(kd(e)||kd(t))return Object.is(e,t);if(jr(e)&&jr(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(n.has(e)||n.has(t))return!0;n.add(e),n.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(jr(l)&&jr(o)||ht(l)&&ht(o)||Array.isArray(l)&&Array.isArray(o)?!Ln(l,o,n):!Object.is(l,o))return!1}}return!0}const B2=At.createContext(null);B2.displayName="HookFormContext";var q2=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},wi=e=>Array.isArray(e)?e:[e],Up=()=>{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 Q0(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&ht(a)&&i){const l=Q0(a,i);ht(l)&&(n[r]=l)}else e[r]&&(n[r]=i)}return n}var Kt=e=>ht(e)&&!Object.keys(e).length,Qm=e=>e.type==="file",$o=e=>{if(!Bm)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},H0=e=>e.type==="select-multiple",Hm=e=>e.type==="radio",V2=e=>Hm(e)||fl(e),tu=e=>$o(e)&&e.isConnected;function Q2(e,t){const n=t.slice(0,-1).length;let r=0;for(;r{for(const t in e)if(Ms(e[t]))return!0;return!1};function W0(e){return Array.isArray(e)||ht(e)&&!W2(e)}function Cd(e,t={}){for(const n in e){const r=e[n];W0(r)?(t[n]=Array.isArray(r)?[]:{},Cd(r,t[n])):Ze(r)||(t[n]=!0)}return t}function Gr(e,t,n){n||(n=Cd(t));for(const r in e){const a=e[r];if(W0(a))Ze(t)||kd(n[r])?n[r]=Cd(a,Array.isArray(a)?[]:{}):Gr(a,Jt(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Ln(a,i)}}return n}const Bp={value:!1,isValid:!1},qp={value:!0,isValid:!0};var G0=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ze(e[0].attributes.value)?Ze(e[0].value)||e[0].value===""?qp:{value:e[0].value,isValid:!0}:qp:Bp}return Bp},Z0=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ze(e)?e:t?e===""?NaN:e&&+e:n&&os(e)?new Date(e):r?r(e):e;const Vp={isValid:!1,value:null};var J0=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Vp):Vp;function Qp(e){const t=e.ref;return Qm(t)?t.files:Hm(t)?J0(e.refs).value:H0(t)?[...t.selectedOptions].map(({value:n})=>n):fl(t)?G0(e.refs).value:Z0(Ze(t.value)?e.ref.value:t.value,e)}var G2=(e,t,n,r)=>{const a={};for(const i of e){const l=ue(t,i);l&&He(a,i,l._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},_o=e=>e instanceof RegExp,ii=e=>Ze(e)?e:_o(e)?e.source:ht(e)?_o(e.value)?e.value.source:e.value:e,Hp=e=>({isOnSubmit:!e||e===Ts.onSubmit,isOnBlur:e===Ts.onBlur,isOnChange:e===Ts.onChange,isOnAll:e===Ts.all,isOnTouch:e===Ts.onTouched});const Wp="AsyncFunction";var Z2=e=>!!e&&!!e.validate&&!!(Ms(e.validate)&&e.validate.constructor.name===Wp||ht(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Wp)),J2=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Gp=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Si=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=ue(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(Si(o,t))break}else if(ht(o)&&Si(o,t))break}}};function Zp(e,t,n){const r=ue(e,n);if(r||vc(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),l=ue(t,i),o=ue(e,i);if(l&&!Array.isArray(l)&&n!==i)return{name:n};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:n}}var X2=(e,t,n,r)=>{n(e);const{name:a,...i}=e;return Kt(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(l=>t[l]===(!r||Ts.all))},Y2=(e,t,n)=>!e||!t||e===t||wi(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),ek=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,tk=(e,t)=>!qm(ue(e,t)).length&&dt(e,t),sk=(e,t,n)=>{const r=wi(ue(e,n));return He(r,"root",t[n]),He(e,n,r),e};function Jp(e,t,n="validate"){if(os(e)||Array.isArray(e)&&e.every(os)||Ks(e)&&!e)return{type:n,message:os(e)?e:"",ref:t}}var Wr=e=>ht(e)&&!_o(e)?e:{value:e,message:""},Xp=async(e,t,n,r,a,i)=>{const{ref:l,refs:o,required:c,maxLength:u,minLength:d,min:h,max:p,pattern:m,validate:f,name:y,valueAsNumber:w,mount:v}=e._f,g=ue(n,y);if(!v||t.has(y))return{};const x=o?o[0]:l,b=L=>{a&&x.reportValidity&&(x.setCustomValidity(Ks(L)?"":L||""),x.reportValidity())},k={},F=Hm(l),E=fl(l),S=F||E,M=(w||Qm(l))&&Ze(l.value)&&Ze(g)||$o(l)&&l.value===""||g===""||Array.isArray(g)&&!g.length,P=q2.bind(null,y,r,k),z=(L,U,V,R=tn.maxLength,C=tn.minLength)=>{const N=L?U:V;k[y]={type:L?R:C,message:N,ref:l,...P(L?R:C,N)}};if(i?!Array.isArray(g)||!g.length:c&&(!S&&(M||Jt(g))||Ks(g)&&!g||E&&!G0(o).isValid||F&&!J0(o).isValid)){const{value:L,message:U}=os(c)?{value:!!c,message:c}:Wr(c);if(L&&(k[y]={type:tn.required,message:U,ref:x,...P(tn.required,U)},!r))return b(U),k}if(!M&&(!Jt(h)||!Jt(p))){let L,U;const V=Wr(p),R=Wr(h);if(!Jt(g)&&!isNaN(g)){const C=l.valueAsNumber||g&&+g;Jt(V.value)||(L=C>V.value),Jt(R.value)||(U=Cnew Date(new Date().toDateString()+" "+te),K=l.type=="time",X=l.type=="week";os(V.value)&&g&&(L=K?N(g)>N(V.value):X?g>V.value:C>new Date(V.value)),os(R.value)&&g&&(U=K?N(g)+L.value,R=!Jt(U.value)&&g.length<+U.value;if((V||R)&&(z(V,L.message,U.message),!r))return b(k[y].message),k}if(m&&!M&&os(g)){const{value:L,message:U}=Wr(m);if(_o(L)&&!g.match(L)&&(k[y]={type:tn.pattern,message:U,ref:l,...P(tn.pattern,U)},!r))return b(U),k}if(f){if(Ms(f)){const L=await f(g,n),U=Jp(L,x);if(U&&(k[y]={...U,...P(tn.validate,U.message)},!r))return b(U.message),k}else if(ht(f)){let L={};for(const U in f){if(!Kt(L)&&!r)break;const V=Jp(await f[U](g,n),x,U);V&&(L={...V,...P(U,V.message)},b(V.message),r&&(k[y]=L))}if(!Kt(L)&&(k[y]={ref:x,...L},!r))return k}}return b(!0),k};const nk={mode:Ts.onSubmit,reValidateMode:Ts.onChange,shouldFocusError:!0};function rk(e={}){let t={...nk,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ms(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},a=ht(t.defaultValues)||ht(t.values)?pt(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:pt(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},h={...d};let p={...h};const m={array:Up(),state:Up()},f=t.criteriaMode===Ts.all,y=A=>$=>{clearTimeout(u),u=setTimeout(A,$)},w=async A=>{if(!l.keepIsValid&&!t.disabled&&(h.isValid||p.isValid||A)){let $;t.resolver?($=Kt((await S()).errors),v()):$=await P(r,!0),$!==n.isValid&&m.state.next({isValid:$})}},v=(A,$)=>{!t.disabled&&(h.isValidating||h.validatingFields||p.isValidating||p.validatingFields)&&((A||Array.from(o.mount)).forEach(B=>{B&&($?He(n.validatingFields,B,$):dt(n.validatingFields,B))}),m.state.next({validatingFields:n.validatingFields,isValidating:!Kt(n.validatingFields)}))},g=(A,$=[],B,ie,ee=!0,J=!0)=>{if(ie&&B&&!t.disabled){if(l.action=!0,J&&Array.isArray(ue(r,A))){const he=B(ue(r,A),ie.argA,ie.argB);ee&&He(r,A,he)}if(J&&Array.isArray(ue(n.errors,A))){const he=B(ue(n.errors,A),ie.argA,ie.argB);ee&&He(n.errors,A,he),tk(n.errors,A)}if((h.touchedFields||p.touchedFields)&&J&&Array.isArray(ue(n.touchedFields,A))){const he=B(ue(n.touchedFields,A),ie.argA,ie.argB);ee&&He(n.touchedFields,A,he)}(h.dirtyFields||p.dirtyFields)&&(n.dirtyFields=Gr(a,i)),m.state.next({name:A,isDirty:L(A,$),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else He(i,A,$)},x=(A,$)=>{He(n.errors,A,$),m.state.next({errors:n.errors})},b=A=>{n.errors=A,m.state.next({errors:n.errors,isValid:!1})},k=(A,$,B,ie)=>{const ee=ue(r,A);if(ee){const J=ue(i,A,Ze(B)?ue(a,A):B);Ze(J)||ie&&ie.defaultChecked||$?He(i,A,$?J:Qp(ee._f)):R(A,J),l.mount&&!l.action&&w()}},F=(A,$,B,ie,ee)=>{let J=!1,he=!1;const De={name:A};if(!t.disabled){if(!B||ie){(h.isDirty||p.isDirty)&&(he=n.isDirty,n.isDirty=De.isDirty=L(),J=he!==De.isDirty);const Fe=Ln(ue(a,A),$);he=!!ue(n.dirtyFields,A),Fe?dt(n.dirtyFields,A):He(n.dirtyFields,A,!0),De.dirtyFields=n.dirtyFields,J=J||(h.dirtyFields||p.dirtyFields)&&he!==!Fe}if(B){const Fe=ue(n.touchedFields,A);Fe||(He(n.touchedFields,A,B),De.touchedFields=n.touchedFields,J=J||(h.touchedFields||p.touchedFields)&&Fe!==B)}J&&ee&&m.state.next(De)}return J?De:{}},E=(A,$,B,ie)=>{const ee=ue(n.errors,A),J=(h.isValid||p.isValid)&&Ks($)&&n.isValid!==$;if(t.delayError&&B?(c=y(()=>x(A,B)),c(t.delayError)):(clearTimeout(u),c=null,B?He(n.errors,A,B):dt(n.errors,A)),(B?!Ln(ee,B):ee)||!Kt(ie)||J){const he={...ie,...J&&Ks($)?{isValid:$}:{},errors:n.errors,name:A};n={...n,...he},m.state.next(he)}},S=async A=>(v(A,!0),await t.resolver(i,t.context,G2(A||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),M=async A=>{const{errors:$}=await S(A);if(v(A),A)for(const B of A){const ie=ue($,B);ie?He(n.errors,B,ie):dt(n.errors,B)}else n.errors=$;return $},P=async(A,$,B={valid:!0})=>{for(const ie in A){const ee=A[ie];if(ee){const{_f:J,...he}=ee;if(J){const De=o.array.has(J.name),Fe=ee._f&&Z2(ee._f);Fe&&h.validatingFields&&v([J.name],!0);const bt=await Xp(ee,o.disabled,i,f,t.shouldUseNativeValidation&&!$,De);if(Fe&&h.validatingFields&&v([J.name]),bt[J.name]&&(B.valid=!1,$||e.shouldUseNativeValidation))break;!$&&(ue(bt,J.name)?De?sk(n.errors,bt,J.name):He(n.errors,J.name,bt[J.name]):dt(n.errors,J.name))}!Kt(he)&&await P(he,$,B)}}return B.valid},z=()=>{for(const A of o.unMount){const $=ue(r,A);$&&($._f.refs?$._f.refs.every(B=>!tu(B)):!tu($._f.ref))&&ft(A)}o.unMount=new Set},L=(A,$)=>!t.disabled&&(A&&$&&He(i,A,$),!Ln(pe(),a)),U=(A,$,B)=>U2(A,o,{...l.mount?i:Ze($)?a:os(A)?{[A]:$}:$},B,$),V=A=>qm(ue(l.mount?i:a,A,t.shouldUnregister?ue(a,A,[]):[])),R=(A,$,B={})=>{const ie=ue(r,A);let ee=$;if(ie){const J=ie._f;J&&(!J.disabled&&He(i,A,Z0($,J)),ee=$o(J.ref)&&Jt($)?"":$,H0(J.ref)?[...J.ref.options].forEach(he=>he.selected=ee.includes(he.value)):J.refs?fl(J.ref)?J.refs.forEach(he=>{(!he.defaultChecked||!he.disabled)&&(Array.isArray(ee)?he.checked=!!ee.find(De=>De===he.value):he.checked=ee===he.value||!!ee)}):J.refs.forEach(he=>he.checked=he.value===ee):Qm(J.ref)?J.ref.value="":(J.ref.value=ee,J.ref.type||m.state.next({name:A,values:pt(i)})))}(B.shouldDirty||B.shouldTouch)&&F(A,ee,B.shouldTouch,B.shouldDirty,!0),B.shouldValidate&&te(A)},C=(A,$,B)=>{for(const ie in $){if(!$.hasOwnProperty(ie))return;const ee=$[ie],J=A+"."+ie,he=ue(r,J);(o.array.has(A)||ht(ee)||he&&!he._f)&&!jr(ee)?C(J,ee,B):R(J,ee,B)}},N=(A,$,B={})=>{const ie=ue(r,A),ee=o.array.has(A),J=pt($);He(i,A,J),ee?(m.array.next({name:A,values:pt(i)}),(h.isDirty||h.dirtyFields||p.isDirty||p.dirtyFields)&&B.shouldDirty&&m.state.next({name:A,dirtyFields:Gr(a,i),isDirty:L(A,J)})):ie&&!ie._f&&!Jt(J)?C(A,J,B):R(A,J,B),Gp(A,o)?m.state.next({...n,name:A,values:pt(i)}):m.state.next({name:l.mount?A:void 0,values:pt(i)})},K=async A=>{l.mount=!0;const $=A.target;let B=$.name,ie=!0;const ee=ue(r,B),J=Fe=>{ie=Number.isNaN(Fe)||jr(Fe)&&isNaN(Fe.getTime())||Ln(Fe,ue(i,B,Fe))},he=Hp(t.mode),De=Hp(t.reValidateMode);if(ee){let Fe,bt;const Ys=$.type?Qp(ee._f):L2(A),Ss=A.type===Kp.BLUR||A.type===Kp.FOCUS_OUT,xl=!J2(ee._f)&&!t.resolver&&!ue(n.errors,B)&&!ee._f.deps||ek(Ss,ue(n.touchedFields,B),n.isSubmitted,De,he),Vr=Gp(B,o,Ss);He(i,B,Ys),Ss?(!$||!$.readOnly)&&(ee._f.onBlur&&ee._f.onBlur(A),c&&c(0)):ee._f.onChange&&ee._f.onChange(A);const Qr=F(B,Ys,Ss),gl=!Kt(Qr)||Vr;if(!Ss&&m.state.next({name:B,type:A.type,values:pt(i)}),xl)return(h.isValid||p.isValid)&&(t.mode==="onBlur"?Ss&&w():Ss||w()),gl&&m.state.next({name:B,...Vr?{}:Qr});if(!Ss&&Vr&&m.state.next({...n}),t.resolver){const{errors:Wa}=await S([B]);if(v([B]),J(Ys),ie){const yl=Zp(n.errors,r,B),Ga=Zp(Wa,r,yl.name||B);Fe=Ga.error,B=Ga.name,bt=Kt(Wa)}}else v([B],!0),Fe=(await Xp(ee,o.disabled,i,f,t.shouldUseNativeValidation))[B],v([B]),J(Ys),ie&&(Fe?bt=!1:(h.isValid||p.isValid)&&(bt=await P(r,!0)));ie&&(ee._f.deps&&(!Array.isArray(ee._f.deps)||ee._f.deps.length>0)&&te(ee._f.deps),E(B,bt,Fe,Qr))}},X=(A,$)=>{if(ue(n.errors,$)&&A.focus)return A.focus(),1},te=async(A,$={})=>{let B,ie;const ee=wi(A);if(t.resolver){const J=await M(Ze(A)?A:ee);B=Kt(J),ie=A?!ee.some(he=>ue(J,he)):B}else A?(ie=(await Promise.all(ee.map(async J=>{const he=ue(r,J);return await P(he&&he._f?{[J]:he}:he)}))).every(Boolean),!(!ie&&!n.isValid)&&w()):ie=B=await P(r);return m.state.next({...!os(A)||(h.isValid||p.isValid)&&B!==n.isValid?{}:{name:A},...t.resolver||!A?{isValid:B}:{},errors:n.errors}),$.shouldFocus&&!ie&&Si(r,X,A?ee:o.mount),ie},pe=(A,$)=>{let B={...l.mount?i:a};return $&&(B=Q0($.dirtyFields?n.dirtyFields:n.touchedFields,B)),Ze(A)?B:os(A)?ue(B,A):A.map(ie=>ue(B,ie))},oe=(A,$)=>({invalid:!!ue(($||n).errors,A),isDirty:!!ue(($||n).dirtyFields,A),error:ue(($||n).errors,A),isValidating:!!ue(n.validatingFields,A),isTouched:!!ue(($||n).touchedFields,A)}),Ge=A=>{A&&wi(A).forEach($=>dt(n.errors,$)),m.state.next({errors:A?n.errors:{}})},Q=(A,$,B)=>{const ie=(ue(r,A,{_f:{}})._f||{}).ref,ee=ue(n.errors,A)||{},{ref:J,message:he,type:De,...Fe}=ee;He(n.errors,A,{...Fe,...$,ref:ie}),m.state.next({name:A,errors:n.errors,isValid:!1}),B&&B.shouldFocus&&ie&&ie.focus&&ie.focus()},Se=(A,$)=>Ms(A)?m.state.subscribe({next:B=>"values"in B&&A(U(void 0,$),B)}):U(A,$,!0),Me=A=>m.state.subscribe({next:$=>{Y2(A.name,$.name,A.exact)&&X2($,A.formState||h,Ha,A.reRenderRoot)&&A.callback({values:{...i},...n,...$,defaultValues:a})}}).unsubscribe,Qe=A=>(l.mount=!0,p={...p,...A.formState},Me({...A,formState:{...d,...A.formState}})),ft=(A,$={})=>{for(const B of A?wi(A):o.mount)o.mount.delete(B),o.array.delete(B),$.keepValue||(dt(r,B),dt(i,B)),!$.keepError&&dt(n.errors,B),!$.keepDirty&&dt(n.dirtyFields,B),!$.keepTouched&&dt(n.touchedFields,B),!$.keepIsValidating&&dt(n.validatingFields,B),!t.shouldUnregister&&!$.keepDefaultValue&&dt(a,B);m.state.next({values:pt(i)}),m.state.next({...n,...$.keepDirty?{isDirty:L()}:{}}),!$.keepIsValid&&w()},jt=({disabled:A,name:$})=>{if(Ks(A)&&l.mount||A||o.disabled.has($)){const ee=o.disabled.has($)!==!!A;A?o.disabled.add($):o.disabled.delete($),ee&&l.mount&&!l.action&&w()}},W=(A,$={})=>{let B=ue(r,A);const ie=Ks($.disabled)||Ks(t.disabled);return He(r,A,{...B||{},_f:{...B&&B._f?B._f:{ref:{name:A}},name:A,mount:!0,...$}}),o.mount.add(A),B?jt({disabled:Ks($.disabled)?$.disabled:t.disabled,name:A}):k(A,!0,$.value),{...ie?{disabled:$.disabled||t.disabled}:{},...t.progressive?{required:!!$.required,min:ii($.min),max:ii($.max),minLength:ii($.minLength),maxLength:ii($.maxLength),pattern:ii($.pattern)}:{},name:A,onChange:K,onBlur:K,ref:ee=>{if(ee){W(A,$),B=ue(r,A);const J=Ze(ee.value)&&ee.querySelectorAll&&ee.querySelectorAll("input,select,textarea")[0]||ee,he=V2(J),De=B._f.refs||[];if(he?De.find(Fe=>Fe===J):J===B._f.ref)return;He(r,A,{_f:{...B._f,...he?{refs:[...De.filter(tu),J,...Array.isArray(ue(a,A))?[{}]:[]],ref:{type:J.type,name:A}}:{ref:J}}}),k(A,!1,void 0,J)}else B=ue(r,A,{}),B._f&&(B._f.mount=!1),(t.shouldUnregister||$.shouldUnregister)&&!(O2(o.array,A)&&l.action)&&o.unMount.add(A)}}},$e=()=>t.shouldFocusError&&Si(r,X,o.mount),Dt=A=>{Ks(A)&&(m.state.next({disabled:A}),Si(r,($,B)=>{const ie=ue(r,B);ie&&($.disabled=ie._f.disabled||A,Array.isArray(ie._f.refs)&&ie._f.refs.forEach(ee=>{ee.disabled=ie._f.disabled||A}))},0,!1))},Cn=(A,$)=>async B=>{let ie;B&&(B.preventDefault&&B.preventDefault(),B.persist&&B.persist());let ee=pt(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:J,values:he}=await S();v(),n.errors=J,ee=pt(he)}else await P(r);if(o.disabled.size)for(const J of o.disabled)dt(ee,J);if(dt(n.errors,"root"),Kt(n.errors)){m.state.next({errors:{}});try{await A(ee,B)}catch(J){ie=J}}else $&&await $({...n.errors},B),$e(),setTimeout($e);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Kt(n.errors)&&!ie,submitCount:n.submitCount+1,errors:n.errors}),ie)throw ie},fs=(A,$={})=>{ue(r,A)&&(Ze($.defaultValue)?N(A,pt(ue(a,A))):(N(A,$.defaultValue),He(a,A,pt($.defaultValue))),$.keepTouched||dt(n.touchedFields,A),$.keepDirty||(dt(n.dirtyFields,A),n.isDirty=$.defaultValue?L(A,pt(ue(a,A))):L()),$.keepError||(dt(n.errors,A),h.isValid&&w()),m.state.next({...n}))},En=(A,$={})=>{const B=A?pt(A):a,ie=pt(B),ee=Kt(A),J=ee?a:ie;if($.keepDefaultValues||(a=B),!$.keepValues){if($.keepDirtyValues){const he=new Set([...o.mount,...Object.keys(Gr(a,i))]);for(const De of Array.from(he)){const Fe=ue(n.dirtyFields,De),bt=ue(i,De),Ys=ue(J,De);Fe&&!Ze(bt)?He(J,De,bt):!Fe&&!Ze(Ys)&&N(De,Ys)}}else{if(Bm&&Ze(A))for(const he of o.mount){const De=ue(r,he);if(De&&De._f){const Fe=Array.isArray(De._f.refs)?De._f.refs[0]:De._f.ref;if($o(Fe)){const bt=Fe.closest("form");if(bt){bt.reset();break}}}}if($.keepFieldsRef)for(const he of o.mount)N(he,ue(J,he));else r={}}i=t.shouldUnregister?$.keepDefaultValues?pt(a):{}:pt(J),m.array.next({values:{...J}}),m.state.next({values:{...J}})}o={mount:$.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!h.isValid||!!$.keepIsValid||!!$.keepDirtyValues||!t.shouldUnregister&&!Kt(J),l.watch=!!t.shouldUnregister,l.keepIsValid=!!$.keepIsValid,l.action=!1,$.keepErrors||(n.errors={}),m.state.next({submitCount:$.keepSubmitCount?n.submitCount:0,isDirty:ee?!1:$.keepDirty?n.isDirty:!!($.keepDefaultValues&&!Ln(A,a)),isSubmitted:$.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ee?{}:$.keepDirtyValues?$.keepDefaultValues&&i?Gr(a,i):n.dirtyFields:$.keepDefaultValues&&A?Gr(a,A):$.keepDirty?n.dirtyFields:{},touchedFields:$.keepTouched?n.touchedFields:{},errors:$.keepErrors?n.errors:{},isSubmitSuccessful:$.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},G=(A,$)=>En(Ms(A)?A(i):A,{...t.resetOptions,...$}),ke=(A,$={})=>{const B=ue(r,A),ie=B&&B._f;if(ie){const ee=ie.refs?ie.refs[0]:ie.ref;ee.focus&&setTimeout(()=>{ee.focus(),$.shouldSelect&&Ms(ee.select)&&ee.select()})}},Ha=A=>{n={...n,...A}},pl={control:{register:W,unregister:ft,getFieldState:oe,handleSubmit:Cn,setError:Q,_subscribe:Me,_runSchema:S,_updateIsValidating:v,_focusError:$e,_getWatch:U,_getDirty:L,_setValid:w,_setFieldArray:g,_setDisabledField:jt,_setErrors:b,_getFieldArray:V,_reset:En,_resetDefaultValues:()=>Ms(t.defaultValues)&&t.defaultValues().then(A=>{G(A,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:z,_disableForm:Dt,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return l},set _state(A){l=A},get _defaultValues(){return a},get _names(){return o},set _names(A){o=A},get _formState(){return n},get _options(){return t},set _options(A){t={...t,...A}}},subscribe:Qe,trigger:te,register:W,handleSubmit:Cn,watch:Se,setValue:N,getValues:pe,reset:G,resetField:fs,clearErrors:Ge,unregister:ft,setError:Q,setFocus:ke,getFieldState:oe};return{...pl,formControl:pl}}function X0(e={}){const t=At.useRef(void 0),n=At.useRef(void 0),[r,a]=At.useState({isDirty:!1,isValidating:!1,isLoading:Ms(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:Ms(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Ms(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=rk(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,K2(()=>{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]),At.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),At.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),At.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),At.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),At.useEffect(()=>{if(i._proxyFormState.isDirty){const l=i._getDirty();l!==r.isDirty&&i._subjects.state.next({isDirty:l})}},[i,r.isDirty]),At.useEffect(()=>{var l;e.values&&!Ln(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((l=i._options.resetOptions)===null||l===void 0)&&l.keepIsValid||i._setValid(),n.current=e.values,a(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),At.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=At.useMemo(()=>_2(r,i),[i,r]),t.current}function Yp(){var v,g;const{id:e}=ac(),t=Ht(),n=xe(),r=!!e,{register:a,handleSubmit:i,reset:l,watch:o,setValue:c,formState:{errors:u}}=X0(),d=o("type"),{data:h}=me({queryKey:["customer",e],queryFn:()=>kt.getById(parseInt(e)),enabled:r});j.useEffect(()=>{if(h!=null&&h.data){const x={...h.data};x.birthDate&&(x.birthDate=x.birthDate.split("T")[0]),x.foundingDate&&(x.foundingDate=x.foundingDate.split("T")[0]),l(x)}},[h,l]);const p=H({mutationFn:kt.create,onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),t("/customers")}}),m=H({mutationFn:x=>kt.update(parseInt(e),x),onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),n.invalidateQueries({queryKey:["customer",e]}),t(`/customers/${e}`)}}),f=x=>{const b={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()!==""?b.birthDate=new Date(x.birthDate).toISOString():b.birthDate=null,x.foundingDate&&typeof x.foundingDate=="string"&&x.foundingDate.trim()!==""?b.foundingDate=new Date(x.foundingDate).toISOString():b.foundingDate=null,r?m.mutate(b):p.mutate(b)},y=p.isPending||m.isPending,w=p.error||m.error;return s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:r?"Kunde bearbeiten":"Neuer Kunde"}),w&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:w instanceof Error?w.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:i(f),children:[s.jsx(Y,{className:"mb-6",title:"Stammdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Oe,{label:"Kundentyp",...a("type"),options:[{value:"PRIVATE",label:"Privatkunde"},{value:"BUSINESS",label:"Geschäftskunde"}]}),s.jsx(Oe,{label:"Anrede",...a("salutation"),options:[{value:"Herr",label:"Herr"},{value:"Frau",label:"Frau"},{value:"Divers",label:"Divers"}]}),s.jsx(q,{label:"Vorname",...a("firstName",{required:"Vorname erforderlich"}),error:(v=u.firstName)==null?void 0:v.message}),s.jsx(q,{label:"Nachname",...a("lastName",{required:"Nachname erforderlich"}),error:(g=u.lastName)==null?void 0:g.message}),d==="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(q,{label:"Firmenname",...a("companyName"),className:"md:col-span-2"}),s.jsx(q,{label:"Gründungsdatum",type:"date",...a("foundingDate"),value:o("foundingDate")||"",onClear:()=>c("foundingDate","")})]}),d!=="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(q,{label:"Geburtsdatum",type:"date",...a("birthDate"),value:o("birthDate")||"",onClear:()=>c("birthDate","")}),s.jsx(q,{label:"Geburtsort",...a("birthPlace")})]})]})}),s.jsx(Y,{className:"mb-6",title:"Kontaktdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"E-Mail",type:"email",...a("email")}),s.jsx(q,{label:"Telefon",...a("phone")}),s.jsx(q,{label:"Mobil",...a("mobile")})]})}),d==="BUSINESS"&&s.jsxs(Y,{className:"mb-6",title:"Geschäftsdaten",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Steuernummer",...a("taxNumber")}),s.jsx(q,{label:"Handelsregisternummer",...a("commercialRegisterNumber"),placeholder:"z.B. HRB 12345"})]}),r&&s.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Dokumente (Gewerbeanmeldung, Handelsregisterauszug) können nach dem Speichern in der Kundendetailansicht hochgeladen werden."})]}),s.jsx(Y,{className:"mb-6",title:"Notizen",children:s.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..."})}),s.jsxs("div",{className:"flex justify-end gap-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:()=>t(-1),children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:y,children:y?"Speichern...":"Speichern"})]})]})]})}const su={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},nu={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},ex={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function ak(){const[e,t]=lc(),n=Ht(),[r,a]=j.useState(e.get("search")||""),[i,l]=j.useState(e.get("type")||""),[o,c]=j.useState(e.get("status")||""),[u,d]=j.useState(parseInt(e.get("page")||"1",10)),{hasPermission:h,isCustomer:p,isCustomerPortal:m,user:f}=Ue(),y=xe();j.useEffect(()=>{const b=new URLSearchParams;r&&b.set("search",r),i&&b.set("type",i),o&&b.set("status",o),u>1&&b.set("page",u.toString()),t(b,{replace:!0})},[r,i,o,u,t]);const w=H({mutationFn:qe.delete,onSuccess:()=>{y.invalidateQueries({queryKey:["contracts"]})}}),{data:v,isLoading:g}=me({queryKey:["contracts",r,i,o,u,p?f==null?void 0:f.customerId:null],queryFn:()=>qe.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=j.useMemo(()=>{if(!m||!(v!=null&&v.data))return null;const b={};for(const k of v.data){const F=k.customerId;if(!b[F]){const E=k.customer?k.customer.companyName||`${k.customer.firstName} ${k.customer.lastName}`:`Kunde ${F}`;b[F]={customerName:E,isOwn:F===(f==null?void 0:f.customerId),contracts:[]}}b[F].contracts.push(k)}return Object.values(b).sort((k,F)=>k.isOwn&&!F.isOwn?-1:!k.isOwn&&F.isOwn?1:k.customerName.localeCompare(F.customerName))},[v==null?void 0:v.data,m,f==null?void 0:f.customerId]);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Verträge"}),h("contracts:create")&&!p&&s.jsx(we,{to:"/contracts/new",children:s.jsxs(T,{children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Neuer Vertrag"]})})]}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-4 flex-wrap",children:[s.jsx("div",{className:"flex-1 min-w-[200px]",children:s.jsx(q,{placeholder:"Suchen...",value:r,onChange:b=>a(b.target.value)})}),s.jsx(Oe,{value:i,onChange:b=>l(b.target.value),options:Object.entries(su).map(([b,k])=>({value:b,label:k})),className:"w-48"}),s.jsx(Oe,{value:o,onChange:b=>c(b.target.value),options:Object.entries(nu).map(([b,k])=>({value:b,label:k})),className:"w-48"}),s.jsx(T,{variant:"secondary",children:s.jsx(ml,{className:"w-4 h-4"})})]})}),g?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):v!=null&&v.data&&v.data.length>0?s.jsx(s.Fragment,{children:m&&x?s.jsx("div",{className:"space-y-6",children:x.map(b=>s.jsxs(Y,{children:[s.jsx("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:b.isOwn?s.jsxs(s.Fragment,{children:[s.jsx(Km,{className:"w-5 h-5 text-blue-600"}),s.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Meine Verträge"}),s.jsx(ye,{variant:"default",children:b.contracts.length})]}):s.jsxs(s.Fragment,{children:[s.jsx(pa,{className:"w-5 h-5 text-purple-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Verträge von ",b.customerName]}),s.jsx(ye,{variant:"default",children:b.contracts.length})]})}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Vertragsnr."}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Anbieter / Tarif"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beginn"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:b.contracts.map(k=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:k.contractNumber}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ye,{children:su[k.type]})}),s.jsxs("td",{className:"py-3 px-4",children:[k.providerName||"-",k.tariffName&&s.jsxs("span",{className:"text-gray-500",children:[" / ",k.tariffName]})]}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ye,{variant:ex[k.status],children:nu[k.status]})}),s.jsx("td",{className:"py-3 px-4",children:k.startDate?new Date(k.startDate).toLocaleDateString("de-DE"):"-"}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${k.id}`,{state:{from:"contracts"}}),children:s.jsx(Ae,{className:"w-4 h-4"})})})]},k.id))})]})})]},b.isOwn?"own":b.customerName))}):s.jsxs(Y,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Vertragsnr."}),!p&&s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kunde"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Anbieter / Tarif"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beginn"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:v.data.map(b=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:b.contractNumber}),!p&&s.jsx("td",{className:"py-3 px-4",children:b.customer&&s.jsx(we,{to:`/customers/${b.customer.id}`,className:"text-blue-600 hover:underline",children:b.customer.companyName||`${b.customer.firstName} ${b.customer.lastName}`})}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ye,{children:su[b.type]})}),s.jsxs("td",{className:"py-3 px-4",children:[b.providerName||"-",b.tariffName&&s.jsxs("span",{className:"text-gray-500",children:[" / ",b.tariffName]})]}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ye,{variant:ex[b.status],children:nu[b.status]})}),s.jsx("td",{className:"py-3 px-4",children:b.startDate?new Date(b.startDate).toLocaleDateString("de-DE"):"-"}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${b.id}`,{state:{from:"contracts"}}),children:s.jsx(Ae,{className:"w-4 h-4"})}),h("contracts:update")&&!p&&s.jsx(we,{to:`/contracts/${b.id}/edit`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(tt,{className:"w-4 h-4"})})}),h("contracts:delete")&&!p&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&w.mutate(b.id)},children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})})]},b.id))})]})}),v.pagination&&v.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",v.pagination.page," von ",v.pagination.totalPages," (",v.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>d(b=>Math.max(1,b-1)),disabled:u===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>d(b=>b+1),disabled:u>=v.pagination.totalPages,children:"Weiter"})]})]})]})}):s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Verträge gefunden."})})]})}const ik={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},lk={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},ok={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function ck(e){const t=e.match(/^(\d+)([TMWJ])$/);if(!t)return!1;const n=parseInt(t[1]),r=t[2];let a=0;return r==="T"?a=n:r==="W"?a=n*7:r==="M"?a=n*30:r==="J"&&(a=n*365),a<=30}function uk({simCard:e}){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[i,l]=j.useState(!1),o=async()=>{if(t)n(!1),a(null);else{l(!0);try{const c=await qe.getSimCardCredentials(e.id);c.data&&(a(c.data),n(!0))}catch{alert("PIN/PUK konnte nicht geladen werden")}finally{l(!1)}}};return s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg border",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.isMain&&s.jsx(ye,{variant:"success",children:"Hauptkarte"}),e.isMultisim&&s.jsx(ye,{variant:"warning",children:"Multisim"})]}),s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[e.phoneNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Rufnummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[e.phoneNumber,s.jsx(de,{value:e.phoneNumber})]})]}),e.simCardNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIM-Nr."}),s.jsxs("dd",{className:"font-mono text-xs flex items-center gap-1",children:[e.simCardNumber,s.jsx(de,{value:e.simCardNumber})]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"PIN"}),s.jsx("dd",{className:"font-mono flex items-center gap-1",children:t&&(r!=null&&r.pin)?s.jsxs(s.Fragment,{children:[r.pin,s.jsx(de,{value:r.pin})]}):"••••"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"PUK"}),s.jsx("dd",{className:"font-mono flex items-center gap-1",children:t&&(r!=null&&r.puk)?s.jsxs(s.Fragment,{children:[r.puk,s.jsx(de,{value:r.puk})]}):"••••••••"})]})]}),s.jsx("div",{className:"mt-2",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:o,disabled:i,children:i?"Laden...":t?s.jsxs(s.Fragment,{children:[s.jsx(Mt,{className:"w-4 h-4 mr-1"})," PIN/PUK verbergen"]}):s.jsxs(s.Fragment,{children:[s.jsx(Ae,{className:"w-4 h-4 mr-1"})," PIN/PUK anzeigen"]})})})]})}function dk({meterId:e,meterType:t,readings:n,contractId:r,canEdit:a}){const[i,l]=j.useState(!1),[o,c]=j.useState(!1),[u,d]=j.useState(null),h=xe(),p=H({mutationFn:y=>Zs.deleteReading(e,y),onSuccess:()=>{h.invalidateQueries({queryKey:["contract",r.toString()]})}}),m=[...n].sort((y,w)=>new Date(w.readingDate).getTime()-new Date(y.readingDate).getTime()),f=t==="ELECTRICITY"?"kWh":"m³";return s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(R0,{className:"w-4 h-4 text-gray-500"}),s.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Zählerstände"}),s.jsx(ye,{variant:"default",children:n.length})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[a&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>c(!0),title:"Zählerstand erfassen",children:s.jsx(ze,{className:"w-4 h-4"})}),n.length>0&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(!i),children:i?s.jsx(I0,{className:"w-4 h-4"}):s.jsx(pc,{className:"w-4 h-4"})})]})]}),i&&n.length>0&&s.jsx("div",{className:"space-y-2 bg-gray-50 rounded-lg p-3",children:m.map(y=>s.jsxs("div",{className:"flex justify-between items-center text-sm group py-1 border-b border-gray-200 last:border-0",children:[s.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(y.readingDate).toLocaleDateString("de-DE"),s.jsx(de,{value:new Date(y.readingDate).toLocaleDateString("de-DE")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[y.value.toLocaleString("de-DE")," ",y.unit,s.jsx(de,{value:y.value.toString(),title:"Nur Wert kopieren"})]}),a&&s.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[s.jsx("button",{onClick:()=>d(y),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(tt,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&p.mutate(y.id)},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:s.jsx(je,{className:"w-3 h-3"})})]})]})]},y.id))}),!i&&n.length>0&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Letzter Stand: ",m[0].value.toLocaleString("de-DE")," ",m[0].unit," (",new Date(m[0].readingDate).toLocaleDateString("de-DE"),")"]}),n.length===0&&s.jsx("p",{className:"text-sm text-gray-500",children:"Keine Zählerstände vorhanden."}),(o||u)&&s.jsx(mk,{isOpen:!0,onClose:()=>{c(!1),d(null)},meterId:e,contractId:r,reading:u,defaultUnit:f})]})}function mk({isOpen:e,onClose:t,meterId:n,contractId:r,reading:a,defaultUnit:i}){var f;const l=xe(),o=!!a,[c,u]=j.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=H({mutationFn:y=>Zs.addReading(n,y),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),h=H({mutationFn:y=>Zs.updateReading(n,a.id,y),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),p=y=>{y.preventDefault();const w={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:c.unit,notes:c.notes||void 0};o?h.mutate(w):d.mutate(w)},m=d.isPending||h.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:o?"Zählerstand bearbeiten":"Zählerstand erfassen",children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(q,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:y=>u({...c,readingDate:y.target.value}),required:!0}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(q,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:y=>u({...c,value:y.target.value}),required:!0})}),s.jsx(Oe,{label:"Einheit",value:c.unit,onChange:y=>u({...c,unit:y.target.value}),options:[{value:"kWh",label:"kWh"},{value:"m³",label:"m³"}]})]}),s.jsx(q,{label:"Notizen (optional)",value:c.notes,onChange:y=>u({...c,notes:y.target.value})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m||!c.value,children:m?"Speichern...":o?"Speichern":"Erfassen"})]})]})})}function tx({task:e,contractId:t,canEdit:n,isCustomerPortal:r,isCompleted:a,onEdit:i}){const[l,o]=j.useState(""),[c,u]=j.useState(!1),[d,h]=j.useState(null),[p,m]=j.useState(""),f=xe(),y=H({mutationFn:N=>it.complete(N),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),w=H({mutationFn:N=>it.reopen(N),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),v=H({mutationFn:N=>it.delete(N),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),g=H({mutationFn:N=>it.createSubtask(e.id,N),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),u(!1)},onError:N=>{console.error("Fehler beim Erstellen der Unteraufgabe:",N),alert("Fehler beim Erstellen der Unteraufgabe. Bitte versuchen Sie es erneut.")}}),x=H({mutationFn:N=>it.createReply(e.id,N),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),u(!1)},onError:N=>{console.error("Fehler beim Erstellen der Antwort:",N),alert("Fehler beim Erstellen der Antwort. Bitte versuchen Sie es erneut.")}}),b=H({mutationFn:({id:N,title:K})=>it.updateSubtask(N,K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),h(null),m("")}}),k=H({mutationFn:N=>it.completeSubtask(N),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),F=H({mutationFn:N=>it.reopenSubtask(N),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),E=H({mutationFn:N=>it.deleteSubtask(N),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),S=N=>{N.preventDefault(),l.trim()&&(r?x.mutate(l.trim()):g.mutate(l.trim()))},M=N=>{N.preventDefault(),p.trim()&&d&&b.mutate({id:d,title:p.trim()})},P=(N,K)=>{h(N),m(K)},z=()=>{h(null),m("")},L=e.subtasks||[],U=L.filter(N=>N.status==="OPEN"),V=L.filter(N=>N.status==="COMPLETED"),R=r?{singular:"Antwort",placeholder:"Antwort...",deleteConfirm:"Antwort löschen?"}:{singular:"Unteraufgabe",placeholder:"Unteraufgabe...",deleteConfirm:"Unteraufgabe löschen?"},C=(N,K)=>d===N.id?s.jsx("div",{className:"py-1",children:s.jsxs("form",{onSubmit:M,className:"flex items-center gap-2",children:[s.jsx(ro,{className:"w-4 h-4 text-gray-300 flex-shrink-0"}),s.jsx("input",{type:"text",value:p,onChange:te=>m(te.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}),s.jsx(T,{type:"submit",size:"sm",disabled:!p.trim()||b.isPending,children:"✓"}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:z,children:"×"})]})},N.id):s.jsx("div",{className:`py-1 group/subtask ${K?"opacity-60":""}`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("button",{onClick:()=>K?F.mutate(N.id):k.mutate(N.id),disabled:k.isPending||F.isPending||r,className:`flex-shrink-0 mt-0.5 ${r?"cursor-default":K?"hover:text-yellow-600":"hover:text-green-600"}`,children:K?s.jsx(js,{className:"w-4 h-4 text-green-500"}):s.jsx(ro,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:`text-sm ${K?"line-through text-gray-500":""}`,children:N.title}),n&&!r&&!K&&s.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover/subtask:opacity-100",children:[s.jsx("button",{onClick:()=>P(N.id,N.title),className:"text-gray-400 hover:text-blue-600 p-0.5",title:"Bearbeiten",children:s.jsx(tt,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm(R.deleteConfirm)&&E.mutate(N.id)},className:"text-gray-400 hover:text-red-600 p-0.5",title:"Löschen",children:s.jsx(je,{className:"w-3 h-3"})})]}),n&&!r&&K&&s.jsx("button",{onClick:()=>{confirm(R.deleteConfirm)&&E.mutate(N.id)},className:"text-gray-400 hover:text-red-600 p-0.5 opacity-0 group-hover/subtask:opacity-100",title:"Löschen",children:s.jsx(je,{className:"w-3 h-3"})})]}),s.jsxs("p",{className:"text-xs text-gray-400",children:[N.createdBy&&`${N.createdBy} • `,K?`Erledigt am ${N.completedAt?new Date(N.completedAt).toLocaleDateString("de-DE"):new Date(N.updatedAt).toLocaleDateString("de-DE")}`:new Date(N.createdAt).toLocaleDateString("de-DE")]})]})]})},N.id);return s.jsx("div",{className:`p-3 bg-gray-50 rounded-lg group ${a?"bg-gray-50/50 opacity-70":""}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>a?w.mutate(e.id):y.mutate(e.id),disabled:y.isPending||w.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?s.jsx(js,{className:"w-5 h-5 text-green-500"}):s.jsx(ro,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`font-medium ${a?"line-through text-gray-500":""}`,children:e.title}),e.visibleInPortal&&s.jsx(ye,{variant:"default",className:"text-xs",children:"Portal"}),L.length>0&&s.jsxs("span",{className:"text-xs text-gray-400",children:["(",V.length,"/",L.length,")"]})]}),e.description&&s.jsx("p",{className:`text-sm mt-1 whitespace-pre-wrap ${a?"text-gray-500":"text-gray-600"}`,children:e.description}),s.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")]}),L.length>0&&s.jsxs("div",{className:"mt-3 ml-2 space-y-0 border-l-2 border-gray-200 pl-3",children:[U.map(N=>C(N,!1)),V.map(N=>C(N,!0))]}),!a&&(n&&!r||r)&&s.jsx("div",{className:"mt-2 ml-2",children:c?s.jsxs("form",{onSubmit:S,className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:l,onChange:N=>o(N.target.value),placeholder:R.placeholder,className:"flex-1 text-sm px-2 py-1 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500",autoFocus:!0}),s.jsx(T,{type:"submit",size:"sm",disabled:!l.trim()||g.isPending||x.isPending,children:s.jsx(ze,{className:"w-3 h-3"})}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{u(!1),o("")},children:"×"})]}):s.jsxs("button",{onClick:()=>u(!0),className:"text-xs text-gray-400 hover:text-blue-600 flex items-center gap-1",children:[s.jsx(ze,{className:"w-3 h-3"}),R.singular]})})]}),n&&!r&&s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100",children:[!a&&s.jsx("button",{onClick:i,className:"text-gray-400 hover:text-blue-600 p-1",title:"Bearbeiten",children:s.jsx(tt,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm("Aufgabe wirklich löschen?")&&v.mutate(e.id)},className:"text-gray-400 hover:text-red-600 p-1",title:"Löschen",children:s.jsx(je,{className:"w-4 h-4"})})]})]})})}function hk({contractId:e,canEdit:t,isCustomerPortal:n}){var x;const[r,a]=j.useState(!1),[i,l]=j.useState(null),{data:o,isLoading:c}=me({queryKey:["contract-tasks",e],queryFn:()=>it.getByContract(e),staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:u,isLoading:d}=me({queryKey:["app-settings-public"],queryFn:()=>Ur.getPublic(),enabled:n,staleTime:0}),h=!d&&((x=u==null?void 0:u.data)==null?void 0:x.customerSupportTicketsEnabled)==="true",p=(o==null?void 0:o.data)||[],m=p.filter(b=>b.status==="OPEN"),f=p.filter(b=>b.status==="COMPLETED"),y=n?{title:"Support-Anfragen",button:"Anfrage erstellen",empty:"Keine Support-Anfragen vorhanden."}:{title:"Aufgaben",button:"Aufgabe",empty:"Keine Aufgaben vorhanden."},w=n?Zi:Gi;if(c||n&&d)return s.jsx(Y,{className:"mb-6",title:y.title,children:s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."})});const g=t&&!n||n&&h;return s.jsxs(Y,{className:"mb-6",title:y.title,children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(w,{className:"w-5 h-5 text-gray-500"}),s.jsxs("span",{className:"text-sm text-gray-600",children:[m.length," offen, ",f.length," erledigt"]})]}),g&&s.jsxs(T,{size:"sm",onClick:()=>a(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-1"}),y.button]})]}),p.length===0?s.jsx("p",{className:"text-center py-4 text-gray-500",children:y.empty}):s.jsxs("div",{className:"space-y-2",children:[m.map(b=>s.jsx(tx,{task:b,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!1,onEdit:()=>l(b)},b.id)),f.length>0&&m.length>0&&s.jsx("div",{className:"border-t my-3"}),f.map(b=>s.jsx(tx,{task:b,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!0,onEdit:()=>{}},b.id))]}),(r||i)&&s.jsx(fk,{isOpen:!0,onClose:()=>{a(!1),l(null)},contractId:e,task:i,isCustomerPortal:n})]})}function fk({isOpen:e,onClose:t,contractId:n,task:r,isCustomerPortal:a=!1}){const i=xe(),l=!!r,[o,c]=j.useState({title:(r==null?void 0:r.title)||"",description:(r==null?void 0:r.description)||"",visibleInPortal:(r==null?void 0:r.visibleInPortal)||!1});j.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=H({mutationFn:y=>it.create(n,y),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),d=H({mutationFn:y=>it.createSupportTicket(n,y),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),h=H({mutationFn:y=>it.update(r.id,y),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),p=y=>{y.preventDefault(),l?h.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})},m=u.isPending||d.isPending||h.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 s.jsx(ut,{isOpen:e,onClose:t,title:f.modalTitle,children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(q,{label:f.titleLabel,value:o.title,onChange:y=>c({...o,title:y.target.value}),required:!0,placeholder:f.titlePlaceholder}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:f.descLabel}),s.jsx("textarea",{value:o.description,onChange:y=>c({...o,description:y.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&&s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.visibleInPortal,onChange:y=>c({...o,visibleInPortal:y.target.checked}),className:"w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),s.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m||!o.title.trim(),children:m?"Speichern...":f.submitBtn})]})]})})}function pk(){var K,X,te,pe,oe,Ge;const{id:e}=ac(),t=Ht(),r=kn().state,a=xe(),{hasPermission:i,isCustomer:l,isCustomerPortal:o}=Ue(),c=parseInt(e),[u,d]=j.useState(!1),[h,p]=j.useState(null),[m,f]=j.useState(!1),[y,w]=j.useState(!1),[v,g]=j.useState(null),[x,b]=j.useState({}),[k,F]=j.useState({}),{data:E,isLoading:S}=me({queryKey:["contract",e],queryFn:()=>qe.getById(c)}),M=H({mutationFn:()=>qe.delete(c),onSuccess:()=>{t("/contracts")}}),P=H({mutationFn:()=>qe.createFollowUp(c),onSuccess:Q=>{Q.data?t(`/contracts/${Q.data.id}/edit`):alert("Folgevertrag wurde erstellt, aber keine ID zurückgegeben")},onError:Q=>{console.error("Folgevertrag Fehler:",Q),alert(`Fehler beim Erstellen des Folgevertrags: ${Q instanceof Error?Q.message:"Unbekannter Fehler"}`)}}),z=H({mutationFn:Q=>{const Me={cancellationConfirmationDate:Q?new Date(Q).toISOString():null};return qe.update(c,Me)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:Q=>{console.error("Fehler beim Speichern des Datums:",Q),alert("Fehler beim Speichern des Datums")}}),L=H({mutationFn:Q=>{const Me={cancellationConfirmationOptionsDate:Q?new Date(Q).toISOString():null};return qe.update(c,Me)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:Q=>{console.error("Fehler beim Speichern des Datums:",Q),alert("Fehler beim Speichern des Datums")}}),U=async()=>{var Q;if(u)d(!1),p(null);else try{const Se=await qe.getPassword(c);(Q=Se.data)!=null&&Q.password&&(p(Se.data.password),d(!0))}catch{alert("Passwort konnte nicht entschlüsselt werden")}},V=async()=>{var Q;if(y)w(!1),g(null);else try{const Se=await qe.getInternetCredentials(c);(Q=Se.data)!=null&&Q.password&&(g(Se.data.password),w(!0))}catch{alert("Internet-Passwort konnte nicht entschlüsselt werden")}},R=async Q=>{var Se;if(x[Q])b(Me=>({...Me,[Q]:!1})),F(Me=>({...Me,[Q]:null}));else try{const Qe=(Se=(await qe.getSipCredentials(Q)).data)==null?void 0:Se.password;Qe&&(F(ft=>({...ft,[Q]:Qe})),b(ft=>({...ft,[Q]:!0})))}catch{alert("SIP-Passwort konnte nicht entschlüsselt werden")}},C=async()=>{var Me,Qe,ft;const Q=E==null?void 0:E.data,Se=((Me=Q==null?void 0:Q.stressfreiEmail)==null?void 0:Me.email)||(Q==null?void 0:Q.portalUsername);if(!((Qe=Q==null?void 0:Q.provider)!=null&&Qe.portalUrl)||!Se){alert("Portal-URL oder Benutzername fehlt");return}f(!0);try{const jt=await qe.getPassword(c);if(!((ft=jt.data)!=null&&ft.password)){alert("Passwort konnte nicht entschlüsselt werden");return}const W=Q.provider,$e=W.portalUrl,Dt=W.usernameFieldName||"username",Cn=W.passwordFieldName||"password",fs=new URL($e);fs.searchParams.set(Dt,Se),fs.searchParams.set(Cn,jt.data.password),window.open(fs.toString(),"_blank")}catch{alert("Fehler beim Auto-Login")}finally{f(!1)}};if(S)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(E!=null&&E.data))return s.jsx("div",{className:"text-center py-8 text-red-600",children:"Vertrag nicht gefunden"});const N=E.data;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[s.jsx(T,{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 Q=r.filter?`?filter=${r.filter}`:"";t(`/contracts/cockpit${Q}`)}else(r==null?void 0:r.from)==="contracts"?t("/contracts"):N.customer?t(`/customers/${N.customer.id}?tab=contracts`):t("/contracts")},children:s.jsx(Xs,{className:"w-4 h-4"})}),s.jsx("h1",{className:"text-2xl font-bold",children:N.contractNumber}),s.jsx(ye,{children:ik[N.type]}),s.jsx(ye,{variant:ok[N.status],children:lk[N.status]})]}),N.customer&&s.jsxs("p",{className:"text-gray-500 ml-10",children:["Kunde:"," ",s.jsx(we,{to:`/customers/${N.customer.id}`,className:"text-blue-600 hover:underline",children:N.customer.companyName||`${N.customer.firstName} ${N.customer.lastName}`})]})]}),!l&&s.jsxs("div",{className:"flex gap-2",children:[i("contracts:create")&&!N.followUpContract&&s.jsxs(T,{variant:"secondary",onClick:()=>P.mutate(),disabled:P.isPending,children:[s.jsx(Rm,{className:"w-4 h-4 mr-2"}),P.isPending?"Erstelle...":"Folgevertrag anlegen"]}),N.followUpContract&&s.jsx(we,{to:`/contracts/${N.followUpContract.id}`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(M0,{className:"w-4 h-4 mr-2"}),"Folgevertrag anzeigen"]})}),i("contracts:update")&&s.jsx(we,{to:`/contracts/${e}/edit`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(tt,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),i("contracts:delete")&&s.jsxs(T,{variant:"danger",onClick:()=>{confirm("Vertrag wirklich löschen?")&&M.mutate()},children:[s.jsx(je,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),N.previousContract&&s.jsx(Y,{className:"mb-6 border-l-4 border-l-blue-500",title:"Vorgängervertrag",children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),s.jsx("dd",{children:s.jsx(we,{to:`/contracts/${N.previousContract.id}`,className:"text-blue-600 hover:underline",children:N.previousContract.contractNumber})})]}),N.previousContract.providerName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{children:N.previousContract.providerName})]}),N.previousContract.customerNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),s.jsx("dd",{className:"font-mono",children:N.previousContract.customerNumberAtProvider})]}),N.previousContract.portalUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Zugangsdaten"}),s.jsx("dd",{children:N.previousContract.portalUsername})]})]})}),N.cancellationConfirmationDate&&s.jsxs("div",{className:"mb-6 p-4 bg-red-50 border-2 border-red-400 rounded-lg flex items-start gap-3",children:[s.jsx("span",{className:"text-red-600 text-xl font-bold",children:"!"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-red-800",children:"Kündigungsbestätigung vorhanden"}),s.jsxs("p",{className:"text-sm text-red-700 mt-1",children:["Dieser Vertrag hat eine Kündigungsbestätigung vom"," ",s.jsx("strong",{children:new Date(N.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),".",N.cancellationConfirmationOptionsDate&&s.jsxs(s.Fragment,{children:[" Optionen-Bestätigung: ",s.jsx("strong",{children:new Date(N.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),"."]})]})]})]}),N.type==="MOBILE"&&((K=N.mobileDetails)==null?void 0:K.requiresMultisim)&&s.jsxs("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-300 rounded-lg flex items-start gap-3",children:[s.jsx("span",{className:"text-amber-600 text-xl font-bold",children:"!"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-amber-800",children:"Multisim erforderlich"}),s.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."})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[s.jsx(Y,{title:"Anbieter & Tarif",children:s.jsxs("dl",{className:"space-y-3",children:[(N.provider||N.providerName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{className:"font-medium",children:((X=N.provider)==null?void 0:X.name)||N.providerName})]}),(N.tariff||N.tariffName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Tarif"}),s.jsx("dd",{children:((te=N.tariff)==null?void 0:te.name)||N.tariffName})]}),N.customerNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.customerNumberAtProvider,s.jsx(de,{value:N.customerNumberAtProvider})]})]}),N.salesPlatform&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertriebsplattform"}),s.jsx("dd",{children:N.salesPlatform.name})]}),N.commission!==null&&N.commission!==void 0&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Provision"}),s.jsx("dd",{children:N.commission.toLocaleString("de-DE",{style:"currency",currency:"EUR"})})]}),N.priceFirst12Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis erste 12 Monate"}),s.jsx("dd",{children:N.priceFirst12Months})]}),N.priceFrom13Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis ab 13. Monat"}),s.jsx("dd",{children:N.priceFrom13Months})]}),N.priceAfter24Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis nach 24 Monaten"}),s.jsx("dd",{children:N.priceAfter24Months})]})]})}),s.jsxs(Y,{title:"Laufzeit und Kündigung",className:N.cancellationConfirmationDate?"border-2 border-red-400":"",children:[N.contractDuration&&ck(N.contractDuration.code)&&s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.jsx("strong",{children:"Hinweis:"})," Dieser Vertrag gilt als unbefristet mit der jeweiligen Kündigungsfrist."]}),s.jsxs("dl",{className:"space-y-3",children:[N.startDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsbeginn"}),s.jsx("dd",{children:new Date(N.startDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),N.endDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsende"}),s.jsx("dd",{children:new Date(N.endDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),N.contractDuration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragslaufzeit"}),s.jsx("dd",{children:N.contractDuration.description})]}),N.cancellationPeriod&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsfrist"}),s.jsx("dd",{children:N.cancellationPeriod.description})]}),N.cancellationConfirmationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsdatum"}),s.jsx("dd",{children:new Date(N.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),N.cancellationConfirmationOptionsDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsoptionendatum"}),s.jsx("dd",{children:new Date(N.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),N.wasSpecialCancellation&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Sonderkündigung"}),s.jsx("dd",{children:s.jsx(ye,{variant:"warning",children:"Ja"})})]})]}),i("contracts:update")&&s.jsxs("div",{className:"mt-6 pt-6 border-t",children:[s.jsx("h4",{className:"font-medium mb-4",children:"Kündigungsdokumente"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben"}),N.cancellationLetterPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${N.cancellationLetterPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${N.cancellationLetterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Fs,{className:"w-4 h-4"}),"Download"]}),s.jsx(St,{onUpload:async Q=>{await rt.uploadCancellationLetter(c,Q),a.invalidateQueries({queryKey:["contract",e]})},existingFile:N.cancellationLetterPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await rt.deleteCancellationLetter(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(je,{className:"w-4 h-4"}),"Löschen"]})]}):s.jsx(St,{onUpload:async Q=>{await rt.uploadCancellationLetter(c,Q),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung"}),N.cancellationConfirmationPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${N.cancellationConfirmationPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${N.cancellationConfirmationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Fs,{className:"w-4 h-4"}),"Download"]}),s.jsx(St,{onUpload:async Q=>{await rt.uploadCancellationConfirmation(c,Q),a.invalidateQueries({queryKey:["contract",e]})},existingFile:N.cancellationConfirmationPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await rt.deleteCancellationConfirmation(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(je,{className:"w-4 h-4"}),"Löschen"]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"date",value:N.cancellationConfirmationDate?N.cancellationConfirmationDate.split("T")[0]:"",onChange:Q=>{const Se=Q.target.value||null;z.mutate(Se)},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"}),N.cancellationConfirmationDate&&s.jsx("button",{onClick:()=>z.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:s.jsx(je,{className:"w-4 h-4"})})]})]})]}):s.jsx(St,{onUpload:async Q=>{await rt.uploadCancellationConfirmation(c,Q),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben Optionen"}),N.cancellationLetterOptionsPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${N.cancellationLetterOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${N.cancellationLetterOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Fs,{className:"w-4 h-4"}),"Download"]}),s.jsx(St,{onUpload:async Q=>{await rt.uploadCancellationLetterOptions(c,Q),a.invalidateQueries({queryKey:["contract",e]})},existingFile:N.cancellationLetterOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await rt.deleteCancellationLetterOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(je,{className:"w-4 h-4"}),"Löschen"]})]}):s.jsx(St,{onUpload:async Q=>{await rt.uploadCancellationLetterOptions(c,Q),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung Optionen"}),N.cancellationConfirmationOptionsPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${N.cancellationConfirmationOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${N.cancellationConfirmationOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Fs,{className:"w-4 h-4"}),"Download"]}),s.jsx(St,{onUpload:async Q=>{await rt.uploadCancellationConfirmationOptions(c,Q),a.invalidateQueries({queryKey:["contract",e]})},existingFile:N.cancellationConfirmationOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await rt.deleteCancellationConfirmationOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(je,{className:"w-4 h-4"}),"Löschen"]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"date",value:N.cancellationConfirmationOptionsDate?N.cancellationConfirmationOptionsDate.split("T")[0]:"",onChange:Q=>{const Se=Q.target.value||null;L.mutate(Se)},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"}),N.cancellationConfirmationOptionsDate&&s.jsx("button",{onClick:()=>L.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:s.jsx(je,{className:"w-4 h-4"})})]})]})]}):s.jsx(St,{onUpload:async Q=>{await rt.uploadCancellationConfirmationOptions(c,Q),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]})]})]})]})]}),(N.portalUsername||N.stressfreiEmail||N.portalPasswordEncrypted)&&s.jsxs(Y,{className:"mb-6",title:"Zugangsdaten",children:[s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[(N.portalUsername||N.stressfreiEmail)&&s.jsxs("div",{children:[s.jsxs("dt",{className:"text-sm text-gray-500",children:["Benutzername",N.stressfreiEmail&&s.jsx("span",{className:"ml-2 text-xs text-blue-600",children:"(Stressfrei-Wechseln)"})]}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[((pe=N.stressfreiEmail)==null?void 0:pe.email)||N.portalUsername,s.jsx(de,{value:((oe=N.stressfreiEmail)==null?void 0:oe.email)||N.portalUsername||""})]})]}),N.portalPasswordEncrypted&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),s.jsxs("dd",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono",children:u&&h?h:"••••••••"}),u&&h&&s.jsx(de,{value:h}),s.jsx(T,{variant:"ghost",size:"sm",onClick:U,children:u?s.jsx(Mt,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]}),((Ge=N.provider)==null?void 0:Ge.portalUrl)&&(N.portalUsername||N.stressfreiEmail)&&N.portalPasswordEncrypted&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs(T,{onClick:C,disabled:m,className:"w-full sm:w-auto",children:[s.jsx(Om,{className:"w-4 h-4 mr-2"}),m?"Wird geöffnet...":"Zum Kundenportal (Auto-Login)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Öffnet das Portal mit vorausgefüllten Zugangsdaten"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[N.address&&s.jsx(Y,{title:"Adresse",children:s.jsxs(q0,{values:[`${N.address.street} ${N.address.houseNumber}`,`${N.address.postalCode} ${N.address.city}`,N.address.country],children:[s.jsxs("p",{children:[N.address.street," ",N.address.houseNumber]}),s.jsxs("p",{children:[N.address.postalCode," ",N.address.city]}),s.jsx("p",{className:"text-gray-500",children:N.address.country})]})}),N.bankCard&&s.jsxs(Y,{title:"Bankkarte",children:[s.jsx("p",{className:"font-medium",children:N.bankCard.accountHolder}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[N.bankCard.iban,s.jsx(de,{value:N.bankCard.iban})]}),N.bankCard.bankName&&s.jsx("p",{className:"text-gray-500",children:N.bankCard.bankName})]}),N.identityDocument&&s.jsxs(Y,{title:"Ausweis",children:[s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[N.identityDocument.documentNumber,s.jsx(de,{value:N.identityDocument.documentNumber})]}),s.jsx("p",{className:"text-gray-500",children:N.identityDocument.type})]})]}),N.energyDetails&&s.jsxs(Y,{className:"mb-6",title:N.type==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[N.energyDetails.meter&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Zählernummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.energyDetails.meter.meterNumber,s.jsx(de,{value:N.energyDetails.meter.meterNumber})]})]}),N.energyDetails.annualConsumption&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Jahresverbrauch"}),s.jsxs("dd",{children:[N.energyDetails.annualConsumption.toLocaleString("de-DE")," ",N.type==="ELECTRICITY"?"kWh":"m³"]})]}),N.energyDetails.basePrice&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Grundpreis"}),s.jsxs("dd",{children:[N.energyDetails.basePrice.toLocaleString("de-DE")," €/Monat"]})]}),N.energyDetails.unitPrice&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Arbeitspreis"}),s.jsxs("dd",{children:[N.energyDetails.unitPrice.toLocaleString("de-DE")," ct/",N.type==="ELECTRICITY"?"kWh":"m³"]})]}),N.energyDetails.bonus&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Bonus"}),s.jsxs("dd",{children:[N.energyDetails.bonus.toLocaleString("de-DE")," €"]})]}),N.energyDetails.previousProviderName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversorger"}),s.jsx("dd",{children:N.energyDetails.previousProviderName})]}),N.energyDetails.previousCustomerNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorherige Kundennr."}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.energyDetails.previousCustomerNumber,s.jsx(de,{value:N.energyDetails.previousCustomerNumber})]})]})]}),N.energyDetails.meter&&s.jsx(dk,{meterId:N.energyDetails.meter.id,meterType:N.energyDetails.meter.type,readings:N.energyDetails.meter.readings||[],contractId:c,canEdit:i("contracts:update")&&!l})]}),N.internetDetails&&s.jsxs(Y,{className:"mb-6",title:N.type==="DSL"?"DSL-Details":N.type==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[N.internetDetails.downloadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Download"}),s.jsxs("dd",{children:[N.internetDetails.downloadSpeed," Mbit/s"]})]}),N.internetDetails.uploadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Upload"}),s.jsxs("dd",{children:[N.internetDetails.uploadSpeed," Mbit/s"]})]}),N.internetDetails.routerModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Router"}),s.jsx("dd",{children:N.internetDetails.routerModel})]}),N.internetDetails.routerSerialNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Router S/N"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.internetDetails.routerSerialNumber,s.jsx(de,{value:N.internetDetails.routerSerialNumber})]})]}),N.internetDetails.installationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Installation"}),s.jsx("dd",{children:new Date(N.internetDetails.installationDate).toLocaleDateString("de-DE")})]}),N.internetDetails.homeId&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Home-ID"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.internetDetails.homeId,s.jsx(de,{value:N.internetDetails.homeId})]})]}),N.internetDetails.activationCode&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Aktivierungscode"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.internetDetails.activationCode,s.jsx(de,{value:N.internetDetails.activationCode})]})]})]}),(N.internetDetails.internetUsername||N.internetDetails.internetPasswordEncrypted)&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Internet-Zugangsdaten"}),s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[N.internetDetails.internetUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Benutzername"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.internetDetails.internetUsername,s.jsx(de,{value:N.internetDetails.internetUsername})]})]}),N.internetDetails.internetPasswordEncrypted&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),s.jsxs("dd",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono",children:y&&v?v:"••••••••"}),y&&v&&s.jsx(de,{value:v}),s.jsx(T,{variant:"ghost",size:"sm",onClick:V,children:y?s.jsx(Mt,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})]}),N.internetDetails.phoneNumbers&&N.internetDetails.phoneNumbers.length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Rufnummern & SIP-Zugangsdaten"}),s.jsx("div",{className:"space-y-3",children:N.internetDetails.phoneNumbers.map(Q=>s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsxs("span",{className:"font-mono font-medium flex items-center gap-1",children:[Q.phoneNumber,s.jsx(de,{value:Q.phoneNumber})]}),Q.isMain&&s.jsx(ye,{variant:"success",children:"Hauptnummer"})]}),(Q.sipUsername||Q.sipPasswordEncrypted||Q.sipServer)&&s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[Q.sipUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIP-Benutzer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[Q.sipUsername,s.jsx(de,{value:Q.sipUsername})]})]}),Q.sipPasswordEncrypted&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIP-Passwort"}),s.jsxs("dd",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono",children:x[Q.id]&&k[Q.id]?k[Q.id]:"••••••••"}),x[Q.id]&&k[Q.id]&&s.jsx(de,{value:k[Q.id]}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>R(Q.id),children:x[Q.id]?s.jsx(Mt,{className:"w-3 h-3"}):s.jsx(Ae,{className:"w-3 h-3"})})]})]}),Q.sipServer&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIP-Server"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[Q.sipServer,s.jsx(de,{value:Q.sipServer})]})]})]})]},Q.id))})]})]}),N.mobileDetails&&s.jsxs(Y,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[N.mobileDetails.dataVolume&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Datenvolumen"}),s.jsxs("dd",{children:[N.mobileDetails.dataVolume," GB"]})]}),N.mobileDetails.includedMinutes&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-Minuten"}),s.jsx("dd",{children:N.mobileDetails.includedMinutes})]}),N.mobileDetails.includedSMS&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-SMS"}),s.jsx("dd",{children:N.mobileDetails.includedSMS})]}),N.mobileDetails.deviceModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Gerät"}),s.jsx("dd",{children:N.mobileDetails.deviceModel})]}),N.mobileDetails.deviceImei&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"IMEI"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.mobileDetails.deviceImei,s.jsx(de,{value:N.mobileDetails.deviceImei})]})]}),N.mobileDetails.requiresMultisim&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Multisim"}),s.jsx("dd",{children:s.jsx(ye,{variant:"warning",children:"Erforderlich"})})]})]}),N.mobileDetails.simCards&&N.mobileDetails.simCards.length>0&&s.jsxs("div",{className:"mt-6 pt-6 border-t",children:[s.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karten"}),s.jsx("div",{className:"space-y-3",children:N.mobileDetails.simCards.map(Q=>s.jsx(uk,{simCard:Q},Q.id))})]}),(!N.mobileDetails.simCards||N.mobileDetails.simCards.length===0)&&(N.mobileDetails.phoneNumber||N.mobileDetails.simCardNumber)&&s.jsxs("div",{className:"mt-6 pt-6 border-t",children:[s.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karte (Legacy)"}),s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[N.mobileDetails.phoneNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Rufnummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.mobileDetails.phoneNumber,s.jsx(de,{value:N.mobileDetails.phoneNumber})]})]}),N.mobileDetails.simCardNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SIM-Kartennummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.mobileDetails.simCardNumber,s.jsx(de,{value:N.mobileDetails.simCardNumber})]})]})]})]})]}),N.tvDetails&&s.jsx(Y,{className:"mb-6",title:"TV-Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[N.tvDetails.receiverModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Receiver"}),s.jsx("dd",{children:N.tvDetails.receiverModel})]}),N.tvDetails.smartcardNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Smartcard"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.tvDetails.smartcardNumber,s.jsx(de,{value:N.tvDetails.smartcardNumber})]})]}),N.tvDetails.package&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Paket"}),s.jsx("dd",{children:N.tvDetails.package})]})]})}),N.carInsuranceDetails&&s.jsx(Y,{className:"mb-6",title:"KFZ-Versicherung Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[N.carInsuranceDetails.licensePlate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kennzeichen"}),s.jsxs("dd",{className:"font-mono font-bold flex items-center gap-1",children:[N.carInsuranceDetails.licensePlate,s.jsx(de,{value:N.carInsuranceDetails.licensePlate})]})]}),N.carInsuranceDetails.vehicleType&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Fahrzeug"}),s.jsx("dd",{children:N.carInsuranceDetails.vehicleType})]}),N.carInsuranceDetails.hsn&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"HSN/TSN"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.carInsuranceDetails.hsn,"/",N.carInsuranceDetails.tsn,s.jsx(de,{value:`${N.carInsuranceDetails.hsn}/${N.carInsuranceDetails.tsn}`})]})]}),N.carInsuranceDetails.vin&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"FIN"}),s.jsxs("dd",{className:"font-mono text-sm flex items-center gap-1",children:[N.carInsuranceDetails.vin,s.jsx(de,{value:N.carInsuranceDetails.vin})]})]}),N.carInsuranceDetails.firstRegistration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Erstzulassung"}),s.jsx("dd",{children:new Date(N.carInsuranceDetails.firstRegistration).toLocaleDateString("de-DE")})]}),N.carInsuranceDetails.noClaimsClass&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SF-Klasse"}),s.jsx("dd",{children:N.carInsuranceDetails.noClaimsClass})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsart"}),s.jsx("dd",{children:s.jsx(ye,{variant:N.carInsuranceDetails.insuranceType==="FULL"?"success":N.carInsuranceDetails.insuranceType==="PARTIAL"?"warning":"default",children:N.carInsuranceDetails.insuranceType==="FULL"?"Vollkasko":N.carInsuranceDetails.insuranceType==="PARTIAL"?"Teilkasko":"Haftpflicht"})})]}),N.carInsuranceDetails.deductiblePartial&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Teilkasko"}),s.jsxs("dd",{children:[N.carInsuranceDetails.deductiblePartial," €"]})]}),N.carInsuranceDetails.deductibleFull&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Vollkasko"}),s.jsxs("dd",{children:[N.carInsuranceDetails.deductibleFull," €"]})]}),N.carInsuranceDetails.policyNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsschein-Nr."}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[N.carInsuranceDetails.policyNumber,s.jsx(de,{value:N.carInsuranceDetails.policyNumber})]})]}),N.carInsuranceDetails.previousInsurer&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversicherer"}),s.jsx("dd",{children:N.carInsuranceDetails.previousInsurer})]})]})}),s.jsx(hk,{contractId:c,canEdit:i("contracts:update"),isCustomerPortal:o}),!o&&i("contracts:read")&&N.customerId&&s.jsx(b2,{contractId:c,customerId:N.customerId}),N.notes&&s.jsx(Y,{title:"Notizen",children:s.jsx("p",{className:"whitespace-pre-wrap",children:N.notes})})]})}const xk=[{value:"DRAFT",label:"Entwurf"},{value:"PENDING",label:"Ausstehend"},{value:"ACTIVE",label:"Aktiv"},{value:"CANCELLED",label:"Gekündigt"},{value:"EXPIRED",label:"Abgelaufen"},{value:"DEACTIVATED",label:"Deaktiviert"}];function sx(){var Ss,xl,Vr,Qr,gl,Wa,yl,Ga,Wm;const{id:e}=ac(),[t]=lc(),n=Ht(),r=xe(),a=!!e,i=t.get("customerId"),{register:l,handleSubmit:o,reset:c,watch:u,setValue:d,formState:{errors:h}}=X0({defaultValues:{customerId:i||"",type:"ELECTRICITY",status:"DRAFT"}}),p=u("type"),m=u("customerId"),{data:f}=me({queryKey:["contract",e],queryFn:()=>qe.getById(parseInt(e)),enabled:a}),{data:y}=me({queryKey:["customers-all"],queryFn:()=>kt.getAll({limit:1e3})}),{data:w}=me({queryKey:["customer",m],queryFn:()=>kt.getById(parseInt(m)),enabled:!!m}),{data:v}=me({queryKey:["platforms"],queryFn:()=>Vi.getAll()}),{data:g}=me({queryKey:["cancellation-periods"],queryFn:()=>Qi.getAll()}),{data:x}=me({queryKey:["contract-durations"],queryFn:()=>Hi.getAll()}),{data:b}=me({queryKey:["providers"],queryFn:()=>za.getAll()}),{data:k}=me({queryKey:["contract-categories"],queryFn:()=>Wi.getAll()}),F=u("providerId"),[E,S]=j.useState(null),[M,P]=j.useState([]),[z,L]=j.useState([]),[U,V]=j.useState(!1),[R,C]=j.useState("manual"),[N,K]=j.useState(""),[X,te]=j.useState(!1),[pe,oe]=j.useState(!1),[Ge,Q]=j.useState({}),[Se,Me]=j.useState({}),[Qe,ft]=j.useState({});j.useEffect(()=>{a||V(!0)},[a]),j.useEffect(()=>{!a&&i&&(y!=null&&y.data)&&y.data.some(re=>re.id.toString()===i)&&d("customerId",i)},[a,i,y,d]),j.useEffect(()=>{U&&E!==null&&F!==E&&d("tariffId",""),S(F)},[F,E,d,U]),j.useEffect(()=>{if(!a&&(k!=null&&k.data)&&k.data.length>0){const I=u("type"),re=k.data.filter(ce=>ce.isActive),ve=re.some(ce=>ce.code===I);if(!I||!ve){const ce=re.sort((ge,st)=>ge.sortOrder-st.sortOrder)[0];ce&&d("type",ce.code)}}},[k,a,d,u]),j.useEffect(()=>{var I,re,ve,ce,ge,st,Ce,Za,Gm,Zm,Jm,Xm,Ym,eh,th,sh,nh,rh,ah,ih,lh,oh,ch,uh,dh,mh,hh,fh,ph,xh,gh,yh,vh,jh,bh,Nh,wh,Sh,kh,Ch,Eh,Dh,Ph,Ah,Mh,Th,Fh,Ih,Lh;if(f!=null&&f.data&&(v!=null&&v.data)&&(k!=null&&k.data)){const se=f.data;c({customerId:se.customerId.toString(),type:se.type,status:se.status,addressId:((I=se.addressId)==null?void 0:I.toString())||"",bankCardId:((re=se.bankCardId)==null?void 0:re.toString())||"",identityDocumentId:((ve=se.identityDocumentId)==null?void 0:ve.toString())||"",salesPlatformId:((ce=se.salesPlatformId)==null?void 0:ce.toString())||"",providerId:((ge=se.providerId)==null?void 0:ge.toString())||"",tariffId:((st=se.tariffId)==null?void 0:st.toString())||"",providerName:se.providerName||"",tariffName:se.tariffName||"",customerNumberAtProvider:se.customerNumberAtProvider||"",priceFirst12Months:se.priceFirst12Months||"",priceFrom13Months:se.priceFrom13Months||"",priceAfter24Months:se.priceAfter24Months||"",startDate:se.startDate?se.startDate.split("T")[0]:"",endDate:se.endDate?se.endDate.split("T")[0]:"",cancellationPeriodId:((Ce=se.cancellationPeriodId)==null?void 0:Ce.toString())||"",contractDurationId:((Za=se.contractDurationId)==null?void 0:Za.toString())||"",commission:se.commission||"",portalUsername:se.portalUsername||"",notes:se.notes||"",meterId:((Zm=(Gm=se.energyDetails)==null?void 0:Gm.meterId)==null?void 0:Zm.toString())||"",annualConsumption:((Jm=se.energyDetails)==null?void 0:Jm.annualConsumption)||"",basePrice:((Xm=se.energyDetails)==null?void 0:Xm.basePrice)||"",unitPrice:((Ym=se.energyDetails)==null?void 0:Ym.unitPrice)||"",bonus:((eh=se.energyDetails)==null?void 0:eh.bonus)||"",previousProviderName:((th=se.energyDetails)==null?void 0:th.previousProviderName)||"",previousCustomerNumber:((sh=se.energyDetails)==null?void 0:sh.previousCustomerNumber)||"",downloadSpeed:((nh=se.internetDetails)==null?void 0:nh.downloadSpeed)||"",uploadSpeed:((rh=se.internetDetails)==null?void 0:rh.uploadSpeed)||"",routerModel:((ah=se.internetDetails)==null?void 0:ah.routerModel)||"",routerSerialNumber:((ih=se.internetDetails)==null?void 0:ih.routerSerialNumber)||"",installationDate:(lh=se.internetDetails)!=null&&lh.installationDate?se.internetDetails.installationDate.split("T")[0]:"",internetUsername:((oh=se.internetDetails)==null?void 0:oh.internetUsername)||"",homeId:((ch=se.internetDetails)==null?void 0:ch.homeId)||"",activationCode:((uh=se.internetDetails)==null?void 0:uh.activationCode)||"",requiresMultisim:((dh=se.mobileDetails)==null?void 0:dh.requiresMultisim)||!1,dataVolume:((mh=se.mobileDetails)==null?void 0:mh.dataVolume)||"",includedMinutes:((hh=se.mobileDetails)==null?void 0:hh.includedMinutes)||"",includedSMS:((fh=se.mobileDetails)==null?void 0:fh.includedSMS)||"",deviceModel:((ph=se.mobileDetails)==null?void 0:ph.deviceModel)||"",deviceImei:((xh=se.mobileDetails)==null?void 0:xh.deviceImei)||"",phoneNumber:((gh=se.mobileDetails)==null?void 0:gh.phoneNumber)||"",simCardNumber:((yh=se.mobileDetails)==null?void 0:yh.simCardNumber)||"",receiverModel:((vh=se.tvDetails)==null?void 0:vh.receiverModel)||"",smartcardNumber:((jh=se.tvDetails)==null?void 0:jh.smartcardNumber)||"",tvPackage:((bh=se.tvDetails)==null?void 0:bh.package)||"",licensePlate:((Nh=se.carInsuranceDetails)==null?void 0:Nh.licensePlate)||"",hsn:((wh=se.carInsuranceDetails)==null?void 0:wh.hsn)||"",tsn:((Sh=se.carInsuranceDetails)==null?void 0:Sh.tsn)||"",vin:((kh=se.carInsuranceDetails)==null?void 0:kh.vin)||"",vehicleType:((Ch=se.carInsuranceDetails)==null?void 0:Ch.vehicleType)||"",firstRegistration:(Eh=se.carInsuranceDetails)!=null&&Eh.firstRegistration?se.carInsuranceDetails.firstRegistration.split("T")[0]:"",noClaimsClass:((Dh=se.carInsuranceDetails)==null?void 0:Dh.noClaimsClass)||"",insuranceType:((Ph=se.carInsuranceDetails)==null?void 0:Ph.insuranceType)||"LIABILITY",deductiblePartial:((Ah=se.carInsuranceDetails)==null?void 0:Ah.deductiblePartial)||"",deductibleFull:((Mh=se.carInsuranceDetails)==null?void 0:Mh.deductibleFull)||"",policyNumber:((Th=se.carInsuranceDetails)==null?void 0:Th.policyNumber)||"",previousInsurer:((Fh=se.carInsuranceDetails)==null?void 0:Fh.previousInsurer)||"",cancellationConfirmationDate:se.cancellationConfirmationDate?se.cancellationConfirmationDate.split("T")[0]:"",cancellationConfirmationOptionsDate:se.cancellationConfirmationOptionsDate?se.cancellationConfirmationOptionsDate.split("T")[0]:"",wasSpecialCancellation:se.wasSpecialCancellation||!1}),(Ih=se.mobileDetails)!=null&&Ih.simCards&&se.mobileDetails.simCards.length>0?P(se.mobileDetails.simCards.map(Wt=>({id:Wt.id,phoneNumber:Wt.phoneNumber||"",simCardNumber:Wt.simCardNumber||"",pin:"",puk:"",hasExistingPin:!!Wt.pin,hasExistingPuk:!!Wt.puk,isMultisim:Wt.isMultisim,isMain:Wt.isMain}))):P([]),(Lh=se.internetDetails)!=null&&Lh.phoneNumbers&&se.internetDetails.phoneNumbers.length>0?L(se.internetDetails.phoneNumbers.map(Wt=>({id:Wt.id,phoneNumber:Wt.phoneNumber||"",sipUsername:Wt.sipUsername||"",sipPassword:"",hasExistingSipPassword:!!Wt.sipPasswordEncrypted,sipServer:Wt.sipServer||"",isMain:Wt.isMain}))):L([]),se.stressfreiEmailId?(C("stressfrei"),K(se.stressfreiEmailId.toString())):(C("manual"),K("")),V(!0)}},[f,c,v,k]);const jt=u("startDate"),W=u("contractDurationId");j.useEffect(()=>{if(jt&&W&&(x!=null&&x.data)){const I=x.data.find(re=>re.id===parseInt(W));if(I){const re=new Date(jt),ce=I.code.match(/^(\d+)([MTJ])$/);if(ce){const ge=parseInt(ce[1]),st=ce[2];let Ce=new Date(re);st==="T"?Ce.setDate(Ce.getDate()+ge):st==="M"?Ce.setMonth(Ce.getMonth()+ge):st==="J"&&Ce.setFullYear(Ce.getFullYear()+ge),d("endDate",Ce.toISOString().split("T")[0])}}}},[jt,W,x,d]);const $e=H({mutationFn:qe.create,onSuccess:(I,re)=>{r.invalidateQueries({queryKey:["contracts"]}),re.customerId&&r.invalidateQueries({queryKey:["customer",re.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),n(i?`/customers/${i}?tab=contracts`:"/contracts")}}),Dt=H({mutationFn:I=>qe.update(parseInt(e),I),onSuccess:(I,re)=>{r.invalidateQueries({queryKey:["contracts"]}),r.invalidateQueries({queryKey:["contract",e]}),re.customerId&&r.invalidateQueries({queryKey:["customer",re.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),n(`/contracts/${e}`)}}),Cn=I=>{const re=Ce=>{if(Ce==null||Ce==="")return;const Za=parseInt(String(Ce));return isNaN(Za)?void 0:Za},ve=J.find(Ce=>Ce.code===I.type),ce=re(I.customerId);if(!ce){alert("Bitte wählen Sie einen Kunden aus");return}if(!I.type||!ve){alert("Bitte wählen Sie einen Vertragstyp aus");return}const ge=Ce=>Ce==null||Ce===""?null:Ce,st={customerId:ce,type:I.type,contractCategoryId:ve.id,status:I.status,addressId:re(I.addressId)??null,bankCardId:re(I.bankCardId)??null,identityDocumentId:re(I.identityDocumentId)??null,salesPlatformId:re(I.salesPlatformId)??null,providerId:re(I.providerId)??null,tariffId:re(I.tariffId)??null,providerName:ge(I.providerName),tariffName:ge(I.tariffName),customerNumberAtProvider:ge(I.customerNumberAtProvider),priceFirst12Months:ge(I.priceFirst12Months),priceFrom13Months:ge(I.priceFrom13Months),priceAfter24Months:ge(I.priceAfter24Months),startDate:I.startDate?new Date(I.startDate):null,endDate:I.endDate?new Date(I.endDate):null,cancellationPeriodId:re(I.cancellationPeriodId)??null,contractDurationId:re(I.contractDurationId)??null,commission:I.commission?parseFloat(I.commission):null,portalUsername:R==="manual"?ge(I.portalUsername):null,stressfreiEmailId:R==="stressfrei"&&N?parseInt(N):null,portalPassword:I.portalPassword||void 0,notes:ge(I.notes),cancellationConfirmationDate:I.cancellationConfirmationDate?new Date(I.cancellationConfirmationDate):null,cancellationConfirmationOptionsDate:I.cancellationConfirmationOptionsDate?new Date(I.cancellationConfirmationOptionsDate):null,wasSpecialCancellation:I.wasSpecialCancellation||!1};["ELECTRICITY","GAS"].includes(I.type)&&(st.energyDetails={meterId:re(I.meterId)??null,annualConsumption:I.annualConsumption?parseFloat(I.annualConsumption):null,basePrice:I.basePrice?parseFloat(I.basePrice):null,unitPrice:I.unitPrice?parseFloat(I.unitPrice):null,bonus:I.bonus?parseFloat(I.bonus):null,previousProviderName:ge(I.previousProviderName),previousCustomerNumber:ge(I.previousCustomerNumber)}),["DSL","CABLE","FIBER"].includes(I.type)&&(st.internetDetails={downloadSpeed:re(I.downloadSpeed)??null,uploadSpeed:re(I.uploadSpeed)??null,routerModel:ge(I.routerModel),routerSerialNumber:ge(I.routerSerialNumber),installationDate:I.installationDate?new Date(I.installationDate):null,internetUsername:ge(I.internetUsername),internetPassword:I.internetPassword||void 0,homeId:ge(I.homeId),activationCode:ge(I.activationCode),phoneNumbers:z.length>0?z.map(Ce=>({id:Ce.id,phoneNumber:Ce.phoneNumber||"",isMain:Ce.isMain??!1,sipUsername:ge(Ce.sipUsername),sipPassword:Ce.sipPassword||void 0,sipServer:ge(Ce.sipServer)})):void 0}),I.type==="MOBILE"&&(st.mobileDetails={requiresMultisim:I.requiresMultisim||!1,dataVolume:I.dataVolume?parseFloat(I.dataVolume):null,includedMinutes:re(I.includedMinutes)??null,includedSMS:re(I.includedSMS)??null,deviceModel:ge(I.deviceModel),deviceImei:ge(I.deviceImei),phoneNumber:ge(I.phoneNumber),simCardNumber:ge(I.simCardNumber),simCards:M.length>0?M.map(Ce=>({id:Ce.id,phoneNumber:ge(Ce.phoneNumber),simCardNumber:ge(Ce.simCardNumber),pin:Ce.pin||void 0,puk:Ce.puk||void 0,isMultisim:Ce.isMultisim,isMain:Ce.isMain})):void 0}),I.type==="TV"&&(st.tvDetails={receiverModel:ge(I.receiverModel),smartcardNumber:ge(I.smartcardNumber),package:ge(I.tvPackage)}),I.type==="CAR_INSURANCE"&&(st.carInsuranceDetails={licensePlate:ge(I.licensePlate),hsn:ge(I.hsn),tsn:ge(I.tsn),vin:ge(I.vin),vehicleType:ge(I.vehicleType),firstRegistration:I.firstRegistration?new Date(I.firstRegistration):null,noClaimsClass:ge(I.noClaimsClass),insuranceType:I.insuranceType,deductiblePartial:I.deductiblePartial?parseFloat(I.deductiblePartial):null,deductibleFull:I.deductibleFull?parseFloat(I.deductibleFull):null,policyNumber:ge(I.policyNumber),previousInsurer:ge(I.previousInsurer)}),a?Dt.mutate(st):$e.mutate(st)},fs=$e.isPending||Dt.isPending,En=$e.error||Dt.error,G=w==null?void 0:w.data,ke=(G==null?void 0:G.addresses)||[],Ha=((Ss=G==null?void 0:G.bankCards)==null?void 0:Ss.filter(I=>I.isActive))||[],jc=((xl=G==null?void 0:G.identityDocuments)==null?void 0:xl.filter(I=>I.isActive))||[],pl=((Vr=G==null?void 0:G.meters)==null?void 0:Vr.filter(I=>I.isActive))||[],A=((Qr=G==null?void 0:G.stressfreiEmails)==null?void 0:Qr.filter(I=>I.isActive))||[],$=(v==null?void 0:v.data)||[],B=(g==null?void 0:g.data)||[],ie=(x==null?void 0:x.data)||[],ee=((gl=b==null?void 0:b.data)==null?void 0:gl.filter(I=>I.isActive))||[],J=((Wa=k==null?void 0:k.data)==null?void 0:Wa.filter(I=>I.isActive).sort((I,re)=>I.sortOrder-re.sortOrder))||[],he=J.map(I=>({value:I.code,label:I.name})),De=ee.find(I=>I.id===parseInt(F||"0")),Fe=((yl=De==null?void 0:De.tariffs)==null?void 0:yl.filter(I=>I.isActive))||[],bt=I=>{const re=I.companyName||`${I.firstName} ${I.lastName}`,ve=I.birthDate?` (geb. ${new Date(I.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})`:"";return`${I.customerNumber} - ${re}${ve}`},Ys=(()=>{var ve;const re=((y==null?void 0:y.data)||[]).map(ce=>({value:ce.id.toString(),label:bt(ce)}));if(a&&((ve=f==null?void 0:f.data)!=null&&ve.customer)){const ce=f.data.customer;re.some(st=>st.value===ce.id.toString())||re.unshift({value:ce.id.toString(),label:bt(ce)})}return re})();return s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:a?"Vertrag bearbeiten":"Neuer Vertrag"}),En&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:En instanceof Error?En.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:o(Cn),children:[s.jsx(Y,{className:"mb-6",title:"Vertragsdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Oe,{label:"Kunde *",...l("customerId",{required:"Kunde erforderlich"}),options:Ys,error:(Ga=h.customerId)==null?void 0:Ga.message}),s.jsx(Oe,{label:"Vertragstyp *",...l("type",{required:"Typ erforderlich"}),options:he}),s.jsx(Oe,{label:"Status",...l("status"),options:xk}),s.jsx(Oe,{label:"Vertriebsplattform",...l("salesPlatformId"),options:$.map(I=>({value:I.id,label:I.name}))})]})}),m&&s.jsx(Y,{className:"mb-6",title:"Kundendaten verknüpfen",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Oe,{label:"Adresse",...l("addressId"),options:ke.map(I=>({value:I.id,label:`${I.street} ${I.houseNumber}, ${I.postalCode} ${I.city} (${I.type==="BILLING"?"Rechnung":"Liefer"})`}))}),s.jsx(Oe,{label:"Bankkarte",...l("bankCardId"),options:Ha.map(I=>({value:I.id,label:`${I.iban} (${I.accountHolder})`}))}),s.jsx(Oe,{label:"Ausweis",...l("identityDocumentId"),options:jc.map(I=>({value:I.id,label:`${I.documentNumber} (${I.type})`}))})]})}),s.jsx(Y,{className:"mb-6",title:"Anbieter & Tarif",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Oe,{label:"Anbieter",...l("providerId"),options:ee.map(I=>({value:I.id,label:I.name}))}),s.jsx(Oe,{label:"Tarif",...l("tariffId"),options:Fe.map(I=>({value:I.id,label:I.name})),disabled:!F}),s.jsx(q,{label:"Kundennummer beim Anbieter",...l("customerNumberAtProvider")}),s.jsx(q,{label:"Provision (€)",type:"number",step:"0.01",...l("commission")}),s.jsx(q,{label:"Preis erste 12 Monate",...l("priceFirst12Months"),placeholder:"z.B. 29,99 €/Monat"}),s.jsx(q,{label:"Preis ab 13. Monat",...l("priceFrom13Months"),placeholder:"z.B. 39,99 €/Monat"}),s.jsx(q,{label:"Preis nach 24 Monaten",...l("priceAfter24Months"),placeholder:"z.B. 49,99 €/Monat"})]})}),s.jsxs(Y,{className:"mb-6",title:"Laufzeit und Kündigung",children:[s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.jsx("strong",{children:"Hinweis:"})," Ist die Laufzeit ≤ 4 Wochen, 1 Monat oder 30 Tage, gilt der Vertrag als unbefristet mit der jeweiligen Kündigungsfrist."]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Vertragsbeginn",type:"date",...l("startDate"),value:u("startDate")||"",onClear:()=>d("startDate","")}),s.jsx(q,{label:"Vertragsende (berechnet)",type:"date",...l("endDate"),disabled:!0,className:"bg-gray-50"}),s.jsx(Oe,{label:"Vertragslaufzeit",...l("contractDurationId"),options:ie.map(I=>({value:I.id,label:I.description}))}),s.jsx(Oe,{label:"Kündigungsfrist",...l("cancellationPeriodId"),options:B.map(I=>({value:I.id,label:I.description}))}),s.jsx(q,{label:"Kündigungsbestätigungsdatum",type:"date",...l("cancellationConfirmationDate"),value:u("cancellationConfirmationDate")||"",onClear:()=>d("cancellationConfirmationDate","")}),s.jsx(q,{label:"Kündigungsbestätigungsoptionendatum",type:"date",...l("cancellationConfirmationOptionsDate"),value:u("cancellationConfirmationOptionsDate")||"",onClear:()=>d("cancellationConfirmationOptionsDate","")}),s.jsx("div",{className:"col-span-2",children:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",...l("wasSpecialCancellation"),className:"rounded border-gray-300"}),s.jsx("span",{children:"Wurde sondergekündigt?"})]})})]})]}),s.jsx(Y,{className:"mb-6",title:"Zugangsdaten (verschlüsselt gespeichert)",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Portal Benutzername"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"usernameType",checked:R==="manual",onChange:()=>{C("manual"),K("")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Manuell eingeben"})]}),R==="manual"&&s.jsx(q,{...l("portalUsername"),placeholder:"Benutzername eingeben..."}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"usernameType",checked:R==="stressfrei",onChange:()=>{C("stressfrei"),d("portalUsername","")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Stressfrei-Wechseln Adresse"})]}),R==="stressfrei"&&s.jsx(Oe,{value:N,onChange:I=>K(I.target.value),options:A.map(I=>({value:I.id,label:I.email+(I.notes?` (${I.notes})`:"")})),placeholder:A.length===0?"Keine Stressfrei-Adressen vorhanden":"Adresse auswählen..."}),R==="stressfrei"&&A.length===0&&s.jsx("p",{className:"text-xs text-amber-600",children:"Keine Stressfrei-Wechseln Adressen für diesen Kunden vorhanden. Bitte zuerst beim Kunden anlegen."})]})]}),s.jsxs("div",{className:"mt-8",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer lassen = unverändert)":"Portal Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:X?"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"}),s.jsx("button",{type:"button",onClick:()=>te(!X),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:X?s.jsx(Mt,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})}),["ELECTRICITY","GAS"].includes(p)&&s.jsx(Y,{className:"mb-6",title:p==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Oe,{label:"Zähler",...l("meterId"),options:pl.filter(I=>I.type===p).map(I=>({value:I.id,label:`${I.meterNumber}${I.location?` (${I.location})`:""}`}))}),s.jsx(q,{label:`Jahresverbrauch (${p==="ELECTRICITY"?"kWh":"m³"})`,type:"number",...l("annualConsumption")}),s.jsx(q,{label:"Grundpreis (€/Monat)",type:"number",step:"0.01",...l("basePrice")}),s.jsx(q,{label:`Arbeitspreis (ct/${p==="ELECTRICITY"?"kWh":"m³"})`,type:"number",step:"0.01",...l("unitPrice")}),s.jsx(q,{label:"Bonus (€)",type:"number",step:"0.01",...l("bonus")}),s.jsx(q,{label:"Vorversorger",...l("previousProviderName")}),s.jsx(q,{label:"Kundennr. beim Vorversorger",...l("previousCustomerNumber")})]})}),["DSL","CABLE","FIBER"].includes(p)&&s.jsxs(s.Fragment,{children:[s.jsx(Y,{className:"mb-6",title:p==="DSL"?"DSL-Details":p==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Download (Mbit/s)",type:"number",...l("downloadSpeed")}),s.jsx(q,{label:"Upload (Mbit/s)",type:"number",...l("uploadSpeed")}),s.jsx(q,{label:"Router Modell",...l("routerModel")}),s.jsx(q,{label:"Router Seriennummer",...l("routerSerialNumber")}),s.jsx(q,{label:"Installationsdatum",type:"date",...l("installationDate"),value:u("installationDate")||"",onClear:()=>d("installationDate","")}),p==="FIBER"&&s.jsx(q,{label:"Home-ID",...l("homeId")}),((Wm=De==null?void 0:De.name)==null?void 0:Wm.toLowerCase().includes("vodafone"))&&["DSL","CABLE"].includes(p)&&s.jsx(q,{label:"Aktivierungscode",...l("activationCode")})]})}),s.jsx(Y,{className:"mb-6",title:"Internet-Zugangsdaten (verschlüsselt)",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Benutzername",...l("internetUsername")}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer = beibehalten)":"Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:pe?"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"}),s.jsx("button",{type:"button",onClick:()=>oe(!pe),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:pe?s.jsx(Mt,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})}),s.jsxs(Y,{className:"mb-6",title:"Rufnummern & SIP-Zugangsdaten",children:[s.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie Festnetz-Rufnummern mit SIP-Zugangsdaten erfassen."}),z.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:z.map((I,re)=>s.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("span",{className:"font-medium",children:["Rufnummer ",re+1]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:I.isMain,onChange:ve=>{const ce=[...z];ve.target.checked?ce.forEach((ge,st)=>ge.isMain=st===re):ce[re].isMain=!1,L(ce)},className:"rounded border-gray-300"}),"Hauptnummer"]})]}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{L(z.filter((ve,ce)=>ce!==re))},children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[s.jsx(q,{label:"Rufnummer",value:I.phoneNumber,onChange:ve=>{const ce=[...z];ce[re].phoneNumber=ve.target.value,L(ce)},placeholder:"z.B. 030 123456"}),s.jsx(q,{label:"SIP-Benutzername",value:I.sipUsername,onChange:ve=>{const ce=[...z];ce[re].sipUsername=ve.target.value,L(ce)}}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:I.hasExistingSipPassword?"SIP-Passwort (bereits hinterlegt)":"SIP-Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Ge[re]?"text":"password",value:I.sipPassword,onChange:ve=>{const ce=[...z];ce[re].sipPassword=ve.target.value,L(ce)},placeholder:I.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"}),s.jsx("button",{type:"button",onClick:()=>Q(ve=>({...ve,[re]:!ve[re]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Ge[re]?s.jsx(Mt,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]}),s.jsx(q,{label:"SIP-Server",value:I.sipServer,onChange:ve=>{const ce=[...z];ce[re].sipServer=ve.target.value,L(ce)},placeholder:"z.B. sip.provider.de"})]})]},re))}),s.jsxs(T,{type:"button",variant:"secondary",onClick:()=>{L([...z,{phoneNumber:"",sipUsername:"",sipPassword:"",sipServer:"",isMain:z.length===0}])},children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Rufnummer hinzufügen"]})]})]}),p==="MOBILE"&&s.jsxs(s.Fragment,{children:[s.jsxs(Y,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Datenvolumen (GB)",type:"number",...l("dataVolume")}),s.jsx(q,{label:"Inklusiv-Minuten",type:"number",...l("includedMinutes")}),s.jsx(q,{label:"Inklusiv-SMS",type:"number",...l("includedSMS")}),s.jsx(q,{label:"Gerät (Modell)",...l("deviceModel")}),s.jsx(q,{label:"Gerät (IMEI)",...l("deviceImei")})]}),s.jsx("div",{className:"mt-4 pt-4 border-t",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",...l("requiresMultisim"),className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium",children:"Multisim erforderlich"}),s.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."})]})]})})]}),s.jsxs(Y,{className:"mb-6",title:"SIM-Karten",children:[s.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)."}),M.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:M.map((I,re)=>s.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("span",{className:"font-medium",children:["SIM-Karte ",re+1]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:I.isMain,onChange:ve=>{const ce=[...M];ve.target.checked?ce.forEach((ge,st)=>ge.isMain=st===re):ce[re].isMain=!1,P(ce)},className:"rounded border-gray-300"}),"Hauptkarte"]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:I.isMultisim,onChange:ve=>{const ce=[...M];ce[re].isMultisim=ve.target.checked,P(ce)},className:"rounded border-gray-300"}),"Multisim"]})]}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{P(M.filter((ve,ce)=>ce!==re))},children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[s.jsx(q,{label:"Rufnummer",value:I.phoneNumber,onChange:ve=>{const ce=[...M];ce[re].phoneNumber=ve.target.value,P(ce)},placeholder:"z.B. 0171 1234567"}),s.jsx(q,{label:"SIM-Kartennummer",value:I.simCardNumber,onChange:ve=>{const ce=[...M];ce[re].simCardNumber=ve.target.value,P(ce)},placeholder:"ICCID"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:I.hasExistingPin?"PIN (bereits hinterlegt)":"PIN"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Se[re]?"text":"password",value:I.pin,onChange:ve=>{const ce=[...M];ce[re].pin=ve.target.value,P(ce)},placeholder:I.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"}),s.jsx("button",{type:"button",onClick:()=>Me(ve=>({...ve,[re]:!ve[re]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Se[re]?s.jsx(Mt,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:I.hasExistingPuk?"PUK (bereits hinterlegt)":"PUK"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Qe[re]?"text":"password",value:I.puk,onChange:ve=>{const ce=[...M];ce[re].puk=ve.target.value,P(ce)},placeholder:I.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"}),s.jsx("button",{type:"button",onClick:()=>ft(ve=>({...ve,[re]:!ve[re]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Qe[re]?s.jsx(Mt,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})]},re))}),s.jsxs(T,{type:"button",variant:"secondary",onClick:()=>{P([...M,{phoneNumber:"",simCardNumber:"",pin:"",puk:"",isMultisim:!1,isMain:M.length===0}])},children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"SIM-Karte hinzufügen"]})]})]}),p==="TV"&&s.jsx(Y,{className:"mb-6",title:"TV-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(q,{label:"Receiver Modell",...l("receiverModel")}),s.jsx(q,{label:"Smartcard-Nummer",...l("smartcardNumber")}),s.jsx(q,{label:"Paket",...l("tvPackage"),placeholder:"z.B. Basis, Premium, Sport"})]})}),p==="CAR_INSURANCE"&&s.jsx(Y,{className:"mb-6",title:"KFZ-Versicherung Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(q,{label:"Kennzeichen",...l("licensePlate")}),s.jsx(q,{label:"HSN",...l("hsn")}),s.jsx(q,{label:"TSN",...l("tsn")}),s.jsx(q,{label:"FIN (VIN)",...l("vin")}),s.jsx(q,{label:"Fahrzeugtyp",...l("vehicleType")}),s.jsx(q,{label:"Erstzulassung",type:"date",...l("firstRegistration"),value:u("firstRegistration")||"",onClear:()=>d("firstRegistration","")}),s.jsx(q,{label:"SF-Klasse",...l("noClaimsClass")}),s.jsx(Oe,{label:"Versicherungsart",...l("insuranceType"),options:[{value:"LIABILITY",label:"Haftpflicht"},{value:"PARTIAL",label:"Teilkasko"},{value:"FULL",label:"Vollkasko"}]}),s.jsx(q,{label:"SB Teilkasko (€)",type:"number",...l("deductiblePartial")}),s.jsx(q,{label:"SB Vollkasko (€)",type:"number",...l("deductibleFull")}),s.jsx(q,{label:"Versicherungsscheinnummer",...l("policyNumber")}),s.jsx(q,{label:"Vorversicherer",...l("previousInsurer")})]})}),s.jsx(Y,{className:"mb-6",title:"Notizen",children:s.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..."})}),s.jsxs("div",{className:"flex justify-end gap-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:()=>n(-1),children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:fs,children:fs?"Speichern...":"Speichern"})]})]})]})}const gk={ELECTRICITY:Um,GAS:L0,DSL:xa,CABLE:xa,FIBER:xa,MOBILE:$m,TV:$0,CAR_INSURANCE:F0},yk={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabel",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ"},vk={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"},jk={critical:"danger",warning:"warning",ok:"success",none:"default"},bk={cancellation_deadline:T0,contract_ending:bn,missing_cancellation_letter:lt,missing_cancellation_confirmation:lt,missing_portal_credentials:GS,missing_customer_number:lt,missing_provider:lt,missing_address:lt,missing_bank:lt,missing_meter:Um,missing_sim:$m,open_tasks:Gi,pending_status:bn,draft_status:lt},Nk={cancellationDeadlines:"Kündigungsfristen",contractEnding:"Vertragsenden",missingCredentials:"Fehlende Zugangsdaten",missingData:"Fehlende Daten",openTasks:"Offene Aufgaben",pendingContracts:"Wartende Verträge"};function wk(){var y;const[e,t]=lc(),[n,r]=j.useState(new Set),a=e.get("filter"),[i,l]=j.useState(a||"all");j.useEffect(()=>{i==="all"?e.delete("filter"):e.set("filter",i),t(e,{replace:!0})},[i,e,t]);const{data:o,isLoading:c,error:u}=me({queryKey:["contract-cockpit"],queryFn:()=>qe.getCockpit(),staleTime:0}),d=w=>{r(v=>{const g=new Set(v);return g.has(w)?g.delete(w):g.add(w),g})},h=j.useMemo(()=>{var v;if(!((v=o==null?void 0:o.data)!=null&&v.contracts))return[];const w=o.data.contracts;switch(i){case"critical":return w.filter(g=>g.highestUrgency==="critical");case"warning":return w.filter(g=>g.highestUrgency==="warning");case"ok":return w.filter(g=>g.highestUrgency==="ok");case"deadlines":return w.filter(g=>g.issues.some(x=>["cancellation_deadline","contract_ending"].includes(x.type)));case"credentials":return w.filter(g=>g.issues.some(x=>x.type.includes("credentials")));case"data":return w.filter(g=>g.issues.some(x=>x.type.startsWith("missing_")&&!x.type.includes("credentials")));case"tasks":return w.filter(g=>g.issues.some(x=>["open_tasks","pending_status","draft_status"].includes(x.type)));default:return w}},[(y=o==null?void 0:o.data)==null?void 0:y.contracts,i]);if(c)return s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})});if(u||!(o!=null&&o.data))return s.jsx("div",{className:"text-center py-12",children:s.jsx("p",{className:"text-red-500",children:"Fehler beim Laden des Cockpits"})});const{summary:p,thresholds:m}=o.data,f=w=>{var x,b,k,F;const v=n.has(w.id),g=gk[w.type]||lt;return s.jsxs("div",{className:`border rounded-lg mb-2 ${vk[w.highestUrgency]}`,children:[s.jsxs("div",{className:"flex items-center p-4 cursor-pointer hover:bg-opacity-50",onClick:()=>d(w.id),children:[s.jsx("div",{className:"w-6 mr-2",children:v?s.jsx(pc,{className:"w-5 h-5"}):s.jsx(ls,{className:"w-5 h-5"})}),s.jsx(g,{className:"w-5 h-5 mr-3"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(we,{to:`/contracts/${w.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"font-medium hover:underline",onClick:E=>E.stopPropagation(),children:w.contractNumber}),s.jsxs(ye,{variant:jk[w.highestUrgency],children:[w.issues.length," ",w.highestUrgency==="ok"?w.issues.length===1?"Hinweis":"Hinweise":w.issues.length===1?"Problem":"Probleme"]}),s.jsx("span",{className:"text-sm",children:yk[w.type]})]}),s.jsxs("div",{className:"text-sm mt-1",children:[s.jsxs(we,{to:`/customers/${w.customer.id}`,className:"hover:underline",onClick:E=>E.stopPropagation(),children:[w.customer.customerNumber," - ",w.customer.name]}),(((x=w.provider)==null?void 0:x.name)||w.providerName)&&s.jsxs("span",{className:"ml-2",children:["| ",((b=w.provider)==null?void 0:b.name)||w.providerName,(((k=w.tariff)==null?void 0:k.name)||w.tariffName)&&` - ${((F=w.tariff)==null?void 0:F.name)||w.tariffName}`]})]})]}),s.jsx(we,{to:`/contracts/${w.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"ml-4 p-2 hover:bg-white hover:bg-opacity-50 rounded",onClick:E=>E.stopPropagation(),title:"Zum Vertrag",children:s.jsx(Ae,{className:"w-4 h-4"})})]}),v&&s.jsx("div",{className:"border-t px-4 py-3 bg-white bg-opacity-50",children:s.jsx("div",{className:"space-y-2",children:w.issues.map((E,S)=>{const M=bk[E.type]||hn,P=E.urgency==="critical"?hn:E.urgency==="warning"?ir:E.urgency==="ok"?js:bn;return s.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[s.jsx(P,{className:`w-4 h-4 mt-0.5 flex-shrink-0 ${E.urgency==="critical"?"text-red-500":E.urgency==="warning"?"text-yellow-500":E.urgency==="ok"?"text-green-500":"text-gray-500"}`}),s.jsx(M,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-gray-500"}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium",children:E.label}),E.details&&s.jsx("span",{className:"text-gray-600 ml-2",children:E.details})]})]},S)})})})]},w.id)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(hn,{className:"w-6 h-6 text-red-500"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Vertrags-Cockpit"})]}),s.jsx(we,{to:"/settings/deadlines",className:"text-sm text-blue-600 hover:underline",children:"Fristenschwellen anpassen"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[s.jsx(Y,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(hn,{className:"w-6 h-6 text-red-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-red-600",children:p.criticalCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",m.criticalDays," Tage)"]})]})]})}),s.jsx(Y,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-yellow-100 rounded-lg",children:s.jsx(ir,{className:"w-6 h-6 text-yellow-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:p.warningCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",m.warningDays," Tage)"]})]})]})}),s.jsx(Y,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-green-100 rounded-lg",children:s.jsx(js,{className:"w-6 h-6 text-green-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-green-600",children:p.okCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",m.okDays," Tage)"]})]})]})}),s.jsx(Y,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-gray-100 rounded-lg",children:s.jsx(lt,{className:"w-6 h-6 text-gray-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-gray-600",children:p.totalContracts}),s.jsx("p",{className:"text-sm text-gray-500",children:"Verträge mit Handlungsbedarf"})]})]})})]}),s.jsx(Y,{className:"mb-6",children:s.jsx("div",{className:"flex flex-wrap gap-4",children:Object.entries(p.byCategory).map(([w,v])=>v>0&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("span",{className:"font-medium",children:[Nk[w]||w,":"]}),s.jsx(ye,{variant:"default",children:v})]},w))})}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Filter:"}),s.jsx(Oe,{value:i,onChange:w=>l(w.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"}),s.jsxs("span",{className:"text-sm text-gray-500",children:[h.length," Verträge angezeigt"]})]})}),h.length===0?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:i==="all"?s.jsxs(s.Fragment,{children:[s.jsx(js,{className:"w-12 h-12 mx-auto mb-4 text-green-500"}),s.jsx("p",{className:"text-lg font-medium",children:"Alles in Ordnung!"}),s.jsx("p",{children:"Keine Verträge mit Handlungsbedarf gefunden."})]}):s.jsx("p",{children:"Keine Verträge für diesen Filter gefunden."})})}):s.jsx("div",{children:h.map(f)})]})}const nx={OPEN:"Offen",COMPLETED:"Erledigt"},Sk={OPEN:"warning",COMPLETED:"success"};function kk(){var V;const e=Ht(),t=xe(),{isCustomerPortal:n,user:r,hasPermission:a}=Ue(),[i,l]=j.useState("OPEN"),[o,c]=j.useState(new Set),[u,d]=j.useState(!1),[h,p]=j.useState({}),m=n?"Support-Anfragen":"Aufgaben",f=n?"Anfrage":"Aufgabe",{data:y,isLoading:w}=me({queryKey:["app-settings-public"],queryFn:()=>Ur.getPublic(),enabled:n,staleTime:0}),v=!w&&((V=y==null?void 0:y.data)==null?void 0:V.customerSupportTicketsEnabled)==="true",{data:g,isLoading:x}=me({queryKey:["all-tasks",i],queryFn:()=>it.getAll({status:i||void 0}),staleTime:0}),b=H({mutationFn:R=>it.completeSubtask(R),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),k=H({mutationFn:R=>it.reopenSubtask(R),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),F=H({mutationFn:({taskId:R,title:C})=>n?it.createReply(R,C):it.createSubtask(R,C),onSuccess:(R,{taskId:C})=>{t.invalidateQueries({queryKey:["all-tasks"]}),p(N=>({...N,[C]:""}))}}),E=j.useMemo(()=>{var K;if(!(g!=null&&g.data))return{ownTasks:[],representedTasks:[],allTasks:[]};const R=g.data;if(!n)return{allTasks:R,ownTasks:[],representedTasks:[]};const C=[],N=[];for(const X of R)((K=X.contract)==null?void 0:K.customerId)===(r==null?void 0:r.customerId)?C.push(X):N.push(X);return{ownTasks:C,representedTasks:N,allTasks:[]}},[g==null?void 0:g.data,n,r==null?void 0:r.customerId]),S=R=>{c(C=>{const N=new Set(C);return N.has(R)?N.delete(R):N.add(R),N})},M=R=>{b.isPending||k.isPending||(R.status==="COMPLETED"?k.mutate(R.id):b.mutate(R.id))},P=R=>{var N;const C=(N=h[R])==null?void 0:N.trim();C&&F.mutate({taskId:R,title:C})},z=!n&&a("contracts:update"),L=(R,C=!1)=>{var Q,Se,Me,Qe,ft,jt;const N=o.has(R.id),K=R.subtasks&&R.subtasks.length>0,X=((Q=R.subtasks)==null?void 0:Q.filter(W=>W.status==="COMPLETED").length)||0,te=((Se=R.subtasks)==null?void 0:Se.length)||0,pe=R.status==="COMPLETED",oe=R.contract?`${R.contract.contractNumber} - ${((Me=R.contract.provider)==null?void 0:Me.name)||R.contract.providerName||"Kein Anbieter"}`:`Vertrag #${R.contractId}`,Ge=(Qe=R.contract)!=null&&Qe.customer?R.contract.customer.companyName||`${R.contract.customer.firstName} ${R.contract.customer.lastName}`:"";return s.jsxs("div",{className:"border rounded-lg mb-2",children:[s.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50 cursor-pointer",onClick:()=>S(R.id),children:[s.jsx("div",{className:"w-6 mr-2",children:N?s.jsx(pc,{className:"w-5 h-5 text-gray-400"}):s.jsx(ls,{className:"w-5 h-5 text-gray-400"})}),s.jsx("div",{className:"mr-3",children:R.status==="COMPLETED"?s.jsx(js,{className:"w-5 h-5 text-green-500"}):s.jsx(bn,{className:"w-5 h-5 text-yellow-500"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium",children:R.title}),s.jsx(ye,{variant:Sk[R.status],children:nx[R.status]}),K&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",X,"/",te," erledigt)"]})]}),s.jsxs("div",{className:"text-sm text-gray-500 mt-1 flex items-center gap-2",children:[s.jsx(lt,{className:"w-4 h-4"}),s.jsx(we,{to:`/contracts/${R.contractId}`,className:"text-blue-600 hover:underline",onClick:W=>W.stopPropagation(),children:oe}),C&&Ge&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-gray-400",children:"|"}),s.jsx("span",{children:Ge})]})]}),R.description&&s.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:R.description})]}),s.jsx("div",{className:"ml-4 flex gap-2",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:W=>{W.stopPropagation(),e(`/contracts/${R.contractId}`)},title:"Zum Vertrag",children:s.jsx(Ae,{className:"w-4 h-4"})})})]}),N&&s.jsxs("div",{className:"border-t bg-gray-50 px-4 py-3",children:[K&&s.jsx("div",{className:"space-y-2 mb-4",children:(ft=R.subtasks)==null?void 0:ft.map(W=>{const $e=new Date(W.createdAt).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"});return s.jsxs("div",{className:`flex items-start gap-2 text-sm ml-6 ${z?"cursor-pointer hover:bg-gray-100 rounded px-2 py-1 -mx-2":""}`,onClick:z?()=>M(W):void 0,children:[s.jsx("span",{className:"flex-shrink-0 mt-0.5",children:W.status==="COMPLETED"?s.jsx(js,{className:"w-4 h-4 text-green-500"}):s.jsx(ro,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:W.status==="COMPLETED"?"text-gray-500 line-through":"",children:[W.title,s.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[W.createdBy," • ",$e]})]})]},W.id)})}),!pe&&(z||n)&&s.jsxs("div",{className:"flex gap-2 ml-6",children:[s.jsx(q,{placeholder:n?"Antwort schreiben...":"Neue Unteraufgabe...",value:h[R.id]||"",onChange:W=>p($e=>({...$e,[R.id]:W.target.value})),onKeyDown:W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),P(R.id))},className:"flex-1"}),s.jsx(T,{size:"sm",onClick:()=>P(R.id),disabled:!((jt=h[R.id])!=null&&jt.trim())||F.isPending,children:s.jsx(hl,{className:"w-4 h-4"})})]}),!K&&pe&&s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"Keine Unteraufgaben vorhanden."})]})]},R.id)},U=n?v:a("contracts:update");return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:m}),U&&s.jsxs(T,{onClick:()=>d(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Neue ",f]})]}),s.jsx(Y,{className:"mb-6",children:s.jsx("div",{className:"flex gap-4 flex-wrap items-center",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Status:"}),s.jsx(Oe,{value:i,onChange:R=>l(R.target.value),options:[{value:"",label:"Alle"},...Object.entries(nx).map(([R,C])=>({value:R,label:C}))],className:"w-40"})]})})}),x?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):s.jsx(s.Fragment,{children:n?s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Y,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(Km,{className:"w-5 h-5 text-blue-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Meine ",m]}),s.jsx(ye,{variant:"default",children:E.ownTasks.length})]}),E.ownTasks.length>0?s.jsx("div",{children:E.ownTasks.map(R=>L(R,!1))}):s.jsxs("p",{className:"text-gray-500 text-center py-4",children:["Keine eigenen ",m.toLowerCase()," vorhanden."]})]}),E.representedTasks.length>0&&s.jsxs(Y,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(pa,{className:"w-5 h-5 text-purple-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:[m," freigegebener Kunden"]}),s.jsx(ye,{variant:"default",children:E.representedTasks.length})]}),s.jsx("div",{children:E.representedTasks.map(R=>L(R,!0))})]})]}):s.jsx(Y,{children:E.allTasks&&E.allTasks.length>0?s.jsx("div",{children:E.allTasks.map(R=>L(R,!0))}):s.jsxs("div",{className:"text-center py-8 text-gray-500",children:["Keine ",m.toLowerCase()," gefunden."]})})}),n?s.jsx(Ck,{isOpen:u,onClose:()=>d(!1)}):s.jsx(Ek,{isOpen:u,onClose:()=>d(!1)})]})}function Ck({isOpen:e,onClose:t}){const{user:n}=Ue(),r=Ht(),a=xe(),[i,l]=j.useState("own"),[o,c]=j.useState(null),[u,d]=j.useState(""),[h,p]=j.useState(""),[m,f]=j.useState(!1),[y,w]=j.useState(""),{data:v}=me({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>qe.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),g=j.useMemo(()=>{if(!(v!=null&&v.data))return{own:[],represented:{}};const S=[],M={};for(const P of v.data)if(P.customerId===(n==null?void 0:n.customerId))S.push(P);else{if(!M[P.customerId]){const z=P.customer?P.customer.companyName||`${P.customer.firstName} ${P.customer.lastName}`:`Kunde ${P.customerId}`;M[P.customerId]={name:z,contracts:[]}}M[P.customerId].contracts.push(P)}return{own:S,represented:M}},[v==null?void 0:v.data,n==null?void 0:n.customerId]),x=Object.keys(g.represented).length>0,b=j.useMemo(()=>{var S;return i==="own"?g.own:((S=g.represented[i])==null?void 0:S.contracts)||[]},[i,g]),k=j.useMemo(()=>{if(!y)return b;const S=y.toLowerCase();return b.filter(M=>M.contractNumber.toLowerCase().includes(S)||(M.providerName||"").toLowerCase().includes(S)||(M.tariffName||"").toLowerCase().includes(S))},[b,y]),F=async()=>{if(!(!o||!u.trim())){f(!0);try{await it.createSupportTicket(o,{title:u.trim(),description:h.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)}}},E=()=>{d(""),p(""),c(null),l("own"),w(""),t()};return s.jsx(ut,{isOpen:e,onClose:E,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[x&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),s.jsxs("select",{value:i,onChange:S=>{const M=S.target.value;l(M==="own"?"own":parseInt(M)),c(null),w("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(g.represented).map(([S,{name:M}])=>s.jsx("option",{value:S,children:M},S))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(q,{placeholder:"Vertrag suchen...",value:y,onChange:S=>w(S.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(S=>s.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:[s.jsx("div",{className:"font-medium",children:S.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[S.providerName||"Kein Anbieter",S.tariffName&&` - ${S.tariffName}`]})]},S.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(q,{value:u,onChange:S=>d(S.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:h,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"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:E,children:"Abbrechen"}),s.jsx(T,{onClick:F,disabled:!o||!u.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function Ek({isOpen:e,onClose:t}){const n=Ht(),r=xe(),[a,i]=j.useState(null),[l,o]=j.useState(null),[c,u]=j.useState(""),[d,h]=j.useState(""),[p,m]=j.useState(!1),[f,y]=j.useState(!1),[w,v]=j.useState(""),[g,x]=j.useState(""),{data:b}=me({queryKey:["customers-for-task"],queryFn:()=>kt.getAll({limit:100}),enabled:e}),{data:k}=me({queryKey:["contracts-for-task",a],queryFn:()=>qe.getAll({customerId:a}),enabled:e&&a!==null}),F=j.useMemo(()=>{if(!(b!=null&&b.data))return[];if(!w)return b.data;const z=w.toLowerCase();return b.data.filter(L=>L.customerNumber.toLowerCase().includes(z)||L.firstName.toLowerCase().includes(z)||L.lastName.toLowerCase().includes(z)||(L.companyName||"").toLowerCase().includes(z))},[b==null?void 0:b.data,w]),E=j.useMemo(()=>{if(!(k!=null&&k.data))return[];if(!g)return k.data;const z=g.toLowerCase();return k.data.filter(L=>L.contractNumber.toLowerCase().includes(z)||(L.providerName||"").toLowerCase().includes(z)||(L.tariffName||"").toLowerCase().includes(z))},[k==null?void 0:k.data,g]),S=async()=>{if(!(!l||!c.trim())){y(!0);try{await it.create(l,{title:c.trim(),description:d.trim()||void 0,visibleInPortal:p}),r.invalidateQueries({queryKey:["all-tasks"]}),r.invalidateQueries({queryKey:["task-stats"]}),t(),u(""),h(""),m(!1),o(null),i(null),n(`/contracts/${l}`)}catch(z){console.error("Fehler beim Erstellen der Aufgabe:",z),alert("Fehler beim Erstellen der Aufgabe. Bitte versuchen Sie es erneut.")}finally{y(!1)}}},M=()=>{u(""),h(""),m(!1),o(null),i(null),v(""),x(""),t()},P=z=>{const L=z.companyName||`${z.firstName} ${z.lastName}`;return`${z.customerNumber} - ${L}`};return s.jsx(ut,{isOpen:e,onClose:M,title:"Neue Aufgabe",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde *"}),s.jsx(q,{placeholder:"Kunde suchen...",value:w,onChange:z=>v(z.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:F.length>0?F.map(z=>s.jsx("div",{onClick:()=>{i(z.id),o(null),x("")},className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${a===z.id?"bg-blue-50 border-blue-200":""}`,children:s.jsx("div",{className:"font-medium",children:P(z)})},z.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Kunden gefunden."})})]}),a&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(q,{placeholder:"Vertrag suchen...",value:g,onChange:z=>x(z.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:E.length>0?E.map(z=>s.jsxs("div",{onClick:()=>o(z.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${l===z.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:z.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[z.providerName||"Kein Anbieter",z.tariffName&&` - ${z.tariffName}`]})]},z.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:k?"Keine Verträge gefunden.":"Laden..."})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(q,{value:c,onChange:z=>u(z.target.value),placeholder:"Aufgabentitel"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:d,onChange:z=>h(z.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"})]}),s.jsx("div",{children:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:p,onChange:z=>m(z.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),s.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:M,children:"Abbrechen"}),s.jsx(T,{onClick:S,disabled:!l||!c.trim()||f,children:f?"Wird erstellt...":"Aufgabe erstellen"})]})]})})}function Dk(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=Ue(),o=xe(),{data:c,isLoading:u}=me({queryKey:["platforms",a],queryFn:()=>Vi.getAll(a)}),d=H({mutationFn:Vi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["platforms"]})}}),h=m=>{r(m),t(!0)},p=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Vertriebsplattformen"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Neue Plattform"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),u?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kontakt"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:c.data.map(m=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-medium",children:m.name}),s.jsx("td",{className:"py-3 px-4 text-gray-500",children:m.contactInfo||"-"}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ye,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(tt,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Plattform wirklich löschen?")&&d.mutate(m.id)},children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})})]},m.id))})]})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Plattformen vorhanden."})]}),s.jsx(Pk,{isOpen:e,onClose:p,platform:n})]})}function Pk({isOpen:e,onClose:t,platform:n}){const r=xe(),[a,i]=j.useState({name:"",contactInfo:"",isActive:!0});j.useState(()=>{i(n?{name:n.name,contactInfo:n.contactInfo||"",isActive:n.isActive}:{name:"",contactInfo:"",isActive:!0})}),n&&a.name!==n.name?i({name:n.name,contactInfo:n.contactInfo||"",isActive:n.isActive}):!n&&a.name;const l=H({mutationFn:Vi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t(),i({name:"",contactInfo:"",isActive:!0})}}),o=H({mutationFn:d=>Vi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t()}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Plattform bearbeiten":"Neue Plattform",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{label:"Name *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kontaktinformationen"}),s.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..."})]}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Ak(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=Ue(),o=xe(),{data:c,isLoading:u}=me({queryKey:["cancellation-periods",a],queryFn:()=>Qi.getAll(a)}),d=H({mutationFn:Qi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["cancellation-periods"]})}}),h=m=>{r(m),t(!0)},p=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(we,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Xs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Kündigungsfristen"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Neue Frist"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),s.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[s.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",s.jsx("br",{}),s.jsx("strong",{children:"Beispiele:"})," 14T = 14 Tage, 3M = 3 Monate, 1J = 1 Jahr"]}),u?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:c.data.map(m=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:m.code}),s.jsx("td",{className:"py-3 px-4",children:m.description}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ye,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(tt,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Kündigungsfrist wirklich löschen?")&&d.mutate(m.id)},children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})})]},m.id))})]})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kündigungsfristen vorhanden."})]}),s.jsx(Mk,{isOpen:e,onClose:p,period:n})]})}function Mk({isOpen:e,onClose:t,period:n}){const r=xe(),[a,i]=j.useState({code:"",description:"",isActive:!0});j.useEffect(()=>{e&&i(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[e,n]);const l=H({mutationFn:Qi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t(),i({code:"",description:"",isActive:!0})}}),o=H({mutationFn:d=>Qi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t()}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Kündigungsfrist bearbeiten":"Neue Kündigungsfrist",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{label:"Code *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 14T, 3M, 1J"}),s.jsx(q,{label:"Beschreibung *",value:a.description,onChange:d=>i({...a,description:d.target.value}),required:!0,placeholder:"z.B. 14 Tage, 3 Monate, 1 Jahr"}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Tk(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=Ue(),o=xe(),{data:c,isLoading:u}=me({queryKey:["contract-durations",a],queryFn:()=>Hi.getAll(a)}),d=H({mutationFn:Hi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-durations"]})}}),h=m=>{r(m),t(!0)},p=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(we,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Xs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragslaufzeiten"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Neue Laufzeit"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),s.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[s.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",s.jsx("br",{}),s.jsx("strong",{children:"Beispiele:"})," 12M = 12 Monate, 24M = 24 Monate, 2J = 2 Jahre"]}),u?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:c.data.map(m=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:m.code}),s.jsx("td",{className:"py-3 px-4",children:m.description}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ye,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(tt,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Laufzeit wirklich löschen?")&&d.mutate(m.id)},children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})})]},m.id))})]})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Laufzeiten vorhanden."})]}),s.jsx(Fk,{isOpen:e,onClose:p,duration:n})]})}function Fk({isOpen:e,onClose:t,duration:n}){const r=xe(),[a,i]=j.useState({code:"",description:"",isActive:!0});j.useEffect(()=>{e&&i(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[e,n]);const l=H({mutationFn:Hi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t(),i({code:"",description:"",isActive:!0})}}),o=H({mutationFn:d=>Hi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t()}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Laufzeit bearbeiten":"Neue Laufzeit",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{label:"Code *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 12M, 24M, 2J"}),s.jsx(q,{label:"Beschreibung *",value:a.description,onChange:d=>i({...a,description:d.target.value}),required:!0,placeholder:"z.B. 12 Monate, 24 Monate, 2 Jahre"}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Ik(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),[l,o]=j.useState(new Set),{hasPermission:c}=Ue(),u=xe(),{data:d,isLoading:h}=me({queryKey:["providers",a],queryFn:()=>za.getAll(a)}),p=H({mutationFn:za.delete,onSuccess:()=>{u.invalidateQueries({queryKey:["providers"]})},onError:w=>{alert(w.message)}}),m=w=>{o(v=>{const g=new Set(v);return g.has(w)?g.delete(w):g.add(w),g})},f=w=>{r(w),t(!0)},y=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(we,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Xs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Anbieter & Tarife"}),c("providers:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Neuer Anbieter"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:w=>i(w.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),h?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):d!=null&&d.data&&d.data.length>0?s.jsx("div",{className:"space-y-2",children:d.data.map(w=>s.jsx(Lk,{provider:w,isExpanded:l.has(w.id),onToggle:()=>m(w.id),onEdit:()=>f(w),onDelete:()=>{confirm("Anbieter wirklich löschen?")&&p.mutate(w.id)},hasPermission:c,showInactive:a},w.id))}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Anbieter vorhanden."})]}),s.jsx(Rk,{isOpen:e,onClose:y,provider:n})]})}function Lk({provider:e,isExpanded:t,onToggle:n,onEdit:r,onDelete:a,hasPermission:i,showInactive:l}){var f,y;const[o,c]=j.useState(!1),[u,d]=j.useState(null),h=xe(),p=H({mutationFn:C0.delete,onSuccess:()=>{h.invalidateQueries({queryKey:["providers"]})},onError:w=>{alert(w.message)}}),m=((f=e.tariffs)==null?void 0:f.filter(w=>l||w.isActive))||[];return s.jsxs("div",{className:"border rounded-lg",children:[s.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50",children:[s.jsx("button",{onClick:n,className:"mr-3 p-1 hover:bg-gray-200 rounded",children:t?s.jsx(pc,{className:"w-5 h-5 text-gray-400"}):s.jsx(ls,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium",children:e.name}),s.jsx(ye,{variant:e.isActive?"success":"danger",children:e.isActive?"Aktiv":"Inaktiv"}),s.jsxs("span",{className:"text-sm text-gray-500",children:["(",m.length," Tarife, ",((y=e._count)==null?void 0:y.contracts)||0," Verträge)"]})]}),e.portalUrl&&s.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:[s.jsx(Om,{className:"w-3 h-3"}),e.portalUrl]})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[i("providers:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:r,title:"Bearbeiten",children:s.jsx(tt,{className:"w-4 h-4"})}),i("providers:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:a,title:"Löschen",children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})]}),t&&s.jsxs("div",{className:"border-t bg-gray-50 p-4",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h4",{className:"font-medium text-gray-700",children:"Tarife"}),i("providers:create")&&s.jsxs(T,{size:"sm",onClick:()=>c(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-1"}),"Tarif hinzufügen"]})]}),m.length>0?s.jsx("div",{className:"space-y-2",children:m.map(w=>{var v;return s.jsxs("div",{className:"flex items-center justify-between bg-white p-3 rounded border",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{children:w.name}),s.jsx(ye,{variant:w.isActive?"success":"danger",className:"text-xs",children:w.isActive?"Aktiv":"Inaktiv"}),((v=w._count)==null?void 0:v.contracts)!==void 0&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",w._count.contracts," Verträge)"]})]}),s.jsxs("div",{className:"flex gap-1",children:[i("providers:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{d(w),c(!0)},title:"Bearbeiten",children:s.jsx(tt,{className:"w-3 h-3"})}),i("providers:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Tarif wirklich löschen?")&&p.mutate(w.id)},title:"Löschen",children:s.jsx(je,{className:"w-3 h-3 text-red-500"})})]})]},w.id)})}):s.jsx("p",{className:"text-sm text-gray-500",children:"Keine Tarife vorhanden."})]}),s.jsx(Ok,{isOpen:o,onClose:()=>{c(!1),d(null)},providerId:e.id,tariff:u})]})}function Rk({isOpen:e,onClose:t,provider:n}){const r=xe(),[a,i]=j.useState({name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0});j.useEffect(()=>{e&&i(n?{name:n.name,portalUrl:n.portalUrl||"",usernameFieldName:n.usernameFieldName||"",passwordFieldName:n.passwordFieldName||"",isActive:n.isActive}:{name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0})},[e,n]);const l=H({mutationFn:za.create,onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:d=>{alert(d.message)}}),o=H({mutationFn:d=>za.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:d=>{alert(d.message)}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Anbieter bearbeiten":"Neuer Anbieter",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{label:"Anbietername *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0,placeholder:"z.B. Vodafone, E.ON, Allianz"}),s.jsx(q,{label:"Portal-URL (Login-Seite)",value:a.portalUrl,onChange:d=>i({...a,portalUrl:d.target.value}),placeholder:"https://kundenportal.anbieter.de/login"}),s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg space-y-3",children:[s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("strong",{children:"Auto-Login Felder"})," (optional)",s.jsx("br",{}),"Feldnamen für URL-Parameter beim Auto-Login:"]}),s.jsx(q,{label:"Benutzername-Feldname",value:a.usernameFieldName,onChange:d=>i({...a,usernameFieldName:d.target.value}),placeholder:"z.B. username, email, login"}),s.jsx(q,{label:"Passwort-Feldname",value:a.passwordFieldName,onChange:d=>i({...a,passwordFieldName:d.target.value}),placeholder:"z.B. password, pwd, kennwort"})]}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Ok({isOpen:e,onClose:t,providerId:n,tariff:r}){const a=xe(),[i,l]=j.useState({name:"",isActive:!0});j.useEffect(()=>{e&&l(r?{name:r.name,isActive:r.isActive}:{name:"",isActive:!0})},[e,r]);const o=H({mutationFn:h=>za.createTariff(n,h),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:h=>{alert(h.message)}}),c=H({mutationFn:h=>C0.update(r.id,h),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:h=>{alert(h.message)}}),u=h=>{h.preventDefault(),r?c.mutate(i):o.mutate(i)},d=o.isPending||c.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:r?"Tarif bearbeiten":"Neuer Tarif",children:s.jsxs("form",{onSubmit:u,className:"space-y-4",children:[s.jsx(q,{label:"Tarifname *",value:i.name,onChange:h=>l({...i,name:h.target.value}),required:!0,placeholder:"z.B. Comfort Plus, Basic 100"}),r&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:i.isActive,onChange:h=>l({...i,isActive:h.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}const Ed={Zap:s.jsx(Um,{className:"w-5 h-5"}),Flame:s.jsx(L0,{className:"w-5 h-5"}),Wifi:s.jsx(xa,{className:"w-5 h-5"}),Cable:s.jsx(US,{className:"w-5 h-5"}),Network:s.jsx(t2,{className:"w-5 h-5"}),Smartphone:s.jsx($m,{className:"w-5 h-5"}),Tv:s.jsx($0,{className:"w-5 h-5"}),Car:s.jsx(F0,{className:"w-5 h-5"}),FileText:s.jsx(lt,{className:"w-5 h-5"})},zk=[{value:"Zap",label:"Blitz (Strom)"},{value:"Flame",label:"Flamme (Gas)"},{value:"Wifi",label:"WLAN (DSL)"},{value:"Cable",label:"Kabel"},{value:"Network",label:"Netzwerk (Glasfaser)"},{value:"Smartphone",label:"Smartphone (Mobilfunk)"},{value:"Tv",label:"TV"},{value:"Car",label:"Auto (KFZ)"},{value:"FileText",label:"Dokument (Sonstige)"}],$k=[{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 _k(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=Ue(),o=xe(),{data:c,isLoading:u}=me({queryKey:["contract-categories",a],queryFn:()=>Wi.getAll(a)}),d=H({mutationFn:Wi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-categories"]})},onError:m=>{alert(m.message)}}),h=m=>{r(m),t(!0)},p=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(we,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Xs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragstypen"}),l("developer:access")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Neuer Vertragstyp"]})]}),s.jsxs(Y,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),u?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"space-y-2",children:c.data.map(m=>{var f;return s.jsxs("div",{className:"flex items-center p-4 border rounded-lg hover:bg-gray-50",children:[s.jsx("div",{className:"mr-3 text-gray-400",children:s.jsx(HS,{className:"w-5 h-5"})}),s.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center mr-4",style:{backgroundColor:m.color||"#E5E7EB",color:"#fff"},children:m.icon&&Ed[m.icon]?Ed[m.icon]:s.jsx(lt,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium",children:m.name}),s.jsx(ye,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"}),s.jsxs("span",{className:"text-sm text-gray-500",children:["(",((f=m._count)==null?void 0:f.contracts)||0," Verträge)"]})]}),s.jsxs("div",{className:"text-sm text-gray-500",children:["Code: ",s.jsx("span",{className:"font-mono",children:m.code})]})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[l("developer:access")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),title:"Bearbeiten",children:s.jsx(tt,{className:"w-4 h-4"})}),l("developer:access")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertragstyp wirklich löschen?")&&d.mutate(m.id)},title:"Löschen",children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})]},m.id)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Vertragstypen vorhanden."})]}),s.jsx(Kk,{isOpen:e,onClose:p,category:n})]})}function Kk({isOpen:e,onClose:t,category:n}){const r=xe(),[a,i]=j.useState({code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0});j.useEffect(()=>{e&&i(n?{code:n.code,name:n.name,icon:n.icon||"FileText",color:n.color||"#607D8B",sortOrder:n.sortOrder,isActive:n.isActive}:{code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0})},[e,n]);const l=H({mutationFn:Wi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:d=>{alert(d.message)}}),o=H({mutationFn:d=>Wi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:d=>{alert(d.message)}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Vertragstyp bearbeiten":"Neuer Vertragstyp",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(q,{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:!!n}),s.jsx(q,{label:"Anzeigename *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0,placeholder:"z.B. Strom, Mobilfunk Business"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Icon"}),s.jsx("div",{className:"grid grid-cols-4 gap-2",children:zk.map(d=>s.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:[Ed[d.value],s.jsx("span",{className:"truncate w-full text-center",children:d.label.split(" ")[0]})]},d.value))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Farbe"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:$k.map(d=>s.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))})]}),s.jsx(q,{label:"Sortierung",type:"number",value:a.sortOrder,onChange:d=>i({...a,sortOrder:parseInt(d.target.value)||0}),placeholder:"0"}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}const Uk=[{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 Bk(){const{settings:e,updateSettings:t}=P0();return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(we,{to:"/settings",className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(Xs,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ae,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Ansicht"})]})]}),s.jsx(Y,{title:"Scroll-Verhalten",children:s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Nach-oben-Button"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Ab welcher Scroll-Position der Button unten rechts erscheinen soll"})]}),s.jsx("div",{className:"w-48",children:s.jsx(Oe,{options:Uk,value:e.scrollToTopThreshold.toString(),onChange:n=>t({scrollToTopThreshold:parseFloat(n.target.value)})})})]})})})]})}function qk(){const e=xe(),{data:t,isLoading:n}=me({queryKey:["app-settings"],queryFn:()=>Ur.getAll()}),[r,a]=j.useState(!1);j.useEffect(()=>{t!=null&&t.data&&a(t.data.customerSupportTicketsEnabled==="true")},[t]);const i=H({mutationFn:o=>Ur.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 n?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(we,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(Xs,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(zm,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Kundenportal"})]})]}),s.jsxs(Y,{title:"Support-Anfragen",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Zi,{className:"w-5 h-5 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Kunden können Support-Anfragen erstellen"}),s.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."})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:o=>l(o.target.checked),disabled:i.isPending,className:"sr-only peer"}),s.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&&s.jsx("div",{className:"mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:s.jsxs("p",{className:"text-sm text-blue-800",children:[s.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 Vk(){const e=xe(),{data:t,isLoading:n}=me({queryKey:["app-settings"],queryFn:()=>Ur.getAll()}),[r,a]=j.useState("14"),[i,l]=j.useState("42"),[o,c]=j.useState("90"),[u,d]=j.useState(!1);j.useEffect(()=>{t!=null&&t.data&&(a(t.data.deadlineCriticalDays||"14"),l(t.data.deadlineWarningDays||"42"),c(t.data.deadlineOkDays||"90"),d(!1))},[t]);const h=H({mutationFn:f=>Ur.update(f),onSuccess:()=>{e.invalidateQueries({queryKey:["app-settings"]}),e.invalidateQueries({queryKey:["contract-cockpit"]}),d(!1)}}),p=()=>{const f=parseInt(r),y=parseInt(i),w=parseInt(o);if(isNaN(f)||isNaN(y)||isNaN(w)){alert("Bitte gültige Zahlen eingeben");return}if(f>=y||y>=w){alert("Die Werte müssen aufsteigend sein: Kritisch < Warnung < OK");return}h.mutate({deadlineCriticalDays:r,deadlineWarningDays:i,deadlineOkDays:o})},m=(f,y)=>{f(y),d(!0)};return n?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(we,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(Xs,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(bn,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Fristenschwellen"})]})]}),s.jsxs(Y,{title:"Farbkodierung für Fristen",children:[s.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."}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-red-50 border border-red-200 rounded-lg",children:[s.jsx(hn,{className:"w-8 h-8 text-red-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block font-medium text-red-800 mb-1",children:"Kritisch (Rot)"}),s.jsx("p",{className:"text-sm text-red-600 mb-2",children:"Fristen mit weniger als X Tagen werden rot markiert"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{type:"number",min:"1",value:r,onChange:f=>m(a,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-red-700",children:"Tage"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-yellow-50 border border-yellow-200 rounded-lg",children:[s.jsx(ir,{className:"w-8 h-8 text-yellow-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block font-medium text-yellow-800 mb-1",children:"Warnung (Gelb)"}),s.jsx("p",{className:"text-sm text-yellow-600 mb-2",children:"Fristen mit weniger als X Tagen werden gelb markiert"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{type:"number",min:"1",value:i,onChange:f=>m(l,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-yellow-700",children:"Tage"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-green-50 border border-green-200 rounded-lg",children:[s.jsx(js,{className:"w-8 h-8 text-green-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block font-medium text-green-800 mb-1",children:"OK (Grün)"}),s.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)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{type:"number",min:"1",value:o,onChange:f=>m(c,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-green-700",children:"Tage"})]})]})]})]}),s.jsxs("div",{className:"mt-6 pt-4 border-t flex justify-between items-center",children:[s.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."}),s.jsx(T,{onClick:p,disabled:!u||h.isPending,children:h.isPending?"Speichere...":"Speichern"})]})]})]})}const Qk=[{value:"PLESK",label:"Plesk"},{value:"CPANEL",label:"cPanel"},{value:"DIRECTADMIN",label:"DirectAdmin"}],rx=[{value:"SSL",label:"SSL/TLS",description:"Verschlüsselung von Anfang an"},{value:"STARTTLS",label:"STARTTLS",description:"Startet unverschlüsselt, dann Upgrade"},{value:"NONE",label:"Keine",description:"Keine Verschlüsselung"}],ru={name:"",type:"PLESK",apiUrl:"",apiKey:"",username:"",password:"",domain:"stressfrei-wechseln.de",defaultForwardEmail:"",imapEncryption:"SSL",smtpEncryption:"SSL",allowSelfSignedCerts:!1,isActive:!0,isDefault:!1};function Hk(){const e=Ht(),t=xe(),[n,r]=j.useState(!1),[a,i]=j.useState(null),[l,o]=j.useState(ru),[c,u]=j.useState(!1),[d,h]=j.useState(null),[p,m]=j.useState(!1),[f,y]=j.useState({}),[w,v]=j.useState(null),{data:g,isLoading:x}=me({queryKey:["email-provider-configs"],queryFn:()=>an.getConfigs()}),b=H({mutationFn:C=>an.createConfig(C),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),P()}}),k=H({mutationFn:({id:C,data:N})=>an.updateConfig(C,N),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),P()}}),F=H({mutationFn:C=>an.deleteConfig(C),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]})}}),E=(g==null?void 0:g.data)||[],S=()=>{o(ru),i(null),u(!1),h(null),r(!0)},M=C=>{o({name:C.name,type:C.type,apiUrl:C.apiUrl,apiKey:C.apiKey||"",username:C.username||"",password:"",domain:C.domain,defaultForwardEmail:C.defaultForwardEmail||"",imapEncryption:C.imapEncryption??"SSL",smtpEncryption:C.smtpEncryption??"SSL",allowSelfSignedCerts:C.allowSelfSignedCerts??!1,isActive:C.isActive,isDefault:C.isDefault}),i(C.id),u(!1),h(null),r(!0)},P=()=>{r(!1),i(null),o(ru),u(!1),h(null)},z=async C=>{var N,K,X;v(C.id),y(te=>({...te,[C.id]:null}));try{const te=await an.testConnection({id:C.id}),pe={success:((N=te.data)==null?void 0:N.success)||!1,message:(K=te.data)==null?void 0:K.message,error:(X=te.data)==null?void 0:X.error};y(oe=>({...oe,[C.id]:pe}))}catch(te){y(pe=>({...pe,[C.id]:{success:!1,error:te instanceof Error?te.message:"Unbekannter Fehler beim Testen"}}))}finally{v(null)}},L=async()=>{var C,N,K;if(!l.apiUrl||!l.domain){h({success:!1,error:"Bitte geben Sie API-URL und Domain ein."});return}m(!0),h(null);try{const X=await an.testConnection({testData:{type:l.type,apiUrl:l.apiUrl,apiKey:l.apiKey||void 0,username:l.username||void 0,password:l.password||void 0,domain:l.domain}});h({success:((C=X.data)==null?void 0:C.success)||!1,message:(N=X.data)==null?void 0:N.message,error:(K=X.data)==null?void 0:K.error})}catch(X){h({success:!1,error:X instanceof Error?X.message:"Unbekannter Fehler beim Verbindungstest"})}finally{m(!1)}},U=C=>{C.preventDefault();const N={name:l.name,type:l.type,apiUrl:l.apiUrl,apiKey:l.apiKey,username:l.username,domain:l.domain,defaultForwardEmail:l.defaultForwardEmail,imapEncryption:l.imapEncryption,smtpEncryption:l.smtpEncryption,allowSelfSignedCerts:l.allowSelfSignedCerts,isActive:l.isActive,isDefault:l.isDefault};l.password&&(N.password=l.password),a?k.mutate({id:a,data:N}):b.mutate(N)},V=(C,N)=>{confirm(`Möchten Sie den Provider "${N}" wirklich löschen?`)&&F.mutate(C)},R=C=>C.error?C.error:C.message?C.message:"Verbindung fehlgeschlagen";return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs(T,{variant:"ghost",onClick:()=>e("/settings"),children:[s.jsx(Xs,{className:"w-4 h-4 mr-2"}),"Zurück"]}),s.jsx("h1",{className:"text-2xl font-bold",children:"Email-Provisionierung"})]}),s.jsxs(Y,{className:"mb-6",children:[s.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.'}),s.jsxs(T,{onClick:S,children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Provider hinzufügen"]})]}),x?s.jsx("div",{className:"text-center py-8",children:"Laden..."}):E.length===0?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Noch keine Email-Provider konfiguriert."})}):s.jsx("div",{className:"space-y-4",children:E.map(C=>{const N=f[C.id],K=w===C.id;return s.jsx(Y,{children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"font-semibold text-lg",children:C.name}),s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-blue-100 text-blue-800",children:C.type}),C.isDefault&&s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-green-100 text-green-800",children:"Standard"}),!C.isActive&&s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-gray-100 text-gray-600",children:"Inaktiv"})]}),s.jsxs("dl",{className:"mt-3 grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"API-URL"}),s.jsx("dd",{className:"font-mono text-xs truncate",children:C.apiUrl})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Domain"}),s.jsx("dd",{children:C.domain})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Benutzer"}),s.jsx("dd",{children:C.username||"-"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Standard-Weiterleitung"}),s.jsx("dd",{className:"truncate",children:C.defaultForwardEmail||"-"})]})]}),N&&s.jsx("div",{className:`mt-3 p-3 rounded-lg text-sm ${N.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:N.success?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(zo,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:"Verbindung erfolgreich!"})]}):s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ip,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:R(N)})]})})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>z(C),disabled:K,title:"Verbindung testen",children:K?s.jsx("span",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}):s.jsx(xa,{className:"w-4 h-4 text-blue-500"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>M(C),children:s.jsx(tt,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>V(C.id,C.name),children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})]})},C.id)})}),n&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h2",{className:"text-xl font-semibold",children:a?"Provider bearbeiten":"Neuer Provider"}),s.jsx("button",{onClick:P,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Nn,{className:"w-5 h-5"})})]}),(b.error||k.error)&&s.jsx("div",{className:"mb-4 p-3 rounded-lg bg-red-50 text-red-800 text-sm",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Nn,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:b.error instanceof Error?b.error.message:k.error instanceof Error?k.error.message:"Fehler beim Speichern"})]})}),s.jsxs("form",{onSubmit:U,className:"space-y-4",children:[s.jsx(q,{label:"Name *",value:l.name,onChange:C=>o({...l,name:C.target.value}),placeholder:"z.B. Plesk Hauptserver",required:!0}),s.jsx(Oe,{label:"Provider-Typ *",value:l.type,onChange:C=>o({...l,type:C.target.value}),options:Qk}),s.jsx(q,{label:"API-URL *",value:l.apiUrl,onChange:C=>o({...l,apiUrl:C.target.value}),placeholder:"https://server.de:8443",required:!0}),s.jsx(q,{label:"API-Key",value:l.apiKey,onChange:C=>o({...l,apiKey:C.target.value}),placeholder:"Optional - alternativ zu Benutzername/Passwort"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(q,{label:"Benutzername",value:l.username,onChange:C=>o({...l,username:C.target.value}),placeholder:"admin"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer = beibehalten)":"Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:c?"text":"password",value:l.password,onChange:C=>o({...l,password:C.target.value}),className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.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?s.jsx(Mt,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]}),s.jsx(q,{label:"Domain *",value:l.domain,onChange:C=>o({...l,domain:C.target.value}),placeholder:"stressfrei-wechseln.de",required:!0}),s.jsx(q,{label:"Standard-Weiterleitungsadresse",value:l.defaultForwardEmail,onChange:C=>o({...l,defaultForwardEmail:C.target.value}),placeholder:"info@meinefirma.de",type:"email"}),s.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."}),s.jsxs("div",{className:"pt-4 border-t",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"E-Mail-Verbindungseinstellungen"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["IMAP Verschlüsselung",s.jsxs("span",{className:"text-gray-400 font-normal ml-1",children:["(Port ",l.imapEncryption==="SSL"?"993":"143",")"]})]}),s.jsx("select",{value:l.imapEncryption,onChange:C=>o({...l,imapEncryption:C.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:rx.map(C=>s.jsxs("option",{value:C.value,children:[C.label," - ",C.description]},C.value))})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["SMTP Verschlüsselung",s.jsxs("span",{className:"text-gray-400 font-normal ml-1",children:["(Port ",l.smtpEncryption==="SSL"?"465":l.smtpEncryption==="STARTTLS"?"587":"25",")"]})]}),s.jsx("select",{value:l.smtpEncryption,onChange:C=>o({...l,smtpEncryption:C.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:rx.map(C=>s.jsxs("option",{value:C.value,children:[C.label," - ",C.description]},C.value))})]})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.allowSelfSignedCerts,onChange:C=>o({...l,allowSelfSignedCerts:C.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Selbstsignierte Zertifikate erlauben"})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"Aktivieren Sie diese Option für Testumgebungen mit selbstsignierten SSL-Zertifikaten."})]})]}),s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.isActive,onChange:C=>o({...l,isActive:C.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Aktiv"})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.isDefault,onChange:C=>o({...l,isDefault:C.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Als Standard verwenden"})]})]}),s.jsxs("div",{className:"pt-4 border-t",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:L,disabled:p,className:"w-full",children:p?"Teste Verbindung...":s.jsxs(s.Fragment,{children:[s.jsx(xa,{className:"w-4 h-4 mr-2"}),"Verbindung testen"]})}),d&&s.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?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(zo,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:"Verbindung erfolgreich!"})]}):s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ip,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:R(d)})]})})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:P,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:b.isPending||k.isPending,children:b.isPending||k.isPending?"Speichern...":"Speichern"})]})]})]})})})]})}function Wk(){const[e,t]=j.useState(null),[n,r]=j.useState(null),[a,i]=j.useState(!1),[l,o]=j.useState(""),[c,u]=j.useState(null),d=j.useRef(null),h=xe(),{logout:p}=Ue(),{data:m,isLoading:f}=me({queryKey:["backups"],queryFn:()=>dr.list()}),y=(m==null?void 0:m.data)||[],w=H({mutationFn:()=>dr.create(),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]})}}),v=H({mutationFn:M=>dr.restore(M),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),t(null)}}),g=H({mutationFn:M=>dr.delete(M),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),r(null)}}),x=H({mutationFn:M=>dr.upload(M),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),u(null),d.current&&(d.current.value="")},onError:M=>{u(M.message||"Upload fehlgeschlagen")}}),b=H({mutationFn:()=>dr.factoryReset(),onSuccess:()=>{i(!1),o(""),p()}}),k=M=>{var z;const P=(z=M.target.files)==null?void 0:z[0];if(P){if(!P.name.endsWith(".zip")){u("Nur ZIP-Dateien sind erlaubt");return}u(null),x.mutate(P)}},F=async M=>{const P=localStorage.getItem("token"),z=dr.getDownloadUrl(M);try{const L=await fetch(z,{headers:{Authorization:`Bearer ${P}`}});if(!L.ok)throw new Error("Download fehlgeschlagen");const U=await L.blob(),V=window.URL.createObjectURL(U),R=document.createElement("a");R.href=V,R.download=`opencrm-backup-${M}.zip`,document.body.appendChild(R),R.click(),document.body.removeChild(R),window.URL.revokeObjectURL(V)}catch(L){console.error("Download error:",L)}},E=M=>new Date(M).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),S=M=>M<1024?`${M} B`:M<1024*1024?`${(M/1024).toFixed(1)} KB`:`${(M/(1024*1024)).toFixed(1)} MB`;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-gray-900 flex items-center gap-2",children:[s.jsx(gc,{className:"w-5 h-5"}),"Datenbank & Zurücksetzen"]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Backups erstellen, wiederherstellen oder auf Werkseinstellungen zurücksetzen."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"file",ref:d,accept:".zip",onChange:k,className:"hidden"}),s.jsx(T,{variant:"secondary",onClick:()=>{var M;return(M=d.current)==null?void 0:M.click()},disabled:x.isPending,children:x.isPending?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"w-4 h-4 mr-2 animate-spin"}),"Hochladen..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Sd,{className:"w-4 h-4 mr-2"}),"Backup hochladen"]})}),s.jsx(T,{onClick:()=>w.mutate(),disabled:w.isPending,children:w.isPending?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird erstellt..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Fs,{className:"w-4 h-4 mr-2"}),"Neues Backup"]})})]})]}),c&&s.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-700",children:c}),s.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-blue-800 mb-2",children:"Hinweise zur Datensicherung"}),s.jsxs("ul",{className:"text-sm text-blue-700 space-y-1 list-disc list-inside",children:[s.jsx("li",{children:"Backups enthalten alle Datenbankdaten und hochgeladene Dokumente"}),s.jsx("li",{children:"Erstellen Sie vor Datenbankmigrationen immer ein Backup"}),s.jsx("li",{children:"Backups können als ZIP heruntergeladen und auf einem anderen System wiederhergestellt werden"}),s.jsx("li",{children:"Bei der Wiederherstellung werden bestehende Daten mit dem Backup-Stand überschrieben"})]})]}),s.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 overflow-hidden",children:[s.jsx("div",{className:"px-4 py-3 bg-gray-50 border-b border-gray-200",children:s.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Verfügbare Backups"})}),f?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(fr,{className:"w-6 h-6 animate-spin text-gray-400"})}):y.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Tp,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Keine Backups vorhanden"}),s.jsx("p",{className:"text-sm mt-1",children:"Erstellen Sie Ihr erstes Backup"})]}):s.jsx("div",{className:"divide-y divide-gray-200",children:y.map(M=>s.jsx("div",{className:"p-4 hover:bg-gray-50",children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[s.jsx("span",{className:"font-mono text-sm bg-gray-100 px-2 py-1 rounded",children:M.name}),s.jsxs("span",{className:"text-sm text-gray-500 flex items-center gap-1",children:[s.jsx(bn,{className:"w-4 h-4"}),E(M.timestamp)]})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(lt,{className:"w-4 h-4"}),M.totalRecords.toLocaleString("de-DE")," Datensätze"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Tp,{className:"w-4 h-4"}),S(M.sizeBytes)]}),M.hasUploads&&s.jsxs("span",{className:"flex items-center gap-1 text-green-600",children:[s.jsx(QS,{className:"w-4 h-4"}),"Dokumente (",S(M.uploadSizeBytes),")"]})]}),s.jsxs("details",{className:"mt-2",children:[s.jsxs("summary",{className:"text-xs text-gray-500 cursor-pointer hover:text-gray-700",children:["Tabellen anzeigen (",M.tables.filter(P=>P.count>0).length," mit Daten)"]}),s.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:M.tables.filter(P=>P.count>0).map(P=>s.jsxs("span",{className:"text-xs bg-gray-100 px-2 py-0.5 rounded",children:[P.table,": ",P.count]},P.table))})]})]}),s.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>F(M.name),title:"Als ZIP herunterladen",children:s.jsx(_S,{className:"w-4 h-4"})}),s.jsxs(T,{variant:"secondary",size:"sm",onClick:()=>t(M.name),disabled:v.isPending,children:[s.jsx(Sd,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsx(T,{variant:"danger",size:"sm",onClick:()=>r(M.name),disabled:g.isPending,children:s.jsx(je,{className:"w-4 h-4"})})]})]})},M.name))})]}),e&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup wiederherstellen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",s.jsx("strong",{children:e})," wirklich wiederherstellen?"]}),s.jsxs("p",{className:"text-amber-600 text-sm mb-4 bg-amber-50 p-3 rounded-lg",children:[s.jsx("strong",{children:"Achtung:"})," Bestehende Daten und Dokumente werden mit dem Backup-Stand überschrieben. Dies kann nicht rückgängig gemacht werden."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>t(null),disabled:v.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"primary",onClick:()=>v.mutate(e),disabled:v.isPending,children:v.isPending?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird wiederhergestellt..."]}):"Ja, wiederherstellen"})]})]})}),n&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup löschen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",s.jsx("strong",{children:n})," wirklich löschen? Dies kann nicht rückgängig gemacht werden."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>r(null),disabled:g.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>g.mutate(n),disabled:g.isPending,children:g.isPending?"Wird gelöscht...":"Ja, löschen"})]})]})}),s.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 mt-8",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(ir,{className:"w-6 h-6 text-red-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-red-800 mb-2",children:"Werkseinstellungen"}),s.jsxs("p",{className:"text-sm text-red-700 mb-4",children:["Setzt das System auf den Ausgangszustand zurück. ",s.jsx("strong",{children:"Alle Daten werden unwiderruflich gelöscht"})," - Kunden, Verträge, Benutzer, Dokumente und Einstellungen. Nur die hier gespeicherten Backups bleiben erhalten."]}),s.jsxs("ul",{className:"text-sm text-red-700 mb-4 list-disc list-inside space-y-1",children:[s.jsx("li",{children:"Alle Kunden und Verträge werden gelöscht"}),s.jsx("li",{children:"Alle Benutzer werden gelöscht"}),s.jsx("li",{children:"Alle hochgeladenen Dokumente werden gelöscht"}),s.jsx("li",{children:"Ein neuer Admin-Benutzer wird erstellt (admin@admin.com / admin)"}),s.jsxs("li",{children:[s.jsx("strong",{children:"Backups bleiben erhalten"})," und können danach wiederhergestellt werden"]})]}),s.jsxs(T,{variant:"danger",onClick:()=>i(!0),children:[s.jsx(n2,{className:"w-4 h-4 mr-2"}),"Werkseinstellungen"]})]})]})}),a&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-lg mx-4",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(ir,{className:"w-6 h-6 text-red-600"})}),s.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Wirklich auf Werkseinstellungen zurücksetzen?"})]}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Diese Aktion löscht ",s.jsx("strong",{children:"alle Daten unwiderruflich"}),". Es gibt kein Zurück!"]}),s.jsxs("p",{className:"text-sm text-gray-600 mb-4",children:["Geben Sie zur Bestätigung ",s.jsx("strong",{className:"font-mono bg-gray-100 px-1",children:"LÖSCHEN"})," ein:"]}),s.jsx("input",{type:"text",value:l,onChange:M=>o(M.target.value),placeholder:"LÖSCHEN",className:"w-full px-3 py-2 border border-gray-300 rounded-lg mb-4 focus:ring-2 focus:ring-red-500 focus:border-red-500"}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>{i(!1),o("")},disabled:b.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>b.mutate(),disabled:l!=="LÖSCHEN"||b.isPending,children:b.isPending?s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird zurückgesetzt..."]}):"Ja, alles löschen"})]})]})})]})}function Gk(){var g;const[e,t]=j.useState(""),[n,r]=j.useState(1),[a,i]=j.useState(!1),[l,o]=j.useState(null),c=xe(),{refreshUser:u}=Ue(),{data:d,isLoading:h}=me({queryKey:["users",e,n],queryFn:()=>Ni.getAll({search:e||void 0,page:n,limit:20})}),{data:p}=me({queryKey:["roles"],queryFn:()=>Ni.getRoles()}),m=H({mutationFn:Ni.delete,onSuccess:()=>{c.invalidateQueries({queryKey:["users"]})},onError:x=>{alert((x==null?void 0:x.message)||"Fehler beim Löschen des Benutzers")}}),f=x=>{var b;return(b=x.roles)==null?void 0:b.some(k=>k.name==="Admin")},y=((g=d==null?void 0:d.data)==null?void 0:g.filter(x=>x.isActive&&f(x)).length)||0,w=x=>{o(x),i(!0)},v=()=>{i(!1),o(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(we,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Xs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Benutzer"}),s.jsxs(T,{onClick:()=>i(!0),children:[s.jsx(ze,{className:"w-4 h-4 mr-2"}),"Neuer Benutzer"]})]}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx(q,{placeholder:"Suchen...",value:e,onChange:x=>t(x.target.value)})}),s.jsx(T,{variant:"secondary",children:s.jsx(ml,{className:"w-4 h-4"})})]})}),s.jsxs("div",{className:"mb-6 bg-blue-50 border border-blue-200 rounded-lg p-4 flex items-start gap-3",children:[s.jsx(WS,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-blue-800",children:[s.jsx("strong",{children:"Hinweis:"})," Bei Änderungen an Rollen oder Berechtigungen wird der betroffene Benutzer automatisch ausgeloggt und muss sich erneut anmelden."]})]}),s.jsx(Y,{children:h?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):d!=null&&d.data&&d.data.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Rollen"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:d.data.map(x=>{var b;return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsxs("td",{className:"py-3 px-4",children:[x.firstName," ",x.lastName]}),s.jsx("td",{className:"py-3 px-4",children:x.email}),s.jsx("td",{className:"py-3 px-4",children:s.jsx("div",{className:"flex gap-1 flex-wrap",children:(b=x.roles)==null?void 0:b.filter(k=>k.name!=="Developer").map(k=>s.jsx(ye,{variant:"info",children:k.name},k.id||k.name))})}),s.jsx("td",{className:"py-3 px-4",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ye,{variant:x.isActive?"success":"danger",children:x.isActive?"Aktiv":"Inaktiv"}),x.hasDeveloperAccess&&s.jsxs(ye,{variant:"warning",className:"flex items-center gap-1",children:[s.jsx(xc,{className:"w-3 h-3"}),"Dev"]})]})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>w(x),children:s.jsx(tt,{className:"w-4 h-4"})}),(()=>{const k=f(x)&&x.isActive&&y<=1;return s.jsx(T,{variant:"ghost",size:"sm",disabled:k,title:k?"Letzter Administrator kann nicht gelöscht werden":void 0,onClick:()=>{confirm("Benutzer wirklich löschen?")&&m.mutate(x.id)},children:s.jsx(je,{className:`w-4 h-4 ${k?"text-gray-300":"text-red-500"}`})})})()]})})]},x.id)})})]})}),d.pagination&&d.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",d.pagination.page," von ",d.pagination.totalPages]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(x=>Math.max(1,x-1)),disabled:n===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(x=>x+1),disabled:n>=d.pagination.totalPages,children:"Weiter"})]})]})]}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Benutzer gefunden."})}),s.jsx(Zk,{isOpen:a,onClose:v,user:l,roles:(p==null?void 0:p.data)||[],onUserUpdated:u})]})}function Zk({isOpen:e,onClose:t,user:n,roles:r,onUserUpdated:a}){const i=xe(),[l,o]=j.useState(null),[c,u]=j.useState({email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1});j.useEffect(()=>{var y;e&&(o(null),u(n?{email:n.email,password:"",firstName:n.firstName,lastName:n.lastName,roleIds:((y=n.roles)==null?void 0:y.filter(w=>w.name!=="Developer").map(w=>w.id))||[],isActive:n.isActive??!0,hasDeveloperAccess:n.hasDeveloperAccess??!1}:{email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1}))},[e,n]);const d=H({mutationFn:Ni.create,onSuccess:()=>{i.invalidateQueries({queryKey:["users"]}),t()},onError:y=>{o((y==null?void 0:y.message)||"Fehler beim Erstellen des Benutzers")}}),h=H({mutationFn:y=>Ni.update(n.id,y),onSuccess:async()=>{i.invalidateQueries({queryKey:["users"]}),await a(),t()},onError:y=>{o((y==null?void 0:y.message)||"Fehler beim Aktualisieren des Benutzers")}}),p=y=>{if(y.preventDefault(),n){const w={email:c.email,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,isActive:c.isActive,hasDeveloperAccess:c.hasDeveloperAccess};c.password&&(w.password=c.password),h.mutate(w)}else d.mutate({email:c.email,password:c.password,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,hasDeveloperAccess:c.hasDeveloperAccess})},m=y=>{u(w=>({...w,roleIds:w.roleIds.includes(y)?w.roleIds.filter(v=>v!==y):[...w.roleIds,y]}))},f=d.isPending||h.isPending;return s.jsx(ut,{isOpen:e,onClose:t,title:n?"Benutzer bearbeiten":"Neuer Benutzer",children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[l&&s.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 flex items-start gap-2",children:[s.jsx(ir,{className:"w-5 h-5 text-red-500 flex-shrink-0 mt-0.5"}),s.jsx("p",{className:"text-red-700 text-sm",children:l})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(q,{label:"Vorname *",value:c.firstName,onChange:y=>u({...c,firstName:y.target.value}),required:!0}),s.jsx(q,{label:"Nachname *",value:c.lastName,onChange:y=>u({...c,lastName:y.target.value}),required:!0})]}),s.jsx(q,{label:"E-Mail *",type:"email",value:c.email,onChange:y=>u({...c,email:y.target.value}),required:!0}),s.jsx(q,{label:n?"Neues Passwort (leer = unverändert)":"Passwort *",type:"password",value:c.password,onChange:y=>u({...c,password:y.target.value}),required:!n}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Rollen"}),s.jsxs("div",{className:"space-y-2",children:[r.filter(y=>y.name!=="Developer").map(y=>s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.roleIds.includes(y.id),onChange:()=>m(y.id),className:"rounded"}),s.jsx("span",{children:y.name}),y.description&&s.jsxs("span",{className:"text-sm text-gray-500",children:["(",y.description,")"]})]},y.id)),s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.hasDeveloperAccess,onChange:y=>u({...c,hasDeveloperAccess:y.target.checked}),className:"rounded border-purple-300 text-purple-600 focus:ring-purple-500"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(xc,{className:"w-4 h-4 text-purple-600"}),"Entwicklerzugriff"]}),s.jsx("span",{className:"text-sm text-gray-500",children:"(Datenbanktools)"})]})]}),n&&s.jsxs("p",{className:"mt-2 text-xs text-amber-600 flex items-center gap-1",children:[s.jsx(ir,{className:"w-3 h-3"}),"Bei Rollenänderung wird der Benutzer automatisch ausgeloggt."]})]}),n&&s.jsx("div",{className:"space-y-3 pt-3 border-t",children:s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.isActive,onChange:y=>u({...c,isActive:y.target.checked}),className:"rounded"}),"Aktiv"]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:f,children:f?"Speichern...":"Speichern"})]})]})})}function Jk(){const{hasPermission:e,developerMode:t,setDeveloperMode:n}=Ue(),r=[{to:"/settings/users",icon:l2,title:"Benutzer",description:"Verwalten Sie Benutzerkonten, Rollen und Berechtigungen.",show:e("users:read")},{to:"/settings/platforms",icon:a2,title:"Vertriebsplattformen",description:"Verwalten Sie die Plattformen, über die Verträge abgeschlossen werden.",show:e("platforms:read")},{to:"/settings/cancellation-periods",icon:bn,title:"Kündigungsfristen",description:"Konfigurieren Sie die verfügbaren Kündigungsfristen für Verträge.",show:e("platforms:read")},{to:"/settings/contract-durations",icon:T0,title:"Vertragslaufzeiten",description:"Konfigurieren Sie die verfügbaren Laufzeiten für Verträge.",show:e("platforms:read")},{to:"/settings/providers",icon:KS,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:VS,title:"Vertragstypen",description:"Konfigurieren Sie die verfügbaren Vertragstypen (Strom, Gas, Mobilfunk, etc.).",show:e("platforms:read")}];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx(z0,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Einstellungen"})]}),s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Stammdaten"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:r.filter(a=>a.show).map(a=>s.jsx(we,{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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(a.icon,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:[a.title,s.jsx(ls,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:a.description})]})]})},a.to))})]}),e("settings:update")&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"System"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(we,{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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(zm,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Kundenportal",s.jsx(ls,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie das Kundenportal und Support-Anfragen."})]})]})}),s.jsx(we,{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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(bn,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Fristenschwellen",s.jsx(ls,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die Farbkodierung für Vertragsfristen im Cockpit."})]})]})}),s.jsx(we,{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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(Hs,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Email-Provisionierung",s.jsx(ls,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die automatische E-Mail-Erstellung für Stressfrei-Wechseln Adressen."})]})]})}),s.jsx(we,{to:"/settings/database-backup",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(gc,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Datenbank & Zurücksetzen",s.jsx(ls,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Backups erstellen, wiederherstellen oder auf Werkseinstellungen zurücksetzen."})]})]})})]})]}),s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Persönlich"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:s.jsx(we,{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:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(Ae,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Ansicht",s.jsx(ls,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Passen Sie die Darstellung der Anwendung an."})]})]})})})]}),e("developer:access")&&s.jsxs(Y,{title:"Entwickleroptionen",className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(xc,{className:"w-5 h-5 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Entwicklermodus"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Aktiviert erweiterte Funktionen wie direkten Datenbankzugriff"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:a=>n(a.target.checked),className:"sr-only peer"}),s.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&&s.jsx("div",{className:"mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:s.jsxs("p",{className:"text-sm text-yellow-800",children:[s.jsx("strong",{children:"Warnung:"})," Der Entwicklermodus ermöglicht direkten Zugriff auf die Datenbank. Unsachgemäße Änderungen können zu Datenverlust oder Inkonsistenzen führen."]})})]}),s.jsx(Y,{title:"Über",children:s.jsxs("dl",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Version"}),s.jsx("dd",{children:"1.0.0"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"System"}),s.jsx("dd",{children:"OpenCRM"})]})]})})]})}function Xk({onSelectTable:e}){const t=j.useRef(null),[n,r]=j.useState(1),[a,i]=j.useState({x:0,y:0}),[l,o]=j.useState(!1),[c,u]=j.useState({x:0,y:0}),[d,h]=j.useState({}),[p,m]=j.useState(null),{data:f,isLoading:y}=me({queryKey:["developer-schema"],queryFn:mi.getSchema}),w=(f==null?void 0:f.data)||[];j.useEffect(()=>{if(w.length>0&&Object.keys(d).length===0){const S=Math.ceil(Math.sqrt(w.length)),M={x:280,y:200},P={};w.forEach((z,L)=>{const U=L%S,V=Math.floor(L/S);P[z.name]={x:50+U*M.x,y:50+V*M.y}}),h(P)}},[w,d]);const v=j.useCallback(S=>{(S.target===S.currentTarget||S.target.tagName==="svg")&&(o(!0),u({x:S.clientX-a.x,y:S.clientY-a.y}))},[a]),g=j.useCallback(S=>{var M;if(l&&!p)i({x:S.clientX-c.x,y:S.clientY-c.y});else if(p){const P=(M=t.current)==null?void 0:M.getBoundingClientRect();P&&h(z=>({...z,[p]:{x:(S.clientX-P.left-a.x)/n-100,y:(S.clientY-P.top-a.y)/n-20}}))}},[l,p,c,a,n]),x=j.useCallback(()=>{o(!1),m(null)},[]),b=S=>{r(M=>Math.min(2,Math.max(.3,M+S)))},k=()=>{r(1),i({x:0,y:0})},F=j.useCallback(()=>{const S=[];return w.forEach(M=>{const P=d[M.name];P&&M.foreignKeys.forEach(z=>{const L=d[z.targetTable];if(!L)return;const U=w.find(R=>R.name===z.targetTable),V=U==null?void 0:U.relations.find(R=>R.targetTable===M.name);S.push({from:{table:M.name,x:P.x+100,y:P.y+60},to:{table:z.targetTable,x:L.x+100,y:L.y+60},type:(V==null?void 0:V.type)||"one",label:z.field})})}),S},[w,d]);if(y)return s.jsx("div",{className:"flex items-center justify-center h-full",children:"Laden..."});const E=F();return s.jsxs("div",{className:"relative h-full w-full bg-gray-50 overflow-hidden",ref:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex gap-2 bg-white rounded-lg shadow-md p-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>b(.1),title:"Vergrößern",children:s.jsx(c2,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>b(-.1),title:"Verkleinern",children:s.jsx(u2,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:k,title:"Zurücksetzen",children:s.jsx(YS,{className:"w-4 h-4"})}),s.jsxs("div",{className:"text-xs text-gray-500 flex items-center px-2",children:[Math.round(n*100),"%"]})]}),s.jsxs("div",{className:"absolute top-4 left-4 z-10 bg-white rounded-lg shadow-md p-2 text-xs text-gray-500",children:[s.jsx(e2,{className:"w-3 h-3 inline mr-1"}),"Tabellen ziehen zum Verschieben"]}),s.jsx("svg",{className:"w-full h-full cursor-grab",style:{cursor:l?"grabbing":"grab"},onMouseDown:v,onMouseMove:g,onMouseUp:x,onMouseLeave:x,children:s.jsxs("g",{transform:`translate(${a.x}, ${a.y}) scale(${n})`,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6b7280"})}),s.jsx("marker",{id:"many-marker",markerWidth:"12",markerHeight:"12",refX:"6",refY:"6",orient:"auto",children:s.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"#6b7280"})})]}),E.map((S,M)=>{const P=S.to.x-S.from.x,z=S.to.y-S.from.y,L=S.from.x+P/2,U=S.from.y+z/2,V=S.from.x+P*.25,R=S.from.y,C=S.from.x+P*.75,N=S.to.y;return s.jsxs("g",{children:[s.jsx("path",{d:`M ${S.from.x} ${S.from.y} C ${V} ${R}, ${C} ${N}, ${S.to.x} ${S.to.y}`,fill:"none",stroke:"#9ca3af",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),s.jsx("text",{x:L,y:U-8,fontSize:"10",fill:"#6b7280",textAnchor:"middle",className:"select-none",children:S.type==="many"?"1:n":"1:1"})]},M)}),w.map(S=>{const M=d[S.name];if(!M)return null;const P=200,z=32,L=20,U=[...new Set([S.primaryKey,...S.foreignKeys.map(R=>R.field)])],V=z+Math.min(U.length,5)*L+8;return s.jsxs("g",{transform:`translate(${M.x}, ${M.y})`,style:{cursor:"move"},onMouseDown:R=>{R.stopPropagation(),m(S.name)},children:[s.jsx("rect",{x:"3",y:"3",width:P,height:V,rx:"6",fill:"rgba(0,0,0,0.1)"}),s.jsx("rect",{x:"0",y:"0",width:P,height:V,rx:"6",fill:"white",stroke:"#e5e7eb",strokeWidth:"1"}),s.jsx("rect",{x:"0",y:"0",width:P,height:z,rx:"6",fill:"#3b82f6",className:"cursor-pointer",onClick:()=>e==null?void 0:e(S.name)}),s.jsx("rect",{x:"0",y:z-6,width:P,height:"6",fill:"#3b82f6"}),s.jsx("text",{x:P/2,y:"21",fontSize:"13",fontWeight:"bold",fill:"white",textAnchor:"middle",className:"select-none pointer-events-none",children:S.name}),U.slice(0,5).map((R,C)=>{const N=R===S.primaryKey||S.primaryKey.includes(R),K=S.foreignKeys.some(X=>X.field===R);return s.jsx("g",{transform:`translate(8, ${z+4+C*L})`,children:s.jsxs("text",{x:"0",y:"14",fontSize:"11",fill:N?"#dc2626":K?"#2563eb":"#374151",fontFamily:"monospace",className:"select-none",children:[N&&"🔑 ",K&&!N&&"🔗 ",R]})},R)}),U.length>5&&s.jsxs("text",{x:P/2,y:V-4,fontSize:"10",fill:"#9ca3af",textAnchor:"middle",className:"select-none",children:["+",U.length-5," mehr..."]})]},S.name)})]})}),s.jsxs("div",{className:"absolute bottom-4 left-4 bg-white rounded-lg shadow-md p-3 text-xs",children:[s.jsx("div",{className:"font-medium mb-2",children:"Legende"}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-red-600",children:"🔑"}),s.jsx("span",{children:"Primary Key"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-blue-600",children:"🔗"}),s.jsx("span",{children:"Foreign Key"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-6 h-0.5 bg-gray-400"}),s.jsx("span",{children:"Beziehung"})]})]})]})]})}function Yk(){var E;const[e,t]=j.useState(null),[n,r]=j.useState(1),[a,i]=j.useState(null),[l,o]=j.useState(!1),c=xe(),{data:u,isLoading:d,error:h}=me({queryKey:["developer-schema"],queryFn:mi.getSchema});console.log("Schema data:",u),console.log("Schema error:",h);const{data:p,isLoading:m}=me({queryKey:["developer-table",e,n],queryFn:()=>mi.getTableData(e,n),enabled:!!e}),f=H({mutationFn:({tableName:S,id:M,data:P})=>mi.updateRow(S,M,P),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]}),i(null)},onError:S=>{var M,P;alert(((P=(M=S.response)==null?void 0:M.data)==null?void 0:P.error)||"Fehler beim Speichern")}}),y=H({mutationFn:({tableName:S,id:M})=>mi.deleteRow(S,M),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]})},onError:S=>{var M,P;alert(((P=(M=S.response)==null?void 0:M.data)==null?void 0:P.error)||"Fehler beim Löschen")}}),w=(u==null?void 0:u.data)||[],v=w.find(S=>S.name===e),g=(S,M)=>M.primaryKey.includes(",")?M.primaryKey.split(",").map(P=>S[P]).join("-"):String(S[M.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),b=()=>{!a||!e||f.mutate({tableName:e,id:a.id,data:a.data})},k=S=>{e&&confirm("Datensatz wirklich löschen?")&&y.mutate({tableName:e,id:S})};if(d)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});const F=S=>{t(S),r(1),o(!1)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(gc,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Datenbankstruktur"})]}),s.jsxs(T,{onClick:()=>o(!0),children:[s.jsx(Mp,{className:"w-4 h-4 mr-2"}),"ER-Diagramm"]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[s.jsx(Y,{title:"Tabellen",className:"lg:col-span-1",children:s.jsx("div",{className:"space-y-1 max-h-[600px] overflow-y-auto",children:w.map(S=>s.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:[s.jsx(i2,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-mono",children:S.name})]},S.name))})}),s.jsx("div",{className:"lg:col-span-3 space-y-6",children:e&&v?s.jsxs(s.Fragment,{children:[s.jsxs(Y,{title:`${e} - Beziehungen`,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Fremdschlüssel (referenziert)"}),v.foreignKeys.length>0?s.jsx("div",{className:"space-y-1",children:v.foreignKeys.map(S=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:S.field}),s.jsx(M0,{className:"w-4 h-4 text-gray-400"}),s.jsx(ye,{variant:"info",className:"cursor-pointer",onClick:()=>{t(S.targetTable),r(1)},children:S.targetTable})]},S.field))}):s.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Relationen (wird referenziert von)"}),v.relations.length>0?s.jsx("div",{className:"space-y-1",children:v.relations.map(S=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:S.field}),s.jsx(ye,{variant:S.type==="many"?"warning":"default",children:S.type==="many"?"1:n":"1:1"}),s.jsx(ye,{variant:"info",className:"cursor-pointer",onClick:()=>{t(S.targetTable),r(1)},children:S.targetTable})]},S.field))}):s.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]})]}),s.jsx("div",{className:"mt-4 pt-4 border-t",children:s.jsxs("div",{className:"flex gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Primary Key:"})," ",s.jsx("span",{className:"font-mono",children:v.primaryKey})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Readonly:"})," ",s.jsx("span",{className:"font-mono text-red-600",children:v.readonlyFields.join(", ")||"-"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Required:"})," ",s.jsx("span",{className:"font-mono text-green-600",children:v.requiredFields.join(", ")||"-"})]})]})})]}),s.jsx(Y,{title:`${e} - Daten`,children:m?s.jsx("div",{className:"text-center py-4",children:"Laden..."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.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=>s.jsxs("th",{className:"text-left py-2 px-3 font-medium text-gray-600 whitespace-nowrap",children:[S,v.readonlyFields.includes(S)&&s.jsx("span",{className:"ml-1 text-red-400 text-xs",children:"*"}),v.requiredFields.includes(S)&&s.jsx("span",{className:"ml-1 text-green-400 text-xs",children:"!"})]},S)),s.jsx("th",{className:"text-right py-2 px-3 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsxs("tbody",{children:[(E=p==null?void 0:p.data)==null?void 0:E.map(S=>{const M=g(S,v);return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[Object.entries(S).map(([P,z])=>s.jsx("td",{className:"py-2 px-3 font-mono text-xs max-w-[200px] truncate",children:x(z)},P)),s.jsx("td",{className:"py-2 px-3 text-right whitespace-nowrap",children:s.jsxs("div",{className:"flex justify-end gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>i({id:M,data:{...S}}),children:s.jsx(tt,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>k(M),children:s.jsx(je,{className:"w-4 h-4 text-red-500"})})]})})]},M)}),(!(p!=null&&p.data)||p.data.length===0)&&s.jsx("tr",{children:s.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&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",p.pagination.page," von ",p.pagination.totalPages," (",p.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(S=>Math.max(1,S-1)),disabled:n===1,children:s.jsx(BS,{className:"w-4 h-4"})}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(S=>S+1),disabled:n>=p.pagination.totalPages,children:s.jsx(ls,{className:"w-4 h-4"})})]})]})]})})]}):s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Wähle eine Tabelle aus der Liste aus"})})})]}),s.jsx(ut,{isOpen:!!a,onClose:()=>i(null),title:`${e} bearbeiten`,children:a&&v&&s.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[Object.entries(a.data).map(([S,M])=>{const P=v.readonlyFields.includes(S),z=v.requiredFields.includes(S);return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[S,P&&s.jsx("span",{className:"ml-1 text-red-400",children:"(readonly)"}),z&&s.jsx("span",{className:"ml-1 text-green-600",children:"*"})]}),P?s.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg font-mono text-sm",children:x(M)}):typeof M=="boolean"?s.jsxs("select",{value:String(a.data[S]),onChange:L=>i({...a,data:{...a.data,[S]:L.target.value==="true"}}),className:"w-full px-3 py-2 border rounded-lg",children:[s.jsx("option",{value:"true",children:"Ja"}),s.jsx("option",{value:"false",children:"Nein"})]}):s.jsx("input",{type:typeof M=="number"?"number":"text",value:a.data[S]??"",onChange:L=>i({...a,data:{...a.data,[S]:typeof M=="number"?L.target.value?Number(L.target.value):null:L.target.value||null}}),className:"w-full px-3 py-2 border rounded-lg font-mono text-sm",disabled:P})]},S)}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[s.jsxs(T,{variant:"secondary",onClick:()=>i(null),children:[s.jsx(Nn,{className:"w-4 h-4 mr-2"}),"Abbrechen"]}),s.jsxs(T,{onClick:b,disabled:f.isPending,children:[s.jsx(r2,{className:"w-4 h-4 mr-2"}),f.isPending?"Speichern...":"Speichern"]})]})]})}),l&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>o(!1)}),s.jsxs("div",{className:"relative bg-white rounded-xl shadow-2xl w-[90vw] h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Mp,{className:"w-5 h-5 text-blue-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"ER-Diagramm - Datenbankbeziehungen"})]}),s.jsx("button",{onClick:()=>o(!1),className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(Nn,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(Xk,{onSelectTable:F})})]})]})]})}function eC({children:e}){const{isAuthenticated:t,isLoading:n}=Ue();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):t?s.jsx(s.Fragment,{children:e}):s.jsx(oa,{to:"/login",replace:!0})}function tC({children:e}){const{hasPermission:t,developerMode:n}=Ue();return!t("developer:access")||!n?s.jsx(oa,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:e})}function sC(){const{isAuthenticated:e,isLoading:t}=Ue();return t?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):s.jsxs(s.Fragment,{children:[s.jsx(RS,{}),s.jsxs(jN,{children:[s.jsx(Ie,{path:"/login",element:e?s.jsx(oa,{to:"/",replace:!0}):s.jsx(f2,{})}),s.jsxs(Ie,{path:"/",element:s.jsx(eC,{children:s.jsx(h2,{})}),children:[s.jsx(Ie,{index:!0,element:s.jsx(p2,{})}),s.jsx(Ie,{path:"customers",element:s.jsx(g2,{})}),s.jsx(Ie,{path:"customers/new",element:s.jsx(Yp,{})}),s.jsx(Ie,{path:"customers/:id",element:s.jsx(w2,{})}),s.jsx(Ie,{path:"customers/:id/edit",element:s.jsx(Yp,{})}),s.jsx(Ie,{path:"contracts",element:s.jsx(ak,{})}),s.jsx(Ie,{path:"contracts/cockpit",element:s.jsx(wk,{})}),s.jsx(Ie,{path:"contracts/new",element:s.jsx(sx,{})}),s.jsx(Ie,{path:"contracts/:id",element:s.jsx(pk,{})}),s.jsx(Ie,{path:"contracts/:id/edit",element:s.jsx(sx,{})}),s.jsx(Ie,{path:"tasks",element:s.jsx(kk,{})}),s.jsx(Ie,{path:"settings",element:s.jsx(Jk,{})}),s.jsx(Ie,{path:"settings/users",element:s.jsx(Gk,{})}),s.jsx(Ie,{path:"settings/platforms",element:s.jsx(Dk,{})}),s.jsx(Ie,{path:"settings/cancellation-periods",element:s.jsx(Ak,{})}),s.jsx(Ie,{path:"settings/contract-durations",element:s.jsx(Tk,{})}),s.jsx(Ie,{path:"settings/providers",element:s.jsx(Ik,{})}),s.jsx(Ie,{path:"settings/contract-categories",element:s.jsx(_k,{})}),s.jsx(Ie,{path:"settings/view",element:s.jsx(Bk,{})}),s.jsx(Ie,{path:"settings/portal",element:s.jsx(qk,{})}),s.jsx(Ie,{path:"settings/deadlines",element:s.jsx(Vk,{})}),s.jsx(Ie,{path:"settings/email-providers",element:s.jsx(Hk,{})}),s.jsx(Ie,{path:"settings/database-backup",element:s.jsx(Wk,{})}),s.jsx(Ie,{path:"users",element:s.jsx(oa,{to:"/settings/users",replace:!0})}),s.jsx(Ie,{path:"platforms",element:s.jsx(oa,{to:"/settings/platforms",replace:!0})}),s.jsx(Ie,{path:"developer/database",element:s.jsx(tC,{children:s.jsx(Yk,{})})})]}),s.jsx(Ie,{path:"*",element:s.jsx(oa,{to:"/",replace:!0})})]})]})}const nC=new rw({defaultOptions:{queries:{retry:1,staleTime:0,gcTime:0,refetchOnMount:"always"}}});au.createRoot(document.getElementById("root")).render(s.jsx(At.StrictMode,{children:s.jsx(aw,{client:nC,children:s.jsx(PN,{children:s.jsx(LS,{children:s.jsxs(IS,{children:[s.jsx(sC,{}),s.jsx(r1,{position:"top-right",toastOptions:{duration:4e3,style:{background:"#363636",color:"#fff"},success:{iconTheme:{primary:"#10b981",secondary:"#fff"}},error:{iconTheme:{primary:"#ef4444",secondary:"#fff"}}}})]})})})})})); diff --git a/frontend/dist/index.html b/frontend/dist/index.html index 32e37fca..53dfd01d 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -5,8 +5,8 @@ OpenCRM - - + +
diff --git a/frontend/src/components/email/EmailDetail.tsx b/frontend/src/components/email/EmailDetail.tsx index 5f417f70..fb81380c 100644 --- a/frontend/src/components/email/EmailDetail.tsx +++ b/frontend/src/components/email/EmailDetail.tsx @@ -25,7 +25,7 @@ export default function EmailDetail({ onReply, onAssignContract, onDeleted, - isSentFolder = false, + isSentFolder: _isSentFolder = false, isContractView = false, isTrashView = false, onRestored, diff --git a/frontend/src/pages/contracts/ContractForm.tsx b/frontend/src/pages/contracts/ContractForm.tsx index 52c088c8..dfd281e4 100644 --- a/frontend/src/pages/contracts/ContractForm.tsx +++ b/frontend/src/pages/contracts/ContractForm.tsx @@ -35,6 +35,7 @@ export default function ContractForm() { customerId: preselectedCustomerId || '', type: 'ELECTRICITY', status: 'DRAFT', + previousContractId: '', }, }); @@ -61,6 +62,13 @@ export default function ContractForm() { enabled: !!customerId, }); + // Fetch contracts for same customer (for predecessor selection) + const { data: customerContractsData } = useQuery({ + queryKey: ['customer-contracts-for-predecessor', customerId], + queryFn: () => contractApi.getAll({ customerId: parseInt(customerId), limit: 1000 }), + enabled: !!customerId, + }); + // Fetch platforms const { data: platformsData } = useQuery({ queryKey: ['platforms'], @@ -256,6 +264,8 @@ export default function ContractForm() { cancellationConfirmationDate: c.cancellationConfirmationDate ? c.cancellationConfirmationDate.split('T')[0] : '', cancellationConfirmationOptionsDate: c.cancellationConfirmationOptionsDate ? c.cancellationConfirmationOptionsDate.split('T')[0] : '', wasSpecialCancellation: c.wasSpecialCancellation || false, + // Vorgänger-Vertrag + previousContractId: c.previousContractId?.toString() || '', }); // Load simCards if available @@ -427,6 +437,7 @@ export default function ContractForm() { cancellationConfirmationDate: data.cancellationConfirmationDate ? new Date(data.cancellationConfirmationDate) : null, cancellationConfirmationOptionsDate: data.cancellationConfirmationOptionsDate ? new Date(data.cancellationConfirmationOptionsDate) : null, wasSpecialCancellation: data.wasSpecialCancellation || false, + previousContractId: safeParseInt(data.previousContractId) ?? null, }; // Add type-specific details @@ -540,6 +551,11 @@ export default function ContractForm() { const contractCategories = contractCategoriesData?.data?.filter(c => c.isActive).sort((a, b) => a.sortOrder - b.sortOrder) || []; const typeOptions = contractCategories.map(c => ({ value: c.code, label: c.name })); + // Available predecessor contracts (same customer, excluding current contract if editing) + const predecessorContracts = (customerContractsData?.data || []) + .filter(c => !isEdit || c.id !== parseInt(id!)) + .sort((a, b) => new Date(b.startDate || 0).getTime() - new Date(a.startDate || 0).getTime()); + // Get tariffs for selected provider const selectedProvider = providers.find(p => p.id === parseInt(selectedProviderId || '0')); const availableTariffs = selectedProvider?.tariffs?.filter(t => t.isActive) || []; @@ -615,6 +631,19 @@ export default function ContractForm() { {...register('salesPlatformId')} options={platforms.map((p) => ({ value: p.id, label: p.name }))} /> + + {/* Vorgänger-Vertrag auswählen (nur wenn Kunde gewählt) */} + {customerId && ( +