1import{H as U,a as S,r as o,c as g,j as e,I as F,R as xe,o as ue,m as me,n as fe,Q as pe,C as he,d as ge,L as k,X as O,N as L,B as z,P as be,an as ve,K as Y,J as D,ao as je,u as $,ap as ye,a6 as Ne,p as _,aq as K,e as Q,q as we,ad as ke,b as Ce,W as _e,Z as Se,ah as Ae,a5 as Me,ar as ze}from"./index-36WAU1xY.js";import{A as Z,h as ee,a as te,b as se,c as ae,d as ne,e as oe,f as re,g as le}from"./alert-dialog-Bl3RGY-1.js";import{B as X}from"./building-2-DH757pnY.js";import{T as Pe}from"./truck-qrk98INK.js";import{B as Ie,A as ie}from"./AddressAutocomplete-B2W12Mnb.js";import{M as de}from"./map-pin-BfdB5Idu.js";import{S as V}from"./switch-Daihj4PE.js";import{c as G,h as H}from"./missions-DTO3s9Ux.js";import{W as De}from"./WhatsAppPhoneBanner-MJJ-ZIN9.js";import{P as q}from"./pencil-CbGbteU_.js";import{M as Te}from"./mail-xrcKjpsD.js";import{T as Ee}from"./tag-DWQ7ctHY.js";import{P as Re}from"./package-D64FcgzL.js";import{T as Fe}from"./triangle-alert-C3WvYRYO.js";import"./search-Cp64Uwfb.js";import"./locate-fixed-CvT84hHI.js";import"./smartphone-fVb4kBAY.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Le=[["path",{d:"M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8",key:"1w3rig"}],["path",{d:"M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1",key:"n2jgmb"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M7 8v3",key:"1qtyvj"}],["path",{d:"M12 8v3",key:"hwp4zt"}],["path",{d:"M17 8v3",key:"1i6e5u"}],["path",{d:"M7 4h.01",key:"1bh4kh"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M17 4h.01",key:"1upcoc"}]],We=U("Cake",Le);/** 7 * @license lucide-react v0.475.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Be=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],Oe=U("Languages",Be);/** 12 * @license lucide-react v0.475.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Ve=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],qe=U("LogOut",Ve);function Ue(){const{user:s,refreshUser:t}=S(),[r,c]=o.useState(""),[n,i]=o.useState(!1),[x,b]=o.useState(""),[a,f]=o.useState(null),[h,p]=o.useState(!1),[m,d]=o.useState(!1);o.useEffect(()=>{s!=null&&s.convention_code&&g.functions.invoke("getMyConvenzione",{}).then(v=>{const l=v.data;if((l==null?void 0:l.active)===!1){f(null),sessionStorage.removeItem("cachedConvention"),g.auth.updateMe({convention_code:"",convention_personal_code:""}).catch(()=>{}),t();return}l!=null&&l.personal_code&&(f(l),sessionStorage.setItem("cachedConvention",JSON.stringify(l)),(!s.convention_personal_code||s.convention_personal_code!==l.personal_code)&&g.auth.updateMe({convention_personal_code:l.personal_code}).catch(()=>{}))}).catch(()=>{})},[s==null?void 0:s.convention_code]);const j=async()=>{if(!r.trim())return;i(!0),b("");const l=(await g.functions.invoke("activateConvenzione",{convenzione_code:r.toUpperCase().trim()})).data;if(!l.success){b(l.error||"Codice convenzione non valido o non attivo"),i(!1);return}await g.auth.updateMe({convention_code:r.toUpperCase().trim(),convention_personal_code:l.personal_code}),f(l),sessionStorage.setItem("cachedConvention",JSON.stringify(l)),c(""),i(!1),t()},u=async()=>{i(!0),await g.auth.updateMe({convention_code:"",convention_personal_code:""}),f(null),sessionStorage.removeItem("cachedConvention"),i(!1),t()},N=()=>{const v=(a==null?void 0:a.personal_code)||(s==null?void 0:s.convention_personal_code)||"";v&&(navigator.clipboard.writeText(v),d(!0),setTimeout(()=>d(!1),2e3))};if(a){const v=a.personal_code||(s==null?void 0:s.convention_personal_code)||"",l=a.channel_discounts||{},w=l.ondemand_delivery||l.Delivery||l.delivery,C=l.ondemand_pickup||l["On demand (ritiro)"]||l.pickup||l.Takeaway||l.takeaway,A=(w==null?void 0:w.discount_value)??a.delivery_discount_value??a.discount_delivery??0,T=(w==null?void 0:w.discount_type)||a.delivery_discount_type||a.discount_type||"percentage",M=(C==null?void 0:C.discount_value)??a.takeaway_discount_value??a.discount_takeaway??0,E=(C==null?void 0:C.discount_type)||a.takeaway_discount_type||a.discount_type||"percentage",W=w?!0:a.val
16id_for_delivery!==!1&&A>0,B=C?!0:a.valid_for_takeaway!==!1&&M>0,I=a.brand_name||a.company_name||(s==null?void 0:s.convention_code)||"";return e.jsxs("div",{className:"relative overflow-hidden bg-card border-2 border-foreground/15 rounded-3xl",style:{boxShadow:"0 4px 12px rgba(0,0,0,0.08)"},children:[e.jsx("div",{className:"absolute top-0 left-0 w-full h-1.5 bg-green-500"}),e.jsxs("div",{className:"p-4 pt-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.logo_url?e.jsx("img",{src:a.logo_url,alt:I,className:"w-10 h-10 rounded-2xl object-contain bg-white flex-shrink-0 border border-foreground/10"}):e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-green-100 flex items-center justify-center flex-shrink-0",children:e.jsx(X,{className:"w-5 h-5 text-green-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[10px] font-body font-bold text-green-600 uppercase tracking-wider",children:"Convenzione attiva"}),e.jsx("p",{className:"text-sm font-body font-bold text-foreground leading-tight truncate",children:I})]}),e.jsx("div",{className:"w-7 h-7 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0",children:e.jsx(F,{className:"w-4 h-4 text-white",strokeWidth:3})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[W&&A>0&&e.jsxs("div",{className:"bg-secondary/50 border border-foreground
16/10 rounded-2xl p-3 text-center",children:[e.jsx(Pe,{className:"w-4 h-4 text-green-600 mx-auto mb-1.5"}),e.jsx("p",{className:"text-xl font-display text-green-700 leading-none",children:T==="percentage"?`${A}%`:`â¬${A}`}),e.jsx("p",{className:"text-[10px] font-body font-bold text-muted-foreground mt-1 uppercase",children:"Consegna"})]}),B&&M>0&&e.jsxs("div",{className:"bg-secondary/50 border border-foreground/10 rounded-2xl p-3 text-center",children:[e.jsx(xe,{className:"w-4 h-4 text-green-600 mx-auto mb-1.5"}),e.jsx("p",{className:"text-xl font-display text-green-700 leading-none",children:E==="percentage"?`${M}%`:`â¬${M}`}),e.jsx("p",{className:"text-[10px] font-body font-bold text-muted-foreground mt-1 uppercase",children:"Ritiro"})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>p(!h),className:"w-full flex items-center justify-center gap-2 py-3 mb-3 rounded-2xl bg-green-600 hover:bg-green-700 text-white text-xs font-body font-bold uppercase tracking-wide transition-colors active:scale-[0.98]",children:[e.jsx(ue,{className:"w-4 h-4"}),h?"Nascondi QR":"Mostra in cassa â¡",h?e.jsx(me,{className:"w-4 h-4"}):e.jsx(fe,{className:"w-4 h-4"})]}),h&&e.jsxs("div",{className:"bg-white rounded-2xl p-4 flex flex-col items-center gap-3 border border-foreground
16/10 mb-3",children:[e.jsx(pe,{value:v,size:160,level:"M"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-lg font-display tracking-widest text-primary",children:v}),e.jsx("button",{onClick:N,className:"p-1 rounded-full hover:bg-secondary transition-colors",children:m?e.jsx(he,{className:"w-4 h-4 text-green-600"}):e.jsx(ge,{className:"w-4 h-4 text-foreground/40"})})]}),e.jsx("p",{className:"text-[10px] font-body font-semibold text-muted-foreground uppercase text-center",children:"Il tuo codice personale â mostralo in cassa"})]})]}),a.valid_until&&e.jsxs("p",{className:"text-[10px] font-body font-semibold text-muted-foreground text-center mb-2",children:["Valida fino al ",new Date(a.valid_until).toLocaleDateString("it-IT",{day:"numeric",month:"long",year:"numeric"})]}),e.jsx("div",{className:"mt-5 pt-3 border-t border-foreground/10 flex justify-end",children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("button",{disabled:n,className:"flex items-center gap-1 py-1 px-2 text-[10px] font-body font-semibold text-muted-foreground/60 hover:text-destructive transition-colors disabled:opacity-50",children:[n?e.jsx(k,{className:"w-3 h-3 animate-spin"}):e.jsx(O,{className:"w-3 h-3"}),"Rimuovi convenzione"]})}),e.jsxs(te,{className:"rounded-3xl",children:[e.jsxs(se,{children:[e.jsx(ae,{className:"font-display text-lg uppercase",children:"Rimuovere la convenzione?"}),e.jsxs(ne,{className:"font-body text-sm",children:['Perderai gli sconti di "',I,'". Potrai riattivarla in seguito inserendo di nuovo il codice aziendale.']})]}),e.jsxs(oe,{children:[e.jsx(re,{className:"rounded-full font-body font-bold uppercase text-xs",children:"Annulla"}),e.jsx(le,{onClick:u,className:"bg-destructive hover:bg-destructive/90 rounded-full font-body font-bold uppercase text-xs",children:"Rimuovi"})]})]})]})})]})]})}return e.jsxs("div",{className:"bg-card border-2 border-foreground
16/15 rounded-3xl p-4",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"hsl(39,100%,93%)"},children:e.jsx(X,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-body font-bold text-foreground uppercase",children:"Convenzione aziendale"}),e.jsx("p",{className:"text-[10px] font-body font-semibold text-muted-foreground uppercase tracking-wide",children:"Inserisci il codice della tua azienda"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{placeholder:"Es: SPRING2024",value:r,onChange:v=>{c(v.target.value.toUpperCase()),b("")},className:"font-mono text-sm flex-1"}),e.jsx(z,{onClick:j,disabled:n||!r.trim(),size:"sm",className:"rounded-full font-body font-bold uppercase text-xs",children:n?e.jsx(k,{className:"w-4 h-4 animate-spin"}):"Attiva"})]}),x&&e.jsx("p",{className:"text-xs text-destructive mt-2 font-body",children:x})]})}const $e={Casa:ve,Ufficio:Ie};function Qe(){const{user:s,refreshUser:t}=S(),[r,c]=o.useState(!1),[n,i]=o.useState(""),[x,b]=o.useState(""),[a,f]=o.useState(null),[h,p]=o.useState(!1),m=(s==null?void 0:s.saved_addresses)||[],d=async u=>{const N=m.filter(v=>v.label!==u);await g.auth.updateMe({saved_addresses:N}),await t()},j=async()=>{if(!n.trim()||!x||!(a!=null&&a.lat))return;p(!0);const u={label:n.trim(),address:x,lat:a.lat,lng:a.lng},N=[...m.filter(l=>l.label!==u.label),u],v=s!=null&&s.address?{saved_addresses:N}:{saved_addresses:N,address:x};await g.auth.updateMe(v),await t(),p(!1),c(!1),i(""),b(""),f(null)};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:"Indirizzi salvati"}),!r&&e.jsxs(z,{variant:"ghost",size:"sm",onClick:()=>c(!0),className:"gap-1.5 text-xs text-primary",children:[e.jsx(be,{className:"w-3.5 h-3.5"}
16)," Aggiungi"]})]}),m.length===0&&!r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Nessun indirizzo salvato"}),m.map(u=>{const N=$e[u.label]||de;return e.jsxs("div",{className:"flex items-center gap-3 border border-border rounded-xl p-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(N,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:u.label}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:u.address})]}),e.jsx("button",{onClick:()=>d(u.label),className:"p-1.5 hover:bg-destructive/10 rounded-lg flex-shrink-0",children:e.jsx(Y,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]},u.label)}),r&&e.jsxs("div",{className:"border border-primary/20 bg-primary/5 rounded-xl p-4 space-y-3",children:[e.jsx(L,{placeholder:"Nome (es. Casa, Ufficio, Palestra)",value:n,onChange:u=>i(u.target.value),className:"text-sm"}),e.jsx(ie,{value:x,onChange:u=>b(u),onSelect:u=>{u?(f({lat:u.lat,lng:u.lng}),b(u.address)):f(null)}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{onClick:j,disabled:!n.trim()||!(a!=null&&a.lat)||h,size:"sm",className:"gap-1.5",children:h?e.jsx(k,{className:"w-3.5 h-3.5 animate-spin"}):"Salva indirizzo"}),e.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{c(!1),i(""),b(""),f(null)},children:"Annulla"})]})]})]})}function Ge(){const{user:s,refreshUser:t}=S(),{toast:r}=D(),[c,n]=o.useState(!!(s!=null&&s.consent_whatsapp)),[i,x]=o.useState((s==null?void 0:s.phone)||""),[b,a]=o.useState(!1),[f,h]=o.use
16State(!1);o.useEffect(()=>{g.functions.invoke("manageConsents",{action:"get"}).then(d=>{var j;(j=d.data)!=null&&j.success&&(d.data.whatsapp_opt_in!==void 0&&n(!!d.data.whatsapp_opt_in),d.data.phone&&!(s!=null&&s.phone)&&x(d.data.phone))}).catch(()=>{})},[]);const p=async(d,j)=>{var v;if(h(!0),!((v=(await g.functions.invoke("manageConsents",{action:"update",whatsapp_opt_in:d,...j?{phone:j}:{}}).catch(()=>({data:{success:!1}}))).data)!=null&&v.success)){r({title:"Errore",description:"Impossibile aggiornare il consenso, riprova.",variant:"destructive"}),h(!1);return}const N={consent_whatsapp:d,consent_whatsapp_at:new Date().toISOString()};j&&j!==(s==null?void 0:s.phone)&&(N.phone=j),await g.auth.updateMe(N),await t(),n(d),a(!1),h(!1),r({title:d?"WhatsApp attivato â
":"WhatsApp disattivato"})},m=d=>{if(d&&!i.trim()){a(!0);return}p(d,d?i.trim():void 0)};return e.jsxs("div",{className:"px-4 py-3.5 border-b border-foreground/10",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-body font-bold text-foreground flex items-center gap-1.5",children:[e.jsx(je,{className:"w-3.5 h-3.5 text-green-600"})," WhatsApp"]}),e.jsx("p",{className:"text-[10px] font-body text-muted-foreground",children:"Aggiornamenti ordini e offerte esclusive"})]}),f?e.jsx(k,{className:"w-4 h-4 animate-spin text-muted-foreground"}):e.jsx(V,{checked:c,onCheckedChange:m})]}),b&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx("p",{className:"text-[10px] font-body font-semibold text-muted-foreground",children:"Inserisci il tuo numero per ricevere i messaggi WhatsApp:"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{type:"tel",value:i,onChange:d=>x(d.target.value),placeholder:"+39 333 1234567",className:"text-sm h-9 flex-1",autoFocus:!0}),e.jsx(z,{size:"sm",className:"rounded-full font-body font-bold uppercase text-xs h-9",disabled:!i.trim()||f,onClick:()=>p(!0,i.trim()),children:"Attiva"})]})]})]})}function He(){const s=$(),{user:t,refreshUser:r}=S(),{toast:c}=D(),{openPanel:n}=ye(),[i,x]=o.useState(!1),[b,a]=o.useState(!1),f=async p=>{x(!0),await g.auth.updateMe({consent_profiling:p,consent_profiling_at:new Date().toISOString()}),await r(),x(!1),c({title:p?"Profilazione attivata":"Profilazione disattivata"})},h=async p=>{a(!0),await g.auth.updateMe({consent_marketing:p,consent_marketing_at:new Date().toISOString()}),g.functions.invoke("manageConsents",{action:"update",marketing_consent:p}).catch(()=>{}),await r(),a(!1),c({title:p?"Marketing attivato":"Marketing disattivato"})};return e.jsxs("div",{className:"bg-card border-2 border-foreground
16/15 rounded-3xl overflow-hidden",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[e.jsxs("div",{className:"px-4 py-3 border-b border-foreground/10 flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"hsl(39,100%,93%)"},children:e.jsx(Ne,{className:"w-4 h-4 text-foreground"})}),e.jsx("p",{className:"text-[10px] font-body font-bold text-muted-foreground uppercase tracking-wide",children:"Privacy e consensi"})]}),e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3 border-b border-foreground/10",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-body font-bold text-foreground",children:"Profilazione"}),e.jsx("p",{className:"text-[10px] font-body text-muted-foreground",children:"Offerte e suggerimenti personalizzati"})]}),i?e.jsx(k,{className:"w-4 h-4 animate-spin text-muted-foreground"}):e.jsx(V,{checked:!!(t!=null&&t.consent_profiling),onCheckedChange:f})]}),e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3 border-b border-foreground
16/10",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-body font-bold text-foreground",children:"Comunicazioni marketing"}),e.jsx("p",{className:"text-[10px] font-body text-muted-foreground",children:"Email su promozioni, novità ed eventi"})]}),b?e.jsx(k,{className:"w-4 h-4 animate-spin text-muted-foreground"}):e.jsx(V,{checked:!!(t!=null&&t.consent_marketing),onCheckedChange:h})]}),e.jsx(Ge,{}),e.jsxs("button",{onClick:()=>s("/RegolamentoFedelta"),className:"w-full px-4 py-3 flex items-center gap-3 border-b border-foreground/10 hover:bg-muted/30 transition-colors",children:[e.jsx("span",{className:"text-xs font-body font-bold text-foreground flex-1 text-left",children:"Regolamento Fedeltà "}),e.jsx(_,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsxs("button",{onClick:()=>s("/Privacy"),className:"w-full px-4 py-3 flex items-center gap-3 border-b border-foreground/10 hover:bg-muted/30 transition-colors",children:[e.jsx(K,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-body font-bold text-foreground flex-1 text-left",children:"Informativa Privacy"}),e.jsx(_,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsxs("button",{onClick:n,className:"w-full px-4 py-3 flex items-center gap-3 border-b border-foreground
16/10 hover:bg-muted/30 transition-colors",children:[e.jsx(K,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-body font-bold text-foreground flex-1 text-left",children:"Preferenze cookie"}),e.jsx(_,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsxs("button",{onClick:()=>s("/CookiePolicy"),className:"w-full px-4 py-3 flex items-center gap-3 border-b border-foreground/10 hover:bg-muted/30 transition-colors",children:[e.jsx("span",{className:"text-xs font-body font-bold text-foreground flex-1 text-left",children:"Cookie Policy"}),e.jsx(_,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsxs("button",{onClick:()=>s("/CondizioniWallet"),className:"w-full px-4 py-3 flex items-center gap-3 hover:bg-muted/30 transition-colors",children:[e.jsx("span",{className:"text-xs font-body font-bold text-foreground flex-1 text-left",children:"Condizioni d'uso del Wallet"}),e.jsx(_,{className:"w-4 h-4 text-muted-foreground"})]})]})}function Je(){const{user:s,refreshUser:t}=S(),{toast:r}=D(),c=Q(),[n,i]=o.useState((s==null?void 0:s.birth_date)||""),[x,b]=o.useState(!1),[a,f]=o.useState(!1),h=async()=>{if(n){if(b(!0),await g.auth.updateMe({birth_date:n}),s!=null&&s.full_name&&(s!=null&&s.phone)&&n){const p=await G("complete_profile",{birth_date:n});H(p,r,c,s==null?void 0:s.email)}f(!0),b(!1),await(t==null?void 0:t())}};return e.jsxs("div",{className:"bg-card border-2 border-foreground
16/15 rounded-3xl p-4 space-y-3",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"hsl(39,100%,93%)"},children:e.jsx(We,{className:"w-4 h-4 text-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-body font-bold text-muted-foreground uppercase tracking-wide",children:"Data di nascita"}),e.jsx("p",{className:"text-xs font-body font-semibold text-foreground",children:"ð Aggiungi la tua data di nascita: ti aspetta un regalo per il compleanno!"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"date",value:n,onChange:p=>{i(p.target.value),f(!1)},max:new Date().toISOString().split("T")[0],className:"flex-1 text-xs font-body font-bold text-foreground bg-background border border-border rounded-lg px-2.5 py-2 outline-none focus:ring-1 focus:ring-primary"}),e.jsxs("button",{onClick:h,disabled:x||!n||n===(s==null?void 0:s.birth_date)||a,className:"h-9 px-4 rounded-full bg-primary text-primary-foreground text-xs font-body font-bold uppercase flex items-center gap-1.5 disabled:opacity-50 active:scale-[0.97] transition-all",children:[x?e.jsx(k,{className:"w-3.5 h-3.5 animate-spin"}):a||n===(s==null?void 0:s.birth_date)?e.jsx(F,{className:"w-3.5 h-3.5"}):null,a||n===(s==null?void 0:s.birth_date)?"Salvata":"Salva"]})]})]})}function Ke(){const{lang:s,setLang:t,t:r}=we(),c=async n=>{await t(n),g.auth.updateMe({language:n}).catch(()=>{})};return e.jsxs("div",{className:"bg-card border-2 border-foreground
16/15 rounded-3xl p-4 space-y-3",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"hsl(39,100%,93%)"},children:e.jsx(Oe,{className:"w-4 h-4 text-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-body font-bold text-foreground uppercase",children:r("profile.language.title")}),e.jsx("p",{className:"text-[10px] font-body font-semibold text-muted-foreground",children:r("profile.language.subtitle")})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ke.map(({code:n,flag:i,name:x})=>e.jsxs("button",{onClick:()=>c(n),className:`px-3 py-1.5 rounded-full text-xs font-body font-bold border-2 transition-colors ${s===n?"bg-primary text-primary-foreground border-primary":"bg-background text-foreground border-foreground/15 hover:border-primary"}`,children:[i," ",x]},n))})]})}function Xe(){const{user:s,refreshUser:t}=S(),{toast:r}=D(),c=Q(),[n,i]=o.useState(!1),[x,b]=o.useState((s==null?void 0:s.address)||""),[a,f]=o.useState(!1),h=(s==null?void 0:s.saved_addresses)||[],p=async m=>{if(m){if(f(!0),await g.auth.updateMe({address:m}),s!=null&&s.full_name&&(s!=null&&s.phone)&&(s!=null&&s.birth_date)){const d=await G("complete_profile",{address:m});H(d,r,c,s==null?void 0:s.email)}await(t==null?void 0:t()),f(!1),i(!1),r({title:"Indirizzo aggiornato â
"})}};return e.jsxs("div",{className:"bg-card border-2 border-foreground
16/15 rounded-3xl p-4 space-y-3",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"hsl(39,100%,93%)"},children:e.jsx(de,{className:"w-4 h-4 text-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[10px] font-body font-bold text-muted-foreground uppercase tracking-wide",children:"Indirizzo"}),e.jsx("p",{className:"text-xs font-body font-bold text-foreground break-words",children:(s==null?void 0:s.address)||"Non impostato"})]}),!n&&e.jsx("button",{onClick:()=>i(!0),className:"w-7 h-7 rounded-full flex items-center justify-center hover:bg-muted transition-colors flex-shrink-0",children:e.jsx(q,{className:"w-3.5 h-3.5 text-muted-foreground"})})]}),n&&e.jsxs("div",{className:"space-y-3",children:[h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(m=>e.jsx("button",{onClick:()=>p(m.address),className:"text-[11px] font-body font-bold text-primary bg-primary/10 px-3 py-1.5 rounded-full",children:m.label},m.label))}),e.jsx(ie,{value:x,onChange:m=>b(m),onSelect:m=>b((m==null?void 0:m.address)||"")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{size:"sm",onClick:()=>p(x),disabled:!x||a,className:"gap-1.5",children:a?e.jsx(k,{className:"w-3.5 h-3.5 animate-spin"}):"Salva indirizzo"}),e.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{i(!1),b((s==null?void 0:s.address)||"")},children:"Annulla"})]})]})]})}function Ye(){const s=$(),{user:t}=S(),{data:r}=Ce({queryKey:["walletBalance",t==null?void 0:t.email],queryFn:async()=>(await g.functions.invoke("getWalletBalance",{})).data.balance||0,enabled:!!(t!=null&&t.email),staleTime:300*1e3});return e.jsxs("button",{onClick:()=>s("/Wallet"),className:"w-full bg-card border-2 border-foreground
16/15 rounded-3xl px-4 py-4 flex items-center gap-3 transition-all hover:border-primary active:scale-[0.98]",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-green-100 flex items-center justify-center flex-shrink-0",children:e.jsx(_e,{className:"w-5 h-5 text-green-700"})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:"text-sm font-body font-bold text-foreground uppercase",children:"ð³ Il mio Wallet"}),e.jsx("p",{className:"text-[10px] font-body font-semibold text-muted-foreground uppercase tracking-wide",children:r!==void 0?`Saldo â¬${Number(r).toFixed(2)} · -5% sul totale`:"Ricarica e paga con -5%"})]}),e.jsx(_,{className:"w-5 h-5 text-muted-foreground flex-shrink-0"})]})}function ht(){var J;const s=$(),{user:t,logout:r,refreshUser:c}=S(),{toast:n}=D(),i=Q(),[x,b]=o.useState(!1),[a,f]=o.useState(""),[h,p]=o.useState(!1),[m,d]=o.useState(!1),[j,u]=o.useState((t==null?void 0:t.phone)||""),[N,v]=o.useState(!1),[l,w]=o.useState(!1),[C,A]=o.useState((t==null?void 0:t.display_name)||(t==null?void 0:t.full_name)||""),[T,M]=o.useState(!1),E=async()=>{const y=C.trim();if(!y)return;const P=(t==null?void 0:t.display_name)||(t==null?void 0:t.full_name)||"";if(y===P){w(!1);return}M(!0);try{await g.auth.updateMe({display_name:y}),await(c==null?void 0:c()),g.functions.invoke("syncUserToCrm",{email:t==null?void 0:t.email,name:y,userId:t==null?void 0:t.id,phone:t==null?void 0:t.phone}).catch(R=>console.error("Error syncing name to CRM:",R)),n({title:"Nome aggiornato",description:"Usato nelle prossime comande e sincronizzato nel CRM."})}catch{n({title:"Errore",description:"Impossibile aggiornare il nome.",variant:"destructive"})}M(!1),w(!1)},W=async()=>{if(v(!0),await g.auth.updateMe({phone:j.trim()}),t!=null&&t.full_name&&(t!=null&&t.birth_date)&&j.trim()){const y=await G("complete_profile",{birth_date:t.birth_date});H(y,n,i,t==null?void 0:t.email)}await(c==null?void 0:c()),v(!1),d(!1)},B=async()=>{b(!0),await g.auth.updateMe({account_deletion_requested:!0}),r()},I=[{icon:Te,label:"Email",value:t==null?void 0:t.email},{icon:Se,label:"Telefono",value:(t==null?void 0:t.phone)||"Non impostato"},{icon:Ee,label:"Codice sconto",value:(t==null?void 0:t.promo_code)||"Nessuno"}];return e.jsxs("div",{className:"min-h-screen bg-background pb-24",children:[e.jsx("div",{className:"bg-card border-b border-foreground
16/10",children:e.jsx("div",{className:"max-w-md mx-auto px-4 py-4",children:e.jsx("p",{className:"font-display text-xl text-foreground uppercase",children:"Il tuo profilo ð¤"})})}),e.jsxs("div",{className:"max-w-md mx-auto px-4 pt-5 space-y-4",children:[e.jsx(De,{}),e.jsxs("div",{className:"relative overflow-hidden bg-card border-2 border-foreground/15 rounded-3xl p-5",style:{boxShadow:"0 4px 12px rgba(0,0,0,0.08)"},children:[e.jsx("div",{className:"absolute top-0 right-0 w-24 h-24 rounded-full -translate-y-10 translate-x-10",style:{backgroundColor:"#FFC244",opacity:.15}}),e.jsx("div",{className:"absolute bottom-0 left-0 w-16 h-16 rounded-full translate-y-8 -translate-x-8",style:{backgroundColor:"#FFC244",opacity:.1}}),e.jsxs("div",{className:"relative flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"#FFC244"},children:e.jsx(Ae,{className:"w-6 h-6 text-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:C,onChange:y=>A(y.target.value),placeholder:"Il tuo nome",className:"flex-1 min-w-0 text-base font-display uppercase text-foreground bg-background border border-border rounded-lg px-2.5 py-1.5 outline-none focus:ring-1 focus:ring-primary",autoFocus:!0,onKeyDown:y=>{y.key==="Enter"&&E()}}),e.jsx("button",{onClick:E,disabled:T,className:"w-7 h-7 rounded-full bg-green-100 flex items-center justify-center flex-shrink-0",children:T?e.jsx(k,{className:"w-3.5 h-3.5 animate-spin text-green-600"}):e.jsx(F,{className:"w-3.5 h-3.5 text-green-600"})}),e.jsx("button",{onClick:()=>{w(!1),A((t==null?void 0:t.display_name)||(t==null?void 0:t.full_name)||"")},className:"w-7 h-7 rounded-full bg-red-100 flex items-center justify-center flex-shrink-0",children:e.jsx(O,{className:"w-3.5 h-3.5 text-red-500"})})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-display text-2xl text-foreground uppercase truncate",children:(t==null?void 0:t.display_name)||(t==null?void 0:t.full_name)||"Amico"}),e.jsx("button",{onClick:()=>w(!0),className:"w-7 h-7 rounded-full flex items-center justify-center hover:bg-foreground
16/5 transition-colors flex-shrink-0",children:e.jsx(q,{className:"w-3.5 h-3.5 text-muted-foreground"})})]}),e.jsx("p",{className:"text-xs font-body font-semibold text-muted-foreground truncate",children:t==null?void 0:t.email}),(t==null?void 0:t.is_tester)&&!((J=t==null?void 0:t.role)!=null&&J.includes("admin"))&&e.jsxs("span",{className:"inline-flex items-center gap-1 mt-1 text-[10px] font-bold text-orange-600 bg-orange-100 px-2 py-0.5 rounded-full w-fit",children:[e.jsx(Me,{className:"w-3 h-3"})," Modalità Tester"]})]})]})]}),e.jsx("div",{className:"bg-card border-2 border-foreground/15 rounded-3xl overflow-hidden divide-y divide-foreground/10",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:I.map(({icon:y,label:P,value:R})=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"hsl(39,100%,93%)"},children:e.jsx(y,{className:"w-4 h-4 text-foreground"})}),P==="Telefono"&&m?e.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[e.jsx("input",{value:j,onChange:ce=>u(ce.target.value),placeholder:"+39 333...",className:"flex-1 text-xs font-body font-bold text-foreground bg-background border border-border rounded-lg px-2.5 py-1.5 outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{onClick:W,disabled:N,className:"w-7 h-7 rounded-full bg-green-100 flex items-center justify-center",children:N?e.jsx(k,{className:"w-3.5 h-3.5 animate-spin text-green-600"}):e.jsx(F,{className:"w-3.5 h-3.5 text-green-600"})}),e.jsx("button",{onClick:()=>{d(!1),u((t==null?void 0:t.phone)||"")},className:"w-7 h-7 rounded-full bg-red-100 flex items-center justify-center",children:e.jsx(O,{className:"w-3.5 h-3.5 text-red-500"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[10px] font-body font-bold text-muted-foreground uppercase tracking-wide",children:P}),e.jsx("p",{className:"text-xs font-body font-bold text-foreground truncate",children:R})]}),P==="Telefono"&&e.jsx("button",{onClick:()=>d(!0),className:"w-7 h-7 rounded-full flex items-center justify-center hover:bg-muted transition-colors",children:e.jsx(q,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]},P))}),e.jsx(Xe,{}),e.jsx(Ke,{}),e.jsx(Je,{}
16),e.jsx("div",{className:"bg-card border-2 border-foreground/15 rounded-3xl p-4",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:e.jsx(Qe,{})}),e.jsx(He,{}),e.jsx(Ue,{}),e.jsx(Ye,{}),e.jsxs("button",{onClick:()=>s("/Orders"),className:"w-full bg-card border-2 border-foreground/15 rounded-3xl px-4 py-4 flex items-center gap-3 transition-all hover:border-primary active:scale-[0.98]",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"hsl(39,100%,93%)"},children:e.jsx(Re,{className:"w-5 h-5 text-foreground"})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:"text-sm font-body font-bold text-foreground uppercase",children:"I miei ordini"}),e.jsx("p",{className:"text-[10px] font-body font-semibold text-muted-foreground uppercase tracking-wide",children:"Storico e tracking ð¦"})]}),e.jsx(_,{className:"w-5 h-5 text-muted-foreground flex-shrink-0"})]}),e.jsxs("button",{onClick:r,className:"w-full bg-card border-2 border-foreground
16/15 rounded-3xl px-4 py-3.5 flex items-center gap-3 transition-all hover:border-primary active:scale-[0.98]",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"hsl(39,100%,93%)"},children:e.jsx(qe,{className:"w-4 h-4 text-foreground"})}),e.jsx("p",{className:"text-xs font-body font-bold text-foreground uppercase",children:"Esci dall'account"})]}),e.jsxs("div",{className:"bg-card border-2 border-foreground/15 rounded-3xl p-4 space-y-3",style:{boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[e.jsxs("button",{onClick:()=>p(!h),className:"w-full flex items-center gap-3 text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"hsl(39,100%,93%)"},children:e.jsx(ze,{className:"w-5 h-5 text-foreground"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-body font-bold text-foreground uppercase",children:"Gestisci account"}),e.jsx("p",{className:"text-[10px] font-body font-semibold text-muted-foreground uppercase tracking-wide",children:"Eliminazione account"})]}),e.jsx(_,{className:`w-5 h-5 text-muted-foreground flex-shrink-0 transition-transform ${h?"rotate-90":""}`})]}
16),h&&e.jsxs("div",{className:"border-t border-foreground/10 pt-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{className:"w-4 h-4 text-destructive flex-shrink-0"}),e.jsx("p",{className:"text-xs font-body font-bold text-destructive uppercase",children:"Danger area"})]}),e.jsxs(Z,{onOpenChange:y=>{y||f("")},children:[e.jsx(ee,{asChild:!0,children:e.jsxs("button",{className:"w-full bg-card border-2 border-destructive/30 rounded-2xl px-4 py-3.5 flex items-center gap-3 transition-all hover:border-destructive active:scale-[0.98]",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Y,{className:"w-4 h-4 text-destructive"})}),e.jsx("p",{className:"text-xs font-body font-bold text-destructive uppercase",children:"Elimina account"})]})}),e.jsxs(te,{className:"rounded-3xl",children:[e.jsxs(se,{children:[e.jsx(ae,{className:"font-display text-lg uppercase",children:"Vuoi davvero eliminare l'account?"}),e.jsx(ne,{asChild:!0,children:e.jsxs("div",{className:"font-body text-sm space-y-3",children:[e.jsx("p",{children:"Attenzione, è irreversibile. Perderai ordini, punti e saldo wallet."}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Scrivi ",e.jsx("span",{className:"font-bold text-destructive",children:"ELIMINA"})," per confermare."]}),e.jsx(L,{value:a,onChange:y=>f(y.target.value),placeholder:"Scrivi ELIMINA",className:"text-sm",autoComplete:"off"})]})})]}),e.jsxs(oe,{children:[e.jsx(re,{className:"rounded-full font-body font-bold uppercase text-xs",children:"Annulla"}),e.jsx(le,{onClick:B,className:"bg-destructive hover:bg-destructive/90 rounded-full font-body font-bold uppercase text-xs",disabled:x||a!=="ELIMINA",children:x?e.jsx(k,{className:"w-4 h-4 animate-spin"}):"Elimina definitivamente"})]})]})]})]})]}),e.jsx("div",{className:"pb-4 text-center",children:e.jsxs("p",{className:"text-[10px] font-body font-semibold text-muted-foreground uppercase tracking-wide",children:["© ",new Date().getFullYear()," Sa Pizzedda. Tutti i diritti riservati."]})})]})]})}export{ht 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.