1import{R as Wt,a as es,U as ts,c as ss,r as a,V as jt,N as xt,W as v,X as Mt,Y as as,Z as Ft,_ as $t,$ as rs,j as e,L as Pt,E as os,a0 as Lt,G as me,O as Vt,a1 as ns,T as ls,a2 as Zt,a3 as Bt,a4 as is,a5 as ds,a6 as cs,a7 as ms,a8 as us}from"./index-DpeRiJon.js";import{Y as St,i as ht}from"./cpf-ChL2IU4c.js";import{t as Nt,f as ps,s as qt,l as fs,v as gs,a as At,S as Kt,M as bt,i as Xt,b as xs,g as zt,C as De,A as hs,c as Qe,d as Qt,e as vt,P as bs,h as ys,j as js,k as Ns,w as Ot}from"./name-BDKC7yc1.js";import{S as vs,C as ws}from"./CheckoutFooter-BNQKoJ6a.js";/** 2 * @license lucide-react v0.462.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 Cs=Wt("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** 7 * @license lucide-react v0.462.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 Ps=Wt("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),kt="6Lc0slYqAAAAADTZmrzZAu1_3jsaXPuhdhgUiQr3";let nt=null;function Ss(t){return nt||(nt=new Promise((r,s)=>{if(window.grecaptcha){r();return}const o=document.createElement("script");o.src=`https://www.google.com/recaptcha/api.js?render=${encodeURIComponent(t)}`,o.async=!0,o.defer=!0,o.onload=()=>r(),o.onerror=()=>{nt=null,s(new Error("Falha ao carregar o reCAPTCHA."))},document.head.appendChild(o)}),nt)}async function Ut(t){await Ss(kt);const r=window.grecaptcha;return r?new Promise((s,o)=>{r.ready(()=>{r.execute(kt,{action:t}).then(s).catch(()=>o(new Error("Falha ao validar o reCAPTCHA.")))})}):null}const As="/assets/instituto-BdvEdD29.png",Es="/assets/tamar-DuWPBeV-.png",wt={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_API_BASE_URL:"https://api-k8s.bcwprd.betocarrero.com.br",VITE_CLEARSALE_APP_KEY:"ortcsmkqe24ywtypjqg6",VITE_LEGACY_SITE_URL:"https://www.interno.betocarrero.com.br",VITE_RECAPTCHA_SITE_KEY:"6Lc0slYqAAAAADTZmrzZAu1_3jsaXPuhdhgUiQr3"},lt=t=>t.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2});function Yt(t){if(!t||typeof t!="string")return null;const r=t.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/);if(r){const[,w,m,p]=r;let M=parseInt(p);M<100&&(M+=2e3);const A=parseInt(w),l=parseInt(m);if(l<1||l>12||A<1||A>31)return null;const d=new Date(Date.UTC(M,l-1,A));return d.getUTCDate()!==A||d.getUTCMonth()!==l-1?null:d.toLocaleDateString("pt-BR",{timeZone:"UTC"})}const s=t.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(s){const w=new Date(Date.UTC(+s[1],+s[2]-1,+s[3]));return w.getUTCDate()!==+s[3]||w.getUTCMonth()!==+s[2]-1?null:w.toLocaleDateString("pt-BR",{timeZone:"UTC"})}const o=new Date(t);return isNaN(o.getTime())?null:o.toLocaleDateString("pt-BR")}const Gt=t=>t.replace(/\D/g,"").slice(0,11).replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2"),Xe="bcw_order_uid",Hs=()=>{var Ze,fe,Et,It,Tt,Rt,_t;const t=es(),{login:r,userName:s,logout:o}=ts(),{visitDate:w}=ss(),[m,p]=a.useState(()=>typeof window<"u"&&localStorage.getItem("accessToken")?"dados":"login"),[M,A]=a.useState(!1),[l,d]=a.useState(null),[R,$]=a.useState(!1),[c,C]=a.useState(null),[y,I]=a.useState(!1),[f,Y]=a.useState(null),[j,P]=a.useState(null),[L,N]=a.useState(!1),[B,h]=a.useState(!1),[T,W]=a.useState(null),[Z,G]=a.useState(null),[z,xe]=a.useState(null),[je,Q]=a.useState(null),[oe,ee]=a.useState(!1),te=a.useRef(!1),_=a.useRef(null),[ue,Ae]=a.useState(""),[he,dt]=a.useState(()=>{if(typeof window<"u"){const b=localStorage.getItem("loginMode");if(b==="phone"||b==="email")return b}return"phone"}),[Ee,Re]=a.useState(["","","","","",""]),[re,_e]=a.useState(""),[Me,Fe]=a.useState(""),[pe,$e]=a.useState(""),[Je,Le]=a.useState(""),[Ie,Ve]=a.useState(!1),[et,Be]=a.useState(""),[tt,Ne]=a.useState(!1),[ne,st]=a.useState(null),[qe,ve]=a.useState(0),[ct,mt]=a.useState("1"),[ze,Oe]=a.useState(""),[at,ke]=a.useState(""),[Ue,Ye]=a.useState(""),[S,E]=a.useState(""),[k,ae]=a.useState(""),[D,Ge]=a.useState(""),[He,le]=a.useState(""),[Te,we]=a.useState(""),F=(Ze=l==null?void 0:l.cart)==null?void 0:Ze.summary,Ce=(F==null?void 0:F.subtotal)??0,rt=(F==null?void 0:F.discountTotal)??
11(F==null?void 0:F.couponDiscount)??(F==null?void 0:F.discount)??0,We=((fe=F==null?void 0:F.coupon)==null?void 0:fe.code)??(F==null?void 0:F.couponCode)??null,Pe=((F==null?void 0:F.total)??Ce)+qe,ut=s||re||"",pt=async()=>{var i;const b=((i=f==null?void 0:f.order)==null?void 0:i.uid)||typeof window<"u"&&localStorage.getItem(Xe)||void 0;if(b){ee(!0);try{await ys(b),v.success("Voucher enviado para o seu e-mail!")}catch(n){v.error((n==null?void 0:n.message)||"Erro ao enviar voucher")}finally{ee(!1)}}};a.useEffect(()=>{var i;const b=(i=f==null?void 0:f.order)==null?void 0:i.uid;if(b)try{localStorage.setItem(Xe,b)}catch{}},[f]),a.useEffect(()=>{if(m!=="dados"&&m!=="pagamento"){st(null);return}if(!(()=>{try{return localStorage.getItem("accessToken")}catch{return null}})()||l)return;const i=new AbortController;return $(!0),(async()=>{var n,g,q,se,X,J,U,de;try{await jt()}catch(x){if(typeof(x==null?void 0:x.message)=="string"&&/\(401\)/.test(x.message)){try{localStorage.removeItem("accessToken")}catch{}try{o()}catch{}d(null),p("login"),$(!1);return}}try{let x=await xt(i.signal);if(!(x!=null&&x.donations)||x.donations.length===0||!((g=(n=x.donations[0])==null?void 0:n.options)!=null&&g.length))try{const u=await xt(i.signal);(X=(se=(q=u==null?void 0:u.donations)==null?void 0:q[0])==null?void 0:se.options)!=null&&X.length&&(x={...x,donations:u.donations})}catch{}d(x);const O=x.account;if(O){O.firstName&&_e(O.firstName),O.lastName&&Fe(O.lastName),O.email&&$e(O.email),O.cpf&&Be(O.cpf);const u=O.mobile||O.phone;u&&Le(Nt(u)),typeof O.foreigner=="boolean"&&Ve(!!O.foreigner);const ce=O,be=ce.address??ce.addresses,ge=Array.isArray(be)?be[0]:be,Se=(Ke,...Dt)=>{if(!Ke)return"";for(const Jt of Dt){const ot=Ke[Jt];if(typeof ot=="string"&&ot)return ot;if(typeof ot=="number")return String(ot)}return""};if(ge){Oe(Se(ge,"zipCode","cep","postalCode","postal_code")),ke(Se(ge,"stateCode","state","uf","estado")),Ye(Se(ge,"district","neighborhood","bairro")),E(Se(ge,"cityName","city","cidade","municipality")),ae(Se(ge,"street","rua","logradouro")),Ge(Se(ge,"number","numero","num","streetNumber")),le(Se(ge,"complement","complemento","complementNumber"));const Ke=ge.cityId;we(Ke!=null?String(Ke):"")}}const K=(de=(U=(J=x.donations)==null?void 0:J[0])==null?void 0:U.options)==null?void 0:de.find(u=>u.selected);K?(C(K.productCode),ve(K.amount)):(C(null),ve(0))}catch(x){(x==null?void 0:x.name)!=="AbortError"&&v.error((x==null?void 0:x.message)||"Erro ao carregar checkout")}finally{$(!1)}})(),()=>i.abort()},[m,l]),a.useEffect(()=>{if(m!=="pagamento"&&m!=="wallet"||Z)return;const b=new AbortController;return ps(b.signal).then(i=>G(i)).catch(i=>{(i==null?void 0:i.name)!=="AbortError"&&console.warn("payments/config falhou",i)}),()=>b.abort()},[m,Z]),a.useEffect(()=>{var b;if(!te.current&&l)try{const i=Mt();as({items:(i==null?void 0:i.items)??[],summary:(b=l.cart)==null?void 0:b.summary}),te.current=!0}catch{}},[l]);const ie=a.useRef(!1);a.useEffect(()=>{var q,se,X;if(m!=="pagamento"||!l||f||ie.current||(Pe??0)>0)return;const i=(((q=l==null?void 0:l.paymentMethods)==null?void 0:q.methods)??[]).find(J=>J.slug==="pix"),n=(i==null?void 0:i.id)??((se=l==null?void 0:l.cardInstallments)==null?void 0:se.formaPagamentoId),g=(X=l==null?void 0:l.paymentMethods)==null?void 0:X.countryId;typeof n!="number"||typeof g!="number"||(ie.current=!0,st("pix"),(async()=>{var J,U,de,x,O;try{let K;try{K=await Ut("checkout")??void 0}catch{K=void 0}const u=await Ft({mobile:!1,countryId:g,payments:[{formaPagamentoId:n,valor:0}],recaptchaToken:K});Y(u),d(null),$t(),P(((J=u==null?void 0:u.payment)==null?void 0:J.pix)??null),N(!1),h(!!((de=(U=u==null?void 0:u.payment)==null?void 0:U.pix)!=null&&de.qrCode&&((O=(x=u==null?void 0:u.payment)==null?void 0:x.pix)!=null&&O.qrCodeUrl))),p("aguardando")}catch(K){ie.current=!1,v.error((K==null?void 0:K.message)||"Erro ao finalizar pedido grátis")}})())},[m,l,Pe,f]),a.useEffect(()=>{var n,g,q,se;const b=(n=f==null?void 0:f.order)==null?void 0:n.id;if(!b)return;const i=String(b);if(_.current!==i)try{const X=Mt(),J=parseFloat(((g=f==null?void 0:f.order)==null?void 0:g.valorTotal)??"0")||0,U=(q=l==null?void 0:l.cart)==null?void 0:q.summary;rs({transactionId:i,value:J,currency:(U==null?void 0:U.currency)??"BRL",items:(X==null?void 0:X.items)??[],coupon:((se=U==null?void 0:U.coupon)==null?void 0:se.code)??(U==null?void 0:U.couponCode)??null}),_.current=i}catch{}},[f,l,qe]),a.useEffect(()=>{var J;if(m!=="qrcode"&&m!=="wallet"&&m!=="aguardando")return;const b=(J=f==null?void 0:f.order)==null?void 0:J.uid;if(!b)return;let i=!1,n=null,g=null,q=!1,se=!1;const X=async()=>{var U,de,x,O;if(!i){g=new AbortController;try{const K=await ds(b,g.signal);if(i)return;const u=K,ce=(u==null?void 0:u.pix)??((U=u==null?void 0:u.payment)==null?void 0:U.pix);ce!=null&&ce.qrCode&&(ce!=null&&ce.qrCodeUrl)&&(P({qrCode:ce.qrCode,qrCodeUrl:ce.qrCodeUrl}),h(!0));const be=(u==null?void 0:u.statusPayment)??(u==null?void 0:u.statusPagamento)??((de=u==null?void 0:u.order)==null?void 0:de.statusPayment)??((x=u==null?void 0:u.order)==null?void 0:x.statusPagamento);if(W(be??null),ne==="card"&&be===2){se||(se=!0,v.info("Pagamento em análise! Aguardeâ¦",{duration:6e3})),h(!0),i||(n=setTimeout(X,3e3));return}if(be===2||be===3){q||(q=!0,v.success("Pagamento confirmado!")),N(!0),h(!0),p("passaportes");return}if((((O=u==null?void 0:u.order)==null?void 0:O.status)??(u==null?void 0:u.status))===0){h(!0);try{localStorage.removeItem(Xe)}catch{}v.error("Pedido cancelado."),t("/minha-conta?tab=pedidos");return}if(be===0){h(!0),p("negado");try{localStorage.removeItem(Xe)}catch{}return}if((u==null?void 0:u.paid)===!0||(u==null?void 0:u.status)==="paid"||(u==null?void 0:u.status)==="approved"||(u==null?void 0:u.redirectToConfirmation)===!0){q||(q=!0,v.success("Pagamento confirmado!")),N(!0),h(!0),p("passaportes");return}}catch(K){if((K==null?void 0:K.name)==="AbortError")return}i||(n=setTimeout(X,3e3))}};return X(),()=>{i=!0,n&&clearTimeout(n),g==null||g.abort()}},[m,f,ne,t]);
11const ft=async()=>{if(!Qe(re)||!Qe(Me)){v.error("Verifique o nome e o sobrenome â não use o e-mail nesses campos.");return}if(pe.trim()&&!Xt(pe)){v.error("Informe um e-mail válido.");return}A(!0);try{const i=js(he==="phone"?ue:Je),n={firstName:re,lastName:Me,email:pe,cpf:et.replace(/\D/g,""),mobile:i,foreigner:Ie};l!=null&&l.requiresAddress&&(n.address={street:k||void 0,number:D||void 0,district:Ue||void 0,zipCode:ze||void 0,complement:He||void 0,cityId:Te?Number(Te):void 0}),await cs(n),r(re);try{const g=await xt();d(g)}catch{}p("pagamento")}catch(b){v.error((b==null?void 0:b.message)||"Erro ao salvar dados")}finally{A(!1)}};return e.jsxs("div",{className:"min-h-screen flex flex-col bg-muted/40",children:[e.jsx("header",{className:"bg-header text-header-foreground sticky top-0 z-50",children:e.jsxs("div",{className:"container flex items-center justify-between h-16 md:h-20",children:[e.jsx(Pt,{to:"/",className:"flex-shrink-0 relative z-10","aria-label":"InÃcio",children:e.jsx("img",{src:os,alt:"Beto Carrero World",className:"h-[72px] md:h-[85px] w-auto -mb-8 md:-mb-8 drop-shadow-md"})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(vs,{className:"w-4 h-4"}),e.jsx("span",{children:"Ambiente 100% seguro"})]})]})}),e.jsx("main",{className:"flex-1",children:e.jsxs("div",{className:"container max-w-[640px] md:max-w-[800px] py-6 md:py-10",children:[m==="login"&&e.jsx(Is,{contact:ue,setContact:Ae,onContinue:async b=>{const i=ue.trim();if(!i){v.error(b==="email"?"Informe seu e-mail":"Informe seu celular");return}try{await qt({channel:b,destination:i})}catch(n){if(!(n.status===429&&(n.errorCode==="otp_send_cooldown"||n.errorCode==="otp_send_rate_limit"))){v.error((n==null?void 0:n.message)||`Erro: ${n.errorCode||"desconhecido"}`);return}}dt(b),p("otp")},onGoogle:async b=>{try{const i=await fs(b);if(i!=null&&i.accessToken)try{localStorage.setItem("accessToken",i.accessToken)}catch{}try{await jt()}catch{}try{const n=await Lt();n!=null&&n.firstName&&_e(n.firstName),n!=null&&n.lastName&&Fe(n.lastName),n!=null&&n.email&&($e(n.email),Ae(n.email)),n!=null&&n.cpf&&Be(n.cpf);const g=(n==null?void 0:n.mobile)||(n==null?void 0:n.phone);g&&Le(Nt(g)),typeof(n==null?void 0:n.foreigner)=="boolean"&&Ve(!!n.foreigner),r((n==null?void 0:n.firstName)||"")}catch{r("")}dt("email");try{localStorage.setItem("loginMode","email")}catch{}p("dados")}catch(i){v.error((i==null?void 0:i.message)||"Falha ao entrar com Google")}}}),m==="otp"&&e.jsx(Ts,{otp:Ee,setOtp:Re,onBack:()=>p("login"),onContinue:async()=>{const b=Ee.join("");if(b.length!==Ee.length)return;const i=await gs({channel:he,destination:ue.trim(),code:b}),n=(i==null?void 0:i.accessToken)||(i==null?void 0:i.access_token)||(i==null?void 0:i.token);if(n)try{localStorage.setItem("accessToken",n),localStorage.setItem("loginMode",he)}catch{}try{const g=await Lt();g!=null&&g.firstName&&_e(g.firstName),g!=null&&g.lastName&&Fe(g.lastName),g!=null&&g.email&&$e(g.email),g!=null&&g.cpf&&Be(g.cpf);const q=(g==null?void 0:g.mobile)||(g==null?void 0:g.phone);q&&Le(Nt(q)),typeof(g==null?void 0:g.foreigner)=="boolean"&&Ve(!!g.foreigner)}catch{}try{await jt()}catch{}r(re),p("dados")},onResend:async()=>{try{await qt({channel:he,destination:ue.trim()}),v.success("Código reenviado")}catch(b){v.error((b==null?void 0:b.message)||`Erro: ${b.errorCode||"desconhecido"}`)}},destination:ue,channel:he}),m==="dados"&&e.jsx(Rs,{firstName:re,setFirstName:_e,lastName:Me,setLastName:Fe,email:pe,setEmail:$e,foreigner:Ie,setForeigner:Ve,docNumber:et,setDocNumber:Be,aceito:tt,setAceito:Ne,contact:ue,loginMode:he,phone:Je,setPhone:Le,savingData:M,loadingCheckout:R,requiresAddress:!!(l!=null&&l.requiresAddress),billCep:ze,setBillCep:Oe,billState:at,setBillState:ke,billBairro:Ue,setBillBairro:Ye,billCity:S,setBillCity:E,billRua:k,setBillRua:ae,billNumero:D,setBillNumero:Ge,billComplemento:He,setBillComplemento:le,billCityId:Te,setBillCityId:we,onContinue:ft}),m==="pagamento"&&(Pe??0)<=0&&e.jsxs("div",{className:"bg-card rounded-xl border border-border p-10 flex flex-col items-center justify-center gap-3",children:[e.jsx(me,{className:"w-6 h-6 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Finalizando seu pedido..."})]}),m==="pagamento"&&(Pe??0)>0&&e.jsx(Ms,{method:ne,setMethod:st,donation:qe,setDonation:ve,parcelas:ct,setParcelas:mt,total:Pe,subtotal:Ce,discountTotal:rt,appliedCouponCode:We,checkoutData:l,setCheckoutData:d,paymentsConfig:Z,loadingCheckout:R,selectedDonationCode:c,donationLoading:y,billCep:ze,setBillCep:Oe,billState:at,setBillState:ke,billBairro:Ue,setBillBairro:Ye,billCity:S,setBillCity:E,billRua:k,setBillRua:ae,billNumero:D,setBillNumero:Ge,billComplemento:He,setBillComplemento:le,billCityId:Te,setBillCityId:we,onToggleDonation:async b=>{var n,g;if(y)return;if(!w){v.error("Selecione uma data de visita antes de adicionar a doação.");return}const i=(g=(n=l==null?void 0:l.donations)==null?void 0:n[0])==null?void 0:g.donationParentId;if(typeof i!="number"){v.error("Dados da doação incompletos.");return}I(!0);
11try{if(c===b.productCode)await Vt(b.productCode,w,i),C(null),ve(0);else{if(c)try{await Vt(c,w,i)}catch{}await ns(b.productCode,1,w,i),C(b.productCode),ve(b.amount)}}catch(q){v.error((q==null?void 0:q.message)||"Erro ao atualizar doação")}finally{I(!1)}},onPay:async b=>{var g,q,se,X,J,U,de;const i=(g=l==null?void 0:l.paymentMethods)==null?void 0:g.countryId;if(typeof i!="number"){v.error("Dados de checkout incompletos.");return}let n;try{n=await Ut("checkout")??void 0}catch{v.error("Não foi possÃvel validar a segurança. Recarregue a página e tente novamente.");return}try{const x=await Ft({mobile:!1,countryId:i,payments:[b],recaptchaToken:n});if((x==null?void 0:x.status)==="payment_failed"||(x==null?void 0:x.nextStep)==="retry_pay"){const O=((q=x==null?void 0:x.error)==null?void 0:q.message)||"Pagamento não autorizado. Escolha outra forma de pagamento.";v.error(O),p("pagamento");return}Y(x),d(null),$t(),P(((se=x==null?void 0:x.payment)==null?void 0:se.pix)??null),N(!1),h(!!((J=(X=x==null?void 0:x.payment)==null?void 0:X.pix)!=null&&J.qrCode&&((de=(U=x==null?void 0:x.payment)==null?void 0:U.pix)!=null&&de.qrCodeUrl))),ne==="pix"?p("qrcode"):ne==="mpago"||ne==="gpay"||ne==="apay"?(xe(ne),p("wallet")):p("aguardando")}catch(x){v.error((x==null?void 0:x.message)||"Erro ao finalizar pagamento")}}}),m==="qrcode"&&e.jsx(Fs,{userName:ut,email:pe,orderId:(Et=f==null?void 0:f.order)==null?void 0:Et.id,pix:j,paid:L,onContinue:()=>p("passaportes")}),m==="aguardando"&&e.jsx($s,{userName:ut,email:pe,orderId:(It=f==null?void 0:f.order)==null?void 0:It.id,method:ne,paymentStatus:T}),m==="negado"&&e.jsx(Ls,{orderId:(Tt=f==null?void 0:f.order)==null?void 0:Tt.id,onRetry:()=>p("pagamento")}),m==="wallet"&&z&&((Rt=f==null?void 0:f.order)==null?void 0:Rt.uid)&&e.jsx(Vs,{provider:z,orderUid:f.order.uid,orderId:f.order.id,payment:f.payment,paymentsConfig:Z,paid:L,onPaid:()=>{N(!0),p("passaportes")},onCancel:()=>p("pagamento")}),m==="passaportes"&&e.jsx(Bs,{email:pe,orderUid:((_t=f==null?void 0:f.order)==null?void 0:_t.uid)||typeof window<"u"&&localStorage.getItem(Xe)||void 0,orderData:je,setOrderData:Q,onFinish:()=>{try{localStorage.removeItem(Xe)}catch{}t("/")},sendingVoucher:oe,onSendVoucher:pt})]})}),e.jsx(ws,{showPayments:m==="login"||m==="otp"||m==="dados"})]})},Ct=(wt==null?void 0:wt.VITE_GOOGLE_OAUTH_CLIENT_ID)||"295924407992-30384afuv5s4gbf2fj91jfod4q16ccfm.apps.googleusercontent.com",Is=({contact:t,setContact:r,onContinue:s,onGoogle:o})=>{const[w,m]=a.useState("phone"),p=a.useRef(null),[M,A]=a.useState(!1),l=a.useRef(o);return a.useEffect(()=>{l.current=o},[o]),a.useEffect(()=>{if(!Ct)return;let d=!1;return At("https://accounts.google.com/gsi/client").then(()=>{var R,$;d||!(($=(R=window.google)==null?void 0:R.accounts)!=null&&$.id)||!p.current||(window.google.accounts.id.initialize({client_id:Ct,callback:c=>{c!=null&&c.credential&&l.current(c.credential)}}),window.google.accounts.id.renderButton(p.current,{theme:"outline",size:"large",shape:"pill",text:"continue_with",locale:"pt-BR",width:p.current.clientWidth||320}),A(!0))}).catch(()=>{}),()=>{d=!0}},[]),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"md:bg-card rounded-xl md:p-7 md:border md:border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx(it,{n:1,active:!0}),e.jsx("h2",{className:"font-extrabold text-lg text-foreground",children:"Faça login ou crie uma conta"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 p-1 bg-muted rounded-full mb-4",children:[e.jsxs("button",{type:"button",onClick:()=>{m("phone"),r("")},className:`flex items-center justify-center gap-2 py-2.5 rounded-full text-sm font-bold transition-colors ${w==="phone"?"bg-card text-foreground shadow-sm":"text-muted-foreground"}`,children:[e.jsx(Kt,{className:"w-4 h-4"})," Celular"]}),e.jsxs("button",{type:"button",onClick:()=>{m("email"),r("")},className:`flex items-center justify-center gap-2 py-2.5 rounded-full text-sm font-bold transition-colors ${w==="email"?"bg-card text-foreground shadow-sm":"text-muted-foreground"}`,children:[e.jsx(bt,{className:"w-4 h-4"})," E-mail"]})]}),e.jsx(Os,{mode:w,value:t,onChange:r,onEnter:()=>s(w)}),(()=>{const d=w==="email"?Xt(t):xs(t);return e.jsx("button",{onClick:()=>s(w),disabled:!d,className:"w-full bg-accent text-accent-foreground py-3.5 rounded-full font-extrabold text-base hover:bg-accent/90 transition-colors mb-3 disabled:opacity-60 disabled:cursor-not-allowed",children:"Continuar"})})(),Ct?e.jsxs("div",{className:"min-h-[44px]",children:[!M&&e.jsxs("div",{className:"w-full flex items-center justify-center gap-3 bg-card border border-border py-3.5 rounded-full font-bold text-foreground",children:[e.jsx("img",{src:zt,alt:"",className:"w-5 h-5"}),"Carregando Googleâ¦"]}),e.jsx("div",{ref:p,className:"flex justify-center"})]}):e.jsxs("button",{type:"button",disabled:!0,title:"Defina VITE_GOOGLE_OAUTH_CLIENT_ID para habilitar",className:"w-full flex items-center justify-center gap-3 bg-card border border-border py-3.5 rounded-full font-bold text-foreground opacity-60 cursor-not-allowed",children:[e.jsx("img",{src:zt,alt:"",className:"w-5 h-5"}),"Continuar com o Google"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-4 leading-relaxed",children:["Ao continuar, você concorda com as"," ",e.jsx("a",{className:"font-bold underline",children:"Condições de Uso e privacidade"})," do Beto Carrero World."]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-sm font-bold text-foreground mb-2",children:"Usamos
11seus dados de forma 100% segura para:"}),e.jsx("ul",{className:"text-sm text-foreground space-y-1.5",children:["Identificar seu perfil","Notificar sobre o andamento da compra","Gerenciar seu histórico de compras","Acelerar o preenchimento de suas informações"].map(d=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4 text-accent"})," ",d]},d))})]})]}),e.jsx(ye,{n:2,title:"Confirme seus dados pessoais"}),e.jsx(ye,{n:3,title:"Pagamento"}),e.jsx(ye,{n:4,title:"Cadastre os passaportes"})]})},Ts=({otp:t,setOtp:r,onBack:s,onContinue:o,onResend:w,destination:m,channel:p})=>{const[M,A]=a.useState(!1),[l,d]=a.useState(!1),[R,$]=a.useState(!1),c=async()=>{if(!M){A(!0);try{await o(),$(!1)}catch(I){(I==null?void 0:I.status)===400&&(I==null?void 0:I.errorCode)==="otp_invalid"?$(!0):v.error((I==null?void 0:I.message)||`Erro: ${(I==null?void 0:I.errorCode)||"desconhecido"}`)}finally{A(!1)}}},C=async()=>{if(!l){d(!0);try{await w()}finally{d(!1)}}},y=p==="email"?bt:Kt;return e.jsxs("div",{className:"fixed inset-0 z-[60] bg-card overflow-y-auto p-5 md:static md:inset-auto md:z-auto md:overflow-visible md:rounded-xl md:border md:border-border md:p-7",children:[e.jsx("button",{onClick:s,className:"text-foreground mb-4","aria-label":"Voltar",children:e.jsx(hs,{className:"w-5 h-5"})}),e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(y,{className:"w-6 h-6 text-primary"})})}),e.jsx("h2",{className:"text-center font-extrabold text-lg text-foreground mb-2",children:"Insira o código de 6 dÃgitos"}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Enviado por ",p==="email"?"e-mail para:":"WhatsApp para o número:"]}),e.jsx("p",{className:"text-center text-sm text-primary font-bold mb-6 break-all",children:m}),e.jsx(zs,{otp:t,setOtp:r,onComplete:c,invalid:R,onClearInvalid:()=>$(!1)}),R&&e.jsx("p",{className:"text-center text-sm text-destructive font-semibold mb-3",children:"Código inválido. Verifique e tente novamente."}),M&&e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx(me,{className:"w-5 h-5 animate-spin text-primary"})}),e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Não recebeu o código?"}),e.jsx("button",{type:"button",onClick:C,disabled:l,className:"block mx-auto text-sm text-primary font-bold mb-2 disabled:opacity-60",children:l?"Reenviandoâ¦":"Reenviar código"})]})},Rs=({firstName:t,setFirstName:r,lastName:s,setLastName:o,email:w,setEmail:m,foreigner:p,setForeigner:M,docNumber:A,setDocNumber:l,aceito:d,setAceito:R,onContinue:$,contact:c,loginMode:C,phone:y,setPhone:I,savingData:f,loadingCheckout:Y,requiresAddress:j,billCep:P,setBillCep:L,billState:N,setBillState:B,billBairro:h,setBillBairro:T,billCity:W,setBillCity:Z,billRua:G,setBillRua:z,billNumero:xe,setBillNumero:je,billComplemento:Q,setBillComplemento:oe,billCityId:ee,setBillCityId:te})=>e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{n:1,title:"Faça login ou crie uma conta",done:!0}),e.jsxs("div",{className:"md:bg-card rounded-xl md:p-7 md:border md:border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx(it,{n:2,active:!0}),e.jsx("h2",{className:"font-extrabold text-lg text-foreground",children:"Confirme seus dados pessoais"})]}),Y?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-10",children:[e.jsx(me,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Carregando seus dadosâ¦"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:C==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(V,{label:"Celular",children:c?e.jsxs("div",{className:"flex items-center justify-between bg-accent/10 border border-accent rounded-lg px-3 py-2.5",children:[e.jsx("span",{className:"text-sm font-semibold",children:c}),e.jsx(De,{className:"w-4 h-4 text-accent"})]}):e.jsx("div",{className:"bcw-phone-wrapper",children:e.jsx(St,{defaultCountry:"br",hideDropdown:!0,forceDialCode:!0,value:y,onChange:_=>I(_),inputProps:{placeholder:"11 99999-0000"}})})}),e.jsx(V,{label:"E-mail",children:e.jsx(H,{type:"email",name:"email",autoComplete:"email",value:w,onChange:_=>m(_.target.value)})})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{label:"E-mail",children:c?e.jsxs("div",{className:"flex items-center justify-between bg-accent/10 border border-accent rounded-lg px-3 py-2.5",children:[e.jsx("span",{className:"text-sm font-semibold",children:c}),e.jsx(De,{className:"w-4 h-4 text-accent"})]}):e.jsx(H,{type:"email",name:"email",autoComplete:"email",value:w,onChange:_=>m(_.target.value)})}),e.jsx(V,{label:"Celular",children:e.jsx("div",{className:"bcw-phone-wrapper",children:e.jsx(St,{defaultCountry:"br",hideDropdown:!0,forceDialCode:!0,value:y,onChange:_=>I(_),inputProps:{placeholder:"11 99999-0000"}})})})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(V,{label:"Primeiro nome",children:[e.jsx(H,{name:"given-name",autoComplete:"given-name",value:t,onChange:_=>r(_.target.value),className:t.trim()&&!Qe(t)?"border-destructive focus-visible:ring-destructive/30":void 0}),t.trim()&&!Qe(t)&&e.jsx("p",{className:"text-[11px] text-destructive mt-1",children:"Digite o nome, não o e-mail."})]}),e.jsxs(V,{label:"Ãltimo nome",children:[e.jsx(H,{name:"family-name",autoComplete:"family-name",value:s,onChange:_=>o(_.target.value),className:s.trim()&&!Qe(s)?"border-destructive focus-visible:ring-destructive/30":void 0}),s.trim()&&!Qe(s)&&e.jsx("p",{className:"text-[11px] text-destructive mt-1",children:"Digite o sobrenome, não o e-mail."})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(V,{label:"Tipo de documento",children:e.jsxs("select",{value:p?"Passaporte":"CPF",onChange:_=>{M(_.target.value==="Passaporte"),l("")},className:"w-full border border-border rounded-lg px-3 py-2.5 text-sm bg-card focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{children:"CPF"}),e.jsx("option",{children:"Passaporte"})]})}),e.jsxs(V,{label:p?"Passaporte":"CPF",children:[e.jsx(H,{value:A,onChange:_=>{if(p)l(_.target.value);else{const Ae=_.target.value.replace(/\D/g,"").slice(0,11).replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2");l(Ae)}},placeholder:p?"Documento":"000.000.000-00",inputMode:p?"text":"numeric",maxLength:p?void 0:14,className:!p&&A.replace(/\D/g,"").length===11&&!ht(A)?"border-destructive focus-visible:ring-destructive/30":void 0}),!p&&A.replace(/\D/g,"").length===11&&!ht(A)&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:"CPF inválido"})]})]}),j&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"font-bold text-foreground pt-2 mb-3",children:"Endereço"}),e.jsx(Qt,{zipCode:P,setZipCode:L,stateCode:N,setStateCode:B,district:h,setDistrict:T,cityId:ee||"",setCityId:te,cityName:W,setCityName:Z,setStreet:z,setComplement:oe,children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(V,{label:"Rua",children:e.jsx(H,{placeholder:"Rua",value:G,onChange:_=>z(_.target.value)})}),e.jsx(V,{label:"Número",children:e.jsx(H,{placeholder:"00000",value:xe,onChange:_=>je(_.target.value)})}),e.jsx(V,{label:"Complemento",children:e.jsx(H,{placeholder:"complemento",value:Q,onChange:_=>oe(_.target.value)})})]})})]}
11),e.jsxs("label",{className:"flex items-start gap-3 mb-5 cursor-pointer",children:[e.jsx("button",{type:"button",onClick:()=>R(!d),className:`mt-0.5 w-5 h-5 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${d?"border-accent bg-accent":"border-border"}`,children:d&&e.jsx(De,{className:"w-3 h-3 text-accent-foreground"})}),e.jsxs("span",{className:"text-xs text-foreground leading-relaxed",children:["Aceito as ",e.jsx("a",{href:"https://www2.betocarrero.com.br/embed?url=https%3A%2F%2Fwww.betocarrero.com.br%2Fcondicoes-gerais&title=Condi%C3%A7%C3%B5es%20gerais",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline font-bold",children:"condições gerais"})," do contrato de serviços e produtos comercializados pela loja virtual Beto Carrero World. Regulamento interno ",e.jsx("a",{href:"https://info.betocarrero.com.br/regulamento_interno/Regulamento_interno.pdf",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline font-bold",children:"clique aqui"}),"."]})]}),e.jsxs("button",{onClick:$,disabled:!d||f,className:"w-full bg-accent text-accent-foreground py-3.5 rounded-full font-extrabold hover:bg-accent/90 transition-colors disabled:bg-muted disabled:text-muted-foreground disabled:opacity-100 flex items-center justify-center gap-2",children:[f&&e.jsx(me,{className:"w-4 h-4 animate-spin"}),"Ir para pagamento"]})]})]}),e.jsx(ye,{n:3,title:"Pagamento"}),e.jsx(ye,{n:4,title:"Cadastre os passaportes"})]}),Ht={credit_card:"card",pix:"pix",mercado_pago:"mpago",google_pay:"gpay",apple_pay:"apay"},_s=t=>{const r=t.replace(/\D/g,"");return/^4/.test(r)?"visa":/^(34|37)/.test(r)?"amex":/^(5[1-5]|2[2-7])/.test(r)?"mastercard":/^(4011|4312|4389|4514|4573|5041|5066|5067|509|6277|6362|6363|650|6516|6550)/.test(r)?"elo":/^(36|38|30[0-5])/.test(r)?"diners":/^(60|64|65)/.test(r)?"discover":/^35/.test(r)?"jcb":/^(606282|3841)/.test(r)?"hipercard":""},Ms=({method:t,setMethod:r,donation:s,parcelas:o,setParcelas:w,total:m,subtotal:p,discountTotal:M,appliedCouponCode:A,onPay:l,checkoutData:d,setCheckoutData:R,paymentsConfig:$,loadingCheckout:c,selectedDonationCode:C,donationLoading:y,onToggleDonation:I,billCep:f,setBillCep:Y,billState:j,setBillState:P,billBairro:L,setBillBairro:N,billCity:B,setBillCity:h,billRua:T,setBillRua:W,billNumero:Z,setBillNumero:G,billComplemento:z,setBillComplemento:xe,billCityId:je,setBillCityId:Q})=>{var qe,ve,ct,mt,ze,Oe,at,ke,Ue,Ye;const oe=(qe=d==null?void 0:d.donations)==null?void 0:qe[0],ee=(oe==null?void 0:oe.options)??[],te=a.useRef(!1);a.useEffect(()=>{c||d&&(ee.length>0||te.current||(te.current=!0,(async()=>{var S,E,k;try{const ae=await xt();(k=(E=(S=ae==null?void 0:ae.donations)==null?void 0:S[0])==null?void 0:E.options)!=null&&k.length&&R&&R(D=>({...D||ae,donations:ae.donations}))}catch{}})()))},[d,ee.length,c,R]);const _=new Set((((ve=d==null?void 0:d.paymentMethods)==null?void 0:ve.methods)??[]).map(S=>S.slug)),ue=S=>_.has(S),Ae=(S,E)=>{const k=Ht[S];return!k||!ue(S)?null:e.jsx(qs,{active:t===k,onClick:()=>r(k),children:E},S)},he=((ct=d==null?void 0:d.cardInstallments)==null?void 0:ct.minInstallmentAmount)??0,dt=((ze=(mt=d==null?void 0:d.cart)==null?void 0:mt.summary)==null?void 0:ze.total)??0,Ee=he>0?dt>=he:!0,Re=[Ae("pix",e.jsx("img",{src:ms,alt:"Pix",className:"h-5"})),Ee?Ae("credit_card",e.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap text-xs sm:text-sm font-bold",children:[e.jsx(Cs,{className:"w-5 h-5 text-foreground flex-shrink-0"}),"Cartão de Crédito"]})):null].filter(Boolean);a.useEffect(()=>{t==="card"&&!Ee&&r(null)},[t,Ee,r]),typeof window<"u"&&(/Android|iPhone|iPad|iPod|Mobile|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||((Oe=window.matchMedia)==null||Oe.call(window,"(max-width: 767px)").matches));const re=[],_e=t==="pix"?"Pagar com PIX":t==="card"?"Pagar com cartão de crédito":t==="gpay"?"Pagar com Google Pay":t==="apay"?"Pagar com Apple Pay":t==="mpago"?"Pagar com Mercado Pago":"Escolha uma forma de pagamento",[Me,Fe]=a.useState(""),[pe,$e]=a.useState(""),[Je,Le]=a.useState(""),[Ie,Ve]=a.useState(""),[et,Be]=a.useState(""),[tt,Ne]=a.useState(!1),ne=S=>{const E=Object.entries(Ht).find(([,k])=>k===S);return(E==null?void 0:E[0])??null},st=async()=>{var Ge,He;if(!t||tt)return;const S=ne(t),E=(((Ge=d==null?void 0:d.paymentMethods)==null?void 0:Ge.methods)??[]).find(le=>le.slug===S),k=(E==null?void 0:E.id)??((He=d==null?void 0:d.cardInstallments)==null?void 0:He.formaPagamentoId);if(typeof k!="number"){v.error("Forma de pagamento inválida.");return}const ae=Math.round((m??0)*100),D={formaPagamentoId:k,valor:ae};if(t==="card"){const le=Me.replace(/\D/g,"");if(le.length<13){v.error("Número do cartão inválido.");return}if(!Ie.trim()){v.error("Informe o nome do titular do cartão.");return}const Te=et.replace(/\D/g,"");if(Te.length<11){v.error("CPF do titular inválido.");return}const we=Je.replace(/\D/g,"");if(we.length<3){v.error("CVV inválido.");return}const F=pe.replace(/\D/g,"");
11if(F.length<4){v.error("Validade inválida (use MM/YY).");return}const Ce=parseInt(F.slice(0,2),10),rt=F.slice(2),We=rt.length===2?2e3+parseInt(rt,10):parseInt(rt,10);if(!Ce||Ce<1||Ce>12||!We){v.error("Validade inválida (use MM/YY).");return}const yt=new Date,Pe=yt.getFullYear(),ut=yt.getMonth()+1;if(We<Pe||We===Pe&&Ce<ut){v.error("Cartão vencido. Verifique a validade.");return}if(we.length!==3&&we.length!==4){v.error("CVV deve ter 3 ou 4 dÃgitos.");return}const pt=$==null?void 0:$.mundipaggPublicKey;if(!pt){v.error("Configuração de pagamento indisponÃvel. Tente novamente.");return}Ne(!0);let ie;try{const fe=await fetch(`https://api.mundipagg.com/core/v1/tokens?appId=${encodeURIComponent(pt)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"card",card:{number:le,holder_name:Ie.trim(),exp_month:Ce,exp_year:We,cvv:we}})});if(!fe.ok)throw new Error(`Falha ao tokenizar cartão (${fe.status})`);ie=await fe.json()}catch(fe){Ne(!1),v.error((fe==null?void 0:fe.message)||"Erro ao tokenizar cartão.");return}const ft=ie==null?void 0:ie.id,Ze=(ie==null?void 0:ie.card)??{};if(!ft){Ne(!1),v.error("Token do cartão inválido.");return}D.token=ft,D.nome=Ie.trim(),D.cpf=Te,D.parcelas=Number(o)||1,D.bandeira=Ze.brand??_s(le),D.primeiros_seis_digitos=Ze.first_six_digits??le.slice(0,6),D.ultimos_quatro_digitos=Ze.last_four_digits??le.slice(-4);try{await l(D)}finally{Ne(!1)}return}Ne(!0);try{await l(D)}finally{Ne(!1)}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{n:1,title:"Faça login ou crie uma conta",done:!0}),e.jsx(ye,{n:2,title:"Confirme seus dados pessoais",done:!0}),e.jsxs("div",{className:"md:bg-card rounded-xl md:p-7 md:border md:border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx(it,{n:3,active:!0}),e.jsx("h2",{className:"font-extrabold text-lg text-foreground",children:"Pagamento"})]}),((ke=(at=d==null?void 0:d.cart)==null?void 0:at.items)==null?void 0:ke.length)===0?e.jsxs(e.Fragment,{children:[e.jsxs(Pt,{to:"/passaportes",className:"flex items-start gap-3 rounded-xl border border-yellow-200 bg-yellow-50 text-yellow-900 p-4 md:p-5 mb-3 hover:bg-yellow-100 transition-colors",children:[e.jsx(Ps,{className:"w-6 h-6 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-extrabold text-base md:text-lg leading-tight",children:"Seu carrinho está vazio!"}),e.jsx("p",{className:"font-semibold text-sm md:text-base mt-1 underline underline-offset-2",children:"Comprar passaportes"})]})]}),e.jsx(Pt,{to:"/minha-conta?tab=pedidos",className:"inline-block text-sm underline underline-offset-2 mb-5 hover:text-yellow-700",children:"Ver histórico de pedidos"})]}):null,(((Ye=(Ue=d==null?void 0:d.cart)==null?void 0:Ue.items)==null?void 0:Ye.length)??0)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"font-bold text-foreground mb-3",children:"Resumo do pedido"}),e.jsxs("div",{className:"space-y-3 mb-6",children:[e.jsx(gt,{label:"Subtotal:",value:e.jsxs("span",{className:"font-bold",children:["R$ ",lt(p)]})}),(A||M>0)&&e.jsx(gt,{label:e.jsxs("span",{className:"text-sm text-foreground font-semibold",children:["Desconto",A?` (${A})`:"",":"]}),value:e.jsxs("span",{className:"text-accent font-bold",children:["â R$ ",lt(M)]})}),s>0&&e.jsx(gt,{label:"Doação:",value:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-bold",children:["R$ ",lt(s)]}),e.jsx("button",{onClick:()=>{const S=ee.find(E=>E.productCode===C);S&&I(S)},disabled:y,className:"text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50","aria-label":"Remover doação",title:"Remover doação",children:y?e.jsx(me,{className:"w-4 h-4 animate-spin"}):e.jsx(ls,{className:"w-4 h-4"})})]})}),e.jsx(gt,{label:e.jsx("span",{className:"font-bold",children:"Total:"}),value:e.jsxs("span",{className:"font-extrabold text-foreground",children:["R$ ",lt(m)]}),noBorder:!0})]}),e.jsxs("div",{className:"bg-muted -mx-5 md:-mx-7 px-5 md:px-7 py-5 mb-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("p",{className:"text-sm text-foreground flex-1",children:"Que tal ajudar uma boa causa? O valor arrecadado será divi
11dido entre as duas instituições:"}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0 items-center",children:[e.jsx("img",{src:As,alt:"Instituto Beto Carrero",className:"h-12 w-auto object-contain"}),e.jsx("img",{src:Es,alt:"Projeto Tamar",className:"h-12 w-auto object-contain"})]})]}),e.jsx("p",{className:"text-sm font-bold text-foreground mb-3",children:"Escolha um valor para doar:"}),e.jsx("div",{className:`grid gap-2 ${ee.length>0?`grid-cols-${Math.min(ee.length,5)}`:"grid-cols-5"}`,children:ee.map(S=>{const E=C===S.productCode;return e.jsxs("button",{disabled:y,onClick:()=>I(S),className:`py-2.5 rounded-lg border-2 text-xs sm:text-sm font-bold transition-colors disabled:opacity-60 ${E?"border-accent bg-accent/10 text-foreground":"border-border text-muted-foreground bg-card"}`,children:["R$ ",S.amount]},S.productCode)})})]}),e.jsx("h3",{className:"font-bold text-foreground mb-3",children:"Escolha uma forma de pagamento"}),c&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6",children:[e.jsx(me,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Carregando formas de pagamentoâ¦"})]}),!c&&Re.length===0&&re.length===0&&e.jsx("p",{className:"text-center text-sm text-muted-foreground py-6",children:"Nenhuma forma de pagamento disponÃvel no momento."}),Re.length>0&&e.jsx("div",{className:`grid gap-3 mb-3 ${Re.length===1?"grid-cols-1":"grid-cols-2"}`,children:Re}),re.length>0&&e.jsx("div",{className:`grid gap-3 mb-5 ${re.length===1?"grid-cols-1":re.length===2?"grid-cols-2":"grid-cols-3"}`,children:re}),t==="card"&&e.jsxs("div",{className:"space-y-3 mb-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(V,{label:"Parcelas",children:e.jsx("select",{value:o,onChange:S=>w(S.target.value),className:"w-full border border-border rounded-lg px-3 py-2.5 text-sm bg-card focus:outline-none focus:ring-2 focus:ring-primary",children:(()=>{var E;const S=((E=d==null?void 0:d.cardInstallments)==null?void 0:E.maxInstallments)??1;return Array.from({length:S},(k,ae)=>ae+1).map(k=>e.jsxs("option",{value:k,children:[k,"x de R$ ",lt(m/k)," sem juros"]},k))})()})}),e.jsx(V,{label:"Número do cartão",children:e.jsx(H,{placeholder:"0000 0000 0000 0000",value:Me,inputMode:"numeric",maxLength:19,onChange:S=>{const E=S.target.value.replace(/\D/g,"").slice(0,16);Fe(E.replace(/(\d{4})(?=\d)/g,"$1 "))}})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(V,{label:"Validade",children:e.jsx(H,{placeholder:"MM/YY",value:pe,inputMode:"numeric",maxLength:5,onChange:S=>{const E=S.target.value.replace(/\D/g,"").slice(0,4);$e(E.length>=3?`${E.slice(0,2)}/${E.slice(2)}`:E)}})}),e.jsx(V,{label:"CVV",children:e.jsx(H,{placeholder:"3 ou 4 dÃgitos",value:Je,inputMode:"numeric",maxLength:4,onChange:S=>Le(S.target.value.replace(/\D/g,"").slice(0,4))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(V,{label:"Nome do titular do cartão",children:e.jsx(H,{placeholder:"Digite o nome impresso no cartão",value:Ie,onChange:S=>Ve(S.target.value)})}),e.jsx(V,{label:"CPF do titular do cartão",children:e.jsx(H,{placeholder:"000.000.000-00",value:et,onChange:S=>Be(S.target.value)})})]}),e.jsx("h4",{className:"font-bold text-foreground pt-2",children:"Endereço de cobrança"}),e.jsx(Qt,{zipCode:f,setZipCode:Y,stateCode:j,setStateCode:P,district:L,setDistrict:N,cityId:je||"",setCityId:Q,cityName:B,setCityName:h,setStreet:W,setComplement:xe,children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(V,{label:"Rua",children:e.jsx(H,{placeholder:"Rua",value:T,onChange:S=>W(S.target.value)})}),e.jsx(V,{label:"Número",children:e.jsx(H,{placeholder:"00000",value:Z,onChange:S=>G(S.target.value)})}),e.jsx(V,{label:"Complemento",children:e.jsx(H,{placeholder:"complemento",value:z,onChange:S=>xe(S.target.value)})})]})})]}),!t&&e.jsx("p",{className:"text-center text-sm text-muted-foreground mb-4",children:"Para prosseguir, escolha uma forma de pagamento."}),t==="pix"&&e.jsx("p",{className:"text-center text-sm text-muted-foreground mb-4",children:"Para prosseguir, clique em Pagar com PIX e gere o QR Code da venda."}),e.jsxs("button",{onClick:st,disabled:!t||tt,className:"w-full bg-accent text-accent-foreground py-3.5 rounded-full font-extrabold hover:bg-accent/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:[tt&&e.jsx(me,{className:"w-4 h-4 animate-spin"}),_e]})]})]}),e.jsx(ye,{n:4,title:"Cadastre os passaportes"})]})},Fs=({userName:t,email:r,orderId:s,pix:o,paid:w,onContinue:m})=>{const p=async()=>
11{if(!(o!=null&&o.qrCode)){v.error("Código PIX indisponÃvel");return}try{await navigator.clipboard.writeText(o.qrCode),v.success("Código PIX copiado!")}catch{v.error("Não foi possÃvel copiar o código")}};return e.jsxs("div",{className:"md:bg-card rounded-xl md:p-7 md:border md:border-border text-center",children:[e.jsxs("h2",{className:"font-extrabold text-foreground mb-1",children:[t,", estamos quase lá!"]}),e.jsx("p",{className:"font-bold text-foreground mb-5",children:w?"Pagamento confirmado!":"Seu QR Code para o PIX foi gerado."}),s&&e.jsx("div",{className:"inline-block border border-border rounded-lg px-6 py-3 mb-6",children:e.jsxs("span",{className:"text-primary font-bold",children:["Pedido #",s]})}),e.jsx("div",{className:"flex justify-center mb-6",children:o!=null&&o.qrCodeUrl?e.jsx("img",{src:o.qrCodeUrl,alt:"QR Code PIX",className:"w-60 h-60"}):e.jsx("div",{className:"w-60 h-60 flex items-center justify-center border border-dashed border-border rounded-lg text-sm text-muted-foreground",children:"Gerando QR Code..."})}),w?e.jsx("button",{onClick:m,className:"bg-accent text-accent-foreground px-10 py-3 rounded-full font-extrabold hover:bg-accent/90 transition-colors mb-5",children:"Continuar"}):e.jsx("button",{onClick:p,disabled:!(o!=null&&o.qrCode),className:"bg-accent text-accent-foreground px-10 py-3 rounded-full font-extrabold hover:bg-accent/90 transition-colors mb-5 disabled:opacity-60",children:"Copiar QR Code"}),e.jsx("p",{className:"text-sm text-foreground",children:"Você receberá uma mensagem sobre"}),e.jsx("p",{className:"text-sm text-foreground",children:"o status do pagamento no e-mail:"}),e.jsx("p",{className:"text-primary font-bold mt-2",children:r})]})},$s=({userName:t,email:r,orderId:s,method:o,paymentStatus:w})=>{const m=o==="card"&&w===2;return e.jsxs("div",{className:"md:bg-card rounded-xl md:p-7 md:border md:border-border text-center",children:[e.jsxs("h2",{className:"font-extrabold text-foreground mb-1",children:[t,", estamos quase lá!"]}),e.jsx("p",{className:"font-bold text-foreground mb-5",children:m?"Pagamento em análise! Aguardeâ¦":"Aguardando confirmação do pagamentoâ¦"}),s&&e.jsx("div",{className:"inline-block border border-border rounded-lg px-6 py-3 mb-6",children:e.jsxs("span",{className:"text-primary font-bold",children:["Pedido #",s]})}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsxs("div",{className:"w-60 h-60 flex flex-col items-center justify-center border border-dashed border-border rounded-lg gap-3",children:[e.jsx(me,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Processando pagamento"})]})}),e.jsx("p",{className:"text-sm text-foreground",children:"Você receberá uma mensagem sobre"}),e.jsx("p",{className:"text-sm text-foreground",children:"o status do pagamento no e-mail:"}),e.jsx("p",{className:"text-primary font-bold mt-2",children:r})]})},Ls=({orderId:t,onRetry:r})=>e.jsxs("div",{className:"md:bg-card rounded-xl md:p-7 md:border md:border-border text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Zt,{className:"h-8 w-8 text-destructive"})})}),e.jsx("h2",{className:"font-extrabold text-foreground mb-2 text-xl",children:"Pedido negado"}),e.jsx("p",{className:"text-foreground mb-5",children:"Não foi possÃvel autorizar o pagamento. Verifique os dados e tente novamente."}),t&&e.jsx("div",{className:"inline-block border border-border rounded-lg px-6 py-3 mb-6",children:e.jsxs("span",{className:"text-primary font-bold",children:["Pedido #",t]})}),e.jsx("div",{className:"flex justify-center",children:e.jsx("button",{onClick:r,className:"bg-accent text-accent-foreground px-10 py-3 rounded-full font-extrabold hover:bg-accent/90 transition-colors",children:"Tentar novamente"})})]}),Vs=({provider:t,orderUid:r,orderId:s,payment:o,paymentsConfig:w,paid:m,onPaid:p,onCancel:M})=>{const A=a.useRef(null),l=a.useRef(!1),[d,R]=a.useState(null),[$,c]=a.useState("Preparando pagamentoâ¦"),C=o==null?void 0:o.transactionId,y=o==null?void 0:o.amount;a.useEffect(()=>{m&&p()},[m,p]),a.useEffect(()=>{if(l.current||!o)return;const Y=async()=>{var T,W;const N=(T=o==null?void 0:o.mercadoPago)==null?void 0:T.preferenceId,B=((W=o==null?void 0:o.mercadoPago)==null?void 0:W.publicKey)||(w==null?void 0:w.mercadoPagoPublicKey);if(!N||!B)throw new Error("Dados Mercado Pago incompletos.");await At("https://sdk.mercadopago.com/js/v2"),new window.MercadoPago(B,{locale:"pt-BR"}
11).checkout({preference:{id:N},render:{container:"#mp-wallet-container",type:"wallet"}}),c("Aguardando pagamento no Mercado Pagoâ¦")},j=async()=>{var N,B;if(!window.ApplePaySession)throw new Error("Apple Pay não disponÃvel neste navegador.");if(!((B=(N=window.ApplePaySession).canMakePayments)!=null&&B.call(N)))throw new Error("Apple Pay não disponÃvel neste dispositivo.");if(typeof C!="number"||typeof y!="number")throw new Error("Dados de transação incompletos.");c("Clique no botão Apple Pay para continuar.")},P=async()=>{const N=w==null?void 0:w.googlePay;if(!N)throw new Error("Config Google Pay indisponÃvel.");if(typeof C!="number"||typeof y!="number")throw new Error("Dados de transação incompletos.");await At("https://pay.google.com/gp/p/js/pay.js");const B={merchantId:N.merchantId,merchantName:"Beto Carrero World"},h=new window.google.payments.api.PaymentsClient({environment:(N.environment||"TEST").toUpperCase(),merchantInfo:B,paymentDataCallbacks:{onPaymentAuthorized:async z=>{var xe,je;try{const Q=(je=(xe=z==null?void 0:z.paymentMethodData)==null?void 0:xe.tokenizationData)==null?void 0:je.token;let oe,ee;if(Q)try{const te=JSON.parse(Q);oe=te==null?void 0:te.signature,ee=te==null?void 0:te.signedMessage}catch{}return await Ot(r,{provider:"google_pay",transactionId:C,total:y,payload:JSON.stringify(z),dataTr:oe,dataTrMsg:ee}),c("Pagamento autorizado. Confirmandoâ¦"),{transactionState:"SUCCESS"}}catch(Q){return R((Q==null?void 0:Q.message)||"Falha ao capturar pagamento Google Pay"),{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:(Q==null?void 0:Q.message)||"Falha",reason:"PAYMENT_DATA_INVALID"}}}}}}),T={apiVersion:2,apiVersionMinor:0},W=[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["VISA","MASTERCARD","AMEX","DISCOVER"],billingAddressRequired:!1},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:N.gateway,gatewayMerchantId:N.gatewayMerchantId}}}],Z=await h.isReadyToPay({...T,allowedPaymentMethods:W,existingPaymentMethodRequired:!1});if(!(Z!=null&&Z.result))throw new Error("Google Pay não disponÃvel neste dispositivo.");const G=h.createButton({buttonType:"pay",buttonSizeMode:"fill",onClick:()=>{h.loadPaymentData({...T,allowedPaymentMethods:W,transactionInfo:{countryCode:"BR",currencyCode:"BRL",totalPriceStatus:"FINAL",totalPrice:y.toFixed(2)},merchantInfo:B,callbackIntents:["PAYMENT_AUTHORIZATION"]}).catch(z=>{(z==null?void 0:z.statusCode)!=="CANCELED"&&R((z==null?void 0:z.statusMessage)||"Erro Google Pay")})}});A.current&&(A.current.innerHTML="",A.current.appendChild(G)),c("Clique no botão Google Pay para continuar.")};l.current=!0,(t==="mpago"?Y:t==="apay"?j:P)().catch(N=>{R((N==null?void 0:N.message)||"Falha ao iniciar pagamento")})},[t,o,w,r,s,C,y]);const I=()=>{R(null);try{if(!window.ApplePaySession)throw new Error("Apple Pay não disponÃvel neste navegador.");if(typeof C!="number"||typeof y!="number")throw new Error("Dados de transação incompletos.");const Y={countryCode:"BR",currencyCode:"BRL",merchantCapabilities:["supports3DS","supportsCredit"],supportedNetworks:["visa","masterCard","amex","discover"],total:{label:`Pedido ${s??""}`.trim(),type:"final",amount:y.toFixed(2)}},j=new window.ApplePaySession(3,Y);j.onvalidatemerchant=async()=>{try{const P=await Ns(r);j.completeMerchantValidation(P)}catch(P){R((P==null?void 0:P.message)||"Falha na validação Apple Pay"),j.abort()}},j.onpaymentauthorized=async P=>{try{await Ot(r,{provider:"apple_pay",transactionId:C,total:y,payload:JSON.stringify(P.payment)}),j.completePayment({status:window.ApplePaySession.STATUS_SUCCESS}),c("Pagamento autorizado. Confirmandoâ¦")}catch(L){j.completePayment({status:window.ApplePaySession.STATUS_FAILURE}),R((L==null?void 0:L.message)||"Falha ao capturar pagamento Apple Pay")}},j.oncancel=()=>{c("Pagamento cancelado.")},j.begin(),c("Aguardando autorização no Apple Payâ¦")}catch(Y){R((Y==null?void 0:Y.message)||"Falha ao iniciar Apple Pay")}},f=t==="mpago"?"Pagamento com Mercado Pago":t==="apay"?"Pagamento com Apple Pay":"Pagamento com Google Pay";return e.jsxs("div",{className:"md:bg-card rounded-xl md:p-7 md:border md:border-border text-center",children:[e.jsx("h2",{className:"font-extrabold text-foreground mb-2",children:f}),s&&e.jsx("div",{className:"inline-block border border-border rounded-lg px-6 py-2 mb-5",children:e.jsxs("span",{className:"text-primary font-bold",children:["Pedido #",s]})}),t==="mpago"&&e.jsx("div",{id:"mp-wallet-container",className:"flex justify-center my-4"}),t==="gpay"&&e.jsx("div",{ref:A,className:"flex justify-center my-4"}),t==="apay"&&e.jsxs("div",{className:"flex flex-col items-center my-4 gap-2",children:[e.jsx("button",{type:"button",onClick:I,"aria-label":"Pagar com Apple Pay",style:{WebkitAppearance:"-apple-pay-button",ApplePayButtonType:"pay",ApplePayButtonStyle:"black"},className:"apple-pay-button h-12 w-56 rounded-lg bg-black text-white font-semibold"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Confirme no painel do Apple Pay após o clique."})]}),d?e.jsx("p",{className:"text-sm text-destructive font-semibold mb-4",children:d}):e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:$}),e.jsx("button",{onClick:M,className:"text-sm text-primary font-bold underline",children:"Voltar e escolher outra forma de pagamento"})]})},Bs=({email:t,orderUid:r,orderData:s,setOrderData:o,onFinish:w,sendingVoucher:m,onSendVoucher:p})=>{var Y;
11const[M,A]=a.useState(!1),[l,d]=a.useState(!1),[R,$]=a.useState({}),c=(j,P)=>{$(L=>({...L,[j]:{...L[j]??{fullName:"",document:"",birthDate:"",foreigner:!1},foreigner:P,document:""}}))};a.useEffect(()=>{if(s||!r)return;const j=new AbortController;return A(!0),Bt(r,j.signal).then(P=>o(P)).catch(P=>{(P==null?void 0:P.name)!=="AbortError"&&v.error((P==null?void 0:P.message)||"Erro ao carregar pedido")}).finally(()=>A(!1)),()=>j.abort()},[r,s,o]),a.useEffect(()=>{s!=null&&s.items&&$(j=>{var L;const P={...j};return(L=s.items)==null||L.forEach(N=>{var B;(B=N.tickets)==null||B.forEach(h=>{var Z,G,z;if(P[h.id])return;const T=((Z=h.holder)==null?void 0:Z.document)??"",W=/[a-zA-Z]/.test(T);P[h.id]={fullName:((G=h.holder)==null?void 0:G.fullName)??"",document:W?T:Gt(T),birthDate:((z=h.holder)==null?void 0:z.birthDate)??"",foreigner:W}})}),P})},[s]);const C=(j,P,L)=>{$(N=>({...N,[j]:{...N[j]??{fullName:"",document:"",birthDate:"",foreigner:!1},[P]:L}}))},y=((s==null?void 0:s.items)??[]).some(j=>(j.tickets??[]).some(P=>!!P.canEditHolder)),I=async()=>{if(!r){v.error("Pedido não encontrado.");return}const j=[];let P=0;const L=(s==null?void 0:s.items)??[];for(const N of L)for(const B of N.tickets??[]){if(!B.canEditHolder)continue;const h=R[B.id];if(!h)continue;if(P+=1,!vt(h.fullName)){v.error(`Informe o nome completo (nome e sobrenome) do Passaporte ${String(P).padStart(2,"0")}.`);return}const T=h.document.trim();if(!T){v.error(`Informe o documento do Passaporte ${String(P).padStart(2,"0")}.`);return}if(h.foreigner){if(T.length<3){v.error(`Passaporte inválido no Passaporte ${String(P).padStart(2,"0")}.`);return}}else if(T.replace(/\D/g,"").length!==11||!ht(h.document)){v.error(`CPF inválido no Passaporte ${String(P).padStart(2,"0")}.`);return}j.push({ticketId:B.id,fullName:h.fullName.trim(),document:h.foreigner?T:T.replace(/\D/g,""),birthDate:h.birthDate.trim()})}if(j.length!==0){d(!0);try{await us(r,j),v.success("Passaportes cadastrados!");try{const N=await Bt(r);o(N)}catch{}}catch(N){v.error((N==null?void 0:N.message)||"Erro ao salvar passaportes")}finally{d(!1)}}},f=s!=null&&s.id?`#${s.id}`:r?`#${r}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"md:bg-card rounded-xl md:p-7 md:border md:border-border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-accent flex items-center justify-center",children:e.jsx(De,{className:"w-4 h-4 text-accent-foreground"})}),e.jsx("h2",{className:"font-extrabold text-foreground",children:"Sua compra foi confirmada!"})]}),f&&e.jsx("div",{className:"inline-block border border-border rounded-lg px-6 py-2 mb-3 bg-card",children:e.jsxs("span",{className:"text-primary font-bold",children:["Pedido ",f]})}),e.jsx("p",{className:"text-sm text-foreground",children:"Você receberá uma mensagem com"}),e.jsx("p",{className:"text-sm text-foreground",children:"detalhes do seu pedido no e-mail:"}),e.jsx("p",{className:"text-primary font-bold mt-1",children:t})]}),y?e.jsxs("div",{className:"-mx-4 md:mx-0 md:rounded-xl bg-[hsl(12_85%_78%)] px-4 py-4 flex items-center gap-3",children:[e.jsx("span",{className:"text-foreground font-bold text-3xl leading-none self-stretch flex items-end",children:"â"}),e.jsx("p",{className:"flex-1 text-sm font-bold text-foreground text-center",children:"Evite filas! Cadastre os passaportes de cada membro do seu grupo para acessar o parque."}),e.jsx("span",{className:"text-foreground font-bold text-3xl leading-none self-stretch flex items-end",children:"â"})]}):e.jsxs("div",{className:"-mx-4 md:mx-0 md:rounded-xl bg-[hsl(158_70%_82%)] px-4 py-4 flex items-center gap-3",children:[e.jsx("span",{className:"text-foreground font-bold text-3xl leading-none self-stretch flex items-end",children:"â"}),e.jsx("p",{className:"flex-1 text-sm font-bold text-foreground text-center",children:"Passaportes cadastrados com sucesso!"}),e.jsx("span",{className:"text-foreground font-bold text-3xl leading-none self-stretch flex items-end",children:"â"})]}),e.jsxs("div",{className:"md:bg-card rounded-xl md:p-7 md:border md:border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx(it,{n:4,active:!0}),e.jsx("h2",{className:"font-extrabold text-lg text-foreground",children:"Cadastre os passaportes"})]}),M&&e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(me,{className:"w-5 h-5 animate-spin text-primary"})}),!M&&((s==null?void 0:s.items)??[]).length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum passaporte para cadastrar."}),!M&&((Y=s==null?void 0:s.items)==null?void 0:Y.map((j,P)=>{var L;return e.jsxs("div",{className:P>0?"border-t border-dashed border-border pt-5 mt-5":"",children:[e.jsx("h3",{className:"font-bold text-foreground mb-1",children:j.name}),j.visitDate&&Yt(j.visitDate)&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:["Visita: ",Yt(j.visitDate)]}),(L=j.tickets)==null?void 0:L.map((N,B)=>{const h=R[N.id]??{fullName:"",document:"",birthDate:"",foreigner:!1},T=!!N.canEditHolder,W=h.foreigner?"":h.document.replace(/\D/g,""),Z=!h.foreigner&&W.length===11&&!ht(h.document);return e.jsxs("div",{className:B>0?"border-t border-border/60 pt-4 mt-4":"mt-2",children:[e.jsxs("p",{className:"text-sm font-semibold text-foreground mb-2",children:["Passaporte ",String(B+1).padStart(2,"0")," â #",
11N.id]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3",children:[e.jsxs(V,{label:"Nome completo",children:[e.jsx(H,{placeholder:"Nome completo",value:h.fullName,disabled:!T,onChange:G=>C(N.id,"fullName",G.target.value),className:T&&h.fullName.trim()&&!vt(h.fullName)?"border-destructive focus-visible:ring-destructive/30":void 0}),T&&h.fullName.trim()&&!vt(h.fullName)&&e.jsx("p",{className:"text-[11px] text-destructive mt-1",children:"Informe o nome completo (nome e sobrenome)."})]}),e.jsx(V,{label:"Tipo de documento",children:e.jsxs("select",{value:h.foreigner?"Passaporte":"CPF",disabled:!T,onChange:G=>c(N.id,G.target.value==="Passaporte"),className:"w-full border border-border rounded-lg px-3 py-2.5 text-sm bg-card focus:outline-none focus:ring-2 focus:ring-primary disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-70",children:[e.jsx("option",{children:"CPF"}),e.jsx("option",{children:"Passaporte"})]})}),e.jsxs(V,{label:h.foreigner?"Passaporte":"CPF",children:[e.jsx(H,{placeholder:h.foreigner?"Documento":"000.000.000-00",value:h.document,disabled:!T,inputMode:h.foreigner?"text":"numeric",maxLength:h.foreigner?void 0:14,onChange:G=>C(N.id,"document",h.foreigner?G.target.value:Gt(G.target.value)),className:Z?"border-destructive focus-visible:ring-destructive/30":void 0}),Z&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:"CPF inválido"})]}),e.jsx(V,{label:"Data de nascimento",children:e.jsx(H,{type:"date",value:h.birthDate,disabled:!T,onChange:G=>C(N.id,"birthDate",G.target.value)})})]})]},N.id)})]},`${j.productCode??j.name}-${P}`)})),y?e.jsxs("button",{onClick:I,disabled:l||M,className:"w-full bg-accent text-accent-foreground py-3.5 rounded-full font-extrabold hover:bg-accent/90 transition-colors mt-5 flex items-center justify-center gap-2 disabled:opacity-60",children:[l&&e.jsx(me,{className:"w-4 h-4 animate-spin"}),"Cadastrar passaportes"]}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mt-5",children:[e.jsxs("button",{onClick:p,disabled:m||((s==null?void 0:s.items)??[]).length===0,className:"w-full bg-accent text-accent-foreground py-3.5 rounded-full font-extrabold hover:bg-accent/90 transition-colors flex items-center justify-center gap-2 disabled:opacity-60",children:[m?e.jsx(me,{className:"w-4 h-4 animate-spin"}):e.jsx(bt,{className:"w-4 h-4"}),"Enviar Voucher"]}),e.jsxs("a",{href:`${is}/pedido/e-ticket/imprimir-todos/${r}`,target:"_blank",rel:"noopener noreferrer",className:"w-full bg-primary text-primary-foreground py-3.5 rounded-full font-extrabold hover:bg-primary/90 transition-colors flex items-center justify-center gap-2",children:[e.jsx(bs,{className:"w-4 h-4"}),"Imprimir Voucher"]})]})]})]})},it=({n:t,active:r,done:s})=>e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-extrabold text-sm flex-shrink-0 ${r?"bg-primary text-primary-foreground":s?"bg-accent text-accent-foreground":"bg-muted text-muted-foreground"}`,children:s?e.jsx(De,{className:"w-4 h-4"}):t}),ye=({n:t,title:r,done:s})=>e.jsxs("div",{className:`flex items-center gap-3 ${s?"py-2":"bg-card rounded-xl p-4 border border-border"}`,children:[e.jsx(it,{n:t,done:s}),e.jsx("span",{className:"font-extrabold text-foreground",children:r})]}),V=({label:t,children:r})=>e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-xs md:text-sm font-bold text-foreground mb-1.5",children:t}),r]}),H=t=>e.jsx("input",{...t,className:"w-full border border-border rounded-lg px-3 py-2.5 text-sm bg-card focus:outline-none focus:ring-2 focus:ring-primary disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-70"}),gt=({label:t,value:r,noBorder:s})=>e.jsxs("div",{className:`flex items-center justify-between text-sm ${s?"":"border-b border-border pb-3"}`,children:[e.jsx("span",{className:"text-foreground",children:t}),e.jsx("span",{children:r})]}),qs=({children:t,active:r,onClick:s})=>e.jsx("button",{onClick:s,className:`flex items-center justify-center py-3 rounded-lg border-2 transition-colors ${r?"border-accent bg-accent/10":"border-border bg-card"}`,children:t}),zs=({otp:t,setOtp:r,onComplete:s,invalid:o,onClearInvalid:w})=>{const m=a.useRef([]),p=a.useRef(t),M=a.useRef(!1);a.useEffect(()=>{p.current=t},[t]),a.useEffect(()=>{var c;(c=m.current[0])==null||c.focus()},[]),a.useEffect(()=>{t.every(c=>c!=="")&&!M.current?(M.current=!0,s==null||s()):t.every(c=>c!=="")||(M.current=!1)},[t,s]);const A=(c,C)=>{const y=[...p.current];return y[c]=C,r(y),y},l=c=>{const C=m.current[c];C&&(C.focus(),C.select())},d=(c,C)=>{const y=C.replace(/\D/g,"");if(o&&(w==null||w()),!y){A(c,"");return}if(y.length===1)A(c,y),c<p.current.length-1&&l(c+1);else{const I=[...p.current];for(let j=0;j<y.length&&c+j<p.current.length;j++)I[c+j]=y[j];r(I);const f=Math.min(c+y.length,p.current.length)-1,Y=f<p.current.length-1?f+1:f;l(Y)}},R=(c,C)=>{C.key==="Backspace"?(o&&(w==null||w()),p.current[c]?A(c,""):c>0&&(C.preventDefault(),A(c-1,""),l(c-1))):C.key==="ArrowLeft"&&c>0?(C.preventDefault(),l(c-1)):C.key==="ArrowRight"&&c<p.current.length-1&&(C.preventDefault(),l(c+1))},$=(c,C)=>{const y=C.clipboardData.getData("text").replace(/\D/g,"");y&&(C.preventDefault(),d(c,y))};return e.jsx("div",{className:"flex justify-center gap-4 mb-5",children:t.map((c,C)=>e.jsx("input",{ref:y=>m.current[C]=y,value:c,inputMode:"numeric",autoComplete:"one-time-code",maxLength:1,onChange:y=>
11d(C,y.target.value),onKeyDown:y=>R(C,y),onPaste:y=>$(C,y),onFocus:y=>y.target.select(),className:`w-12 h-14 text-center text-xl font-bold border-2 rounded-xl bg-card focus:outline-none ${o?"border-destructive text-destructive focus:border-destructive":"border-border focus:border-primary"}`},C))})},Os=({mode:t,value:r,onChange:s,onEnter:o})=>t==="email"?e.jsxs("div",{className:"flex items-center gap-2 border-2 border-accent rounded-lg px-3 py-2.5 mb-4 bg-card h-[50px]",children:[e.jsx(bt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("input",{type:"email",value:r,onChange:m=>s(m.target.value),onKeyDown:m=>m.key==="Enter"&&(o==null?void 0:o()),autoFocus:!0,className:"flex-1 bg-transparent text-sm focus:outline-none",placeholder:"[email protected]"}),e.jsx("button",{type:"button",onClick:()=>s(""),className:"text-muted-foreground","aria-label":"Limpar",children:e.jsx(Zt,{className:"w-4 h-4"})})]}):e.jsx("div",{className:"bcw-phone-wrapper mb-4",children:e.jsx(St,{defaultCountry:"br",hideDropdown:!0,forceDialCode:!0,value:r,onChange:m=>s(m),inputProps:{placeholder:"11 99999-0000",onKeyDown:m=>m.key==="Enter"&&(o==null?void 0:o())}})});export{Hs 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.