import{V as se,t as K,q as F,r as x,c as Q,j as e,cT as xt,h as Xr,C as Y,W as k,Y as R,i as I,d as w,$ as A,n as tt,bq as rt,cU as Zr,cV as es,cW as ts,p as ke,B as f,cX as Re,S as he,f as U,F as rs,a4 as X,a5 as Z,a6 as ee,a7 as te,a8 as M,bp as ss,ac as ye,ae as Ne,af as De,ag as xe,I as fe,X as Le,U as we,cY as st,br as jt,bs as Gt,bt as Vt,bu as Yt,bv as wt,bw as _t,bx as Tt,by as kt,bz as Rt,E as $e,aC as is,bB as vt,M as re,aA as Mt,aB as ns,a3 as It,aa as os,cZ as ls,bG as hr,v as q,c_ as ft,aM as yr,c$ as as,cv as Nr,d0 as ms,N as Zt,P as us,A as cs,g as ds,d1 as er,D as ps,bR as Ss,d2 as bs,bj as _e,d3 as gs,d4 as Dr,d5 as hs,d6 as ys,ad as xr,aT as it,d7 as Ns,d8 as Ds,d9 as xs,da as vs,db as fs,dc as Es,dd as Os,de as Cs,df as As,dg as Ps,dh as Ls,di as Us,aX as be,bl as Qe,dj as js,dk as Gs,dl as Vs,dm as tr,dn as Ys,at as Ft,bE as ws,bF as _s,a0 as vr,aR as fr,e as Bt,a9 as Ts,R as Xe,bW as Er,dp as ks,aS as Rs,dq as Ms,as as Is,dr as Fs,Z as Bs,bo as qs,x as Hs,ds as zs,dt as Ks,du as $s}from"./index-Ef5HIHwv.js";import{S as z}from"./switch-rB53P3uH.js";import{S as ge,C as rr}from"./separator-B9mtBW3A.js";import{T as qt,a as Ht,b as me,c as B}from"./tabs-CqJ-vF-U.js";import{a as Qs,E as Or,A as Js,S as Ws}from"./EmailLivePreview-BVCmMA0B.js";import{T as Me}from"./textarea-DI4Rh5ZE.js";import{b as Cr,c as Ar,T as Ve,d as ue,e as Pr,a as oe}from"./table-DrgroWVy.js";import{S as Lr}from"./scroll-area-BSXmvPtw.js";import{u as Xs}from"./useEmailTemplates-Dmy9fM1z.js";import{P as le}from"./plus-DVUs0UFy.js";import{S as nt,P as ct}from"./square-pen-BWM0P-fi.js";import{T as de}from"./trash-2-BE5kUvUv.js";import{C as Zs,E as Je}from"./eye-eVxIYKEU.js";import{B as Ur,p as ei,H as ti}from"./parseISO-CdvFKCuZ.js";import{D as ri}from"./index-5CRimzhx.js";import{C as jr}from"./copy-DnQN62QH.js";import{supabase as Ee}from"./client-D7qhFv0L.js";import{S as Ie}from"./save-CPclD06J.js";import{S as si}from"./star-BJeP7_T0.js";import{C as sr}from"./checkbox-BVivpJ34.js";import{T as Gr,S as ir}from"./tag-D-azZ-Vm.js";import{C as ot}from"./circle-plus-BZE0a09n.js";import{f as ii,h as ni,i as oi,j as li,k as ai,l as mi,m as ui}from"./useSupplierBalance-CAc2DLgF.js";import{P as ci}from"./pencil-DayKovnD.js";import{B as di}from"./boxes-buRwjPR-.js";/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const pi=se("CircleUser",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const dt=se("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Si=se("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const nr=se("Link2Off",[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Vr=se("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const zt=se("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const or=se("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const We=se("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Kt=se("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const bi=se("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.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const qe=se("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"}]]);function gi(){const t=K(),{toast:r}=F(),[o,l]=x.useState(!1),[s,n]=x.useState(!1),{data:m}=Q({queryKey:["easygds-health-card"],queryFn:es,refetchInterval:3e4}),{data:i=[]}=Q({queryKey:["easygds-outages"],queryFn:()=>ts(20),enabled:s}),a=m?m.state==="force_readonly"?{color:"bg-amber-100 text-amber-800 border-amber-200",label:"Read-only (manual)",icon:e.jsxDEV(xt,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:43,columnNumber:143},this)}:m.state==="closed"&&m.ok?{color:"bg-emerald-100 text-emerald-800 border-emerald-200",label:"Connected",icon:e.jsxDEV(qe,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:44,columnNumber:145},this)}:m.state==="half_open"?{color:"bg-amber-100 text-amber-800 border-amber-200",label:"Probing",icon:e.jsxDEV(qe,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:45,columnNumber:127},this)}:{color:"bg-red-100 text-red-800 border-red-200",label:"Unreachable",icon:e.jsxDEV(bi,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:46,columnNumber:91},this)}:{color:"bg-slate-100 text-slate-700",label:"—",icon:e.jsxDEV(qe,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:42,columnNumber:83},this)},h=(m==null?void 0:m.state)==="force_readonly",u=async g=>{l(!0);try{await Zr(g),t.invalidateQueries({queryKey:["easygds-health-card"]}),t.invalidateQueries({queryKey:["easygds-health"]}),r({title:g?"Read-only mode enabled":"Read-only mode disabled",description:g?"Upstream EasyGDS calls will fail-fast until you turn this off.":"Live calls re-enabled. Cache will refresh on next user activity."})}catch(c){r({variant:"destructive",title:"Failed to toggle",description:c==null?void 0:c.message})}finally{l(!1)}};let d="";if(m!=null&&m.last_call_at)try{d=Xr(new Date(m.last_call_at),{addSuffix:!0})}catch{}return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center justify-between gap-2",children:[e.jsxDEV("span",{className:"flex items-center gap-2",children:[e.jsxDEV(qe,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:78,columnNumber:13},this)," EasyGDS Connection"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:77,columnNumber:11},this),e.jsxDEV(I,{variant:"outline",className:`text-[11px] inline-flex items-center gap-1 ${a.color}`,children:[a.icon," ",a.label]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:80,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:76,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:75,columnNumber:7},this),e.jsxDEV(w,{className:"space-y-4",children:[e.jsxDEV("p",{className:"text-sm text-gray-600",children:"Live status of the upstream EasyGDS API. The platform automatically falls back to cached data and disables write actions when the connection drops. Operations resume on its own when the API recovers — no manual intervention needed in normal cases."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:86,columnNumber:9},this),e.jsxDEV("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[e.jsxDEV("div",{className:"rounded-md border bg-slate-50 p-2",children:[e.jsxDEV("div",{className:"text-[10px] uppercase tracking-wider text-slate-500",children:"Last successful contact"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:95,columnNumber:13},this),e.jsxDEV("div",{className:"mt-0.5",children:d||"(never)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:96,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:94,columnNumber:11},this),e.jsxDEV("div",{className:"rounded-md border bg-slate-50 p-2",children:[e.jsxDEV("div",{className:"text-[10px] uppercase tracking-wider text-slate-500",children:"Last error"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:99,columnNumber:13},this),e.jsxDEV("div",{className:"mt-0.5 truncate",title:(m==null?void 0:m.last_error)||"",children:(m==null?void 0:m.last_error)||"—"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:100,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:98,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:93,columnNumber:9},this),e.jsxDEV("div",{className:"flex items-center justify-between rounded-md border p-3",children:[e.jsxDEV("div",{className:"space-y-0.5",children:[e.jsxDEV(A,{className:"flex items-center gap-2",children:[e.jsxDEV(xt,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:110,columnNumber:15},this)," Force read-only mode"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:109,columnNumber:13},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"Disable all upstream EasyGDS calls. Use this during planned maintenance windows so the platform doesn't keep retrying. Cache stays available for reads."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:112,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:108,columnNumber:11},this),e.jsxDEV(z,{checked:!!h,onCheckedChange:u,disabled:o},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:117,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:107,columnNumber:9},this),e.jsxDEV("div",{children:[e.jsxDEV("button",{className:"text-xs flex items-center gap-1 text-slate-600 hover:text-slate-900",onClick:()=>n(g=>!g),children:[e.jsxDEV(tt,{className:`h-3 w-3 transition-transform ${s?"rotate-90":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:130,columnNumber:13},this),"Outage history"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:126,columnNumber:11},this),s&&e.jsxDEV("div",{className:"mt-2 border rounded-md divide-y text-xs max-h-64 overflow-y-auto",children:i.length===0?e.jsxDEV("div",{className:"p-3 text-muted-foreground text-center",children:"No outages logged yet."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:136,columnNumber:17},this):i.map(g=>e.jsxDEV("div",{className:"p-2 flex items-start gap-2",children:[e.jsxDEV(rt,{className:`h-3.5 w-3.5 mt-0.5 ${g.resolved_at?"text-emerald-600":"text-red-600"}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:140,columnNumber:21},this),e.jsxDEV("div",{className:"flex-1",children:[e.jsxDEV("div",{className:"font-medium",children:g.message||"(no detail)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:142,columnNumber:23},this),e.jsxDEV("div",{className:"text-[11px] text-muted-foreground",children:[new Date(g.noticed_at).toLocaleString(),g.resolved_at?e.jsxDEV(e.Fragment,{children:[" · Resolved after ",Math.round((g.duration_ms||0)/1e3),"s"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:148,columnNumber:27},this):e.jsxDEV(e.Fragment,{children:" · Ongoing"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:150,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:145,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:141,columnNumber:21},this)]},g.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:139,columnNumber:19},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:134,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:125,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:85,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EasyGDSResilienceCard.tsx",lineNumber:74,columnNumber:5},this)}function hi(){const[t,r]=x.useState(!1),[o,l]=x.useState(null),[s,n]=x.useState(!0),[m,i]=x.useState(!1),[a,h]=x.useState({name:"",subject:"",body:"",template_type:"customer",reminder_request_type:"",ref_display:"",is_active:!0}),[u,d]=x.useState(""),[g,c]=x.useState("all"),[N,D]=x.useState(1),y=10,{templates:v,loading:P,createTemplate:S,updateTemplate:p,deleteTemplate:b}=Xs(),{user:V}=ke(),C=x.useMemo(()=>{let L=v.filter(Se=>{const ne=Se.name.toLowerCase().includes(u.toLowerCase())||Se.subject.toLowerCase().includes(u.toLowerCase()),Wr=g==="all"||Se.template_type===g;return ne&&Wr});const $=L.length,ie=Math.ceil($/y),G=(N-1)*y;return{items:L.slice(G,G+y),totalItems:$,totalPages:ie,currentPage:N,hasNextPage:N<ie,hasPrevPage:N>1}},[v,u,g,N]),O=L=>{d(L),D(1)},T=L=>{c(L),D(1)},_=async L=>{L.preventDefault();const $={...a,reminder_request_type:a.template_type==="supplier"&&a.reminder_request_type?a.reminder_request_type:null,ref_display:a.ref_display||null};try{o?await p(o.id,$):await S({...$,created_by:(V==null?void 0:V.id)||""}),r(!1),l(null),E()}catch(ie){console.error("Error saving email template:",ie)}},E=()=>{h({name:"",subject:"",body:"",template_type:"customer",reminder_request_type:"",ref_display:"",is_active:!0}),n(!0),i(!1)},j=L=>{l(L),h({name:L.name,subject:L.subject,body:L.body,template_type:L.template_type,reminder_request_type:L.reminder_request_type||"",ref_display:L.ref_display||"",is_active:L.is_active}),r(!0)},J=async L=>{confirm("Are you sure you want to delete this email template?")&&await b(L)},Ue=L=>{switch(L){case"supplier":return"bg-blue-100 text-blue-800";case"customer":return"bg-green-100 text-green-800";case"voucher":return"bg-purple-100 text-purple-800";case"acknowledgment":return"bg-orange-100 text-orange-800";default:return"bg-gray-100 text-gray-800"}};return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:[e.jsxDEV("div",{className:"flex justify-between items-center",children:[e.jsxDEV(R,{children:"Email Templates"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:162,columnNumber:11},this),e.jsxDEV(f,{onClick:()=>r(!0),children:[e.jsxDEV(le,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:164,columnNumber:13},this),"Add Template"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:163,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:161,columnNumber:9},this),e.jsxDEV(Re,{children:"Manage email templates for different communication types"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:168,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:160,columnNumber:7},this),e.jsxDEV(w,{children:[e.jsxDEV("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxDEV("div",{className:"relative flex-1",children:[e.jsxDEV(he,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:176,columnNumber:13},this),e.jsxDEV(U,{placeholder:"Search templates by name or subject...",value:u,onChange:L=>O(L.target.value),className:"pl-10"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:177,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:175,columnNumber:11},this),e.jsxDEV("div",{className:"flex items-center gap-2 min-w-[200px]",children:[e.jsxDEV(rs,{className:"h-4 w-4 text-muted-foreground"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:185,columnNumber:13},this),e.jsxDEV(X,{value:g,onValueChange:T,children:[e.jsxDEV(Z,{className:"bg-background",children:e.jsxDEV(ee,{placeholder:"Filter by type"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:188,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:187,columnNumber:15},this),e.jsxDEV(te,{className:"bg-background border shadow-md z-50",children:[e.jsxDEV(M,{value:"all",children:"All Types"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:191,columnNumber:17},this),e.jsxDEV(M,{value:"supplier",children:"Supplier"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:192,columnNumber:17},this),e.jsxDEV(M,{value:"customer",children:"Customer"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:193,columnNumber:17},this),e.jsxDEV(M,{value:"voucher",children:"Voucher"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:194,columnNumber:17},this),e.jsxDEV(M,{value:"acknowledgment",children:"Acknowledgment"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:195,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:190,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:186,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:184,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:174,columnNumber:9},this),P?e.jsxDEV("div",{className:"flex items-center justify-center py-8",children:e.jsxDEV("div",{className:"text-muted-foreground",children:"Loading email templates..."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:203,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:202,columnNumber:11},this):e.jsxDEV(e.Fragment,{children:[e.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[e.jsxDEV("div",{className:"text-sm text-muted-foreground",children:["Showing ",C.items.length," of ",C.totalItems," templates",u&&e.jsxDEV("span",{children:[' matching "',u,'"']},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:212,columnNumber:19},this),g!=="all"&&e.jsxDEV("span",{children:[" filtered by ",g]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:215,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:209,columnNumber:15},this),(u||g!=="all")&&e.jsxDEV(f,{variant:"ghost",size:"sm",onClick:()=>{d(""),c("all"),D(1)},children:"Clear filters"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:219,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:208,columnNumber:13},this),e.jsxDEV("div",{className:"rounded-md border",children:e.jsxDEV(Cr,{children:[e.jsxDEV(Ar,{children:e.jsxDEV(Ve,{children:[e.jsxDEV(ue,{children:"Name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:238,columnNumber:21},this),e.jsxDEV(ue,{children:"Type"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:239,columnNumber:21},this),e.jsxDEV(ue,{children:"Subject"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:240,columnNumber:21},this),e.jsxDEV(ue,{className:"text-right",children:"Actions"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:241,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:237,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:236,columnNumber:17},this),e.jsxDEV(Pr,{children:C.items.length===0?e.jsxDEV(Ve,{children:e.jsxDEV(oe,{colSpan:4,className:"text-center py-8",children:e.jsxDEV("div",{className:"text-muted-foreground",children:u||g!=="all"?"No templates match your current filters.":"No email templates found."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:248,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:247,columnNumber:23},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:246,columnNumber:21},this):C.items.map(L=>e.jsxDEV(Ve,{children:[e.jsxDEV(oe,{className:"font-medium",children:L.name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:258,columnNumber:25},this),e.jsxDEV(oe,{children:e.jsxDEV("div",{className:"flex flex-col gap-1",children:[e.jsxDEV(I,{className:Ue(L.template_type),children:L.template_type},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:261,columnNumber:29},this),L.template_type==="supplier"&&L.reminder_request_type&&e.jsxDEV(I,{variant:"outline",className:"text-[10px] w-fit",children:["Reminder: ",L.reminder_request_type.replace("_"," ")]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:265,columnNumber:31},this),L.ref_display&&e.jsxDEV(I,{variant:"outline",className:"text-[10px] w-fit",children:["Header: ",L.ref_display==="both"?"supplier + booking":L.ref_display==="supplier"?"supplier ref":L.ref_display==="booking"?"booking":"no ref"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:270,columnNumber:31},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:260,columnNumber:27},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:259,columnNumber:25},this),e.jsxDEV(oe,{className:"max-w-xs truncate",children:L.subject},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:282,columnNumber:25},this),e.jsxDEV(oe,{children:e.jsxDEV("div",{className:"flex justify-end space-x-2",children:[e.jsxDEV(f,{variant:"outline",size:"sm",onClick:()=>j(L),children:e.jsxDEV(nt,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:290,columnNumber:31},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:285,columnNumber:29},this),e.jsxDEV(f,{variant:"outline",size:"sm",onClick:()=>J(L.id),children:e.jsxDEV(de,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:297,columnNumber:31},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:292,columnNumber:29},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:284,columnNumber:27},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:283,columnNumber:25},this)]},L.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:257,columnNumber:23},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:244,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:235,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:234,columnNumber:13},this),C.totalPages>1&&e.jsxDEV("div",{className:"flex items-center justify-between mt-4",children:[e.jsxDEV("div",{className:"text-sm text-muted-foreground",children:["Page ",C.currentPage," of ",C.totalPages]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:311,columnNumber:17},this),e.jsxDEV("div",{className:"flex items-center space-x-2",children:[e.jsxDEV(f,{variant:"outline",size:"sm",onClick:()=>D(N-1),disabled:!C.hasPrevPage,children:[e.jsxDEV(ss,{className:"h-4 w-4 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:321,columnNumber:21},this),"Previous"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:315,columnNumber:19},this),e.jsxDEV("div",{className:"flex items-center space-x-1",children:Array.from({length:C.totalPages},(L,$)=>$+1).filter(L=>L===1||L===C.totalPages||Math.abs(L-N)<=2).map((L,$,ie)=>e.jsxDEV("div",{className:"flex items-center",children:[$>0&&ie[$-1]!==L-1&&e.jsxDEV("span",{className:"px-2 text-muted-foreground",children:"..."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:337,columnNumber:29},this),e.jsxDEV(f,{variant:L===N?"default":"outline",size:"sm",onClick:()=>D(L),className:"w-8 h-8 p-0",children:L},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:339,columnNumber:27},this)]},L,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:335,columnNumber:25},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:326,columnNumber:19},this),e.jsxDEV(f,{variant:"outline",size:"sm",onClick:()=>D(N+1),disabled:!C.hasNextPage,children:["Next",e.jsxDEV(tt,{className:"h-4 w-4 ml-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:358,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:351,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:314,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:310,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:206,columnNumber:11},this),e.jsxDEV(ye,{open:t,onOpenChange:r,children:e.jsxDEV(Ne,{className:"max-w-6xl h-[90vh] flex flex-col",children:[e.jsxDEV(De,{className:"flex-shrink-0 pb-4",children:e.jsxDEV(xe,{children:o?"Edit Email Template":"Add Email Template"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:369,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:368,columnNumber:13},this),e.jsxDEV("div",{className:"flex-1 overflow-hidden",children:e.jsxDEV(Lr,{className:"h-full pr-4",children:e.jsxDEV("form",{onSubmit:_,className:"space-y-6 pb-6",children:[e.jsxDEV("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Template Name *"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:379,columnNumber:21},this),e.jsxDEV(U,{value:a.name,onChange:L=>h({...a,name:L.target.value}),required:!0},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:380,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:378,columnNumber:19},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Template Type *"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:388,columnNumber:21},this),e.jsxDEV(X,{value:a.template_type,onValueChange:L=>h({...a,template_type:L}),children:[e.jsxDEV(Z,{children:e.jsxDEV(ee,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:391,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:390,columnNumber:23},this),e.jsxDEV(te,{children:[e.jsxDEV(M,{value:"supplier",children:"Supplier"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:394,columnNumber:25},this),e.jsxDEV(M,{value:"customer",children:"Customer"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:395,columnNumber:25},this),e.jsxDEV(M,{value:"voucher",children:"Voucher"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:396,columnNumber:25},this),e.jsxDEV(M,{value:"acknowledgment",children:"Acknowledgment"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:397,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:393,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:389,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:387,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:377,columnNumber:17},this),a.template_type==="supplier"&&e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:["Reminder type ",e.jsxDEV("span",{className:"text-muted-foreground text-xs",children:"(when sent from a booking)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:409,columnNumber:42},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:409,columnNumber:21},this),e.jsxDEV(X,{value:a.reminder_request_type||"none",onValueChange:L=>h({...a,reminder_request_type:L==="none"?"":L}),children:[e.jsxDEV(Z,{children:e.jsxDEV(ee,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:418,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:417,columnNumber:23},this),e.jsxDEV(te,{children:[e.jsxDEV(M,{value:"none",children:"None — operator picks at send time"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:421,columnNumber:25},this),e.jsxDEV(M,{value:"hcn",children:"HCN (Hotel Confirmation Number)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:422,columnNumber:25},this),e.jsxDEV(M,{value:"cancellation",children:"Cancellation"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:423,columnNumber:25},this),e.jsxDEV(M,{value:"change_request",children:"Change request"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:424,columnNumber:25},this),e.jsxDEV(M,{value:"refund",children:"Refund"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:425,columnNumber:25},this),e.jsxDEV(M,{value:"other",children:"Other"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:426,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:420,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:410,columnNumber:21},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"When this template is used to email a supplier from the Booking Details page, the reminder created on send will default to this type. SLA hours come from Settings → System → Reminders."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:429,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:408,columnNumber:19},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Reference shown in email header"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:443,columnNumber:19},this),e.jsxDEV(X,{value:a.ref_display||"auto",onValueChange:L=>h({...a,ref_display:L==="auto"?"":L}),children:[e.jsxDEV(Z,{children:e.jsxDEV(ee,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:452,columnNumber:23},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:451,columnNumber:21},this),e.jsxDEV(te,{children:[e.jsxDEV(M,{value:"auto",children:["Auto — ",a.template_type==="supplier"?"Supplier ref":"Booking code"," ","(based on template type)"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:455,columnNumber:23},this),e.jsxDEV(M,{value:"supplier",children:"Supplier reference only"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:459,columnNumber:23},this),e.jsxDEV(M,{value:"booking",children:"Booking code only"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:460,columnNumber:23},this),e.jsxDEV(M,{value:"both",children:"Both — supplier ref FIRST, then booking"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:461,columnNumber:23},this),e.jsxDEV(M,{value:"none",children:"None (suppress)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:462,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:454,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:444,columnNumber:19},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:`Supplier templates default to the supplier's own reference (so they can locate their record fast). Customer templates default to the booking code. Pick "Both" to show both — supplier ref appears first.`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:465,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:442,columnNumber:17},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Subject *"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:473,columnNumber:19},this),e.jsxDEV(U,{value:a.subject,onChange:L=>h({...a,subject:L.target.value}),placeholder:"Use {{booking_ref}} for dynamic booking reference",required:!0},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:474,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:472,columnNumber:17},this),e.jsxDEV("div",{className:"space-y-4",children:[e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV(A,{children:"Email Body *"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:484,columnNumber:21},this),e.jsxDEV("div",{className:"flex items-center space-x-4",children:[e.jsxDEV("div",{className:"flex items-center space-x-2",children:[e.jsxDEV(z,{checked:s,onCheckedChange:n},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:487,columnNumber:25},this),e.jsxDEV(A,{className:"text-sm",children:"HTML Mode"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:491,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:486,columnNumber:23},this),e.jsxDEV("div",{className:"flex items-center space-x-2",children:e.jsxDEV(f,{type:"button",variant:"outline",size:"sm",onClick:()=>i(!m),children:[m?e.jsxDEV(Zs,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:500,columnNumber:42},this):e.jsxDEV(Je,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:500,columnNumber:73},this),m?"Edit":"Preview"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:494,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:493,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:485,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:483,columnNumber:19},this),e.jsxDEV("div",{className:"bg-muted/30 p-3 rounded-md",children:[e.jsxDEV(A,{className:"text-sm font-medium mb-2 block",children:"Quick Insert Variables:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:509,columnNumber:21},this),e.jsxDEV("div",{className:"flex flex-wrap gap-2",children:["{{customer_name}}","{{booking_ref}}","{{supplier_ref}}","{{company_name}}","{{departure_date}}","{{destination}}","{{total_amount}}","{{passenger_count}}","{{hcn_number}}","{{tour_confirmation_number}}","{{ops_user_signature}}"].map(L=>e.jsxDEV(f,{type:"button",variant:"outline",size:"sm",className:"text-xs h-7",onClick:()=>{const $=a.body+" "+L;h({...a,body:$})},children:L},L,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:517,columnNumber:25},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:510,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:508,columnNumber:19},this),m?e.jsxDEV(Qs,{bodyHtml:a.body,label:"Recipient view (live)",className:"min-h-[500px]"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:538,columnNumber:21},this):s?e.jsxDEV(Or,{value:a.body,onChange:L=>h({...a,body:L}),minHeight:500,placeholder:"Write the template body. Use {{booking_ref}}, {{customer_name}}, {{services_table}}, etc. — they'll be filled at send time."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:544,columnNumber:21},this):e.jsxDEV(Me,{value:a.body,onChange:L=>h({...a,body:L.target.value}),placeholder:`Use {{booking_ref}} for dynamic booking reference

Example:
Dear {{customer_name}},

Your booking {{booking_ref}} has been confirmed.

We appreciate your quick response.`,rows:20,required:!0,className:"font-mono text-sm resize-vertical min-h-[500px]"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:551,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:482,columnNumber:17},this),e.jsxDEV("div",{className:"text-sm text-muted-foreground bg-muted/30 p-4 rounded-md",children:[e.jsxDEV("p",{children:e.jsxDEV("strong",{children:"Available placeholders:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:563,columnNumber:22},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:563,columnNumber:19},this),e.jsxDEV("div",{className:"grid grid-cols-2 gap-1 mt-2 text-xs",children:[e.jsxDEV("p",{children:["{{booking_ref}}"," - Booking reference number"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:565,columnNumber:21},this),e.jsxDEV("p",{children:["{{company_name}}"," - Company name"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:566,columnNumber:21},this),e.jsxDEV("p",{children:["{{customer_name}}"," - Customer full name"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:567,columnNumber:21},this),e.jsxDEV("p",{children:["{{departure_date}}"," - Departure date"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:568,columnNumber:21},this),e.jsxDEV("p",{children:["{{destination}}"," - Destination"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:569,columnNumber:21},this),e.jsxDEV("p",{children:["{{total_amount}}"," - Total amount"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:570,columnNumber:21},this),e.jsxDEV("p",{children:["{{passenger_count}}"," - Number of passengers"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:571,columnNumber:21},this),e.jsxDEV("p",{children:["{{hcn_number}}"," - HCN/Confirmation number"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:572,columnNumber:21},this),e.jsxDEV("p",{children:["{{eticket_id}}"," - E-ticket ID"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:573,columnNumber:21},this),e.jsxDEV("p",{children:["{{tour_confirmation_number}}"," - Tour confirmation"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:574,columnNumber:21},this),e.jsxDEV("p",{children:["{{transfer_confirmation_number}}"," - Transfer confirmation"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:575,columnNumber:21},this),e.jsxDEV("p",{children:["{{supplier_name}}"," - Supplier name"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:576,columnNumber:21},this),e.jsxDEV("p",{children:["{{supplier_ref}}"," - Supplier reference (best per booking)"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:577,columnNumber:21},this),e.jsxDEV("p",{children:["{{ops_user_signature}}"," - Your signature (Settings → Profile)"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:578,columnNumber:21},this),e.jsxDEV("p",{children:["{{currency}}"," - Currency code"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:579,columnNumber:21},this),e.jsxDEV("p",{children:["{{check_in_date}}"," - Hotel check-in date"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:580,columnNumber:21},this),e.jsxDEV("p",{children:["{{check_out_date}}"," - Hotel check-out date"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:581,columnNumber:21},this),e.jsxDEV("p",{children:["{{request_number}}"," - Support request number"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:582,columnNumber:21},this),e.jsxDEV("p",{children:["{{customer_first_name}}"," - Customer first name"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:583,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:564,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:562,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:376,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:375,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:374,columnNumber:13},this),e.jsxDEV("div",{className:"flex justify-end space-x-2 pt-4 border-t bg-background flex-shrink-0",children:[e.jsxDEV(f,{type:"button",variant:"outline",onClick:()=>{r(!1),l(null),E()},children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:591,columnNumber:15},this),e.jsxDEV(f,{type:"submit",form:"template-form",onClick:_,children:o?"Update":"Create"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:598,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:590,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:367,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:366,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:172,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailTemplateSettings.tsx",lineNumber:159,columnNumber:5},this)}const lr={name:"",description:"",imap_host:"",imap_port:993,imap_username:"",imap_password:"",imap_use_ssl:!0,auto_process:!0,check_interval:5,is_active:!0,owner_type:"system",owner_id:null,display_label:null};async function ve(t,r){const o=localStorage.getItem("platform_token"),s=await(await fetch(`/api${t}`,{headers:{"Content-Type":"application/json",...o?{Authorization:`Bearer ${o}`}:{}},...r})).json();if(s.error)throw new Error(s.error.message||s.error);return s.data}function ar({personalOnly:t=!1}={}){const{toast:r}=F(),{user:o,profile:l}=ke(),s=(l==null?void 0:l.role)==="admin"&&!t,[n,m]=x.useState([]),[i,a]=x.useState(null),[h,u]=x.useState(!1),[d,g]=x.useState(!1),[c,N]=x.useState(!1);x.useEffect(()=>{D()},[]);const D=async()=>{try{const E=await ve("/email-inboxes");m(E||[])}catch(E){console.error("Error loading inboxes:",E),r({title:"Error",description:E.message||"Failed to load inbox configurations.",variant:"destructive"})}},y=async()=>{if(i){g(!0);try{const E={...i};E.imap_password==="********"&&delete E.imap_password,i.id?await ve(`/email-inboxes/${encodeURIComponent(i.id)}`,{method:"PATCH",body:JSON.stringify(E)}):await ve("/email-inboxes",{method:"POST",body:JSON.stringify(E)}),r({title:"Inbox saved",description:"Email inbox configuration has been saved."}),u(!1),a(null),D()}catch(E){r({title:"Error",description:E.message||"Failed to save inbox settings.",variant:"destructive"})}finally{g(!1)}}},v=async E=>{if(E.id&&window.confirm(`Delete inbox "${E.name}"? This cannot be undone.`))try{await ve(`/email-inboxes/${encodeURIComponent(E.id)}`,{method:"DELETE"}),r({title:"Inbox deleted"}),D(),(i==null?void 0:i.id)===E.id&&(a(null),u(!1))}catch(j){r({title:"Error",description:j.message||"Failed to delete inbox.",variant:"destructive"})}},[P,S]=x.useState(null),p=async E=>{if(E.id){S(E.id);try{const j=await ve(`/email-inboxes/${encodeURIComponent(E.id)}/poll`,{method:"POST",body:JSON.stringify({full:!0})});r({title:"Full fetch complete",description:`${j.ingested} new email(s) saved · ${j.skipped} already in DB · ${j.errors} error(s)`}),D()}catch(j){r({title:"Full fetch failed",description:j.message||"Could not fetch all emails.",variant:"destructive"})}finally{S(null)}}},b=async()=>{if(i){N(!0);try{const E={imap_host:i.imap_host,imap_port:i.imap_port,imap_username:i.imap_username,imap_use_ssl:i.imap_use_ssl};i.imap_password&&i.imap_password!=="********"&&(E.imap_password=i.imap_password),i.id&&(E.id=i.id);const j=await ve("/email-inboxes/test",{method:"POST",body:JSON.stringify(E)});r({title:"Connection test",description:j.message||"Connection successful!"})}catch(E){r({title:"Test failed",description:E.message||"Unable to connect.",variant:"destructive"})}finally{N(!1)}}},V=E=>{a(E?{...E,imap_password:""}:{...lr}),u(!0)},C=()=>{a(null),u(!1)},O=x.useMemo(()=>n.filter(E=>t?E.owner_type==="user":!0),[n,t]),T=()=>{const E={...lr,owner_type:t?"user":s?"system":"user",owner_id:(t||!s)&&(o==null?void 0:o.id)||null};a(E),u(!0)};if(h&&i)return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"flex items-center space-x-2",children:[e.jsxDEV(fe,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:240,columnNumber:15},this),e.jsxDEV("span",{children:i.id?"Edit Inbox":"Add New Inbox"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:241,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:239,columnNumber:13},this),e.jsxDEV(f,{variant:"ghost",size:"sm",onClick:C,children:e.jsxDEV(Le,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:244,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:243,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:238,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:237,columnNumber:9},this),e.jsxDEV(w,{className:"space-y-4",children:[e.jsxDEV("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"name",children:"Inbox Name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:251,columnNumber:15},this),e.jsxDEV(U,{id:"name",value:i.name,onChange:E=>a({...i,name:E.target.value}),placeholder:"e.g., Support Inbox"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:252,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:250,columnNumber:13},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"description",children:"Description"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:257,columnNumber:15},this),e.jsxDEV(U,{id:"description",value:i.description||"",onChange:E=>a({...i,description:E.target.value}),placeholder:"Optional description"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:258,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:256,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:249,columnNumber:11},this),e.jsxDEV("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"imap_host",children:"IMAP Host"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:266,columnNumber:15},this),e.jsxDEV(U,{id:"imap_host",value:i.imap_host,onChange:E=>a({...i,imap_host:E.target.value}),placeholder:"imap.gmail.com"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:267,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:265,columnNumber:13},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"imap_port",children:"IMAP Port"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:272,columnNumber:15},this),e.jsxDEV(U,{id:"imap_port",type:"number",value:i.imap_port,onChange:E=>a({...i,imap_port:parseInt(E.target.value)||993}),placeholder:"993"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:273,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:271,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:264,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"imap_username",children:"Username/Email"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:280,columnNumber:13},this),e.jsxDEV(U,{id:"imap_username",value:i.imap_username,onChange:E=>a({...i,imap_username:E.target.value}),placeholder:"your-email@domain.com"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:281,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:279,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"imap_password",children:"Password / App Password"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:287,columnNumber:13},this),e.jsxDEV(U,{id:"imap_password",type:"password",value:i.imap_password,onChange:E=>a({...i,imap_password:E.target.value}),placeholder:i.id?"Leave blank to keep current password":"Your email password or app password"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:288,columnNumber:13},this),i.id&&e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"Password is never sent back to the browser — leave the field alone to keep the stored one."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:292,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:286,columnNumber:11},this),e.jsxDEV(ge,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:298,columnNumber:11},this),e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"space-y-0.5",children:[e.jsxDEV(A,{children:"Use SSL/TLS"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:302,columnNumber:15},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground",children:"Enable secure connection"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:303,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:301,columnNumber:13},this),e.jsxDEV(z,{checked:i.imap_use_ssl,onCheckedChange:E=>a({...i,imap_use_ssl:E})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:305,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:300,columnNumber:11},this),e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"space-y-0.5",children:[e.jsxDEV(A,{children:"Auto Process Emails"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:311,columnNumber:15},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground",children:"Automatically process incoming emails"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:312,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:310,columnNumber:13},this),e.jsxDEV(z,{checked:i.auto_process,onCheckedChange:E=>a({...i,auto_process:E})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:314,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:309,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"check_interval",children:"Check Interval (minutes)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:319,columnNumber:13},this),e.jsxDEV(U,{id:"check_interval",type:"number",value:i.check_interval,onChange:E=>a({...i,check_interval:parseInt(E.target.value)||5}),placeholder:"5",min:"1",max:"60"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:320,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:318,columnNumber:11},this),e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"space-y-0.5",children:[e.jsxDEV(A,{children:"Enable Inbox Monitoring"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:327,columnNumber:15},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground",children:"Activate email monitoring"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:328,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:326,columnNumber:13},this),e.jsxDEV(z,{checked:i.is_active,onCheckedChange:E=>a({...i,is_active:E})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:330,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:325,columnNumber:11},this),e.jsxDEV(ge,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:334,columnNumber:11},this),s?e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Owner"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:340,columnNumber:15},this),e.jsxDEV(X,{value:i.owner_type,onValueChange:E=>a({...i,owner_type:E,owner_id:E==="system"?null:i.owner_id}),disabled:!!i.id,children:[e.jsxDEV(Z,{children:e.jsxDEV(ee,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:346,columnNumber:32},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:346,columnNumber:17},this),e.jsxDEV(te,{children:[e.jsxDEV(M,{value:"system",children:"System (shared by all Ops)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:348,columnNumber:19},this),e.jsxDEV(M,{value:"app",children:"Application (one app)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:349,columnNumber:19},this),e.jsxDEV(M,{value:"user",children:"Personal (one user)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:350,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:347,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:341,columnNumber:15},this),(i.owner_type==="app"||i.owner_type==="user")&&e.jsxDEV(U,{value:i.owner_id||"",onChange:E=>a({...i,owner_id:E.target.value||null}),placeholder:i.owner_type==="app"?"app_id (UUID)":"platform_users.id (blank = self)",className:"font-mono text-xs",disabled:!!i.id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:354,columnNumber:17},this),i.id&&e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"Owner can't be changed after the inbox is created. Delete + recreate to reassign."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:363,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:339,columnNumber:13},this):e.jsxDEV("div",{className:"rounded-md border bg-slate-50/60 p-3 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxDEV(we,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:370,columnNumber:15},this),e.jsxDEV("span",{children:["This will be saved as your ",e.jsxDEV("strong",{children:"personal"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:371,columnNumber:48},this)," inbox — only you and Ops admins can see it."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:371,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:369,columnNumber:13},this),e.jsxDEV("div",{className:"flex space-x-2",children:[e.jsxDEV(f,{onClick:y,disabled:d||!i.name||!i.imap_host||!i.imap_username||!i.id&&!i.imap_password,className:"flex-1",children:d?"Saving...":"Save Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:376,columnNumber:13},this),e.jsxDEV(f,{variant:"outline",onClick:b,disabled:c||!i.imap_host||!i.imap_username,children:[e.jsxDEV(st,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:384,columnNumber:15},this),c?"Testing...":"Test Connection"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:382,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:375,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:248,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:236,columnNumber:7},this);const _=[{key:"user",label:"Personal inboxes",icon:we,rows:O.filter(E=>E.owner_type==="user")},{key:"app",label:"Application inboxes",icon:Ur,rows:O.filter(E=>E.owner_type==="app")},{key:"system",label:"System inboxes (shared by all Ops)",icon:Kt,rows:O.filter(E=>E.owner_type==="system")}].filter(E=>t?E.key==="user":!0);return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"flex items-center space-x-2",children:[e.jsxDEV(fe,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:406,columnNumber:13},this),e.jsxDEV("span",{children:t?"My inboxes":"Email Inbox Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:407,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:405,columnNumber:11},this),e.jsxDEV(f,{onClick:T,children:[e.jsxDEV(le,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:410,columnNumber:13},this),"Add Inbox"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:409,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:404,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:403,columnNumber:7},this),e.jsxDEV(w,{children:O.length===0?e.jsxDEV("div",{className:"text-center py-8",children:[e.jsxDEV(fe,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:418,columnNumber:13},this),e.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"No Email Inboxes Configured"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:419,columnNumber:13},this),e.jsxDEV("p",{className:"text-muted-foreground mb-4",children:t?"Add your personal IMAP inbox so the system can pull emails sent to you.":"Add your first email inbox to start monitoring incoming emails."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:420,columnNumber:13},this),e.jsxDEV(f,{onClick:T,children:[e.jsxDEV(le,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:426,columnNumber:15},this),"Add Your First Inbox"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:425,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:417,columnNumber:11},this):e.jsxDEV("div",{className:"space-y-5",children:_.map(E=>E.rows.length===0?null:e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[e.jsxDEV(E.icon,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:435,columnNumber:19},this),e.jsxDEV("span",{children:E.label},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:436,columnNumber:19},this),e.jsxDEV("span",{className:"text-[10px]",children:["(",E.rows.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:437,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:434,columnNumber:17},this),E.rows.map(j=>e.jsxDEV(Y,{className:"border",children:e.jsxDEV(w,{className:"p-4",children:e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"flex-1",children:[e.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxDEV("h3",{className:"font-medium",children:j.display_label||j.name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:445,columnNumber:25},this),e.jsxDEV("span",{className:`px-2 py-1 text-xs rounded ${j.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:j.is_active?"Active":"Inactive"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:446,columnNumber:25},this),j.owner_type==="app"&&j.owner_id&&e.jsxDEV("code",{className:"text-[10px] font-mono text-muted-foreground",children:["app:",j.owner_id.slice(0,8),"…"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:450,columnNumber:27},this),j.owner_type==="user"&&j.owner_id&&j.owner_id!==(o==null?void 0:o.id)&&e.jsxDEV("code",{className:"text-[10px] font-mono text-muted-foreground",children:["user:",j.owner_id.slice(0,8),"…"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:453,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:444,columnNumber:23},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground mt-1",children:j.description||j.imap_username},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:456,columnNumber:23},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:[j.imap_host,":",j.imap_port," · check every ",j.check_interval," min"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:459,columnNumber:23},this),j.last_polled_at&&e.jsxDEV("p",{className:"text-[10px] text-muted-foreground",children:["Last polled: ",new Date(j.last_polled_at).toLocaleString()]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:463,columnNumber:25},this),j.last_error&&e.jsxDEV("p",{className:"text-[10px] text-red-600 mt-0.5",children:["Last error: ",j.last_error]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:466,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:443,columnNumber:21},this),e.jsxDEV("div",{className:"flex space-x-2",children:[e.jsxDEV(jt,{children:[e.jsxDEV(Gt,{asChild:!0,children:e.jsxDEV(f,{variant:"outline",size:"sm",disabled:P===j.id,title:"Fetch every email in this inbox (one-time backfill)",children:e.jsxDEV(ri,{className:`h-4 w-4 ${P===j.id?"animate-pulse":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:478,columnNumber:29},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:476,columnNumber:27},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:475,columnNumber:25},this),e.jsxDEV(Vt,{children:[e.jsxDEV(Yt,{children:[e.jsxDEV(wt,{className:"flex items-center gap-2",children:[e.jsxDEV(rt,{className:"h-5 w-5 text-amber-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:484,columnNumber:31},this),'Fetch all emails from "',j.name,'"?']},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:483,columnNumber:29},this),e.jsxDEV(_t,{children:["Pulls ",e.jsxDEV("strong",{children:"every message"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:488,columnNumber:37},this)," currently in the INBOX folder, ignoring the incremental watermark. Any email already saved in the system is silently skipped (matching by Message-ID), so it's safe to run multiple times.",e.jsxDEV("br",{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:492,columnNumber:31},this),e.jsxDEV("br",{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:492,columnNumber:37},this),"Larger mailboxes can take a few minutes — the parser processes one message at a time. The page stays usable while it runs."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:487,columnNumber:29},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:482,columnNumber:27},this),e.jsxDEV(Tt,{children:[e.jsxDEV(kt,{children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:498,columnNumber:29},this),e.jsxDEV(Rt,{onClick:()=>p(j),children:"Fetch all"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:499,columnNumber:29},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:497,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:481,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:474,columnNumber:23},this),e.jsxDEV(f,{variant:"outline",size:"sm",onClick:()=>V(j),children:e.jsxDEV(nt,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:506,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:505,columnNumber:23},this),e.jsxDEV(f,{variant:"outline",size:"sm",onClick:()=>v(j),children:e.jsxDEV(de,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:509,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:508,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:469,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:442,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:441,columnNumber:17},this)},j.id,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:440,columnNumber:15},this))]},E.key,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:433,columnNumber:15},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:431,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:415,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/EmailInboxSettings.tsx",lineNumber:402,columnNumber:5},this)}function yi(){const{toast:t}=F(),[r,o]=x.useState(""),[l,s]=x.useState(""),[n,m]=x.useState(!1),[i,a]=x.useState(""),h=`${window.location.origin}/auth/callback`,u=()=>{if(!r||!l){t({title:"Missing Information",description:"Please provide both Client ID and Client Secret",variant:"destructive"});return}t({title:"OAuth2 Credentials Saved",description:"Credentials kept in this session only. Backend storage is not yet wired up — you'll need to re-enter them after a refresh."})},d=()=>{if(!r){t({title:"Missing Client ID",description:"Please save your OAuth2 credentials first",variant:"destructive"});return}const c=window.location.origin;if(!c.startsWith("https://")&&!c.includes("localhost")){t({title:"Invalid Origin",description:"OAuth2 requires HTTPS or localhost for security",variant:"destructive"});return}const N=["https://www.googleapis.com/auth/gmail.readonly","https://www.googleapis.com/auth/gmail.modify"].join(" "),D=`${c}/auth/callback`,y=`https://accounts.google.com/o/oauth2/v2/auth?client_id=${encodeURIComponent(r)}&redirect_uri=${encodeURIComponent(D)}&scope=${encodeURIComponent(N)}&response_type=code&access_type=offline&prompt=consent&state=${encodeURIComponent(JSON.stringify({timestamp:Date.now()}))}`;console.log("OAuth2 URL:",y),console.log("Redirect URI:",D),window.location.href=y},g=c=>{navigator.clipboard.writeText(c),t({title:"Copied to clipboard",description:"The redirect URI has been copied to your clipboard."})};return e.jsxDEV("div",{className:"space-y-6",children:e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center space-x-2",children:[e.jsxDEV(Si,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:93,columnNumber:13},this),e.jsxDEV("span",{children:"OAuth2 Configuration"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:94,columnNumber:13},this),n&&e.jsxDEV(I,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Connected"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:95,columnNumber:29},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:92,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:91,columnNumber:9},this),e.jsxDEV(w,{className:"space-y-6",children:[e.jsxDEV("div",{className:"bg-green-50 p-4 rounded-lg space-y-3",children:[e.jsxDEV("h3",{className:"font-medium text-green-900",children:"⚡ Easier Alternative: Use App Password Instead"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:102,columnNumber:13},this),e.jsxDEV("div",{className:"text-sm text-green-800 space-y-2",children:[e.jsxDEV("p",{className:"font-medium",children:"Skip OAuth2 complexity - use Gmail App Password:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:104,columnNumber:15},this),e.jsxDEV("ol",{className:"space-y-1 ml-4",children:[e.jsxDEV("li",{children:["1. Go to your ",e.jsxDEV("a",{href:"https://myaccount.google.com/security",target:"_blank",rel:"noopener noreferrer",className:"underline inline-flex items-center",children:["Google Account Security ",e.jsxDEV($e,{className:"h-3 w-3 ml-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:106,columnNumber:196},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:106,columnNumber:35},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:106,columnNumber:17},this),e.jsxDEV("li",{children:"2. Enable 2-Factor Authentication if not already enabled"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:107,columnNumber:17},this),e.jsxDEV("li",{children:'3. Go to "App passwords" and generate a new password for "Mail"'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:108,columnNumber:17},this),e.jsxDEV("li",{children:'4. Use this app password in the "Inbox" settings tab with IMAP'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:109,columnNumber:17},this),e.jsxDEV("li",{children:"5. Set IMAP server to: imap.gmail.com, Port: 993, SSL: Yes"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:110,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:105,columnNumber:15},this),e.jsxDEV("p",{className:"text-xs italic mt-2",children:"This is much simpler and works immediately!"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:112,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:103,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:101,columnNumber:11},this),e.jsxDEV("div",{className:"bg-blue-50 p-4 rounded-lg space-y-3",children:[e.jsxDEV("h3",{className:"font-medium text-blue-900",children:"Setup Instructions"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:117,columnNumber:13},this),e.jsxDEV("ol",{className:"text-sm text-blue-800 space-y-2 ml-4",children:[e.jsxDEV("li",{children:["1. Go to the ",e.jsxDEV("a",{href:"https://console.cloud.google.com/",target:"_blank",rel:"noopener noreferrer",className:"underline inline-flex items-center",children:["Google Cloud Console ",e.jsxDEV($e,{className:"h-3 w-3 ml-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:119,columnNumber:186},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:119,columnNumber:32},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:119,columnNumber:15},this),e.jsxDEV("li",{children:"2. Create a new project or select an existing one"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:120,columnNumber:15},this),e.jsxDEV("li",{children:"3. Enable the Gmail API for your project"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:121,columnNumber:15},this),e.jsxDEV("li",{children:'4. Go to "OAuth consent screen" and configure it (choose "External" for testing)'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:122,columnNumber:15},this),e.jsxDEV("li",{children:'5. In OAuth consent screen, add your email address to "Test users" section'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:123,columnNumber:15},this),e.jsxDEV("li",{children:'6. Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client IDs"'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:124,columnNumber:15},this),e.jsxDEV("li",{children:'7. Choose "Web application" as the application type'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:125,columnNumber:15},this),e.jsxDEV("li",{children:'8. Add the exact redirect URI below to "Authorized redirect URIs"'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:126,columnNumber:15},this),e.jsxDEV("li",{children:['9. Add your domain to "Authorized JavaScript origins" (e.g., ',window.location.origin,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:127,columnNumber:15},this),e.jsxDEV("li",{children:"10. Copy your Client ID and Client Secret here"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:128,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:118,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:116,columnNumber:11},this),e.jsxDEV("div",{className:"bg-red-50 p-4 rounded-lg space-y-3",children:[e.jsxDEV("h3",{className:"font-medium text-red-900",children:'Troubleshooting 403 "Access denied" Error'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:134,columnNumber:13},this),e.jsxDEV("div",{className:"text-sm text-red-800 space-y-2",children:[e.jsxDEV("p",{className:"font-medium",children:"This error occurs when:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:136,columnNumber:15},this),e.jsxDEV("ul",{className:"space-y-1 ml-4",children:[e.jsxDEV("li",{children:"• Your OAuth app is in testing mode (most common)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:138,columnNumber:17},this),e.jsxDEV("li",{children:`• Your email isn't added to the "Test users" list`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:139,columnNumber:17},this),e.jsxDEV("li",{children:"• The OAuth consent screen isn't configured properly"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:140,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:137,columnNumber:15},this),e.jsxDEV("p",{className:"font-medium mt-3",children:"To fix this:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:142,columnNumber:15},this),e.jsxDEV("ol",{className:"space-y-1 ml-4",children:[e.jsxDEV("li",{children:"1. Go to Google Cloud Console → OAuth consent screen"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:144,columnNumber:17},this),e.jsxDEV("li",{children:'2. Choose "External" user type for testing'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:145,columnNumber:17},this),e.jsxDEV("li",{children:"3. Fill in required fields (App name, User support email, Developer contact)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:146,columnNumber:17},this),e.jsxDEV("li",{children:'4. In "Test users" section, add your Gmail address'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:147,columnNumber:17},this),e.jsxDEV("li",{children:"5. Save and try connecting again"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:148,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:143,columnNumber:15},this),e.jsxDEV("p",{className:"mt-2 text-xs italic",children:"Note: For production use, you'll need to submit your app for Google verification or publish it."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:150,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:135,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:133,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Redirect URI (copy this to Google Cloud Console)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:156,columnNumber:13},this),e.jsxDEV("div",{className:"flex space-x-2",children:[e.jsxDEV(U,{value:h,readOnly:!0,className:"bg-gray-50"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:158,columnNumber:15},this),e.jsxDEV(f,{variant:"outline",size:"sm",onClick:()=>g(h),children:e.jsxDEV(jr,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:168,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:163,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:157,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:155,columnNumber:11},this),e.jsxDEV("div",{className:"grid grid-cols-1 gap-4",children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"clientId",children:"Google Client ID"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:176,columnNumber:15},this),e.jsxDEV(U,{id:"clientId",value:r,onChange:c=>o(c.target.value),placeholder:"Enter your Google OAuth2 Client ID"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:177,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:175,columnNumber:13},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"clientSecret",children:"Google Client Secret"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:185,columnNumber:15},this),e.jsxDEV(U,{id:"clientSecret",type:"password",value:l,onChange:c=>s(c.target.value),placeholder:"Enter your Google OAuth2 Client Secret"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:186,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:184,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:174,columnNumber:11},this),e.jsxDEV("div",{className:"flex space-x-3",children:[e.jsxDEV(f,{onClick:u,variant:"outline",children:"Save Credentials"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:197,columnNumber:13},this),e.jsxDEV(f,{onClick:d,className:"flex items-center space-x-2",children:[e.jsxDEV("span",{children:"Connect to Gmail"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:201,columnNumber:15},this),e.jsxDEV($e,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:202,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:200,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:196,columnNumber:11},this),n&&e.jsxDEV("div",{className:"border rounded-lg p-4 bg-green-50",children:[e.jsxDEV("div",{className:"flex items-center space-x-2 text-green-700",children:[e.jsxDEV(is,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:210,columnNumber:17},this),e.jsxDEV("span",{className:"font-medium",children:"Gmail Connected Successfully"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:211,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:209,columnNumber:15},this),e.jsxDEV("p",{className:"text-sm text-green-600 mt-1",children:"Your email monitoring system can now fetch real emails from Gmail."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:213,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:208,columnNumber:13},this),e.jsxDEV("div",{className:"border rounded-lg p-4",children:[e.jsxDEV("h4",{className:"font-medium mb-2",children:"Required Permissions"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:221,columnNumber:13},this),e.jsxDEV("ul",{className:"text-sm text-gray-600 space-y-1",children:[e.jsxDEV("li",{children:"• Read Gmail messages (gmail.readonly)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:223,columnNumber:15},this),e.jsxDEV("li",{children:"• Modify Gmail messages (gmail.modify) - for marking as read"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:224,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:222,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:220,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:98,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:90,columnNumber:7},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/OAuth2Settings.tsx",lineNumber:89,columnNumber:5},this)}function Ni(){const[t,r]=x.useState(null),[o,l]=x.useState(!1),[s,n]=x.useState({setting_key:"",setting_value:"",description:"",is_active:!0}),{toast:m}=F(),i=K(),{data:a,isLoading:h}=Q({queryKey:["system-settings"],queryFn:async()=>{const{data:D,error:y}=await Ee.from("system_settings").select("*").order("setting_key");if(y)throw y;return D||[]}}),u=D=>{r(D),n({setting_key:D.setting_key,setting_value:D.setting_value,description:D.description||"",is_active:D.is_active})},d=async()=>{try{if(!t)return;const{error:D}=await Ee.from("system_settings").update({setting_value:s.setting_value,description:s.description,is_active:s.is_active}).eq("id",t.id);if(D)throw D;m({title:"Setting updated",description:"System setting has been updated successfully."}),r(null),i.invalidateQueries({queryKey:["system-settings"]})}catch(D){console.error("Error updating setting:",D),m({title:"Error",description:"Failed to update setting. Please try again.",variant:"destructive"})}},g=async()=>{try{const{error:D}=await Ee.from("system_settings").insert({setting_key:s.setting_key,setting_value:s.setting_value,description:s.description,is_active:s.is_active});if(D)throw D;m({title:"Setting created",description:"New system setting has been created successfully."}),l(!1),n({setting_key:"",setting_value:"",description:"",is_active:!0}),i.invalidateQueries({queryKey:["system-settings"]})}catch(D){console.error("Error creating setting:",D),m({title:"Error",description:"Failed to create setting. Please try again.",variant:"destructive"})}},c=()=>{r(null),n({setting_key:"",setting_value:"",description:"",is_active:!0})},N=D=>{switch(D){case"booking_reference_format":return{name:"Booking Reference Format",example:"TPV000000 → TPV000001, TPV000002...",description:"Use 0 for incrementing numbers. Example: TPV000000 will generate TPV000001, TPV000002, etc."};default:return{name:D.replace(/_/g," ").replace(/\b\w/g,y=>y.toUpperCase()),example:"",description:""}}};return h?e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center space-x-2",children:[e.jsxDEV(vt,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:160,columnNumber:13},this),e.jsxDEV("span",{children:"System Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:161,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:159,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:158,columnNumber:9},this),e.jsxDEV(w,{children:e.jsxDEV("div",{className:"flex items-center justify-center py-8",children:e.jsxDEV("div",{className:"text-muted-foreground",children:"Loading settings..."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:166,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:165,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:164,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:157,columnNumber:7},this):e.jsxDEV(e.Fragment,{children:[e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"flex items-center space-x-2",children:[e.jsxDEV(vt,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:179,columnNumber:15},this),e.jsxDEV("span",{children:"System Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:180,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:178,columnNumber:13},this),e.jsxDEV(f,{variant:"outline",size:"sm",onClick:()=>l(!0),children:[e.jsxDEV(le,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:187,columnNumber:15},this),"Add Setting"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:182,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:177,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:176,columnNumber:9},this),e.jsxDEV(w,{children:[e.jsxDEV(Cr,{children:[e.jsxDEV(Ar,{children:e.jsxDEV(Ve,{children:[e.jsxDEV(ue,{children:"Setting"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:196,columnNumber:17},this),e.jsxDEV(ue,{children:"Value"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:197,columnNumber:17},this),e.jsxDEV(ue,{children:"Description"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:198,columnNumber:17},this),e.jsxDEV(ue,{children:"Status"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:199,columnNumber:17},this),e.jsxDEV(ue,{children:"Actions"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:200,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:195,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:194,columnNumber:13},this),e.jsxDEV(Pr,{children:a==null?void 0:a.map(D=>{const y=N(D.setting_key),v=(t==null?void 0:t.id)===D.id;return e.jsxDEV(Ve,{children:[e.jsxDEV(oe,{children:e.jsxDEV("div",{children:[e.jsxDEV("div",{className:"font-medium",children:y.name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:212,columnNumber:25},this),e.jsxDEV("div",{className:"text-xs text-muted-foreground",children:D.setting_key},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:213,columnNumber:25},this),y.example&&e.jsxDEV("div",{className:"text-xs text-blue-600 mt-1",children:y.example},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:215,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:211,columnNumber:23},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:210,columnNumber:21},this),e.jsxDEV(oe,{children:v?e.jsxDEV(U,{value:s.setting_value,onChange:P=>n({...s,setting_value:P.target.value}),className:"w-full"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:221,columnNumber:25},this):e.jsxDEV("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:D.setting_value},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:227,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:219,columnNumber:21},this),e.jsxDEV(oe,{children:v?e.jsxDEV(U,{value:s.description,onChange:P=>n({...s,description:P.target.value}),placeholder:"Setting description",className:"w-full"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:234,columnNumber:25},this):e.jsxDEV("div",{className:"text-sm text-muted-foreground",children:D.description||y.description||"No description"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:241,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:232,columnNumber:21},this),e.jsxDEV(oe,{children:v?e.jsxDEV(z,{checked:s.is_active,onCheckedChange:P=>n({...s,is_active:P})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:248,columnNumber:25},this):e.jsxDEV(I,{variant:D.is_active?"default":"secondary",children:D.is_active?"Active":"Inactive"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:253,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:246,columnNumber:21},this),e.jsxDEV(oe,{children:v?e.jsxDEV("div",{className:"flex space-x-2",children:[e.jsxDEV(f,{size:"sm",onClick:d,children:e.jsxDEV(Ie,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:262,columnNumber:29},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:261,columnNumber:27},this),e.jsxDEV(f,{size:"sm",variant:"outline",onClick:c,children:e.jsxDEV(Le,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:265,columnNumber:29},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:264,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:260,columnNumber:25},this):e.jsxDEV(f,{size:"sm",variant:"outline",onClick:()=>u(D),children:e.jsxDEV(nt,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:274,columnNumber:27},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:269,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:258,columnNumber:21},this)]},D.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:209,columnNumber:19},this)})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:203,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:193,columnNumber:11},this),(!a||a.length===0)&&e.jsxDEV("div",{className:"text-center py-8 text-muted-foreground",children:"No system settings found"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:285,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:192,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:175,columnNumber:7},this),e.jsxDEV(ye,{open:o,onOpenChange:l,children:e.jsxDEV(Ne,{children:[e.jsxDEV(De,{children:e.jsxDEV(xe,{children:"Add System Setting"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:296,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:295,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-4",children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Setting Key *"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:301,columnNumber:15},this),e.jsxDEV(U,{value:s.setting_key,onChange:D=>n({...s,setting_key:D.target.value}),placeholder:"e.g., booking_reference_format"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:302,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:300,columnNumber:13},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Setting Value *"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:310,columnNumber:15},this),e.jsxDEV(U,{value:s.setting_value,onChange:D=>n({...s,setting_value:D.target.value}),placeholder:"e.g., TPV000000"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:311,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:309,columnNumber:13},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Description"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:319,columnNumber:15},this),e.jsxDEV(U,{value:s.description,onChange:D=>n({...s,description:D.target.value}),placeholder:"Description of this setting"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:320,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:318,columnNumber:13},this),e.jsxDEV("div",{className:"flex items-center space-x-2",children:[e.jsxDEV(z,{checked:s.is_active,onCheckedChange:D=>n({...s,is_active:D})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:328,columnNumber:15},this),e.jsxDEV(A,{children:"Active"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:332,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:327,columnNumber:13},this),e.jsxDEV("div",{className:"flex justify-end space-x-2",children:[e.jsxDEV(f,{variant:"outline",onClick:()=>l(!1),children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:336,columnNumber:15},this),e.jsxDEV(f,{onClick:g,children:"Create Setting"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:339,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:335,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:299,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:294,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:293,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SystemSettings.tsx",lineNumber:174,columnNumber:5},this)}const Di={name:"",host:"",port:587,secure:!1,username:"",password:"",from_email:"",from_name:"",owner_type:"system",owner_id:null,display_label:null,is_default_for_scope:!1,is_default:!1,is_active:!0};async function je(t,r){const o=localStorage.getItem("platform_token"),s=await(await fetch(`/api${t}`,{headers:{"Content-Type":"application/json",...o?{Authorization:`Bearer ${o}`}:{}},...r})).json();if(s.error)throw new Error(s.error.message||s.error);return s.data}function mr({personalOnly:t=!1}={}){const{toast:r}=F(),{user:o,profile:l}=ke(),s=(l==null?void 0:l.role)==="admin"&&!t,[n,m]=x.useState([]),[i,a]=x.useState(null),[h,u]=x.useState(!1),[d,g]=x.useState(!1);x.useEffect(()=>{c()},[]);const c=async()=>{try{m(await je("/smtp-accounts"))}catch(p){r({variant:"destructive",title:"Load failed",description:p.message})}},N=async()=>{if(i){u(!0);try{const p={...i};i.id&&(p.password===""||p.password==="********")&&delete p.password,i.id?await je(`/smtp-accounts/${i.id}`,{method:"PATCH",body:JSON.stringify(p)}):await je("/smtp-accounts",{method:"POST",body:JSON.stringify(p)}),r({title:"Saved"}),a(null),c()}catch(p){r({variant:"destructive",title:"Save failed",description:p.message})}finally{u(!1)}}},D=async p=>{if(p.id&&window.confirm(`Delete SMTP account "${p.name}"?`))try{await je(`/smtp-accounts/${p.id}`,{method:"DELETE"}),c()}catch(b){r({variant:"destructive",title:"Delete failed",description:b.message})}},y=async()=>{if(i){g(!0);try{const p={host:i.host,port:i.port,secure:i.secure,username:i.username};i.password&&i.password!=="********"&&(p.password=i.password),i.id&&(p.id=i.id);const b=await je("/smtp-accounts/test",{method:"POST",body:JSON.stringify(p)});r({title:"SMTP OK",description:b.message||"Verified"})}catch(p){r({variant:"destructive",title:"Test failed",description:p.message})}finally{g(!1)}}},v=x.useMemo(()=>n.filter(p=>t?p.owner_type==="user":!0),[n,t]),P=()=>({...Di,owner_type:t?"user":s?"system":"user",owner_id:(t||!s)&&(o==null?void 0:o.id)||null});if(i)return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"flex items-center gap-2",children:[e.jsxDEV(re,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:145,columnNumber:54},this),e.jsxDEV("span",{children:i.id?"Edit SMTP Account":"Add SMTP Account"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:146,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:145,columnNumber:13},this),e.jsxDEV(f,{variant:"ghost",size:"sm",onClick:()=>a(null),children:e.jsxDEV(Le,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:148,columnNumber:80},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:148,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:144,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:143,columnNumber:9},this),e.jsxDEV(w,{className:"space-y-4",children:[e.jsxDEV("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Account name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:154,columnNumber:15},this),e.jsxDEV(U,{value:i.name,onChange:p=>a({...i,name:p.target.value}),placeholder:"e.g. Gmail – ops"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:155,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:153,columnNumber:13},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"From address"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:159,columnNumber:15},this),e.jsxDEV(U,{type:"email",value:i.from_email,onChange:p=>a({...i,from_email:p.target.value}),placeholder:"ops@tripovo.com"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:160,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:158,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:152,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"From display name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:166,columnNumber:13},this),e.jsxDEV(U,{value:i.from_name,onChange:p=>a({...i,from_name:p.target.value}),placeholder:"Tripovo Ops"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:167,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:165,columnNumber:11},this),e.jsxDEV(ge,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:171,columnNumber:11},this),e.jsxDEV("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"SMTP host"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:175,columnNumber:15},this),e.jsxDEV(U,{value:i.host,onChange:p=>a({...i,host:p.target.value}),placeholder:"smtp.gmail.com"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:176,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:174,columnNumber:13},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Port"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:180,columnNumber:15},this),e.jsxDEV(U,{type:"number",value:i.port,onChange:p=>a({...i,port:parseInt(p.target.value)||587})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:181,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:179,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:173,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Username"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:186,columnNumber:13},this),e.jsxDEV(U,{value:i.username,onChange:p=>a({...i,username:p.target.value})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:187,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:185,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Password / App Password"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:190,columnNumber:13},this),e.jsxDEV(U,{type:"password",value:i.password,onChange:p=>a({...i,password:p.target.value}),placeholder:i.id?"Leave blank to keep current password":""},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:191,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:189,columnNumber:11},this),e.jsxDEV(ge,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:196,columnNumber:11},this),s?e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Owner"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:203,columnNumber:15},this),e.jsxDEV(X,{value:i.owner_type,onValueChange:p=>a({...i,owner_type:p,owner_id:p==="system"?null:i.owner_id}),disabled:!!i.id,children:[e.jsxDEV(Z,{children:e.jsxDEV(ee,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:209,columnNumber:32},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:209,columnNumber:17},this),e.jsxDEV(te,{children:[e.jsxDEV(M,{value:"system",children:"System (shared by all Ops)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:211,columnNumber:19},this),e.jsxDEV(M,{value:"app",children:"Application (one app)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:212,columnNumber:19},this),e.jsxDEV(M,{value:"user",children:"Personal (one user)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:213,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:210,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:204,columnNumber:15},this),(i.owner_type==="app"||i.owner_type==="user")&&e.jsxDEV(U,{value:i.owner_id||"",onChange:p=>a({...i,owner_id:p.target.value||null}),placeholder:i.owner_type==="app"?"app_id (UUID)":"platform_users.id (blank = self)",className:"font-mono text-xs",disabled:!!i.id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:217,columnNumber:17},this),i.id&&e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"Owner can't be changed after the account is created. Delete + recreate to reassign."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:226,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:202,columnNumber:13},this):e.jsxDEV("div",{className:"rounded-md border bg-slate-50/60 p-3 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxDEV(we,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:233,columnNumber:15},this),e.jsxDEV("span",{children:["This will be saved as your ",e.jsxDEV("strong",{children:"personal"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:234,columnNumber:48},this)," SMTP account — only you and Ops admins can see it."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:234,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:232,columnNumber:13},this),e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV(A,{children:"Use TLS/SSL (port 465)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:239,columnNumber:13},this),e.jsxDEV(z,{checked:i.secure,onCheckedChange:p=>a({...i,secure:p,port:p?465:587})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:240,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:238,columnNumber:11},this),e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV(A,{children:["Default for this scope ",e.jsxDEV("span",{className:"text-muted-foreground text-xs",children:"(picked first when no other choice)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:244,columnNumber:43},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:244,columnNumber:13},this),e.jsxDEV(z,{checked:i.is_default_for_scope,onCheckedChange:p=>a({...i,is_default_for_scope:p})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:245,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:243,columnNumber:11},this),e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV(A,{children:"Active"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:249,columnNumber:13},this),e.jsxDEV(z,{checked:i.is_active,onCheckedChange:p=>a({...i,is_active:p})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:250,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:248,columnNumber:11},this),e.jsxDEV(ge,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:254,columnNumber:11},this),e.jsxDEV("div",{className:"flex gap-2",children:[e.jsxDEV(f,{className:"flex-1",disabled:h||!i.name||!i.host||!i.username||!i.from_email||!i.id&&!i.password,onClick:N,children:h?"Saving…":"Save Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:257,columnNumber:13},this),e.jsxDEV(f,{variant:"outline",onClick:y,disabled:d||!i.host||!i.username,children:[e.jsxDEV(st,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:263,columnNumber:15},this),d?"Testing…":"Test Connection"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:262,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:256,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:151,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:142,columnNumber:7},this);const S=[{key:"user",label:"Personal accounts",icon:we,rows:v.filter(p=>p.owner_type==="user")},{key:"app",label:"Application accounts",icon:Ur,rows:v.filter(p=>p.owner_type==="app")},{key:"system",label:"System accounts (shared by all Ops)",icon:Kt,rows:v.filter(p=>p.owner_type==="system")}].filter(p=>t?p.key==="user":!0);return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"flex items-center gap-2",children:[e.jsxDEV(re,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:285,columnNumber:52},this)," ",t?"My SMTP accounts":"SMTP Accounts"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:285,columnNumber:11},this),e.jsxDEV(f,{onClick:()=>a({...P()}),children:[e.jsxDEV(le,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:286,columnNumber:71},this)," Add Account"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:286,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:284,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:283,columnNumber:7},this),e.jsxDEV(w,{children:v.length===0?e.jsxDEV("div",{className:"text-center py-8",children:[e.jsxDEV(re,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:292,columnNumber:13},this),e.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"No SMTP accounts"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:293,columnNumber:13},this),e.jsxDEV("p",{className:"text-muted-foreground mb-4",children:t?"Add your personal SMTP so outbound emails go from your address. You can still pick a system account at send time.":"Add one to enable outbound mail (replies from the Emails page and support tickets)."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:294,columnNumber:13},this),e.jsxDEV(f,{onClick:()=>a({...P()}),children:[e.jsxDEV(le,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:299,columnNumber:73},this)," Add your first account"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:299,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:291,columnNumber:11},this):e.jsxDEV("div",{className:"space-y-5",children:S.map(p=>p.rows.length===0?null:e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[e.jsxDEV(p.icon,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:306,columnNumber:19},this),e.jsxDEV("span",{children:p.label},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:307,columnNumber:19},this),e.jsxDEV("span",{className:"text-[10px]",children:["(",p.rows.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:308,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:305,columnNumber:17},this),p.rows.map(b=>e.jsxDEV(Y,{className:"border",children:e.jsxDEV(w,{className:"p-4",children:e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"flex-1",children:[e.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxDEV("h3",{className:"font-medium",children:b.display_label||b.name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:316,columnNumber:29},this),b.is_default_for_scope&&e.jsxDEV(I,{variant:"outline",className:"text-[10px] bg-amber-50 text-amber-700 border-amber-200 inline-flex items-center gap-1",children:[e.jsxDEV(si,{className:"h-3 w-3 fill-amber-400 text-amber-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:319,columnNumber:33},this)," Default"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:318,columnNumber:31},this),e.jsxDEV("span",{className:`px-2 py-0.5 text-[10px] rounded ${b.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-700"}`,children:b.is_active?"Active":"Inactive"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:322,columnNumber:29},this),b.owner_type==="app"&&b.owner_id&&e.jsxDEV("code",{className:"text-[10px] font-mono text-muted-foreground",children:["app:",b.owner_id.slice(0,8),"…"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:326,columnNumber:31},this),b.owner_type==="user"&&b.owner_id&&b.owner_id!==(o==null?void 0:o.id)&&e.jsxDEV("code",{className:"text-[10px] font-mono text-muted-foreground",children:["user:",b.owner_id.slice(0,8),"…"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:329,columnNumber:31},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:315,columnNumber:27},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground mt-1",children:[b.from_name?`${b.from_name} — `:"",b.from_email]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:332,columnNumber:27},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:[b.host,":",b.port,b.secure?" · SSL":""]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:333,columnNumber:27},this),b.last_used_at&&e.jsxDEV("p",{className:"text-[10px] text-muted-foreground",children:["Last used: ",new Date(b.last_used_at).toLocaleString()]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:335,columnNumber:29},this),b.last_error&&e.jsxDEV("p",{className:"text-[10px] text-red-600 mt-0.5",children:["Last error: ",b.last_error]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:338,columnNumber:29},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:314,columnNumber:25},this),e.jsxDEV("div",{className:"flex gap-2",children:[e.jsxDEV(f,{size:"sm",variant:"outline",onClick:()=>a({...b,password:""}),children:e.jsxDEV(nt,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:342,columnNumber:114},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:342,columnNumber:27},this),e.jsxDEV(f,{size:"sm",variant:"outline",onClick:()=>D(b),children:e.jsxDEV(de,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:343,columnNumber:86},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:343,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:341,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:313,columnNumber:23},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:312,columnNumber:21},this)},b.id,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:311,columnNumber:19},this))]},p.key,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:304,columnNumber:15},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:302,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:289,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SMTPSettings.tsx",lineNumber:282,columnNumber:5},this)}function Et(t){return(t||"").trim().toLowerCase().replace(/\s+/g,"-")}function Yr({url:t,label:r,onCopyToast:o}){return e.jsxDEV("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsxDEV("code",{className:"font-mono text-[11px] bg-gray-100 px-2 py-1 rounded border text-gray-700 truncate max-w-md",children:t},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:29,columnNumber:7},this),e.jsxDEV(f,{size:"sm",variant:"outline",className:"h-7 px-2 text-[10px]",onClick:()=>{navigator.clipboard.writeText(t),o()},title:`Copy ${r}`,children:e.jsxDEV(jr,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:37,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:32,columnNumber:7},this),e.jsxDEV(f,{size:"sm",variant:"outline",className:"h-7 px-2 text-[10px]",onClick:()=>window.open(t,"_blank","noopener,noreferrer"),title:`Open ${r} in new tab`,children:e.jsxDEV($e,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:44,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:39,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:28,columnNumber:5},this)}function xi({app:t,onBack:r}){const{toast:o}=F(),[l,s]=x.useState(""),{data:n=[],isLoading:m}=Q({queryKey:["easygds-agents-for-logins",t.id],queryFn:async()=>{const u=await ls({app_id:t.id,per_page:500});return(u==null?void 0:u.result)||(Array.isArray(u)?u:[])},staleTime:6e4}),i=Et(t.name),a=`${window.location.origin}/login/${i}`,h=x.useMemo(()=>{if(!l.trim())return n;const u=l.toLowerCase();return n.filter(d=>(d.name||"").toLowerCase().includes(u)||(d.code||"").toLowerCase().includes(u)||(d.email||"").toLowerCase().includes(u))},[n,l]);return e.jsxDEV("div",{className:"space-y-3",children:[e.jsxDEV(Y,{children:e.jsxDEV(w,{className:"p-3 flex items-center gap-3 flex-wrap",children:[e.jsxDEV(f,{size:"sm",variant:"ghost",onClick:r,children:[e.jsxDEV(ns,{className:"h-4 w-4 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:86,columnNumber:13},this)," All applications"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:85,columnNumber:11},this),e.jsxDEV("div",{className:"flex-1 min-w-0",children:[e.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxDEV(Mt,{className:"h-4 w-4 text-orange-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:90,columnNumber:15},this),e.jsxDEV("span",{className:"font-semibold",children:t.name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:91,columnNumber:15},this),t.code&&e.jsxDEV("code",{className:"text-xs font-mono text-muted-foreground",children:t.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:92,columnNumber:28},this),e.jsxDEV(I,{variant:"outline",className:`text-[10px] ${t.status==="running"?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-gray-50 text-gray-600"}`,children:t.status},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:93,columnNumber:15},this),e.jsxDEV("span",{className:"text-xs text-muted-foreground",children:["· ",n.length," agencies"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:96,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:89,columnNumber:13},this),e.jsxDEV("div",{className:"text-[11px] text-muted-foreground mt-1",children:["App-level login: ",e.jsxDEV("code",{className:"font-mono",children:a},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:99,columnNumber:32},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:98,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:88,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:84,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:83,columnNumber:7},this),e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3 pb-2",children:[e.jsxDEV(R,{className:"text-sm flex items-center gap-2",children:[e.jsxDEV(It,{className:"h-4 w-4 text-blue-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:108,columnNumber:13},this)," Agencies in ",t.name]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:107,columnNumber:11},this),e.jsxDEV("div",{className:"relative pt-2",children:[e.jsxDEV(he,{className:"absolute left-2 top-1/2 -translate-y-1/2 mt-1 h-3.5 w-3.5 text-gray-400"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:111,columnNumber:13},this),e.jsxDEV(U,{className:"pl-7 h-8 text-sm",placeholder:"Search by name, code, or email…",value:l,onChange:u=>s(u.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:112,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:110,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:106,columnNumber:9},this),e.jsxDEV(w,{className:"p-0",children:[m&&e.jsxDEV("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Loading agencies…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:121,columnNumber:25},this),!m&&h.length===0&&e.jsxDEV("div",{className:"p-4 text-center text-sm text-muted-foreground",children:n.length===0?"No agencies in this app yet.":"No matches."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:123,columnNumber:13},this),e.jsxDEV("ul",{className:"divide-y",children:h.map(u=>{const d=Et(u.name),g=`${a}/${d}`,c=u.status==="approved";return e.jsxDEV("li",{className:"p-3 flex items-center gap-3 flex-wrap",children:[e.jsxDEV(os,{className:"h-4 w-4 text-gray-400 shrink-0"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:137,columnNumber:19},this),e.jsxDEV("div",{className:"flex-1 min-w-[200px]",children:[e.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxDEV("span",{className:"font-medium text-sm",children:u.name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:140,columnNumber:23},this),u.code&&e.jsxDEV("code",{className:"text-[10px] font-mono text-muted-foreground",children:u.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:141,columnNumber:38},this),e.jsxDEV(I,{variant:"outline",className:`text-[9px] ${c?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-amber-50 text-amber-700 border-amber-200"}`,children:u.status||"unknown"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:142,columnNumber:23},this),u.enabled===!1&&e.jsxDEV(I,{variant:"outline",className:"text-[9px] bg-red-50 text-red-700 border-red-200",children:"disabled"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:147,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:139,columnNumber:21},this),u.email&&e.jsxDEV("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:u.email},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:150,columnNumber:37},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:138,columnNumber:19},this),e.jsxDEV(Yr,{url:g,label:"agency login",onCopyToast:()=>o({title:"Copied",description:`Agency login link for ${u.name}`})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:152,columnNumber:19},this)]},u.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:136,columnNumber:17},this)})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:127,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:120,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:105,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:82,columnNumber:5},this)}function vi(){const{toast:t}=F(),[r,o]=x.useState(""),[l,s]=x.useState(null),{data:n,isLoading:m}=Q({queryKey:["easygds-apps-logins"],queryFn:async()=>{const d=await hr();return(d==null?void 0:d.result)||[]},staleTime:6e4}),i=Array.isArray(n)?n:[],a=x.useMemo(()=>{if(!r.trim())return i;const d=r.toLowerCase();return i.filter(g=>(g.name||"").toLowerCase().includes(d)||(g.code||"").toLowerCase().includes(d))},[i,r]),h=a.filter(d=>d.status==="running"),u=a.filter(d=>d.status!=="running");return l?e.jsxDEV(xi,{app:l,onBack:()=>s(null)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:201,columnNumber:12},this):e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3 pb-2",children:[e.jsxDEV(R,{className:"text-sm flex items-center gap-2",children:[e.jsxDEV(Mt,{className:"h-4 w-4 text-orange-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:208,columnNumber:11},this),"Application login links",e.jsxDEV(I,{variant:"outline",className:"text-[10px] ml-auto",children:[i.length," total"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:210,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:207,columnNumber:9},this),e.jsxDEV("p",{className:"text-[11px] text-muted-foreground",children:["Each app has a friendly login URL on this Operations Platform — copy or open to share with the app's users. Click ",e.jsxDEV("strong",{children:"View agencies"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:214,columnNumber:61},this)," ","to see per-agency login links."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:212,columnNumber:9},this),e.jsxDEV("div",{className:"relative pt-2",children:[e.jsxDEV(he,{className:"absolute left-2 top-1/2 -translate-y-1/2 mt-1 h-3.5 w-3.5 text-gray-400"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:218,columnNumber:11},this),e.jsxDEV(U,{className:"pl-7 h-8 text-sm",placeholder:"Search applications by name or code…",value:r,onChange:d=>o(d.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:219,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:217,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:206,columnNumber:7},this),e.jsxDEV(w,{className:"p-0",children:[m&&e.jsxDEV("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Loading applications…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:228,columnNumber:23},this),!m&&a.length===0&&e.jsxDEV("div",{className:"p-4 text-center text-sm text-muted-foreground",children:i.length===0?"No applications.":"No matches."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:230,columnNumber:11},this),h.length>0&&e.jsxDEV(e.Fragment,{children:[e.jsxDEV("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground bg-gray-50",children:["Active (",h.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:237,columnNumber:13},this),e.jsxDEV("ul",{className:"divide-y",children:h.map(d=>e.jsxDEV(ur,{app:d,onView:()=>s(d),onCopyToast:()=>t({title:"Copied",description:`App login link for ${d.name}`})},d.id,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:241,columnNumber:35},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:240,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:236,columnNumber:11},this),u.length>0&&e.jsxDEV(e.Fragment,{children:[e.jsxDEV("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground bg-gray-50 border-t",children:["Non-active (",u.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:248,columnNumber:13},this),e.jsxDEV("ul",{className:"divide-y",children:u.map(d=>e.jsxDEV(ur,{app:d,onView:()=>s(d),onCopyToast:()=>t({title:"Copied",description:`App login link for ${d.name}`}),dimmed:!0},d.id,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:252,columnNumber:38},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:251,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:247,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:227,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:205,columnNumber:5},this)}function ur({app:t,onView:r,onCopyToast:o,dimmed:l}){const s=Et(t.name),n=`${window.location.origin}/login/${s}`;return e.jsxDEV("li",{className:`p-3 flex items-center gap-3 flex-wrap ${l?"opacity-70":""}`,children:[e.jsxDEV(Mt,{className:`h-4 w-4 shrink-0 ${t.status==="running"?"text-orange-500":"text-gray-400"}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:270,columnNumber:7},this),e.jsxDEV("div",{className:"flex-1 min-w-[200px]",children:e.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxDEV("span",{className:"font-medium text-sm",children:t.name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:273,columnNumber:11},this),t.code&&e.jsxDEV("code",{className:"text-[10px] font-mono text-muted-foreground",children:t.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:274,columnNumber:24},this),e.jsxDEV(I,{variant:"outline",className:`text-[9px] ${t.status==="running"?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-gray-50 text-gray-600"}`,children:t.status},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:275,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:272,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:271,columnNumber:7},this),e.jsxDEV(Yr,{url:n,label:"app login",onCopyToast:o},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:281,columnNumber:7},this),e.jsxDEV(f,{size:"sm",variant:"outline",onClick:r,children:[e.jsxDEV(It,{className:"h-3.5 w-3.5 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:283,columnNumber:9},this)," View agencies"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:282,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppLoginsSettings.tsx",lineNumber:269,columnNumber:5},this)}function fi(){return e.jsxDEV(qt,{defaultValue:"active",className:"space-y-4",children:[e.jsxDEV(Ht,{className:"grid w-full grid-cols-3",children:[e.jsxDEV(me,{value:"active",children:"Active apps"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:31,columnNumber:9},this),e.jsxDEV(me,{value:"review",children:"Review & audit"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:32,columnNumber:9},this),e.jsxDEV(me,{value:"logins",children:"Login links"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:33,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:30,columnNumber:7},this),e.jsxDEV(B,{value:"active",children:e.jsxDEV(Ei,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:35,columnNumber:35},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:35,columnNumber:7},this),e.jsxDEV(B,{value:"review",children:e.jsxDEV(Oi,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:36,columnNumber:35},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:36,columnNumber:7},this),e.jsxDEV(B,{value:"logins",children:e.jsxDEV(vi,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:37,columnNumber:35},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:37,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:29,columnNumber:5},this)}function Ei(){const t=K(),{toast:r}=F(),[o,l]=x.useState(""),[s,n]=x.useState(new Set),[m,i]=x.useState(!1),{data:a=[],isLoading:h}=Q({queryKey:["app-settings"],queryFn:()=>Nr(),staleTime:3e4}),u=q({mutationFn:async O=>ft(O.appId,O.patch),onSuccess:()=>t.invalidateQueries({queryKey:["app-settings"]})}),d=x.useMemo(()=>a.filter(T=>!o||(T.app_name||"").toLowerCase().includes(o.toLowerCase())||(T.app_code||"").toLowerCase().includes(o.toLowerCase())).slice().sort((T,_)=>T.is_enabled!==_.is_enabled?T.is_enabled?-1:1:(T.app_name||"").localeCompare(_.app_name||"")),[a,o]),g=x.useMemo(()=>d.map(O=>O.app_id),[d]),c=g.filter(O=>s.has(O)).length,N=g.length>0&&c===g.length,D=c>0&&!N,y=O=>{n(T=>{const _=new Set(T);return _.has(O)?_.delete(O):_.add(O),_})},v=()=>{n(O=>{const T=new Set(O);if(N)for(const _ of g)T.delete(_);else for(const _ of g)T.add(_);return T})},P=()=>n(new Set),S=async(O,T)=>{try{await u.mutateAsync({appId:O.app_id,patch:{is_enabled:T}}),r({title:T?"App enabled":"App disabled",description:T?`"${O.app_name}" data will now be fetched and shown across the platform.`:`"${O.app_name}" is hidden everywhere. The system will not fetch data for it until re-enabled.`})}catch(_){r({variant:"destructive",title:"Could not update",description:_.message})}},p=async O=>{if(s.size===0)return;const T=a.filter(j=>s.has(j.app_id)&&j.is_enabled!==O);if(T.length===0){r({title:O?"Already active":"Already inactive",description:"All selected apps are already in that state."});return}i(!0);let _=0,E=0;await Promise.all(T.map(async j=>{try{await ft(j.app_id,{is_enabled:O}),_++}catch{E++}})),t.invalidateQueries({queryKey:["app-settings"]}),i(!1),r(E===0?{title:O?`Activated ${_} app${_===1?"":"s"}`:`Deactivated ${_} app${_===1?"":"s"}`,description:O?"Data fetching is on for all of them.":"The system will stop fetching data for these apps."}:{variant:"destructive",title:`${E} update${E===1?"":"s"} failed`,description:`${_} succeeded. Try again on the rest.`})},b=a.filter(O=>O.is_enabled).length,V=a.length-b,C=s.size;return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:[e.jsxDEV(R,{className:"flex items-center gap-2",children:[e.jsxDEV(We,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:179,columnNumber:11},this)," Active applications"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:178,columnNumber:9},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground mt-1",children:["This Ops platform doesn't necessarily handle every EasyGDS application. Use the switch below to choose which apps we operate. When an app is",e.jsxDEV("strong",{className:"mx-1",children:"OFF"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:184,columnNumber:11},this),", the system stops fetching its data and it won't show up in dashboards or lists for any user."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:181,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:177,columnNumber:7},this),e.jsxDEV(w,{children:[e.jsxDEV("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsxDEV(he,{className:"h-4 w-4 text-gray-400"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:190,columnNumber:11},this),e.jsxDEV(U,{placeholder:"Search apps by name or code…",value:o,onChange:O=>l(O.target.value),className:"max-w-xs"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:191,columnNumber:11},this),e.jsxDEV("span",{className:"text-xs text-muted-foreground ml-auto",children:[a.length," apps · ",e.jsxDEV("span",{className:"text-emerald-600",children:[b," active"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:198,columnNumber:34},this),V>0&&e.jsxDEV(e.Fragment,{children:[" · ",e.jsxDEV("span",{className:"text-gray-500",children:[V," inactive"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:199,columnNumber:40},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:199,columnNumber:35},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:197,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:189,columnNumber:9},this),C>0&&e.jsxDEV("div",{className:"flex items-center gap-2 mb-3 p-2.5 rounded-md border bg-blue-50 border-blue-200 flex-wrap",children:[e.jsxDEV("span",{className:"text-sm font-medium text-blue-900",children:[C," app",C===1?"":"s"," selected"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:208,columnNumber:13},this),e.jsxDEV("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsxDEV(f,{size:"sm",variant:"outline",className:"bg-white",onClick:()=>p(!0),disabled:m||u.isPending,children:[e.jsxDEV(We,{className:"h-3.5 w-3.5 mr-1.5 text-emerald-600"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:219,columnNumber:17},this),"Activate selected"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:212,columnNumber:15},this),e.jsxDEV(f,{size:"sm",variant:"outline",className:"bg-white",onClick:()=>p(!1),disabled:m||u.isPending,children:[e.jsxDEV(or,{className:"h-3.5 w-3.5 mr-1.5 text-gray-700"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:229,columnNumber:17},this),"Deactivate selected"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:222,columnNumber:15},this),e.jsxDEV(f,{size:"sm",variant:"ghost",onClick:P,disabled:m,children:"Clear"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:232,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:211,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:207,columnNumber:11},this),h?e.jsxDEV("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"Loading…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:240,columnNumber:11},this):d.length===0?e.jsxDEV("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"No apps match that search."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:242,columnNumber:11},this):e.jsxDEV("div",{className:"border rounded-lg divide-y",children:[e.jsxDEV("div",{className:"flex items-center gap-3 p-2.5 bg-slate-50 text-xs font-medium text-slate-700",children:[e.jsxDEV(sr,{checked:N?!0:D?"indeterminate":!1,onCheckedChange:v,disabled:m,"aria-label":"Select all visible"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:249,columnNumber:15},this),e.jsxDEV("button",{onClick:v,className:"hover:underline",disabled:m,children:[N?"Unselect all":"Select all",o&&d.length!==a.length&&e.jsxDEV("span",{className:"text-muted-foreground font-normal",children:[" (",d.length," match",d.length===1?"":"es",")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:262,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:255,columnNumber:15},this),e.jsxDEV("span",{className:"ml-auto text-muted-foreground font-normal",children:"Fetch data"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:265,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:248,columnNumber:13},this),d.map(O=>{const T=s.has(O.app_id);return e.jsxDEV("div",{className:`flex items-center gap-3 p-3 ${O.is_enabled?"":"bg-gray-50/60"} ${T?"bg-blue-50/40":""}`,children:[e.jsxDEV(sr,{checked:T,onCheckedChange:()=>y(O.app_id),disabled:m,"aria-label":`Select ${O.app_name}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:276,columnNumber:19},this),e.jsxDEV("div",{className:"flex-1 min-w-0",children:[e.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxDEV("span",{className:`font-medium truncate ${O.is_enabled?"":"text-gray-500"}`,children:O.app_name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:284,columnNumber:23},this),O.app_code&&e.jsxDEV(I,{variant:"outline",className:"text-[10px] font-mono",children:O.app_code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:288,columnNumber:25},this),O.is_enabled?e.jsxDEV(I,{className:"bg-emerald-100 text-emerald-800 text-[10px] border border-emerald-200 inline-flex items-center gap-1",children:[e.jsxDEV(We,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:292,columnNumber:27},this)," Active"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:291,columnNumber:25},this):e.jsxDEV(I,{className:"bg-gray-100 text-gray-700 text-[10px] border border-gray-200 inline-flex items-center gap-1",children:[e.jsxDEV(or,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:296,columnNumber:27},this)," Inactive"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:295,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:283,columnNumber:21},this),e.jsxDEV("div",{className:"text-[10px] text-muted-foreground font-mono mt-0.5 truncate",children:O.app_id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:300,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:282,columnNumber:19},this),e.jsxDEV("div",{className:"flex items-center shrink-0",children:e.jsxDEV(z,{checked:O.is_enabled,onCheckedChange:_=>S(O,_),disabled:u.isPending||m},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:305,columnNumber:21},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:304,columnNumber:19},this)]},O.app_id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:272,columnNumber:17},this)})]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:244,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:188,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:176,columnNumber:5},this)}function Oi(){const t=K(),{toast:r}=F(),[o,l]=x.useState(""),[s,n]=x.useState(new Set),[m,i]=x.useState({}),[a,h]=x.useState({}),[u,d]=x.useState(new Set),{data:g=[],isLoading:c}=Q({queryKey:["app-settings"],queryFn:()=>Nr(),staleTime:3e4}),N=q({mutationFn:async S=>ft(S.appId,S.patch),onSuccess:()=>{t.invalidateQueries({queryKey:["app-settings"]})}});x.useEffect(()=>{i(S=>{const p={...S};for(const b of g)b.app_id in p||(p[b.app_id]=(b.bcc_emails||[]).join(", "));return p})},[g]);const D=g.filter(S=>!o||(S.app_name||"").toLowerCase().includes(o.toLowerCase())||(S.app_code||"").toLowerCase().includes(o.toLowerCase())),y=S=>{n(p=>{const b=new Set(p);return b.has(S)?b.delete(S):b.add(S),b}),!(S in a)&&!u.has(S)&&(d(p=>new Set(p).add(S)),as(S).then(p=>h(b=>({...b,[S]:p.upstream_bcc_emails||[]}))).catch(()=>h(p=>({...p,[S]:[]}))).finally(()=>d(p=>{const b=new Set(p);return b.delete(S),b})))},v=async(S,p)=>{try{await N.mutateAsync({appId:S.app_id,patch:{skip_app_review:p}}),r({title:p?"Review step disabled":"Review step re-enabled",description:p?`Customer tickets for "${S.app_name}" now go directly to the Operation team.`:`Customer tickets for "${S.app_name}" will go through App review again.`})}catch(b){r({variant:"destructive",title:"Could not update",description:b.message})}},P=async S=>{const b=(m[S.app_id]??"").split(/[,;\n]+/).map(C=>C.trim()).filter(Boolean),V=b.filter(C=>!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C));if(V.length>0){r({variant:"destructive",title:`Invalid address: ${V[0]}`,description:"Use comma-separated email addresses."});return}try{const C=await N.mutateAsync({appId:S.app_id,patch:{bcc_emails:b}});i(O=>({...O,[S.app_id]:(C.bcc_emails||[]).join(", ")})),r({title:b.length?`BCC list saved (${b.length})`:"BCC list cleared",description:b.length?`All notifications about "${S.app_name}" will BCC: ${b.slice(0,3).join(", ")}${b.length>3?`, +${b.length-3} more`:""}.`:`No BCC recipients for "${S.app_name}".`})}catch(C){r({variant:"destructive",title:"Save failed",description:C.message})}};return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:[e.jsxDEV(R,{className:"flex items-center gap-2",children:[e.jsxDEV(It,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:441,columnNumber:11},this)," App Review Settings"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:440,columnNumber:9},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground mt-1",children:["Some Apps don't have their own operation team. Switch on",e.jsxDEV("strong",{className:"mx-1",children:'"Skip App review"'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:445,columnNumber:11},this)," for those apps and their agency / customer support tickets will go straight to the Operation team — the pending-app-review handoff is removed for them."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:443,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:439,columnNumber:7},this),e.jsxDEV(w,{children:[e.jsxDEV("div",{className:"flex items-center gap-2 mb-3",children:[e.jsxDEV(he,{className:"h-4 w-4 text-gray-400"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:452,columnNumber:11},this),e.jsxDEV(U,{placeholder:"Search apps by name or code…",value:o,onChange:S=>l(S.target.value),className:"max-w-xs"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:453,columnNumber:11},this),e.jsxDEV("span",{className:"text-xs text-muted-foreground ml-auto",children:[g.length," apps · ",g.filter(S=>S.skip_app_review).length," skip review"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:459,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:451,columnNumber:9},this),c?e.jsxDEV("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"Loading…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:465,columnNumber:11},this):D.length===0?e.jsxDEV("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"No apps match that search."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:467,columnNumber:11},this):e.jsxDEV("div",{className:"border rounded-lg divide-y",children:D.map(S=>{var V;const p=s.has(S.app_id),b=((V=S.bcc_emails)==null?void 0:V.length)||0;return e.jsxDEV("div",{children:[e.jsxDEV("div",{className:"flex items-center gap-4 p-3",children:[e.jsxDEV("button",{className:"h-7 w-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-500 shrink-0",onClick:()=>y(S.app_id),"aria-label":p?"Collapse":"Expand",children:p?e.jsxDEV(yr,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:482,columnNumber:33},this):e.jsxDEV(tt,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:482,columnNumber:71},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:477,columnNumber:21},this),e.jsxDEV("div",{className:"flex-1 min-w-0",children:[e.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxDEV("span",{className:"font-medium truncate",children:S.app_name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:486,columnNumber:25},this),S.app_code&&e.jsxDEV(I,{variant:"outline",className:"text-[10px] font-mono",children:S.app_code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:488,columnNumber:27},this),S.skip_app_review&&e.jsxDEV(I,{className:"bg-orange-100 text-orange-800 text-[10px] border border-orange-200 inline-flex items-center gap-1",children:[e.jsxDEV(xt,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:492,columnNumber:29},this)," No App review"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:491,columnNumber:27},this),b>0&&e.jsxDEV(I,{className:"bg-blue-100 text-blue-800 text-[10px] border border-blue-200 inline-flex items-center gap-1",children:[e.jsxDEV(re,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:497,columnNumber:29},this)," BCC ",b]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:496,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:485,columnNumber:23},this),e.jsxDEV("div",{className:"text-[10px] text-muted-foreground font-mono mt-0.5 truncate",children:S.app_id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:501,columnNumber:23},this),S.updated_at&&e.jsxDEV("div",{className:"text-[10px] text-gray-400 mt-0.5",children:["Updated ",new Date(S.updated_at).toLocaleString()]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:505,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:484,columnNumber:21},this),e.jsxDEV("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxDEV("span",{className:"text-xs text-muted-foreground",children:"Skip App review"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:511,columnNumber:23},this),e.jsxDEV(z,{checked:S.skip_app_review,onCheckedChange:C=>v(S,C),disabled:N.isPending},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:512,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:510,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:475,columnNumber:19},this),p&&e.jsxDEV("div",{className:"px-3 pb-3 pl-14 bg-slate-50/50 border-t",children:e.jsxDEV("div",{className:"pt-3 space-y-3",children:[e.jsxDEV("div",{className:"flex items-center gap-2",children:[e.jsxDEV(re,{className:"h-4 w-4 text-gray-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:524,columnNumber:27},this),e.jsxDEV("span",{className:"text-sm font-medium",children:"Audit BCC addresses"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:525,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:523,columnNumber:25},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"Every notification email about tickets under this app will BCC these addresses. Leave blank to inherit the app's upstream EasyGDS BCC list shown below."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:527,columnNumber:25},this),(()=>{const C=a[S.app_id];if(u.has(S.app_id))return e.jsxDEV("div",{className:"rounded-md border border-dashed bg-white p-2.5 text-xs text-muted-foreground",children:[e.jsxDEV(fe,{className:"h-3.5 w-3.5 inline mr-1.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:542,columnNumber:33},this),"Checking upstream BCC defaults…"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:541,columnNumber:31},this);if(!C||C.length===0)return e.jsxDEV("div",{className:"rounded-md border border-dashed bg-white p-2.5 text-xs text-muted-foreground",children:[e.jsxDEV(fe,{className:"h-3.5 w-3.5 inline mr-1.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:550,columnNumber:33},this),"No upstream BCC configured for this app in EasyGDS."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:549,columnNumber:31},this);const T=(S.bcc_emails||[]).slice().sort().join(",")===C.slice().sort().join(",");return e.jsxDEV("div",{className:"rounded-md border bg-white p-2.5 space-y-1.5",children:[e.jsxDEV("div",{className:"flex items-center justify-between gap-2",children:[e.jsxDEV("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-blue-800",children:[e.jsxDEV(fe,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:560,columnNumber:35},this),"Inherited from EasyGDS (",C.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:559,columnNumber:33},this),e.jsxDEV(f,{variant:"outline",size:"sm",className:"h-6 text-[11px]",onClick:()=>i(_=>({..._,[S.app_id]:C.join(", ")})),disabled:T&&(m[S.app_id]??"").trim()===C.join(", "),children:[e.jsxDEV(le,{className:"h-3 w-3 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:570,columnNumber:35},this),"Use these"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:563,columnNumber:33},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:558,columnNumber:31},this),e.jsxDEV("div",{className:"text-[11px] text-muted-foreground break-all",children:C.join(", ")},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:574,columnNumber:31},this),b===0&&e.jsxDEV("div",{className:"text-[10px] text-emerald-700",children:"✓ Currently inheriting this list for outbound mail."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:578,columnNumber:33},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:557,columnNumber:29},this)})(),e.jsxDEV("div",{className:"flex gap-2",children:[e.jsxDEV(U,{placeholder:"ops-audit@yourcompany.com, backup@yourcompany.com",value:m[S.app_id]??"",onChange:C=>i(O=>({...O,[S.app_id]:C.target.value})),className:"flex-1 text-sm"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:587,columnNumber:27},this),e.jsxDEV(f,{size:"sm",onClick:()=>P(S),disabled:N.isPending,children:[e.jsxDEV(Ie,{className:"h-4 w-4 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:598,columnNumber:29},this),"Save"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:593,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:586,columnNumber:25},this),b>0&&e.jsxDEV("div",{className:"text-[11px] text-muted-foreground",children:["Local override active: ",S.bcc_emails.join(", ")]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:603,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:522,columnNumber:23},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:521,columnNumber:21},this)]},S.app_id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:474,columnNumber:17},this)})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:469,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:450,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/AppReviewSettings.tsx",lineNumber:438,columnNumber:5},this)}function Ot({value:t,onChange:r,placeholder:o="Pick a date",disabled:l,className:s,clearable:n=!0,triggerClassName:m}){const[i,a]=x.useState(!1),h=x.useMemo(()=>{if(!t)return;const c=String(t).slice(0,10),N=ei(c);return ms(N)?N:void 0},[t]),u=h?Zt(h,"dd MMM yyyy"):"",d=c=>{if(!c){r(""),a(!1);return}r(Zt(c,"yyyy-MM-dd")),a(!1)},g=c=>{c.stopPropagation(),r("")};return e.jsxDEV("div",{className:er("relative",s),children:e.jsxDEV(us,{open:i,onOpenChange:c=>!l&&a(c),children:[e.jsxDEV(cs,{asChild:!0,children:e.jsxDEV(f,{type:"button",variant:"outline",disabled:l,className:er("w-full justify-start text-left font-normal h-9 px-3",!u&&"text-muted-foreground",m),children:[e.jsxDEV(ds,{className:"h-4 w-4 mr-2 shrink-0 opacity-60"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:84,columnNumber:13},this),e.jsxDEV("span",{className:"flex-1 truncate",children:u||o},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:85,columnNumber:13},this),n&&u&&!l&&e.jsxDEV("span",{role:"button",tabIndex:0,"aria-label":"Clear date",onClick:g,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),r(""))},className:"ml-2 opacity-50 hover:opacity-100 transition-opacity cursor-pointer",children:e.jsxDEV(Le,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:100,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:87,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:74,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:73,columnNumber:9},this),e.jsxDEV(ps,{className:"w-auto p-0",align:"start",children:e.jsxDEV(Ss,{mode:"single",selected:h,onSelect:d,initialFocus:!0},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:106,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:105,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:72,columnNumber:7},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/date-field.tsx",lineNumber:71,columnNumber:5},this)}const pt=[{value:"exact_email",label:"Exact email",example:"reservations@hilton.com"},{value:"domain_wildcard",label:"Domain wildcard",example:"*@hilton.com  (or just hilton.com)"},{value:"subject_regex",label:"Subject regex",example:"Booking #HLN\\d{8}"},{value:"body_regex",label:"Body regex",example:"Hilton Confirmation:\\s*[A-Z0-9]+"}],Ci=["booking_ref","pnr","supplier_confirmation","hcn_number","amount","currency","check_in_date","check_out_date","pax_name"];function Ai({onSelect:t,selectedId:r}){const{toast:o}=F(),l=K(),[s,n]=x.useState(""),{data:m=[],isLoading:i}=Q({queryKey:["suppliers-local"],queryFn:()=>Ft(),staleTime:3e4}),a=q({mutationFn:()=>gs(),onSuccess:u=>{l.invalidateQueries({queryKey:["suppliers-local"]}),l.invalidateQueries({queryKey:["supplier-names-by-code"]}),o({title:u.inserted>0?`Discovered ${u.inserted} new supplier code${u.inserted===1?"":"s"}`:"No new supplier codes found",description:`Scanned ${u.scanned.toLocaleString()} bookings (${u.products_scanned.toLocaleString()} products). Found ${u.distinct_codes_found} distinct codes; ${u.already_existed} already existed.`})},onError:u=>o({variant:"destructive",title:"Discovery failed",description:u.message})}),h=m.filter(u=>!s||(u.name||"").toLowerCase().includes(s.toLowerCase())||(u.code||"").toLowerCase().includes(s.toLowerCase()));return e.jsxDEV(Y,{className:"h-full flex flex-col",children:[e.jsxDEV(k,{className:"p-3 shrink-0 space-y-2",children:[e.jsxDEV(R,{className:"text-sm flex items-center gap-2 flex-wrap",children:["Suppliers",e.jsxDEV(I,{variant:"outline",className:"text-[10px] ml-auto",children:m.length},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:101,columnNumber:11},this),e.jsxDEV(jt,{children:[e.jsxDEV(Gt,{asChild:!0,children:e.jsxDEV(f,{size:"sm",variant:"outline",disabled:a.isPending,title:"Scan cached bookings for product supplier codes and add any missing ones",children:[e.jsxDEV(Dr,{className:`h-3 w-3 mr-1 ${a.isPending?"animate-pulse":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:108,columnNumber:17},this),a.isPending?"Scanning…":"Discover from bookings"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:106,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:105,columnNumber:13},this),e.jsxDEV(Vt,{children:[e.jsxDEV(Yt,{children:[e.jsxDEV(wt,{children:"Discover suppliers from bookings?"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:114,columnNumber:17},this),e.jsxDEV(_t,{children:["Scans every cached booking for the supplier code on each product (the codes shown in the ",e.jsxDEV("strong",{children:"Supplier"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:117,columnNumber:43},this)," column on the Bookings page). Any code that isn't already in this supplier list is added as a new row with the code as its identifier; you can rename it and add contacts / rules afterwards.",e.jsxDEV("br",{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:121,columnNumber:19},this),e.jsxDEV("br",{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:121,columnNumber:25},this),"This is safe to re-run — existing supplier rows are never modified or deleted."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:115,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:113,columnNumber:15},this),e.jsxDEV(Tt,{children:[e.jsxDEV(kt,{children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:127,columnNumber:17},this),e.jsxDEV(Rt,{onClick:()=>a.mutate(),children:"Run discovery"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:128,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:126,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:112,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:104,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:99,columnNumber:9},this),e.jsxDEV("div",{className:"relative",children:[e.jsxDEV(he,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-gray-400"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:136,columnNumber:11},this),e.jsxDEV(U,{className:"pl-7 h-8 text-sm",placeholder:"Search…",value:s,onChange:u=>n(u.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:137,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:135,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:98,columnNumber:7},this),e.jsxDEV(w,{className:"p-0 flex-1 overflow-y-auto",children:[i&&e.jsxDEV("div",{className:"text-sm text-center py-6 text-muted-foreground",children:"Loading…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:141,columnNumber:23},this),!i&&m.length===0&&e.jsxDEV("div",{className:"text-sm text-muted-foreground p-4 text-center",children:[e.jsxDEV("p",{children:"No suppliers yet."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:144,columnNumber:13},this),e.jsxDEV("p",{className:"text-xs mt-2",children:["Click ",e.jsxDEV("strong",{children:"Sync"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:145,columnNumber:47},this)," to pull them from the upstream EasyGDS catalogue."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:145,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:143,columnNumber:11},this),e.jsxDEV("ul",{className:"divide-y",children:h.map(u=>{const d=u.id===r,g=u.name||u.code||u.id,c=u.source==="from_bookings",N=!!u.merged_into_id;return e.jsxDEV("li",{className:`p-2 cursor-pointer ${d?"bg-blue-50 border-l-4 border-blue-500":"hover:bg-gray-50"} ${N?"opacity-75":""}`,onClick:()=>t(u),children:[e.jsxDEV("div",{className:"text-sm font-medium truncate flex items-center gap-1.5",children:[e.jsxDEV("span",{className:u.name?"":"text-gray-500 italic",children:g},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:162,columnNumber:19},this),c&&!N&&e.jsxDEV(I,{variant:"outline",className:"text-[9px] bg-amber-50 text-amber-700 border-amber-200 shrink-0",title:"Auto-discovered from a booking. Rename and add contacts to complete setup.",children:"from bookings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:166,columnNumber:21},this),!N&&(u.variants_count||0)>0&&e.jsxDEV(I,{variant:"outline",className:"text-[9px] bg-violet-50 text-violet-700 border-violet-200 shrink-0",title:`${u.variants_count} other supplier(s) link here as variants`,children:[e.jsxDEV(_e,{className:"h-2.5 w-2.5 mr-0.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:176,columnNumber:23},this)," ",u.variants_count]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:174,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:161,columnNumber:17},this),N&&e.jsxDEV("div",{className:"text-[10px] text-blue-600 flex items-center gap-1 mt-0.5",children:[e.jsxDEV(Js,{className:"h-2.5 w-2.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:185,columnNumber:21},this),e.jsxDEV("span",{className:"truncate",children:u.merged_into_name||u.merged_into_code||"canonical"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:186,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:184,columnNumber:19},this),e.jsxDEV("div",{className:"text-[10px] text-muted-foreground flex items-center gap-2 mt-0.5",children:[u.code&&u.name&&e.jsxDEV("code",{className:"font-mono",children:u.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:190,columnNumber:40},this),e.jsxDEV("span",{className:"flex items-center gap-1",children:[e.jsxDEV(re,{className:"h-2.5 w-2.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:192,columnNumber:21},this)," ",u.contacts_count||0]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:191,columnNumber:19},this),e.jsxDEV("span",{className:"flex items-center gap-1",children:[e.jsxDEV(Gr,{className:"h-2.5 w-2.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:195,columnNumber:21},this)," ",u.email_rules_count||0]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:194,columnNumber:19},this),!u.is_active&&e.jsxDEV(I,{variant:"outline",className:"text-[9px]",children:"inactive"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:197,columnNumber:36},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:189,columnNumber:17},this)]},u.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:158,columnNumber:15},this)})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:148,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:140,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:97,columnNumber:5},this)}function Pi({detail:t}){const r=K(),{toast:o}=F(),[l,s]=x.useState(!1),[n,m]=x.useState(t.name||""),i=q({mutationFn:a=>hs(t.id,{name:a.trim()||null}),onSuccess:()=>{r.invalidateQueries({queryKey:["supplier-detail",t.id]}),r.invalidateQueries({queryKey:["suppliers-local"]}),r.invalidateQueries({queryKey:["supplier-names-by-code"]}),o({title:"Name saved"}),s(!1)},onError:a=>o({variant:"destructive",title:"Could not save",description:a.message})});return!l&&n!==(t.name||"")&&m(t.name||""),l?e.jsxDEV("div",{className:"flex items-center gap-1.5",children:[e.jsxDEV(U,{autoFocus:!0,value:n,onChange:a=>m(a.target.value),onKeyDown:a=>{a.key==="Enter"&&i.mutate(n),a.key==="Escape"&&(m(t.name||""),s(!1))},placeholder:t.code||"Supplier name",className:"h-8 text-base font-semibold w-64",disabled:i.isPending},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:238,columnNumber:9},this),e.jsxDEV(f,{size:"sm",onClick:()=>i.mutate(n),disabled:i.isPending,children:[e.jsxDEV(Ie,{className:"h-3.5 w-3.5 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:251,columnNumber:11},this)," Save"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:250,columnNumber:9},this),e.jsxDEV(f,{size:"sm",variant:"ghost",onClick:()=>{m(t.name||""),s(!1)},children:e.jsxDEV(Le,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:254,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:253,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:237,columnNumber:7},this):e.jsxDEV("button",{type:"button",onClick:()=>s(!0),className:"group flex items-center gap-1.5 hover:bg-gray-100 rounded px-1 -mx-1",title:"Click to rename",children:[e.jsxDEV("h3",{className:`text-lg font-semibold ${t.name?"":"text-gray-500 italic"}`,children:t.name||t.code||t.id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:267,columnNumber:7},this),e.jsxDEV(zt,{className:"h-3.5 w-3.5 text-gray-400 opacity-0 group-hover:opacity-100 transition-opacity"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:270,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:261,columnNumber:5},this)}function Li({detail:t,onSelectCanonical:r}){const o=K(),{toast:l}=F(),[s,n]=x.useState(!1),[m,i]=x.useState(""),[a,h]=x.useState(null),{data:u=[]}=Q({queryKey:["suppliers-local"],queryFn:()=>Ft(),enabled:s,staleTime:3e4}),d=q({mutationFn:c=>ys(t.id,c),onSuccess:()=>{o.invalidateQueries({queryKey:["supplier-detail",t.id]}),o.invalidateQueries({queryKey:["suppliers-local"]}),o.invalidateQueries({queryKey:["supplier-names-by-code"]}),l({title:"Linked",description:"Bookings using this code will now show the canonical name."}),n(!1),h(null),i("")},onError:c=>l({variant:"destructive",title:"Could not link",description:c.message})}),g=u.filter(c=>c.id!==t.id&&!c.merged_into_id).filter(c=>{if(!m.trim())return!0;const N=m.toLowerCase();return(c.name||"").toLowerCase().includes(N)||(c.code||"").toLowerCase().includes(N)}).sort((c,N)=>!!c.name!=!!N.name?c.name?-1:1:(c.name||c.code||"").localeCompare(N.name||N.code||""));return e.jsxDEV(ye,{open:s,onOpenChange:n,children:[e.jsxDEV(xr,{asChild:!0,children:e.jsxDEV(f,{size:"sm",variant:"outline",children:[e.jsxDEV(_e,{className:"h-3.5 w-3.5 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:330,columnNumber:11},this)," Link to existing supplier…"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:329,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:328,columnNumber:7},this),e.jsxDEV(Ne,{className:"max-w-lg",children:[e.jsxDEV(De,{children:e.jsxDEV(xe,{children:"Link this supplier to a canonical one"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:335,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:334,columnNumber:9},this),e.jsxDEV("div",{className:"text-xs text-muted-foreground -mt-2",children:["Pick the canonical supplier that ",e.jsxDEV("strong",{children:t.name||t.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:338,columnNumber:44},this)," is a variant of. The Bookings table will show the canonical name for any product carrying",e.jsxDEV("code",{className:"font-mono mx-1",children:t.code||t.id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:340,columnNumber:11},this),"."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:337,columnNumber:9},this),e.jsxDEV("div",{className:"relative",children:[e.jsxDEV(he,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-gray-400"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:343,columnNumber:11},this),e.jsxDEV(U,{autoFocus:!0,className:"pl-7 h-9 text-sm",placeholder:"Search by name or code…",value:m,onChange:c=>i(c.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:344,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:342,columnNumber:9},this),e.jsxDEV("div",{className:"max-h-72 overflow-y-auto border rounded",children:g.length===0?e.jsxDEV("div",{className:"p-4 text-xs text-muted-foreground text-center",children:"No matches."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:354,columnNumber:13},this):e.jsxDEV("ul",{className:"divide-y",children:[g.slice(0,100).map(c=>e.jsxDEV("li",{className:`p-2 cursor-pointer text-sm flex items-center gap-2 ${a===c.id?"bg-blue-50":"hover:bg-gray-50"}`,onClick:()=>h(c.id),children:[e.jsxDEV("input",{type:"radio",checked:a===c.id,onChange:()=>h(c.id),className:"shrink-0"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:361,columnNumber:19},this),e.jsxDEV("div",{className:"flex-1 min-w-0",children:[e.jsxDEV("div",{className:`truncate ${c.name?"font-medium":"text-gray-500 italic"}`,children:c.name||c.code||c.id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:368,columnNumber:21},this),e.jsxDEV("div",{className:"text-[10px] text-muted-foreground flex items-center gap-2",children:[c.code&&c.name&&e.jsxDEV("code",{className:"font-mono",children:c.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:372,columnNumber:44},this),e.jsxDEV("span",{children:[c.contacts_count||0," contacts"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:373,columnNumber:23},this),(c.variants_count||0)>0&&e.jsxDEV("span",{className:"text-violet-600",children:[c.variants_count," variant(s)"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:375,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:371,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:367,columnNumber:19},this)]},c.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:358,columnNumber:17},this)),g.length>100&&e.jsxDEV("li",{className:"p-2 text-[10px] text-muted-foreground text-center",children:"Showing first 100 — refine the search to see more."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:382,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:356,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:352,columnNumber:9},this),e.jsxDEV(it,{children:[e.jsxDEV(f,{variant:"ghost",onClick:()=>{n(!1),h(null)},children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:390,columnNumber:11},this),e.jsxDEV(f,{onClick:()=>a&&d.mutate(a),disabled:!a||d.isPending,children:[e.jsxDEV(_e,{className:"h-3.5 w-3.5 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:392,columnNumber:13},this),d.isPending?"Linking…":"Link"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:391,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:389,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:333,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:327,columnNumber:5},this)}function Ui({detail:t}){const r=K(),{toast:o}=F(),[l,s]=x.useState("email"),[n,m]=x.useState(""),[i,a]=x.useState(""),[h,u]=x.useState(!1),d=q({mutationFn:()=>Ns(t.id,{type:l,value:n.trim(),label:i.trim()||null,is_primary:h}),onSuccess:()=>{r.invalidateQueries({queryKey:["supplier-detail",t.id]}),r.invalidateQueries({queryKey:["suppliers-local"]}),o({title:"Contact added"}),m(""),a(""),u(!1)},onError:S=>o({variant:"destructive",title:"Could not add",description:S.message})}),g=q({mutationFn:S=>Ds(S),onSuccess:()=>{r.invalidateQueries({queryKey:["supplier-detail",t.id]}),r.invalidateQueries({queryKey:["suppliers-local"]})}}),c=q({mutationFn:S=>xs(S.id,{is_primary:!S.is_primary}),onSuccess:()=>r.invalidateQueries({queryKey:["supplier-detail",t.id]})}),N=(S,p)=>!!p.is_primary!=!!S.is_primary?p.is_primary?1:-1:(S.label||"").localeCompare(p.label||""),D=t.contacts.filter(S=>S.type==="email").sort(N),y=t.contacts.filter(S=>S.type==="phone").sort(N),v=l==="email"?["Reservations","Accounting","Operations","After-hours","Group bookings"]:["Reservations","Reception","WhatsApp","After-hours","Mobile","Office"],P=S=>e.jsxDEV("li",{className:"py-2 flex items-center gap-2",children:[S.type==="email"?e.jsxDEV(re,{className:"h-3.5 w-3.5 text-blue-500 shrink-0"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:458,columnNumber:11},this):e.jsxDEV(ct,{className:"h-3.5 w-3.5 text-green-600 shrink-0"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:459,columnNumber:11},this),e.jsxDEV("div",{className:"flex-1 min-w-0",children:[e.jsxDEV("div",{className:"text-sm font-medium truncate",children:S.value},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:461,columnNumber:9},this),e.jsxDEV("div",{className:"text-[10px] text-muted-foreground flex items-center gap-2",children:[S.label&&e.jsxDEV("span",{children:S.label},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:463,columnNumber:23},this),S.is_primary?e.jsxDEV(I,{className:"bg-amber-100 text-amber-800 text-[9px]",children:"primary"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:464,columnNumber:27},this):null]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:462,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:460,columnNumber:7},this),e.jsxDEV(f,{size:"sm",variant:"ghost",onClick:()=>c.mutate(S),title:S.is_primary?"Remove primary":"Mark as primary",children:e.jsxDEV(Gr,{className:`h-3 w-3 ${S.is_primary?"text-amber-500":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:469,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:467,columnNumber:7},this),e.jsxDEV(f,{size:"sm",variant:"ghost",onClick:()=>g.mutate(S.id),className:"text-red-500",title:"Delete contact",children:e.jsxDEV(de,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:473,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:471,columnNumber:7},this)]},S.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:456,columnNumber:5},this);return e.jsxDEV("div",{className:"space-y-3",children:[e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm",children:"Add a contact"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:481,columnNumber:37},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:481,columnNumber:9},this),e.jsxDEV(w,{className:"p-3 pt-0 grid grid-cols-1 md:grid-cols-5 gap-2 items-end",children:[e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Type"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:484,columnNumber:13},this),e.jsxDEV(X,{value:l,onValueChange:S=>{s(S),a("")},children:[e.jsxDEV(Z,{className:"h-8 text-sm",children:e.jsxDEV(ee,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:486,columnNumber:54},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:486,columnNumber:15},this),e.jsxDEV(te,{children:[e.jsxDEV(M,{value:"email",children:e.jsxDEV("span",{className:"inline-flex items-center gap-1.5",children:[e.jsxDEV(re,{className:"h-3 w-3 text-blue-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:489,columnNumber:70},this)," Email"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:489,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:488,columnNumber:17},this),e.jsxDEV(M,{value:"phone",children:e.jsxDEV("span",{className:"inline-flex items-center gap-1.5",children:[e.jsxDEV(ct,{className:"h-3 w-3 text-green-600"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:492,columnNumber:70},this)," Phone"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:492,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:491,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:487,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:485,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:483,columnNumber:11},this),e.jsxDEV("div",{className:"md:col-span-2",children:[e.jsxDEV(A,{className:"text-[10px]",children:l==="email"?"Email address":"Phone number"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:498,columnNumber:13},this),e.jsxDEV(U,{className:"h-8 text-sm",type:l==="email"?"email":"tel",value:n,onChange:S=>m(S.target.value),placeholder:l==="email"?"reservations@supplier.com":"+44 20 7000 0000"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:499,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:497,columnNumber:11},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Label"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:508,columnNumber:13},this),e.jsxDEV(U,{className:"h-8 text-sm",value:i,onChange:S=>a(S.target.value),placeholder:l==="email"?"Reservations, Accounting…":"Reception, WhatsApp…",list:`label-suggestions-${l}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:509,columnNumber:13},this),e.jsxDEV("datalist",{id:`label-suggestions-${l}`,children:v.map(S=>e.jsxDEV("option",{value:S},S,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:517,columnNumber:42},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:516,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:507,columnNumber:11},this),e.jsxDEV("div",{className:"flex items-center gap-2",children:[e.jsxDEV(z,{checked:h,onCheckedChange:u},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:521,columnNumber:13},this),e.jsxDEV("span",{className:"text-xs",children:"Primary"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:522,columnNumber:13},this),e.jsxDEV(f,{size:"sm",className:"ml-auto",onClick:()=>d.mutate(),disabled:!n.trim()||d.isPending,children:[e.jsxDEV(ot,{className:"h-3 w-3 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:524,columnNumber:15},this)," Add"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:523,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:520,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:482,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:480,columnNumber:7},this),e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm flex items-center gap-2",children:[e.jsxDEV(re,{className:"h-4 w-4 text-blue-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:536,columnNumber:13},this)," Emails (",D.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:535,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:534,columnNumber:9},this),e.jsxDEV(w,{className:"p-3 pt-0",children:D.length===0?e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:["No emails yet — pick ",e.jsxDEV("strong",{children:"Email"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:541,columnNumber:79},this)," above and add one."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:541,columnNumber:13},this):e.jsxDEV("ul",{className:"divide-y",children:D.map(P)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:543,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:539,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:533,columnNumber:7},this),e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm flex items-center gap-2",children:[e.jsxDEV(ct,{className:"h-4 w-4 text-green-600"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:551,columnNumber:13},this)," Phone numbers (",y.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:550,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:549,columnNumber:9},this),e.jsxDEV(w,{className:"p-3 pt-0",children:y.length===0?e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:["No phone numbers yet — pick ",e.jsxDEV("strong",{children:"Phone"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:556,columnNumber:86},this),' above and add one (with a label like "Reservations" or "WhatsApp").']},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:556,columnNumber:13},this):e.jsxDEV("ul",{className:"divide-y",children:y.map(P)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:558,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:554,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:548,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:479,columnNumber:5},this)}function ji({detail:t}){var D;const r=K(),{toast:o}=F(),[l,s]=x.useState("domain_wildcard"),[n,m]=x.useState(""),[i,a]=x.useState(100),[h,u]=x.useState(""),d=q({mutationFn:()=>Os(t.id,{rule_type:l,pattern:n.trim(),priority:i,notes:h.trim()||null,is_active:!0}),onSuccess:()=>{r.invalidateQueries({queryKey:["supplier-detail",t.id]}),r.invalidateQueries({queryKey:["suppliers-local"]}),o({title:"Rule added"}),m(""),u(""),a(100)},onError:y=>o({variant:"destructive",title:"Could not add",description:y.message})}),g=q({mutationFn:y=>Cs(y),onSuccess:()=>r.invalidateQueries({queryKey:["supplier-detail",t.id]})}),c=q({mutationFn:y=>As(y.id,{is_active:!y.is_active}),onSuccess:()=>r.invalidateQueries({queryKey:["supplier-detail",t.id]})}),N=(D=pt.find(y=>y.value===l))==null?void 0:D.example;return e.jsxDEV("div",{className:"space-y-3",children:[e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm",children:"Add routing rule"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:602,columnNumber:37},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:602,columnNumber:9},this),e.jsxDEV(w,{className:"p-3 pt-0 grid grid-cols-1 md:grid-cols-6 gap-2 items-end",children:[e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Type"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:605,columnNumber:13},this),e.jsxDEV(X,{value:l,onValueChange:y=>s(y),children:[e.jsxDEV(Z,{className:"h-8 text-sm",children:e.jsxDEV(ee,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:607,columnNumber:54},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:607,columnNumber:15},this),e.jsxDEV(te,{children:pt.map(y=>e.jsxDEV(M,{value:y.value,children:y.label},y.value,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:609,columnNumber:45},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:608,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:606,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:604,columnNumber:11},this),e.jsxDEV("div",{className:"md:col-span-3",children:[e.jsxDEV(A,{className:"text-[10px]",children:"Pattern"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:614,columnNumber:13},this),e.jsxDEV(U,{className:"h-8 text-sm font-mono",value:n,onChange:y=>m(y.target.value),placeholder:N},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:615,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:613,columnNumber:11},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Priority (lower = first)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:618,columnNumber:13},this),e.jsxDEV(U,{type:"number",className:"h-8 text-sm",value:i,onChange:y=>a(Number(y.target.value)||100)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:619,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:617,columnNumber:11},this),e.jsxDEV("div",{className:"flex items-end",children:e.jsxDEV(f,{size:"sm",onClick:()=>d.mutate(),disabled:!n.trim()||d.isPending,className:"w-full",children:[e.jsxDEV(ot,{className:"h-3 w-3 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:623,columnNumber:15},this)," Add"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:622,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:621,columnNumber:11},this),e.jsxDEV("div",{className:"md:col-span-6",children:[e.jsxDEV(A,{className:"text-[10px]",children:"Note (optional)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:627,columnNumber:13},this),e.jsxDEV(U,{className:"h-8 text-sm",value:h,onChange:y=>u(y.target.value),placeholder:"e.g. Primary routing rule"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:628,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:626,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:603,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:601,columnNumber:7},this),e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm",children:["Active rules (",t.email_rules.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:634,columnNumber:37},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:634,columnNumber:9},this),e.jsxDEV(w,{className:"p-3 pt-0",children:[t.email_rules.length===0&&e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:["No rules yet. A common first rule is a ",e.jsxDEV("strong",{children:"Domain wildcard"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:638,columnNumber:54},this)," like ",e.jsxDEV("code",{children:"<supplier_domain>"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:638,columnNumber:92},this)," so every email from the supplier's domain auto-routes."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:637,columnNumber:13},this),e.jsxDEV("ul",{className:"divide-y",children:t.email_rules.map(y=>{var v;return e.jsxDEV("li",{className:"py-2 flex items-center gap-2",children:[e.jsxDEV(I,{variant:"outline",className:"text-[10px]",children:((v=pt.find(P=>P.value===y.rule_type))==null?void 0:v.label)||y.rule_type},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:644,columnNumber:17},this),e.jsxDEV("code",{className:"text-xs font-mono truncate flex-1",children:y.pattern},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:645,columnNumber:17},this),e.jsxDEV("span",{className:"text-[10px] text-muted-foreground",children:["#",y.priority]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:646,columnNumber:17},this),e.jsxDEV(z,{checked:!!y.is_active,onCheckedChange:()=>c.mutate(y)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:647,columnNumber:17},this),e.jsxDEV(f,{size:"sm",variant:"ghost",onClick:()=>g.mutate(y.id),className:"text-red-500",children:e.jsxDEV(de,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:649,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:648,columnNumber:17},this)]},y.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:643,columnNumber:15},this)})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:641,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:635,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:633,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:600,columnNumber:5},this)}function Gi({detail:t}){const r=K(),{toast:o}=F(),[l,s]=x.useState("booking_ref"),[n,m]=x.useState("body"),[i,a]=x.useState(""),[h,u]=x.useState(""),[d,g]=x.useState(100),c=q({mutationFn:()=>Ps(t.id,{field_name:l.trim(),source:n,pattern:i.trim(),fallback_value:h.trim()||null,priority:d,is_active:!0}),onSuccess:()=>{r.invalidateQueries({queryKey:["supplier-detail",t.id]}),r.invalidateQueries({queryKey:["suppliers-local"]}),o({title:"Extraction rule added"}),a(""),u(""),g(100)},onError:y=>o({variant:"destructive",title:"Could not add",description:y.message})}),N=q({mutationFn:y=>Ls(y),onSuccess:()=>r.invalidateQueries({queryKey:["supplier-detail",t.id]})}),D=q({mutationFn:y=>Us(y.id,{is_active:!y.is_active}),onSuccess:()=>r.invalidateQueries({queryKey:["supplier-detail",t.id]})});return e.jsxDEV("div",{className:"space-y-3",children:[e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm",children:"Add extraction rule"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:698,columnNumber:37},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:698,columnNumber:9},this),e.jsxDEV(w,{className:"p-3 pt-0 grid grid-cols-1 md:grid-cols-6 gap-2 items-end",children:[e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Field name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:701,columnNumber:13},this),e.jsxDEV(U,{className:"h-8 text-sm",value:l,onChange:y=>s(y.target.value),list:"field-suggestions"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:702,columnNumber:13},this),e.jsxDEV("datalist",{id:"field-suggestions",children:Ci.map(y=>e.jsxDEV("option",{value:y},y,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:704,columnNumber:48},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:703,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:700,columnNumber:11},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Source"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:708,columnNumber:13},this),e.jsxDEV(X,{value:n,onValueChange:y=>m(y),children:[e.jsxDEV(Z,{className:"h-8 text-sm",children:e.jsxDEV(ee,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:710,columnNumber:54},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:710,columnNumber:15},this),e.jsxDEV(te,{children:[e.jsxDEV(M,{value:"body",children:"Body"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:712,columnNumber:17},this),e.jsxDEV(M,{value:"subject",children:"Subject"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:713,columnNumber:17},this),e.jsxDEV(M,{value:"headers",children:"Headers"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:714,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:711,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:709,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:707,columnNumber:11},this),e.jsxDEV("div",{className:"md:col-span-2",children:[e.jsxDEV(A,{className:"text-[10px]",children:"Pattern (regex, 1st capture used)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:719,columnNumber:13},this),e.jsxDEV(U,{className:"h-8 text-sm font-mono",value:i,onChange:y=>a(y.target.value),placeholder:"Booking\\\\s*Ref[:\\\\s]*([A-Z0-9-]+)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:720,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:718,columnNumber:11},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Fallback (optional)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:724,columnNumber:13},this),e.jsxDEV(U,{className:"h-8 text-sm",value:h,onChange:y=>u(y.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:725,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:723,columnNumber:11},this),e.jsxDEV("div",{className:"flex items-end gap-2",children:[e.jsxDEV(U,{type:"number",className:"h-8 text-sm w-20",value:d,onChange:y=>g(Number(y.target.value)||100)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:728,columnNumber:13},this),e.jsxDEV(f,{size:"sm",onClick:()=>c.mutate(),disabled:!l.trim()||!i.trim()||c.isPending,children:[e.jsxDEV(ot,{className:"h-3 w-3 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:730,columnNumber:15},this)," Add"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:729,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:727,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:699,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:697,columnNumber:7},this),e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm",children:["Active extraction rules (",t.extraction_rules.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:737,columnNumber:37},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:737,columnNumber:9},this),e.jsxDEV(w,{className:"p-3 pt-0",children:[t.extraction_rules.length===0&&e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:["No extraction rules yet. A good first one pulls the supplier's booking reference out of the email body:"," ",e.jsxDEV("code",{className:"font-mono text-[10px] bg-gray-100 px-1",children:"Booking\\s*Ref[:\\s]*([A-Z0-9-]+)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:742,columnNumber:20},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:740,columnNumber:13},this),e.jsxDEV("ul",{className:"divide-y",children:t.extraction_rules.map(y=>e.jsxDEV("li",{className:"py-2 flex items-center gap-2 flex-wrap",children:[e.jsxDEV(I,{className:"bg-violet-100 text-violet-800 text-[10px]",children:y.field_name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:748,columnNumber:17},this),e.jsxDEV("span",{className:"text-[10px] text-muted-foreground",children:y.source},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:749,columnNumber:17},this),e.jsxDEV("code",{className:"text-xs font-mono truncate flex-1",children:y.pattern},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:750,columnNumber:17},this),e.jsxDEV("span",{className:"text-[10px] text-muted-foreground",children:["#",y.priority]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:751,columnNumber:17},this),e.jsxDEV(z,{checked:!!y.is_active,onCheckedChange:()=>D.mutate(y)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:752,columnNumber:17},this),e.jsxDEV(f,{size:"sm",variant:"ghost",onClick:()=>N.mutate(y.id),className:"text-red-500",children:e.jsxDEV(de,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:754,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:753,columnNumber:17},this)]},y.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:747,columnNumber:15},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:745,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:738,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:736,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:696,columnNumber:5},this)}function Vi({currentSupplier:t}){const[r,o]=x.useState(""),[l,s]=x.useState(""),[n,m]=x.useState(""),[i,a]=x.useState(null),[h,u]=x.useState(!1),{toast:d}=F(),g=async()=>{u(!0);try{const c=await Vs({from_email:r,subject:l,body:n});a(c)}catch(c){d({variant:"destructive",title:"Test failed",description:c.message})}finally{u(!1)}};return e.jsxDEV("div",{className:"space-y-3",children:[e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm flex items-center gap-2",children:[e.jsxDEV(st,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:794,columnNumber:13},this)," Test against the current rule set"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:793,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:792,columnNumber:9},this),e.jsxDEV(w,{className:"p-3 pt-0 space-y-2",children:[e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"From"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:799,columnNumber:13},this),e.jsxDEV(U,{className:"h-8 text-sm",placeholder:"reservations@hilton.com",value:r,onChange:c=>o(c.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:800,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:798,columnNumber:11},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Subject"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:803,columnNumber:13},this),e.jsxDEV(U,{className:"h-8 text-sm",value:l,onChange:c=>s(c.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:804,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:802,columnNumber:11},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Body"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:807,columnNumber:13},this),e.jsxDEV(Me,{rows:5,value:n,onChange:c=>m(c.target.value),className:"text-sm font-mono"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:808,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:806,columnNumber:11},this),e.jsxDEV(f,{size:"sm",onClick:g,disabled:h,children:h?"Running…":"Run test"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:810,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:797,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:791,columnNumber:7},this),i&&e.jsxDEV(Y,{className:i.supplier_id?"border-emerald-200 bg-emerald-50/30":"border-gray-200",children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm flex items-center gap-2",children:[i.supplier_id?e.jsxDEV(e.Fragment,{children:[e.jsxDEV(be,{className:"h-4 w-4 text-emerald-700"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:821,columnNumber:21},this)," Matched ",i.supplier_name]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:821,columnNumber:19},this):e.jsxDEV(e.Fragment,{children:[e.jsxDEV(Qe,{className:"h-4 w-4 text-gray-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:822,columnNumber:21},this)," No supplier matched"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:822,columnNumber:19},this),t&&i.supplier_id&&i.supplier_id!==t.id&&e.jsxDEV(I,{variant:"outline",className:"text-[10px] ml-2",children:"⚠ different from selected"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:824,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:819,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:818,columnNumber:11},this),e.jsxDEV(w,{className:"p-3 pt-0 text-sm space-y-2",children:[i.matched_rule&&e.jsxDEV("div",{className:"text-xs",children:[e.jsxDEV("span",{className:"text-muted-foreground",children:"via rule "},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:831,columnNumber:17},this),e.jsxDEV(I,{variant:"outline",className:"text-[10px]",children:i.matched_rule.rule_type},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:832,columnNumber:17},this),e.jsxDEV("code",{className:"ml-1 font-mono text-xs",children:i.matched_rule.pattern},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:833,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:830,columnNumber:15},this),e.jsxDEV("div",{children:[e.jsxDEV("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Extracted fields"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:837,columnNumber:15},this),Object.keys(i.extracted||{}).length===0?e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"None."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:839,columnNumber:17},this):e.jsxDEV("ul",{className:"text-xs space-y-0.5 mt-1",children:Object.entries(i.extracted).map(([c,N])=>e.jsxDEV("li",{children:[e.jsxDEV("code",{className:"font-mono bg-white px-1 rounded border",children:c},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:843,columnNumber:33},this),": ",e.jsxDEV("span",{className:"font-medium",children:N},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:843,columnNumber:102},this)]},c,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:843,columnNumber:21},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:841,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:836,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:828,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:817,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:790,columnNumber:5},this)}function Yi(){var a,h;const t=K(),{toast:r}=F(),[o,l]=x.useState(null),{data:s}=Q({queryKey:["supplier-detail",o==null?void 0:o.id],queryFn:()=>ws(o.id),enabled:!!(o!=null&&o.id)}),{data:n=[]}=Q({queryKey:["suppliers-local"],queryFn:()=>Ft(),staleTime:3e4}),m=q({mutationFn:u=>bs(u),onSuccess:()=>{t.invalidateQueries({queryKey:["supplier-detail"]}),t.invalidateQueries({queryKey:["suppliers-local"]}),t.invalidateQueries({queryKey:["supplier-names-by-code"]}),r({title:"Unlinked"})},onError:u=>r({variant:"destructive",title:"Could not unlink",description:u.message})}),i=!!(s!=null&&s.merged_into_id);return e.jsxDEV("div",{className:"grid grid-cols-12 gap-4 h-[calc(100vh-300px)] min-h-[500px]",children:[e.jsxDEV("div",{className:"col-span-12 md:col-span-4 lg:col-span-3",children:e.jsxDEV(Ai,{selectedId:(o==null?void 0:o.id)||null,onSelect:l},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:898,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:897,columnNumber:7},this),e.jsxDEV("div",{className:"col-span-12 md:col-span-8 lg:col-span-9 overflow-y-auto",children:[!o&&e.jsxDEV(Y,{children:e.jsxDEV(w,{className:"p-10 text-center text-muted-foreground",children:[e.jsxDEV("p",{className:"mb-2",children:"Select a supplier on the left to edit its setup."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:903,columnNumber:13},this),e.jsxDEV("p",{className:"text-xs",children:["No suppliers yet? Click ",e.jsxDEV("strong",{children:"Discover from bookings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:904,columnNumber:60},this)," to seed the list from your cached bookings."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:904,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:902,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:902,columnNumber:11},this),o&&!s&&e.jsxDEV("div",{className:"p-6 text-sm text-muted-foreground",children:"Loading…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:907,columnNumber:33},this),s&&e.jsxDEV(qt,{defaultValue:"contacts",className:"space-y-3",children:[e.jsxDEV("div",{className:"flex items-center gap-3 flex-wrap",children:[i?e.jsxDEV("h3",{className:"text-lg font-semibold text-gray-500",children:e.jsxDEV("code",{className:"font-mono",children:s.code||s.id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:916,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:915,columnNumber:17},this):e.jsxDEV(Pi,{detail:s},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:919,columnNumber:17},this),s.code&&s.name&&!i&&e.jsxDEV("code",{className:"text-xs font-mono text-muted-foreground",children:s.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:922,columnNumber:17},this),s.source==="from_bookings"&&!s.name&&!i&&e.jsxDEV(I,{variant:"outline",className:"text-[10px] bg-amber-50 text-amber-700 border-amber-200",children:"needs name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:925,columnNumber:17},this),!s.is_active&&e.jsxDEV(I,{variant:"outline",className:"text-[10px]",children:"inactive"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:929,columnNumber:37},this),e.jsxDEV("div",{className:"ml-auto flex items-center gap-2",children:[!i&&e.jsxDEV(Li,{detail:s},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:934,columnNumber:31},this),e.jsxDEV("span",{className:"text-xs text-muted-foreground",children:[s.contacts.length," contacts · ",s.email_rules.length," rules"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:935,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:930,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:910,columnNumber:13},this),i&&e.jsxDEV("div",{className:"rounded-md border border-blue-200 bg-blue-50 p-3 flex items-center gap-3 flex-wrap",children:[e.jsxDEV(_e,{className:"h-4 w-4 text-blue-600 shrink-0"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:945,columnNumber:17},this),e.jsxDEV("div",{className:"flex-1 min-w-0",children:[e.jsxDEV("div",{className:"text-sm",children:["Linked to ",e.jsxDEV("strong",{children:s.merged_into_name||s.merged_into_code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:948,columnNumber:31},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:947,columnNumber:19},this),e.jsxDEV("div",{className:"text-xs text-blue-800/80",children:["Bookings carrying ",e.jsxDEV("code",{className:"font-mono",children:s.code||s.id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:951,columnNumber:39},this)," show the canonical name. Edit name + contacts on the canonical row."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:950,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:946,columnNumber:17},this),e.jsxDEV(f,{size:"sm",variant:"outline",onClick:()=>{const u=n.find(d=>d.id===s.merged_into_id);u?l(u):r({variant:"destructive",title:"Canonical not found"})},children:"View canonical"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:955,columnNumber:17},this),e.jsxDEV(f,{size:"sm",variant:"outline",onClick:()=>m.mutate(s.id),disabled:m.isPending,children:[e.jsxDEV(nr,{className:"h-3.5 w-3.5 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:972,columnNumber:19},this),m.isPending?"Unlinking…":"Unlink"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:966,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:944,columnNumber:15},this),!i&&(((a=s.variants)==null?void 0:a.length)||0)>0&&e.jsxDEV(Y,{className:"border-violet-200 bg-violet-50/40",children:[e.jsxDEV(k,{className:"p-3 pb-2",children:e.jsxDEV(R,{className:"text-sm flex items-center gap-2 text-violet-900",children:[e.jsxDEV(_e,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:986,columnNumber:21},this),"Linked codes (",(h=s.variants)==null?void 0:h.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:985,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:984,columnNumber:17},this),e.jsxDEV(w,{className:"p-3 pt-0",children:[e.jsxDEV("p",{className:"text-[11px] text-violet-800/80 mb-2",children:["Bookings carrying any of these codes display as ",e.jsxDEV("strong",{children:s.name||s.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:992,columnNumber:69},this)," automatically."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:991,columnNumber:19},this),e.jsxDEV("ul",{className:"flex flex-wrap gap-1.5",children:(s.variants||[]).map(u=>e.jsxDEV("li",{className:"group inline-flex items-center gap-1 rounded-md bg-white border border-violet-200 px-2 py-1 text-xs hover:border-violet-400 cursor-pointer",onClick:()=>{const d=n.find(g=>g.id===u.id);d&&l(d)},title:"Click to open this linked supplier",children:[e.jsxDEV("code",{className:"font-mono text-violet-900",children:u.code||u.id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1004,columnNumber:25},this),u.name&&u.name!==s.name&&e.jsxDEV("span",{className:"text-gray-500",children:["— ",u.name]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1006,columnNumber:27},this),(u.contacts_count||0)>0&&e.jsxDEV("span",{className:"text-[9px] text-gray-400",title:`${u.contacts_count} own contact(s)`,children:["· ",u.contacts_count,e.jsxDEV(re,{className:"h-2 w-2 inline ml-0.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1010,columnNumber:49},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1009,columnNumber:27},this),e.jsxDEV("button",{type:"button",className:"ml-1 text-gray-400 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity",onClick:d=>{d.stopPropagation(),confirm(`Unlink ${u.code} from ${s.name||s.code}? Bookings carrying ${u.code} will no longer show as ${s.name||s.code}.`)&&m.mutate(u.id)},title:`Unlink ${u.code}`,children:e.jsxDEV(nr,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1024,columnNumber:27},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1013,columnNumber:25},this)]},u.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:996,columnNumber:23},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:994,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:990,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:983,columnNumber:15},this),e.jsxDEV(Ht,{children:[e.jsxDEV(me,{value:"contacts",children:"Contacts"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1034,columnNumber:15},this),e.jsxDEV(me,{value:"contracts",children:"Contracts"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1035,columnNumber:15},this),e.jsxDEV(me,{value:"email-rules",children:"Email routing"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1036,columnNumber:15},this),e.jsxDEV(me,{value:"extraction",children:"Extraction"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1037,columnNumber:15},this),e.jsxDEV(me,{value:"test",children:"Test match"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1038,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1033,columnNumber:13},this),e.jsxDEV(B,{value:"contacts",children:e.jsxDEV(Ui,{detail:s},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1040,columnNumber:43},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1040,columnNumber:13},this),e.jsxDEV(B,{value:"contracts",children:e.jsxDEV(_i,{supplierId:s.id},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1041,columnNumber:44},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1041,columnNumber:13},this),e.jsxDEV(B,{value:"email-rules",children:e.jsxDEV(ji,{detail:s},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1042,columnNumber:46},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1042,columnNumber:13},this),e.jsxDEV(B,{value:"extraction",children:e.jsxDEV(Gi,{detail:s},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1043,columnNumber:45},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1043,columnNumber:13},this),e.jsxDEV(B,{value:"test",children:e.jsxDEV(Vi,{currentSupplier:o},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1044,columnNumber:39},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1044,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:909,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:900,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:896,columnNumber:5},this)}const St="__ops__";function Ge(){return{owner_app_id:null,contract_label:"",account_type:"",credit_limit:"",critical_threshold:"",settlement_currency:"",settlement_currencies:"",effective_from:"",effective_to:"",is_active:!0,notes:""}}function Ct(t){if(!t)return"";const r=String(t).slice(0,10);return/^\d{4}-\d{2}-\d{2}$/.test(r)?r:""}function wi(t){return{owner_app_id:t.owner_app_id,contract_label:t.contract_label||"",account_type:t.account_type||"",credit_limit:t.credit_limit==null?"":String(t.credit_limit),critical_threshold:t.critical_threshold==null?"":String(t.critical_threshold),settlement_currency:t.settlement_currency||"",settlement_currencies:Array.isArray(t.settlement_currencies)?t.settlement_currencies.join(", "):"",effective_from:Ct(t.effective_from),effective_to:Ct(t.effective_to),is_active:!!t.is_active,notes:t.notes||""}}function cr(t){const r=t.settlement_currencies.split(",").map(o=>o.trim().toUpperCase()).filter(Boolean);return{owner_app_id:t.owner_app_id,contract_label:t.contract_label.trim()||null,account_type:t.account_type||null,credit_limit:t.credit_limit===""?null:Number(t.credit_limit),critical_threshold:t.critical_threshold===""?null:Number(t.critical_threshold),settlement_currency:t.settlement_currency.trim().toUpperCase()||null,settlement_currencies:r.length>0?r:null,effective_from:t.effective_from||null,effective_to:t.effective_to||null,is_active:t.is_active,notes:t.notes.trim()||null}}function _i({supplierId:t}){const{toast:r}=F(),o=K(),[l,s]=x.useState(null),[n,m]=x.useState(!1),[i,a]=x.useState(Ge()),{data:h=[],isLoading:u}=Q({queryKey:["supplier-contracts",t],queryFn:()=>_s(t),staleTime:3e4}),{data:d=[]}=Q({queryKey:["easygds-apps"],queryFn:async()=>{try{return await hr()}catch{return[]}},staleTime:5*6e4}),g=new Map(d.map(b=>[b.id,b.name||b.code||b.id])),c=q({mutationFn:()=>vs(t,cr(i)),onSuccess:()=>{o.invalidateQueries({queryKey:["supplier-contracts",t]}),m(!1),a(Ge()),r({title:"Contract created"})},onError:b=>r({variant:"destructive",title:"Create failed",description:b.message})}),N=q({mutationFn:b=>fs(t,b,cr(i)),onSuccess:()=>{o.invalidateQueries({queryKey:["supplier-contracts",t]}),s(null),a(Ge()),r({title:"Contract updated"})},onError:b=>r({variant:"destructive",title:"Update failed",description:b.message})}),D=q({mutationFn:b=>Es(t,b),onSuccess:()=>{o.invalidateQueries({queryKey:["supplier-contracts",t]}),r({title:"Contract deleted"})},onError:b=>r({variant:"destructive",title:"Delete failed",description:b.message})}),y=()=>{s(null),a(Ge()),m(!0)},v=b=>{m(!1),s(b.id),a(wi(b))},P=()=>{m(!1),s(null),a(Ge())},S=b=>b.owner_app_id==null?"Ops (us)":g.get(b.owner_app_id)||b.owner_app_id,p=(b,V)=>e.jsxDEV(Y,{className:"border-orange-200",children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm",children:b==="create"?"New contract":"Edit contract"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1216,columnNumber:35},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1216,columnNumber:7},this),e.jsxDEV(w,{className:"p-3 pt-0 grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Owner"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1219,columnNumber:11},this),e.jsxDEV(X,{value:i.owner_app_id==null?St:i.owner_app_id,onValueChange:C=>a(O=>({...O,owner_app_id:C===St?null:C})),children:[e.jsxDEV(Z,{className:"h-8 text-sm",children:e.jsxDEV(ee,{placeholder:"Pick owner"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1224,columnNumber:52},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1224,columnNumber:13},this),e.jsxDEV(te,{children:[e.jsxDEV(M,{value:St,children:"Ops (us)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1226,columnNumber:15},this),d.map(C=>e.jsxDEV(M,{value:C.id,children:C.name||C.code||C.id},C.id,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1228,columnNumber:17},this))]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1225,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1220,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1218,columnNumber:9},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Label (optional)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1234,columnNumber:11},this),e.jsxDEV(U,{className:"h-8 text-sm",value:i.contract_label,onChange:C=>a(O=>({...O,contract_label:C.target.value})),placeholder:"Master agreement v3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1235,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1233,columnNumber:9},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Account type"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1240,columnNumber:11},this),e.jsxDEV(X,{value:i.account_type||"__inherit__",onValueChange:C=>a(O=>({...O,account_type:C==="__inherit__"?"":C})),children:[e.jsxDEV(Z,{className:"h-8 text-sm",children:e.jsxDEV(ee,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1244,columnNumber:52},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1244,columnNumber:13},this),e.jsxDEV(te,{children:[e.jsxDEV(M,{value:"__inherit__",children:"Inherit from supplier"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1246,columnNumber:15},this),e.jsxDEV(M,{value:"deposit",children:"Deposit"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1247,columnNumber:15},this),e.jsxDEV(M,{value:"credit",children:"Credit"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1248,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1245,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1241,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1239,columnNumber:9},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Credit limit"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1253,columnNumber:11},this),e.jsxDEV(U,{type:"number",className:"h-8 text-sm",value:i.credit_limit,onChange:C=>a(O=>({...O,credit_limit:C.target.value})),placeholder:"Inherit"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1254,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1252,columnNumber:9},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Critical threshold"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1259,columnNumber:11},this),e.jsxDEV(U,{type:"number",className:"h-8 text-sm",value:i.critical_threshold,onChange:C=>a(O=>({...O,critical_threshold:C.target.value})),placeholder:"Inherit"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1260,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1258,columnNumber:9},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Primary settlement currency"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1265,columnNumber:11},this),e.jsxDEV(U,{className:"h-8 text-sm uppercase",value:i.settlement_currency,onChange:C=>a(O=>({...O,settlement_currency:C.target.value})),placeholder:"Inherit (e.g. USD)",maxLength:8},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1266,columnNumber:11},this),e.jsxDEV("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:"Default currency this contract settles in. Bookings get FX-converted to this currency."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1269,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1264,columnNumber:9},this),e.jsxDEV("div",{className:"md:col-span-2",children:[e.jsxDEV(A,{className:"text-[10px]",children:"Also accepted currencies (optional)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1274,columnNumber:11},this),e.jsxDEV(U,{className:"h-8 text-sm uppercase",value:i.settlement_currencies,onChange:C=>a(O=>({...O,settlement_currencies:C.target.value})),placeholder:"EUR, GBP"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1275,columnNumber:11},this),e.jsxDEV("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:"Comma-separated. When a booking's original currency is on this list it routes 1:1 without FX. Otherwise it falls back to the primary currency above."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1278,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1273,columnNumber:9},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Effective from"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1284,columnNumber:11},this),e.jsxDEV(Ot,{value:i.effective_from,onChange:C=>a(O=>({...O,effective_from:C})),placeholder:"Pick a start date"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1285,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1283,columnNumber:9},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Effective to (optional)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1292,columnNumber:11},this),e.jsxDEV(Ot,{value:i.effective_to,onChange:C=>a(O=>({...O,effective_to:C})),placeholder:"Open-ended"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1293,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1291,columnNumber:9},this),e.jsxDEV("div",{className:"flex items-end gap-2",children:e.jsxDEV(A,{className:"text-[10px] flex items-center gap-2",children:[e.jsxDEV(z,{checked:i.is_active,onCheckedChange:C=>a(O=>({...O,is_active:C}))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1301,columnNumber:13},this),"Active"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1300,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1299,columnNumber:9},this),e.jsxDEV("div",{className:"md:col-span-3",children:[e.jsxDEV(A,{className:"text-[10px]",children:"Notes"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1306,columnNumber:11},this),e.jsxDEV(Me,{className:"text-sm",rows:2,value:i.notes,onChange:C=>a(O=>({...O,notes:C.target.value}))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1307,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1305,columnNumber:9},this),e.jsxDEV("div",{className:"md:col-span-3 flex items-center justify-end gap-2",children:[e.jsxDEV(f,{variant:"ghost",size:"sm",onClick:P,children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1311,columnNumber:11},this),e.jsxDEV(f,{size:"sm",onClick:V,disabled:c.isPending||N.isPending,children:[e.jsxDEV(Ie,{className:"h-3 w-3 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1313,columnNumber:13},this)," Save"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1312,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1310,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1217,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1215,columnNumber:5},this);return e.jsxDEV("div",{className:"space-y-3",children:[e.jsxDEV(ki,{supplierId:t},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1327,columnNumber:7},this),e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"p-3 flex flex-row items-center justify-between",children:[e.jsxDEV(R,{className:"text-sm",children:["Contracts (",h.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1331,columnNumber:11},this),!n&&!l&&e.jsxDEV(f,{size:"sm",onClick:y,children:[e.jsxDEV(ot,{className:"h-3 w-3 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1334,columnNumber:15},this)," Add contract"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1333,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1330,columnNumber:9},this),e.jsxDEV(w,{className:"p-3 pt-0 space-y-2",children:[u&&e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"Loading…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1339,columnNumber:25},this),!u&&h.length===0&&!n&&e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"No contracts yet — by default everything against this supplier flows into our statement. Add a contract row for any client app (e.g. ABC, Severals) that has its own direct contract with this supplier so their bookings split into a separate statement."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1341,columnNumber:13},this),e.jsxDEV("ul",{className:"divide-y",children:h.map(b=>e.jsxDEV("li",{className:"py-2",children:l===b.id?p("edit",()=>N.mutate(b.id)):e.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxDEV(I,{className:b.owner_app_id==null?"bg-emerald-100 text-emerald-800":"bg-blue-100 text-blue-800",children:S(b)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1352,columnNumber:21},this),b.contract_label&&e.jsxDEV("span",{className:"text-xs font-medium",children:b.contract_label},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1355,columnNumber:42},this),b.account_type&&e.jsxDEV("span",{className:"text-[10px] text-muted-foreground",children:b.account_type},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1356,columnNumber:40},this),b.credit_limit!=null&&e.jsxDEV("span",{className:"text-[10px] text-muted-foreground",children:["limit ",Number(b.credit_limit).toLocaleString()," ",b.settlement_currency||""]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1358,columnNumber:23},this),Array.isArray(b.settlement_currencies)&&b.settlement_currencies.length>0&&e.jsxDEV("span",{className:"text-[10px] font-mono text-muted-foreground border rounded px-1.5 py-0.5",title:`Also accepts: ${b.settlement_currencies.join(", ")}`,children:[b.settlement_currency||"—"," +",b.settlement_currencies.length]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1363,columnNumber:23},this),b.critical_threshold!=null&&e.jsxDEV("span",{className:"text-[10px] text-muted-foreground",children:["threshold ",Number(b.critical_threshold).toLocaleString()]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1369,columnNumber:23},this),(b.effective_from||b.effective_to)&&e.jsxDEV("span",{className:"text-[10px] text-muted-foreground",children:[b.effective_from||"…"," → ",b.effective_to||"…"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1374,columnNumber:23},this),!b.is_active&&e.jsxDEV(I,{className:"bg-gray-100 text-gray-600 text-[10px]",children:"inactive"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1378,columnNumber:38},this),e.jsxDEV("div",{className:"ml-auto flex items-center gap-1",children:[b.owner_app_id!=null&&e.jsxDEV(Ti,{supplierId:t,contract:b,ownerLabel:S(b)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1384,columnNumber:25},this),e.jsxDEV(f,{variant:"ghost",size:"sm",onClick:()=>v(b),children:e.jsxDEV(zt,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1391,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1390,columnNumber:23},this),e.jsxDEV(jt,{children:[e.jsxDEV(Gt,{asChild:!0,children:e.jsxDEV(f,{variant:"ghost",size:"sm",className:"text-red-500",children:e.jsxDEV(de,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1396,columnNumber:29},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1395,columnNumber:27},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1394,columnNumber:25},this),e.jsxDEV(Vt,{children:[e.jsxDEV(Yt,{children:[e.jsxDEV(wt,{children:"Delete this contract?"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1401,columnNumber:29},this),e.jsxDEV(_t,{children:["Bookings made by ",S(b)," against this supplier will fall back into our statement on the next ledger sync. The action is logged in the audit trail."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1402,columnNumber:29},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1400,columnNumber:27},this),e.jsxDEV(Tt,{children:[e.jsxDEV(kt,{children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1408,columnNumber:29},this),e.jsxDEV(Rt,{onClick:()=>D.mutate(b.id),children:"Delete"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1409,columnNumber:29},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1407,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1399,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1393,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1379,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1351,columnNumber:19},this)},b.id,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1349,columnNumber:15},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1347,columnNumber:11},this),n&&p("create",()=>c.mutate())]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1338,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1329,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1321,columnNumber:5},this)}function Ti({supplierId:t,contract:r,ownerLabel:o}){const{toast:l}=F(),s=K(),[n,m]=x.useState(!1),[i,a]=x.useState(Ct(r.effective_from)),[h,u]=x.useState(""),[d,g]=x.useState(null),c=q({mutationFn:()=>js(t,r.id,i),onSuccess:y=>g(y),onError:y=>l({variant:"destructive",title:"Preview failed",description:y.message})}),N=q({mutationFn:()=>Gs(t,r.id,i,h||void 0),onSuccess:y=>{s.invalidateQueries({queryKey:["supplier-contracts",t]}),s.invalidateQueries({queryKey:["supplier-balances"]}),s.invalidateQueries({queryKey:["supplier-transactions"]}),l({title:`${y.rows_moved} transactions moved`,description:`Statement updated for ${o}.`}),m(!1),g(null),u("")},onError:y=>l({variant:"destructive",title:"Backfill failed",description:y.message})}),D=()=>{g(null),u("")};return e.jsxDEV(ye,{open:n,onOpenChange:y=>{m(y),y||D()},children:[e.jsxDEV(xr,{asChild:!0,children:e.jsxDEV(f,{variant:"ghost",size:"sm",title:`Backfill historical bookings into ${o}'s statement`,children:e.jsxDEV(ti,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1479,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1478,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1477,columnNumber:7},this),e.jsxDEV(Ne,{children:[e.jsxDEV(De,{children:e.jsxDEV(xe,{children:["Backfill historical bookings into ",o,"'s statement"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1484,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1483,columnNumber:9},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:["Re-classifies booking + refund transactions whose booking app matches this contract into this owner's statement. By default new contracts only catch future bookings — use this when the contract was set up late or you want to apply it from a specific historical date. Top-ups are ",e.jsxDEV("strong",{children:"not"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1490,columnNumber:40},this)," moved (they carry their own owner stamp from create time)."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1486,columnNumber:9},this),e.jsxDEV("div",{className:"space-y-3 pt-3",children:[e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"From date"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1495,columnNumber:13},this),e.jsxDEV(Ot,{value:i,onChange:y=>{a(y),g(null)},placeholder:"Pick a date"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1496,columnNumber:13},this),e.jsxDEV("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:"Transactions with txn_date ≥ this date will be inspected."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1501,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1494,columnNumber:11},this),d?e.jsxDEV("div",{className:"space-y-3",children:[e.jsxDEV("div",{className:"rounded-md border bg-slate-50 p-3 text-sm space-y-1",children:[e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV("span",{className:"text-muted-foreground",children:"Transactions that would move"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1518,columnNumber:19},this),e.jsxDEV("strong",{children:d.rows_to_move.toLocaleString()},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1519,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1517,columnNumber:17},this),d.first_txn&&e.jsxDEV("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxDEV("span",{children:"Earliest affected"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1523,columnNumber:21},this),e.jsxDEV("span",{children:d.first_txn},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1524,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1522,columnNumber:19},this),d.last_txn&&e.jsxDEV("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxDEV("span",{children:"Latest affected"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1529,columnNumber:21},this),e.jsxDEV("span",{children:d.last_txn},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1530,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1528,columnNumber:19},this),d.rows_to_move===0&&d.rows_already_owned>0&&e.jsxDEV("p",{className:"text-xs text-emerald-700",children:["All ",d.rows_already_owned.toLocaleString()," matching booking",d.rows_already_owned===1?"":"s"," ",d.rows_already_owned===1?"is":"are"," already on ",o,"'s statement — nothing to backfill."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1534,columnNumber:19},this),d.rows_to_move===0&&d.rows_already_owned===0&&e.jsxDEV("p",{className:"text-xs text-muted-foreground italic",children:["No qualifying bookings for this supplier under ",o,` in this window. Either none exist yet or the ledger hasn't synced — try the "Re-sync ledger now" button on the Diagnose card above if you're expecting bookings to appear.`]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1540,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1516,columnNumber:15},this),d.rows_to_move>0&&e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-[10px]",children:"Reason (optional, audit trail)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1550,columnNumber:19},this),e.jsxDEV(Me,{rows:2,value:h,onChange:y=>u(y.target.value),placeholder:"e.g. Severals contract was set up late; bookings since 2026-03-01 belong to them."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1551,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1549,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1515,columnNumber:13},this):e.jsxDEV(f,{onClick:()=>c.mutate(),disabled:!i||c.isPending,className:"w-full",children:c.isPending?"Counting…":"Preview impact (dry-run)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1507,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1493,columnNumber:9},this),e.jsxDEV(it,{children:[d&&e.jsxDEV(f,{variant:"ghost",onClick:D,children:"Re-preview"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1563,columnNumber:23},this),e.jsxDEV(f,{variant:"ghost",onClick:()=>m(!1),children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1564,columnNumber:11},this),e.jsxDEV(f,{onClick:()=>N.mutate(),disabled:!d||d.rows_to_move===0||N.isPending,children:N.isPending?"Moving…":d?`Move ${d.rows_to_move} rows`:"Backfill"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1565,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1562,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1482,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1476,columnNumber:5},this)}function ki({supplierId:t}){var y;const{toast:r}=F(),o=K(),[l,s]=x.useState(""),[n,m]=x.useState(null),[i,a]=x.useState(!1),[h,u]=x.useState(null),[d,g]=x.useState(!1),c=async()=>{if(l.trim()){a(!0),u(null),m(null);try{const v=await tr(l.trim());m(v)}catch(v){u(v.message||"Failed to diagnose")}finally{a(!1)}}},N=async()=>{if(!d){g(!0);try{if(await Ys(),o.invalidateQueries({queryKey:["supplier-balances"]}),o.invalidateQueries({queryKey:["supplier-transactions"]}),o.invalidateQueries({queryKey:["app-finances"]}),l.trim()){const v=await tr(l.trim());m(v)}r({title:"Re-sync complete",description:"Ledger rebuilt and trace refreshed."})}catch(v){r({variant:"destructive",title:"Re-sync failed",description:v.message})}finally{g(!1)}}},D=(y=n==null?void 0:n.contracts)==null?void 0:y.filter(v=>{var P;return v.supplier_id===t||v.supplier_id==null&&((P=n==null?void 0:n.supplier_codes)==null?void 0:P.some(S=>{var p;return((p=S.supplier)==null?void 0:p.canonical_id)===t}))});return e.jsxDEV(Y,{className:"border-amber-100 bg-amber-50/30",children:[e.jsxDEV(k,{className:"p-3",children:e.jsxDEV(R,{className:"text-sm flex items-center gap-2",children:[e.jsxDEV(st,{className:"h-4 w-4 text-amber-700"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1643,columnNumber:11},this),"Diagnose a booking"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1642,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1641,columnNumber:7},this),e.jsxDEV(w,{className:"p-3 pt-0 space-y-2",children:[e.jsxDEV("p",{className:"text-[11px] text-muted-foreground",children:["Paste a booking code (e.g. ",e.jsxDEV("code",{className:"font-mono",children:"DEMOS202302354"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1649,columnNumber:38},this),") to see why it is or isn't classified on a contract for this supplier."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1648,columnNumber:9},this),e.jsxDEV("div",{className:"flex items-center gap-2",children:[e.jsxDEV(U,{value:l,onChange:v=>s(v.target.value),placeholder:"booking code",className:"h-8 text-sm font-mono flex-1",onKeyDown:v=>{v.key==="Enter"&&c()}},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1653,columnNumber:11},this),e.jsxDEV(f,{size:"sm",onClick:c,disabled:!l.trim()||i,children:i?"Tracing…":"Run trace"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1660,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1652,columnNumber:9},this),h&&e.jsxDEV("p",{className:"text-xs text-red-600",children:h},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1665,columnNumber:19},this),n&&e.jsxDEV("div",{className:"rounded-md border bg-white p-3 space-y-2 text-xs",children:[e.jsxDEV("div",{className:`flex items-center gap-2 ${n.ok?"text-emerald-700":"text-red-700"}`,children:[n.ok?e.jsxDEV(be,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1670,columnNumber:27},this):e.jsxDEV(Qe,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1670,columnNumber:66},this),e.jsxDEV("span",{className:"font-semibold",children:n.ok?"Contract matches":`Failed at step: ${n.step}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1671,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1669,columnNumber:13},this),n.message&&e.jsxDEV("p",{className:"text-muted-foreground",children:n.message},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1675,columnNumber:31},this),n.booking&&e.jsxDEV("div",{className:"border-t pt-2",children:[e.jsxDEV("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground mb-1",children:"Booking"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1679,columnNumber:17},this),e.jsxDEV("div",{className:"grid grid-cols-2 gap-1 text-[11px]",children:[e.jsxDEV("div",{children:[e.jsxDEV("span",{className:"text-muted-foreground",children:"Code:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1681,columnNumber:24},this)," ",e.jsxDEV("span",{className:"font-mono",children:n.booking.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1681,columnNumber:77},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1681,columnNumber:19},this),e.jsxDEV("div",{children:[e.jsxDEV("span",{className:"text-muted-foreground",children:"App:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1682,columnNumber:24},this)," ",e.jsxDEV("span",{className:"font-mono",children:n.booking.app_id||e.jsxDEV("em",{children:"NULL"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1682,columnNumber:129},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1682,columnNumber:76},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1682,columnNumber:19},this),e.jsxDEV("div",{children:[e.jsxDEV("span",{className:"text-muted-foreground",children:"Status:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1683,columnNumber:24},this)," ",n.booking.booking_status,"/",n.booking.payment_status]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1683,columnNumber:19},this),e.jsxDEV("div",{children:[e.jsxDEV("span",{className:"text-muted-foreground",children:"Total:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1684,columnNumber:24},this)," ",n.booking.total_amount," ",n.booking.currency]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1684,columnNumber:19},this),e.jsxDEV("div",{className:"col-span-2",children:[e.jsxDEV("span",{className:"text-muted-foreground",children:"Created:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1685,columnNumber:47},this)," ",n.booking.upstream_created]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1685,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1680,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1678,columnNumber:15},this),n.supplier_codes&&n.supplier_codes.length>0&&e.jsxDEV("div",{className:"border-t pt-2",children:[e.jsxDEV("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground mb-1",children:["Supplier codes (",n.supplier_codes.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1692,columnNumber:17},this),e.jsxDEV("ul",{className:"space-y-1",children:n.supplier_codes.map((v,P)=>{var S;return e.jsxDEV("li",{className:"flex items-center gap-2 text-[11px]",children:[v.resolved?e.jsxDEV(be,{className:"h-3 w-3 text-emerald-600"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1698,columnNumber:37},this):e.jsxDEV(Qe,{className:"h-3 w-3 text-red-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1698,columnNumber:93},this),e.jsxDEV("code",{className:`font-mono ${v.primary?"font-semibold":""}`,children:v.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1699,columnNumber:23},this),v.primary&&e.jsxDEV(I,{variant:"outline",className:"text-[10px] bg-amber-50 text-amber-700 border-amber-300",children:"primary"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1701,columnNumber:25},this),v.supplier&&e.jsxDEV("span",{className:"text-muted-foreground",children:["→ ",v.supplier.name||v.supplier.code," (",String(v.supplier.canonical_id).slice(0,8),"…)"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1704,columnNumber:25},this),((S=v.supplier)==null?void 0:S.canonical_id)===t&&e.jsxDEV(I,{variant:"outline",className:"text-[10px] bg-blue-50 text-blue-700",children:"this supplier"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1709,columnNumber:25},this)]},P,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1697,columnNumber:21},this)})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1695,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1691,columnNumber:15},this),D&&D.length>0&&e.jsxDEV("div",{className:"border-t pt-2",children:[e.jsxDEV("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground mb-1",children:"Contract checks (for this supplier)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1719,columnNumber:17},this),e.jsxDEV("ul",{className:"space-y-1",children:D.map((v,P)=>e.jsxDEV("li",{className:"flex items-start gap-2 text-[11px]",children:[v.in_effective_window?e.jsxDEV(be,{className:"h-3 w-3 text-emerald-600 mt-0.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1726,columnNumber:27},this):e.jsxDEV(Qe,{className:"h-3 w-3 text-red-500 mt-0.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1727,columnNumber:27},this),e.jsxDEV("span",{children:[e.jsxDEV("code",{className:"font-mono",children:v.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1728,columnNumber:29},this)," — ",v.reason]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1728,columnNumber:23},this)]},P,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1724,columnNumber:21},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1722,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1718,columnNumber:15},this),n.current_ledger_rows&&n.current_ledger_rows.length>0&&e.jsxDEV("div",{className:"border-t pt-2",children:[e.jsxDEV("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground mb-1",children:["Current ledger rows (",n.current_ledger_rows.length,")"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1737,columnNumber:17},this),e.jsxDEV("ul",{className:"space-y-0.5 font-mono text-[10px]",children:n.current_ledger_rows.map((v,P)=>e.jsxDEV("li",{className:"flex gap-2",children:[e.jsxDEV("span",{className:"text-muted-foreground",children:v.type},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1743,columnNumber:23},this),e.jsxDEV("span",{children:[v.amount," ",v.currency]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1744,columnNumber:23},this),e.jsxDEV("span",{className:"text-muted-foreground",children:"→ owner_app_id:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1745,columnNumber:23},this),e.jsxDEV("span",{className:v.owner_app_id?"text-blue-700":"text-emerald-700",children:v.owner_app_id||"NULL (Ops)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1746,columnNumber:23},this)]},P,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1742,columnNumber:21},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1740,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1736,columnNumber:15},this),n.hint&&e.jsxDEV("p",{className:"border-t pt-2 text-[11px] text-muted-foreground italic",children:n.hint},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1756,columnNumber:15},this),n.ok&&(!n.current_ledger_rows||n.current_ledger_rows.length===0)&&e.jsxDEV("div",{className:"border-t pt-2 flex items-center justify-end",children:e.jsxDEV(f,{size:"sm",onClick:N,disabled:d,children:d?"Re-syncing…":"Re-sync ledger now"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1765,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1764,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1668,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1647,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierSetup.tsx",lineNumber:1640,columnNumber:5},this)}const dr={name:"",code:"",description:"",sort_order:"0",is_active:!0};function Ri(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Mi({open:t,onOpenChange:r,editing:o}){const{toast:l}=F(),s=oi(),n=li(),[m,i]=x.useState(dr),a=(o==null?void 0:o.id)??"new";t&&m.__key!==a&&i({...o?{name:o.name,code:o.code,description:o.description||"",sort_order:String(o.sort_order),is_active:Number(o.is_active)===1}:dr,__key:a});const h=async()=>{if(!m.name.trim())return l({title:"Name is required",variant:"destructive"});const u=m.code.trim()||Ri(m.name);if(!u)return l({title:"Code is required",variant:"destructive"});const d={name:m.name.trim(),code:u,description:m.description.trim()||void 0,sort_order:Number(m.sort_order)||0,is_active:m.is_active};try{o?(await n.mutateAsync({id:o.id,payload:d}),l({title:"Payment method updated"})):(await s.mutateAsync(d),l({title:"Payment method added"})),r(!1)}catch(g){l({title:o?"Update failed":"Add failed",description:g.message,variant:"destructive"})}};return e.jsxDEV(ye,{open:t,onOpenChange:r,children:e.jsxDEV(Ne,{className:"max-w-md",children:[e.jsxDEV(De,{children:[e.jsxDEV(xe,{children:o?"Edit Payment Method":"Add Payment Method"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:100,columnNumber:11},this),e.jsxDEV(fr,{children:"Shown in the supplier top-up form's Payment Method dropdown."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:101,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:99,columnNumber:9},this),e.jsxDEV("div",{className:"space-y-4 py-2",children:[e.jsxDEV("div",{children:[e.jsxDEV(A,{htmlFor:"pm-name",children:"Name *"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:107,columnNumber:13},this),e.jsxDEV(U,{id:"pm-name",value:m.name,onChange:u=>i(d=>({...d,name:u.target.value})),placeholder:"e.g. Wise"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:108,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:106,columnNumber:11},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{htmlFor:"pm-code",children:"Code (slug)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:113,columnNumber:13},this),e.jsxDEV(U,{id:"pm-code",value:m.code,onChange:u=>i(d=>({...d,code:u.target.value})),placeholder:"auto-generated from name if blank"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:114,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:112,columnNumber:11},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{htmlFor:"pm-desc",children:"Description"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:119,columnNumber:13},this),e.jsxDEV(Me,{id:"pm-desc",rows:2,value:m.description,onChange:u=>i(d=>({...d,description:u.target.value}))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:120,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:118,columnNumber:11},this),e.jsxDEV("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxDEV("div",{children:[e.jsxDEV(A,{htmlFor:"pm-order",children:"Sort order"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:125,columnNumber:15},this),e.jsxDEV(U,{id:"pm-order",type:"number",value:m.sort_order,onChange:u=>i(d=>({...d,sort_order:u.target.value}))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:126,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:124,columnNumber:13},this),e.jsxDEV("div",{className:"flex items-end",children:e.jsxDEV(A,{className:"flex items-center gap-2 cursor-pointer",children:[e.jsxDEV(z,{checked:m.is_active,onCheckedChange:u=>i(d=>({...d,is_active:u}))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:131,columnNumber:17},this),"Active"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:130,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:129,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:123,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:105,columnNumber:9},this),e.jsxDEV(it,{children:[e.jsxDEV(f,{variant:"outline",onClick:()=>r(!1),children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:138,columnNumber:11},this),e.jsxDEV(f,{onClick:h,disabled:s.isPending||n.isPending,children:s.isPending||n.isPending?"Saving…":o?"Save Changes":"Add Method"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:139,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:137,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:98,columnNumber:7},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:97,columnNumber:5},this)}function Ii(){const{toast:t}=F(),{data:r=[],isLoading:o}=ii(),l=ni(),[s,n]=x.useState(!1),[m,i]=x.useState(null),a=()=>{i(null),n(!0)},h=d=>{i(d),n(!0)},u=async d=>{if(confirm(`Deactivate "${d.name}"? Existing top-ups will still show this method, but it will no longer appear in the form.`))try{await l.mutateAsync(d.id),t({title:"Deactivated"})}catch(g){t({title:"Failed",description:g.message,variant:"destructive"})}};return e.jsxDEV(Y,{children:[e.jsxDEV(k,{className:"flex flex-row items-start justify-between space-y-0",children:[e.jsxDEV("div",{children:[e.jsxDEV(R,{className:"flex items-center gap-2",children:[e.jsxDEV(rr,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:173,columnNumber:13},this),e.jsxDEV("span",{children:"Payment Methods"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:174,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:172,columnNumber:11},this),e.jsxDEV(Re,{children:"Channels shown in the supplier top-up form. Deactivating keeps history but hides the method from new top-ups."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:176,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:171,columnNumber:9},this),e.jsxDEV(f,{onClick:a,children:[e.jsxDEV(le,{className:"h-4 w-4 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:180,columnNumber:35},this),"Add Method"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:180,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:170,columnNumber:7},this),e.jsxDEV(w,{children:o?e.jsxDEV("div",{className:"space-y-2",children:Array.from({length:4}).map((d,g)=>e.jsxDEV(vr,{className:"h-10 w-full"},g,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:184,columnNumber:79},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:184,columnNumber:11},this):r.length===0?e.jsxDEV("div",{className:"py-12 text-center text-muted-foreground",children:[e.jsxDEV(rr,{className:"h-8 w-8 mx-auto mb-3 opacity-40"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:187,columnNumber:13},this),e.jsxDEV("p",{children:"No payment methods yet."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:188,columnNumber:13},this),e.jsxDEV(f,{variant:"outline",size:"sm",className:"mt-3",onClick:a,children:[e.jsxDEV(le,{className:"h-4 w-4 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:190,columnNumber:15},this),"Add the first one"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:189,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:186,columnNumber:11},this):e.jsxDEV("div",{className:"overflow-x-auto",children:e.jsxDEV("table",{className:"w-full text-sm",children:[e.jsxDEV("thead",{children:e.jsxDEV("tr",{className:"border-b text-left text-xs uppercase tracking-wider text-muted-foreground",children:[e.jsxDEV("th",{className:"px-3 py-2 font-medium",children:"Name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:198,columnNumber:19},this),e.jsxDEV("th",{className:"px-3 py-2 font-medium",children:"Code"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:199,columnNumber:19},this),e.jsxDEV("th",{className:"px-3 py-2 font-medium",children:"Description"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:200,columnNumber:19},this),e.jsxDEV("th",{className:"px-3 py-2 font-medium",children:"Sort"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:201,columnNumber:19},this),e.jsxDEV("th",{className:"px-3 py-2 font-medium",children:"Status"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:202,columnNumber:19},this),e.jsxDEV("th",{className:"px-3 py-2 font-medium w-24"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:203,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:197,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:196,columnNumber:15},this),e.jsxDEV("tbody",{children:r.map(d=>e.jsxDEV("tr",{className:`border-b ${Number(d.is_active)===0?"opacity-50":""}`,children:[e.jsxDEV("td",{className:"px-3 py-2 font-medium",children:d.name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:209,columnNumber:21},this),e.jsxDEV("td",{className:"px-3 py-2 font-mono text-xs text-muted-foreground",children:d.code},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:210,columnNumber:21},this),e.jsxDEV("td",{className:"px-3 py-2 text-xs text-muted-foreground max-w-xs truncate",children:d.description||"—"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:211,columnNumber:21},this),e.jsxDEV("td",{className:"px-3 py-2 text-muted-foreground",children:d.sort_order},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:212,columnNumber:21},this),e.jsxDEV("td",{className:"px-3 py-2",children:Number(d.is_active)===1?e.jsxDEV("span",{className:"inline-block px-2 py-0.5 bg-green-100 text-green-700 rounded text-xs",children:"Active"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:215,columnNumber:25},this):e.jsxDEV("span",{className:"inline-block px-2 py-0.5 bg-gray-100 text-gray-600 rounded text-xs",children:"Inactive"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:217,columnNumber:25},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:213,columnNumber:21},this),e.jsxDEV("td",{className:"px-3 py-2",children:e.jsxDEV("div",{className:"flex items-center gap-1 justify-end",children:[e.jsxDEV(f,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>h(d),children:e.jsxDEV(ci,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:223,columnNumber:27},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:222,columnNumber:25},this),Number(d.is_active)===1&&e.jsxDEV(f,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 hover:text-red-600",onClick:()=>u(d),children:e.jsxDEV(de,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:228,columnNumber:29},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:226,columnNumber:27},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:221,columnNumber:23},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:220,columnNumber:21},this)]},d.id,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:208,columnNumber:19},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:206,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:195,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:194,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:182,columnNumber:7},this),e.jsxDEV(Mi,{open:s,onOpenChange:n,editing:m},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:240,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PaymentMethodsSettings.tsx",lineNumber:169,columnNumber:5},this)}function Fi(){const{toast:t}=F(),{data:r,isLoading:o}=ai(),l=mi(),s=ui(),[n,m]=x.useState([]),[i,a]=x.useState("");x.useEffect(()=>{r!=null&&r.emails&&m(r.emails)},[r==null?void 0:r.emails]);const h=()=>{const c=i.trim();if(c){if(!c.includes("@")){t({title:"Not an email",description:`"${c}" needs an @`,variant:"destructive"});return}if(n.includes(c)){t({title:"Already in list",description:c});return}m([...n,c]),a("")}},u=c=>m(n.filter(N=>N!==c)),d=async()=>{try{await l.mutateAsync(n),t({title:"Recipients saved",description:`${n.length} address${n.length===1?"":"es"}`})}catch(c){t({title:"Save failed",description:c.message,variant:"destructive"})}},g=async()=>{try{const c=await s.mutateAsync(),N=(c==null?void 0:c.checked)??0,D=(c==null?void 0:c.alerted)??0;t({title:D>0?`${D} alert${D===1?"":"s"} sent`:"No suppliers in critical state",description:`Checked ${N} supplier${N===1?"":"s"} with thresholds configured.${D>0?" Recipients should see the email shortly.":""}`})}catch(c){t({title:"Trigger failed",description:c.message,variant:"destructive"})}};return e.jsxDEV("div",{className:"space-y-6",children:[e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV("div",{className:"flex items-start gap-3",children:[e.jsxDEV(re,{className:"h-5 w-5 mt-0.5 text-orange-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:81,columnNumber:13},this),e.jsxDEV("div",{children:[e.jsxDEV(R,{children:"Finance Team Recipients"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:83,columnNumber:15},this),e.jsxDEV(Re,{className:"mt-1",children:"Email addresses notified when a supplier's balance breaches its critical threshold. One canonical list is used for every supplier alert."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:84,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:82,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:80,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:79,columnNumber:9},this),e.jsxDEV(w,{className:"space-y-4",children:o?e.jsxDEV(vr,{className:"h-20 w-full"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:93,columnNumber:13},this):e.jsxDEV(e.Fragment,{children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"finance-email-input",children:"Add recipient"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:97,columnNumber:17},this),e.jsxDEV("div",{className:"flex gap-2",children:[e.jsxDEV(U,{id:"finance-email-input",type:"email",placeholder:"finance@example.com",value:i,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),h())}},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:99,columnNumber:19},this),e.jsxDEV(f,{type:"button",variant:"outline",onClick:h,disabled:!i.trim(),children:[e.jsxDEV(le,{className:"h-4 w-4 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:108,columnNumber:21},this)," Add"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:107,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:98,columnNumber:17},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"Press Enter or click Add. Don't forget to Save below."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:111,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:96,columnNumber:15},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{children:"Current recipients"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:115,columnNumber:17},this),n.length===0?e.jsxDEV("div",{className:"rounded border border-dashed p-4 text-sm text-muted-foreground flex items-center gap-2",children:[e.jsxDEV(Bt,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:118,columnNumber:21},this),"No recipients configured. Critical alerts will be logged but no email is sent."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:117,columnNumber:19},this):e.jsxDEV("div",{className:"flex flex-wrap gap-2",children:n.map(c=>e.jsxDEV("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-orange-50 text-orange-900 text-sm border border-orange-200",children:[c,e.jsxDEV("button",{type:"button",onClick:()=>u(c),className:"text-orange-700 hover:text-orange-900","aria-label":`Remove ${c}`,children:e.jsxDEV(Le,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:135,columnNumber:27},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:129,columnNumber:25},this)]},c,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:124,columnNumber:23},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:122,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:114,columnNumber:15},this),e.jsxDEV("div",{className:"flex flex-wrap gap-2 pt-2",children:[e.jsxDEV(f,{onClick:d,disabled:l.isPending,children:l.isPending?"Saving…":"Save recipients"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:144,columnNumber:17},this),e.jsxDEV(f,{variant:"outline",onClick:g,disabled:s.isPending,children:[e.jsxDEV(Ts,{className:`h-4 w-4 mr-1.5 ${s.isPending?"animate-pulse":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:148,columnNumber:19},this),s.isPending?"Checking…":"Run critical-check now"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:147,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:143,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:95,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:91,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:78,columnNumber:7},this),e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"text-base",children:"How alerts work"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:159,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:158,columnNumber:9},this),e.jsxDEV(w,{className:"text-sm text-muted-foreground space-y-2",children:[e.jsxDEV("p",{children:["After each supplier-balance sync (~every 10 minutes), the server checks every supplier with a configured ",e.jsxDEV("code",{className:"text-xs",children:"critical_threshold"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:164,columnNumber:40},this)," and decides if the threshold is breached:"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:162,columnNumber:11},this),e.jsxDEV("ul",{className:"list-disc pl-5 space-y-1",children:[e.jsxDEV("li",{children:[e.jsxDEV("strong",{className:"text-foreground",children:"Deposit accounts:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:168,columnNumber:17},this)," alert when remaining deposit ≤ threshold (running out of pre-paid balance)."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:168,columnNumber:13},this),e.jsxDEV("li",{children:[e.jsxDEV("strong",{className:"text-foreground",children:"Credit accounts:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:169,columnNumber:17},this)," alert when outstanding debt ≥ threshold (approaching credit limit)."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:169,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:167,columnNumber:11},this),e.jsxDEV("p",{children:"Alerts are sent through the SMTP account configured under Settings → SMTP. A 24-hour cooldown prevents the same supplier from re-alerting more than once per day."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:171,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:161,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:157,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/FinanceAlertsSettings.tsx",lineNumber:77,columnNumber:5},this)}const bt={},Bi=(bt==null?void 0:bt.VITE_API_URL)||"/api";function qi(){const t=localStorage.getItem("platform_token");return t?{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}:{"Content-Type":"application/json"}}async function pr(t,r){const l=await(await fetch(`${Bi}${t}`,{...r,headers:{...qi(),...(r==null?void 0:r.headers)||{}}})).json();if(l!=null&&l.error)throw new Error(l.error.message||"Request failed");return l.data}function Hi({status:t}){return t==="ok"?e.jsxDEV(I,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200 gap-1",children:[e.jsxDEV(be,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:76,columnNumber:99},this),"OK"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:76,columnNumber:12},this):t==="missing_columns"?e.jsxDEV(I,{variant:"outline",className:"bg-amber-50 text-amber-700 border-amber-200 gap-1",children:[e.jsxDEV(rt,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:79,columnNumber:99},this),"Missing columns"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:79,columnNumber:12},this):e.jsxDEV(I,{variant:"outline",className:"bg-red-50 text-red-700 border-red-200 gap-1",children:[e.jsxDEV(Bt,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:81,columnNumber:91},this),"Missing table"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:81,columnNumber:10},this)}function zi(){var g;const{toast:t}=F(),r=K(),[o,l]=x.useState(!1),[s,n]=x.useState(null),{data:m,isLoading:i,isFetching:a,refetch:h}=Q({queryKey:["schema-health"],queryFn:()=>pr("/admin/schema/check"),refetchOnWindowFocus:!1}),u=q({mutationFn:()=>pr("/admin/schema/repair",{method:"POST",body:"{}"}),onSuccess:c=>{n(c),r.setQueryData(["schema-health"],c.report);const N=c.changes.reduce((D,y)=>D+(y.created?1:0)+y.columns_added.length,0);if(c.bootstrap_error)t({title:"Repair finished with errors",description:c.bootstrap_error,variant:"destructive"});else if(N===0)t({title:"Schema already up to date",description:"Nothing to add."});else{const D=c.changes.filter(v=>v.created).length,y=c.changes.reduce((v,P)=>v+P.columns_added.length,0);t({title:"Schema repaired",description:`Created ${D} table(s), added ${y} column(s).`})}},onError:c=>{t({title:"Repair failed",description:c.message,variant:"destructive"})}});x.useEffect(()=>{n(null)},[(g=m==null?void 0:m.summary)==null?void 0:g.tables_total]);const d=((m==null?void 0:m.tables)||[]).filter(c=>o||c.status!=="ok");return e.jsxDEV("div",{className:"space-y-6",children:e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:[e.jsxDEV(R,{className:"flex items-center gap-2",children:[e.jsxDEV(Dr,{className:"h-5 w-5 text-orange-500"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:136,columnNumber:13},this),"Database Health"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:135,columnNumber:11},this),e.jsxDEV(Re,{children:["Compares the live MySQL database against the schema this build expects. Use this after restoring a backup or upgrading to a new version — if any tables or columns are missing, click ",e.jsxDEV("strong",{children:"Repair"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:140,columnNumber:195},this)," to create them. The repair runs the same idempotent migration the server runs at startup, so it's safe to click multiple times."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:139,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:134,columnNumber:9},this),e.jsxDEV(w,{children:[e.jsxDEV("div",{className:"flex flex-wrap items-center gap-3 p-4 rounded-lg border bg-gray-50 mb-4",children:[e.jsxDEV("div",{className:"flex items-center gap-2",children:[i?e.jsxDEV(Xe,{className:"h-5 w-5 animate-spin text-gray-400"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:148,columnNumber:19},this):m!=null&&m.ok?e.jsxDEV(be,{className:"h-5 w-5 text-green-600"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:150,columnNumber:21},this):e.jsxDEV(Bt,{className:"h-5 w-5 text-red-600"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:151,columnNumber:21},this),e.jsxDEV("div",{children:[e.jsxDEV("div",{className:"text-sm font-semibold",children:i?"Checking…":m!=null&&m.ok?"Schema is healthy":"Schema has gaps"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:153,columnNumber:17},this),m&&e.jsxDEV("div",{className:"text-xs text-muted-foreground",children:[m.summary.tables_ok," of ",m.summary.tables_total," tables OK",m.summary.tables_missing>0&&e.jsxDEV(e.Fragment,{children:[" · ",m.summary.tables_missing," missing"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:159,columnNumber:59},this),m.summary.tables_with_missing_columns>0&&e.jsxDEV(e.Fragment,{children:[" · ",m.summary.tables_with_missing_columns," need columns"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:160,columnNumber:72},this),m.summary.columns_missing>0&&e.jsxDEV(e.Fragment,{children:[" · ",m.summary.columns_missing," columns missing"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:161,columnNumber:60},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:157,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:152,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:146,columnNumber:13},this),e.jsxDEV("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxDEV(f,{size:"sm",variant:"outline",onClick:()=>h(),disabled:a,children:[e.jsxDEV(Xe,{className:`h-3.5 w-3.5 mr-1.5 ${a?"animate-spin":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:172,columnNumber:17},this),a?"Checking…":"Re-check"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:167,columnNumber:15},this),e.jsxDEV(f,{size:"sm",onClick:()=>u.mutate(),disabled:u.isPending||((m==null?void 0:m.ok)??!1),className:"bg-orange-600 hover:bg-orange-700",children:[e.jsxDEV(Er,{className:`h-3.5 w-3.5 mr-1.5 ${u.isPending?"animate-pulse":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:181,columnNumber:17},this),u.isPending?"Repairing…":"Repair"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:175,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:166,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:145,columnNumber:11},this),s&&s.changes.length>0&&e.jsxDEV("div",{className:"mb-4 p-3 rounded-md border border-green-200 bg-green-50",children:[e.jsxDEV("div",{className:"flex items-center gap-2 text-sm font-semibold text-green-900 mb-1.5",children:[e.jsxDEV(be,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:191,columnNumber:17},this),"Repair applied — ",s.changes.length," table(s) updated"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:190,columnNumber:15},this),e.jsxDEV("ul",{className:"space-y-1 text-xs text-green-900 ml-6 list-disc",children:s.changes.map(c=>e.jsxDEV("li",{children:[e.jsxDEV("code",{className:"bg-white/50 px-1 rounded",children:c.table},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:197,columnNumber:21},this),c.created&&e.jsxDEV(e.Fragment,{children:" — table created"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:198,columnNumber:35},this),c.columns_added.length>0&&e.jsxDEV(e.Fragment,{children:[" — added ",c.columns_added.length," column(s): ",e.jsxDEV("code",{className:"bg-white/50 px-1 rounded",children:c.columns_added.join(", ")},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:199,columnNumber:99},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:199,columnNumber:52},this)]},c.table,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:196,columnNumber:19},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:194,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:189,columnNumber:13},this),e.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[e.jsxDEV("div",{className:"text-sm font-semibold",children:"Tables"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:208,columnNumber:13},this),e.jsxDEV("button",{type:"button",onClick:()=>l(c=>!c),className:"text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1",children:[o?e.jsxDEV(yr,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:214,columnNumber:25},this):e.jsxDEV(tt,{className:"h-3 w-3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:214,columnNumber:63},this),o?"Hide healthy tables":"Show all tables"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:209,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:207,columnNumber:11},this),m&&d.length===0?e.jsxDEV("div",{className:"p-6 text-center text-sm text-muted-foreground border rounded-md bg-gray-50",children:m.ok?"🎉 Every expected table and column is present.":'Toggle "Show all tables" to inspect healthy ones too.'},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:219,columnNumber:13},this):e.jsxDEV(Lr,{className:"border rounded-md max-h-[480px]",children:e.jsxDEV("table",{className:"w-full text-sm",children:[e.jsxDEV("thead",{className:"bg-gray-50 border-b sticky top-0 z-10",children:e.jsxDEV("tr",{className:"text-left text-xs uppercase text-muted-foreground",children:[e.jsxDEV("th",{className:"px-3 py-2 font-medium",children:"Table"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:229,columnNumber:21},this),e.jsxDEV("th",{className:"px-3 py-2 font-medium",children:"Status"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:230,columnNumber:21},this),e.jsxDEV("th",{className:"px-3 py-2 font-medium text-right",children:"Columns"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:231,columnNumber:21},this),e.jsxDEV("th",{className:"px-3 py-2 font-medium",children:"Missing"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:232,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:228,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:227,columnNumber:17},this),e.jsxDEV("tbody",{className:"divide-y",children:d.map(c=>e.jsxDEV("tr",{className:c.status==="ok"?"":"bg-amber-50/30",children:[e.jsxDEV("td",{className:"px-3 py-2 font-mono text-xs",children:c.name},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:238,columnNumber:23},this),e.jsxDEV("td",{className:"px-3 py-2",children:e.jsxDEV(Hi,{status:c.status},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:239,columnNumber:49},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:239,columnNumber:23},this),e.jsxDEV("td",{className:"px-3 py-2 text-right text-xs text-muted-foreground",children:[c.present_columns,"/",c.expected_columns]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:240,columnNumber:23},this),e.jsxDEV("td",{className:"px-3 py-2 text-xs",children:c.missing_columns.length===0?e.jsxDEV("span",{className:"text-muted-foreground",children:"—"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:245,columnNumber:29},this):e.jsxDEV("span",{className:"font-mono text-amber-900",children:c.missing_columns.join(", ")},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:246,columnNumber:29},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:243,columnNumber:23},this)]},c.name,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:237,columnNumber:21},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:235,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:226,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:225,columnNumber:13},this),m&&m.extra_tables.length>0&&e.jsxDEV("details",{className:"mt-4",children:[e.jsxDEV("summary",{className:"cursor-pointer text-xs text-muted-foreground hover:text-foreground",children:[m.extra_tables.length," table(s) in the database not tracked by this build (informational, not a problem)"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:258,columnNumber:15},this),e.jsxDEV("div",{className:"mt-2 p-3 border rounded-md bg-gray-50 text-xs font-mono text-muted-foreground",children:m.extra_tables.join(", ")},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:261,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:257,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:143,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:133,columnNumber:7},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/DatabaseHealthSettings.tsx",lineNumber:132,columnNumber:5},this)}const Ki={hcn:"HCN (Hotel Confirmation Number)",cancellation:"Cancellation",change_request:"Change request",refund:"Refund",other:"Other / fallback"};function $i(){const t=K(),{toast:r}=F(),{data:o,isLoading:l}=Q({queryKey:["supplier-reminders-sla-config"],queryFn:Ms}),[s,n]=x.useState(null);x.useEffect(()=>{o!=null&&o.config&&!s&&n({...o.config})},[o,s]);const m=q({mutationFn:u=>ks(u),onSuccess:u=>{n(u),t.invalidateQueries({queryKey:["supplier-reminders-sla-config"]}),r({title:"SLA config saved",description:"New thresholds apply on the next reminder check (within 5 min)."})},onError:u=>r({variant:"destructive",title:"Save failed",description:u.message})});if(l||!s)return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{children:"Supplier reminder SLAs"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:57,columnNumber:21},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:57,columnNumber:9},this),e.jsxDEV(w,{children:e.jsxDEV("p",{className:"text-sm text-muted-foreground",children:"Loading…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:58,columnNumber:22},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:58,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:56,columnNumber:7},this);const i=(u,d,g)=>{const c=Number(g);n(N=>N&&{...N,[u]:{...N[u],[d]:Number.isFinite(c)?c:0}})},a=(o==null?void 0:o.config)&&JSON.stringify(o.config)!==JSON.stringify(s),h=(o==null?void 0:o.types)||["hcn","cancellation","change_request","refund","other"];return e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:[e.jsxDEV(R,{className:"flex items-center gap-2",children:[e.jsxDEV(Rs,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:82,columnNumber:11},this)," Supplier reminder SLAs"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:81,columnNumber:9},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground mt-1",children:"For each request type, set how long to wait before the system pings Ops, how often to re-ping after that, and the maximum number of escalation rounds. Defaults are conservative — tune per your team's response patterns."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:84,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:80,columnNumber:7},this),e.jsxDEV(w,{children:[e.jsxDEV("div",{className:"space-y-3",children:h.map(u=>{var c;const d=s[u]||{sla_hours:0,reminder_every_hours:0,max_escalation_level:0},g=(c=o==null?void 0:o.defaults)==null?void 0:c[u];return e.jsxDEV("div",{className:"rounded-md border p-3 bg-slate-50/50",children:[e.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[e.jsxDEV("div",{className:"flex items-center gap-2",children:[e.jsxDEV("span",{className:"font-medium text-sm",children:Ki[u]||u},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:99,columnNumber:21},this),e.jsxDEV(I,{variant:"outline",className:"text-[10px] font-mono",children:u},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:100,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:98,columnNumber:19},this),g&&e.jsxDEV("span",{className:"text-[11px] text-muted-foreground",children:["Default: ",g.sla_hours,"h / every ",g.reminder_every_hours,"h / ",g.max_escalation_level,"× max"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:103,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:97,columnNumber:17},this),e.jsxDEV("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-xs",htmlFor:`sla-${u}`,children:"First reminder after (hours)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:110,columnNumber:21},this),e.jsxDEV(U,{id:`sla-${u}`,type:"number",min:1,step:"1",value:d.sla_hours,onChange:N=>i(u,"sla_hours",N.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:111,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:109,columnNumber:19},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-xs",htmlFor:`every-${u}`,children:"Re-ping every (hours)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:118,columnNumber:21},this),e.jsxDEV(U,{id:`every-${u}`,type:"number",min:1,step:"1",value:d.reminder_every_hours,onChange:N=>i(u,"reminder_every_hours",N.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:119,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:117,columnNumber:19},this),e.jsxDEV("div",{children:[e.jsxDEV(A,{className:"text-xs",htmlFor:`max-${u}`,children:"Max escalations"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:126,columnNumber:21},this),e.jsxDEV(U,{id:`max-${u}`,type:"number",min:1,step:"1",value:d.max_escalation_level,onChange:N=>i(u,"max_escalation_level",N.target.value)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:127,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:125,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:108,columnNumber:17},this)]},u,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:96,columnNumber:15},this)})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:91,columnNumber:9},this),e.jsxDEV("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsxDEV(f,{variant:"outline",onClick:()=>(o==null?void 0:o.config)&&n({...o.config}),disabled:!a||m.isPending,children:"Reset"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:140,columnNumber:11},this),e.jsxDEV(f,{onClick:()=>s&&m.mutate(s),disabled:!a||m.isPending,children:[e.jsxDEV(Ie,{className:"h-4 w-4 mr-1.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:151,columnNumber:13},this),m.isPending?"Saving…":"Save SLAs"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:147,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:139,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:90,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SupplierRemindersSlaSettings.tsx",lineNumber:79,columnNumber:5},this)}function Qi({open:t,onOpenChange:r}){const[o,l]=x.useState(""),[s,n]=x.useState(""),[m,i]=x.useState(""),[a,h]=x.useState(!1),[u,d]=x.useState(!1),[g,c]=x.useState(!1),[N,D]=x.useState(!1),{toast:y}=F(),v=async P=>{if(P.preventDefault(),s!==m){y({title:"Error",description:"New passwords do not match.",variant:"destructive"});return}if(s.length<6){y({title:"Error",description:"Password must be at least 6 characters long.",variant:"destructive"});return}D(!0);try{const{error:S}=await Ee.auth.updateUser({password:s});S?y({title:"Error",description:S.message,variant:"destructive"}):(y({title:"Success",description:"Password updated successfully."}),l(""),n(""),i(""),r(!1))}catch{y({title:"Error",description:"An unexpected error occurred.",variant:"destructive"})}finally{D(!1)}};return e.jsxDEV(ye,{open:t,onOpenChange:r,children:e.jsxDEV(Ne,{className:"sm:max-w-[425px]",children:[e.jsxDEV(De,{children:[e.jsxDEV(xe,{className:"flex items-center gap-2",children:[e.jsxDEV(Vr,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:92,columnNumber:13},this),"Change Password"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:91,columnNumber:11},this),e.jsxDEV(fr,{children:"Enter your current password and choose a new one."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:95,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:90,columnNumber:9},this),e.jsxDEV("form",{onSubmit:v,className:"space-y-4",children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"currentPassword",children:"Current Password"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:101,columnNumber:13},this),e.jsxDEV("div",{className:"relative",children:[e.jsxDEV(U,{id:"currentPassword",type:a?"text":"password",value:o,onChange:P=>l(P.target.value),required:!0,disabled:N},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:103,columnNumber:15},this),e.jsxDEV(f,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>h(!a),disabled:N,children:a?e.jsxDEV(dt,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:120,columnNumber:19},this):e.jsxDEV(Je,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:122,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:111,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:102,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:100,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"newPassword",children:"New Password"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:129,columnNumber:13},this),e.jsxDEV("div",{className:"relative",children:[e.jsxDEV(U,{id:"newPassword",type:u?"text":"password",value:s,onChange:P=>n(P.target.value),required:!0,disabled:N,minLength:6},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:131,columnNumber:15},this),e.jsxDEV(f,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>d(!u),disabled:N,children:u?e.jsxDEV(dt,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:149,columnNumber:19},this):e.jsxDEV(Je,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:151,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:140,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:130,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:128,columnNumber:11},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"confirmPassword",children:"Confirm New Password"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:158,columnNumber:13},this),e.jsxDEV("div",{className:"relative",children:[e.jsxDEV(U,{id:"confirmPassword",type:g?"text":"password",value:m,onChange:P=>i(P.target.value),required:!0,disabled:N,minLength:6},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:160,columnNumber:15},this),e.jsxDEV(f,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>c(!g),disabled:N,children:g?e.jsxDEV(dt,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:178,columnNumber:19},this):e.jsxDEV(Je,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:180,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:169,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:159,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:157,columnNumber:11},this),e.jsxDEV(it,{children:[e.jsxDEV(f,{type:"button",variant:"outline",onClick:()=>r(!1),disabled:N,children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:187,columnNumber:13},this),e.jsxDEV(f,{type:"submit",disabled:N,children:N?"Updating...":"Update Password"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:195,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:186,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:99,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:89,columnNumber:7},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/PasswordChangeDialog.tsx",lineNumber:88,columnNumber:5},this)}var Fe={},Ji=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},wr={},W={};let $t;const Wi=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];W.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17};W.getSymbolTotalCodewords=function(r){return Wi[r]};W.getBCHDigit=function(t){let r=0;for(;t!==0;)r++,t>>>=1;return r};W.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');$t=r};W.isKanjiModeEnabled=function(){return typeof $t<"u"};W.toSJIS=function(r){return $t(r)};var lt={};(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+o)}}t.isValid=function(l){return l&&typeof l.bit<"u"&&l.bit>=0&&l.bit<4},t.from=function(l,s){if(t.isValid(l))return l;try{return r(l)}catch{return s}}})(lt);function _r(){this.buffer=[],this.length=0}_r.prototype={get:function(t){const r=Math.floor(t/8);return(this.buffer[r]>>>7-t%8&1)===1},put:function(t,r){for(let o=0;o<r;o++)this.putBit((t>>>r-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}};var Xi=_r;function Be(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}Be.prototype.set=function(t,r,o,l){const s=t*this.size+r;this.data[s]=o,l&&(this.reservedBit[s]=!0)};Be.prototype.get=function(t,r){return this.data[t*this.size+r]};Be.prototype.xor=function(t,r,o){this.data[t*this.size+r]^=o};Be.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]};var Zi=Be,Tr={};(function(t){const r=W.getSymbolSize;t.getRowColCoords=function(l){if(l===1)return[];const s=Math.floor(l/7)+2,n=r(l),m=n===145?26:Math.ceil((n-13)/(2*s-2))*2,i=[n-7];for(let a=1;a<s-1;a++)i[a]=i[a-1]-m;return i.push(6),i.reverse()},t.getPositions=function(l){const s=[],n=t.getRowColCoords(l),m=n.length;for(let i=0;i<m;i++)for(let a=0;a<m;a++)i===0&&a===0||i===0&&a===m-1||i===m-1&&a===0||s.push([n[i],n[a]]);return s}})(Tr);var kr={};const en=W.getSymbolSize,Sr=7;kr.getPositions=function(r){const o=en(r);return[[0,0],[o-Sr,0],[0,o-Sr]]};var Rr={};(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};t.isValid=function(s){return s!=null&&s!==""&&!isNaN(s)&&s>=0&&s<=7},t.from=function(s){return t.isValid(s)?parseInt(s,10):void 0},t.getPenaltyN1=function(s){const n=s.size;let m=0,i=0,a=0,h=null,u=null;for(let d=0;d<n;d++){i=a=0,h=u=null;for(let g=0;g<n;g++){let c=s.get(d,g);c===h?i++:(i>=5&&(m+=r.N1+(i-5)),h=c,i=1),c=s.get(g,d),c===u?a++:(a>=5&&(m+=r.N1+(a-5)),u=c,a=1)}i>=5&&(m+=r.N1+(i-5)),a>=5&&(m+=r.N1+(a-5))}return m},t.getPenaltyN2=function(s){const n=s.size;let m=0;for(let i=0;i<n-1;i++)for(let a=0;a<n-1;a++){const h=s.get(i,a)+s.get(i,a+1)+s.get(i+1,a)+s.get(i+1,a+1);(h===4||h===0)&&m++}return m*r.N2},t.getPenaltyN3=function(s){const n=s.size;let m=0,i=0,a=0;for(let h=0;h<n;h++){i=a=0;for(let u=0;u<n;u++)i=i<<1&2047|s.get(h,u),u>=10&&(i===1488||i===93)&&m++,a=a<<1&2047|s.get(u,h),u>=10&&(a===1488||a===93)&&m++}return m*r.N3},t.getPenaltyN4=function(s){let n=0;const m=s.data.length;for(let a=0;a<m;a++)n+=s.data[a];return Math.abs(Math.ceil(n*100/m/5)-10)*r.N4};function o(l,s,n){switch(l){case t.Patterns.PATTERN000:return(s+n)%2===0;case t.Patterns.PATTERN001:return s%2===0;case t.Patterns.PATTERN010:return n%3===0;case t.Patterns.PATTERN011:return(s+n)%3===0;case t.Patterns.PATTERN100:return(Math.floor(s/2)+Math.floor(n/3))%2===0;case t.Patterns.PATTERN101:return s*n%2+s*n%3===0;case t.Patterns.PATTERN110:return(s*n%2+s*n%3)%2===0;case t.Patterns.PATTERN111:return(s*n%3+(s+n)%2)%2===0;default:throw new Error("bad maskPattern:"+l)}}t.applyMask=function(s,n){const m=n.size;for(let i=0;i<m;i++)for(let a=0;a<m;a++)n.isReserved(a,i)||n.xor(a,i,o(s,a,i))},t.getBestMask=function(s,n){const m=Object.keys(t.Patterns).length;let i=0,a=1/0;for(let h=0;h<m;h++){n(h),t.applyMask(h,s);const u=t.getPenaltyN1(s)+t.getPenaltyN2(s)+t.getPenaltyN3(s)+t.getPenaltyN4(s);t.applyMask(h,s),u<a&&(a=u,i=h)}return i}})(Rr);var at={};const ce=lt,He=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],ze=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];at.getBlocksCount=function(r,o){switch(o){case ce.L:return He[(r-1)*4+0];case ce.M:return He[(r-1)*4+1];case ce.Q:return He[(r-1)*4+2];case ce.H:return He[(r-1)*4+3];default:return}};at.getTotalCodewordsCount=function(r,o){switch(o){case ce.L:return ze[(r-1)*4+0];case ce.M:return ze[(r-1)*4+1];case ce.Q:return ze[(r-1)*4+2];case ce.H:return ze[(r-1)*4+3];default:return}};var Mr={},mt={};const Ye=new Uint8Array(512),Ze=new Uint8Array(256);(function(){let r=1;for(let o=0;o<255;o++)Ye[o]=r,Ze[r]=o,r<<=1,r&256&&(r^=285);for(let o=255;o<512;o++)Ye[o]=Ye[o-255]})();mt.log=function(r){if(r<1)throw new Error("log("+r+")");return Ze[r]};mt.exp=function(r){return Ye[r]};mt.mul=function(r,o){return r===0||o===0?0:Ye[Ze[r]+Ze[o]]};(function(t){const r=mt;t.mul=function(l,s){const n=new Uint8Array(l.length+s.length-1);for(let m=0;m<l.length;m++)for(let i=0;i<s.length;i++)n[m+i]^=r.mul(l[m],s[i]);return n},t.mod=function(l,s){let n=new Uint8Array(l);for(;n.length-s.length>=0;){const m=n[0];for(let a=0;a<s.length;a++)n[a]^=r.mul(s[a],m);let i=0;for(;i<n.length&&n[i]===0;)i++;n=n.slice(i)}return n},t.generateECPolynomial=function(l){let s=new Uint8Array([1]);for(let n=0;n<l;n++)s=t.mul(s,new Uint8Array([1,r.exp(n)]));return s}})(Mr);const Ir=Mr;function Qt(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}Qt.prototype.initialize=function(r){this.degree=r,this.genPoly=Ir.generateECPolynomial(this.degree)};Qt.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(r.length+this.degree);o.set(r);const l=Ir.mod(o,this.genPoly),s=this.degree-l.length;if(s>0){const n=new Uint8Array(this.degree);return n.set(l,s),n}return l};var tn=Qt,Fr={},pe={},Jt={};Jt.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40};var ae={};const Br="[0-9]+",rn="[A-Z $%*+\\-./:]+";let Te="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Te=Te.replace(/u/g,"\\u");const sn="(?:(?![A-Z0-9 $%*+\\-./:]|"+Te+`)(?:.|[\r
]))+`;ae.KANJI=new RegExp(Te,"g");ae.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");ae.BYTE=new RegExp(sn,"g");ae.NUMERIC=new RegExp(Br,"g");ae.ALPHANUMERIC=new RegExp(rn,"g");const nn=new RegExp("^"+Te+"$"),on=new RegExp("^"+Br+"$"),ln=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");ae.testKanji=function(r){return nn.test(r)};ae.testNumeric=function(r){return on.test(r)};ae.testAlphanumeric=function(r){return ln.test(r)};(function(t){const r=Jt,o=ae;t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(n,m){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!r.isValid(m))throw new Error("Invalid version: "+m);return m>=1&&m<10?n.ccBits[0]:m<27?n.ccBits[1]:n.ccBits[2]},t.getBestModeForData=function(n){return o.testNumeric(n)?t.NUMERIC:o.testAlphanumeric(n)?t.ALPHANUMERIC:o.testKanji(n)?t.KANJI:t.BYTE},t.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},t.isValid=function(n){return n&&n.bit&&n.ccBits};function l(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+s)}}t.from=function(n,m){if(t.isValid(n))return n;try{return l(n)}catch{return m}}})(pe);(function(t){const r=W,o=at,l=lt,s=pe,n=Jt,m=7973,i=r.getBCHDigit(m);function a(g,c,N){for(let D=1;D<=40;D++)if(c<=t.getCapacity(D,N,g))return D}function h(g,c){return s.getCharCountIndicator(g,c)+4}function u(g,c){let N=0;return g.forEach(function(D){const y=h(D.mode,c);N+=y+D.getBitsLength()}),N}function d(g,c){for(let N=1;N<=40;N++)if(u(g,N)<=t.getCapacity(N,c,s.MIXED))return N}t.from=function(c,N){return n.isValid(c)?parseInt(c,10):N},t.getCapacity=function(c,N,D){if(!n.isValid(c))throw new Error("Invalid QR Code version");typeof D>"u"&&(D=s.BYTE);const y=r.getSymbolTotalCodewords(c),v=o.getTotalCodewordsCount(c,N),P=(y-v)*8;if(D===s.MIXED)return P;const S=P-h(D,c);switch(D){case s.NUMERIC:return Math.floor(S/10*3);case s.ALPHANUMERIC:return Math.floor(S/11*2);case s.KANJI:return Math.floor(S/13);case s.BYTE:default:return Math.floor(S/8)}},t.getBestVersionForData=function(c,N){let D;const y=l.from(N,l.M);if(Array.isArray(c)){if(c.length>1)return d(c,y);if(c.length===0)return 1;D=c[0]}else D=c;return a(D.mode,D.getLength(),y)},t.getEncodedBits=function(c){if(!n.isValid(c)||c<7)throw new Error("Invalid QR Code version");let N=c<<12;for(;r.getBCHDigit(N)-i>=0;)N^=m<<r.getBCHDigit(N)-i;return c<<12|N}})(Fr);var qr={};const At=W,Hr=1335,an=21522,br=At.getBCHDigit(Hr);qr.getEncodedBits=function(r,o){const l=r.bit<<3|o;let s=l<<10;for(;At.getBCHDigit(s)-br>=0;)s^=Hr<<At.getBCHDigit(s)-br;return(l<<10|s)^an};var zr={};const mn=pe;function Oe(t){this.mode=mn.NUMERIC,this.data=t.toString()}Oe.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)};Oe.prototype.getLength=function(){return this.data.length};Oe.prototype.getBitsLength=function(){return Oe.getBitsLength(this.data.length)};Oe.prototype.write=function(r){let o,l,s;for(o=0;o+3<=this.data.length;o+=3)l=this.data.substr(o,3),s=parseInt(l,10),r.put(s,10);const n=this.data.length-o;n>0&&(l=this.data.substr(o),s=parseInt(l,10),r.put(s,n*3+1))};var un=Oe;const cn=pe,gt=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Ce(t){this.mode=cn.ALPHANUMERIC,this.data=t}Ce.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)};Ce.prototype.getLength=function(){return this.data.length};Ce.prototype.getBitsLength=function(){return Ce.getBitsLength(this.data.length)};Ce.prototype.write=function(r){let o;for(o=0;o+2<=this.data.length;o+=2){let l=gt.indexOf(this.data[o])*45;l+=gt.indexOf(this.data[o+1]),r.put(l,11)}this.data.length%2&&r.put(gt.indexOf(this.data[o]),6)};var dn=Ce;const pn=pe;function Ae(t){this.mode=pn.BYTE,typeof t=="string"?this.data=new TextEncoder().encode(t):this.data=new Uint8Array(t)}Ae.getBitsLength=function(r){return r*8};Ae.prototype.getLength=function(){return this.data.length};Ae.prototype.getBitsLength=function(){return Ae.getBitsLength(this.data.length)};Ae.prototype.write=function(t){for(let r=0,o=this.data.length;r<o;r++)t.put(this.data[r],8)};var Sn=Ae;const bn=pe,gn=W;function Pe(t){this.mode=bn.KANJI,this.data=t}Pe.getBitsLength=function(r){return r*13};Pe.prototype.getLength=function(){return this.data.length};Pe.prototype.getBitsLength=function(){return Pe.getBitsLength(this.data.length)};Pe.prototype.write=function(t){let r;for(r=0;r<this.data.length;r++){let o=gn.toSJIS(this.data[r]);if(o>=33088&&o<=40956)o-=33088;else if(o>=57408&&o<=60351)o-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),t.put(o,13)}};var hn=Pe,Kr={exports:{}};(function(t){var r={single_source_shortest_paths:function(o,l,s){var n={},m={};m[l]=0;var i=r.PriorityQueue.make();i.push(l,0);for(var a,h,u,d,g,c,N,D,y;!i.empty();){a=i.pop(),h=a.value,d=a.cost,g=o[h]||{};for(u in g)g.hasOwnProperty(u)&&(c=g[u],N=d+c,D=m[u],y=typeof m[u]>"u",(y||D>N)&&(m[u]=N,i.push(u,N),n[u]=h))}if(typeof s<"u"&&typeof m[s]>"u"){var v=["Could not find a path from ",l," to ",s,"."].join("");throw new Error(v)}return n},extract_shortest_path_from_predecessor_list:function(o,l){for(var s=[],n=l;n;)s.push(n),o[n],n=o[n];return s.reverse(),s},find_path:function(o,l,s){var n=r.single_source_shortest_paths(o,l,s);return r.extract_shortest_path_from_predecessor_list(n,s)},PriorityQueue:{make:function(o){var l=r.PriorityQueue,s={},n;o=o||{};for(n in l)l.hasOwnProperty(n)&&(s[n]=l[n]);return s.queue=[],s.sorter=o.sorter||l.default_sorter,s},default_sorter:function(o,l){return o.cost-l.cost},push:function(o,l){var s={value:o,cost:l};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=r})(Kr);var yn=Kr.exports;(function(t){const r=pe,o=un,l=dn,s=Sn,n=hn,m=ae,i=W,a=yn;function h(v){return unescape(encodeURIComponent(v)).length}function u(v,P,S){const p=[];let b;for(;(b=v.exec(S))!==null;)p.push({data:b[0],index:b.index,mode:P,length:b[0].length});return p}function d(v){const P=u(m.NUMERIC,r.NUMERIC,v),S=u(m.ALPHANUMERIC,r.ALPHANUMERIC,v);let p,b;return i.isKanjiModeEnabled()?(p=u(m.BYTE,r.BYTE,v),b=u(m.KANJI,r.KANJI,v)):(p=u(m.BYTE_KANJI,r.BYTE,v),b=[]),P.concat(S,p,b).sort(function(C,O){return C.index-O.index}).map(function(C){return{data:C.data,mode:C.mode,length:C.length}})}function g(v,P){switch(P){case r.NUMERIC:return o.getBitsLength(v);case r.ALPHANUMERIC:return l.getBitsLength(v);case r.KANJI:return n.getBitsLength(v);case r.BYTE:return s.getBitsLength(v)}}function c(v){return v.reduce(function(P,S){const p=P.length-1>=0?P[P.length-1]:null;return p&&p.mode===S.mode?(P[P.length-1].data+=S.data,P):(P.push(S),P)},[])}function N(v){const P=[];for(let S=0;S<v.length;S++){const p=v[S];switch(p.mode){case r.NUMERIC:P.push([p,{data:p.data,mode:r.ALPHANUMERIC,length:p.length},{data:p.data,mode:r.BYTE,length:p.length}]);break;case r.ALPHANUMERIC:P.push([p,{data:p.data,mode:r.BYTE,length:p.length}]);break;case r.KANJI:P.push([p,{data:p.data,mode:r.BYTE,length:h(p.data)}]);break;case r.BYTE:P.push([{data:p.data,mode:r.BYTE,length:h(p.data)}])}}return P}function D(v,P){const S={},p={start:{}};let b=["start"];for(let V=0;V<v.length;V++){const C=v[V],O=[];for(let T=0;T<C.length;T++){const _=C[T],E=""+V+T;O.push(E),S[E]={node:_,lastCount:0},p[E]={};for(let j=0;j<b.length;j++){const J=b[j];S[J]&&S[J].node.mode===_.mode?(p[J][E]=g(S[J].lastCount+_.length,_.mode)-g(S[J].lastCount,_.mode),S[J].lastCount+=_.length):(S[J]&&(S[J].lastCount=_.length),p[J][E]=g(_.length,_.mode)+4+r.getCharCountIndicator(_.mode,P))}}b=O}for(let V=0;V<b.length;V++)p[b[V]].end=0;return{map:p,table:S}}function y(v,P){let S;const p=r.getBestModeForData(v);if(S=r.from(P,p),S!==r.BYTE&&S.bit<p.bit)throw new Error('"'+v+'" cannot be encoded with mode '+r.toString(S)+`.
 Suggested mode is: `+r.toString(p));switch(S===r.KANJI&&!i.isKanjiModeEnabled()&&(S=r.BYTE),S){case r.NUMERIC:return new o(v);case r.ALPHANUMERIC:return new l(v);case r.KANJI:return new n(v);case r.BYTE:return new s(v)}}t.fromArray=function(P){return P.reduce(function(S,p){return typeof p=="string"?S.push(y(p,null)):p.data&&S.push(y(p.data,p.mode)),S},[])},t.fromString=function(P,S){const p=d(P,i.isKanjiModeEnabled()),b=N(p),V=D(b,S),C=a.find_path(V.map,"start","end"),O=[];for(let T=1;T<C.length-1;T++)O.push(V.table[C[T]].node);return t.fromArray(c(O))},t.rawSplit=function(P){return t.fromArray(d(P,i.isKanjiModeEnabled()))}})(zr);const ut=W,ht=lt,Nn=Xi,Dn=Zi,xn=Tr,vn=kr,Pt=Rr,Lt=at,fn=tn,et=Fr,En=qr,On=pe,yt=zr;function Cn(t,r){const o=t.size,l=vn.getPositions(r);for(let s=0;s<l.length;s++){const n=l[s][0],m=l[s][1];for(let i=-1;i<=7;i++)if(!(n+i<=-1||o<=n+i))for(let a=-1;a<=7;a++)m+a<=-1||o<=m+a||(i>=0&&i<=6&&(a===0||a===6)||a>=0&&a<=6&&(i===0||i===6)||i>=2&&i<=4&&a>=2&&a<=4?t.set(n+i,m+a,!0,!0):t.set(n+i,m+a,!1,!0))}}function An(t){const r=t.size;for(let o=8;o<r-8;o++){const l=o%2===0;t.set(o,6,l,!0),t.set(6,o,l,!0)}}function Pn(t,r){const o=xn.getPositions(r);for(let l=0;l<o.length;l++){const s=o[l][0],n=o[l][1];for(let m=-2;m<=2;m++)for(let i=-2;i<=2;i++)m===-2||m===2||i===-2||i===2||m===0&&i===0?t.set(s+m,n+i,!0,!0):t.set(s+m,n+i,!1,!0)}}function Ln(t,r){const o=t.size,l=et.getEncodedBits(r);let s,n,m;for(let i=0;i<18;i++)s=Math.floor(i/3),n=i%3+o-8-3,m=(l>>i&1)===1,t.set(s,n,m,!0),t.set(n,s,m,!0)}function Nt(t,r,o){const l=t.size,s=En.getEncodedBits(r,o);let n,m;for(n=0;n<15;n++)m=(s>>n&1)===1,n<6?t.set(n,8,m,!0):n<8?t.set(n+1,8,m,!0):t.set(l-15+n,8,m,!0),n<8?t.set(8,l-n-1,m,!0):n<9?t.set(8,15-n-1+1,m,!0):t.set(8,15-n-1,m,!0);t.set(l-8,8,1,!0)}function Un(t,r){const o=t.size;let l=-1,s=o-1,n=7,m=0;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let a=0;a<2;a++)if(!t.isReserved(s,i-a)){let h=!1;m<r.length&&(h=(r[m]>>>n&1)===1),t.set(s,i-a,h),n--,n===-1&&(m++,n=7)}if(s+=l,s<0||o<=s){s-=l,l=-l;break}}}function jn(t,r,o){const l=new Nn;o.forEach(function(a){l.put(a.mode.bit,4),l.put(a.getLength(),On.getCharCountIndicator(a.mode,t)),a.write(l)});const s=ut.getSymbolTotalCodewords(t),n=Lt.getTotalCodewordsCount(t,r),m=(s-n)*8;for(l.getLengthInBits()+4<=m&&l.put(0,4);l.getLengthInBits()%8!==0;)l.putBit(0);const i=(m-l.getLengthInBits())/8;for(let a=0;a<i;a++)l.put(a%2?17:236,8);return Gn(l,t,r)}function Gn(t,r,o){const l=ut.getSymbolTotalCodewords(r),s=Lt.getTotalCodewordsCount(r,o),n=l-s,m=Lt.getBlocksCount(r,o),i=l%m,a=m-i,h=Math.floor(l/m),u=Math.floor(n/m),d=u+1,g=h-u,c=new fn(g);let N=0;const D=new Array(m),y=new Array(m);let v=0;const P=new Uint8Array(t.buffer);for(let C=0;C<m;C++){const O=C<a?u:d;D[C]=P.slice(N,N+O),y[C]=c.encode(D[C]),N+=O,v=Math.max(v,O)}const S=new Uint8Array(l);let p=0,b,V;for(b=0;b<v;b++)for(V=0;V<m;V++)b<D[V].length&&(S[p++]=D[V][b]);for(b=0;b<g;b++)for(V=0;V<m;V++)S[p++]=y[V][b];return S}function Vn(t,r,o,l){let s;if(Array.isArray(t))s=yt.fromArray(t);else if(typeof t=="string"){let h=r;if(!h){const u=yt.rawSplit(t);h=et.getBestVersionForData(u,o)}s=yt.fromString(t,h||40)}else throw new Error("Invalid data");const n=et.getBestVersionForData(s,o);if(!n)throw new Error("The amount of data is too big to be stored in a QR Code");if(!r)r=n;else if(r<n)throw new Error(`
The chosen QR Code version cannot contain this amount of data.
Minimum version required to store current data is: `+n+`.
`);const m=jn(r,o,s),i=ut.getSymbolSize(r),a=new Dn(i);return Cn(a,r),An(a),Pn(a,r),Nt(a,o,0),r>=7&&Ln(a,r),Un(a,m),isNaN(l)&&(l=Pt.getBestMask(a,Nt.bind(null,a,o))),Pt.applyMask(l,a),Nt(a,o,l),{modules:a,version:r,errorCorrectionLevel:o,maskPattern:l,segments:s}}wr.create=function(r,o){if(typeof r>"u"||r==="")throw new Error("No input text");let l=ht.M,s,n;return typeof o<"u"&&(l=ht.from(o.errorCorrectionLevel,ht.M),s=et.from(o.version),n=Pt.from(o.maskPattern),o.toSJISFunc&&ut.setToSJISFunction(o.toSJISFunc)),Vn(r,s,l,n)};var $r={},Wt={};(function(t){function r(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let l=o.slice().replace("#","").split("");if(l.length<3||l.length===5||l.length>8)throw new Error("Invalid hex color: "+o);(l.length===3||l.length===4)&&(l=Array.prototype.concat.apply([],l.map(function(n){return[n,n]}))),l.length===6&&l.push("F","F");const s=parseInt(l.join(""),16);return{r:s>>24&255,g:s>>16&255,b:s>>8&255,a:s&255,hex:"#"+l.slice(0,6).join("")}}t.getOptions=function(l){l||(l={}),l.color||(l.color={});const s=typeof l.margin>"u"||l.margin===null||l.margin<0?4:l.margin,n=l.width&&l.width>=21?l.width:void 0,m=l.scale||4;return{width:n,scale:n?4:m,margin:s,color:{dark:r(l.color.dark||"#000000ff"),light:r(l.color.light||"#ffffffff")},type:l.type,rendererOpts:l.rendererOpts||{}}},t.getScale=function(l,s){return s.width&&s.width>=l+s.margin*2?s.width/(l+s.margin*2):s.scale},t.getImageWidth=function(l,s){const n=t.getScale(l,s);return Math.floor((l+s.margin*2)*n)},t.qrToImageData=function(l,s,n){const m=s.modules.size,i=s.modules.data,a=t.getScale(m,n),h=Math.floor((m+n.margin*2)*a),u=n.margin*a,d=[n.color.light,n.color.dark];for(let g=0;g<h;g++)for(let c=0;c<h;c++){let N=(g*h+c)*4,D=n.color.light;if(g>=u&&c>=u&&g<h-u&&c<h-u){const y=Math.floor((g-u)/a),v=Math.floor((c-u)/a);D=d[i[y*m+v]?1:0]}l[N++]=D.r,l[N++]=D.g,l[N++]=D.b,l[N]=D.a}}})(Wt);(function(t){const r=Wt;function o(s,n,m){s.clearRect(0,0,n.width,n.height),n.style||(n.style={}),n.height=m,n.width=m,n.style.height=m+"px",n.style.width=m+"px"}function l(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(n,m,i){let a=i,h=m;typeof a>"u"&&(!m||!m.getContext)&&(a=m,m=void 0),m||(h=l()),a=r.getOptions(a);const u=r.getImageWidth(n.modules.size,a),d=h.getContext("2d"),g=d.createImageData(u,u);return r.qrToImageData(g.data,n,a),o(d,h,u),d.putImageData(g,0,0),h},t.renderToDataURL=function(n,m,i){let a=i;typeof a>"u"&&(!m||!m.getContext)&&(a=m,m=void 0),a||(a={});const h=t.render(n,m,a),u=a.type||"image/png",d=a.rendererOpts||{};return h.toDataURL(u,d.quality)}})($r);var Qr={};const Yn=Wt;function gr(t,r){const o=t.a/255,l=r+'="'+t.hex+'"';return o<1?l+" "+r+'-opacity="'+o.toFixed(2).slice(1)+'"':l}function Dt(t,r,o){let l=t+r;return typeof o<"u"&&(l+=" "+o),l}function wn(t,r,o){let l="",s=0,n=!1,m=0;for(let i=0;i<t.length;i++){const a=Math.floor(i%r),h=Math.floor(i/r);!a&&!n&&(n=!0),t[i]?(m++,i>0&&a>0&&t[i-1]||(l+=n?Dt("M",a+o,.5+h+o):Dt("m",s,0),s=0,n=!1),a+1<r&&t[i+1]||(l+=Dt("h",m),m=0)):s++}return l}Qr.render=function(r,o,l){const s=Yn.getOptions(o),n=r.modules.size,m=r.modules.data,i=n+s.margin*2,a=s.color.light.a?"<path "+gr(s.color.light,"fill")+' d="M0 0h'+i+"v"+i+'H0z"/>':"",h="<path "+gr(s.color.dark,"stroke")+' d="'+wn(m,n,s.margin)+'"/>',u='viewBox="0 0 '+i+" "+i+'"',g='<svg xmlns="http://www.w3.org/2000/svg" '+(s.width?'width="'+s.width+'" height="'+s.width+'" ':"")+u+' shape-rendering="crispEdges">'+a+h+`</svg>
`;return typeof l=="function"&&l(null,g),g};const _n=Ji,Ut=wr,Jr=$r,Tn=Qr;function Xt(t,r,o,l,s){const n=[].slice.call(arguments,1),m=n.length,i=typeof n[m-1]=="function";if(!i&&!_n())throw new Error("Callback required as last argument");if(i){if(m<2)throw new Error("Too few arguments provided");m===2?(s=o,o=r,r=l=void 0):m===3&&(r.getContext&&typeof s>"u"?(s=l,l=void 0):(s=l,l=o,o=r,r=void 0))}else{if(m<1)throw new Error("Too few arguments provided");return m===1?(o=r,r=l=void 0):m===2&&!r.getContext&&(l=o,o=r,r=void 0),new Promise(function(a,h){try{const u=Ut.create(o,l);a(t(u,r,l))}catch(u){h(u)}})}try{const a=Ut.create(o,l);s(null,t(a,r,l))}catch(a){s(a)}}Fe.create=Ut.create;Fe.toCanvas=Xt.bind(null,Jr.render);Fe.toDataURL=Xt.bind(null,Jr.renderToDataURL);Fe.toString=Xt.bind(null,function(t,r,o){return Tn.render(t,o)});function kn({open:t,onOpenChange:r}){var S;const[o,l]=x.useState(""),[s,n]=x.useState(!1),[m,i]=x.useState("setup"),[a,h]=x.useState(""),[u,d]=x.useState(""),{toast:g}=F(),{user:c}=ke(),N=()=>{const p="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";let b="";for(let V=0;V<32;V++)b+=p.charAt(Math.floor(Math.random()*p.length));return b},D=async()=>{try{n(!0);const p=N();d(p);const b="TripOvo Support",V=(c==null?void 0:c.email)||"user@example.com",C=`otpauth://totp/${encodeURIComponent(b)}:${encodeURIComponent(V)}?secret=${p}&issuer=${encodeURIComponent(b)}`,O=await Fe.toDataURL(C);h(O),g({title:"2FA Setup Started",description:"Scan the QR code with your authenticator app"}),i("verify")}catch{g({title:"Error",description:"Failed to setup 2FA",variant:"destructive"})}finally{n(!1)}},y=async()=>{try{if(n(!0),o.length!==6)throw new Error("Invalid code length");const{error:p}=await Ee.auth.updateUser({data:{two_factor_enabled:!0,two_factor_secret:u}});if(p)throw p;g({title:"2FA Enabled",description:"Two-factor authentication has been enabled successfully"}),r(!1),i("setup"),l("")}catch{g({title:"Error",description:"Invalid verification code or setup failed",variant:"destructive"})}finally{n(!1)}},v=async()=>{try{n(!0);const{error:p}=await Ee.auth.updateUser({data:{two_factor_enabled:!1,two_factor_secret:null}});if(p)throw p;g({title:"2FA Disabled",description:"Two-factor authentication has been disabled"}),r(!1)}catch{g({title:"Error",description:"Failed to disable 2FA",variant:"destructive"})}finally{n(!1)}},P=((S=c==null?void 0:c.user_metadata)==null?void 0:S.two_factor_enabled)||!1;return e.jsxDEV(ye,{open:t,onOpenChange:r,children:e.jsxDEV(Ne,{className:"max-w-md",children:[e.jsxDEV(De,{children:e.jsxDEV(xe,{className:"flex items-center gap-2",children:[e.jsxDEV(ir,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:143,columnNumber:13},this),"Two-Factor Authentication"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:142,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:141,columnNumber:9},this),e.jsxDEV("div",{className:"space-y-6",children:[P?e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:[e.jsxDEV(R,{className:"text-green-600 flex items-center gap-2",children:[e.jsxDEV(ir,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:153,columnNumber:19},this),"2FA Enabled"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:152,columnNumber:17},this),e.jsxDEV(Re,{children:"Your account is protected with two-factor authentication"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:156,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:151,columnNumber:15},this),e.jsxDEV(w,{children:e.jsxDEV(f,{variant:"destructive",onClick:v,disabled:s,className:"w-full",children:s?"Disabling...":"Disable 2FA"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:161,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:160,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:150,columnNumber:13},this):m==="setup"?e.jsxDEV(e.Fragment,{children:[e.jsxDEV("div",{className:"space-y-4",children:[e.jsxDEV("div",{className:"text-center",children:[e.jsxDEV(Ws,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:175,columnNumber:19},this),e.jsxDEV("h3",{className:"text-lg font-medium",children:"Secure Your Account"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:176,columnNumber:19},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground",children:"Add an extra layer of security with two-factor authentication"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:177,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:174,columnNumber:17},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV("h4",{className:"font-medium",children:"What you'll need:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:183,columnNumber:19},this),e.jsxDEV("ul",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsxDEV("li",{children:"• An authenticator app (Google Authenticator, Authy, etc.)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:185,columnNumber:21},this),e.jsxDEV("li",{children:"• Your phone or tablet"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:186,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:184,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:182,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:173,columnNumber:15},this),e.jsxDEV("div",{className:"flex space-x-2",children:[e.jsxDEV(f,{variant:"outline",onClick:()=>r(!1),className:"flex-1",children:"Cancel"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:192,columnNumber:17},this),e.jsxDEV(f,{onClick:D,disabled:s,className:"flex-1",children:s?"Setting up...":"Set Up 2FA"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:195,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:191,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:172,columnNumber:13},this):e.jsxDEV(e.Fragment,{children:[e.jsxDEV("div",{className:"space-y-4",children:[e.jsxDEV("div",{className:"text-center",children:[e.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"Scan QR Code"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:204,columnNumber:19},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground",children:"Use your authenticator app to scan this code"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:205,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:203,columnNumber:17},this),e.jsxDEV("div",{className:"flex items-center justify-center p-8 border-2 border-dashed border-muted-foreground/25 rounded-lg",children:e.jsxDEV("div",{className:"text-center",children:a?e.jsxDEV("div",{children:[e.jsxDEV("img",{src:a,alt:"2FA QR Code",className:"mx-auto mb-4 rounded-lg"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:214,columnNumber:25},this),e.jsxDEV("p",{className:"text-sm text-muted-foreground",children:"Scan this QR code with your authenticator app"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:215,columnNumber:25},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground mt-2",children:["Or enter this secret manually: ",e.jsxDEV("code",{className:"bg-muted px-1 rounded",children:u},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:217,columnNumber:58},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:216,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:213,columnNumber:23},this):e.jsxDEV("div",{className:"text-muted-foreground",children:[e.jsxDEV("div",{className:"w-32 h-32 bg-muted mx-auto mb-4 rounded-lg flex items-center justify-center",children:"Generating QR Code..."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:222,columnNumber:25},this),e.jsxDEV("p",{className:"text-sm",children:"Please wait while we generate your QR code"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:225,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:221,columnNumber:23},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:211,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:210,columnNumber:17},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"verification-code",children:"Enter verification code"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:232,columnNumber:19},this),e.jsxDEV(U,{id:"verification-code",type:"text",placeholder:"000000",value:o,onChange:p=>l(p.target.value.replace(/\D/g,"").slice(0,6)),className:"text-center text-lg tracking-widest",maxLength:6},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:233,columnNumber:19},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"Enter the 6-digit code from your authenticator app"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:242,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:231,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:202,columnNumber:15},this),e.jsxDEV("div",{className:"flex space-x-2",children:[e.jsxDEV(f,{variant:"outline",onClick:()=>i("setup"),disabled:s,className:"flex-1",children:"Back"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:249,columnNumber:17},this),e.jsxDEV(f,{onClick:y,disabled:s||o.length!==6,className:"flex-1",children:s?"Verifying...":"Verify & Enable"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:257,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:248,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:201,columnNumber:13},this),!P&&e.jsxDEV("div",{className:"bg-orange-50 border border-orange-200 rounded-lg p-4",children:e.jsxDEV("div",{className:"flex items-start space-x-2",children:[e.jsxDEV(rt,{className:"h-5 w-5 text-orange-600 flex-shrink-0 mt-0.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:271,columnNumber:17},this),e.jsxDEV("div",{className:"text-sm",children:[e.jsxDEV("p",{className:"font-medium text-orange-800",children:"Security Recommendation"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:273,columnNumber:19},this),e.jsxDEV("p",{className:"text-orange-700",children:"Enable 2FA to protect your account from unauthorized access"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:274,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:272,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:270,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:269,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:148,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:140,columnNumber:7},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/TwoFactorDialog.tsx",lineNumber:139,columnNumber:5},this)}function Rn(){const{user:t,profile:r}=ke(),{toast:o}=F(),{canSeeAdminTabs:l}=Is(),[s,n]=x.useState({enabled:!0,categories:{tickets:!0,messages:!0,approvals:!0,internal_notes:!1}}),[m,i]=x.useState(!0),[a,h]=x.useState(!1),[u,d]=x.useState(!1),[g,c]=x.useState(!1),[N,D]=x.useState((r==null?void 0:r.email_signature)||""),[y,v]=x.useState(!1);x.useEffect(()=>{D((r==null?void 0:r.email_signature)||"")},[r==null?void 0:r.email_signature]);const P=async()=>{v(!0);try{await Ks({email_signature:N||null}),o({title:"Signature saved",description:"Future emails will use this signature where templates reference {{ops_user_signature}}."})}catch(G){o({variant:"destructive",title:"Save failed",description:G==null?void 0:G.message})}finally{v(!1)}};x.useEffect(()=>{let G=!1;return Fs().then(H=>{!G&&(H!=null&&H.email_preferences)&&n(H.email_preferences)}).catch(()=>{}).finally(()=>{G||i(!1)}),()=>{G=!0}},[]);const S=()=>{o({title:"Profile Updated",description:"Your profile settings have been saved."})},p=async()=>{h(!0);try{const G=await $s(s);G!=null&&G.email_preferences&&n(G.email_preferences),o({title:"Notification settings saved",description:s.enabled?"You will receive emails for high-signal events.":"Email notifications are now off. You’ll still see the bell + toast."})}catch(G){o({variant:"destructive",title:"Save failed",description:G==null?void 0:G.message})}finally{h(!1)}},b=G=>n(H=>({...H,categories:{...H.categories,[G]:!H.categories[G]}})),V=()=>{d(!0)},C=()=>{c(!0)},[O,T]=x.useState(!1),_=async()=>{var G;T(!0);try{const H=localStorage.getItem("platform_token"),ne=await(await fetch("/api/branding/cache/clear",{method:"POST",headers:{Authorization:`Bearer ${H}`}})).json();if(ne.error)throw new Error(ne.error.message||"Failed");o({title:"Branding cache cleared",description:`Removed ${((G=ne.data)==null?void 0:G.cleared)??0} cached entries. Next page load will refetch from EasyGDS.`})}catch(H){o({variant:"destructive",title:"Failed to clear cache",description:H.message})}finally{T(!1)}},[E,j]=x.useState(null),J=async G=>{if(confirm(`Restart ${G}? You may briefly lose connection.`)){j(G);try{const H=localStorage.getItem("platform_token"),ne=await(await fetch(`/api/system/restart-${G}`,{method:"POST",headers:{Authorization:`Bearer ${H}`}})).json().catch(()=>({}));if(ne!=null&&ne.error)throw new Error(ne.error.message||"Failed");o({title:`${G==="backend"?"Backend":"Frontend"} restart triggered`,description:G==="backend"?"API will be unavailable for a moment.":"Vite will reload shortly."})}catch(H){o({variant:"destructive",title:`Failed to restart ${G}`,description:H.message})}finally{setTimeout(()=>j(null),1500)}}},Ue=x.useMemo(()=>{const G=[{key:"personal",label:"Personal",icon:pi,tabs:[{value:"profile",label:"Profile"},{value:"notifications",label:"Notifications"},{value:"security",label:"Security"}]}];return l&&G.push({key:"apps",label:"Applications",icon:di,tabs:[{value:"apps",label:"Apps"},{value:"suppliers",label:"Suppliers"}]},{key:"comms",label:"Communications",icon:Bs,tabs:[{value:"templates",label:"Templates"},{value:"inbox",label:"Inbox"},{value:"smtp",label:"SMTP"},{value:"oauth2",label:"OAuth2"}]},{key:"finance",label:"Finance",icon:qs,tabs:[{value:"payment-methods",label:"Payment Methods"},{value:"finance-alerts",label:"Finance Alerts"}]},{key:"system",label:"System",icon:Er,tabs:[{value:"system",label:"General"},{value:"branding",label:"Branding"},{value:"reminders",label:"Reminders"},{value:"database",label:"Database"}]}),G},[l]),[L,$]=x.useState("personal"),ie=Ue.find(G=>G.key===L)||Ue[0];return e.jsxDEV("div",{className:"space-y-6",children:[e.jsxDEV("div",{className:"flex items-center space-x-2",children:[e.jsxDEV(vt,{className:"h-6 w-6 text-blue-600"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:228,columnNumber:9},this),e.jsxDEV("h2",{className:"text-2xl font-bold text-gray-900",children:"Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:229,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:227,columnNumber:7},this),e.jsxDEV("div",{className:"flex flex-wrap gap-2 border-b pb-3",children:Ue.map(G=>{const H=G.icon,Se=G.key===L;return e.jsxDEV("button",{onClick:()=>$(G.key),className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium transition-colors "+(Se?"bg-blue-600 text-white shadow-sm":"bg-white text-gray-700 border border-gray-200 hover:bg-gray-50"),children:[e.jsxDEV(H,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:250,columnNumber:15},this),G.label]},G.key,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:240,columnNumber:13},this)})},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:235,columnNumber:7},this),e.jsxDEV(qt,{defaultValue:ie.tabs[0].value,className:"space-y-6",children:[e.jsxDEV(Ht,{className:"grid w-full",style:{gridTemplateColumns:`repeat(${ie.tabs.length}, minmax(0, 1fr))`},children:ie.tabs.map(G=>e.jsxDEV(me,{value:G.value,children:G.label},G.value,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:263,columnNumber:13},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:258,columnNumber:9},this),e.jsxDEV(B,{value:"profile",children:e.jsxDEV("div",{className:"space-y-6",children:[e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center space-x-2",children:[e.jsxDEV(we,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:272,columnNumber:19},this),e.jsxDEV("span",{children:"Profile Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:273,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:271,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:270,columnNumber:15},this),e.jsxDEV(w,{className:"space-y-4",children:[e.jsxDEV("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"firstName",children:"First Name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:279,columnNumber:21},this),e.jsxDEV(U,{id:"firstName",defaultValue:(r==null?void 0:r.first_name)||"",placeholder:"Enter your first name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:280,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:278,columnNumber:19},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"lastName",children:"Last Name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:287,columnNumber:21},this),e.jsxDEV(U,{id:"lastName",defaultValue:(r==null?void 0:r.last_name)||"",placeholder:"Enter your last name"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:288,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:286,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:277,columnNumber:17},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"email",children:"Email"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:296,columnNumber:19},this),e.jsxDEV(U,{id:"email",type:"email",defaultValue:(t==null?void 0:t.email)||"",disabled:!0,className:"bg-gray-50"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:297,columnNumber:19},this),e.jsxDEV("p",{className:"text-sm text-gray-500",children:"Email cannot be changed"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:304,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:295,columnNumber:17},this),e.jsxDEV("div",{className:"space-y-2",children:[e.jsxDEV(A,{htmlFor:"role",children:"Role"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:307,columnNumber:19},this),e.jsxDEV(U,{id:"role",defaultValue:(r==null?void 0:r.role)||"agent",disabled:!0,className:"bg-gray-50"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:308,columnNumber:19},this),e.jsxDEV("p",{className:"text-sm text-gray-500",children:"Role is managed by administrators"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:314,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:306,columnNumber:17},this),e.jsxDEV(f,{onClick:S,children:"Save Profile"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:316,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:276,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:269,columnNumber:13},this),e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center space-x-2",children:[e.jsxDEV(zt,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:327,columnNumber:19},this),e.jsxDEV("span",{children:"Email signature"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:328,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:326,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:325,columnNumber:15},this),e.jsxDEV(w,{className:"space-y-3",children:[e.jsxDEV("p",{className:"text-sm text-gray-600",children:["This block replaces the ",e.jsxDEV("code",{className:"bg-gray-100 px-1 rounded text-xs",children:"{{ops_user_signature}}"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:333,columnNumber:43},this)," placeholder in every outbound email template. Format text, add links, or paste HTML — use the ",e.jsxDEV("strong",{children:"Source"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:335,columnNumber:27},this)," toggle in the editor toolbar to switch to raw HTML."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:332,columnNumber:17},this),e.jsxDEV(Or,{value:N,onChange:D,minHeight:220,placeholder:`Best regards, ${(r==null?void 0:r.first_name)||"Your name"} — Operations Team`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:337,columnNumber:17},this),e.jsxDEV("p",{className:"text-xs text-muted-foreground",children:"Tip: include your title, phone, and company so suppliers can reach you. Leave the editor empty to fall back to a default built from your name."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:343,columnNumber:17},this),e.jsxDEV(f,{onClick:P,disabled:y,children:y?"Saving…":"Save signature"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:347,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:331,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:324,columnNumber:13},this),e.jsxDEV(mr,{personalOnly:!0},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:357,columnNumber:13},this),e.jsxDEV(ar,{personalOnly:!0},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:358,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:268,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:267,columnNumber:9},this),e.jsxDEV(B,{value:"notifications",children:e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center space-x-2",children:[e.jsxDEV(Hs,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:366,columnNumber:17},this),e.jsxDEV("span",{children:"Notification Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:367,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:365,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:364,columnNumber:13},this),e.jsxDEV(w,{className:"space-y-4",children:[e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"space-y-0.5",children:[e.jsxDEV(A,{children:"Email Notifications"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:375,columnNumber:19},this),e.jsxDEV("p",{className:"text-sm text-gray-500",children:"Receive important ticket + approval activity via email. The in-app bell + toasts always stay on."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:376,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:374,columnNumber:17},this),e.jsxDEV(z,{checked:s.enabled,disabled:m,onCheckedChange:G=>n(H=>({...H,enabled:G}))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:381,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:373,columnNumber:15},this),e.jsxDEV(ge,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:388,columnNumber:15},this),e.jsxDEV("div",{className:s.enabled?"":"opacity-50 pointer-events-none",children:[e.jsxDEV("p",{className:"text-sm font-medium text-gray-700 mb-3",children:"Email me about:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:394,columnNumber:17},this),e.jsxDEV("div",{className:"space-y-3",children:[e.jsxDEV(Ke,{label:"Ticket lifecycle",hint:"New ticket, forwarded, assigned, resolved, rejected.",checked:s.categories.tickets,onChange:()=>b("tickets"),disabled:m},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:396,columnNumber:19},this),e.jsxDEV(Ke,{label:"Customer-facing messages",hint:"Any message on the ticket thread (customer ↔ ops/app).",checked:s.categories.messages,onChange:()=>b("messages"),disabled:m},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:401,columnNumber:19},this),e.jsxDEV(Ke,{label:"Approvals",hint:"Charge / refund / change / cancellation proposals + responses.",checked:s.categories.approvals,onChange:()=>b("approvals"),disabled:m},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:406,columnNumber:19},this),e.jsxDEV(Ke,{label:"Internal notes",hint:"App ↔ Ops internal comments. Usually noisy — off by default.",checked:s.categories.internal_notes,onChange:()=>b("internal_notes"),disabled:m},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:411,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:395,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:393,columnNumber:15},this),e.jsxDEV(f,{onClick:p,disabled:a||m,children:a?"Saving…":"Save Notifications"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:419,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:370,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:363,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:362,columnNumber:9},this),e.jsxDEV(B,{value:"security",children:e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center space-x-2",children:[e.jsxDEV(Vr,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:430,columnNumber:17},this),e.jsxDEV("span",{children:"Security Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:431,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:429,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:428,columnNumber:13},this),e.jsxDEV(w,{className:"space-y-4",children:[e.jsxDEV(f,{variant:"outline",className:"w-full",onClick:V,children:"Change Password"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:435,columnNumber:15},this),e.jsxDEV(f,{variant:"outline",className:"w-full",onClick:C,children:"Two-Factor Authentication"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:438,columnNumber:15},this),e.jsxDEV(ge,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:441,columnNumber:15},this),e.jsxDEV("div",{className:"text-sm text-gray-600",children:[e.jsxDEV("p",{className:"font-medium mb-2",children:"Account Security:"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:443,columnNumber:17},this),e.jsxDEV("ul",{className:"space-y-1 ml-4",children:[e.jsxDEV("li",{children:["• Last login: ",new Date().toLocaleDateString()]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:445,columnNumber:19},this),e.jsxDEV("li",{children:["• Account created: ",new Date((t==null?void 0:t.created_at)||"").toLocaleDateString()]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:446,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:444,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:442,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:434,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:427,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:426,columnNumber:9},this),l&&e.jsxDEV(e.Fragment,{children:[e.jsxDEV(B,{value:"system",children:e.jsxDEV("div",{className:"space-y-6",children:[e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center space-x-2",children:[e.jsxDEV(We,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:463,columnNumber:23},this),e.jsxDEV("span",{children:"Process Control"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:464,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:462,columnNumber:21},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:461,columnNumber:19},this),e.jsxDEV(w,{className:"space-y-4",children:[e.jsxDEV("p",{className:"text-sm text-gray-600",children:"Restart the frontend (Vite) or backend (Node API) processes. Use after deploying server-side changes or when something looks stuck. Admin only."},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:468,columnNumber:21},this),e.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[e.jsxDEV(f,{variant:"outline",onClick:()=>J("backend"),disabled:E!==null,children:[e.jsxDEV(Kt,{className:`h-4 w-4 mr-2 ${E==="backend"?"animate-pulse":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:478,columnNumber:25},this),E==="backend"?"Restarting backend…":"Restart backend"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:473,columnNumber:23},this),e.jsxDEV(f,{variant:"outline",onClick:()=>J("frontend"),disabled:E!==null,children:[e.jsxDEV(Xe,{className:`h-4 w-4 mr-2 ${E==="frontend"?"animate-spin":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:486,columnNumber:25},this),E==="frontend"?"Restarting frontend…":"Restart frontend"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:481,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:472,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:467,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:460,columnNumber:17},this),e.jsxDEV(gi,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:492,columnNumber:17},this),e.jsxDEV(Ni,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:493,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:459,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:458,columnNumber:13},this),e.jsxDEV(B,{value:"branding",children:e.jsxDEV(Y,{children:[e.jsxDEV(k,{children:e.jsxDEV(R,{className:"flex items-center space-x-2",children:[e.jsxDEV(zs,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:501,columnNumber:21},this),e.jsxDEV("span",{children:"Branding"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:502,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:500,columnNumber:19},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:499,columnNumber:17},this),e.jsxDEV(w,{className:"space-y-4",children:[e.jsxDEV("div",{children:[e.jsxDEV("p",{className:"text-sm text-gray-600",children:["Login pages dynamically pull each app/agency's logo and primary color from the EasyGDS API. Results are cached for ",e.jsxDEV("span",{className:"font-medium",children:"24 hours"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:509,columnNumber:46},this)," to keep page loads fast. Clear the cache below to force an immediate refetch (e.g. after updating a logo or theme color in EasyGDS)."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:507,columnNumber:21},this),e.jsxDEV("p",{className:"text-xs text-gray-500 mt-2",children:["Local overrides defined in ",e.jsxDEV("code",{className:"bg-gray-100 px-1 rounded",children:"server/branding.json"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:513,columnNumber:50},this)," always take precedence over upstream values."]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:512,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:506,columnNumber:19},this),e.jsxDEV(f,{onClick:_,disabled:O,variant:"outline",children:[e.jsxDEV(Xe,{className:`h-4 w-4 mr-2 ${O?"animate-spin":""}`},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:517,columnNumber:21},this),O?"Clearing…":"Clear branding cache"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:516,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:505,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:498,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:497,columnNumber:13},this),e.jsxDEV(B,{value:"apps",children:e.jsxDEV(fi,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:529,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:528,columnNumber:13},this),e.jsxDEV(B,{value:"suppliers",children:e.jsxDEV(Yi,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:533,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:532,columnNumber:13},this),e.jsxDEV(B,{value:"templates",children:e.jsxDEV(hi,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:537,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:536,columnNumber:13},this),e.jsxDEV(B,{value:"inbox",children:e.jsxDEV(ar,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:541,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:540,columnNumber:13},this),e.jsxDEV(B,{value:"oauth2",children:e.jsxDEV(yi,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:545,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:544,columnNumber:13},this),e.jsxDEV(B,{value:"smtp",children:e.jsxDEV(mr,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:549,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:548,columnNumber:13},this),e.jsxDEV(B,{value:"payment-methods",children:e.jsxDEV(Ii,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:553,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:552,columnNumber:13},this),e.jsxDEV(B,{value:"finance-alerts",children:e.jsxDEV(Fi,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:557,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:556,columnNumber:13},this),e.jsxDEV(B,{value:"reminders",children:e.jsxDEV($i,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:561,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:560,columnNumber:13},this),e.jsxDEV(B,{value:"database",children:e.jsxDEV(zi,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:565,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:564,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:457,columnNumber:11},this)]},L,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:257,columnNumber:7},this),e.jsxDEV(Qi,{open:u,onOpenChange:d},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:571,columnNumber:7},this),e.jsxDEV(kn,{open:g,onOpenChange:c},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:575,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:226,columnNumber:5},this)}function Ke({label:t,hint:r,checked:o,onChange:l,disabled:s}){return e.jsxDEV("div",{className:"flex items-center justify-between",children:[e.jsxDEV("div",{className:"space-y-0.5 pr-4",children:[e.jsxDEV(A,{children:t},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:595,columnNumber:9},this),e.jsxDEV("p",{className:"text-xs text-gray-500",children:r},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:596,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:594,columnNumber:7},this),e.jsxDEV(z,{checked:o,onCheckedChange:l,disabled:s},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:598,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/settings/SettingsSection.tsx",lineNumber:593,columnNumber:5},this)}function co(){return e.jsxDEV("div",{className:"space-y-6",children:[e.jsxDEV("div",{children:[e.jsxDEV("h1",{className:"text-3xl font-bold text-gray-900",children:"Settings"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/SettingsPage.tsx",lineNumber:8,columnNumber:9},this),e.jsxDEV("p",{className:"text-gray-600 mt-2",children:"Configure system settings and preferences"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/SettingsPage.tsx",lineNumber:9,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/SettingsPage.tsx",lineNumber:7,columnNumber:7},this),e.jsxDEV(Rn,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/SettingsPage.tsx",lineNumber:11,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/SettingsPage.tsx",lineNumber:6,columnNumber:5},this)}export{co as default};
