PageSourceSearch

https://sprightly-melba-c7eb28.netlify.app/assets/ProfilePage-D490GMtE.js

js sprightly-melba-c7eb28.netlify.app collected 2026-10-03 11:27:15 UTC 70,591 bytes, 1 lines download raw bytes

1import{r as O}from"./rolldown-runtime-b3L32Ng1.js";import{cn as U}from"./vendor-lucide-BFy6u6yt.js";import{t as X}from"./vendor-react--8d8tp5c.js";import{c as G,n as F,u as q}from"./chunk-BV7QT456-DE-vnYdj.js";import{a as W,i as H,n as K,t as Y}from"./usePasskeys-diRyNZQk.js";import{n as J}from"./AuthContext-CtwjG4ln.js";import{t as D}from"./useTranslation-BHeiaPko.js";import{t as o}from"./Icon-d9ynruow.js";import{r as Q}from"./index-DQ54XwpE.js";import{a as Z,r as ee,s as te}from"./services-PuRtdvYy.js";import{t as se}from"./InfoTooltip-Bekl9vjp.js";var x=O(U(),1),e=X(),re=({user:s,tabs:f,activeTab:b,onTabChange:a,onLogout:r,progress:c,error:i,success:n,children:N})=>{const{t:y}=D();return(0,e.jsx)("div",{"data-component":"profile.ProfileLayout",className:"flex-1 w-full bg-white flex flex-col",children:(0,e.jsxs)("main",{className:"max-w-[1440px] mx-auto mt-8 lg:mt-12 mb-6 lg:mb-24 px-4 md:px-8 animate-fade-in flex flex-col lg:flex-row items-start gap-8 lg:gap-12 w-full",children:[(0,e.jsxs)("nav",{className:"hidden lg:block w-[315px] p-6 glass-panel rounded-3xl flex-shrink-0 border border-grey-100/80 shadow-sm",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4 mb-8",children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-full border-2 border-primary-500 bg-primary-50 flex items-center justify-center flex-shrink-0 text-primary-600 font-bold text-lg",children:s?.first_name?s.first_name.charAt(0).toUpperCase():(0,e.jsx)(o,{name:"user",className:"w-6 h-6 text-primary-500"})}),(0,e.jsxs)("div",{className:"overflow-hidden",children:[(0,e.jsx)("p",{className:"font-semibold text-grey-900 truncate",children:s?.first_name||s?.last_name?`${s?.first_name||""} ${s?.last_name||""}`.trim():y("profile.driver","IRKEN Driver")}),(0,e.jsx)("p",{className:"text-xs text-grey-400 truncate",children:s?.email})]})]}),(0,e.jsx)("ul",{className:"flex flex-col gap-2 mb-6",children:f.map(p=>{const w=b===p.id;return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{onClick:()=>a(p.id),className:`text-sm py-2.5 px-3 rounded-xl transition-all duration-150 flex items-center gap-3 w-full text-start ${w?"text-primary-600 font-bold bg-primary-50/80 shadow-xs":"text-grey-600 hover:text-primary-600 hover:bg-grey-50 font-medium"}`,children:[(0,e.jsx)(o,{name:p.icon,size:18,className:w?"text-primary-500":"text-grey-400"}),(0,e.jsx)("span",{children:p.label})]})},p.id)})}),(0,e.jsx)("div",{className:"pt-4 border-t border-grey-100",children:(0,e.jsxs)("button",{onClick:r,className:"flex items-center gap-3 text-sm text-grey-400 hover:text-error-500 p-2 rounded-xl hover:bg-error-50 w-full transition-colors font-medium",children:[(0,e.jsx)(o,{name:"logOut",size:18,className:"text-grey-400"}),(0,e.jsx)("span",{children:y("profile.logOut","Log Out")})]})})]}),(0,e.jsx)("div",{className:"lg:hidden w-full border border-grey-100 py-3 px-3 overflow-x-auto whitespace-nowrap flex space-x-2 bg-white rounded-2xl shadow-sm",children:f.map(p=>{const w=b===p.id;return(0,e.jsxs)("button",{onClick:()=>a(p.id),className:`px-4 py-2 text-xs font-semibold rounded-xl transition-all duration-200 shrink-0 flex items-center gap-2 ${w?"text-primary-600 font-bold bg-primary-50 border border-primary-200":"text-grey-600 hover:text-primary-600 hover:bg-grey-50"}`,children:[(0,e.jsx)(o,{name:p.icon,size:14,className:w?"text-primary-500":"text-grey-400"}),(0,e.jsx)("span",{children:p.label})]},p.id)})}),(0,e.jsxs)("div",{className:"flex-1 w-full",children:[c<100&&(0,e.jsxs)("div",{className:"px-6 md:px-8 py-5 bg-white border border-grey-100 rounded-2xl mb-6 shadow-xs",children:[(0,e.jsxs)("div",{className:"flex justify-between items-end mb-2",children:[(0,e.jsx)("span",{className:"text-xs font-bold uppercase tracking-wider text-grey-600",children:y("profile.strength","Profile Strength")}),(0,e.jsxs)("span",{className:"text-xs font-bold text-primary-500",children:[c,"% ",y("profile.strengthCompleted","Completed")]})]}),(0,e.jsx)("div",{className:"w-full bg-grey-100 rounded-full h-2 mb-2 overflow-hidden",children:(0,e.jsx)("div",{className:"bg-primary-500 h-2 rounded-full transition-all duration-1000 ease-out",style:{width:`${c}%`}})}),(0,e.jsxs)("p",{className:"text-xs text-grey-400 flex items-center font-medium",children:[(0,e.jsx)(o,{name:"shieldCheck",className:"w-3.5 h-3.5 me-1.5 text-primary-500 shrink-0"}),y("profile.completeProfile","Complete your profile for seamless automated gate access.")
1]})]}),i&&(0,e.jsxs)("div",{className:"mb-6 p-4 bg-error-50 border border-error-200 rounded-xl text-xs font-semibold text-error-600 flex items-center gap-2",children:[(0,e.jsx)(o,{name:"alertCircle",className:"w-4 h-4 shrink-0 text-error-500"}),(0,e.jsx)("span",{children:i})]}),n&&(0,e.jsxs)("div",{className:"mb-6 p-4 bg-success-50 border border-success-200 rounded-xl text-xs font-semibold text-success-600 flex items-center gap-2",children:[(0,e.jsx)(o,{name:"checkCircle",className:"w-4 h-4 shrink-0 text-success-500"}),(0,e.jsx)("span",{children:n})]}),(0,e.jsx)("div",{className:"glass-panel rounded-3xl p-6 md:p-8 min-h-[500px] border border-grey-100/80 shadow-sm",children:N})]})]})})},ae=({user:s,authLoading:f,onUpdateProfile:b,onSuccess:a,onError:r})=>{const{t:c}=D(),[i,n]=(0,x.useState)(s?.first_name||""),[N,y]=(0,x.useState)(s?.last_name||""),[p,w]=(0,x.useState)(s?.phone||""),[k,v]=(0,x.useState)(!1),[d,u]=(0,x.useState)(()=>{try{const g=localStorage.getItem(`irken_billing_${s?.id}`);return g&&JSON.parse(g).companyName||""}catch{return""}}),[P,t]=(0,x.useState)(()=>{try{const g=localStorage.getItem(`irken_billing_${s?.id}`);return g&&JSON.parse(g).taxId||""}catch{return""}}),[h,C]=(0,x.useState)(()=>{try{const g=localStorage.getItem(`irken_billing_${s?.id}`);return g&&JSON.parse(g).billingAddress||""}catch{return""}}),j=async()=>{if(!i.trim()||!N.trim()){r(c("profile.personal.errorRequired","Please fill in required fields."));return}v(!0);try{await b({first_name:i.trim(),last_name:N.trim(),phone:p.trim()}),a(c("profile.personal.successMsg","Personal information updated successfully."))}catch(g){r(g instanceof Error?g.message:c("profile.personal.errorSave","Failed to save changes."))}finally{v(!1)}},_=()=>{if(s?.id)try{localStorage.setItem(`irken_billing_${s.id}`,JSON.stringify({companyName:d.trim(),taxId:P.trim(),billingAddress:h.trim()})),a(c("profile.billing.saved","Billing details saved successfully."))}catch{r(c("profile.billing.error","Failed to save billing information."))}};return(0,e.jsxs)("div",{"data-component":"profile.PersonalInfoTab",className:"space-y-10 animate-fade-in max-w-2xl",children:[(0,e.jsxs)("section",{children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-grey-900 mb-1",children:c("profile.personal.title","Personal Information")}),(0,e.jsx)("p",{className:"text-xs text-grey-400 mb-6",children:c("profile.personal.subtitle","Manage your name, verified phone number, and contact details.")}),(0,e.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{htmlFor:"profile-first-name",className:"block text-xs font-semibold text-grey-700 mb-1.5",children:[c("profile.personal.firstName","First Name")," *"]}),(0,e.jsx)("input",{id:"profile-first-name",type:"text",value:i,onChange:g=>n(g.target.value),disabled:f||k,className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{htmlFor:"profile-last-name",className:"block text-xs font-semibold text-grey-700 mb-1.5",children:[c("profile.personal.lastName","Last Name")," *"]}),(0,e.jsx)("input",{id:"profile-last-name",type:"text",value:N,onChange:g=>y(g.target.value),disabled:f||k,className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]})]}),(0,e.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 mt-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"profile-email",className:"block text-xs font-semibold text-grey-700 mb-1.5",children:c("profile.personal.email","Email Address")}),(0,e.jsx)("input",{id:"profile-email",type:"email",value:s?.email||"",disabled:!0,className:"w-full px-4 py-2.5 bg-grey-100 border border-grey-200 rounded-xl text-sm font-medium text-grey-400 cursor-not-allowed"}),(0,e.jsx)("p",{className:"text-[11px] text-grey-400 mt-1",children:c("profile.personal.emailNote","Email is tied to your account auth and cannot be changed here.")})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"profile-phone",className:"block text-xs font-semibold text-grey-700 mb-1.5",children:c("profile.personal.phone","Phone Number")}),(0,e.jsx)("input",{id:"profile-phone",type:"tel",placeholder:"+20 1X XXXX XXXX",value:p,onChange:g=>w(g.target.value),disabled:f||k,className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]})]}),(0,e.jsx)("div",{className:"mt-5",children:(0,e.jsx)("button",{type:"button",onClick:j,disabled:f||k,className:"px-6 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-sm font-semibold rounded-xl transition-all shadow-sm flex items-center gap-2 disabled:opacity-50",children:k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o,{name:"loader",className:"w-4 h-4 animate-spin"}),(0,e.jsx)("span",{children:c("profile.personal.saving","Saving...")})]}):(0,e.jsx)("span",{children:c("profile.personal.saveDetails","S
1ave Changes")})})})]}),(0,e.jsxs)("section",{className:"pt-8 border-t border-grey-100",children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-grey-900 mb-1",children:c("profile.billing.title","Corporate & VAT Invoicing")}),(0,e.jsx)("p",{className:"text-xs text-grey-400 mb-6",children:c("profile.billing.subtitle","Provide official Egyptian tax registration for business VAT receipts.")}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"billing-company",className:"block text-xs font-semibold text-grey-700 mb-1.5",children:c("profile.billing.companyName","Company / Organization Name")}),(0,e.jsx)("input",{id:"billing-company",type:"text",placeholder:c("profile.billing.companyNamePlaceholder","e.g. Acme Egypt LLC"),value:d,onChange:g=>u(g.target.value),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"billing-tax-id",className:"block text-xs font-semibold text-grey-700 mb-1.5",children:c("profile.billing.taxId","Egyptian Tax Registration Number")}),(0,e.jsx)("input",{id:"billing-tax-id",type:"text",placeholder:c("profile.billing.taxIdPlaceholder","e.g. 123-456-789"),value:P,onChange:g=>t(g.target.value),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"billing-address",className:"block text-xs font-semibold text-grey-700 mb-1.5",children:c("profile.billing.billingAddress","Registered Business Address")}),(0,e.jsx)("textarea",{id:"billing-address",rows:3,placeholder:c("profile.billing.billingAddressPlaceholder","Building number, Street, District, Cairo, Egypt"),value:h,onChange:g=>C(g.target.value),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white resize-none"})]}),(0,e.jsx)("div",{className:"pt-2",children:(0,e.jsx)("button",{type:"button",onClick:_,className:"px-6 py-2.5 bg-grey-800 hover:bg-grey-900 text-white text-sm font-semibold rounded-xl transition-all shadow-sm",children:c("profile.billing.save","Save Tax Information")})})]})]})]})},le=s=>s?/^([a-zA-Z]{1,4}|[\u0600-\u06FF]{1,4})[ -]?([0-9]{1,4}|[\u0660-\u0669]{1,4})$/.test(s.trim()):!1,ie=s=>{if(!s)return s;let f=s.trim().toUpperCase().replace(/\s+/g," ");const b=/^([a-zA-Z]{1,4}|[\u0600-\u06FF]{1,4})([0-9]{1,4}|[\u0660-\u0669]{1,4})$/;return b.test(f)&&(f=f.replace(b,"$1 $2")),f},oe=["Hyundai","Nissan","Chevrolet","Kia","Toyota","Peugeot","Renault","MG","Skoda","Chery","BMW","Mercedes-Benz"],ne=({vehicles:s,onAddVehicle:f,onUpdateVehicle:b,onDeleteVehicle:a,onSetDefaultVehicle:r,onSuccess:c,onError:i})=>{const{t:n}=D(),[N,y]=(0,x.useState)(!1),[p,w]=(0,x.useState)(null),[k,v]=(0,x.useState)(null),[d,u]=(0,x.useState)({alias:"",make:"",model:"",licensePlate:"",color:"",year:"",isDefault:!1}),[P,t]=(0,x.useState)(!1),[h,C]=(0,x.useState)(null),j=()=>{w(null),u({alias:"",make:"",model:"",licensePlate:"",color:"",year:"",isDefault:s.length===0}),C(null),y(!0)},_=l=>{w(l.id),u({alias:l.name||"",make:l.make||"",model:l.model||"",licensePlate:l.licensePlate||"",color:l.color||"",year:l.year?.toString()||"",isDefault:l.isDefault}),C(null),y(!0)},g=async()=>{if(!d.alias.trim()||!d.make||!d.model.trim()||!d.licensePlate.trim()){C(n("profile.vehicles.errorRequired","Please complete all required fields."));return}if(!le(d.licensePlate)){C(n("profile.vehicles.invalidPlate","Please enter a valid Egyptian license plate (e.g. 123 ABC or ١٢٣ أ ب ج)."));return}t(!0),C(null);const l={name:d.alias.trim(),make:d.make,model:d.model.trim(),licensePlate:ie(d.licensePlate),type:"sedan",color:d.color.trim()||"N/A",year:d.year?parseInt(d.year,10):void 0,isDefault:d.isDefault};try{p?(await b(p,l),c(n("profile.vehicles.updated","Vehicle updated successfully."))):(await f(l),c(n("profile.vehicles.saved","Vehicle added successfully."))),y(!1)}catch(S){C(S instanceof Error?S.message:n("profile.vehicles.saveFailed","Failed to save vehicle."))}finally{t(!1)}},m=async l=>{try{await a(l),c(n("profile.vehicles.deleted","Vehicle removed successfully.")),v(null)}catch(S){i(S instanceof Error?S.message:n("profile.vehicles.deleteFailed","Failed to delete vehicle."))}};return(0,e.jsxs)("div",{"data-component":"profile.VehiclesTab",className:"space-y-6 animate-fade-in max-w-3xl",children:[(0,e.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-grey-900 mb-1",children:n("profile.vehicles.title","My Vehicles")}),(0,e.jsx)("p",{className:"text-xs text-grey-400",children:n("profile.vehicles.subtitle","Register vehicles for automated license plate recognition (ALPR) at gates.")})]}),(0,e.jsxs)("button",{type:"button",onClick:j,className:"px-5 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold uppercase tracking-wider rounded-xl transition-all shadow-sm flex items-center gap-2 self
1-start sm:self-auto",children:[(0,e.jsx)(o,{name:"plus",size:16}),(0,e.jsx)("span",{children:n("profile.vehicles.addVehicle","Add Vehicle")})]})]}),s.length>0?(0,e.jsx)("div",{className:"grid gap-4 sm:grid-cols-2",children:s.map(l=>(0,e.jsxs)("div",{className:"p-5 bg-white border border-grey-200/80 rounded-2xl flex flex-col justify-between shadow-xs hover:border-primary-200 transition-all relative group",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-2",children:[(0,e.jsxs)("h3",{className:"font-bold text-grey-900 text-base truncate flex items-center gap-2",children:[(0,e.jsx)(o,{name:"car",className:"w-4 h-4 text-primary-500 shrink-0"}),(0,e.jsx)("span",{children:l.name||`${l.make} ${l.model}`})]}),l.isDefault?(0,e.jsx)("span",{className:"text-[11px] bg-primary-50 text-primary-600 border border-primary-200 px-2 py-0.5 rounded-full font-bold uppercase tracking-wider",children:n("profile.vehicles.default","Default")}):(0,e.jsx)("button",{type:"button",onClick:()=>r(l.id),className:"text-[11px] text-grey-400 hover:text-primary-600 hover:bg-grey-50 px-2 py-0.5 rounded-full border border-grey-200 font-semibold transition-colors",children:n("profile.vehicles.setDefault","Set as Default")})]}),(0,e.jsxs)("div",{className:"text-xs text-grey-600 space-y-1 mb-4",children:[(0,e.jsxs)("p",{className:"font-medium text-grey-800",children:[l.make," ",l.model," ",l.year?`(${l.year})`:""]}),l.color&&(0,e.jsxs)("p",{className:"text-grey-400",children:[n("profile.vehicles.color","Color"),": ",(0,e.jsx)("span",{className:"text-grey-700 capitalize",children:l.color})]}),(0,e.jsxs)("div",{className:"pt-1 flex items-center gap-2",children:[(0,e.jsxs)("span",{className:"text-grey-400 font-semibold uppercase tracking-wider text-[10px]",children:[n("profile.vehicles.plate","Plate"),":"]}),(0,e.jsx)("span",{className:"font-mono bg-grey-100 border border-grey-200 px-2.5 py-1 rounded-lg text-xs font-bold text-grey-900 tracking-wider",children:l.licensePlate})]})]})]}),(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-3 border-t border-grey-100",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>_(l),className:"px-3 py-1.5 text-xs font-semibold text-grey-600 hover:text-primary-600 hover:bg-grey-50 rounded-lg transition-colors flex items-center gap-1.5 border border-grey-200",children:[(0,e.jsx)(o,{name:"edit",size:14}),(0,e.jsx)("span",{children:n("profile.vehicles.edit","Edit")})]}),(0,e.jsx)("button",{type:"button",onClick:()=>v(l.id),className:"p-1.5 text-grey-400 hover:text-error-500 hover:bg-error-50 rounded-lg transition-colors","aria-label":"Delete Vehicle",children:(0,e.jsx)(o,{name:"trash2",size:15})})]})]},l.id))}):(0,e.jsxs)("div",{className:"text-center py-16 bg-grey-50 rounded-2xl border-2 border-dashed border-grey-200",children:[(0,e.jsx)(o,{name:"car",className:"mx-auto h-12 w-12 text-grey-300 mb-3"}),(0,e.jsx)("p",{className:"text-sm font-semibold text-grey-700 mb-1",children:n("profile.vehicles.noVehicles","No vehicles registered yet")}),(0,e.jsx)("p",{className:"text-xs text-grey-400 max-w-sm mx-auto mb-4",children:n("profile.vehicles.noVehiclesDesc","Add your car license plate so gate barriers open automatically upon arrival.")}),(0,e.jsx)("button",{type:"button",onClick:j,className:"px-5 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold rounded-xl transition-all shadow-sm",children:n("profile.vehicles.addFirstVehicle","Add Your First Vehicle")})]}),N&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-grey-900/50 backdrop-blur-sm p-4 animate-fade-in",role:"dialog","aria-modal":"true",children:(0,e.jsxs)("div",{className:"bg-white rounded-3xl max-w-md w-full overflow-hidden shadow-2xl border border-grey-100 flex flex-col",children:[(0,e.jsxs)("div",{className:"px-6 py-4 border-b border-grey-100 flex justify-between items-center bg-grey-50/60",children:[(0,e.jsx)("h3",{className:"text-lg font-bold text-grey-900",children:p?n("profile.vehicles.modal.editTitle","Edit Vehicle"):n("profile.vehicles.modal.addTitle","Register New Vehicle")}),(0,e.jsx)("button",{type:"button",onClick:()=>y(!1),className:"text-grey-400 hover:text-grey-600 p-1.5 rounded-xl hover:bg-grey-100 transition-colors",children:(0,e.jsx)(o,{name:"x",size:18})})]}),(0,e.jsxs)("div",{className:"p-6 space-y-4",children:[h&&(0,e.jsxs)("div",{className:"p-3 bg-error-50 border border-error-200 rounded-xl text-xs font-semibold text-error-600 flex items-center gap-2",children:[(0,e.jsx)(o,{name:"alertCircle",className:"w-4 h-4 shrink-0 text-error-500"}),(0,e.jsx)("span",{children:h})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{htmlFor:"modal-vehicle-alias",className:"block text-xs font-semibold text-grey-700 mb-1",children:[n("profile.vehicles.modal.alias","Vehicle Nickname")," *"]}),(0,e.jsx)("input",{id:"modal-vehicle-alias",type:"text",placeholder:"e.g. My Commuter Sedan",value:d.al
1ias,onChange:l=>u({...d,alias:l.target.value}),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{htmlFor:"modal-vehicle-make",className:"block text-xs font-semibold text-grey-700 mb-1",children:[n("profile.vehicles.modal.make","Car Brand / Make")," *"]}),(0,e.jsxs)("select",{id:"modal-vehicle-make",value:d.make,onChange:l=>u({...d,make:l.target.value}),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white",children:[(0,e.jsx)("option",{value:"",disabled:!0,children:n("profile.vehicles.modal.selectMake","Select Manufacturer")}),oe.map(l=>(0,e.jsx)("option",{value:l,children:l},l))]})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{htmlFor:"modal-vehicle-model",className:"block text-xs font-semibold text-grey-700 mb-1",children:[n("profile.vehicles.modal.model","Model")," *"]}),(0,e.jsx)("input",{id:"modal-vehicle-model",type:"text",placeholder:"e.g. Sunny / Tucson",value:d.model,onChange:l=>u({...d,model:l.target.value}),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{htmlFor:"modal-vehicle-plate",className:"block text-xs font-semibold text-grey-700 mb-1",children:[n("profile.vehicles.modal.licensePlate","Plate Number")," *"]}),(0,e.jsx)("input",{id:"modal-vehicle-plate",type:"text",placeholder:"123 ABC or ١٢٣ أ ب ج",value:d.licensePlate,onChange:l=>u({...d,licensePlate:l.target.value}),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-mono uppercase font-bold text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"modal-vehicle-color",className:"block text-xs font-semibold text-grey-700 mb-1",children:n("profile.vehicles.modal.color","Color")}),(0,e.jsx)("input",{id:"modal-vehicle-color",type:"text",placeholder:"e.g. Silver",value:d.color,onChange:l=>u({...d,color:l.target.value}),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"modal-vehicle-year",className:"block text-xs font-semibold text-grey-700 mb-1",children:n("profile.vehicles.modal.year","Year")}),(0,e.jsx)("input",{id:"modal-vehicle-year",type:"number",placeholder:"e.g. 2023",value:d.year,onChange:l=>u({...d,year:l.target.value}),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]})]}),(0,e.jsxs)("label",{className:"flex items-center gap-2.5 pt-2 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:d.isDefault,onCh
1ange:l=>u({...d,isDefault:l.target.checked}),className:"rounded text-primary-500 focus:ring-primary-500 w-4 h-4"}),(0,e.jsx)("span",{className:"text-xs font-semibold text-grey-700",children:n("profile.vehicles.modal.isDefault","Set as default vehicle for quick booking")})]})]}),(0,e.jsxs)("div",{className:"px-6 py-4 bg-grey-50/60 border-t border-grey-100 flex justify-end gap-3",children:[(0,e.jsx)("button",{type:"button",onClick:()=>y(!1),disabled:P,className:"px-4 py-2 border border-grey-200 rounded-xl text-xs font-semibold text-grey-600 hover:bg-grey-100 transition-colors",children:n("common.cancel","Cancel")}),(0,e.jsx)("button",{type:"button",onClick:g,disabled:P,className:"px-5 py-2 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold rounded-xl transition-all shadow-sm flex items-center gap-2 disabled:opacity-50",children:P?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o,{name:"loader",size:14,className:"animate-spin"}),(0,e.jsx)("span",{children:n("common.saving","Saving...")})]}):(0,e.jsx)("span",{children:p?n("common.saveChanges","Save Changes"):n("profile.vehicles.modal.save","Add Vehicle")})})]})]})}),k&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-grey-900/50 backdrop-blur-sm p-4 animate-fade-in",role:"dialog","aria-modal":"true",children:(0,e.jsxs)("div",{className:"bg-white rounded-3xl max-w-sm w-full p-6 shadow-2xl border border-grey-100 text-center",children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-full bg-error-50 text-error-500 flex items-center justify-center mx-auto mb-4",children:(0,e.jsx)(o,{name:"alertTriangle",size:24})}),(0,e.jsx)("h3",{className:"text-base font-bold text-grey-900 mb-1",children:n("profile.vehicles.deleteConfirmTitle","Delete Vehicle")}),(0,e.jsx)("p",{className:"text-xs text-grey-500 mb-6",children:n("profile.vehicles.deleteConfirm","Are you sure you want to remove this vehicle? Automatic ALPR entry will no longer function for this plate.")}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:()=>v(null),className:"flex-1 py-2.5 border border-grey-200 rounded-xl text-xs font-semibold text-grey-600 hover:bg-grey-100",children:n("common.cancel","Cancel")}),(0,e.jsx)("button",{type:"button",onClick:()=>m(k),className:"flex-1 py-2.5 bg-error-500 hover:bg-error-600 text-white text-xs font-bold rounded-xl shadow-sm",children:n("common.delete","Delete")})]})]})})]})},de=["Credit Card (Paymob)","Mobile Wallet (Vodafone Cash / Orange / Etisalat / WE)","InstaPay"],ce=({paymentMethods:s,onAddPaymentMethod:f,onUpdatePaymentMethod:b,onRemovePaymentMethod:a,onSuccess:r,onError:c})=>{const{t:i}=D(),[n,N]=(0,x.useState)(!1),[y,p]=(0,x.useState)(null),[w,k]=(0,x.useState)(null),[v,d]=(0,x.useState)({provider:"",details:"",isDefault:!1}),[u,P]=(0,x.useState)(!1),[t,h]=(0,x.useState)(null),C=()=>{p(null),d({provider:"",details:"",isDefault:s.length===0}),h(null),N(!0)},j=m=>{p(m.id),d({provider:m.provider||m.name||"",details:m.details||"",isDefault:m.isDefault}),h(null),N(!0)},_=async()=>{if(!v.provider||!v.details.trim()){h(i("profile.payment.errorRequired","Please choose a provider and provide payment identifier details."));return}P(!0),h(null);const m={type:v.provider.toLowerCase().includes("card")?"card":v.provider.toLowerCase().includes("wallet")?"mobile_wallet":"fawry",name:v.provider,provider:v.provider,details:v.details.trim(),isDefault:v.isDefault};try{y?(await b(y,m),r(i("profile.payment.updated","Payment method updated successfully."))):(await f(m),r(i("profile.payment.saved","Payment method added successfully."))),N(!1)}catch(l){h(l instanceof Error?l.message:i("profile.payment.saveFailed","Failed to save payment method."))}finally{P(!1)}},g=async m=>{try{await a(m),r(i("profile.payment.deleted","Payment method removed successfully.")),k(null)}catch(l){c(l instanceof Error?l.message:i("profile.payment.deleteFailed","Failed to delete payment method."))}};return(0,e.jsxs)("div",{"data-component":"profile.PaymentMethodsTab",className:"space-y-6 animate-fade-in max-w-3xl",children:[(0,e.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-grey-900 mb-1",children:i("profile.payment.title","Payment Methods & Wallets")}),(0,e.jsx)("p",{className:"text-xs text-grey-400",children:i("profile.payment.subtitle","Manage saved Paymob cards, InstaPay, and Egyptian mobile wallets for one-click checkout.")})]}),(0,e.jsxs)("button",{type:"button",onClick:C,className:"px-5 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold uppercase tracking-wider rounded-xl transition-all shadow-sm flex items-center gap-2 self
1-start sm:self-auto",children:[(0,e.jsx)(o,{name:"plus",size:16}),(0,e.jsx)("span",{children:i("profile.payment.addNew","Add Payment Method")})]})]}),s.length>0?(0,e.jsx)("div",{className:"grid gap-4 sm:grid-cols-2",children:s.map(m=>(0,e.jsxs)("div",{className:"p-5 bg-white border border-grey-200/80 rounded-2xl flex flex-col justify-between shadow-xs hover:border-primary-200 transition-all relative group",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2.5 overflow-hidden",children:[(0,e.jsx)("div",{className:"w-8 h-8 rounded-xl bg-primary-50 text-primary-500 flex items-center justify-center shrink-0",children:(0,e.jsx)(o,{name:m.provider?.toLowerCase().includes("wallet")||m.type==="mobile_wallet"?"smartphone":"creditCard",size:18})}),(0,e.jsx)("h3",{className:"font-bold text-grey-900 text-sm truncate",children:m.name||m.provider})]}),m.isDefault&&(0,e.jsx)("span",{className:"text-[10px] bg-primary-50 text-primary-600 border border-primary-200 px-2 py-0.5 rounded-full font-bold uppercase tracking-wider shrink-0",children:i("profile.payment.default","Primary")})]}),(0,e.jsx)("p",{className:"text-xs font-mono text-grey-600 tracking-wider mt-3 mb-1",children:m.details}),(0,e.jsx)("p",{className:"text-[11px] text-grey-400",children:i("pricing.vatIncludedBadge","Paymob 3D Secure / EGP")})]}),(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-3 border-t border-grey-100 mt-4",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>j(m),className:"px-3 py-1.5 text-xs font-semibold text-grey-600 hover:text-primary-600 hover:bg-grey-50 rounded-lg transition-colors flex items-center gap-1.5 border border-grey-200",children:[(0,e.jsx)(o,{name:"edit",size:14}),(0,e.jsx)("span",{children:i("common.edit","Edit")})]}),(0,e.jsx)("button",{type:"button",onClick:()=>k(m.id),className:"p-1.5 text-grey-400 hover:text-error-500 hover:bg-error-50 rounded-lg transition-colors","aria-label":"Delete Payment Method",children:(0,e.jsx)(o,{name:"trash2",size:15})})]})]},m.id))}):(0,e.jsxs)("div",{className:"text-center py-16 bg-grey-50 rounded-2xl border-2 border-dashed border-grey-200",children:[(0,e.jsx)(o,{name:"wallet",className:"mx-auto h-12 w-12 text-grey-300 mb-3"}),(0,e.jsx)("p",{className:"text-sm font-semibold text-grey-700 mb-1",children:i("profile.payment.emptyWallet","No saved payment methods")}),(0,e.jsx)("p",{className:"text-xs text-grey-400 max-w-sm mx-auto mb-4",children:i("profile.payment.emptyDesc","Save a card or Egyptian mobile wallet (Vodafone Cash, Orange, Etisalat, InstaPay) for rapid gate checkouts.")}),(0,e.jsx)("button",{type:"button",onClick:C,className:"px-5 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold rounded-xl transition-all shadow-sm",children:i("profile.payment.addFirst","Add Your First Payment Method")})]}),n&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-grey-900/50 backdrop-blur-sm p-4 animate-fade-in",role:"dialog","aria-modal":"true",children:(0,e.jsxs)("div",{className:"bg-white rounded-3xl max-w-md w-full overflow-hidden shadow-2xl border border-grey-100 flex flex-col",children:[(0,e.jsxs)("div",{className:"px-6 py-4 border-b border-grey-100 flex justify-between items-center bg-grey-50/60",children:[(0,e.jsx)("h3",{className:"text-lg font-bold text-grey-900",children:y?i("profile.payment.modal.editTitle","Edit Payment Method"):i("profile.payment.modal.addTitle","Add Payment Method")}),(0,e.jsx)("button",{type:"button",onClick:()=>N(!1),className:"text-grey-400 hover:text-grey-600 p-1.5 rounded-xl hover:bg-grey-100 transition-colors",children:(0,e.jsx)(o,{name:"x",size:18})})]}),(0,e.jsxs)("div",{className:"p-6 space-y-4",children:[t&&(0,e.jsxs)("div",{className:"p-3 bg-error-50 border border-error-200 rounded-xl text-xs font-semibold text-error-600 flex items-center gap-2",children:[(0,e.jsx)(o,{name:"alertCircle",className:"w-4 h-4 shrink-0 text-error-500"}),(0,e.jsx)("span",{children:t})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{htmlFor:"modal-payment-provider",className:"block text-xs font-semibold text-grey-700 mb-1",children:[i("profile.payment.modal.provider","Payment Channel")," *"]}),(0,e.jsxs)("select",{id:"modal-payment-provider",value:v.provider,onCh
1ange:m=>d({...v,provider:m.target.value}),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white",children:[(0,e.jsx)("option",{value:"",disabled:!0,children:i("profile.payment.modal.selectProvider","Select Payment Option")}),de.map(m=>(0,e.jsx)("option",{value:m,children:m},m))]})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{htmlFor:"modal-payment-details",className:"block text-xs font-semibold text-grey-700 mb-1",children:[i("profile.payment.modal.details","Card Last 4 Digits or Wallet Number")," *"]}),(0,e.jsx)("input",{id:"modal-payment-details",type:"text",placeholder:"e.g. **** 1234 or 010XXXXXXXX",value:v.details,onChange:m=>d({...v,details:m.target.value}),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white"})]}),(0,e.jsxs)("label",{className:"flex items-center gap-2.5 pt-2 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:v.isDefault,onCh
1ange:m=>d({...v,isDefault:m.target.checked}),className:"rounded text-primary-500 focus:ring-primary-500 w-4 h-4"}),(0,e.jsx)("span",{className:"text-xs font-semibold text-grey-700",children:i("profile.payment.modal.isDefault","Set as primary payment method")})]})]}),(0,e.jsxs)("div",{className:"px-6 py-4 bg-grey-50/60 border-t border-grey-100 flex justify-end gap-3",children:[(0,e.jsx)("button",{type:"button",onClick:()=>N(!1),disabled:u,className:"px-4 py-2 border border-grey-200 rounded-xl text-xs font-semibold text-grey-600 hover:bg-grey-100 transition-colors",children:i("common.cancel","Cancel")}),(0,e.jsx)("button",{type:"button",onClick:_,disabled:u,className:"px-5 py-2 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold rounded-xl transition-all shadow-sm flex items-center gap-2 disabled:opacity-50",children:u?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o,{name:"loader",size:14,className:"animate-spin"}),(0,e.jsx)("span",{children:i("common.saving","Saving...")})]}):(0,e.jsx)("span",{children:y?i("common.saveChanges","Save Changes"):i("profile.payment.modal.save","Add Method")})})]})]})}),w&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-grey-900/50 backdrop-blur-sm p-4 animate-fade-in",role:"dialog","aria-modal":"true",children:(0,e.jsxs)("div",{className:"bg-white rounded-3xl max-w-sm w-full p-6 shadow-2xl border border-grey-100 text-center",children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-full bg-error-50 text-error-500 flex items-center justify-center mx-auto mb-4",children:(0,e.jsx)(o,{name:"trash2",size:24})}),(0,e.jsx)("h3",{className:"text-base font-bold text-grey-900 mb-1",children:i("profile.payment.deleteConfirmTitle","Delete Payment Method")}),(0,e.jsx)("p",{className:"text-xs text-grey-500 mb-6",children:i("profile.payment.deleteConfirm","Are you sure you want to remove this payment method?")}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:()=>k(null),className:"flex-1 py-2.5 border border-grey-200 rounded-xl text-xs font-semibold text-grey-600 hover:bg-grey-100",children:i("common.cancel","Cancel")}),(0,e.jsx)("button",{type:"button",onClick:()=>g(w),className:"flex-1 py-2.5 bg-error-500 hover:bg-error-600 text-white text-xs font-bold rounded-xl shadow-sm",children:i("common.delete","Delete")})]})]})})]})},me=({isOpen:s,onClose:f,booking:b,onSuccess:a})=>{const{t:r,i18n:c}=D(),i=c.language.startsWith("ar"),[n,N]=(0,x.useState)(30),[y,p]=(0,x.useState)(""),[w,k]=(0,x.useState)(!1),[v,d]=(0,x.useState)(null);if(!s||!b)return null;const u=y?Math.max(15,parseInt(y,10)||0):n,P=Math.max(1,b.duration_hours||1),t=b.total_amount||b.final_amount||30,h=Math.max(15,Math.round(t/P))/60*u,C=h*.14,j=h+C,_=new Date(b.end_time),g=new Date(_.getTime()+u*60*1e3),m=S=>S.toLocaleTimeString(i?"ar-EG":"en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}),l=async()=>{if(u<=0){d(r("profile.bookings.invalidMinutes","Please select a valid extension duration."));return}k(!0),d(null);try{const S=await ee(b.id,u);S.ok?(k(!1),a(),f()):(k(!1),d(S.error?.message||r("profile.bookings.extendError","Failed to extend booking. Please try again.")))}catch(S){k(!1),d(S instanceof Error?S.message:r("profile.bookings.extendError","Failed to extend booking."))}};return(0,e.jsx)("div",{"data-component":"profile.BookingExtensionModal",className:"fixed inset-0 z-50 flex items-center justify-center bg-grey-900/50 backdrop-blur-sm p-4 animate-fade-in",role:"dialog","aria-modal":"true","aria-labelledby":"extension-modal-title",children:(0,e.jsxs)("div",{className:"bg-white rounded-3xl max-w-lg w-full overflow-hidden shadow-2xl border border-grey-100 flex flex-col",children:[(0,e.jsxs)("div",{className:"px-6 py-5 border-b border-grey-100 flex justify-between items-center bg-grey-50/60",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{id:"extension-modal-title",className:"text-xl font-bold text-grey-900 flex items-center gap-2",children:[(0,e.jsx)(o,{name:"clock",className:"w-5 h-5 text-primary-500"}),r("profile.bookings.extendModalTitle","Extend Parking Reservation")]}),(0,e.jsxs)("p",{className:"text-xs text-grey-500 mt-0.5",children:[r("profile.bookings.bookingRef","Booking Reference"),": #",b.booking_reference||b.id.split("-")[0]]})]}),(0,e.jsx)("button",{onClick:f,className:"text-grey-400 hover:text-grey-600 p-2 rounded-xl hover:bg-grey-100 transition-colors","aria-label":r("common.close","Close"),children:(0,e.jsx)(o,{name:"x",className:"w-5 h-5"})})]}),(0,e.jsxs)("div",{className:"p-6 space-y-6",children:[v&&(0,e.jsxs)("div",{className:"p-3.5 bg-error-50 border border-error-200 rounded-xl text-xs font-semibold text-error-600 flex items-center gap-2",children:[(0,e.jsx)(o,{name:"alertTriangle",className:"w-4 h-4 shrink-0 text-error-500"}),(0,e.jsx)("span",{children:v})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 p-4 bg-primary-50/50 border border-primary-100 rounded-2xl",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"block text-xs font-medium text-grey-500 mb-1",children:r("profile.bookings.currentExit","Current Exit")}),(0,e.jsx)("span",{className:"text-sm font-bold text-grey-900",children:m(_)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"block text-xs font-medium text-primary-700 mb-1",children:r("profile.bookings.newExit","New Exit Time (12h)")}),(0,e.jsx)("span",{className:"text-sm font-bold text-primary-600",children:m(g)})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider text-grey-600 mb-2.5",children:r("profile.bookings.selectDuration","Select Duration")}),(0,e.jsx)("div",{className:"grid grid-cols-3 gap-2.5",children:[30,60,120].map(S=>(0,e.jsxs)("button",{type:"button",onClick:()=>{N(S),p("")},className:`py-3 px-3 rounded-2xl border text-sm font-bold transition-all ${!y&&n===S?"border-primary-500 bg-primary-500 text-white shadow-md":"border-grey-200 bg-white text-grey-700 hover:border-primary-200 hover:bg-grey-50"}
1`,children:["+",S," ",r("common.minutesShort","mins")]},S))}),(0,e.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,e.jsx)("input",{type:"number",min:"15",step:"15",placeholder:r("profile.bookings.customMinutes","Custom minutes (e.g. 45)"),value:y,onChange:S=>p(S.target.value),className:"flex-1 px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-800 placeholder:text-grey-400 focus:outline-none focus:ring-2 focus:ring-primary-500"}),y&&(0,e.jsx)("button",{type:"button",onClick:()=>p(""),className:"px-3 py-2 text-xs font-semibold text-grey-500 hover:text-grey-700",children:r("common.clear","Clear")})]})]}),(0,e.jsxs)("div",{className:"p-4 bg-grey-50 rounded-2xl border border-grey-100 space-y-2 text-xs",children:[(0,e.jsxs)("div",{className:"flex justify-between text-grey-600",children:[(0,e.jsxs)("span",{children:[r("profile.bookings.extensionBase","Extension Fee")," (",u," ",r("common.minutesShort","mins"),")"]}),(0,e.jsxs)("span",{className:"font-semibold text-grey-900",children:[h.toFixed(2)," EGP"]})]}),(0,e.jsxs)("div",{className:"flex justify-between text-grey-500",children:[(0,e.jsx)("span",{className:"flex items-center gap-1",children:r("pricing.vatStatutory","Statutory Egyptian VAT (14%)")}),(0,e.jsxs)("span",{className:"font-semibold text-grey-900",children:[C.toFixed(2)," EGP"]})]}),(0,e.jsxs)("div",{className:"pt-2 border-t border-grey-200 flex justify-between items-center text-sm font-bold text-grey-900",children:[(0,e.jsx)("span",{children:r("common.totalDue","Total Amount Due")}),(0,e.jsxs)("span",{className:"text-base text-primary-600",children:[j.toFixed(2)," EGP"]})]})]})]}),(0,e.jsxs)("div",{className:"px-6 py-4 bg-grey-50/60 border-t border-grey-100 flex justify-end gap-3",children:[(0,e.jsx)("button",{type:"button",onClick:f,disabled:w,className:"px-5 py-2.5 rounded-xl border border-grey-200 text-sm font-semibold text-grey-700 hover:bg-grey-100 transition-colors disabled:opacity-50",children:r("common.cancel","Cancel")}),(0,e.jsx)("button",{type:"button",onClick:l,disabled:w||u<=0,className:"px-6 py-2.5 rounded-xl bg-primary-500 text-white text-sm font-semibold hover:bg-primary-600 transition-all shadow-md disabled:opacity-50 flex items-center gap-2",children:w?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o,{name:"loader",className:"w-4 h-4 animate-spin"}),(0,e.jsx)("span",{children:r("profile.bookings.extending","Processing...")})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o,{name:"check",className:"w-4 h-4"}),(0,e.jsx)("span",{children:r("profile.bookings.confirmAndPay","Confirm Extension")})]})})]})]})})},xe=({bookings:s,loading:f,onRefreshBookings:b})=>{const{t:a,i18n:r}=D(),c=r.language.startsWith("ar"),[i,n]=(0,x.useState)("in_progress"),[N,y]=(0,x.useState)(null),[p,w]=(0,x.useState)(null),k=t=>{y(h=>h===t?null:t)},d=(()=>{const t=new Date;return s.filter(h=>{const C=new Date(h.start_time),j=new Date(h.end_time);return h.status==="cancelled"||h.status==="expired"||h.status==="rejected"||h.status==="completed"||j<t?i==="history":C<=t||h.status==="active"?i==="in_progress":i==="future"})})(),u=t=>{try{return new Date(t).toLocaleTimeString(c?"ar-EG":"en-US",{hour:"2-digit",minute:"2-digit",hour12:!0})}catch{return t}},P=t=>{try{return new Date(t).toLocaleDateString(c?"ar-EG":"en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return t}};return(0,e.jsxs)("div",{"data-component":"profile.BookingsTab",className:"animate-in fade-in slide-in-from-bottom-4 duration-500",children:[(0,e.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-8",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-grey-900 tracking-tight",children:a("profile.bookings.title","Parking Passes & Bookings")}),(0,e.jsx)("p",{className:"text-grey-400 text-xs mt-0.5",children:a("profile.bookings.subtitle","Access active QR passes, manage reservations, and extend parking time.")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-grey-100 p-1 rounded-xl self-start sm:self-center border border-grey-200/60",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>n("in_progress"),className:`px-3.5 py-1.5 text-xs font-semibold rounded-lg transition-all flex items-center gap-1.5 ${i==="in_progress"?"bg-white text-primary-600 shadow-xs":"text-grey-500 hover:text-grey-800"}`,children:[(0,e.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${i==="in_progress"?"bg-primary-500 animate-pulse":"bg-grey-400"}`}),(0,e.jsx)("span",{children:a("profile.bookings.inProgress","In Process")})]}),(0,e.jsx)("button",{type:"button",onClick:()=>n("future"),className:`px-3.5 py-1.5 text-xs font-semibold rounded-lg transition-all ${i==="future"?"bg-white text-grey-900 shadow-xs":"text-grey-500 hover:text-grey-800"}`,children:a("profile.bookings.future","Upcoming")}),(0,e.jsx)("button",{type:"button",onClick:()=>n("history"),className:`px-3.5 py-1.5 text-xs font-semibold rounded-lg transition-all ${i==="history"?"bg-white text-grey-900 shadow-xs":"text-grey-500 hover:text-grey-800"}`,children:a("profile.bookings.history","History")})]})]}),f?(0,e.jsx)("div",{className:"space-y-4",children:[1,2,3].map(t=>(0,e.jsx)("div",{className:"border border-grey-100 bg-white rounded-2xl p-5 h-32 animate-shimmer",style:{animationDelay:`${t*80}ms`}},t))}):d.length>0?(0,e.jsx)("div",{className:"space-y-4",children:d.map(t=>{const h=N===t.id,C=t.status==="in_progress"||t.status==="active"||t.status==="confirmed";return(0,e.jsxs)("div",{className:"bg-white border border-grey-200/80 rounded-2xl p-5 flex flex-col gap-4 shadow-xs hover:border-primary-200 transition-all",children:[(0,e.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between gap-5",children:[(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[(0,e.jsx)("span",{className:`px-2.5 py-0.5 text-[11px] font-bold uppercase tracking-wider rounded-md ${t.status==="confirmed"||t.status==="active"||t.status==="completed"?"bg-success-50 text-success-700 border border-success-200":t.status==="cancelled"||t.status==="expired"?"bg-error-50 text-error-700 border border-error-200":"bg-primary-50 text-primary-700 border border-primary-200"}`,children:(t.status||"pending").replace("_"," ")}
1),(0,e.jsx)(se,{content:a(`profile.bookings.status_${t.status||"pending"}`,`Booking status: ${(t.status||"pending").replace("_"," ")}`)}),(t.status==="confirmed"||t.status==="active"||t.status==="in_progress")&&(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-emerald-500/10 border border-emerald-500/30 text-emerald-700",children:[(0,e.jsx)(o,{name:"checkCircle2",className:"w-3 h-3 text-emerald-600"}),a("confirmation.paidInFullBadge","Paid in Full — 0.00 EGP Due at Gate")]}),t.is_for_guest&&(0,e.jsxs)("span",{className:"px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider rounded-md bg-secondary-100 text-secondary-800",children:[a("profile.bookings.guest","Guest"),": ",t.guest_name]}),(0,e.jsxs)("span",{className:"text-xs font-mono text-grey-400",children:["#",t.booking_reference||t.id.split("-")[0]]})]}),(0,e.jsx)("h3",{className:"font-bold text-base text-grey-900 tracking-tight",children:(0,e.jsx)(F,{to:`/parking/${t.location_id}`,className:"hover:text-primary-600 transition-colors",children:t.parking_locations?.name||a("profile.bookings.locationUnavailable","IRKEN Parking Location")})}),(0,e.jsxs)("p",{className:"text-xs text-grey-400 flex items-center mt-1",children:[(0,e.jsx)(o,{name:"mapPin",className:"w-3.5 h-3.5 me-1 text-grey-400"}),t.parking_locations?.address||a("profile.bookings.addressUnavailable","Address not specified")]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5 mt-3 text-xs font-medium text-grey-600",children:[(0,e.jsxs)("div",{className:"flex items-center",children:[(0,e.jsx)(o,{name:"calendar",className:"w-3.5 h-3.5 me-1.5 text-grey-400"}),P(t.start_time)]}),(0,e.jsxs)("div",{className:"flex items-center",children:[(0,e.jsx)(o,{name:"clock",className:"w-3.5 h-3.5 me-1.5 text-grey-400"}),u(t.start_time)]}),(0,e.jsxs)("div",{className:"flex items-center",children:[(0,e.jsx)(o,{name:"timer",className:"w-3.5 h-3.5 me-1.5 text-grey-400"}),t.duration_hours,"h"]})]})]}),(0,e.jsxs)("div",{className:"flex flex-col sm:items-end justify-between border-t sm:border-t-0 sm:border-s border-grey-100 pt-3 sm:pt-0 sm:ps-5 shrink-0",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"text-xl font-bold text-grey-900",children:[(t.total_amount||t.final_amount||0).toFixed(2)," EGP"]}),(0,e.jsx)("span",{className:"text-[10px] text-grey-400 block sm:text-end",children:a("pricing.vatIncludedBadge","Includes 14% Egyptian VAT")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-4 sm:mt-0",children:[(0,e.jsx)("button",{type:"button",onClick:()=>k(t.id),className:"text-grey-600 hover:text-grey-900 font-semibold text-xs px-3 py-2 rounded-xl transition-colors border border-grey-200",children:h?a("profile.bookings.lessDetails","Less"):a("profile.bookings.fullDetails","Details")}),t.status==="pending_payment"?(0,e.jsx)(F,{to:`/payment/${t.id}`,className:"text-white bg-primary-500 hover:bg-primary-600 font-semibold text-xs px-4 py-2 rounded-xl transition-colors text-center shadow-xs",children:a("checkout.payNow","Pay Now")}):(0,e.jsxs)("div",{className:"flex gap-2",children:[C&&(0,e.jsxs)("button",{type:"button",onClick:()=>w(t),className:"text-white bg-primary-500 hover:bg-primary-600 font-semibold text-xs px-4 py-2 rounded-xl transition-all shadow-xs flex items-center gap-1.5",children:[(0,e.jsx)(o,{name:"clock",size:13}),(0,e.jsx)("span",{children:a("profile.bookings.extend","Extend")})]}),(0,e.jsxs)(F,{to:`/confirmation/${t.id}`,className:"text-primary-700 bg-primary-50 hover:bg-primary-100 border border-primary-200 font-semibold text-xs px-3.5 py-2 rounded-xl transition-colors text-center flex items-center gap-1",children:[(0,e.jsx)(o,{name:"ticket",size:13}),(0,e.jsx)("span",{children:a("profile.bookings.viewTicket","Pass")})]})]})]})]})]}),h&&(0,e.jsxs)("div",{className:"mt-3 pt-3 border-t border-grey-100 animate-fade-in grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 text-xs",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"block text-grey-400 mb-0.5",children:a("profile.bookings.bookingDate","Created")}),(0,e.jsx)("span",{className:"font-semibold text-grey-800",children:P(t.created_at||t.start_time)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"block text-grey-400 mb-0.5",children:a("profile.bookings.entry","Entry (12h)")}),(0,e.jsxs)("span",{className:"font-semibold text-grey-800",children:[P(t.start_time)," ",u(t.start_time)]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"block text-grey-400 mb-0.5",children:a("profile.bookings.exit","Exit (12h)")}),(0,e.jsxs)("span",{className:"font-semibold text-grey-800",children:[P(t.end_time)," ",u(t.end_time)]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"block text-grey-400 mb-0.5",children:a("profile.bookings.bookingRef","Booking Reference")}),(0,e.jsx)("span",{className:"font-mono font-bold text-grey-800",children:t.booking_reference||t.id})]}),t.user_vehicles&&(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"block text-grey-400 mb-0.5",children:a("profile.bookings.vehicle","Registered Vehicle")}),(0,e.jsxs)("span",{className:"font-semibold text-grey-800",children:[t.user_vehicles.name," 
1(",t.user_vehicles.license_plate,")"]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"block text-grey-400 mb-0.5",children:a("profile.bookings.totalAmount","Total Paid")}),(0,e.jsxs)("span",{className:"font-bold text-primary-600",children:[(t.total_amount||t.final_amount||0).toFixed(2)," EGP"]}),(0,e.jsx)("span",{className:"block text-[10px] text-grey-400",children:a("pricing.vatIncludedBadge","Includes 14% Egyptian VAT")})]}),(0,e.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 p-3 bg-amber-50/80 border border-amber-200/70 rounded-xl text-amber-900 text-xs font-medium flex items-center gap-2",children:[(0,e.jsx)(o,{name:"alertTriangle",className:"w-4 h-4 text-amber-600 shrink-0"}),(0,e.jsx)("span",{children:a("confirmation.overstayNoticeShort","Price locked for reserved duration. Late departure subject to operator hourly rates at gate exit.")})]})]})]},t.id)})}):(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 bg-grey-50 rounded-2xl border-2 border-dashed border-grey-200",children:[(0,e.jsx)("div",{className:"bg-primary-50 p-3.5 rounded-full mb-3 text-primary-500",children:(0,e.jsx)(o,{name:"calendar",size:28})}),(0,e.jsx)("h3",{className:"text-sm font-bold text-grey-800 mb-1",children:a("profile.bookings.noReservations","No reservations found in this section")}),(0,e.jsxs)("p",{className:"text-xs text-grey-400 text-center max-w-sm mb-4 leading-relaxed",children:[a("profile.bookings.noReservationsDesc","Search and reserve verified parking spots across Egypt with")," ",(0,e.jsx)("strong",{className:"text-grey-700",children:"IRKEN"}),"."]}),(0,e.jsx)(F,{to:"/search",className:"px-5 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold rounded-xl transition-all shadow-sm",children:a("profile.bookings.searchParking","Find Parking")})]}),p&&(0,e.jsx)(me,{isOpen:!!p,booking:p,onClose:()=>w(null),onSuccess:()=>{w(null),b()}})]})},pe=({favorites:s,loading:f,onRemoveFavorite:b})=>{const{t:a}=D();return(0,e.jsxs)("div",{"data-component":"profile.FavoritesTab",className:"space-y-6 animate-fade-in max-w-3xl",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-grey-900 mb-1",children:a("profile.favorites.title","Favorite Parking Facilities")}),(0,e.jsx)("p",{className:"text-xs text-grey-400",children:a("profile.favorites.subtitle","Quickly access and re-book your preferred parking facilities across Egypt.")})]}),f?(0,e.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2,3,4].map(r=>(0,e.jsx)("div",{className:"border border-grey-100 rounded-2xl overflow-hidden bg-white h-[240px] animate-shimmer",style:{animationDelay:`${r*80}ms`}},r))}):s.length>0?(0,e.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:s.map(r=>(0,e.jsxs)("div",{className:"group border border-grey-200/80 rounded-2xl overflow-hidden bg-white hover:border-primary-300 transition-all flex flex-col relative shadow-xs",children:[(0,e.jsxs)("div",{className:"h-32 bg-grey-100 relative overflow-hidden",children:[(0,e.jsx)("img",{src:r.images?.[0]||"https://images.unsplash.com/photo-1590674899484-9c64ade10ff5?auto=format&fit=crop&q=80",alt:r.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}),(0,e.jsx)("button",{type:"button",onClick:()=>b(r.id),className:"absolute top-2.5 end-2.5 bg-white/90 hover:bg-white backdrop-blur rounded-full p-2 z-10 transition-all cursor-pointer shadow-xs","aria-label":"Remove from Favorites",children:(0,e.jsx)(o,{name:"heart",className:"w-4 h-4 text-error-500 fill-error-500"})})]}),(0,e.jsxs)("div",{className:"p-4 flex-1 flex flex-col justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"font-bold text-grey-900 text-sm leading-tight mb-1",children:r.name||a("profile.favorites.customLocation","Parking Facility")}),(0,e.jsxs)("p",{className:"text-xs text-grey-400 flex items-center",children:[(0,e.jsx)(o,{name:"mapPin",className:"w-3.5 h-3.5 me-1 text-grey-400 shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:r.address||a("profile.bookings.addressUnavailable","Cairo, Egypt")})]})]}),(0,e.jsxs)("div",{className:"mt-4 pt-3 border-t border-grey-100 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center text-xs font-bold text-grey-800",children:[(0,e.jsx)(o,{name:"star",className:"w-3.5 h-3.5 text-secondary-500 fill-current me-1"}),(0,e.jsx)("span",{children:r.rating||"4.8"})]}),(0,e.jsxs)(F,{to:r.location_id?`/parking/${r.location_id}`:"/search",className:"text-xs font-bold text-primary-600 hover:text-primary-700 flex items-center gap-1",children:[(0,e.jsx)("span",{children:a("profile.favorites.bookNow","Book Now")}),(0,e.jsx)(o,{name:"arrowRight",size:12})]})]})]})]},r.id))}):(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 bg-grey-50 rounded-2xl border-2 border-dashed border-grey-200",children:[(0,e.jsx)("div",{className:"bg-error-50 p-3.5 rounded-full mb-3 text-error-500",children:(0,e.jsx)(o,{name:"heart",size:28})}),(0,e.jsx)("h3",{className:"text-sm font-bold text-grey-800 mb-1",children:a("profile.favorites.noFavorites","No saved favorites")}),(0,e.jsx)("p",{className:"text-xs text-grey-400 text-center max-w-sm mb-4 leading-relaxed",children:a("profile.favorites.noFavoritesDesc","Tap the heart icon on any parking facility to save it here for fast re-booking.")}),(0,e.jsx)(F,{to:"/search",className:"px-5 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold rounded-xl transition-all shadow-sm",children:a("profile.favorites.searchParking","Explore Parking")})]})]})},ge=()=>{const s=(0,x.useContext)(Q);if(!s)throw new Error("usePushNotifications must be used within a PushNotificationProvider");return s},ue=()=>{const{t:s}=D(),{isSupported:f,isSubscribed:b,settings:a,requestPermissionAndSubscribe:r,unsubscribe:c,updateSettings:i,loading:n}=ge(),{data:N=[],isLoading:y}=H(),{mutate:p,isPending:w}=K(),{mutate:k}=W(),{mutate:v}=Y(),[d,u]=(0,x.useState)(null),[P,t]=(0,x.useState)(null),h=()=>{d&&d.name.trim()&&(k({passkeyId:d.id,name:d.name.trim()}),u(null))},C=()=>{P&&(v(P),t(null))};return(0,e.jsxs)("div",{"data-component":"profile.SecurityTab",className:"space-y-8 animate-fade-in max-w-2xl",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-grey-900 mb-1",children:s("profile.tabs.security","Security & Credentials")}),(0,e.jsx)("p",{className:"text-xs text-grey-400",children:s("profile.security.subtitle","Configure modern biometric passkeys and push notifications for reservation alerts.")})]}),(0,e.jsxs)("section",{className:"bg-white rounded-2xl border border-grey-200/80 p-6 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-base font-bold text-grey-900 mb-1",children:s("profile.notifications.title","Push Notifications")}),(0,e.jsx)("p",{className:"text-xs text-grey-400 mb-5",children:s("profile.notifications.desc","Get updates about your reservations and exclusive offers directly to your device.")}),n?(0,e.jsx)("div",{className:"flex justify-center p-4",children:(0,e.jsx)(o,{name:"loader",className:"h-6 w-6 text-primary-500 animate-spin"})}):f?(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-4 border border-grey-200/80 rounded-xl bg-grey-50",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-bold text-grey-800",children:s("profile.notifications.enablePush","Enable Push Notifications")}),(0,e.jsx)("p",{className:"text-xs text-grey-400",children:b?s("profile.notifications.pushEnabled","Notifications are enabled on this device"):s("profile.notifications.pushDisabled","Enable to re
1ceive notifications")})]}),(0,e.jsxs)("label",{htmlFor:"security-push-enabled",className:"relative inline-flex items-center cursor-pointer",children:[(0,e.jsx)("input",{id:"security-push-enabled",name:"enablePush","aria-label":s("profile.notifications.enablePush","Enable Push Notifications"),type:"checkbox",className:"sr-only peer",checked:b,onChange:j=>{j.target.checked?r():c()}}),(0,e.jsx)("div",{className:"w-11 h-6 bg-grey-300 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-grey-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-primary-500"})]})]}),b&&a&&(0,e.jsxs)("div",{className:"ps-4 space-y-3 mt-3 border-s-2 border-primary-200",children:[(0,e.jsxs)("label",{htmlFor:"push-promotional-offers",className:"flex items-center gap-3 cursor-pointer group",children:[(0,e.jsx)("div",{className:`w-5 h-5 rounded-lg flex items-center justify-center border transition-colors ${a.reminders?"bg-primary-500 border-primary-500 text-white":"bg-white border-grey-300"}`,children:a.reminders&&(0,e.jsx)(o,{name:"check",size:14})}),(0,e.jsx)("span",{className:"text-xs font-semibold text-grey-700 select-none",children:s("profile.notifications.promotional","Promotional Offers & News")}),(0,e.jsx)("input",{id:"push-promotional-offers",name:"promotionalOffers",type:"checkbox",className:"hidden",checked:a.reminders,onChange:j=>i({reminders:j.target.checked})})]}),(0,e.jsxs)("label",{htmlFor:"push-booking-updates",className:"flex items-center gap-3 cursor-pointer group",children:[(0,e.jsx)("div",{className:`w-5 h-5 rounded-lg flex items-center justify-center border transition-colors ${a.booking_updates?"bg-primary-500 border-primary-500 text-white":"bg-white border-grey-300"}`,children:a.booking_updates&&(0,e.jsx)(o,{name:"check",size:14})}),(0,e.jsx)("span",{className:"text-xs font-semibold text-grey-700 select-none",children:s("profile.notifications.bookingUpdates","Booking Updates & Reminders")}),(0,e.jsx)("input",{id:"push-booking-updates",name:"bookingUpdates",type:"checkbox",className:"hidden",checked:a.booking_updates,onChange:j=>i({booking_updates:j.target.checked})})]})]})]}):(0,e.jsx)("div",{className:"p-4 border border-error-100 bg-error-50 rounded-xl",children:(0,e.jsx)("p",{className:"text-xs font-medium text-error-600",children:s("profile.notifications.pushNotSupported","Push notifications are not supported on this browser or platform.")})})]}),(0,e.jsxs)("section",{className:"bg-white rounded-2xl border border-grey-200/80 p-6 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-base font-bold text-grey-900 mb-1",children:s("profile.passkeys.title","Passkeys & Biometric Login")}),(0,e.jsx)("p",{className:"text-xs text-grey-400 mb-5",children:s("profile.passkeys.subtitle","Sign in securely with Touch ID, Face ID, or Windows Hello without typing passwords.")}),(0,e.jsxs)("div",{className:"space-y-3",children:[y?(0,e.jsx)("div",{className:"flex justify-center p-4",children:(0,e.jsx)(o,{name:"loader",className:"h-6 w-6 text-primary-500 animate-spin"})}):N.length>0?N.map(j=>(0,e.jsxs)("div",{className:"p-4 border border-grey-200/80 rounded-xl bg-grey-50 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("div",{className:"w-8 h-8 rounded-lg bg-primary-50 text-primary-600 flex items-center justify-center",children:(0,e.jsx)(o,{name:"fingerprint",size:18})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-bold text-sm text-grey-900",children:j.friendly_name||"Passkey"}),(0,e.jsxs)("p",{className:"text-[11px] text-grey-400",children:["Added ",new Date(j.created_at).toLocaleDateString()]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>u({id:j.id,name:j.friendly_name||""}),className:"p-2 text-grey-400 hover:text-grey-700 hover:bg-grey-100 rounded-lg transition-colors",title:"Rename Passkey",children:(0,e.jsx)(o,{name:"edit2",size:14})}),(0,e.jsx)("button",{type:"button",onClick:()=>t(j.id),className:"p-2 text-grey-400 hover:text-error-500 hover:bg-error-50 rounded-lg transition-colors",title:"Delete Passkey",children:(0,e.jsx)(o,{name:"trash2",size:14})})]})]},j.id)):(0,e.jsx)("div",{className:"text-center py-6",children:(0,e.jsx)("p",{className:"text-xs text-grey-400 mb-3",children:s("profile.passkeys.noPasskeys","No passkeys registered yet. Add one for rapid biometric login.")})}),(0,e.jsx)("button",{type:"button",onClick:()=>p(),disabled:w,className:"w-full mt-2 p-3.5 border-2 border-dashed border-primary-200 hover:border-primary-500 rounded-xl flex items-center justify-center gap-2 hover:bg-primary-50/50 transition-all group disabled:opacity-50 text-primary-600 font-bold text-xs",children:w?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o,{name:"loader",size:15,className:"animate-spin"}),(0,e.jsx)("span",{children:s("profile.passkeys.registering","Registering Passkey...")})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o,{name:"plus",size:15}),(0,e.jsx)("span",{children:s("profile.passkeys.addNew","Register New Passkey")})]})})]})]}),d&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-grey-900/50 backdrop-blur-sm p-4 animate-fade-in",role:"dialog","aria-modal":"true",children:(0,e.jsxs)("div",{className:"bg-white rounded-3xl max-w-sm w-full p-6 shadow-2xl border border-grey-100",children:[(0,e.jsx)("h3",{className:"text-base font-bold text-grey-900 mb-2",children:"Rename Passkey"}),(0,e.jsx)("input",{type:"text",value:d.name,onChange:j=>u({...d,name:j.target.value}),className:"w-full px-4 py-2.5 bg-grey-50 border border-grey-200 rounded-xl text-sm font-medium text-grey-900 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:bg-white mb-4",placeholder:"e.g. Work MacBook Pro"}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:()=>u(null),className:"flex-1 py-2 border border-grey-200 rounded-xl text-xs font-semibold text-grey-600 hover:bg-grey-100",children:"Cancel"}),(0,e.jsx)("button",{type:"button",onClick:h,className:"flex-1 py-2 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold rounded-xl shadow-sm",children:"Save"})]})]})}),P&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-grey-900/50 backdrop-blur-sm p-4 animate-fade-in",role:"dialog","aria-modal":"true",children:(0,e.jsxs)("div",{className:"bg-white rounded-3xl max-w-sm w-full p-6 shadow-2xl border border-grey-100 text-center",children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-full bg-error-50 text-error-500 flex items-center justify-center mx-auto mb-4",children:(0,e.jsx)(o,{name:"alertTriangle",size:24})}),(0,e.jsx)("h3",{className:"text-base font-bold text-grey-900 mb-1",children:"Delete Passkey"}),(0,e.jsx)("p",{className:"text-xs text-grey-500 mb-5",children:"Are you sure you want to delete this passkey credential from your account?"}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:()=>t(null),className:"flex-1 py-2 border border-grey-200 rounded-xl text-xs font-semibold text-grey-600 hover:bg-grey-100",children:"Cancel"}),(0,e.jsx)("button",{type:"button",onClick:C,className:"flex-1 py-2 bg-error-500 hover:bg-error-600 text-white text-xs font-bold rounded-xl shadow-sm",children:"Delete"})]})]})})]})},Se=()=>{const{t:s}=D(),f=G(),[b,a]=q(),{user:r,updateProfile:c,isLoading:i,logout:n,isAuthenticated:N,addVehicle:y,updateVehicle:p,deleteVehicle:w,setDefaultVehicle:k,removeFavoriteLocation:v,addPaymentMethod:d,updatePaymentMethod:u,removePaymentMethod:P}=J(),t=b.get("tab")||"personal",h=[{id:"personal",label:s("profile.tabs.personal","Personal & Billing"),icon:"user"},{id:"vehicles",label:s("profile.tabs.vehicles","Vehicles"),icon:"car"},{id:"payment",label:s("profile.tabs.payment","Payment Methods"),icon:"creditCard"},{id:"bookings",label:s("profile.tabs.bookings","Passes & Bookings"),icon:"ticket"},{id:"favorites",label:s("profile.tabs.favorites","Favorites"),icon:"heart"},{id:"security",label:s("profile.tabs.security","Security & Passkeys"),icon:"shieldCheck"}],[C,j]=(0,x.useState)(""),[_,g]=(0,x.useState)(""),m=(0,x.useCallback)(E=>{g(E),j(""),setTimeout(()=>g(""),4e3)},[]),l=(0,x.useCallback)(E=>
1{j(E),g(""),setTimeout(()=>j(""),5e3)},[]),[S,I]=(0,x.useState)([]),[B,T]=(0,x.useState)(!1),M=(0,x.useCallback)(async()=>{if(!(!N||!r?.id)){T(!0);try{const E=await Z();E.ok?I(E.data):console.error(E.error)}catch(E){console.error("Failed to load bookings:",E)}finally{T(!1)}}},[N,r?.id]);(0,x.useEffect)(()=>{let E=!0;if(t==="bookings"&&N&&r?.id){M();const $=te(r.id,()=>{E&&M()});return()=>{E=!1,$()}}},[t,N,r?.id,M]),(0,x.useEffect)(()=>{!i&&!N&&f("/auth")},[i,N,f]);const[z,A]=(0,x.useState)(!1),R=(0,x.useCallback)(E=>{a({tab:E}),j(""),g("")},[a]),V=async()=>{A(!1),await n(),f("/")},L=()=>{let E=0;return r?.first_name&&(E+=25),r?.email&&(E+=25),r?.vehicles?.length&&(E+=25),r?.paymentMethods?.length&&(E+=25),E};return i?(0,e.jsxs)("div",{className:"text-center py-20 flex justify-center items-center gap-2 min-h-[50vh]",children:[(0,e.jsx)("span",{className:"w-2.5 h-2.5 bg-primary-500/40 rounded-full animate-pulse",style:{animationDelay:"0ms"}}),(0,e.jsx)("span",{className:"w-2.5 h-2.5 bg-primary-500/60 rounded-full animate-pulse",style:{animationDelay:"150ms"}}),(0,e.jsx)("span",{className:"w-2.5 h-2.5 bg-primary-500 rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}):r?(0,e.jsxs)("div",{"data-component":"profile.ProfilePage",className:"flex-1 w-full bg-white flex flex-col",children:[(0,e.jsxs)(re,{user:r,tabs:h,activeTab:t==="billing"?"personal":t,onTabChange:R,onLogout:()=>A(!0),progress:L(),error:C,success:_,children:[(t==="personal"||t==="billing")&&(0,e.jsx)(ae,{user:r,authLoading:i,onUpdateProfile:c,onSuccess:m,onError:l}),t==="vehicles"&&(0,e.jsx)(ne,{vehicles:r.vehicles||[],onAddVehicle:y,onUpdateVehicle:p,onDeleteVehicle:w,onSetDefaultVehicle:k,onSuccess:m,onError:l}),t==="payment"&&(0,e.jsx)(ce,{paymentMethods:r.paymentMethods||[],onAddPaymentMethod:d,onUpdatePaymentMethod:u,onRemovePaymentMethod:P,onSuccess:m,onError:l}),t==="bookings"&&(0,e.jsx)(xe,{bookings:S,loading:B,onRefreshBookings:M}),t==="favorites"&&(0,e.jsx)(pe,{favorites:r.favoriteLocations||[],loading:!1,onRemoveFavorite:async E=>{await v(E),m(s("profile.favorites.removed","Removed from favorite locations."))}}),t==="security"&&(0,e.jsx)(ue,{})]}),z&&(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-grey-900/50 backdrop-blur-sm p-4 animate-fade-in",role:"dialog","aria-modal":"true",children:(0,e.jsxs)("div",{className:"bg-white rounded-3xl max-w-sm w-full p-6 shadow-2xl border border-grey-100 text-center",children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-full bg-primary-50 text-primary-500 flex items-center justify-center mx-auto mb-4",children:(0,e.jsx)(o,{name:"logOut",size:24})}),(0,e.jsx)("h3",{className:"text-base font-bold text-grey-900 mb-1",children:s("profile.logOut","Log Out")}),(0,e.jsx)("p",{className:"text-xs text-grey-500 mb-6",children:s("profile.logOutConfirm","Are you sure you want to log out of your IRKEN account?")}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("button",{type:"button",onClick:()=>A(!1),className:"flex-1 py-2.5 border border-grey-200 rounded-xl text-xs font-semibold text-grey-600 hover:bg-grey-100",children:s("common.cancel","Cancel")}),(0,e.jsx)("button",{type:"button",onClick:V,className:"flex-1 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-xs font-bold rounded-xl shadow-sm",children:s("profile.logOut","Log Out")})]})]})})]}):null};export{Se as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.