1import{j as e,d as q,c as G,r as o}from"./vendor-react-CwobwNtT.js";import{ah as W,C as J,J as C,Q,f as R,ap as Y,ak as K,aB as V,O as X}from"./index-u3Hw4B3k.js";import{a as Z,b as m,u as ee,B as j,c as T,T as te,S as se}from"./PassengersSkeleton-D_YnZftg.js";import{T as ae}from"./TripSummary-BBl0WR5U.js";import{P as re,a as P,r as ne}from"./repriceRequest-CRHOXA-F.js";import{g as k}from"./useSelectFlight-zR5JK-tS.js";import{h as ie,p as oe,b as ce,m as le,i as de,t as E,a as A,c as pe}from"./ancillary-D-YTZYP2.js";import{c as me,b as ue}from"./journeyPresence-DJeaVXA6.js";import"./vendor-sentry-Du8NRRv8.js";import"./vendor-motion-Crkh7Uo1.js";import"./AirlineLogo-DlFp5BA1.js";import"./fareTerms-C7SGMljK.js";import"./RefundIcon-DBbjBAJZ.js";function xe(){return e.jsxs("div",{className:"mt-3 rounded-[14px] bg-app-sunken p-3.5",children:[e.jsx(m,{width:170,height:18,className:"mb-1.5"}),e.jsxs("div",{className:"flex flex-wrap gap-x-6 gap-y-1",children:[e.jsx(m,{width:110,height:21}),e.jsx(m,{width:100,height:21})]})]})}function fe(){return e.jsxs("div",{"aria-hidden":"true",children:[e.jsx(Z,{}),e.jsxs("div",{className:"zgb-panel",style:{marginTop:20},children:[e.jsx(m,{width:90,height:24}),e.jsx(xe,{}),e.jsx(m,{width:"85%",height:22,className:"mt-3.5"})]}),e.jsxs("div",{className:"zgb-panel",style:{marginTop:20},children:[e.jsx(m,{width:70,height:24}),e.jsx(m,{width:"70%",height:22,className:"mt-3"})]})]})}const he=1e3;function O(i){return i.charAt(0).toUpperCase()+i.slice(1).replace(/_/g," ")}function B({option:i,selected:r,onToggle:l}){const{amount:c,currency:f}=A(i);return e.jsxs("label",{className:`mb-2 flex cursor-pointer items-center gap-3 rounded-[12px] border p-3 transition-colors ${r?"border-[rgb(0,125,187)] bg-[rgba(0,125,187,0.06)]":"border-stroke bg-white"}`,children:[e.jsx("input",{type:"checkbox",checked:r,onChange:l,className:"h-4 w-4 shrink-0 accent-[rgb(0,125,187)]"}),e.jsx("span",{className:"min-w-0 flex-1 text-[14px] text-neutral-30",children:i.description}),e.jsx("span",{className:"shrink-0 text-[14px] font-bold text-neutral-30",children:R(c,f)})]})}function Ee(){const i=q(),r=W(),l=r.get("offer")??"",{draftId:c=""}=G(),f=r.get("flight")??"",[I,L]=o.useState(l),[$,y]=o.useState("checking"),N=k(l),d=!!N&&ie(N);o.useEffect(()=>{let s=!1;async function a(){if(d)return;const n=C(new URLSearchParams(r)).form,x=k(l),p=await ne({offerId:l,flightId:f,fallbackOrigin:n.from,fallbackDestination:n.to,search:n,fallbackDepartureDate:K(x?.slices?.[0]?.segments?.[0]?.departure)??V(),onCacheHitDelay:()=>new Promise(b=>window.setTimeout(b,he))});if(!s){if(p.status==="error"){i(`/flights/book/${c}/passengers?${r.toString()}`,{replace:!0,state:{submitError:p.error.message,fareUnavailable:p.error.code==="FLIGHT_NOT_FOUND_AT_NEW_PASSENGER_COUNT"}});return}if(p.status==="skipped"){y("done");return}if(p.changed){const b=new URLSearchParams(r);b.set("offer",p.offerId),i(`/flights/book/${c}/extras?${b.toString()}`,{replace:!0})}L(p.offerId),y("done")}}return a(),()=>{s=!0}},[l,f,d]);const t=k(I),M=ee(t),{user:U}=J(),{coupons:D,ready:F}=me(t?.price.currency,U?.uid),[u,S]=o.useState(()=>{const s={};for(const a of oe(r.get("services")))s[a.service_id]=a.quantity;return{services:s}}),h=o.useMemo(()=>t?ce(t):[],[t]),g=o.useMemo(()=>t?le(t):[],[t]),_=o.useMemo(()=>t?de(t):{},[t]),z=o.useMemo(()=>C(new URLSearchParams(r)).form,[r]),w=o.useMemo(()=>t&&(t.slices?.find(s=>s.fare_brand)?.fare_brand||t.fare_type)||null,[t]),v=o.useMemo(()=>t?[...h.flatMap(a=>a.options),...g.flatMap(a=>a.options)].filter(a=>u.services[a.service_id]):[],[t,h,g,u]);o.useEffect(()=>{!t||d||Q(`extras:${c}`,"extras_viewed",{booking_id:c,offer_id:t.offer_id})},[t?.offer_id,d]);const H=()=>{X("extras_submitted",{booking_id:c,offer_id:t?.offer_id,extras_count:v.length});const s=new URLSearchParams(r),a=pe(u).map(n=>`${n.service_id}:${n.quantity}`).join(",");a?s.set("services",a):s.delete("services"),i(`/flights/book/${c}/payment?${s.toString()}`)};return o.useEffect(()=>{if(!d)return;const s=new URLSearchParams(r);s.delete("services"),i(`/flights/book/${c}/payment?${s.toString()}`,{replace:!0})},[d,c,i,r]),d?e.jsxs(j,{title:"Complete your booking",currentStep:"payment",skipSteps:["extras"],children:[e.jsx("p",{role:"status","aria-live":"polite",className:"sr-only",children:"Confirming your fareâ¦"}),e.jsx(re,{}),e.jsx(P,{route:{from:r.get("from"),to:r.get("to")},stage:"fare"})]}):$==="checking"?e.jsxs(j,{title:"Add extras",currentStep:"extras",onBack:()=>i(-1),children:[e.jsx("p",{role:"status","aria-live":"polite",className:"sr-only",children:"Confirming your fareâ¦"}),e.jsx(T,{summary:e.jsx(te,{}),children:e.jsx(fe,{})}),e.jsx(P,{route:{from:r.get("from"),to:r.get("to")},stage:"fare"})]}):t?e.jsx(j,{title:"Add extras",subtitle:"Bags and meals for this trip",currentStep:"extras",onBack:()=>i(-1),holdSecondsLeft:M,children:e.jsxs(T,{summary:e.jsx(ae,{rows:[...w?[{label:"Fare",value:w}]:[],{label:"Travelers",value:Y(z)}],lines:v.map(s=>{const{amount:a,currency:n}=A(s);return{label:s.description,value:R(a,n)}}),total:t.price.customer_total,totalCurrency:t.price.currency,totalLabel:"Total",coupon:ue(D,t.price.customer_total,t.price.currency),pricePending:!F,note:v.length===0?"Extras are optional â you can continue without any.":"Added to your fare. The final amount is confirmed at payment.",cta:H,ctaLabel:"Continue to payment"}),children:[e.jsx(se,{slices:t.slices??[],airline:t.airline}),e.jsxs("div",{className:"zgb-panel",children:[e.jsx("h2",{className:"text-[16px] font-extrabold text-neutral-30",children:"Baggage"}),e.jsxs("div",{className:"mt-3 rounded-[14px] bg-app-sunken p-3.5",children:[e.jsx("div",{className:"text-[12px] font-extrabold uppercase tracking-[0.05em] text-app-muted",children:"Included with your fare"}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-x-6 gap-y-1 text-[14px] text-neutral-30",children:[e.jsxs("span",{children:[e.jsx("b",{className:"font-bold",children:"Checked:"})," ",_.checked??"Not stated"]}),e.jsxs("span",{children:[e.jsx("b",{className:"font-bold",children:"Cabin:"})," ",_.cabin??"Not stated"]})]})]}),h.length===0?e.jsx("p",{className:"mt-3.5 text-[13px] leading-[1.7] text-neutral-20",children:"No extra baggage is available for this fare. Bags can be added at check-in."}):h.map(({leg:s,options:a})=>e.jsxs("div",{className:"mt-3.5",children:[e.jsx("div",{className:"mb-1.5 text-[12px] font-extrabold uppercase tracking-[0.05em] text-app-muted",children:O(s)}),a.map(n=>e.jsx(B,{option:n,selected:!!u.services[n.service_id],onToggle:()=>S(x=>E(x,n.service_id))},n.service_id))]},s))]}),e.jsxs("div",{className:"zgb-panel",children:[e.jsx("h2",{className:"text-[16px] font-extrabold text-neutral-30",children:"Meals"}),g.length===0?e.jsx("p",{className:"mt-3 text-[13px] leading-[1.7] text-neutral-20",children:"No meals are available to pre-order for this fare."}):g.map(({leg:s,options:a})=>e.jsxs("div",{className:"mt-3.5",children:[e.jsx("div",{className:"mb-1.5 text-[12px] font-extrabold uppercase tracking-[0.05em] text-app-muted",children:O(s)}),a.map(n=>e.jsx(B,{option:n,selected:!!u.services[n.service_id],onToggle:()=>S(x=>E(x,n.service_id))},n.service_id))]},s))]})]})}):e.jsx(j,{title:"Add extras",currentStep:"extras",onBack:()=>i(-1),children:e.jsxs("div",{className:"zgb-panel",children:[e.jsx("p",{className:"text-[15px] font-semibold text-neutral-30",children:"This booking has expired"}),e.jsx("p",{className:"mt-2 text-[14px] leading-[1.7] text-neutral-20",children:"We no longer have the confirmed fare for this trip. Search again to pick it up."}),e.jsx("button",{type:"button",onClick:()=>i("/flights"),className:"mt-4 rounded-full px-5 py-2.5 text-[14px] font-bold text-white",style:{background:"var(--zg-button-primary-bg)"},children:"Start a new search"})]})})}export{Ee 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.