PageSourceSearch

https://repaircircle.eu/assets/RepairCheckoutPage-3JsVeL8j.js

js repaircircle.eu collected 2026-10-07 11:50:51 UTC 56,859 bytes, 1 lines download raw bytes

1import{r as l,j as e}from"./vendor-react-CSSqAeAu.js";import{u as bs,e as js,as as As,aq as Es,bi as Rs,b3 as is,b9 as Fs,b8 as Ls,p as N,bj as Os,r as Oe,t as T,bb as _e,B as G,j as Us,N as zs,aN as Be,aB as We,I as $,aj as ns,s as os,J as cs,K as ls,O as ds,P as ms,Q as ye,ad as Zs,am as Pe,aK as Me,w as Bs,_ as ps,bk as Ws,ar as Ms,a0 as Vs,a5 as $s,aH as _s,aL as qs,U as Ds,ah as ks,bl as Js,bm as Ks}from"./index-BGBqiLLz.js";import{u as Gs,F as us,a as _,b as q,c as D,d as J,e as K}from"./form-CCrZe3Zk.js";import{t as Hs}from"./zod-CneX8ejW.js";import{c as Ys}from"./schema-oX-DtQfs.js";import{C as Xs}from"./calendar-Chz6QJMX.js";import{P as Qs,a as et,b as st}from"./popover-C1qqqlYG.js";import{E as tt,l as rt,u as at,a as it,P as nt,w as ot}from"./bookingSaveGate-Dt4iGCji.js";import{S as ct}from"./StickyStatusBanner-B5ELMJ6P.js";import{i as gs}from"./isSunday-D4PfoFuA.js";import{U as hs}from"./user-B6wqMb2W.js";import{C as xs}from"./calendar-DCW2sGzd.js";import{E as lt}from"./euro-ccvTh4Iw.js";import{f as Ve,e as ys}from"./format-DnwNf7CX.js";import{d as fs}from"./de-BE5gx8Ym.js";import"./vendor-query-DiXUylMp.js";import"./vendor-charts-BKriOm_U.js";import"./vendor-motion-DNXF7DOe.js";import"./types-YUyFZkoO.js";import"./subDays-CkgwAC8o.js";import"./chevron-left-CpcIEr8V.js";const dt=rt("pk_live_51S12O5CMGXYUXJNumuXF4eMAbSsRcPwmpWWXXeUbIYUdwhFiWjYG2NdW9R4tP4zlwNSk94c1CnrMwwkgoSqP6IkN000ayuYvrx");function mt({bookingData:r,onSuccess:a,additionalPhotos:h,zipBlocked:Z,onValidateZip:S}){const A=at(),E=it(),{language:f,t:B}=bs(),[,s]=js(),[se,U]=l.useState(!1),[te,W]=l.useState(""),[qe,Ce]=l.useState(!1),[re,ae]=l.useState(!1),fe=async I=>{var i;if(I.preventDefault(),!(!A||!E)&&!(S&&!S())&&!Z){U(!0),W(""),Ce(!1);try{let R=r.imageUrls||[];if(r.imageUrls&&r.imageUrls.length>0&&console.log(`📸 Including ${r.imageUrls.length} existing image URLs`),h&&h.length>0){console.log(`📸 Uploading ${h.length} additional photos...`);try{const v=new FormData;h.forEach(Ee=>v.append("files",Ee));const ie=await fetch("/api/analyze",{method:"POST",body:v});if(ie.ok){const g=(await ie.json()).imageUrls||[];console.log(`✅ Uploaded ${g.length} additional photos`),R=[...R,...g]}else console.warn("⚠️ Failed to upload additional photos, continuing with existing images only")}catch(v){console.error("Error uploading additional photos:",v)}}const De=sessionStorage.getItem("airtableRecordId")||r.airtableRecordId,Te=sessionStorage.getItem("currentOrderId"),w=await fetch("/api/bookings/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,airtableRecordId:De,bookingToken:Te,requestTimestamp:Date.now(),imageUrls:R,language:f})});if(!w.ok){const v=await w.json().catch(()=>null);console.error("Failed to save booking to Airtable",(v==null?void 0:v.code)||w.status),(v==null?void 0:v.code)==="SHOP_UNAVAILABLE"||(v==null?void 0:v.code)==="SHOP_ELIGIBILITY_UNAVAILABLE"?(Ce(!0),W(v.code==="SHOP_ELIGIBILITY_UNAVAILABLE"?f==="de"?"Wir konnten die Verfügbarkeit dieser Werkstatt gerade nicht prüfen. Bitte versuche es erneut oder wähle eine andere Werkstatt.":"We could not verify this shop right now. Please try again or choose another shop.":f==="de"?"Diese Werkstatt ist für dieses Gerät nicht mehr verfügbar. Bitte wähle eine andere Werkstatt.":"This repair shop is no longer available for this device. Please choose another shop.")):W(B("checkoutPage.error.saveFailed")),U(!1);return}const ve=await w.json(),z=ve.orderId||`TMP-${Date.now()}`,Ae=ve.recordId;sessionStorage.setItem("currentOrderId",z),sessionStorage.setItem("airtableRecordId",Ae),r.tier&&sessionStorage.setItem("bookingTier",r.tier);const be=await A.confirmPayment({elements:E,confirmParams:{return_url:`${window.location.origin}/repair/checkout?confirmed=true`,receipt_email:r.userInfo.email},redirect:"if_required"});if(be.error){W(be.error.message||"Payment failed"),U(!1);return}console.log("💳 Payment confirmed, calling backend to create order...");const je=await fetch("/api/payment/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:z,airtableRecordId:Ae,paymentId:((i=be.paymentIntent)==null?void 0:i.id)||"payment_success",customerEmail:r.userInfo.email,confirmationType:"stripe_payment",appointmentDetails:r.appointment?{date:r.appointment.date,timeSlot:r.appointment.timeSlot,address:r.userInfo.address||"",bellName:"",instructions:""}:void 0})});if(!je.ok){console.error("Failed to confirm payment with backend"),W(B("checkoutPage.error.paymentConfirmFailed")),U(!1);return}const M=await je.json(),F=M.orderId||z,ke=M.recordId,Ne=M.shopEmail,H=M.shopSlug,Se=M.shopLoginUrl;sessionStorage.setItem("currentOrderId",F),ke&&sessionStorage.setItem("requestRecordId",ke),Ne&&sessionStorage.setItem("shopEmail",Ne),H&&sessionStorage.setItem("shopSlug",H),Se&&sessionStorage.setItem("shopLoginUrl",Se);const Ue={...r,orderId:F,requestRecordId:ke,shopEmail:Ne,shopSlug:H,shopLoginUrl:Se};sessionStorage.setItem("bookingData",JSON.stringify(Ue)),a(F)}catch{W("An unexpected error occurred")}finally{U(!1)}}};return e.jsxs("form",{onSubmit:fe,className:"space-y-6",children:[!re&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 space-y-3",children:[e.jsx(Oe,{className:"w-6 h-6 animate-spin text-gray-700"}),e.jsx("p",{className:"text-sm text-gray-500",children:f==="de"?"Zahlungsmethoden werden geladen...":"Loading payment methods..."})]}),e.jsx("div",{className:re?"":"opacity-0 h-0 overflow-hidden",children:e.jsx(nt,{onReady:()=>ae(!0)})}),te&&e.jsxs("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-md text-sm text-red-600 dark:text-red-400","data-testid":"error-payment",children:[te,qe&&e.jsx("div",{className:"mt-3",children:e.jsx(G,{type:"button",variant:"outline",onClick:()=>s(N("/repair/compare-shops",f)),children:f==="de"?"Andere Werkstatt wählen":"Choose another shop"})})]}),e.jsx("div",{className:"rounded-lg border border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/40 p-3 space-y-1.5",children:[f==="de"?"✓ Koordiniert von Repair Circle":"✓ Coordinated by Repair Circle",f==="de"?"✓ Trans
1parente Preise":"✓ Transparent pricing",f==="de"?"✓ Keine versteckten Kosten":"✓ No hidden fees",f==="de"?"✓ Reparaturkosten erst nach Diagnose":"✓ Repair cost paid after diagnosis",...r.tier==="premium"?[f==="de"?"✓ Tür-zu-Tür-Service":"✓ Door-to-door service",f==="de"?"✓ Live-Updates per SMS/Email":"✓ Live updates via SMS/Email"]:[]].map((I,i)=>e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:I},i))}),e.jsx(G,{type:"submit",disabled:!A||se||!!Z,className:"w-full bg-black hover:bg-gray-800 dark:bg-white dark:hover:bg-gray-200 dark:text-black h-12 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"button-pay",children:se?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"w-4 h-4 mr-2 animate-spin"}),B("checkoutPage.payment.processing")]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"w-4 h-4 mr-2"}),B("checkoutPage.payment.pay",{amount:r.bookingFee.toFixed(2)})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-gray-500",children:[e.jsx(ks,{className:"w-3 h-3"}),e.jsx("span",{children:B("checkoutPage.payment.secureStripe")})]})]})}const $e="checkoutFormData";function pt(r){const a=r.toLowerCase().trim();return a.includes("smartphone")||a.includes("phone")&&!a.includes("headphone")?"landing.devices.smartphone":a.includes("laptop")||a.includes("macbook")||a.includes("notebook")?"landing.devices.laptop":a.includes("tablet")||a.includes("ipad")?"landing.devices.tablet":a.includes("coffee")?"landing.devices.coffee":a.includes("printer")||a.includes("drucker")?"landing.devices.printer":a.includes("headphone")||a.includes("kopfhörer")?"landing.devices.headphones":a.includes("vacuum")||a.includes("staubsauger")?"landing.devices.vacuum":a.includes("washing")||a.includes("wasch")?"landing.devices.washing":a.includes("drone")?"landing.devices.drone":a.includes("kitchen")?"landing.devices.kitchen":""}function vs(r){if(!r)return!1;const a=S=>S.replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss"),h=["washing machine","washingmachine","dishwasher","printer","refrigerator","oven","stove","dryer","fridge","freezer","waschmaschine","waschautomat","waschtrockner","waschvollautomat","toplader","frontlader","geschirrspueler","geschirrspuelmaschine","spuelmaschine","spueler","spulmaschine","geschirrspueler","geschirrautomat","drucker","multifunktionsdrucker","laserdrucker","kuehlschrank","gefrierschrank","gefriertruhe","kuehltruhe","kuehl-gefrier-kombination","kombigeraet","side-by-side","kuehlgefrierkombination","ofen","herd","backofen","elektroherd","gasherd","einbauherd","standherd","trockner","waeschetrockner","waermepumpentrockner","kondenstrockner","ablufttrockner","grossgeraet","grossgeraete","haushaltsgeraet","haushaltsgeraete","haushaltsgrossgeraet","weissware"],Z=S=>{const A=a(S.toLowerCase().trim());return h.some(E=>A.includes(E))};return!!(r.deviceType&&Z(r.deviceType)||r.deviceTypeCopy&&Z(r.deviceTypeCopy))}function Lt(){var He,Ye,Xe,Qe,es,ss,ts,rs;const{language:r,t:a}=bs(),[,h]=js(),{trackFunnelStep:Z}
1=As(),{getPrice:S,formatPrice:A,getZonePrice:E,formatZonePrice:f}=Es(),B=l.useRef(!1),[s,se]=l.useState(null),[U,te]=l.useState(""),[W,qe]=l.useState(!1),[Ce,re]=l.useState(!1),ae=l.useRef(0),fe=l.useRef(null),I=l.useRef(null);l.useEffect(()=>{localStorage.removeItem("rc-confirmation-orderId"),localStorage.removeItem("rc-confirmation-shopId"),localStorage.removeItem("rc-confirmation-rid"),localStorage.removeItem("rc-confirmation-se"),localStorage.removeItem("rc-confirmation-ss"),localStorage.removeItem("rc-confirmation-slu"),localStorage.removeItem("rc-confirmation-tier")},[]);const[i,R]=l.useState(null),[De,Te]=l.useState(!1),[w,ve]=l.useState(void 0),[z,Ae]=l.useState(""),[be,je]=l.useState(!1),[M,F]=l.useState(""),[ke,Ne]=l.useState(0),[H,Se]=l.useState([]),[Ue,v]=l.useState(""),[ie,Ee]=l.useState(!1),[g,Ns]=l.useState(""),[ne,oe]=l.useState(""),[ce,Re]=l.useState(""),[le,ze]=l.useState(null),[Je,Y]=l.useState(!0),Ke=t=>{var c;const n=(t||"").trim();return/^\d{5}$/.test(n)&&!!((c=Pe[n])!=null&&c.premiumEligible)},Ze=t=>{if(!t||t.trim()==="")return oe(r==="de"?"Bitte geben Sie die PLZ für die Abholung ein":"Please enter the ZIP code for pickup"),!1;const n=t.trim();return/^\d{5}$/.test(n)?!Pe[n]||!Pe[n].premiumEligible?(oe(r==="de"?"Wir bieten in dieser Region leider keinen Abholservice an.":"We don't offer pickup in this area."),!1):(oe(""),!0):(oe(r==="de"?"Bitte geben Sie eine gültige 5-stellige PLZ ein":"Please enter a valid 5-digit ZIP code"),!1)},Fe=t=>le?le.type==="percent"?t*(1-le.value/100):Math.max(0,t-le.value):t,d=Gs({resolver:Hs(Ys),mode:"onBlur",defaultValues:{serviceTier:void 0,userName:"",userEmail:"",userPhone:"",userZipCode:"",userAddress:"",userCity:"Berlin",referralSource:"",priority:"Medium",autoApproveAmount:""}}),Ge=l.useMemo(()=>Rs($e,300),[]);l.useEffect(()=>{const t=d.watch(n=>{(n.userName||n.userEmail)&&Ge(n)});return()=>t.unsubscribe()},[d,Ge]),l.useEffect(()=>{i&&(d.setValue("serviceTier",i,{shouldValidate:!0}),console.log(`✅ Updated form serviceTier field to: ${i}`))},[i,d]),l.useEffect(()=>{var t,n,c,o;if(!B.current){Z("checkout");const u=g||((t=s==null?void 0:s.userInfo)==null?void 0:t.zipCode)||"",m=i==="premium"?is(u)??void 0:void 0,x=i==="premium"?E(u,((n=s==null?void 0:s.deviceAnalysis)==null?void 0:n.deviceType)||""):S(((c=s==null?void 0:s.deviceAnalysis)==null?void 0:c.deviceType)||"","basic");Fs(i,(o=s==null?void 0:s.deviceAnalysis)==null?void 0:o.deviceType,void 0,x,m),B.current=!0}},[Z]),l.useEffect(()=>{var t,n,c,o;if(i){const u=g||((t=s==null?void 0:s.userInfo)==null?void 0:t.zipCode)||"",m=i==="premium"?is(u)??void 0:void 0,x=i==="premium"?E(u,((n=s==null?void 0:s.deviceAnalysis)==null?void 0:n.deviceType)||""):S(((c=s==null?void 0:s.deviceAnalysis)==null?void 0:c.deviceType)||"","basic");Ls(i,(o=s==null?void 0:s.deviceAnalysis)==null?void 0:o.deviceType,x,m)}},[i]),l.useEffect(()=>{const t=()=>{const n=d.getValues(),c=[];n.userName&&c.push("name"),n.userEmail&&c.push("email"),n.userPhone&&c.push("phone"),n.userZipCode&&c.push("zipCode"),c.length>0&&!sessionStorage.getItem("paymentCompleted")&&Js("checkout",c,i||void 0)};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[d,i]),l.useEffect(()=>{var L,V,Q,C,ee,Le,Ie,de;const t=new URLSearchParams(window.location.search),n=t.get("confirmed"),c=sessionStorage.getItem("bookingData");if(!c){h(N("/repair/start",r));return}let o=JSON.parse(c);const u=sessionStorage.getItem("currentOrderId");u&&!o.orderId&&(o={...o,orderId:u},sessionStorage.setItem("bookingData",JSON.stringify(o)));const m=sessionStorage.getItem("deviceImageUrls");if(m)try{const p=JSON.parse(m);o={...o,imageUrls:p},console.log("📸 Loaded image URLs from sessionStorage:",p)}catch(p){console.error("Failed to parse image URLs from sessionStorage:",p)}const x=vs(o.deviceAnalysis);x&&o.tier==="premium"&&(o={...o,tier:null},sessionStorage.setItem("bookingData",JSON.stringify(o)),sessionStorage.removeItem("selectedTier")),se(o);const y=sessionStorage.getItem("appliedPromoCode"),j=sessionStorage.getItem("promoDiscount");if(y&&j){console.log("🎟️ Rehydrating promo code from sessionStorage:",y),Re(y);try{const p=JSON.parse(j);ze(p),console.log("✅ Promo discount loaded from sessionStorage:",p)}catch(p){console.error("❌ Failed to parse stored promo discount:",p),sessionStorage.removeItem("appliedPromoCode"),sessionStorage.removeItem("promoDiscount")}Y(!1)}else y&&!j?(console.log("🎟️ Re-validating promo code:",y),Re(y),fetch("/api/validate-promo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:y})}).then(p=>p.json()).then(p=>{if(p.success&&p.valid&&p.coupon){const O=p.coupon;
1if(O.percent_off){const we={type:"percent",value:O.percent_off};ze(we),Y(!1),sessionStorage.setItem("promoDiscount",JSON.stringify(we))}else if(O.amount_off){const k={type:"fixed",value:O.amount_off/100};ze(k),Y(!1),sessionStorage.setItem("promoDiscount",JSON.stringify(k))}else Y(!1)}else sessionStorage.removeItem("appliedPromoCode"),sessionStorage.removeItem("promoDiscount"),Re(""),Y(!1)}).catch(()=>{sessionStorage.removeItem("appliedPromoCode"),sessionStorage.removeItem("promoDiscount"),Re(""),Y(!1)})):Y(!1);const P=sessionStorage.getItem("selectedTier");P&&(x&&P==="premium"?(sessionStorage.removeItem("selectedTier"),R(null)):R(P));const b=Os($e),X={userName:((L=o.userInfo)==null?void 0:L.name)||"",userEmail:((V=o.userInfo)==null?void 0:V.email)||"",userPhone:((Q=o.userInfo)==null?void 0:Q.phoneNumber)||"",userZipCode:((C=o.userInfo)==null?void 0:C.zipCode)||sessionStorage.getItem("userZipCode")||"",userAddress:((ee=o.userInfo)==null?void 0:ee.address)||"",userCity:((Le=o.userInfo)==null?void 0:Le.city)||"Berlin",referralSource:((Ie=o.userInfo)==null?void 0:Ie.referralSource)||"",priority:"Medium",autoApproveAmount:""};if(d.reset({...X,...b||{}}),console.log(b?"✅ Restored form session data":"📝 No saved form data found"),v(((de=o.deviceAnalysis)==null?void 0:de.issue)||""),n==="true"){const p=sessionStorage.getItem("currentOrderId"),O=sessionStorage.getItem("airtableRecordId"),we=t.get("payment_intent");if(p)fetch("/api/payment/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:p,airtableRecordId:O,paymentId:we||"payment_success",customerEmail:o.userInfo.email,confirmationType:"stripe_redirect",appointmentDetails:o.appointment?{date:o.appointment.date,timeSlot:o.appointment.timeSlot,address:o.userInfo.address||"",bellName:"",instructions:""}:void 0})}).then(k=>k.json()).then(k=>{const me=k.orderId||p,pe=k.recordId,ue=k.shopEmail,ge=k.shopSlug,he=k.shopLoginUrl;console.log(`✅ Payment confirmed! Order_Number generated: ${me}`,{requestRecordId:pe,shopEmail:ue,shopSlug:ge,shopLoginUrl:he}),sessionStorage.setItem("currentOrderId",me),pe&&sessionStorage.setItem("requestRecordId",pe),ue&&sessionStorage.setItem("shopEmail",ue),ge&&sessionStorage.setItem("shopSlug",ge),he&&sessionStorage.setItem("shopLoginUrl",he);const Cs={...o,orderId:me,requestRecordId:pe,shopEmail:ue,shopSlug:ge,shopLoginUrl:he};sessionStorage.setItem("bookingData",JSON.stringify(Cs));const Ts=sessionStorage.getItem("bookingTier")||o.tier||"basic",xe=new URLSearchParams;pe&&xe.set("rid",pe),ue&&xe.set("se",encodeURIComponent(ue)),ge&&xe.set("ss",ge),he&&xe.set("slu",encodeURIComponent(he)),xe.set("oid",me);const as=xe.toString();h(Ts==="premium"?N("/repair/confirmation-premium",r)+"?"+as:N("/repair/confirmation-basic",r)+"?"+as)}).catch(k=>{console.error("Failed to confirm payment:",k);const me=sessionStorage.getItem("bookingTier")||o.tier||"basic";h(me==="premium"?N("/repair/confirmation-premium",r):N("/repair/confirmation-basic",r))});
1else{const k=sessionStorage.getItem("bookingTier")||o.tier||"basic";h(k==="premium"?N("/repair/confirmation-premium",r):N("/repair/confirmation-basic",r))}return}if(o.tier==="premium"){let p=new Date;p.setDate(p.getDate()+1),gs(p)&&p.setDate(p.getDate()+1),ve(p)}},[]),l.useEffect(()=>{i&&(d.clearErrors(),d.trigger())},[i,d]),l.useEffect(()=>{if(!d.watch("userZipCode")&&i){const n=setTimeout(()=>{Te(!0)},5e3);return()=>clearTimeout(n)}},[d.watch("userZipCode"),i]),l.useEffect(()=>{var P,b,X;const t=d.getValues();if(!s||W||!i||!t.userEmail||!t.userEmail.includes("@")||Je||i==="premium"&&!Ke(g))return;const n=g||((P=s==null?void 0:s.userInfo)==null?void 0:P.zipCode)||"",c=i==="premium"?E(n,((b=s==null?void 0:s.deviceAnalysis)==null?void 0:b.deviceType)||""):S(((X=s==null?void 0:s.deviceAnalysis)==null?void 0:X.deviceType)||"","basic"),o=Fe(c);console.log("💳 Creating payment intent with:",{baseBookingFee:c,discountedBookingFee:o,promoCode:ce,promoDiscount:le});const u={...s,tier:i,bookingFee:o,userInfo:{...s.userInfo,name:t.userName,email:t.userEmail,phoneNumber:t.userPhone||void 0,zipCode:t.userZipCode||s.userInfo.zipCode||"",address:i==="premium"?t.userAddress:void 0,city:i==="premium"?t.userCity:void 0,referralSource:t.referralSource||void 0}};let m=sessionStorage.getItem("currentOrderId");(!m||!m.startsWith("TMP-"))&&(m=`TMP-${Date.now()}`,sessionStorage.setItem("currentOrderId",m),console.log(`🔑 Generated new booking token: ${m}`)),ae.current+=1;const x=ae.current;I.current={payload:u,promo:ce,version:x};const y=async()=>{const L=I.current,{payload:V,promo:Q,version:C}=L;if(I.current&&I.current.version!==C)return console.log(`⏭️ [v${C}] Skipping stale request, newer version exists (v${I.current.version})`),!0;try{const ee=Date.now();console.log(`📝 [v${C}] Saving pending Airtable record (ts: ${ee})...`);const Le=sessionStorage.getItem("airtableRecordId");let Ie=!1;const de=await ot(()=>fetch("/api/bookings/save-pending",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...V,bookingToken:m,airtableRecordId:Le,requestTimestamp:ee})}),async p=>{if(I.current&&I.current.version!==C){Ie=!0;return}const O=p.recordId;sessionStorage.setItem("airtableRecordId",O),console.log(`✅ [v${C}] Got record: ${O}`),console.log(`💳 [v${C}] Creating payment intent after verified save...`),await Ss({...V,airtableRecordId:O},m,Q||void 0,C)});return de.success?Ie?(console.log(`🔄 [v${C}] Newer request queued, replaying before payment intent creation`),!0):!1:I.current&&I.current.version!==C?(console.log(`🔄 [v${C}] Save failed for stale payload; replaying newer request`),!0):(te(""),de.kind==="eligibility"?(re(!0),F(de.code==="SHOP_ELIGIBILITY_UNAVAILABLE"?r==="de"?"Wir konnten die Verfügbarkeit dieser Werkstatt gerade nicht prüfen. Bitte versuche es erneut oder wähle eine andere Werkstatt.":"We could not verify this shop right now. Please try again or choose another shop.":r==="de"?"Diese Werkstatt ist für dieses Gerät nicht mehr verfügbar. Bitte wähle eine andere Werkstatt.":"This repair shop is no longer available for this device. Please choose another shop.")):(re(!1),F(r==="de"?"Deine Reparaturdaten konnten nicht gespeichert werden. Bitte versuche es erneut, bevor du bezahlst.":"We could not save your repair details. Please try again before payment.")),!1)}catch(ee){return console.error("Error initializing payment:",ee),te(""),re(!1),F(r==="de"?"Deine Reparaturdaten konnten nicht gespeichert werden. Bitte versuche es erneut, bevor du bezahlst.":"We could not save your repair details. Please try again before payment."),!1}};if(fe.current){console.log(`⏳ [v${x}] Save-pending in flight, payload queued for next run`);return}const j=async()=>{let L=!0;for(;L;)L=await y();fe.current=null};fe.current=j()},[i,ce,le,Je,g,ke]);const Ss=async(t,n,c,o)=>{var u,m;F("");try{const x=t.tier==="premium"?"fast-track":"provider-selection",y=n||sessionStorage.getItem("currentOrderId")||`TMP-${Date.now()}`,j=t.airtableRecordId||sessionStorage.getItem("airtableRecordId")||"",b=await(await fetch("/api/payment/create-intent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:y,option:x,customerEmail:t.userInfo.email,amount:t.bookingFee,deviceType:((u=t.deviceAnalysis)==null?void 0:u.deviceType)||"",zipCode:((m=t.userInfo)==null?void 0:m.zipCode)||"",promoCode:c||void 0,airtableRecordId:j,bookingToken:y})})).json();if(o!==void 0&&o!==ae.current){console.log(`⏭️ [v${o}] Stale payment intent response, ignoring (current: v${ae.current})`);return}b.success&&b.clientSecret?te(b.clientSecret):F(a("checkoutPage.error.paymentInit"))}catch(x){console.error("Failed to create payment intent:",x),F(a("checkoutPage.error.connection"))}},Is=async t=>{var L,V,Q;if(!s||!i)return;const n=d.getValues(),c=sessionStorage.getItem("requestRecordId"),o=sessionStorage.getItem("shopEmail"),u=sessionStorage.getItem("shopSlug"),m=sessionStorage.getItem("shopLoginUrl");console.log("📦 handlePaymentSuccess - QR data from sessionStorage:",{requestRecordId:c,shopEmail:o,shopSlug:u,shopLoginUrl:m?"present":"missing"});const x=g||((L=s==null?void 0:s.userInfo)==null?void 0:L.zipCode)||"",y=i==="premium"?E(x,((V=s==null?void 0:s.deviceAnalysis)==null?void 0:V.deviceType)||""):S(((Q=s==null?void 0:s.deviceAnalysis)==null?void 0:Q.deviceType)||"","basic"),j=Fe(y),P={...s,orderId:t,tier:i,bookingFee:j,appliedPromoCode:ce||void 0,requestRecordId:c||void 0,shopEmail:o||void 0,shopSlug:u||void 0,shopLoginUrl:m||void 0,deliveryZipCode:i==="premium"?g:void 0,userInfo:{...s.userInfo,name:n.userName,email:n.userEmail,phoneNumber:n.userPhone||void 0,zipCode:n.userZipCode||s.userInfo.zipCode||"",address:i==="premium"?n.userAddress:void 0,city:i==="premium"?n.userCity:void 0,referralSource:n.referralSource||s.userInfo.referralSource||void 0},appointment:i==="premium"&&w&&z?{date:Ve(w,"yyyy-MM-dd"),timeSlot:z}:null,imageUrls:s.imageUrls||[],airtableRecordId:s.airtableRecordId};se(P),sessionStorage.setItem("bookingData",JSON.stringify(P)),sessionStorage.setItem("bookingTier",i),ce&&sessionStorage.setItem("appliedPromoCode",ce),Ks($e),sessionStorage.removeItem("currentOrderId"),sessionStorage.removeItem("airtableRecordId"),console.log("✅ Payment success - cleared booking tokens for fresh start on next order");const b=new URLSearchParams;c&&b.set("rid",c),o&&b.set("se",encodeURIComponent(o)),u&&b.set("ss",u),m&&b.set("slu",encodeURIComponent(m)),b.set("oid",t);const X=b.toString();h(i==="premium"?N("/repair/confirmation-premium",r)+"?"+X:N("/repair/confirmation-basic",r)+"?"+X)},ws=a("checkoutPage.title"),Ps=a("checkoutPage.metaDescription");return s?M&&!U?e.jsx("div",{className:"min-h-screen bg-white dark:bg-black flex items-center justify-center p-4",children:e.jsxs(T,{className:"max-w-md w-full p-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(_e,{className:"w-8 h-8 text-red-600"})}),e.jsx("h2",{className:"text-xl font-bold mb-2",children:a("checkoutPage.error.paymentError")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:M}),Ce?e.jsx(G,{onClick:()=>h(N("/repair/compare-shops",r)),variant:"outline",className:"w-full","data-testid":"button-choose-another-shop",children:r==="de"?"Andere Werkstatt wählen":"Choose another shop"}):e.jsxs("div",{className:"flex gap-3",children:[e.jsx(G,{onClick:()=>h(N("/repair/select-service",r)),variant:"outline",className:"flex-1","data-testid":"button-back-error",children:a("checkoutPage.button.back")}),e.jsx(G,{onClick:()=>{F(""),Ne(t=>t+1)},className:"flex-1 bg-black hover:bg-gray-800 dark:bg-white dark:hover:bg-gray-200 dark:text-black","data-testid":"button-retry",children:a("checkoutPage.button.retry")})]})]})}):e.jsxs("div",{className:"min-h-screen bg-white dark:bg-black flex flex-col",children:[e.jsxs(Us,{children:[e.jsxs("title",{children:[ws," | RepairCircle"]}),e.jsx("meta",{name:"description",content:Ps})]}),e.jsx(zs,{variant:"focus"}),s&&e.jsx("div",{className:"sticky top-0 z-50",children:e.jsx(ct,{deviceType:s.deviceAnalysis.deviceType,brand:s.deviceAnalysis.brand,model:s.deviceAnalysis.model,costEstimate:s.costEstimate,currentStep:2,onStepClick:t=>{t===1&&h(N("/repair/select-service",r))}})}),e.jsx("div",{className:"flex-grow",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-8 md:py-12",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold mb-6 text-center text-gray-900 dark:text-gray-100",children:a("checkoutPage.heading")}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"lg:hidden",children:[e.jsxs("button",{onClick:()=>Ee(!ie),className:"w-full flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-800 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-gray-900 dark:text-gray-100",children:[e.jsxs("span",{children:[s.deviceAnalysis.brand," ",s.deviceAnalysis.model]}),e.jsx("span",{className:"text-gray-400",children:"·"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:i==="premium"?f(g||((He=s.userInfo)==null?void 0:He.zipCode)||"",r,s.deviceAnalysis.deviceType):i==="basic"?A(s.deviceAnalysis.deviceType,"basic",r):r==="de"?"Service wählen":"Choose service"})]}),e.jsxs("span",{className:"text-gray-500 text-xs",children:[ie?"▲":"▼"," ","Details"]}
1)]}),ie&&e.jsxs("div",{className:"mt-2 p-4 border border-gray-200 dark:border-gray-700 rounded-lg bg-white dark:bg-gray-950 space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:a("checkoutPage.device.type")}),e.jsxs("span",{className:"font-medium",children:[s.deviceAnalysis.brand," ",s.deviceAnalysis.model]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:a("checkoutPage.device.issue")}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 max-w-[60%] text-right",children:s.deviceAnalysis.issue})]}),s.costEstimate&&e.jsxs("div",{className:"flex justify-between border-t pt-2 mt-2",children:[e.jsx("span",{className:"text-gray-500",children:a("checkoutPage.cost.estimated")}),e.jsx("span",{className:"font-semibold",children:Be(s.costEstimate.min,s.costEstimate.max)})]}),i&&e.jsxs("div",{className:"flex justify-between border-t pt-2 mt-2",children:[e.jsx("span",{className:"text-gray-500",children:r==="de"?"Heute fällig":"Due today"}),e.jsx("span",{className:"font-bold",children:i==="premium"?f(g||((Ye=s.userInfo)==null?void 0:Ye.zipCode)||"",r,s.deviceAnalysis.deviceType):A(s.deviceAnalysis.deviceType,"basic",r)})]})]})]}),(()=>{var o,u,m,x;const t=vs(s==null?void 0:s.deviceAnalysis),n=f(((o=s==null?void 0:s.userInfo)==null?void 0:o.zipCode)||"",r,((u=s==null?void 0:s.deviceAnalysis)==null?void 0:u.deviceType)||""),c=A(((m=s==null?void 0:s.deviceAnalysis)==null?void 0:m.deviceType)||"","basic",r);return e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-gray-900 dark:text-gray-100",children:a("checkoutPage.tier.chooseService")}),t&&e.jsx("div",{className:"mb-3 p-3 bg-stone-50 dark:bg-stone-900/20 border border-stone-200 dark:border-stone-700 rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(We,{className:"w-4 h-4 text-stone-600 dar
1k:text-stone-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-xs text-stone-800 dark:text-stone-200 space-y-1",children:[e.jsx("p",{className:"font-medium",children:a("checkoutPage.tier.largeAppliance.title")}),e.jsx("p",{children:a("checkoutPage.tier.largeAppliance.benefit1")}),e.jsx("p",{children:a("checkoutPage.tier.largeAppliance.benefit2")}),e.jsx("p",{children:a("checkoutPage.tier.largeAppliance.benefit3")}),e.jsx("p",{children:a("checkoutPage.tier.largeAppliance.benefit4")})]})]})}),e.jsxs("div",{className:"flex gap-2 p-1 bg-gray-100 dark:bg-gray-900 rounded-lg",children:[e.jsx("button",{onClick:()=>!t&&R("premium"),disabled:t,className:`flex-1 py-3 px-3 rounded-md text-sm font-semibold transition-all ${i==="premium"?"bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 shadow-sm":t?"opacity-40 cursor-not-allowed text-gray-400 dark:text-gray-600":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100"}`,title:t?a("checkoutPage.tier.largeAppliance.tooltip"):"","data-testid":"button-tier-premium",children:e.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[e.jsxs("span",{className:"text-xs",children:["🚚 ",r==="de"?"Abholung & Lieferung":"Pickup & Delivery"]}),e.jsx("span",{className:"font-bold text-xs leading-tight text-gray-800 dark:text-gray-200",children:n})]})}),e.jsx("button",{onClick:()=>R("basic"),className:`flex-1 py-3 px-3 rounded-md text-sm font-semibold transition-all ${i==="basic"?"bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100"}`,"data-testid":"button-tier-basic",children:e.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[e.jsxs("span",{className:"text-xs",children:["🏪 ",r==="de"?"Selbst vorbeibringen":"Self Drop-off"]}),e.jsx("span",{className:"font-bold text-xs leading-tight text-gray-800 dark:text-gray-200",children:c})]})})]}),i==="premium"&&e.jsxs("div",{className:"mt-3 p-4 bg-green-50 dark:bg-green-950/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx("ul",{className:"space-y-1.5 text-sm text-gray-700 dark:text-gray-300 mb-3",children:(r==="de"?["🚪 Tür-zu-Tür — wir holen ab & liefern zurück","📱 Live-Updates per SMS & Email","⏱️ Spart 3+ Stunden Aufwand","🔒 Gerät sicher versichert während des Transports"]:["🚪 Door-to-door — we collect & return your device","📱 Live updates via SMS & email","⏱️ Saves you 3+ hours of hassle","🔒 Device insured during transit"]).map((y,j)=>e.jsx("li",{className:"text-xs",children:y},j))}),e.jsx("button",{onClick:()=>R("basic"),className:"text-xs text-gray-500 dark:text-gray-400 underline underline-offset-2 hover:text-gray-700",children:r==="de"?"Lieber selbst vorbeibringen? Kostenlos wechseln →":"Prefer to bring it yourself? Switch to free self drop-off →"})]}),i==="basic"&&e.jsxs("div",{className:"mt-3 p-4 bg-gray-50 dark:bg-gray-900/40 border border-gray-200 dark:border-gray-700 rounded-lg",children:[(x=s.shopInfo)!=null&&x.name?e.jsxs("div",{className:"space-y-1 text-xs text-gray-700 dark:text-gray-300 mb-3",children:[e.jsxs("p",{className:"font-semibold text-sm text-gray-900 dark:text-gray-100",children:["🏪 ",s.shopInfo.name]}),s.shopInfo.distance&&e.jsxs("p",{children:["📍 ",s.shopInfo.distance]}),s.shopInfo.openingHours&&e.jsxs("p",{children:["🕐 ",s.shopInfo.openingHours]})]}):e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-3",children:r==="de"?"🏪 Bringe dein Gerät direkt zur Werkstatt — kostenlos.":"🏪 Drop off your device directly at the repair shop — free of charge."}),!t&&e.jsx("button",{onClick:()=>R("premium"),className:"text-xs text-gray-500 dark:text-gray-400 underline underline-offset-2 hover:text-gray-700",children:r==="de"?"Mehr Komfort? Zur Abholung & Lieferung wechseln →":"Need more convenience? Switch to Pickup & Delivery →"})]})]})})(),e.jsxs("div",{className:"rounded-lg border border-gray-100 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-900/20 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 mb-3",children:r==="de"?"Was passiert als nächstes?":"What happens next?"}),e.jsx("ol",{className:"space-y-2.5",children:(r==="de"?[{step:"1",label:"Service wählen & bezahlen",sub:"Buchungsgebühr heute"},{step:"2",label:i==="premium"?"Abholtermin bestätigen":"Termin in der Werkstatt",sub:i==="premium"?"Wir kommen zu dir":"Gerät vorbeibringen"},{step:"3",label:"Diagnose durch den Techniker",sub:"Innerhalb von 24–48 h"},{step:"4",label:"Kostenvoranschlag erhalten",sub:"Transparent & unverbindlich"},{step:"5",label:"Reparatur freigeben",sub:"Per SMS oder Email"},{step:"6",label:i==="premium"?"Gerät repariert zurückgeliefert":"Gerät repariert abholen",sub:"Fertig!"}
1]:[{step:"1",label:"Choose service & pay",sub:"Booking fee today"},{step:"2",label:i==="premium"?"Confirm pickup appointment":"Visit the repair shop",sub:i==="premium"?"We come to you":"Drop off your device"},{step:"3",label:"Technician diagnosis",sub:"Within 24–48 h"},{step:"4",label:"Receive a quote",sub:"Transparent & no obligation"},{step:"5",label:"Approve the repair",sub:"Via SMS or email"},{step:"6",label:i==="premium"?"Device returned repaired":"Pick up your repaired device",sub:"Done!"}]).map(({step:t,label:n,sub:c})=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 text-xs font-bold flex items-center justify-center mt-0.5",children:t}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-gray-800 dark:text-gray-200",children:n}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})]},t))})]}),e.jsxs(T,{className:"p-6",children:[e.jsx("h3",{className:"font-semibold mb-4 text-gray-900 dark:text-gray-100",children:a("checkoutPage.contact.title")}),e.jsx(us,{...d,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(_,{control:d.control,name:"userName",render:({field:t})=>e.jsxs(q,{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(hs,{className:"w-4 h-4"}),a("checkoutPage.contact.name")]}),e.jsx(J,{children:e.jsx($,{...t,placeholder:a("checkoutPage.contact.namePlaceholder"),"data-testid":"input-name"})}),e.jsx(K,{translate:a})]})}),e.jsx(_,{control:d.control,name:"userPhone",render:({field:t})=>e.jsxs(q,{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(hs,{className:"w-4 h-4"}),a("checkoutPage.contact.phone"),i==="premium"&&e.jsx("span",{className:"text-red-500",children:"*"}),i==="basic"&&e.jsxs("span",{className:"text-xs text-gray-500",children:["(",a("checkoutPage.contact.optional"),")"]})]}),e.jsx(J,{children:e.jsx($,{...t,type:"tel",placeholder:a("checkoutPage.contact.phonePlaceholder"),"data-testid":"input-phone"})}),e.jsx(K,{translate:a})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(_,{control:d.control,name:"userZipCode",render:({field:t})=>e.jsxs(q,{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(ns,{className:"w-4 h-4"}),a("checkoutPage.contact.zipcode"),e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(J,{children:e.jsx($,{...t,placeholder:a("checkoutPage.contact.zipcodePlaceholder"),onChange:n=>{t.onChange(n),n.target.value.trim()&&(sessionStorage.setItem("userZipCode",n.target.value.trim()),Te(!1))},"data-testid":"input-zipcode"})}),e.jsx(K,{translate:a})]})}),e.jsx(_,{control:d.control,name:"userCity",render:({field:t})=>e.jsxs(q,{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(os,{className:"w-4 h-4"}),r==="de"?"Stadt":"City"]}),e.jsxs(cs,{onValueChange:t.onChange,value:t.value||"Berlin",children:[e.jsx(J,{children:e.jsx(ls,{"data-testid":"select-city",children:e.jsx(ds,{placeholder:r==="de"?"Stadt wählen":"Select city"})})}),e.jsx(ms,{children:e.jsx(ye,{value:"Berlin",className:"min-h-[44px] flex items-center",children:"Berlin"})})]}),e.jsx(K,{translate:a})]})})]}),e.jsx(_,{control:d.control,name:"userEmail",render:({field:t})=>e.jsxs(q,{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(Zs,{className:"w-4 h-4"}),a("checkoutPage.contact.email")]}),e.jsx(J,{children:e.jsx($,{...t,type:"email",placeholder:a("checkoutPage.contact.emailPlaceholder"),"data-testid":"input-email"})}),e.jsx(K,{translate:a})]})}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 -mt-1",children:r==="de"?"Wir nutzen deine Kontaktdaten nur zur Koordination deiner Reparatur.":"We only use your contact details to coordinate your repair."}),e.jsx(_,{control:d.control,name:"referralSource",render:({field:t})=>e.jsxs(q,{children:[e.jsx(D,{children:a("checkoutPage.contact.referral")}),e.jsx(J,{children:e.jsx($,{...t,placeholder:a("checkoutPage.contact.referralPlaceholder"),"data-testid":"input-referral"})}),e.jsx(K,{translate:a})]})})]})})]}),i==="premium"&&e.jsxs(e.Fragment,{children:[e.jsxs(T,{className:"p-6",children:[e.jsxs("h3",{className:"font-semibold mb-4 flex items-center gap-2 text-gray-900 dark:text-gray-100",children:[e.jsx(os,{className:"w-4 h-4"}),a("checkoutPage.address.title")]}),e.jsx(us,{...d,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(_,{control:d.control,name:"userAddress",render:({field:t})=>e.jsxs(q,{children:[e.jsx(D,{children:a("checkoutPage.address.street")}),e.jsx(J,{children:e.jsx($,{...t,placeholder:a("checkoutPage.address.streetPlaceholder"),"data-testid":"input-address"})}),e.jsx(K,{translate:a})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(_,{control:d.control,name:"userCity",render:({field:t})=>e.jsxs(q,{children:[e.jsx(D,{children:a("checkoutPage.address.city")}),e.jsx(J,{children:e.jsx($,{...t,placeholder:"Berlin","data-testid":"input-city"})}),e.jsx(K,{translate:a})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Me,{htmlFor:"deliveryZipCode",className:"text-sm font-medium flex items-center gap-1",children:[e.jsx(ns,{className:"w-3 h-3"}),r==="de"?"PLZ für Abholung":"Pickup ZIP Code",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx($,{id:"deliveryZipCode",type:"text",value:g,onChange:t=>{const n=t.target.value.replace(/\D/g,"").slice(0,5);Ns(n),n.length===5?Ze(n):oe("")},onBlur:()=>Ze(g),placeholder:"10115",className:ne?"border-red-500":"","data-testid":"input-delivery-zipcode"}),ne&&e.jsxs("div",{className:"flex items-start gap-2 text-red-500 text-xs mt-1",children:[e.jsx(Bs,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:ne})]}),g&&!ne&&Pe[g]&&e.jsxs("div",{className:"flex items-center gap-1 text-gray-700 text-xs mt-1",children:[e.jsx(ps,{className:"w-3 h-3"}),e.jsx("span",{children:Pe[g].district})]})]})]})]})})]}),e.jsxs(T,{className:"p-6",children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2 text-gray-900 dark:text-gray-100",children:[e.jsx(xs,{className:"w-4 h-4"}),a("checkoutPage.appointment.title")]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs(Me,{className:"text-sm font-medium mb-1.5 block flex items-center gap-1",children:[a("checkoutPage.appointment.date"),e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Qs,{open:be,onOpenChange:je,children:[e.jsx(et,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:`w-full justify-start text-left font-normal h-10 ${w?"":"text-muted-foreground"}`,"data-testid":"input-date",children:[e.jsx(xs,{className:"mr-2 h-4 w-4"}),w?Ve(w,r==="de"?"d. MMMM yyyy":"MMMM do, yyyy",{locale:r==="de"?fs:ys}):e.jsx("span",{children:a("checkoutPage.appointment.selectDate")})]})}),e.jsx(st,{className:"w-auto p-0",align:"start",children:e.jsx(Xs,{mode:"single",selected:w,onSelect:t=>{ve(t),je(!1)},disabled:t=>{const n=new Date;return n.setHours(0,0,0,0),t<n||gs(t)},locale:r==="de"?fs:ys,initialFocus:!0})})]})]}),e.jsxs("div",{children:[e.jsxs(Me,{className:"text-sm font-medium mb-1.5 block flex items-center gap-1",children:[a("checkoutPage.appointment.time"),e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(cs,{value:z,onValueChange:Ae,children:[e.jsx(ls,{className:"w-full h-10","data-testid":"select-time",children:e.jsx(ds,{placeholder:a("checkoutPage.appointment.selectTime")})}
1),e.jsxs(ms,{children:[e.jsx(ye,{value:"09:00 to 13:00",className:"min-h-[44px] flex items-center",children:"09:00 to 13:00"}),e.jsx(ye,{value:"11:00 to 15:00",className:"min-h-[44px] flex items-center",children:"11:00 to 15:00"}),e.jsx(ye,{value:"13:00 to 17:00",className:"min-h-[44px] flex items-center",children:"13:00 to 17:00"}),e.jsx(ye,{value:"15:00 to 19:00",className:"min-h-[44px] flex items-center",children:"15:00 to 19:00"}),e.jsx(ye,{value:"17:00 to 21:00",className:"min-h-[44px] flex items-center",children:"17:00 to 21:00"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-3 flex items-center gap-1",children:[e.jsx(We,{className:"w-3 h-3"}),a("checkoutPage.appointment.helperText")]})]})]})]}),i?e.jsxs("div",{className:"lg:sticky lg:top-20 lg:self-start space-y-6",children:[e.jsxs(T,{className:"p-5 border-gray-200 dark:border-gray-700",children:[e.jsx("h3",{className:"font-semibold text-sm text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-3",children:r==="de"?"Deine Reparatur":"Your Repair"}),e.jsxs("div",{className:"space-y-2.5 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:r==="de"?"Gerät":"Device"}),e.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:[s.deviceAnalysis.brand," ",s.deviceAnalysis.model]})]}),e.jsxs("div",{className:"flex justify-between items-start gap-4",children:[e.jsx("span",{className:"text-gray-500 shrink-0",children:r==="de"?"Problem":"Issue"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 text-right max-w-[65%]",children:s.deviceAnalysis.issue})]}),(Xe=s.shopInfo)!=null&&Xe.name?e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:r==="de"?"Werkstatt":"Shop"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.shopInfo.name})]}):null,e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Service"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:i==="premium"?r==="de"?"🚚 Abholung & Lieferung":"🚚 Pickup & Delivery":r==="de"?"🏪 Selbst vorbeibringen":"🏪 Self Drop-off"})]}),s.costEstimate&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:r==="de"?"Reparaturkosten (ca.)":"Est. repair cost"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:Be(s.costEstimate.min,s.costEstimate.max)})]}),e.jsxs("div",{className:"flex justify-between pt-2.5 border-t border-gray-100 dark:border-gray-800",children:[e.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100",children:r==="de"?"Heute fällig":"Due today"}),e.jsx("span",{className:"font-bold text-gray-900 dark:text-gray-100 text-base",children:i==="premium"?f(g||((Qe=s.userInfo)==null?void 0:Qe.zipCode)||"",r,s.deviceAnalysis.deviceType):A(s.deviceAnalysis.deviceType,"basic",r)})]}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:r==="de"?"Reparaturkosten werden erst nach Diagnose berechnet.":"Repair cost is charged only after diagnosis."})]})]}),e.jsxs(T,{className:"p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-sm mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500",children:a("checkoutPage.device.type")}),e.jsx("span",{className:"font-medium",children:(()=>{const t=pt(s.deviceAnalysis.deviceType);return t?a(t):s.deviceAnalysis.deviceType})()})]}),e.jsx("div",{className:"text-gray-300 dark:text-gray-700 hidden sm:block",children:"•"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500",children:a("checkoutPage.device.model")}),e.jsxs("span",{className:"font-medium",children:[s.deviceAnalysis.brand," ",s.deviceAnalysis.model]})]}),e.jsx("div",{className:"text-gray-300 dark:text-gray-700 hidden sm:block",children:"•"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500",children:a("checkoutPage.device.issue")}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 break-words",children:s.deviceAnalysis.issue})]})]}),(()=>{const t=Ws(s.deviceAnalysis.deviceType,s.deviceAnalysis.brand,s.deviceAnalysis.model),n=t.eWastePrevented>=1?`${t.eWastePrevented.toFixed(1)}kg`:`${Math.round(t.eWastePrevented*1e3)}g`;return e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-3 border-t border-gray-100 dark:border-gray-800",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(lt,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"}),e.jsxs("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:["€",t.costSavings.toLocaleStr
1ing()]})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:a("checkoutPage.device.saved")})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(Ms,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"}),e.jsxs("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:[t.timeSavings,"h"]})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:a("checkoutPage.device.timeSaved")})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-1",children:[e.jsx(Vs,{className:"w-3 h-3 text-gray-700 dark:text-gray-400"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:n})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:a("checkoutPage.device.ewaste")})]})]})})()]}),s.costEstimate&&e.jsxs(T,{className:"p-6 bg-gradient-to-br from-stone-50 to-teal-50 dark:from-gray-950/30 dark:to-teal-950/30 border-stone-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx($s,{className:"w-5 h-5 text-gray-700 dark:text-gray-400"}),e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100",children:a("checkoutPage.cost.estimated")})]}),e.jsx("div",{className:"text-3xl font-bold text-gray-800 dark:text-gray-400",children:Be(s.costEstimate.min,s.costEstimate.max)}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-2",children:a("checkoutPage.cost.finalPrice")})]}),e.jsx(T,{className:"p-6 border-gray-200 dark:border-gray-800",children:e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx(_s,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-1",children:a("checkoutPage.issue.title")}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-3",children:a("checkoutPage.issue.reviewEdit")}),e.jsx(qs,{value:Ue,onChange:t=>{const n=t.target.value;if(v(n),s){const c={...s,deviceAnalysis:{...s.deviceAnalysis,issue:n}};se(c),sessionStorage.setItem("bookingData",JSON.stringify(c))}},placeholder:a("checkoutPage.issue.placeholder"),rows:3,className:"w-full","data-testid":"textarea-issue"})]})]})}),e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 py-2 list-none",children:[e.jsx(Ds,{className:"w-4 h-4"}),e.jsx("span",{children:r==="de"?"Fotos hinzufügen (optional)":"Add photos (optional)"}),H.length>0&&e.jsx("span",{className:"text-xs bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 px-2 py-0.5 rounded-full",children:H.length})]}),e.jsxs(T,{className:"p-4 mt-2 border-stone-200 dark:border-stone-700 bg-stone-50/30 dark:bg-stone-950/10",children:[e.jsx("input",{type:"file",accept:"image/*,.heic,.heif",multiple:!0,onChange:t=>{t.target.files&&Se(Array.from(t.target.files))},className:"w-full text-sm file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-gray-100 file:text-gray-700 hover:file:bg-gray-200 dark:file:bg-gray-800 dark:file:text-gray-300","data-testid":"input-photos"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:r==="de"?"Oder sende später via WhatsApp/Email":"Or send later via WhatsApp/Email"})]})]}),e.jsxs(T,{className:"p-6 bg-gray-50 dark:bg-gray-900/50",children:[e.jsx("h3",{className:"font-semibold mb-4 text-gray-900 dark:text-gray-100",children:a("checkoutPage.summary.title")}),e.jsx("div",{className:"space-y-3 text-sm",children:(()=>{var y,j,P;const t=g||((y=s==null?void 0:s.userInfo)==null?void 0:y.zipCode)||"",n=i==="premium"?E(t,((j=s==null?void 0:s.deviceAnalysis)==null?void 0:j.deviceType)||""):S(((P=s==null?void 0:s.deviceAnalysis)==null?void 0:P.deviceType)||"","basic"),c=Fe(n),o=n-c,u=o>0,m=c/1.19,x=c-m;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:a("checkoutPage.summary.bookingFeeNet")}),e.jsxs("span",{className:"font-medium",children:["€",m.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:a("checkoutPage.summary.vat")}),e.jsxs("span",{className:"font-medium",children:["€",x.toFixed(2)]})]}),i==="premium"&&e.jsx("div",{className:"flex justify-between text-xs text-gray-500",children:e.jsx("span",{children:a("checkoutPage.summary.inclPickupDelivery")})}),u&&e.jsxs("div",{className:"flex justify-between text-stone-600 dar
1k:text-stone-400",children:[e.jsx("span",{children:a("payment.promo.discount")}),e.jsxs("span",{className:"font-medium",children:["-€",o.toFixed(2)]})]}),e.jsxs("div",{className:"border-t pt-3 flex justify-between text-lg font-bold",children:[e.jsx("span",{children:a("checkoutPage.summary.total")}),e.jsxs("span",{className:u?"text-stone-700 dark:text-stone-300":"",children:[u&&e.jsxs("span",{className:"text-sm line-through text-gray-400 mr-2",children:["€",n.toFixed(2)]}),"€",c.toFixed(2)]})]})]})})()})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-600 dark:text-gray-400 py-3 px-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:[e.jsx(ps,{className:"w-4 h-4 text-gray-700 flex-shrink-0"}),e.jsx("span",{children:r==="de"?"Nach Zahlung: Werkstatt wird sofort benachrichtigt → Diagnose → Reparatur":"After payment: Shop notified instantly → Diagnosis → Repair"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500 dark:text-gray-400 py-3 px-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg",children:[e.jsx(We,{className:"w-4 h-4 text-amber-600 flex-shrink-0"}),e.jsx("span",{children:r==="de"?"Servicegebühr: 10% der Reparaturkosten (nur bei erfolgreicher Reparatur)":"Service fee: 10% of repair cost (only on successful repairs)"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(ks,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:r==="de"?"Sichere Zahlung • Kein Konto nötig":"Secure payment • No account needed"})]}),U?e.jsxs(T,{className:"p-6",children:[e.jsx("h3",{className:"font-semibold mb-4 text-gray-900 dark:text-gray-100",children:a("checkoutPage.payment.title")}),(!d.formState.isValid||i==="premium"&&(!g||ne))&&e.jsx("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md text-sm text-yellow-800 dark:text-yellow-400 mb-4",children:i==="premium"&&(!g||ne)?r==="de"?"Bitte geben Sie eine gültige Berliner PLZ für die Abholung ein.":"Please enter a valid Berlin ZIP code for pickup.":a("checkoutPage.error.fillRequired")}),e.jsx(tt,{stripe:dt,options:{clientSecret:U,appearance:{theme:"stripe"},locale:r==="de"?"de":"en"},children:e.jsx(mt,{bookingData:{...s,tier:i,bookingFee:Fe(i==="premium"?E(g||((es=s==null?void 0:s.userInfo)==null?void 0:es.zipCode)||"",((ss=s==null?void 0:s.deviceAnalysis)==null?void 0:ss.deviceType)||""):S(((ts=s==null?void 0:s.deviceAnalysis)==null?void 0:ts.deviceType)||"","basic")),deliveryZipCode:i==="premium"?g:void 0,userInfo:{...s.userInfo,...d.getValues(),name:d.getValues().userName,email:d.getValues().userEmail,phoneNumber:d.getValues().userPhone||void 0,address:i==="premium"?d.getValues().userAddress:void 0,city:i==="premium"?d.getValues().userCity:void 0},appointment:i==="premium"&&w&&z?{date:Ve(w,"yyyy-MM-dd"),timeSlot:z}:null},additionalPhotos:H,onSuccess:Is,zipBlocked:i==="premium"&&!Ke(g),onValidateZip:i==="premium"?()=>Ze(g):void 0})})]}):e.jsxs(T,{className:"p-6",children:[e.jsx("h3",{className:"font-semibold mb-4 text-gray-900 dark:text-gray-100",children:a("checkoutPage.payment.title")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(_e,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-500",children:r==="de"?"Zahlungsmethode":"Payment Method"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-14 bg-gray-100 dark:bg-gray-800 rounded-lg animate-pulse"}),e.jsx("div",{className:"h-14 bg-gray-100 dark:bg-gray-800 rounded-lg animate-pulse"}),e.jsx("div",{className:"h-14 bg-gray-100 dark:bg-gray-800 rounded-lg animate-pulse"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 pt-4",children:[e.jsx(Oe,{className:"w-4 h-4 animate-spin text-gray-700"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:a("checkoutPage.payment.preparing")})]})]})]})]}):e.jsx("div",{className:"space-y-6",children:e.jsx(T,{className:"p-6 border-yellow-200 dark:border-yellow-800 bg-yellow-50/30 dark:bg-yellow-950/10",children:e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:a("checkoutPage.tier.selectFirst")})})})})]}),e.jsx("div",{className:"mt-8 text-center pb-24 md:pb-0",children:e.jsx(G,{onClick:()=>h(N("/repair/select-service",r)),variant:"outline","data-testid":"button-back",children:a("checkoutPage.button.back")})})]})}),i&&e.jsxs("div",{className:"lg:hidden fixed bottom-0 left-0 right-0 z-40 bg-white dark:bg-gray-950 border-t border-gray-200 dark:border-gray-800 px-4 py-3 flex items-center gap-3 shadow-[0_-4px_16px_rgba(0,0,0,0.08)]",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-gray-500 truncate",children:i==="premium"?r==="de"?"🚚 Abholung & Lieferung":"🚚 Pickup & Delivery":r==="de"?"🏪 Selbst vorbeibringen":"🏪 Self Drop-off"}),e.jsxs("p",{className:"text-sm font-bold text-gray-900 dark:text-gray-100",children:[i==="premium"?f(g||((rs=s.userInfo)==null?void 0:rs.zipCode)||"",r,s.deviceAnalysis.deviceType):A(s.deviceAnalysis.deviceType,"basic",r)," ",e.jsx("span",{className:"font-normal text-xs text-gray-500",children:r==="de"?"heute":"today"})]})]}),e.jsx(G,{className:"bg-black hover:bg-gray-800 dark:bg-white dark:text-black dark:hover:bg-gray-200 shrink-0 h-11 px-5 text-sm font-semibold",onClick:async()=>{var u;const t=await d.trigger(),n=document.querySelector('[data-testid="button-pay"]'),c=(u=document.querySelector('[data-testid="button-pay"]'))==null?void 0:u.closest(".space-y-6"),o=n||c;if(o&&o.scrollIntoView({behavior:"smooth",block:"center"}
1),!t){const m=document.querySelector('[aria-invalid="true"], .text-destructive');m&&m.scrollIntoView({behavior:"smooth",block:"center"})}},children:r==="de"?"Jetzt buchen →":"Book now →"})]})]}):e.jsx("div",{className:"min-h-screen bg-white dark:bg-black flex items-center justify-center",children:e.jsx(Oe,{className:"w-12 h-12 animate-spin text-gray-400"})})}export{Lt 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.