PageSourceSearch

https://wbk-assets.webook.com/0.7.8/assets/@wbk/flights-zxddM6AH.js

js webook.com collected 2026-09-25 15:15:04 UTC 194,324 bytes, 1 lines download raw bytes

1import{r as b}from"../vendor-Cc9w-i99.js";import{C as Ve,I as te,N as Oa,i as ke,k as We,O as Kt,P as Ge,s as De,e as B,R as Yt,j as e,S as Ba,o as At,w as Va,T as et,u as je,U as Pe,V as Qt,W as Tt,G as Za,H as Ha,X as za,Y as ea}from"./hooks-BlLlWTp9.js";import{u as Y}from"./analytics-DE0c17Pa.js";import{a as X,b as S,k as pt,e as Xa,T as xt,L as Fe,c as qa,d as Ua}from"./config-CNzyBjC_.js";import{u as tt,F as ft,a as de,C as K,b as Wa}from"../react-hook-form-D_m77UuM.js";import{R as Ae,B as L,T as d,f as at,I as ye,S as ta,t as G,P as ae,n as aa,g as Ga,C as Ja,o as Ka,p as sa,D as ie,q as Ya,r as la,s as Pt,L as Qa,u as Ee,m as es,v as ts,w as as,c as ss,x as ls,d as ns,a as rs,M as st,l as na,H as is,b as ra,F as os}from"./ui-Bq7l3oiK.js";import{a8 as lt,E as Me,a9 as $e,aa as Ie,u as cs,ab as ds,ac as vt,ad as ms,C as Le,ae as He,af as Be,a as ge,z as _t,ag as us,o as hs,ah as gs,ai as ps,k as xs,j as Ne,m as be,r as yt,aj as jt,f as Te,ak as ut,M as ia,W as fs,al as vs,c as _s,am as Mt}from"./svg-HUfKeBgT.js";import{M as ys,N as js,O as bs,P as Ns,Q as It,R as oa,S as ws,T as Cs,U as ks,V as ht,W as ca,X as da,Y as ma,Z as ua,_ as Ss,$ as Ds,a0 as Ls}from"./queue-DaHNt4dN.js";import{C as Q,u as Fs}from"./currency-B7PYjEev.js";import{useAuth as bt,AuthForm as As}from"./auth-AbxUcDmb.js";import{u as Nt,P as Ts,W as Ps,a as Et,b as Ms,B as Is}from"./payment-CMegBHo6.js";import{E as Es}from"./logger-DfNVpG3P.js";import"./api-BgBdL-BO.js";var $s=Object.defineProperty,Rs=Object.defineProperties,Os=Object.getOwnPropertyDescriptors,Je=Object.getOwnPropertySymbols,ha=Object.prototype.hasOwnProperty,ga=Object.prototype.propertyIsEnumerable,$t=(t,a,s)=>a in t?$s(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,F=(t,a)=>{for(var s in a||(a={}))ha.call(a,s)&&$t(t,s,a[s]);if(Je)for(var s of Je(a))ga.call(a,s)&&$t(t,s,a[s]);return t},Z=(t,a)=>Rs(t,Os(a)),ee=(t,a)=>{var s={};for(var l in t)ha.call(t,l)&&a.indexOf(l)<0&&(s[l]=t[l]);if(t!=null&&Je)for(var l of Je(t))a.indexOf(l)<0&&ga.call(t,l)&&(s[l]=t[l]);return s},ve=(t,a,s)=>new Promise((l,n)=>{var r=c=>{try{u(s.next(c))}catch(m){n(m)}},i=c=>{try{u(s.throw(c))}catch(m){n(m)}},u=c=>c.done?l(c.value):Promise.resolve(c.value).then(r,i);u((s=s.apply(t,a)).next())}),Bs={firstName:"",lastName:"",email:"",phone:"",country:Ve[0]},Rt={passengersList:[],contactDetails:Bs,checkoutError:null,checkoutLoading:!1},pa=b.createContext({summaryMode:"flight_summary",totals:{gross:0,vat:0,tax:0,net:0},setSummaryMode:()=>{},checkout:()=>ve(null,null,function*(){})});function ne(){const t=b.useContext(pa);if(!t)throw new Error("useBooking must be used within a BookingProvider");return t}var we={connectionType:"round_trip",legs:[{arrivalAirport:void 0,departureAirport:void 0,outboundDate:te({date:new Date,interval:"day",value:1})},{arrivalAirport:void 0,departureAirport:void 0,outboundDate:te({date:new Date,interval:"day",value:2})}],class:"economy",adultsCount:1,childrenCount:0,infantsCount:0},xa=()=>{var t,a;const s=Oa(new URLSearchParams(window.location.search).get("search")||""),l=ke("flightsSearch"),n=We(s)||JSON.parse(l||"{}");let r=(a=(t=n.legs)==null?void 0:t[0])==null?void 0:a.outboundDate;return r=!r||new Date(r).getTime()<new Date().getTime()?new Date(new Date().setHours(0,0,0,0)):new Date(r),{connectionType:(n==null?void 0:n.connectionType)||we.connectionType,excludedAirport:n.excludedAirport,legs:n.legs?n.legs.map((i,u)=>{let c=new Date(i.outboundDate);return c=Kt(c,r)||Ge(r.getTime(),c.getTime())?c:te({date:r,value:u,interval:"day"}),{arrivalAirport:i.arrivalAirport,departureAirport:i.departureAirport,outboundDate:c}}):we.legs,adultsCount:(n==null?void 0:n.adultsCount)||we.adultsCount,childrenCount:(n==null?void 0:n.childrenCount)||we.childrenCount,infantsCount:(n==null?void 0:n.infantsCount)||we.infantsCount,class:(n==null?void 0:n.class)||we.class}},Vs=(t,a)=>t.connectionType===a.connectionType&&t.class===a.class&&t.adultsCount===a.adultsCount&&t.childrenCount===a.childrenCount&&t.infantsCount===a.infantsCount&&t.legs.every((s,l)=>{var n,r,i,u,c,m,o;return((n=s.departureAirport)==null?void 0:n.code)===((i=(r=a.legs[l])==null?void 0:r.departureAirport)==null?void 0:i.code)&&((u=s.arrivalAirport)==null?void 0:u.code)===((m=(c=a.legs[l])==null?void 0:c.arrivalAirport)==null?void 0:m.code)&&Kt(s.outboundDate,(o=a.legs[l])==null?void 0:o.outboundDate)}),oe=()=>{const[t,a]=b.useState(()=>{const c=We(ke("recentFlightSearch")||"[]"),m=new Date().setHours(0,0,0,0),o=c.filter(p=>{var g,h;return new Date((h=(g=p.legs)==null?void 0:g[0])==null?void 0:h.outboundDate).setHours(0,0,0,0)>=m});return o.length&&De("recentFlightSearch",JSON.stringify(o)),o}),{trackEvent:s}=Y(),{locale:l,push:n}=X(),r=xa();return{setSearch:c=>{var m,o;if(s({event:"flights_home_search_started",data:{class:c.class,flight_type:c.connectionType,passengers_count:c.adultsCount+c.childrenCount+c.infantsCount,origin:c.legs.map(p=>p.departureAirport),destination:c.legs.map(p=>p.arrivalAirport),departure_in_date:{start_date:B((m=c.legs[0])==null?void 0:m.outboundDate,l,{weekday:"short",day:"2-digit",month:"short"}),end_date:(o=c.legs[1])!=null&&o.outboundDate?B(c.legs[1].outboundDate,l,{weekday:"short",day:"2-digit",month:"short"}):void 0}}}),c.connectionType!=="multi_city"){const p=t.filter(h=>!Vs(h,c)),g=p.length>=3?[c,...p.slice(0,2)]:[c,...p];De("recentFlightSearch",JSON.stringify(g))}n(`/${l}/flights/search?search=${Yt(JSON.stringify(c))}`)},search:r,clearSearchHistory:()=>{a([]),De("recentFlightSearch",JSON.stringify([]))},recentSearch:t}},Ot={adult:{min:12,max:150},child:{min:2,max:12},infant:{min:0,max:2}},Zs=()=>{const{control:t,getValues:a,watch:s}=de(),{locale:l}=X(),{t:n}=S(["flight_common"]),r=s("date_of_birth"),i=a("passenger_type"),{minAgeAllowed:u,maxAgeAllowed:c}=b.useMemo(()=>{var g,h,v,f;const _=i;return{minAgeAllowed:(h=(g=Ot[_])==null?void 0:g.min)!=null?h:0,maxAgeAllowed:(f=(v=Ot[_])==null?void 0:v.max)!=null?f:150}},[i]),m=te({date:i==="adult"?new Date:te({date:new Date,value:1,interval:"day"}),value:-c,interval:"year"}),o=te({date:new Date,value:-u,interval:"year"}),p=b.useMemo(()=>{const g=r?new Date().getFullYear()-new Date(r).getFullYear():new Date().getFullYear(),h=g<12?"child":g<2?"infant":"adult",v=i||h,f=[{value:"MR",text:n("flight_common:personal_information.mr")},{value:"MRS",text:n("flight_common:personal_information.mrs")},{value:"MS",text:n("flight_common:personal_information.ms")}],_=[{value:"MR",text:n("flight_common:personal_information.mr")},{value:"MS",text:n("flight_common:personal_information.ms")}];return v==="adult"?f:_},[r,i,n]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(d,{as:"h2",variant:"heading-S",children:n("flight_common:personal_information.title")}),e.jsx(d,{color:"text-secondary",variant:"body-S",children:n("flight_common:personal_information.note")})]}),e.jsx(K,{rules:{required:n("flight_common:validation.required")},control:t,name:"title",render:g=>{var h=g,{field:v}=h,f=v,{onChange:_}=f,y=ee(f,["onChange"]),{fieldState:{error:x}}=h;return e.jsx(at,F({error:x==null?void 0:x.message,options:p,onChange:k=>{k&&_(k)},label:"",className:"flex h-9 min-w-fit max-w-fit items-center justify-center rounded-lg",type:"single"},y))}}),e.jsx(K,{name:"first_name",control:t,rules:{required:n("flight_common:validation.first_name.empty"),pattern:{value:/^[a-zA-Z\s]*$/i,message:n("flight_common:validation.first_name.invali
1d")},maxLength:{value:20,message:n("flight_common:validation.max_length",{max:20})},minLength:{value:2,message:n("flight_common:validation.min_length",{min:2})}},render:g=>{var h=g,{field:v}=h,f=ee(v,[]),{fieldState:{error:_}}=h;return e.jsx(ye,F({id:"firstName",placeholder:n("flight_common:personal_information.first_name"),label:n("flight_common:personal_information.first_name"),error:_==null?void 0:_.message},f))}}),e.jsx(K,{name:"middle_name",control:t,rules:{required:!1,pattern:{value:/^[a-zA-Z\s]*$/i,message:n("flight_common:validation.middle_name.invalid")},maxLength:{value:20,message:n("flight_common:validation.max_length",{max:20})},minLength:{value:2,message:n("flight_common:validation.min_length",{min:2})}},render:g=>{var h=g,{field:v}=h,f=ee(v,[]),{fieldState:{error:_}}=h;return e.jsx(ye,F({id:"middleName",placeholder:n("flight_common:personal_information.middle_name"),label:n("flight_common:personal_information.middle_name"),error:_==null?void 0:_.message},f))}}),e.jsx(K,{name:"last_name",control:t,rules:{required:n("flight_common:validation.last_name.empty"),pattern:{value:/^[a-zA-Z\s]*$/i,message:n("flight_common:validation.last_name.invalid")},maxLength:{value:20,message:n("flight_common:validation.max_length",{max:20})},minLength:{value:2,message:n("flight_common:validation.min_length",{min:2})}},render:g=>{var h=g,{field:v}=h,f=ee(v,[]),{fieldState:{error:_}}=h;return e.jsx(ye,F({id:"lastName",placeholder:n("flight_common:personal_information.last_name"),label:n("flight_common:personal_information.last_name"),error:_==null?void 0:_.message},f))}}),e.jsx(K,{name:"date_of_birth",control:t,rules:{required:n("flight_common:validation.date_of_birth.empty"),pattern:{value:/^\d{4}-\d{2}-\d{2}$/,message:n("flight_common:validation.date_of_birth.invalid")}},render:g=>{var h=g,{field:v}=h,f=ee(v,[]),{fieldState:{error:_}}=h;return e.jsx(ye,F({id:"dateOfBirth",type:"date",className:"uppercase",min:m==null?void 0:m.toISOString().split("T")[0],max:o==null?void 0:o.toISOString().split("T")[0],label:n("flight_common:personal_information.date_of_birth"),error:_==null?void 0:_.message},f))}}),e.jsx(K,{rules:{required:n("flight_common:validation.nationality.empty")},control:t,name:"nationality",render:g=>{var h=g,{field:v}=h,f=v,{onChange:_}=f,y=ee(f,["onChange"]),{fieldState:{error:x}}=h;return e.jsx(ta,F({id:"nationality",error:x==null?void 0:x.message,autoComplete:"off",onChange:k=>{_((k==null?void 0:k.value)||"")},label:n("flight_common:personal_information.nationality_in_passport"),portal:!1,placeholder:n("flight_common:personal_information.nationality"),options:Ve.map(k=>({id:k.code,value:k.code,text:k.name[l]||k.name.en,icon:e.jsx("img",{className:"shrink-0",src:`https://wbk-assets-backup.s3.eu-west-1.amazonaws.com/flags/w80/${k.code.toLowerCase()}.png`,width:20,height:14,alt:k.name.en})}))},y))}})]})},Hs=Zs,zs=[{id:"passport",value:"passport",text:"passport"},{id:"national_id",value:"national_id",text:"national_id"},{id:"iqama",value:"iqama",text:"iqama"}],Xs=({passengerType:t})=>{const{selectedFare:a}=ne(),{watch:s}=de(),l=s("documents"),n=b.useMemo(()=>{const m=t&&(a==null?void 0:a.passengerSettings[t].docType),o=Object.values(l).find(p=>!!(p!=null&&p.document_type));return!m||o&&(m!=null&&m.includes(o==null?void 0:o.document_type))?o==null?void 0:o.document_type:"passport"},[l,t,a==null?void 0:a.passengerSettings]),[r,i]=b.useState(n||"passport"),{t:u}=S(["flight_common"]),c=b.useMemo(()=>{var m;return a?(m=a==null?void 0:a.passengerSettings[t==null?void 0:t.toLocaleLowerCase()].docType)==null?void 0:m.map(o=>({id:o,value:o,text:u(`flight_common:travel_documents.${o}`)})):zs.map(o=>({id:o.id,value:o.value,text:u(`flight_common:travel_documents.${o.text}`)}))},[t,a,u]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(d,{as:"h2",variant:"heading-S",children:u("flight_common:travel_documents.title")}),e.jsx(d,{color:"text-secondary",variant:"body-S",children:u("flight_common:travel_documents.note")})]}),e.jsx(at,{className:"flex h-9 min-w-fit max-w-fit items-center justify-center text-nowrap rounded-lg",type:"single",label:"",disabled:(c==null?void 0:c.length)===1,options:c||[],onChange:m=>{m&&i(m)},value:r}),r==="iqama"?e.jsx(ot,{documentType:"iqama"},r):r==="national_id"?e.jsx(ot,{documentType:"national_id"},r):e.jsx(ot,{documentType:"passport"},r)]})},ot=({documentType:t})=>{const{selectedFare:a}=ne(),{locale:s}=X(),{t:l}=S(["flight_common"]),{control:n,trigger:r,watch:i}=de(),u=a==null?void 0:a.legs[a.legs.length-1],c=u==null?void 0:u.segments[
1(u==null?void 0:u.segments.length)-1],m=i(`documents.${t}.expiry_date`),o=te({date:new Date((c==null?void 0:c.arrivalDateTime)||new Date),interval:"day",value:1}).toISOString().split("T")[0],p=`${te({date:new Date((c==null?void 0:c.arrivalDateTime)||new Date),interval:"year",value:10}).getFullYear()}-12-31`,g=l(`flight_common:travel_documents.${t==="passport"?"passport_number":t==="national_id"?"national_id":"iqama_id"}`);return b.useEffect(()=>{m&&r(`documents.${t}.expiry_date`,{shouldFocus:!0})},[t]),e.jsxs(e.Fragment,{children:[e.jsx(K,{name:`documents.${t}.document_number`,control:n,rules:{required:l("flight_common:validation.document_number.empty"),pattern:{value:t!=="passport"?/^[0-9]*$/i:/^[a-zA-Z0-9]*$/i,message:l(`flight_common:validation.${t==="passport"?"alphabets_numbers_only":"numbers_only"}`)},maxLength:{value:t==="passport"?20:10,message:l("flight_common:validation.max_length",{max:t==="passport"?20:10})},minLength:{value:t==="passport"?4:10,message:l("flight_common:validation.min_length",{min:t==="passport"?4:10})}},render:h=>{var v=h,{field:f}=v,_=ee(f,[]),{fieldState:{error:y}}=v;return e.jsx(ye,F({id:"documentNumber",placeholder:g,label:g,error:y==null?void 0:y.message},_))}}),e.jsx(K,{name:`documents.${t}.issuing_country`,rules:{required:l("flight_common:validation.issuing_country.empty")},control:n,render:h=>{var v=h,{field:f}=v,_=f,{onChange:y}=_,x=ee(_,["onChange"]),{fieldState:{error:k}}=v;return e.jsx(ta,F({id:"issuingCountry",error:k==null?void 0:k.message,portal:!1,options:Ve.map(j=>({id:j.code,value:j.code,text:j.name[s]||j.name.en,icon:e.jsx("img",{className:"shrink-0",src:`https://wbk-assets-backup.s3.eu-west-1.amazonaws.com/flags/w80/${j.code.toLowerCase()}.png`,width:20,height:14,alt:j.name.en})})),placeholder:l("flight_common:travel_documents.issuing_country"),onChange:j=>y((j==null?void 0:j.value)||""),label:l("flight_common:travel_documents.issuing_country")},x))}}),e.jsx(K,{name:`documents.${t}.expiry_date`,rules:{required:l("flight_common:validation.expiry_date.empty"),validate:h=>{const v=h?new Date(h).getTime():new Date().getTime();if(Ge(v,new Date(o).getTime()))return l("flight_common:validation.expiry_date.min_date",{date:o});if(Ba(v,new Date(p).getTime()))return l("flight_common:validation.expiry_date.max_date",{date:p})},pattern:{value:/\d{4}-\d{2}-\d{2}/,message:l("flight_common:validation.expiry_date.invalid")}},control:n,defaultValue:"",render:h=>{var v=h,{field:f}=v,_=ee(f,[]),{fieldState:{error:y}}=v;return e.jsx(ye,F({id:"expiryDate",type:"date",min:o,max:p,className:"uppercase",label:l("flight_common:travel_documents.expiry_date"),error:y==null?void 0:y.message},_))}})]})},qs=Xs,Us=["first_name","middle_name","last_name","date_of_birth","nationality","documents"],Ws=({showTravelDocs:t,limitReached:a,onSuccess:s})=>{const{searchId:l,flightId:n}=ne(),{recentSearch:r}=oe(),{t:i}=S(["flight_common"]),{mutateAsync:u,error:c}=ys(),{mutateAsync:m,error:o}=js(),{handleSubmit:p,setValue:g,watch:h}=de(),{trackEvent:v}=Y(),f=h("id")||"",_=h("passenger_type"),{locale:y}=X(),x=f?o:c,k=N=>ve(null,null,function*(){var A,w,R,$;try{g("loading",!0);const M=Object.entries(N.documents).map(([D,C])=>Z(F({},C),{document_type:D})).filter(D=>!!D.document_number);if(f){const D=yield m(Z(F({},N),{id:f,documents:M,searchId:l,flightId:n}));return s(D)}const I=yield u(Z(F({},N),{documents:t?M:[]}));v({event:"flights_pax__details_traveller_added",data:{traveller_type:I.passenger_type,traveller_age:new Date().getFullYear()-new Date(I.date_of_birth).getFullYear(),traveller_gender:I.title==="MR"?"male":"female",nationality:I.nationality.code,destination:r.map(D=>D.legs[0].arrivalAirport),departure_in_date:{start_date:B((w=(A=r[0])==null?void 0:A.legs[0])==null?void 0:w.outboundDate,y,{weekday:"short",day:"2-digit",month:"short"}),end_date:($=(R=r[1])==null?void 0:R.legs[0])!=null&&$.outboundDate?B(r[1].legs[0].outboundDate,y,{weekday:"short",day:"2-digit",month:"short"}):void 0}}}),s(I)}catch{}finally{g("loading",!1)}}),j=N=>{Us.some(A=>
1N[A])&&Object.entries(N).forEach(([A,w])=>{v({event:"flights_pax__details_error_occurred",data:{section:`passenger_details_form.${A}`,error_message:(w==null?void 0:w.message)||""}})})};return e.jsx("form",{onSubmit:p(k,j),id:`passenger-form-${f}`,children:e.jsxs("div",{className:"space-y-8",children:[e.jsx(d,{variant:"heading-S",as:"h2",className:"text-center lg:ltr:text-left lg:rtl:text-right",children:_?i(`flight_common:${f?"edit":"add"}_type_passenger`,{type:i(`flight_common:${_}`)}):i("flight_common:add_passenger")}),a&&!f&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Me,{className:"text-error h-6 w-6"}),e.jsx(d,{color:"error",children:i("flight_common:passengers_limit_reached")})]}),e.jsx(Hs,{}),t&&e.jsx(qs,{passengerType:_}),(x==null?void 0:x.message)&&e.jsx(d,{color:"error",children:x.message})]})})},Gs=Ws,Js=({limitReached:t,initialPassenger:a,showTravelDocs:s,renderAction:l,onSuccess:n})=>{var r;const{t:i}=S(["flight_common"]),{trackEvent:u}=Y(),c=b.useMemo(()=>{let o,p,g;for(const h of(a==null?void 0:a.documents)||[])h.document_type==="passport"?o=h:h.document_type==="national_id"?p=h:h.document_type==="iqama"&&(g=h);return{passport:o?Z(F({},o),{issuing_country:o.issuing_country.code,document_type:"passport"}):void 0,national_id:p?Z(F({},p),{issuing_country:p.issuing_country.code,document_type:"national_id"}):void 0,iqama:g?Z(F({},g),{issuing_country:g.issuing_country.code,document_type:"iqama"}):void 0}},[a==null?void 0:a.documents]),m=tt({defaultValues:{id:(a==null?void 0:a.id)||"",title:a==null?void 0:a.title,passenger_type:a==null?void 0:a.passenger_type,first_name:(a==null?void 0:a.first_name)||"",middle_name:(a==null?void 0:a.middle_name)||"",last_name:(a==null?void 0:a.last_name)||"",date_of_birth:(a==null?void 0:a.date_of_birth)||"",nationality:((r=a==null?void 0:a.nationality)==null?void 0:r.code)||"",documents:c}});return e.jsx(ft,Z(F({},m),{children:e.jsx(Ae,{render:o=>l?l(o):e.jsxs(L,{theme:"action",type:"button",onClick:()=>{u({event:"flights_pax__details_add_pax_clicked"}),o.open()},children:[e.jsx(lt,{className:"h-2.5 w-2.5"}),e.jsx("span",{children:i("flight_common:add")})]}),body:({close:o})=>e.jsx(Gs,{limitReached:t,showTravelDocs:s,onSuccess:p=>{n&&n(p),o()}}),cancel:!1,size:"xl",action:{theme:"action",shape:"outlined",className:"w-full",type:"submit",form:`passenger-form-${(a==null?void 0:a.id)||""}`,loading:m.watch("loading"),disabled:t&&!(a!=null&&a.id)}})}))},Ke=Js,Bt={departureTime:[],arrivalTime:[],stops:[],airlines:[],departureAirports:[],arrivalAirports:[],priceRanges:[]},Se={search:we,departureFilters:Bt,returnFilters:Bt,sortBy:"cheapest",filteredFlights:[],flights:[]},Ks=({penalty:t,showPrice:a=!1,className:s})=>{var l,n,r;const{t:i}=S(["flight_common"]),u=((l=t.change)==null?void 0:l.price)>0;return t.refundableCode==="airline_policy"?e.jsxs("div",{className:G("flex gap-2 text-sm",s),children:[e.jsx(Me,{className:"mt-0.5 h-4 w-4 shrink-0 text-blue-500"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:airline_policy_applies_for_date_change")})]}):t.changeable?u?e.jsxs("div",{className:G("flex items-center gap-2 text-sm",s),children:[e.jsx(vt,{className:"h-4 w-4 shrink-0 text-blue-500"}),a?e.jsxs(e.Fragment,{children:[e.jsx(Q,{originalPrice:(n=t.change)==null?void 0:n.price,currency:(r=t.change)==null?void 0:r.currency}),e.jsx("span",{children:"+"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:fare_difference")})]}):e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:changeable_with_fees")})]}):e.jsxs("div",{className:G("flex items-center gap-2 text-sm",s),children:[e.jsx($e,{className:"h-4 w-4 shrink-0 text-green-500"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:changeable_without_fees")})]}):e.jsxs("div",{className:G("flex items-center gap-2 text-sm",s),children:[e.jsx(Ie,{className:"text-error h-4 w-4 shrink-0"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:non_changeable")})]})},fa=Ks,Ys=({penalty:t,showPrice:a=!1,className:s})=>{var l,n,r;const{t:i}=S(["flight_common"]),u=(l=t.cancellation)==null?void 0:l.price;switch(t.refundableCode){case"airline_policy":return e.jsxs("div",{className:G("flex items-center gap-2",s),children:[e.jsx(Me,{className:"h-4 w-4 shrink-0 text-blue-500"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:airline_policy_applies_for_cancellation")})]});case"non_refundable":return e.jsxs("div",{className:G("flex items-center gap-2",s),children:[e.jsx(Ie,{className:"text-error h-4 w-4 shrink-0"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:non_refundable")})]});case"refundable_with_penalty":return u>0?e.jsxs("div",{className:G("flex items-center gap-2",s),children:[e.jsx(vt,{className:"h-4 w-4 shrink-0 text-blue-500"}
1),a?e.jsx(Q,{originalPrice:u,currency:(n=t.cancellation)==null?void 0:n.currency}):e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:refundable_with_fees")})]}):e.jsxs("div",{className:G("flex items-center gap-2",s),children:[e.jsx($e,{className:"h-4 w-4 shrink-0 text-green-500"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:refundable_without_fees")})]});case"refundable_as_airline_credit":return u>0?e.jsxs("div",{className:G("flex gap-2",s),children:[e.jsx(cs,{className:"mt-0.5 h-4 w-4 shrink-0 text-blue-500"}),a?e.jsx(Q,{originalPrice:u,currency:(r=t.cancellation)==null?void 0:r.currency}):e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:partially_refundable_airline_credit")})]}):e.jsxs("div",{className:G("flex gap-2",s),children:[e.jsx(ds,{className:"mt-0.5 h-4 w-4 shrink-0 text-blue-500"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:fully_refundable_airline_credit")})]});case"refundable_with_credit":return e.jsxs("div",{className:G("flex items-center gap-2",s),children:[e.jsx(Ie,{className:"text-error h-4 w-4 shrink-0"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:non_refundable")})]});default:return e.jsxs("div",{className:G("flex gap-2",s),children:[e.jsx(Me,{className:"mt-0.5 h-4 w-4 shrink-0 text-blue-500"}),e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:airline_policy_applies_for_cancellation")})]})}},va=Ys,Qs=({departureCity:t,arrivalCity:a,penalty:s,className:l})=>{const{t:n}=S("flight_common");return e.jsxs(e.Fragment,{children:[t&&a&&e.jsxs("div",{className:"flex items-center gap-1 pb-3",children:[e.jsx(d,{children:t}),e.jsx(d,{className:"lowercase",children:n("flight_common:to")}),e.jsx(d,{children:a})]}),e.jsxs("div",{className:G("space-y-3",l),children:[e.jsx(va,{penalty:s}),e.jsx(fa,{penalty:s})]})]})},nt=Qs,el=({weight:t,pieces:a,unit:s,dimensions:l,type:n,className:r})=>{const{t:i}=S(["flight_common"]);return e.jsxs("div",{className:G("flex gap-2 text-sm",r),children:[t||a?e.jsx($e,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}):e.jsx(Ie,{className:"text-error mt-0.5 h-4 w-4 shrink-0"}),e.jsx("div",{children:!t&&!a?e.jsx(d,{variant:"body-S",className:"font-light",children:i(`flight_common:${n}_baggage_not_included`)}):e.jsxs(e.Fragment,{children:[n==="under_seat"&&e.jsx(d,{variant:"body-S",className:"font-light",children:i("flight_common:small_under_seat_baggage")}),!!t&&n!=="under_seat"&&e.jsxs(d,{variant:"body-S",className:"font-light",children:[t,s&&i(`flight_common:${s==null?void 0:s.toLocaleLowerCase()}`)," ",i(`flight_common:${n}_baggage`)]}),!!a&&e.jsxs(d,{variant:"body-S",className:`font-light ${t?"text-text-secondary":""}`,children:[i("flight_common:piece",{count:a})," ",!t&&i(`flight_common:${n}_baggage`)]}),!!l&&e.jsxs(d,{variant:"body-S",className:`font-light ${t?"text-text-secondary":""}`,children:["(",l,")"]})]})})]})},ct=el,tl=({baggage:t,className:a})=>e.jsxs("div",{className:G("space-y-3",a),children:[!!t.underSeatBaggage.weight&&e.jsx(ct,{dimensions:t.underSeatBaggage.dimensions,type:"under_seat",weight:t.underSeatBaggage.weight}),e.jsx(ct,{pieces:t.cabinBaggage.pieces,type:"cabin",weight:t.cabinBaggage.weight,unit:t.cabinBaggage.unit}),e.jsx(ct,{pieces:t.checkInBaggage.pieces,type:"checked_in",weight:t.checkInBaggage.weight,unit:t.checkInBaggage.unit})]}),ze=tl,wt=t=>e.jsx("svg",Z(F({width:"48",height:"49",viewBox:"0 0 48 49",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M38.6193 7.5C36.8954 7.5 35.2421 8.18482 34.0231 9.4038L28.144 15.2829C27.7356 15.6913 27.1288 15.829 26.5841 15.6367L10.0033 9.78467L7.76868 12.0193L19.7757 21.2555C20.1178 21.5187 20.33 21.9165 20.358 22.3472C20.386 22.778 20.227 23.1999 19.9218 23.5051L15.8107 27.6162C15.5294 27.8975 15.1479 28.0556 14.75 28.0556H11.2602L8.2079 31.1079L14.2489 33.3733C14.6546 33.5254 14.9746 33.8455 15.1267 34.2511L17.3921 40.2921L20.4445 37.2398V33.75C20.4445 33.3522 20.6025 32.9706 20.8838 32.6893L24.9949 28.5782C25.3001 28.273 25.7221 28.1141 26.1528 28.142C26.5835 28.17 26.9813 28.3822 27.2445 28.7243L36.4807 40.7313L38.7154 38.4967L32.8633 21.9159C32.6711 21.3712 32.8087 20.7645 33.2171 20.356L39.0962 14.4769C40.3152 13.2579 41 11.6046 41 9.88074V7.5H38.6193ZM31.9018 7.28248C33.6834 5.50089 36.0997 4.5 38.6193 4.5H42.5C43.3285 4.5 44 5.17157 44 6V9.88074C44 12.4003 42.9991 14.8167 41.2175 16.5983L36.0069 21.8089L41.859 38.3897C42.0512 38.9344 41.9136 39.5411 41.5051 39.9496L37.394 44.0607C37.0888 44.3659 36.6669 44.5248 36.2362 44.4968C35.8054 44.4689 35.4076 44.2567 35.1444 43.9146L25.9082 31.9075L23.4445 34.3713V37.8611C23.4445 38.2589 23.2864 38.6405 23.0051 38.9218L17.8662 44.0607C17.5056 44.4213 16.9865 44.574 16.488 44.466C15.9896 44.358 15.5802 44.0042 15.4011 43.5267L12.5572 35.9429L4.97334 33.0989C4.49582 32.9199 4.14199 32.5104 4.03402 32.012C3.92606 31.5136 4.07874 30.9944 4.43937 30.6338L9.57826 25.4949C9.85956 25.2136 10.2411 25.0556 10.6389 25.0556H14.1287L16.5925 22.5918L4.58546 13.3556C4.24333 13.0924 4.03115 12.6946 4.00318 12.2639C3.97521 11.8331 4.13415 11.4112 4.43937 11.106L8.55048 6.9949C8.95894 6.58644 9.56565 6.44882 10.1104 6.64107L26.6912 12.4931L31.9018 7.28248Z",fill:"currentColor"})})),al=(t,a)=>{const s=t.replace(a||"","");return s.startsWith("/")?s:`/${s}`},Ct=()=>{const{trackEvent:t}=Y(),{locale:a,push:s}=X();return{trackSelectedStep:({step:r,position:i,timeSpent:u,search:c,filteredFlights:m,returnFlights:o,flights:p})=>{var g,h,v,f,_,y,x,k;t({event:"flight_step_selected",data:{step_name:r,departure:(h=(g=c.legs[0])==null?void 0:g.departureAirport)==null?void 0:h.code,destination:(f=(v=c.legs[0])==null?void 0:v.arrivalAirport)==null?void 0:f.code,start_date:B((_=c.legs[0])==null?void 0:_.outboundDate,a,{weekday:"short",day:"2-digit",month:"short"}),end_date:(y=c.legs[1])!=null&&y.outboundDate?B(c.legs[1].outboundDate,a,{weekday:"short",day:"2-digit",month:"short"}):void 0,nb_passenger:c.adultsCount+c.childrenCount+c.infantsCount,class:c.class,depth_percentage:r==="choose_departing_flight"?`${i}/${m==null?void 0:m.length}`:r==="choose_returning_flight"?`${i}/${m==null?void 0:m.length}`:void 0,is_filtered:r==="choose_departing_flight"?((x=m==null?void 0:m.length)!=null?x:0)<Number(p==null?void 0:p.length):r==="choose_returning_flight"?((k=m==null?void 0:m.length)!=null?k:0)<Number(o==null?void 0:o.length):void 0,time_spent:u}})},selectFare:({fareId:r,searchId:i}
1)=>{s(`/${a}/flights/search/summary?flightId=${r}&searchId=${i}`),De("fareSelectionTime",Date.now().toString()),At("flightPassengers"),At("flightContactDetails")}}},sl=t=>{const a=Ve.find(s=>s.code===(t==null?void 0:t.country))||Ve[0];return{firstName:t==null?void 0:t.first_name,lastName:t==null?void 0:t.last_name,email:t==null?void 0:t.email,country:a,phone:t==null?void 0:t.cell_number}},ll=({children:t,selectedFare:a,flightId:s="",sId:l,searchId:n=""})=>{const{user:r,isTawakkalnaUser:i}=bt({autoFetch:!0}),{bookingSource:u,appSource:c}=pt(),{push:m,locale:o,baseUrl:p,search:g}=X(),{trackSelectedStep:h}=Ct(),{t:v}=S("flight_common"),{mutateAsync:f,error:_}=bs(),y=g.get("attempt"),x=y!==null&&y.trim()!==""?Number(y):NaN,k=Number.isFinite(x)?x+1:1,j=g.get("searchId")||n,N=g.get("flightId")||s,A=Number(ke("fareSelectionTime")),w=xa(),R=g.get("mode"),$=b.useMemo(()=>{var E;const V=We(ke("flightPassengers")||"[]"),U={adult:{count:w.adultsCount,saved:[]},child:{count:w.childrenCount,saved:[]},infant:{count:w.infantsCount,saved:[]}};for(const le of V){const ue=le==null?void 0:le.passenger_type;(E=U[ue])==null||E.saved.push(le)}const W=Object.keys(U),se=[];for(const le of W){const ue=le,xe=U[ue];for(let he=0;he<xe.count;he++)se.push({id:`${ue}-${he}`,selected:xe.saved[he],type:ue,suggestions:xe.saved})}return se},[w.adultsCount,w.childrenCount,w.infantsCount]),M=tt({mode:"onBlur",defaultValues:Z(F({},Rt),{passengersList:$,contactDetails:ke("flightContactDetails")?We(ke("flightContactDetails")||"{}"):Rt.contactDetails})}),{paymentMethod:I,onApplePayPayment:D,error:C}=Nt({applePay:{onPaymentAuthorized:me,onPaymentSuccess:pe,onPaymentFailed:()=>{M.setValue("checkoutLoading",!1)}}}),[T]=M.watch(["contactDetails"]),P=M.watch("passengersList").filter(E=>!!E.selected);b.useEffect(()=>{if(_||C){const E=_||C||null;M.setValue("checkoutError",E)}},[_,C]),b.useEffect(()=>{const E=P.map(V=>V.selected);E.length&&De("flightPassengers",JSON.stringify(E)),Object.values(T).every(V=>!!V)&&De("flightContactDetails",JSON.stringify(T))},[P,T]),b.useEffect(()=>{!ke("flightContactDetails")&&r&&M.setValue("contactDetails",sl(r))},[M,r]);const H=E=>{h({step:E,search:w}),m(`/${o}/flights/search/summary?flightId=${N}&searchId=${j}&mode=${E}`)},O=b.useMemo(()=>{var E,V,U,W,se;const le=((E=a==null?void 0:a.fareDetails)==null?void 0:E.fees.reduce(($a,Ra)=>$a+Ra.price,0))||0,ue=((V=a==null?void 0:a.fareDetails)==null?void 0:V.baseFare)||0,xe=((U=a==null?void 0:a.fareDetails)==null?void 0:U.vat)||0,he=((W=a==null?void 0:a.fareDetails)==null?void 0:W.tax)||0,Re=((se=a==null?void 0:a.fareDetails)==null?void 0:se.totalPrice)||0;return{gross:ue+le,vat:xe,tax:he,net:Re}},[a]),q=()=>ve(null,null,function*(){return z()}),z=()=>ve(null,null,function*(){const E=(O==null?void 0:O.net)>0;if((I==null?void 0:I.type)==="apple_pay"&&E)return J();ce()}),J=()=>ve(null,null,function*(){var E;try{yield D({totals:{gross:O.gross,gross_after_discount:O.gross,vat:O.vat,net:O.net,net_after_discount:O.net}})}catch(V){const U=V;if(M.setValue("checkoutLoading",!1),(E=U==null?void 0:U.message)!=null&&E.includes("JSON"))return M.setValue("checkoutError",new Error(v("flight_common:missing_url_message")));M.setValue("checkoutError",U)}});function me(){return ve(this,null,function*(){const E=re();return M.setValue("checkoutError",null),M.setValue("checkoutLoading",!0),f(E)})}function pe({order_id:E}){m(`/${o}/payment-success/flights/${Yt(E)}`)}const ce=()=>ve(null,null,function*(){var E;try{const V=re();M.setValue("checkoutError",null),M.setValue("checkoutLoading",!0);const U=yield f(V);if(!U.redirect_url)throw new Es({error:new Error(v("flight_common:missing_url_message")),name:"CheckoutNoRedirectUrlException"});const W=window.location.search||"";Va({name:"last_book_page",value:al(window.location.pathname+W,p),expiration:.01}),window.location.href=U.redirect_url}catch(V){const U=V;if(M.setValue("checkoutLoading",!1),(E=U==null?void 0:U.message)!=null&&E.includes("JSON"))return M.setValue("checkoutError",new Error(v("flight_common:missing_url_message")));M.setValue("checkoutError",U)}}),re=()=>{const[E,V]=M.getValues(["passengersList","contactDetails"]);return{redirect:window.origin+`/${o}/payment-success/flights`,redirect_failed:window.origin+`/${o}/flights/search/summary?flightId=${N}&searchId=${j}&mode=payment&payment_status=failed&order_id&attempt=${k}`,booking_source:u,lang:o,entity_payment_method_id:I==null?void 0:I.entity_payment_method_id,payment_method:(I==null?void 0:I.type)||"",searchId:j,flightId:N,email:V.email,areaCode:V.country.dial_co
1de,phone:V.phone,passengers:E.map(W=>{var se;return{id:((se=W.selected)==null?void 0:se.id)||""}}),app_source:i?"twk":c}};return e.jsx(pa.Provider,{value:{totals:O,summaryMode:R||"flight_summary",user:r||void 0,selectedFare:a,searchId:j,flightId:N,selectionTime:A,sId:l,setSummaryMode:H,checkout:q},children:e.jsx(ft,Z(F({},M),{children:t}))})},kt=ll,_e=()=>de(),St=(t,a)=>{const s=new Map;return t.forEach(l=>{s.set(l[a],l)}),Array.from(s.values())},fe=(t,a)=>a?t.price.roundtripTotalDiff:t.price.totalAmount,nl=(t,a)=>{const s=t.map(l=>fe(l,a));return[Math.min(...s),Math.max(...s)]},_a=t=>{const a=t.legs[0].segments[0];return{code:a.departureAirportCode,name:a.departureAirportName}},ya=t=>{const a=t.legs[0].segments[t.legs[0].segments.length-1];return{code:a.arrivalAirportCode,name:a.arrivalAirportName}},rl=t=>St(t.map(_a),"code"),il=t=>St(t.flatMap(ya),"code"),ja=t=>t.legs.reduce((a,s)=>a+s.segments.length-1,0),ol=t=>{const a={};return t.forEach(s=>{const l=ja(s);a[l]=(a[l]||0)+1}),Object.entries(a).map(([s,l])=>({stops:+s,flights:l})).sort((s,l)=>s.stops-l.stops)},Oe=t=>t.legs.map(a=>{var s,l;return new Date((s=a.segments[a.segments.length-1])==null?void 0:s.arrivalDateTime).getTime()-new Date((l=a.segments[0])==null?void 0:l.departureDateTime).getTime()}),cl=t=>{const a=t.flatMap(Oe);return[Math.min(...a),Math.max(...a)]},ba=t=>t.legs.map(a=>{var s;return(s=a.segments[0])==null?void 0:s.airline}),dl=t=>St(t.flatMap(ba),"airlineName"),Ce=(t,a=0)=>{var s;return new Date((s=t.legs[a].segments[0])==null?void 0:s.departureDateTime).getTime()},ml=(t,a=0)=>{var s;return new Date((s=t.legs[a].segments[t.legs[a].segments.length-1])==null?void 0:s.arrivalDateTime).getTime()},ul={departureTime:(t,a)=>{const s=Ce(t);return s>=a[0]&&s<=a[1]},arrivalTime:(t,a)=>{const s=ml(t);return s>=a[0]&&s<=a[1]},priceRanges:(t,a)=>{const s=fe(t);return s>=a[0]&&s<=a[1]},stops:(t,a)=>{const s=ja(t);return a.includes(s)},airlines:(t,a)=>{const s=ba(t);return a.some(l=>s.some(n=>n.airlineName===l))},departureAirports:(t,a)=>{const s=_a(t);return a.includes(s.code)},arrivalAirports:(t,a)=>{const s=ya(t);return a.includes(s.code)}},hl={cheapest:(t,a,s)=>{const l=fe(t,s),n=fe(a,s);if(l===n){const r=Ce(t),i=Ce(a);return r===i?Math.max(...Oe(t))-Math.max(...Oe(a)):r-i}return fe(t,s)-fe(a,s)},shortest:(t,a)=>{const s=Math.max(...Oe(t)),l=Math.max(...Oe(a));return s-l},earliest:(t,a)=>{const s=Ce(t),l=Ce(a);if(s===l){const n=fe(t),r=fe(a);return n-r}return s-l},latest:(t,a)=>{const s=Ce(t),l=Ce(a);if(s===l){const n=fe(t),r=fe(a);return n-r}return l-s}},gl=[{id:"cheapest",text:"Cheapest",value:"cheapest"},{id:"shortest",text:"Shortest",value:"shortest"},{id:"earliest",text:"Earliest",value:"earliest"},{id:"latest",text:"Latest",value:"latest"}],dt=7,pl=t=>{var a=t,{value:s,onChange:l,options:n,className:r,limit:i=5,allowSelectAll:u,selectAllLabel:c}=a,m=ee(a,["value","onChange","options","className","limit","allowSelectAll","selectAllLabel"]);const{t:o}=S(["flight_common"]),[p,g]=b.useState(!1),h=n.slice(0,p?n.length:i),v=f=>{s.includes(f)?l(s.filter(_=>_!==f)):l([...s,f])};return e.jsxs("div",{children:[u&&e.jsx(Ga,{checked:s.length===n.length,groupClassName:"[&>div]:justify-between [&>div]:flex-row-reverse",label:c||o("flight_common:select_all"),onChange:f=>{l(f?n.map(_=>_.value):[])}}),e.jsxs("ul",Z(F({className:G("space-y-4",r)},m),{children:[h.map(f=>e.jsx("li",{children:e.jsx(Ja,{checked:s.includes(f.value),onChange:()=>v(f.value),label:f.text},f.value)},f.value)),n.length>i&&e.jsx(L,{type:"button",shape:"text",onClick:()=>g(!p),className:"px-1 py-0.5 text-xs",children:o(p?"flight_common:show_less":"flight_common:show_more")})]}))]})},Xe=pl,xl=({value:t,onChange:a})=>{const{locale:s}=X(),{t:l}=S(["flight_common"]),{trackEvent:n}=Y(),{watch:r}=_e(),[i,u,c]=r(["selectedDepartureFlight","returnFlights","flights"]),m=x=>{a(F(F({},t),x)),n({event:"flights_results_filter_applied",data:{departure_time:x.departureTime||[],arrival_time:x.arrivalTime||[],price_ranges:x.priceRanges||[],stops:x.stops||[],airlines:x.airlines||[],departure_airports:x.departureAirports||[],arrival_airports:x.arrivalAirports||[]}})},o=b.useMemo(()=>{const x=i?u||[]:c||[],k=nl(x,!!i),j=rl(x),N=il(x),A=ol(x),w=cl(x),R=dl(x);return{priceRanges:k,departureAirports:j,arrivalAirports:N,stops:A,durationRanges:w,airlines:R}},[c,i,u]),p=c==null?void 0:c[0].legs[0].segments[0],g=c==null?void 0:c[0].legs[0].segments[c[0].legs[0].segments.length-1],h=p==null?void 0:p.departureCityName,v=g==null?void 0:g.arrivalCityName,f=t.priceRanges.length?t.priceRanges:o.priceRanges,_=t.departureTime.length?t.departureTime:[0,24],y=t.arrivalTime.length?t.arrivalTime:[0,24];return e.jsxs("div",{children:[e.jsxs("div",{className:"border-paper space-y-4 border-b pb-6",children:[e.jsx(d,{variant:"heading-S",className:"font-semibold",children:l("flight_common:stops")}),e.jsx(Xe,{value:t.stops.map(String),options:o.stops.map(({stops:x,flights:k})=>({text:e.jsxs("div",{className:"flex grow items-center justify-between",children:[e.jsx(d,{children:l("flight_common:stops",{count:x})}),e.jsx(d,{color:"text-secondary",variant:"body-XS",children:k})]}),value:String(x)})),onChange:x=>m({stops:x.map(Number)})})]}),e.jsxs("div",{className:"border-paper space-y-4 border-b py-6",children:[e.jsx(d,{variant:"heading-S",className:"font-semibold",children:l("flight_common:airlines")}),e.jsx(Xe,{allowSelectAll:!0,selectAllLabel:l("flight_common:select_all_airlines"),value:t.airlines,options:o.airlines.map(x=>({text:e.jsxs("div",{className:"flex grow justify-between",children:[e.jsx(d,{children:x.airlineName}),e.jsx("img",{src:x.airlineLogoUrl,alt:x.airlineName,width:40,height:20,className:"max-w-6"})]}),value:x.airlineName})),onChange:x=>m({airlines:x})})]}),e.jsxs("div",{className:"border-paper space-y-5 border-b py-6",children:[e.jsx(d,{variant:"heading-S",className:"font-semibold",children:l("flight_common:flight_times")}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(d,{as:"label",variant:"body-L",id:"departureTime",color:"text-secondary",children:[l("flight_common:flying_from_city",{city:i?v||"":h||""})," "]}),e.jsx(mt,{"aria-labelledby":"departureTime",value:_,onValueCommit:x=>{x[0]===0&&x[1]===24?m({departureTime:[]}):m({departureTime:x})},min:0,max:24,render:x=>e.jsxs("div",{className:"mt-6 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium",children:B(new Date(0,0,0,(x==null?void 0:x[0])||0),s,{timeStyle:"short",timeZone:void 0})}),e.jsx("span",{className:"text-xs font-medium",children:B(new Date(0,0,0,(x==null?void 0:x[1])||0),s,{timeZone:void 0,timeStyle:"short"})})]})},_.join("-"))]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(d,{as:"label",variant:"body-L",id:"arrivalTime",color:"text-secondary",children:[l("flight_common:arrival_in_city",{city:i?h||"":v||""})," "]}),e.jsx(mt,{"aria-labelledby":"arrivalTime",value:y,onValueCommit:x=>{x[0]===0&&x[1]===24?m({arrivalTime:[]}):m({arrivalTime:x})},min:0,max:24,render:x=>e.jsxs("div",{className:"mt-6 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium",children:B(new Date(0,0,0,(x==null?void 0:x[0])||0),s,{timeStyle:"short",timeZone:void 0})}),e.jsx("span",{className:"text-xs font-medium",children:B(new Date(0,0,0,(x==null?void 0:x[1])||0),s,{timeStyle:"short",timeZone:void 0})})]})},y.join("-"))]})]}),e.jsxs("div",{className:"border-paper space-y-6 border-b py-6",children:[e.jsxs("div",{id:"price",children:[e.jsx(d,{variant:"heading-S",className:"font-semibold",children:l("flight_common:price_range")}),e.jsx(d,{variant:"body-S",color:"text-secondary",children:l("flight_common:includes_taxes")})]}),e.jsx(mt,{"aria-labelledby":"price",value:f,onValueCommit:x=>{x[0]===o.priceRanges[0]&&x[1]===o.priceRanges[1]?m({priceRanges:[]}):m({priceRanges:x})},min:o.priceRanges[0],max:o.priceRanges[1],render:x=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Q,{originalPrice
1:Math.round((x==null?void 0:x[0])||0),currency:"SAR",className:"text-xs font-medium"}),e.jsx(Q,{originalPrice:Math.round((x==null?void 0:x[1])||0),currency:"SAR",className:"text-xs font-medium"})]})},f.join("-"))]}),e.jsxs("div",{className:"space-y-4 py-6",children:[e.jsx(d,{variant:"heading-S",className:"font-semibold",children:l("flight_common:airports")}),e.jsx(d,{variant:"body-XS",color:"text-secondary",children:l("flight_common:departure_airports_from",{place:h||""})}),e.jsx(Xe,{value:t.departureAirports,options:o.departureAirports.map(x=>({text:e.jsxs("div",{className:"flex grow items-center justify-between",children:[e.jsx(d,{children:x.name}),e.jsx(d,{variant:"body-XS",className:"bg-body-dark/5 rounded-[4px] p-1 px-3 font-medium uppercase",children:x.code})]}),value:x.code})),onChange:x=>m({departureAirports:x})}),e.jsx(d,{color:"text-secondary",variant:"body-XS",children:l("flight_common:arrival_airports_in",{place:v||""})}),e.jsx(Xe,{value:t.arrivalAirports,options:o.arrivalAirports.map(x=>({text:e.jsxs("div",{className:"flex grow items-center justify-between",children:[e.jsx(d,{children:x.name}),e.jsx(d,{variant:"body-XS",className:"bg-body-dark/5 rounded-[4px] p-1 px-3 font-medium uppercase",children:x.code})]}),value:x.code})),onChange:x=>m({arrivalAirports:x})})]})]})},mt=t=>{var a=t,{render:s}=a,l=ee(a,["render"]);const[n,r]=b.useState(l.value);return e.jsxs(e.Fragment,{children:[e.jsx(Ka,Z(F({},l),{onValueChange:r,value:n})),s==null?void 0:s(n)]})},Na=xl,fl=({value:t,onChange:a,className:s})=>{const[l,n]=b.useState(t),{t:r}=S(["flight_common"]),i=Object.values(t).some(u=>u.length>0);return e.jsx(Ae,{render:({open:u})=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:`bg-primary-400 absolute -top-1 right-0 z-10 h-3 w-3 rounded-full text-center lg:hidden ${i?"block":"hidden"}`}),e.jsx(L,{shape:"outlined",theme:"action",onClick:()=>{u(),n(t)},phill:!0,className:G("text-text-secondary border-paper px-XS relative w-fit py-1.5 text-sm font-medium lg:hidden",s),children:e.jsx(ms,{className:"h-4 w-4"})})]}),title:r("flight_common:filter_by"),body:()=>e.jsx(Na,{value:l,onChange:n}),cancel:!1,action:{className:"w-full",label:r("flight_common:apply"),onClick:({close:u})=>{a(l),u()}}})},wa=fl,vl=t=>{var a=t,{label:s,value:l,placeholder:n,error:r,className:i,icon:u,valueClassName:c,valueTypographyVariant:m}=a,o=ee(a,["label","value","placeholder","error","className","icon","valueClassName","valueTypographyVariant"]);return e.jsxs("div",{className:"w-full",children:[e.jsx(L,Z(F({className:"min-h-16 w-full justify-start rounded-none p-0",theme:"transparent",type:"button"},o),{children:e.jsxs(ae,{surface:"level-1",size:"XS",className:G("flex h-full min-h-16 w-full items-center gap-2",i),children:[u,e.jsxs("div",{className:"space-y-1 lg:space-y-0",children:[s&&e.jsx(d,{variant:"body-S",color:"text-secondary",className:"whitespace-nowrap",children:s}),e.jsx(d,{as:"div",variant:m||"body-S",color:l?void 0:"text-secondary",className:G("line-clamp-1 text-start",c),children:l||n})]})]})})),r&&e.jsx(d,{variant:"body-S",color:"error",children:r})]})},Ca=vl,_l=({mode:t,value:a,onChange:s,startMonth:l,dateType:n,numberOfMonths:r})=>{const{locale:i}=X();return t==="single"?e.jsx(Pt,{className:"w-full pb-2 lg:p-0",mode:"single",selected:a,onSelect:s,lang:i,numberOfMonths:r||1,defaultMonth:l,weekStartsOn:0,startMonth:n==="return"?a:new Date}):e.jsx(Pt,{className:"w-full pb-2 lg:p-0",mode:"range",selected:a,onSelect:u=>s(u),lang:i,numberOfMonths:r||2,defaultMonth:l?a.to:a.from,weekStartsOn:0,startMonth:n==="return"?a.from:new Date})},Vt=_l,yl=({mode:t,startMonth:a,value:s,dateType:l,onChange:n,numberOfMonths:r})=>t==="single"?e.jsx(Vt,{mode:"single",startMonth:a,value:(s==null?void 0:s[0])||new Date,dateType:l,numberOfMonths:r,onChange:i=>{if(!i){n([s==null?void 0:s[0]]);return}n([i])}}):e.jsx(Vt,{mode:"range",startMonth:a,value:{from:(s==null?void 0:s[0])||new Date,to:(s==null?void 0:s[1])||new Date},dateType:l,numberOfMonths:r,onChange:i=>{if(!i){n([s==null?void 0:s[0],s==null?void 0:s[0]]);return}const u=Object.values(i).sort((c,m)=>
1c.getTime()-m.getTime()).filter(Boolean);n(u.length===1?[u[0],u[0]]:u)}}),Zt=yl,jl=t=>{var a=t,{onChange:s,value:l,startMonth:n,connectionType:r,dateType:i,onConnectionTypeChange:u}=a,c=ee(a,["onChange","value","startMonth","connectionType","dateType","onConnectionTypeChange"]);const{locale:m}=X(),{t:o}=S("flight_common"),p=r==="round_trip"?"range":"single",[g,h]=b.useState(l),v=l==null?void 0:l.map(y=>B(y,m,{weekday:"short",day:"2-digit",month:"short",timeZone:void 0})),f=g==null?void 0:g.map(y=>B(y,m,{weekday:"short",day:"2-digit",month:"short",timeZone:void 0})),_=()=>{if(l)h(l);else{const y=[new Date];r==="round_trip"&&y.push(te({date:new Date,interval:"day",value:1})),h(y)}};return e.jsx(la,{body:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"block md:hidden",children:[e.jsxs("div",{className:"flex items-center justify-center gap-10 text-center",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{variant:"body-L",children:o("flight_common:departure")}),e.jsx(d,{color:"text-secondary",children:f!=null&&f[0]?f[0]:o("flight_common:select_your_date")})]}),r!=="multi_city"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-paper h-12 border"}),e.jsx("div",{className:"space-y-1",children:r==="round_trip"||r==="one_way"&&(f!=null&&f[1])?e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"body-L",children:o("flight_common:return")}),e.jsx(d,{color:"text-secondary",children:f!=null&&f[1]?f[1]:o("flight_common:select_your_date")})]}):e.jsxs(L,{shape:"text",theme:"action",className:"px-0",onClick:()=>{u("round_trip"),h([g==null?void 0:g[0],te({date:g==null?void 0:g[0],interval:"day",value:1})])},children:[e.jsx(ps,{className:"h-5 w-5 shrink-0"}),o("flight_common:add_return")]})})]})]}),e.jsx(ie,{className:"my-6 block"}),e.jsx(Zt,{mode:p,startMonth:n,value:g,dateType:i,onChange:h,numberOfMonths:1})]}),e.jsx("div",{className:"hidden md:block",children:e.jsx(Zt,{mode:p,startMonth:n,value:l,dateType:i,onChange:s})})]}),render:({open:y})=>e.jsx(Ca,F({placeholder:o("flight_common:select"),value:n?v==null?void 0:v[1]:v==null?void 0:v[0],icon:e.jsx(gs,{className:"h-5 w-5 shrink-0"}),onClick:()=>{y(),h(l)}},c)),popover:{className:`${r==="one_way"?"min-w-[300px]":"min-w-[300px] md:min-w-[600px]"} pb-24 md:pb-0 z-[999]`,action:!1,cancel:!1},sheet:{ignoreHistory:!0,title:e.jsx("div",{className:"text-center",children:o("flight_common:travel_dates")}),customAction:({close:y})=>e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx(L,{shape:"text",theme:"white",className:"-ml-4 underline underline-offset-2",onClick:_,children:o("flight_common:reset_dates")}),e.jsx(L,{disabled:!(g!=null&&g.length),onClick:()=>{s(g),u(r),y()},theme:"action",children:o("flight_common:confirm")})]})}})},Ht=jl,bl=t=>e.jsxs("svg",Z(F({width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:[e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.66666 15H18.3333V16.6667H1.66666V15Z",fill:"currentColor"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.4889 1.49222L5.97698 2.1116L7.40403 4.58675C7.52738 4.80071 7.74032 4.95038 7.98547 4.99391C9.6738 5.29371 13.6411 5.96115 15.0542 6.19835C15.5519 6.28187 16.0116 6.51343 16.3748 6.86278L17.5778 8.01989C18.3942 8.80512 18.5698 10.0454 18.0026 11.0261C17.4833 11.9241 16.4569 12.4004 15.4359 12.219L11.9921 11.6075L8.68687 13.1584L4.87668 12.4818L5.82955 10.5329L3.77373 10.2045C2.39006 9.98346 1.45617 8.66946 1.70736 7.2898L1.92487 6.09505L2.78092 5.49898L2.4889 1.49222ZM4.30688 3.50778L4.51216 6.3244L3.44144 7.06995L3.34707 7.58832C3.26377 8.04587 3.57326 8.48467 4.03665 8.5587L8.31579 9.2423L7.3452 11.2274L8.45762 11.4249L11.7629 9.87409L15.7272 10.5781C16.0593 10.637 16.392 10.4819 16.5599 10.1917C16.7429 9.8753 16.6865 9.47508 16.4225 9.22111L15.2194 8.06399C15.0979 7.94708 14.9446 7.86992 14.7784 7.84202C13.3687 7.60541 9.39205 6.93642 7.69408 6.6349C6.96527 6.50549 6.32994 6.06061 5.96015 5.41922L4.92098 3.61683L4.30688 3.50778Z",fill:"currentColor"})]})),Nl=t=>e.jsxs("svg",Z(F({width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:[e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13.601 3.56603C14.0737 3.3897 14.5876 3.36081 15.0766 3.48216L16.6963 3.88402C17.7952 4.1567 18.5669 5.14324 18.5669 6.27552C18.5669 7.31275 17.9173 8.23892 16.9421 8.5922L13.6578 9.78198L11.5745 12.7767L7.93925 14.0936L7.78849 11.9289L5.84585 12.671C4.53677 13.1711 3.07237 12.497
17 2.59999 11.1783L2.19056 10.0348L2.63295 9.09052L0.375519 5.76396L3.70465 4.55793L6.17761 5.99016C6.3916 6.1141 6.65041 6.13719 6.88356 6.05273C8.49404 5.46931 12.2599 4.06626 13.601 3.56603ZM14.6753 5.09977C14.5117 5.05918 14.3408 5.06892 14.1835 5.1276C12.8457 5.62659 9.07094 7.03298 7.45123 7.61974C6.75532 7.87185 5.98287 7.80339 5.34233 7.43241L3.54176 6.3896L2.95783 6.60114L4.5444 8.93911L3.99126 10.1198L4.16912 10.6165C4.32658 11.0563 4.81471 11.2808 5.25107 11.1141L9.29486 9.56925L9.44842 11.7742L10.5088 11.3901L12.5922 8.39538L16.3745 7.02519C16.69 6.91087 16.9002 6.61116 16.9002 6.27552C16.9002 5.90912 16.6505 5.58987 16.2949 5.50164L14.6753 5.09977Z",fill:"currentColor"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.66666 15H18.3333V16.6667H1.66666V15Z",fill:"currentColor"})]})),wl=t=>e.jsx("svg",Z(F({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.3096 3.5C18.4477 3.5 17.621 3.84241 17.0115 4.4519L14.072 7.39144C13.8678 7.59567 13.5644 7.66448 13.2921 7.56835L5.00167 4.64233L3.88434 5.75967L9.88785 10.3778C10.0589 10.5093 10.165 10.7082 10.179 10.9236C10.193 11.139 10.1135 11.3499 9.9609 11.5026L7.90534 13.5581C7.76469 13.6988 7.57393 13.7778 7.37501 13.7778H5.63012L4.10395 15.3039L7.12447 16.4366C7.32728 16.5127 7.48731 16.6727 7.56337 16.8755L8.69607 19.8961L10.2222 18.3699V16.625C10.2222 16.4261 10.3013 16.2353 10.4419 16.0947L12.4975 14.0391C12.6501 13.8865 12.861 13.807 13.0764 13.821C13.2918 13.835 13.4907 13.9411 13.6223 14.1122L18.2403 20.1157L19.3577 18.9983L16.4317 10.7079C16.3355 10.4356 16.4043 10.1322 16.6086 9.928L19.5481 6.98846C20.1576 6.37897 20.5 5.55232 20.5 4.69037V3.5H19.3096ZM15.9509 3.39124C16.8417 2.50044 18.0499 2 19.3096 2H21.25C21.6642 2 22 2.33579 22 2.75V4.69037C22 5.95015 21.4996 7.15833 20.6088 8.04913L18.0035 10.6544L20.9295 18.9448C21.0256 19.2172 20.9568 19.5205 20.7526 19.7248L18.697 21.7803C18.5444 21.9329 18.3334 22.0124 18.1181 21.9984C17.9027 21.9844 17.7038 21.8783 17.5722 21.7073L12.9541 15.7038L11.7222 16.9357V18.6806C11.7222 18.8795 11.6432 19.0702 11.5026 19.2109L8.93312 21.7803C8.75281 21.9606 8.49324 22.037 8.24402 21.983C7.9948 21.929 7.79008 21.7521 7.70054 21.5133L6.27858 17.7214L2.48667 16.2995C2.24791 16.2099 2.071 16.0052 2.01701 15.756C1.96303 15.5068 2.03937 15.2472 2.21968 15.0669L4.78913 12.4974C4.92978 12.3568 5.12055 12.2778 5.31946 12.2778H7.06435L8.29624 11.0459L2.29273 6.4278C2.12166 6.29621 2.01558 6.09731 2.00159 5.88194C1.9876 5.66657 2.06707 5.45561 2.21968 5.303L4.27524 3.24745C4.47947 3.04322 4.78283 2.97441 5.05518 3.07054L13.3456 5.99656L15.9509 3.39124Z",fill:"currentColor"})})),Cl=({value:t,onChange:a,type:s,counterpartId:l,error:n})=>{const[r,i]=b.useState(""),u=b.useRef(void 0),{trackEvent:c}=Y(),{locale:m}=X(),{search:o}=oe(),{t:p}=S(["flight_common"]),{data:g,isLoading:h}=Ns({lang:m}),{data:v}=It({search:t==null?void 0:t.code,lang:m},{select:j=>{var N,A;return t!=null&&t._id.includes("airport")?j.filter(w=>w.code===(t==null?void 0:t.code)):((A=(N=j==null?void 0:j[0])==null?void 0:N.airports)==null?void 0:A.filter(w=>w.code===(t==null?void 0:t.code)))||[]}}),f=(v==null?void 0:v[0])||t,{data:_,isFetching:y}=It({search:r,lang:m},{enabled:!!r,placeholderData:g}),x=b.useMemo(()=>{const j=_||[],N=!y&&!j.length,A=[];return y||h?[1,2,3,4].map(w=>({id:w.toString(),value:w.toString(),text:e.jsxs("div",{className:"flex h-10 w-full items-center gap-2",children:[e.jsxs("div",{className:"w-full space-y-2",children:[e.jsx("div",{className:"bg-body-dark/10 h-2 max-w-[50%] animate-pulse rounded-sm"}),e.jsx("div",{className:"bg-body-dark/10 h-2 max-w-[60%] animate-pulse rounded-sm"})]}),e.jsx("div",{className:"bg-body-dark/10 h-7 w-12 max-w-[60%] animate-pulse rounded-sm"})]})})):N?[]:(j.forEach(w=>{var R,$;if(w._id!==l){const M=(R=w.airports)==null?void 0:R.some(I=>{var D;return((D=I.code)==null?void 0:D.toLocaleLowerCase())===o.excludedAirport});A.push({id:w._id,value:w._id,data:w,text:e.jsxs("div",{className:"flex w-full gap-2",children:[e.jsx(hs,{className:"mt-0.5 h-5 w-5 shrink-0"}),e.jsxs("div",{className:"flex w-full items-start justify-between text-start",children:[e.jsxs("div",{children:[e.jsxs(d,{variant:"label-M",color:M?"notice":void 0,children:[`${w.city}
1,`," ",e.jsx("span",{children:w.country})]}),M?e.jsx(d,{variant:"body-S",color:"notice",children:p("flight_common:excluded_city_note",{city:w.city})}):w.airports?e.jsx(d,{variant:"body-S",color:"text-secondary",children:p("flight_common:all_airports")}):e.jsx(d,{variant:"body-S",color:"text-secondary",children:w.name})]}),!w.airports&&e.jsx("span",{className:"bg-body-dark/5 rounded-[4px] px-3 py-1 text-sm uppercase",children:w.code})]})]})})}if(w.airports){const M=($=w==null?void 0:w.airports)==null?void 0:$.reduce((I,D,C)=>{var T;if(D._id!==l){const P=o.excludedAirport===((T=D.code)==null?void 0:T.toLocaleLowerCase());I.push({id:`${D._id}-index-${C}`,value:D._id,data:D,text:e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"flex w-full gap-2 pl-6",children:[e.jsx(wl,{className:"mt-px h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex w-full items-start justify-between text-start",children:[e.jsxs("div",{children:[e.jsx(d,{color:P?"notice":void 0,children:D.name}),P?e.jsxs(d,{variant:"body-S",color:P?"notice":"text-secondary",children:[`${w.city},`," ",e.jsx("span",{children:w.country})]}):e.jsxs(d,{variant:"body-S",color:"text-secondary",children:[`${w.city},`," ",e.jsx("span",{children:w.country})]})]}),e.jsx("span",{className:"bg-body-dark/5 rounded-[4px] px-3 py-1 text-sm uppercase",children:D.code})]})]},C)})})}return I},[]);A.push(...M)}}),A)},[l,_,y,h,o.excludedAirport,p]),k=j=>{clearTimeout(u.current),u.current=setTimeout(()=>i(j),300)};return b.useEffect(()=>{_&&r&&c({event:s==="departure"?"flights_origin_autosuggest_shown":"flights_destination_autosuggest_shown",data:{query:r,suggestions_count:_.length}})},[_,r]),e.jsx(Ya,{className:"h-full w-full",render:({open:j})=>{var N;return e.jsx(L,{type:"button",theme:"transparent",className:"min-h-16 w-full justify-start p-0",onClick:()=>{i(""),j()},children:e.jsxs(ae,{surface:"level-1",size:"XS",className:"flex h-full min-h-16 w-full items-center gap-2",children:[s==="departure"?e.jsx(Nl,{className:"h-5 w-5 shrink-0"}):e.jsx(bl,{className:"h-5 w-5 shrink-0"}),e.jsxs("div",{className:"space-y-1 text-start lg:space-y-0",children:[e.jsx(d,{variant:"body-S",color:"text-secondary",children:p(`flight_common:${s==="departure"?"flying_from":"flying_to"}`)}),e.jsx(d,{variant:"body-S",className:"line-clamp-1",children:f?`${f==null?void 0:f.city} (${f.code}) - ${(N=f.airports)!=null&&N.length?f.country:f.name}`:""})]})]})})},error:n,options:x,value:t==null?void 0:t._id,onChange:j=>{"data"in j&&j.data&&a(j.data)},menu:{className:"z-[999]"},search:{placeholder:p("flight_common:search_for_an_airport_or_city"),onChange:k,loading:y||h,error:n},hideErrorSpace:!0})},zt=Cl,kl=({onChange:t,passengers:a})=>{const{t:s}=S("flight_common"),l=[{label:s("flight_common:adults"),key:"adultsCount",description:s("flight_common:adults_age"),minCount:Math.max(a.infantsCount,1),maxCount:dt-(a.childrenCount+a.infantsCount)},{label:s("flight_common:children"),key:"childrenCount",description:s("flight_common:children_age"),minCount:0,maxCount:dt-(a.adultsCount+a.infantsCount)},{label:s("flight_common:infants"),key:"infantsCount",description:s("flight_common:infants_age"),minCount:0,maxCount:a.infantsCount+a.adultsCount+a.childrenCount===7?dt-(a.adultsCount+a.childrenCount):a.adultsCount}];return e.jsx("div",{className:"w-full space-y-4",children:l.map(({label:n,key:r,description:i,minCount:u,maxCount:c})=>{const m=a[r]||0;return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"grow items-center gap-1 lg:flex",children:[e.jsx(d,{variant:"body-L",children:n}),e.jsx(d,{color:"text-secondary",children:i})]}),e.jsxs("div",{className:"flex max-w-24 grow items-center gap-2",children:[e.jsx(L,{shape:"outlined",theme:"action",type:"button",onClick:()=>t(Z(F({},a),{[r]:Math.max(m-1,0)})),className:"h-[30px] w-[30px] shrink-0 p-0 text-lg font-bold",disabled:m<=u,children:e.jsx("span",{className:"-mt-px",children:"-"})}),e.jsx("span",{className:"w-5 text-center",children:m})," ",e.jsx(L,{shape:"outlined",theme:"action",type:"button",className:"flex h-[30px] w-[30px] shrink-0 p-0 text-lg font-bold",onClick:()=>t(Z(F({},a),{[r]:m+1}
1)),disabled:m>=c,children:e.jsx("span",{className:"-mt-px",children:"+"})})]})]},r)})})},Xt=kl,Sl=({value:t,onChange:a})=>{const{t:s}=S("flight_common"),l=t.adultsCount+t.childrenCount+t.infantsCount,n=[{value:"economy",text:s("flight_common:economy")},{value:"premium_economy",text:s("flight_common:premium_economy")},{value:"business",text:s("flight_common:business")},{value:"first",text:s("flight_common:first")}];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden items-center gap-4 group-data-[small=false]:lg:flex",children:[e.jsx(sa,{className:"w-auto",align:"start",sideOffset:8,content:e.jsx(Xt,{onChange:r=>a(F(F({},t),r)),passengers:{adultsCount:t.adultsCount,childrenCount:t.childrenCount,infantsCount:t.infantsCount}}),children:e.jsxs(L,{shape:"text",theme:"action",children:[s("flight_common:passengers",{count:l}),e.jsx(ge,{className:"h-2.5 w-2.5 rotate-90"})]})}),e.jsx("span",{className:"bg-body-dark/10 h-4 w-px"}),e.jsx(aa,{value:t.class,options:n,menu:{align:"center",sideOffset:8},onChange:r=>a(Z(F({},t),{class:r.value})),hideErrorSpace:!0})]}),e.jsxs("div",{className:"group-data-[small]:lg:hidden",children:[e.jsxs(d,{color:"text-secondary",className:"mb-4 flex items-center gap-1.5",children:[e.jsx(_t,{className:"h-4 w-4 shrink-0"})," ",s("flight_common:passengers")]}),e.jsx(Xt,{onChange:r=>a(F(F({},t),r)),passengers:{adultsCount:t.adultsCount,childrenCount:t.childrenCount,infantsCount:t.infantsCount}}),e.jsx(ie,{className:"my-4"}),e.jsxs(d,{color:"text-secondary",className:"mb-4 flex items-center gap-1.5",children:[e.jsx(us,{})," ",s("flight_common:cabin_class")]}),e.jsx(at,{value:t.class,label:"",onChange:r=>{r&&a(Z(F({},t),{class:r}))},options:n.map(r=>Z(F({},r),{text:e.jsx(d,{variant:"label-S",children:r.text})})),hideErrorSpace:!0,className:"text-body-S flex h-9 min-w-fit max-w-fit items-center rounded-lg",type:"single",activeBtnProps:{className:"border-2 bg-body",theme:"action",shape:"outlined"},btnProps:{className:"border text-text-secondary  border-text-secondary",theme:"action",shape:"outlined"}})]})]})},ka=Sl,Dl=t=>{var a=t,{value:s,onChange:l}=a,n=ee(a,["value","onChange"]);const{t:r}=S("flight_common"),i=s.adultsCount+s.childrenCount+s.infantsCount;return e.jsx(la,{body:()=>e.jsx(ka,{value:s,onChange:l}),sheet:{title:e.jsx("div",{className:"text-center",children:r("flight_common:passengers_and_cabin")}),action:{label:r("flight_common:confirm"),className:"w-full",onClick:({close:u})=>u()},cancel:!1},popover:{action:!1,cancel:!1,className:"z-[999]"},render:({open:u})=>e.jsx(Ca,F({value:[` ${r("flight_common:passengers",{count:i})}`,r(`flight_common:${s.class}`)].filter(Boolean).join(" • "),label:r("flight_common:passengers_and_cabin"),placeholder:r("flight_common:select"),className:"w-full text-start",icon:e.jsx(_t,{className:"h-5 w-5 shrink-0"}),onClick:u},n))})},Ll=Dl,Fl=({className:t,small:a=!1,onFormSubmit:s,showSubmit:l=!0,id:n,search:r})=>{const{locale:i}=X(),{trackEvent:u}=Y(),{t:c}=S(["flight_common"]),[m,o]=b.useState(r.legs.map(D=>D.outboundDate)||[]),[p,g]=b.useState({}),{control:h,handleSubmit:v,watch:f,setValue:_,getValues:y}=tt({defaultValues:Z(F({},r),{passengersAndCabin:{adultsCount:r.adultsCount,childrenCount:r.childrenCount,infantsCount:r.infantsCount,class:r.class}})}),x=f("legs");b.useEffect(()=>{const D=f(C=>{var T=C,{passengersAndCabin:P}=T,H=ee(T,["passengersAndCabin"]);De("flightsSearch",JSON.stringify(F(F({},H),P)))});return()=>D.unsubscribe()},[f]);const{fields:k,append:j,remove:N}=Wa({name:"legs",control:h}),A=f("connectionType"),w=D=>{o(D),_("legs",y("legs").map((C,T)=>Z(F({},C),{outboundDate:D!=null&&D[T]?D[T]:D[0]})))},R=D=>{var C=D,{passengersAndCabin:T}=C,P=ee(C,["passengersAndCabin"]);P.connectionType==="round_trip"&&(P.legs[1].arrivalAirport=P.legs[0].departureAirport,P.legs[1].departureAirport=P.legs[0].arrivalAirport),s(F(F({},P),T))},$=()=>{const D=y(`legs.${k.length-1}`);return{outboundDate:D!=null&&D.outboundDate?te({date:new Date(D.outboundDate),interval:"day",value:1}):new Date,departureAirport:D==null?void 0:D.arrivalAirport,arrivalAirport:void 0}},M=D=>{const C=y(`legs.${D}.departureAirport`),T=y(`legs.${D}.arrivalAirport`);!C||!T||(u({event:"flights_home_destination_selected",data:{destination:T}}),u({event:"flights_home_origin_selected",data:{origin:C}}),_(`legs.${D}.departureAirport`,T),_(`legs.${D}.arrivalAirport`,C),g(P=>Z(F({},P),{[D]:!P[D]}
1)))},I=D=>{const C=y("legs.0");if(D==="round_trip"&&C){_("legs",[C]);const T={departureAirport:C==null?void 0:C.arrivalAirport,arrivalAirport:C==null?void 0:C.departureAirport,outboundDate:te({date:C==null?void 0:C.outboundDate,interval:"day",value:1})};_("legs.1",T),o([C==null?void 0:C.outboundDate,T.outboundDate])}else D==="one_way"&&(_("legs",[C]),o([C==null?void 0:C.outboundDate]))};return e.jsxs("form",{"data-small":a,className:G("group mx-auto max-w-md space-y-4 rounded-xl lg:max-w-none",t),onSubmit:v(R),id:n,children:[e.jsxs("div",{className:"flex items-center justify-between [&>div]:w-full lg:[&>div]:w-auto",children:[e.jsx(K,{control:h,name:"connectionType",render:D=>{var{field:C}=D,T=C,{onChange:P}=T,H=ee(T,["onChange"]);return e.jsx(at,{options:[{value:"round_trip",text:e.jsx(d,{variant:"label-M",children:c("flight_common:round_trip")})},{value:"one_way",text:e.jsx(d,{variant:"label-M",children:c("flight_common:one_way")})}],value:H.value,onChange:O=>{O&&(u({event:"flights_trip_type_selected",data:{trip_type:O}}),P(O),I(O))},label:"",hideErrorSpace:!0,groupClassName:"bg-body-level-1",phill:!0,className:"w-full",type:"single",activeBtnProps:{className:"border-2 max-w-full lg:max-w-fit bg-body",theme:"action",shape:"outlined"},btnProps:{className:"border-2 border-transparent max-w-full lg:max-w-fit text-text-secondary",theme:"action",shape:"outlined"}})}}),e.jsx("div",{className:"hidden group-data-[small=false]:lg:block",children:e.jsx(K,{control:h,name:"passengersAndCabin",render:({field:{value:D,onChange:C}})=>e.jsx(ka,{value:D,onChange:C})})})]}),k.slice(0,A==="multi_city"?k.length:1).map((D,C)=>{const T=C>0&&C===k.length-1;return e.jsxs("div",{className:"space-y-1.5",children:[A==="multi_city"&&e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsxs(d,{variant:"body-L",className:"font-semibold",children:[c("flight_common:flight")," ",C+1]}),T&&e.jsx(L,{shape:"text",className:"bg-primary/20 flex h-6 w-6 items-center justify-center rounded-full p-0",type:"button",onClick:()=>N(C),children:e.jsx(Le,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"group flex flex-col gap-4 group-data-[small=false]:lg:flex-row",children:[e.jsxs("div",{className:"relative flex grow basis-2/3 flex-col items-start gap-4 group-data-[small=false]:lg:flex-row",children:[e.jsx(K,{control:h,name:`legs.${C}.departureAirport`,rules:{required:c("flight_common:validation.required")},render:({field:{value:P,onChange:H},fieldState:{error:O}})=>{var q,z;return e.jsx(zt,{type:"departure",value:P,counterpartId:(z=(q=x==null?void 0:x[C])==null?void 0:q.arrivalAirport)==null?void 0:z._id,onChange:J=>{u({event:"flights_home_origin_selected",data:{origin:J}}),H(J)},error:O==null?void 0:O.message})}}),e.jsx("div",{className:"absolute top-1/2 z-10 flex w-full items-center group-data-[small=false]:lg:static group-data-[small=false]:lg:h-16 group-data-[small=false]:lg:w-auto",children:e.jsx(ae,{surface:"level-1",className:"absolute top-1/2 z-10 -translate-x-1/2 -translate-y-1/2 rounded-full !p-0 group-data-[small=false]:lg:static group-data-[small=false]:lg:translate-x-0 group-data-[small=false]:lg:translate-y-0 group-data-[small=false]:lg:rotate-90 group-data-[small=false]:lg:self-center ltr:right-1 rtl:left-8",border:!0,children:e.jsx("button",{type:"button",onClick:()=>M(C),className:"text-text-secondary flex h-8 w-8 items-center justify-center p-2",children:e.jsx("span",{className:"inline-block transition-transform duration-500",style:{transform:p[C]?"rotate(180deg)":"rotate(0deg)"},children:e.jsx(He,{className:"text-body-dark h-4 w-4"})})})})}),e.jsx(K,{control:h,name:`legs.${C}.arrivalAirport`,rules:{required:c("flight_common:validation.required"),validate:P=>{var H;return(P==null?void 0:P.code)===((H=y(`legs.${C}.departureAirport`))==null?void 0:H.code)?c("flight_common:validation.duplicate_airports"):!0}},render:({field:{value:P,onChange:H},fieldState:{error:O}})=>{var q,z;return e.jsx(zt,{type:"arrival",value:P,counterpartId:(z=(q=x==null?void 0:x[C])==null?void 0:q.departureAirport)==null?void 0:z._id,onChange:J=>{u({event:"flights_home_destination_selected",data:{destination:J}}),H(J)},error:O==null?void 0:O.message})}})]}),e.jsxs("div",{className:"relative flex gap-2 group-data-[small=false]:lg:basis-1/3 group-data-[small=false]:lg:gap-0 [&>div]:w-full",children:[e.jsx(K,{control:h,name:`legs.${C}.outboundDate`,rules:{required:c("flight_common:validation.required")}
1,render:({field:{onChange:P},fieldState:{error:H}})=>e.jsx(Ht,{onConnectionTypeChange:O=>{_("connectionType",O)},connectionType:A,label:c("flight_common:departure_date"),value:m,onChange:O=>{w(O);const q=O==null?void 0:O[0];q&&u({event:"flights_home_departure_date_selected",data:{departure_date:B(O==null?void 0:O[0],i,{weekday:"short",day:"2-digit",month:"short"})}}),P(q)},error:H==null?void 0:H.message,startMonth:f(`legs.${C-1}.outboundDate`),className:A==="round_trip"?"w-full group-data-[small=false]:lg:ltr:rounded-r-none group-data-[small=false]:lg:ltr:border-r-0 group-data-[small=false]:lg:rtl:rounded-l-none group-data-[small=false]:lg:rtl:border-l-0":"w-full"})}),A==="round_trip"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"relative hidden h-16 !w-0 group-data-[small=false]:lg:block",children:e.jsx("span",{className:"bg-body-dark/10 absolute left-1/2 top-1/2 h-4 w-px -translate-x-1/2 -translate-y-1/2"})}),e.jsx(K,{control:h,name:"legs.1.outboundDate",rules:{required:c("flight_common:validation.required"),shouldUnregister:!0,validate:P=>{const H=y("legs.0.outboundDate");return!H||!P?!0:P.getTime()<new Date(H).getTime()?c("flight_common:validation.date_should_be_after",{date:B(new Date(H),i,{weekday:"short",day:"2-digit",month:"short",timeZone:void 0})}):!0}},render:({field:{onChange:P},fieldState:{error:H}})=>e.jsx(Ht,{onConnectionTypeChange:O=>{_("connectionType",O)},dateType:"return",connectionType:A,label:c("flight_common:return_date"),error:H==null?void 0:H.message,value:m,startMonth:m==null?void 0:m[1],onChange:O=>{w(O);const q=O==null?void 0:O[1];q&&u({event:"flights_home_return_date_selected",data:{return_date:B(O==null?void 0:O[1],i,{weekday:"short",day:"2-digit",month:"short"})}}),P(q)},className:"group-lg:rtl:border-r-0 w-full group-data-[small=false]:lg:ltr:rounded-l-none group-data-[small=false]:lg:ltr:border-l-0 group-data-[small=false]:lg:rtl:rounded-r-none group-data-[small=false]:lg:[&_svg]:hidden"})})]})]}),e.jsx(K,{control:h,name:"passengersAndCabin",render:({field:{value:P,onChange:H},fieldState:{error:O}})=>e.jsx("div",{className:"group-data-[small=false]:lg:hidden",children:e.jsx(Ll,{error:O==null?void 0:O.message,value:P,onChange:H})})}),C===0&&A!=="multi_city"&&l&&e.jsxs(L,{className:"hidden h-16 shrink-0 items-center justify-center group-data-[small=false]:lg:flex",type:"submit",children:[e.jsx(Be,{})," ",c("flight_common:search")]})]})]},C)}),A==="multi_city"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{shape:"text",onClick:()=>j($()),type:"button",children:["+ ",c("flight_common:add_flight")]}),l&&e.jsxs(L,{type:"submit",children:[e.jsx(Be,{})," ",c("flight_common:search_flights")]})]}),l&&e.jsx("div",{className:"mx-auto pt-2 group-data-[small=false]:lg:hidden",children:e.jsxs(L,{type:"submit",className:"h-11 w-full",children:[e.jsx(Be,{})," ",c("flight_common:search_flights")]})})]})},Ze=Fl,Al=({value:t,onChange:a})=>{const{t:s}=S(["flight_common"]),{trackEvent:l}=Y();return e.jsx(aa,{trigger:{className:"p-0 underline"},value:t,options:gl.map(n=>Z(F({},n),{text:s(`flight_common:${n.value}`)})),onChange:n=>{a(n.value),l({event:"flights_results_sort_applied",data:{sort_by:n.value}})},hideErrorSpace:!0})},Tl=Al,Pl=({title:t})=>{const{search:a,setSearch:s}=oe();return e.jsx(kt,{children:e.jsxs("div",{className:"container space-y-6",children:[t&&e.jsx(d,{variant:"heading-L",children:t}),e.jsx(ae,{className:"bg-body-level-1 mx-auto max-w-lg lg:max-w-none",children:e.jsx(Ze,{search:a,onFormSubmit:s})})]})})},ti=Pl,Ml=({filterKey:t,renderLabel:a})=>{const{watch:s,setValue:l}=_e(),r=s("selectedDepartureFlight")?"returnFilters":"departureFilters",i=s(r),u=i[t];return u.map(c=>e.jsxs(L,{onClick:()=>l(r,Z(F({},i),{[t]:u.filter(m=>m!==c)})),phill:!0,theme:"action",shape:"outlined",className:"text-sm ltr:mr-2 rtl:ml-2",children:[(a==null?void 0:a(c))||c,e.jsx(Le,{className:"h-3 w-3 shrink-0 ltr:ml-2 rtl:mr-2"})]},c))},qe=Ml,Il=()=>{const{watch:t,setValue:a}=_e(),s=t("selectedDepartureFlight")?"returnFilters":"departureFilters",l=t(s),{locale:n}=X(),{t:r}=S(["flight_common"]),{isMobile:i}=je(),{elements:u,showClearAllFilters:c}=b.useMemo(()=>{const m=g=>l[g].length>0,o=Object.keys(l).some(g=>m(g)),p=[e.jsx(qe,{filterKey:"airlines"},"airlines"),e.jsx(qe,{filterKey:"departureAirports"},"departureAirports"),e.jsx(qe,{filterKey:"arrivalAirports"},"arrivalAirports"),e.jsx(qe,{filterKey:"stops",renderLabel:g=>r("flight_common:stops",{count:g})},"stops")];return m("priceRanges")&&p.push(e.jsxs(L,{phill:!0,theme:"action",shape:"outlined",className:"text-sm ltr:mr-2 rtl:ml-2",onClick:()=>a(s,Z(F({},l),{priceRanges:Se[s].priceRanges}
1)),children:[e.jsx(Q,{originalPrice:l.priceRanges[0]})," - ",e.jsx(Q,{originalPrice:l.priceRanges[1]}),e.jsx(Le,{className:"h-3 w-3 shrink-0 ltr:ml-2 rtl:mr-2"})]},"priceRanges")),m("departureTime")&&p.push(e.jsxs(L,{phill:!0,theme:"action",shape:"outlined",className:"text-sm ltr:mr-2 rtl:ml-2",onClick:()=>a(s,Z(F({},l),{departureTime:Se[s].departureTime})),children:[e.jsxs("span",{children:[r("flight_common:departure_time")," ",Ue(l.departureTime[0],n)," -"," ",Ue(l.departureTime[1],n)]}),e.jsx(Le,{className:"h-3 w-3 shrink-0 ltr:ml-2 rtl:mr-2"})]},"departureTime")),m("arrivalTime")&&p.push(e.jsxs(L,{phill:!0,theme:"action",shape:"outlined",className:"text-sm ltr:mr-2 rtl:ml-2",onClick:()=>a(s,Z(F({},l),{arrivalTime:Se[s].arrivalTime})),children:[e.jsxs("span",{children:[r("flight_common:arrival_time")," ",Ue(l.arrivalTime[0],n)," -"," ",Ue(l.arrivalTime[1],n)]}),e.jsx(Le,{className:"h-3 w-3 shrink-0 ltr:ml-2 rtl:mr-2"})]},"arrivalTime")),o&&p.push(e.jsx(L,{onClick:()=>a(s,Se[s]),className:"text-sm underline underline-offset-2",shape:"text",theme:"transparent",children:r("flight_common:clear_all_filters")},"clearAll")),{elements:p,showClearAllFilters:o}},[r,l,a,s,n]);return c&&(i?e.jsx(Ee,{options:{dragFree:!0},rootClassName:"my-4",children:u.map(m=>e.jsx("div",{className:"shrink-0",children:m},m.key))}):e.jsx("div",{className:"my-4 flex flex-wrap items-center gap-y-2",children:u.map(m=>m)}))},Ue=(t,a)=>B(new Date(0,0,0,t),a,{timeZone:void 0,timeStyle:"short"}),El=Il,$l=({className:t})=>{const{appLoadingComponent:a}=Xa();return e.jsx("section",{className:G("container flex max-w-screen-2xl flex-col gap-4 overflow-hidden px-0 pb-12 pt-20","lg:mt-0 lg:flex-row lg:overflow-visible lg:px-6 lg:pb-8",t),children:e.jsx("div",{className:"flex h-[calc(100svh-150px)] grow flex-col items-center justify-center space-y-1 rounded-xl lg:h-auto lg:min-h-[500px]",children:a||e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"h-20 w-52 md:h-32 md:w-72 md:py-4"}),e.jsx(Qa,{})]})})})},Dt=$l,Rl=({fare:t,flight:a,onFareSelect:s})=>{var l,n;const{selectFare:r}=Ct(),{watch:i,setValue:u}=de(),{t:c}=S("flight_common"),{trackEvent:m}=Y(),[o,p,g]=i(["search","selectedDepartureFlight","searchId"]),h=o.connectionType,v=o.connectionType==="round_trip"&&!p,f=()=>{var y,x,k;const j=t.fareId?t.fareId:a.id;v?u("selectedDepartureFlight",Z(F({},a),{id:j,price:Z(F({},a.price),{totalAmount:t.price-a.price.totalAmount+a.price.cheapestRoundtripTotal})})):s?s(j):r({fareId:j,searchId:g||""}),m({event:"flights_farefamily_clicked",data:{farefamily_airlines:(k=(x=(y=a.legs[0])==null?void 0:y.segments[0])==null?void 0:x.airline)==null?void 0:k.airlineName,farefamily_prices:t.price,farefamily_name:t.fareName,flight_id:a.id,round_trip:h==="round_trip"}})},_=Math.round(t.price-a.price.totalAmount);return e.jsxs(ae,{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx(d,{variant:"body-L",children:t.fareName}),e.jsx(d,{color:"text-secondary",variant:"body-S",children:c(`flight_common:${o.class}`)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lt,{className:"h-4 w-4 shrink-0"}),e.jsx(Q,{originalPrice:_,currency:t.currencyCode,className:"mb-0.5 text-3xl",priceClassName:"ltr:mr-1 rtl:ml-1"})]}),h==="round_trip"?e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"body-S",children:c("flight_common:total_roundtrip_price")}),e.jsx(d,{color:"text-secondary",variant:"body-S",className:"mb-2.5",children:c("flight_common:for_all_passengers")})]}):e.jsx(d,{color:"text-secondary",variant:"body-S",className:"mb-2.5",children:c("flight_common:total_for_all_passengers")}),e.jsxs("div",{className:"space-y-8 pb-8 pt-2",children:[e.jsxs("div",{children:[e.jsx(d,{color:"text-secondary",variant:"body-S",className:"mb-2 font-light",children:c("flight_common:baggage_allowance")}),e.jsx(ze,{baggage:t.baggage,className:"space-y-3"})]}),e.jsxs("div",{children:[e.jsx(d,{color:"text-secondary",variant:"body-S",className:"mb-2 font-light",children:c("flight_common:cancel_date_change")}),e.jsx(nt,{penalty:t.penalty})]}),(!!t.checkin.airportCheckin.price||!!t.checkin.onlineCheckin.timeBeforeDeparture)&&e.jsxs("div",{children:[e.jsx(d,{color:"text-secondary",variant:"body-S",className:"mb-2 font-light",children:c("flight_common:check_in")}),((n=(l=t.checkin)==null?void 0:l.airportCheckin)==null?void 0:n.price)!==void 0&&t.checkin.airportCheckin.price>=0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex gap-2",children:t.checkin.airportCheckin.price===0?e.jsxs(e.Fragment,{children:[e.jsx($e,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),e.jsx(d,{variant:"body-S",className:"font-light",children:c("flight_common:check_in_without_fees")})]}):e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"mt-0.5 h-4 w-4 shrink-0 text-blue-500"}),e.jsxs(d,{as:"div",variant:"body-S",children:[c("flight_common:check_in_fees"),e.jsx(Q,{originalPrice
1:t.checkin.airportCheckin.price,currency:t.checkin.airportCheckin.currency,className:"ms-0.5 inline-block [&_svg]:h-3 [&_svg]:w-3",priceClassName:"text-body-S"})]})]})}),!!t.checkin.onlineCheckin.timeBeforeDeparture&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Me,{className:"mt-0.5 h-4 w-4 shrink-0 text-blue-500"}),e.jsx(d,{variant:"body-S",className:"font-light",children:c("flight_common:check_in_time",{count:t.checkin.onlineCheckin.timeBeforeDeparture})})]})]})]})]}),e.jsx(L,{className:"mt-auto w-full",theme:"action",onClick:f,children:c("flight_common:select")})]})},Ol=Rl,Bl=({flight:t,onFareSelect:a})=>{const{watch:s}=_e(),l=s("searchId"),{isMobile:n}=je(),{data:r,isLoading:i,isError:u}=ws({flightId:t.price.hasFareFamilies?t.id:void 0,searchId:l}),{t:c}=S(["flight_common"]);if(i)return e.jsx(Vl,{});if(u)return e.jsxs("div",{className:"flex items-center justify-between py-4",children:[e.jsx(d,{variant:"body-L",color:"error",children:c("flight_common:fare_error")}),e.jsx(L,{onClick:()=>{window.location.reload()},children:c("flight_common:refresh")})]});if(!(r!=null&&r.length))return e.jsx(d,{variant:"body-L",className:"py-4",children:c("flight_common:no_fares_available")});const m=r.sort((o,p)=>o.price-p.price);return e.jsx(Ee,{arrows:"top",options:{dragFree:!0},rootClassName:"py-4",title:!n&&e.jsx(d,{variant:"heading-M",children:c("flight_common:select_fare_type")}),children:m.map((o,p)=>e.jsx("div",{className:"relative mr-4 flex shrink-0 basis-72",children:e.jsx(Ol,{fare:o,flight:t,onFareSelect:a})},p))})},Vl=()=>e.jsx(Ee,{options:{dragFree:!0},rootClassName:"py-4",renderHeader:()=>e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"bg-body-dark/10 h-6 w-40 animate-pulse rounded"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"bg-body-dark/10 h-[30px] w-[30px] animate-pulse rounded-lg"}),e.jsx("div",{className:"bg-body-dark/10 h-[30px] w-[30px] animate-pulse rounded-lg"})]})]}),children:[...Array(3)].map((t,a)=>e.jsx("div",{className:"relative mr-4 shrink-0 basis-[300px]",children:e.jsx("div",{className:"bg-body-dark/10 h-[400px] animate-pulse rounded-lg"})},a))}),qt=Bl,Zl=({leg:t,className:a})=>{const{t:s}=S("flight_common"),l=t.segments.length-1,n=t.layover,{day:r,hour:i,minute:u}=Pe({from:new Date,to:te({date:new Date,value:t.durationInMinutes,interval:"minute"}),includeZero:!0}),c=r*24+i;return e.jsxs(d,{variant:"body-S",color:"text-secondary",className:G("text-center",a),as:"span",children:[s("flight_common:duration_format",{hours:c.toString().padStart(2,"0"),minutes:u.toString().padStart(2,"0")})," ","•"," ",n.length?e.jsx(es,{className:"space-y-2 text-start",content:n.map((m,o)=>{const{hour:p,minute:g}=Pe({from:new Date,to:te({date:new Date,value:m.duration,interval:"minute"}),includeZero:!0});return e.jsx(d,{variant:"body-S",children:e.jsx(xt,{ns:"flight_common",i18nKey:"layover",values:{count:o+1,hours:p,minutes:g,city:m.cityName,airportCode:m.departureAirportCode,ordinal:"true"},children:e.jsx("span",{className:l<2?"hidden":""})})},o)}),children:e.jsx(d,{as:"span",variant:"body-S",className:"whitespace-nowrap text-blue-500",children:s("flight_common:stops",{count:l})})}):e.jsx(d,{as:"span",variant:"body-S",className:`whitespace-nowrap ${l>0?"text-blue-500":"text-text-secondary"}`,children:l>0?s("flight_common:stops",{count:l}):s("flight_common:direct")})]})},Hl=Zl,zl=({leg:t,hasReturnVariants:a})=>{const{locale:s}=X(),{watch:l}=_e(),n=l("selectedDepartureFlight"),r=t.segments[0],i=t.segments[t.segments.length-1],u=new Date(i.arrivalDateTime),c=new Date(r.departureDateTime),m=u.getTime()-c.getTime(),o=Math.floor(m/(1e3*60*60*24)),p=g=>B(new Date(g),s,{hour:"2-digit",minute:"2-digit",hour12:!0,timeZone:void 0});return!r||!i?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`mb-2 items-center gap-1 lg:hidden ${a&&n?"hidden":"flex"}`,children:[e.jsx("img",{src:r.airline.airlineLogoUrl,alt:r.airline.airlineName,width:24,height:24}),e.jsx(d,{variant:"body-XS",children:r.airline.airlineName})]}),e.jsxs("div",{className:"lg:py-XS flex items-center gap-1 lg:items-center lg:gap-16",children:[e.jsxs("div",{className:`w-full max-w-[110px] flex-row items-center gap-4 lg:flex ${a?"flex":"hidden"}`,children:[e.jsx("img",{src:r.airline.airlineLogoUrl,alt:r.airline.airlineName,width:40,height:34}),e.jsx(d,{variant:"body-S",color:"text-secondary",className:a?"hidden lg:block":"block",children:r.airline.airlineName})]}),e.jsxs("div",{className:"mx-auto w-full",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(d,{className:"lg:text-body-L w-full max-w-24 whitespace-nowrap",children:p(r.departureDateTime)}),e.jsxs("div",{className:"flex w-full items-center justify-center",children:[e.jsx(ie,{className:"ml-M w-full"}),e.jsx(wt,{className:"text-text-secondary mx-XS h-4 w-4 shrink-0 rtl:-scale-100"}),e.jsx(ie,{className:"mr-M w-full"})]}),e.jsx(d,{className:"lg:text-body-L w-full max-w-24 whitespace-nowrap text-end",children:p(i.arrivalDateTime)}),o>0&&e.jsxs(d,{variant:"body-XS",className:"absolute -top-3 right-0 font-thin",children:["+",o]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(d,{variant:"body-S",color:"text-secondary",className:"lg:text-body-M min-w-8",children:r.departureAirportCode}),e.jsx(Hl,{leg:t}),e.jsx(d,{variant:"body-S",color:"text-secondary",className:"lg:text-body-M min-w-8 text-end",children:i.arrivalAirportCode})]})]})]})]})},Xl=zl,ql=({flight:t,position:a,onFareSelect:s})=>{const[l,n]=b.useState(!1),{selectFare:r,trackSelectedStep:i}=Ct(),{t:u}=S(["flight_common"]),{watch:c,setValue:m}=_e(),[o,p,g,h,v,f,_,y]=c(["selectedDepartureFlight","search","departureListLoadTime","returnListLoadTime","filteredFlights","returnFlights","flights","searchId"]),x=p.connectionType,{isMobile:k}=je(),j=b.useRef(null),N=t.legs[0],w=t.legs[t.legs.length-1].segments[0],R=N.segments[0].departureAirportCode,$
1=x==="multi_city"?w.arrivalAirportCode:N.segments[N.segments.length-1].arrivalAirportCode,M=x==="round_trip",I=!o&&M,D=()=>{if(t.id===(o==null?void 0:o.id)){m("selectedDepartureFlight",void 0);return}const q=o?h:g,z=q?`${((Date.now()-q)/1e3).toFixed(0)}s`:void 0;if(i({step:o?"choose_returning_flight":"choose_departing_flight",position:a,timeSpent:z,search:p,filteredFlights:v,returnFlights:f,flights:_}),I&&!t.price.hasFareFamilies){m("selectedDepartureFlight",o?void 0:t);return}if(t.price.hasFareFamilies||t.fares.length>1){O();return}(o==null?void 0:o.id)!==t.id&&(s?s(t.id):r({fareId:t.id,searchId:y||""}))},C=Math.round(t.price.totalAmount),T=Math.round(t.price.cheapestRoundtripTotal),P=I?T:t.id===(o==null?void 0:o.id)?C:Math.round(t.price.roundtripTotalDiff),H=M?P:C,O=()=>{var q;k?(q=j.current)==null||q.open():n(z=>!z)};return e.jsxs(ae,{children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:q=>{q.key==="Enter"&&D()},onClick:D,className:"flex w-full flex-col lg:flex-row lg:items-stretch",children:[e.jsx("div",{className:"w-full",children:t.legs.map((q,z)=>e.jsxs(b.Fragment,{children:[e.jsx(Xl,{hasReturnVariants:t.id===(o==null?void 0:o.id),leg:q}),z!==t.legs.length-1&&e.jsx("hr",{className:"border-paper my-2 border-t border-dashed lg:my-4"})]},z))}),e.jsx("div",{className:"border-paper hidden shrink-0 items-stretch border-l lg:block ltr:ml-12 rtl:mx-12"}),e.jsx(ie,{className:"my-2 block lg:hidden"}),e.jsxs("div",{className:"flex flex-col items-end gap-px lg:w-full lg:max-w-40 lg:justify-center",children:[e.jsxs("div",{className:"flex w-full items-center justify-end gap-1",children:[(t.price.hasFareFamilies||t.fares.length>1)&&!o?e.jsx(d,{color:"text-secondary",variant:"body-S",className:"lg:text-body-M",children:u("flight_common:from")}):null,o&&!I&&H>=0&&e.jsx(lt,{className:"h-3 w-3 shrink-0"}),e.jsx(Q,{originalPrice:H,currency:t.price.currencyCode||"SAR",className:"lg:text-heading-S"})]}),I&&e.jsx(d,{variant:"body-XS",color:"text-secondary",className:"w-full text-end font-light",children:u("flight_common:round_trip_note")})]})]}),k?e.jsx(Ae,{ref:j,onClose:()=>n(!1),ignoreHistory:!0,type:"sheet",title:e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"heading-S",children:u(o?"flight_common:select_return_fare":"flight_common:select_departure_fare")}),e.jsxs(d,{variant:"body-S",color:"text-secondary",className:"flex items-center gap-px",children:[x==="round_trip"?$:R,p.connectionType==="round_trip"?e.jsx(He,{className:"h-4 w-4 shrink-0 rotate-90"}):p.connectionType==="multi_city"?e.jsx(jt,{className:"h-4 w-4 shrink-0 rtl:rotate-180"}):e.jsx(Te,{className:"h-4 w-4 shrink-0 ltr:rotate-180 rtl:-mt-1"}),x==="round_trip"?R:$," •"," ",u(`flight_common:${p.connectionType}`)]})]}),cancel:!1,action:!1,body:()=>e.jsx(qt,{flight:t,onFareSelect:s})}):e.jsx(Ne,{children:l&&e.jsx(be.div,{initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{ease:"linear"},children:e.jsx(qt,{flight:t,onFareSelect:s})})})]})},Ye=ql,Ul=()=>{const{trackEvent:t}=Y(),{t:a}=S(["flight_common"]),{control:s,watch:l,setValue:n}=_e(),[r,i,u,c]=l(["selectedDepartureFlight","filteredFlights","flights","sId"]);b.useEffect(()=>{if(u!=null&&u.length){const g=u.flatMap(f=>f.fares.map(_=>_.price))||[],h=Math.min(...g),v=Math.max(...g);t({event:"flights_result_list_loaded",data:{total_results:u.length,lowest_price:h,highest_price:v}})}},[u]);const{data:m,isLoading:o}=oa({sId:c||"",flightId:(r==null?void 0:r.id)||""},{enabled:!!c&&!!(r!=null&&r.id)});b.useEffect(()=>{m!=null&&m.flights.length&&(n("returnFlights",m.flights),n("returnListLoadTime",Date.now()))},[m]);const p=()=>{n("selectedDepartureFlight",void 0)};return!u||!u.length?e.jsx("div",{className:"text-text-secondary flex h-32 items-center justify-center",children:a("flight_common:no_available_flights")}):e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"hidden w-full max-w-sm lg:block",children:[e.jsx(d,{variant:"heading-M",className:"mb-4",children:a("flight_common:filter_by")}),e.jsx(K,{control:s,name:r?"returnFilters":"departureFilters",render:({field:{onChange:g,value:h}})=>e.jsx(Na,{value:h,onChange:g})},r?"returnFilters":"departureFilters")]}),e.jsxs("div",{className:"grow overflow-x-hidden pt-1 lg:pt-0",children:[e.jsx(Ne,{children:!!r&&e.jsxs(be.div,{className:"bg-body-level-1 mb-8 scroll-mt-20 space-y-4 rounded-lg p-4",initial:{opacity:0}
1,whileInView:{opacity:1},viewport:{once:!0},transition:{duration:.6},ref:g=>{g&&et(g.id)},id:"selected-departure-flight",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yt,{className:"text-success [&>path]:stroke-body-level-1 h-4 w-4 shrink-0"}),e.jsx(d,{color:"text-secondary",className:"lg:text-body-L",children:a("flight_common:selected_departure_flight")})]}),e.jsx(L,{shape:"text",theme:"primary",onClick:p,children:a("flight_common:change")})]}),e.jsx(Ye,{flight:r})]})}),o?e.jsx(Dt,{}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(d,{variant:"heading-M",as:"h1",className:"lg:text-heading-XL",children:a(r?"flight_common:choose_return_flight":"flight_common:choose_departure_flight")}),e.jsx(K,{control:s,name:r?"returnFilters":"departureFilters",render:({field:{onChange:g,value:h}})=>e.jsx(wa,{value:h,onChange:g})},r?"returnFilters":"departureFilters")]}),e.jsx(El,{}),e.jsx("div",{className:"flex justify-between gap-px lg:flex-row lg:items-center lg:gap-1",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(d,{variant:"body-S",className:"lg:text-body-M",children:[a("flight_common:results_sorted_by",{count:i.length})," "]}),e.jsx(K,{control:s,name:"sortBy",render:({field:{value:g,onChange:h}})=>e.jsx(Tl,{value:g,onChange:h})})]})})]}),e.jsxs(d,{variant:"body-S",color:"text-secondary",className:"flex items-center gap-1",children:[e.jsx(Me,{className:"h-4 w-4 shrink-0"}),a("flight_common:exclude_service_fee")]}),i.map((g,h)=>e.jsx(Ye,{flight:g,position:h+1},`${h}-${r}`))]})]})]})},Wl=Ul,Gl="https://apps.apple.com/us/app/webook-com-fun-things-to-do/id6468667896",Jl="https://play.google.com/store/apps/details?id=com.webook.android",Kl="https://appgallery.huawei.com/app/C109536445",Yl=({passengers:t,legs:a,penalty:s,triggerClassName:l=""})=>{const[n,r]=b.useState(!1),[i,u]=b.useState(0),{t:c}=S("flight_common"),m=[c("flight_common:cancellation_note_p1"),c("flight_common:cancellation_note_p2"),c("flight_common:cancellation_note_p3"),c("flight_common:cancellation_note_p4"),c("flight_common:cancellation_note_p5"),c("flight_common:cancellation_note_p6")];return e.jsx(Ae,{title:c("flight_common:changes_and_cancellation"),render:({open:o})=>e.jsxs(L,{shape:"text",theme:"transparent",className:G("flex w-full items-center justify-between p-4",l),onClick:o,children:[e.jsx(d,{variant:"heading-S",children:c("flight_common:changes_and_cancellation")}),e.jsx(ge,{className:"h-4 w-4 shrink-0 rtl:rotate-180"})]}),size:"lg",cancel:!1,action:!1,body:()=>{var o,p;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{containerClassName:"gap-3",children:a.map((g,h)=>{var v,f;return e.jsxs(L,{shape:"outlined",theme:"action",onClick:()=>u(h),className:G("flex min-w-max items-center gap-4",i!==h&&"opacity-50"),children:[e.jsx("img",{src:(v=g.segments[0].airline)==null?void 0:v.airlineLogoUrl,alt:(f=g.segments[0].airline)==null?void 0:f.airlineName,width:20,height:20,className:"h-5 w-5 shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(d,{variant:"body-L",className:"shrink-0",children:a[h].segments[0].departureCityName}),e.jsx(Te,{className:"shrink-0 ltr:rotate-180"}),e.jsx(d,{variant:"body-L",className:"shrink-0",children:a[h].segments[a[h].segments.length-1].arrivalCityName})]})]},h)})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(d,{variant:"body-L",className:"font-semibold",children:c("flight_common:cancellation_fees")}),e.jsxs("div",{className:"border-paper-level-1 xs:flex-row xs:items-center flex flex-col justify-between gap-1 rounded-lg border p-4 text-sm md:text-base",children:[e.jsx(d,{className:"font-medium",children:c(`flight_common:${t.length>1?"all_passengers":(o=t.passenger_type)==null?void 0:o.toLocaleLowerCase()}`)}),s[i]&&e.jsx(va,{showPrice:!0,penalty:s[i],className:"text-text-secondary flex items-center gap-2 text-sm md:text-base"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(d,{variant:"body-L",className:"font-semibold",children:c("flight_common:date_changes_fees")}),e.jsxs("div",{className:"border-paper-level-1 xs:flex-row xs:items-center flex flex-col justify-between gap-1 rounded-lg border p-4 text-sm md:text-base",children:[e.jsx(d,{className:"font-medium",children:c(`flight_common:${t.length>1?"all_passengers":(p=t.passenger_type)==null?void 0:p.toLocaleLowerCase()}`)}),s[i]&&e.jsx(fa,{showPrice:!0,penalty:s[i],className:"text-text-secondary flex items-center gap-2 text-sm md:text-base"})]})]}),e.jsx("ul",{className:"list-disc ltr:pl-4 rtl:pr-4",children:m.slice(0,n?void 0:1).map((g,h)=>e.jsx("li",{className:"text-sm md:text-base",children:g},h))}),e.jsx(L,{shape:"text",onClick:()=>r(!n),children:c(`flight_common:${n?"read_less":"read_more"}`)})]})}})},rt=Yl,Ql=()=>e.jsxs("div",{className:"py-10",children:[e.jsx("section",{className:"container space-y-4 py-4",children:e.jsx("div",{className:"bg-body-dark/10 h-8 w-40 animate-pulse rounded-lg"})}),e.jsxs("section",{className:"container flex flex-col gap-6 p-4 xl:flex-row",children:[e.jsxs("div",{className:"grow space-y-6",children:[e.jsx("div",{className:"bg-body-dark/10 h-96 animate-pulse rounded-lg"}),e.jsx("div",{className:"bg-body-dark/10 h-64 animate-pulse rounded-lg"}),e.jsx("div",{className:"bg-body-dark/10 h-48 animate-pulse rounded-lg"})]}),e.jsx("div",{className:"hidden w-full max-w-[36%] shrink-0 grow space-y-6 xl:block",children:e.jsx("div",{className:"bg-body-dark/10 h-80 animate-pulse rounded-lg"})})]})]}),en=Ql,tn=({legs:t,triggerClassName:a})=>{const{t:s}=S(["flight_common"]),[l,n]=b.useState(0);return e.jsx(Ae,{title:s("flight_common:baggage_allowance"),render:({open:r})=>e.jsxs(L,{shape:"text",theme:"transparent",className:G("flex w-full items-center justify-between p-4",a),onClick:r,children:[e.jsx(d,{as:"span",variant:"heading-S",children:s("flight_common:baggage_allowance")}),e.jsx(ge,{className:"h-4 w-4 shrink-0 rtl:rotate-180"})]}),size:"lg",cancel:!1,action:!1,body:()=>
1e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{containerClassName:"gap-3",children:t.map((r,i)=>{var u,c;return e.jsxs(L,{shape:"outlined",theme:"action",onClick:()=>n(i),className:G("flex min-w-max items-center gap-4",l!==i&&"opacity-50"),children:[e.jsx("img",{src:(u=r.segments[0].airline)==null?void 0:u.airlineLogoUrl,alt:(c=r.segments[0].airline)==null?void 0:c.airlineName,width:20,height:20,className:"h-5 w-5 shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(d,{variant:"body-L",className:"shrink-0",children:t[i].segments[0].departureCityName}),e.jsx(Te,{className:"shrink-0 ltr:rotate-180"}),e.jsx(d,{variant:"body-L",className:"shrink-0",children:t[i].segments[t[i].segments.length-1].arrivalCityName})]})]},i)})}),e.jsx(ze,{baggage:t[l].baggage,className:"border-paper space-y-3 rounded-lg border p-4"})]})})},it=tn,an=({text:t})=>{const[a,s]=b.useState(!1),{t:l}=S(["flight_common"]),n=b.useRef(void 0);b.useEffect(()=>{const i=setTimeout(()=>{s(!1)},1e3);return()=>clearTimeout(i)},[a]);const r=()=>{var i;try{navigator.clipboard.writeText(t),s(!0)}catch{(i=n.current)==null||i.publish({title:l("flight_common:copy_error"),type:"error"})}};return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(L,{theme:"transparent",shape:"text",className:"px-1",onClick:r,children:e.jsx(_s,{className:"h-4 w-4 shrink-0"})}),e.jsx(d,{className:`transition-all ${a?"opacity-100":"opacity-0"}`,variant:"body-XS",children:l("flight_common:copied")}),e.jsx(ss,{ref:n,swipeDirection:"up"})]})},Ut=an,sn=({passengersCount:t,order:a})=>{const{trackEvent:s}=Y(),{locale:l}=X(),{t:n}=S(["flight_common"]),r=a.booking_data.legs,i=r.length===1,u=r[0].segments[0],c=r[r.length-1].segments[r[r.length-1].segments.length-1],m=u.departureCityName,o=i?c.arrivalCityName:r[r.length-1].segments[0].departureCityName,p=b.useMemo(()=>{if(r.length===0)return null;const N=I=>I.toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",A=new Date(u.departureDateTime),w=new Date(c.arrivalDateTime),R=N(A),$=N(w),M=`${m} to ${o}`;return`https://calendar.google.com/calendar/render?action=TEMPLATE&dates=${R}/${$}&text=${encodeURIComponent(M)}`},[u.departureDateTime,m,c.arrivalDateTime,r.length,o]),g=B(new Date(u.departureDateTime),l,{dateStyle:"long",timeStyle:"short",timeZone:void 0}),h=a.booking_data.legs.length,v=h>2?"multi_city":h===2?"round_trip":"one_way",f=u.departureAirportCode,_=u.departureAirportName,y=u.departureTerminalNo,x=t.adult,k=t.child,j=t.infant;return e.jsx("div",{className:"space-y-6 lg:space-y-0",children:e.jsxs("div",{className:"border-paper space-y-6 rounded-lg border p-4",children:[e.jsx(d,{variant:"heading-M",className:"font-semibold",children:n("flight_common:booking_details")}),e.jsxs("div",{className:"flex flex-row items-center gap-6",children:[e.jsx("img",{src:"/@wbk/flights/plane.png",alt:"Airplane",height:106,width:106,className:"shrink-0"}),e.jsxs("div",{children:[e.jsx(d,{variant:"body-S",color:"text-secondary",children:n("flight_common:flight")}),e.jsxs(d,{className:"flex gap-1 text-lg font-medium",children:[e.jsx("span",{children:m}),e.jsx("span",{className:"lowercase",children:n("flight_common:to")}),e.jsx("span",{children:o})]}),e.jsx(d,{variant:"body-S",color:"text-secondary",children:n(`flight_common:${v}`)})]})]}),a.booking_status!=="failed"&&e.jsx(L,{theme:"transparent",shape:"text",className:"pl-0 underline underline-offset-2",onClick:()=>et("flight-summary"),children:n("flight_common:view_flight_details")}),e.jsxs("div",{className:"space-y-4",children:[a.booking_status!=="failed"&&e.jsxs(ae,{className:"inline-block space-y-6",children:[e.jsx(d,{children:n("flight_common:pnr_ref")}),a.booking_data.pnrDetails?a.booking_data.pnrDetails.map(N=>e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("img",{src:N.airline.airlineLogoUrl,alt:N.airline.airlineName,width:24,height:24,className:"shrink-0"}),e.jsxs("div",{children:[e.jsxs(d,{variant:"body-S",color:"text-secondary",className:"inline-flex items-center gap-1",children:[e.jsx("span",{children:N.originCode})," ",e.jsx(Te,{className:"ltr:rotate-180"}),e.jsx("span",{children:N.destinationCode})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx(d,{variant:"body-L",children:N.pnrNumber}),e.jsx(Ut,{text:N.pnrNumber})]})]})]},N.pnrNumber)):e.jsxs(e.Fragment,{children:[e.jsx(d,{children:n("flight_common:retrieving")}),e.jsx(ut,{className:"text-text-secondary h-4 w-4 shrink-0 animate-spin"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/@wbk/flights/icons/doc.svg",alt:"document",width:24,height:24}),e.jsxs("div",{className:"overflow-hidden",children:[e.jsx(d,{variant:"body-S",color:"text-secondary",children:n("flight_common:booking_id")}),e.jsx("div",{className:"flex items-center",children:a.payment_status!=="on-hold"&&a.booking_status?e.jsxs(e.Fragment,{children:[e.jsx(d,{className:"break-words",children:a.booking_data.orderNumber}),e.jsx(Ut,{text:a.booking_data.orderNumber})]}):e.jsxs(e.Fragment,{children:[e.jsx(d,{children:n("flight_common:retrieving")}),e.jsx(ut,{className:"text-text-secondary h-4 w-4 shrink-0 animate-spin"})]})})]})]}),a.booking_status!=="failed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/@wbk/flights/icons/user.svg",alt:"user",width:24,height:24}),e.jsxs("div",{children:[e.jsx(d,{variant:"body-S",color:"text-secondary",children:n("flight_common:tickets")}),e.jsxs(d,{children:[x>0&&e.jsxs("span",{children:[n("flight_common:adults_count",{count:x})," "]}),k>0&&e.jsxs("span",{children:[n("flight_common:child_count",{count:k})," "]}),j>0&&e.jsxs("span",{children:[n("flight_common:infants_count",{count:j})," "]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/@wbk/flights/icons/clock.svg",alt:"clock",width:24,height:24}),e.jsxs("div",{children:[e.jsx(d,{variant:"body-S",color:"text-secondary",children:n("flight_common:departs")}),e.jsx(d,{children:g})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/@wbk/flights/icons/location.svg",alt:"location",width:24,height:24}),e.jsxs("div",{children:[e.jsx(d,{variant:"body-S",color:"text-secondary",children:n("flight_common:location")}),e.jsx(d,{children:`${_} (${f}) - ${n("flight_common:terminal_number",{terminal:y})} `})]})]})]}),a.booking_status==="failed"?e.jsxs(L,{theme:"action",shape:"outlined",className:"w-full",as:"a",onClick:()=>s({event:"flights_support_clicked",data:{page_context:"Support contacted - Email"}}),href:"mailto:[email protected]",children:[e.jsx(ia,{className:"h-5 w-5 shrink-0"}),e.jsx("span",{children:n("flight_common:contact_us_by_email")})]}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[!!a.booking_data.ticketPdf&&e.jsx(L,{theme:"action",as:"a",download:!0,href:a.booking_data.ticketPdf,className:"w-full sm:max-w-56",children:n("flight_common:view_tickets")}),!!p&&e.jsxs(L,{as:"a",href:p,target:"_blank",theme:"white",shape:"outlined",className:"w-full sm:max-w-56",children:[e.jsx("img",{alt:n("flight_common:add_to_calendar"),src:"/@wbk/flights/icons/calendar.svg",width:24,height:24}),n("flight_common:add_to_calendar")]}),!!a.booking_data.ticketPdf&&e.jsx(as,{data:{title:n("flight_common:flight_from_to",{from:m,to:o}),text:n("flight_common:flight_from_to",{from:m,to:o}),url:a.booking_data.ticketPdf},render:({share:N})=>e.jsxs(L,{theme:"action",shape:"outlined",className:"w-full sm:max-w-56",onClick:()=>{s({event:"flights_booking_shared",data:{booking_id:a.booking_data.id}}),N()},children:[e.jsx("img",{alt:n("flight_common:share"),src:"/@wbk/flights/icons/share.svg",width:21,height:22}),n("flight_common:share_booking_details")]})})]})]})]})})},ln=sn,nn=({passengerType:t,total:a,currency:s,base:l,tax:n,index:r})=>{const[i,u]=b.useState(!1),{t:c}=S(["flight_common"]);return e.jsxs(e.Fragment,{children:[e.jsxs(L,{className:"w-full justify-between px-0 text-sm",onClick:()=>u(!i),shape:"text",theme:"transparent",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("span",{className:"min-w-32 text-start",children:[c("flight_common:passenger")," ",r+1,": ",c(`flight_common:${t}`)]}),e.jsx(ge,{className:`h-3.5 w-3.5 transition-all ${i?"-rotate-90":"rotate-90"}`})]}
1),e.jsx(Q,{originalPrice:a,currency:s})]}),e.jsx(Ne,{children:i&&e.jsxs(be.div,{initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{duration:.3},className:"text-text-secondary space-y-2 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx(d,{children:c("flight_common:fare")}),e.jsx(Q,{originalPrice:l,currency:s})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx(d,{children:c("flight_common:taxes")}),e.jsx(Q,{originalPrice:n,currency:s})]})]})})]})},Sa=nn,rn=({order:t,className:a})=>{const[s,l]=b.useState(!1),{mutateAsync:n,error:r}=ks(),{trackEvent:i}=Y(),{isWebView:u}=je(),{locale:c}=X(),{t:m}=S(["flight_common"]),o=t.booking_data.fareDetails,p=b.useMemo(()=>{var h,v,f;const _=(h=o.passengerFares)==null?void 0:h.adult,y=(v=o.passengerFares)==null?void 0:v.child,x=(f=o.passengerFares)==null?void 0:f.infant,k=Array.from({length:_.count},()=>{var A,w,R;return{type:"adult",total:(A=_==null?void 0:_.priceDetails)==null?void 0:A.totalPrice,tax:(w=_==null?void 0:_.priceDetails)==null?void 0:w.tax,base:(R=_==null?void 0:_.priceDetails)==null?void 0:R.baseFare}}),j=Array.from({length:y.count},()=>{var A,w,R;return{type:"child",total:(A=y==null?void 0:y.priceDetails)==null?void 0:A.totalPrice,tax:(w=y==null?void 0:y.priceDetails)==null?void 0:w.tax,base:(R=y==null?void 0:y.priceDetails)==null?void 0:R.baseFare}}),N=Array.from({length:x.count},()=>{var A,w,R;return{type:"infant",total:(A=x==null?void 0:x.priceDetails)==null?void 0:A.totalPrice,tax:(w=x==null?void 0:x.priceDetails)==null?void 0:w.tax,base:(R=x==null?void 0:x.priceDetails)==null?void 0:R.baseFare}});return{passengersDetails:[...k,...j,...N],adultsCount:_.count,childCount:y.count,infantCount:x.count}},[o]),g=()=>ve(null,null,function*(){l(!0);try{yield n({id:t._id,lang:c}),i({event:"flights_file_downloaded",data:{orderId:t._id}})}finally{l(!1)}});return e.jsxs("div",{className:a,children:[e.jsx(ie,{type:"ticket_edges",className:"text-body-level-1"}),e.jsxs("div",{className:"border-paper bg-paper-level-1 relative -mt-1 space-y-6 p-4",children:[e.jsxs("div",{children:[e.jsx(d,{variant:"heading-M",children:m("flight_common:invoice_summary")}),e.jsx(Q,{originalPrice:o.totalPrice,currency:o.totalCurrency,className:"text-text-secondary"})]}),e.jsxs("div",{children:[p.passengersDetails.map((h,v)=>e.jsx(Sa,{index:v,passengerType:m(`flight_common:${h.type}`),total:h.total||0,currency:o.totalCurrency,base:h.base||0,tax:h.tax||0},v)),!!o.vat&&e.jsxs("div",{className:"text-text-secondary flex items-center justify-between pt-2 text-sm",children:[e.jsx(d,{children:m("flight_common:vat")}),e.jsx(Q,{originalPrice:o.vat,currency:o.totalCurrency})]}),o.fees.map((h,v)=>e.jsxs("div",{className:"text-text-secondary flex items-center justify-between pt-2 text-sm",children:[e.jsx(d,{children:m("flight_common:service_fee")}),e.jsx(Q,{originalPrice:h.price,currency:o.totalCurrency})]},v))]}),e.jsx(ie,{className:"border-paper-level-1 border-dashed"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("span",{children:m("flight_common:total")}),e.jsxs("span",{className:"text-text-secondary",children:["(",m("flight_common:includes_vat"),")"]})]}),e.jsx(Q,{originalPrice:o.totalPrice,currency:o.totalCurrency,changeable:!0})]}),(r==null?void 0:r.message)&&e.jsx(d,{color:"error",children:r.message}),!u&&e.jsxs(L,{theme:"action",shape:"outlined",className:"w-full",onClick:g,loading:s,disabled:t.payment_status==="on-hold",children:[e.jsx("img",{src:"/@wbk/flights/icons/doc.svg",alt:"calendar",width:24,height:24}),e.jsx("span",{children:m("flight_common:download_invoice")})]})]}),e.jsx(ie,{type:"ticket_edges",className:"text-body-level-1 rotate-180"})]})},Wt=rn,on=({order:t})=>{const[a,s]=b.useState(!0),{t:l}=S(["flight_common"]);return e.jsxs("div",{className:"border-paper space-y-2 rounded-lg border",children:[e.jsxs(L,{theme:"transparent",className:"w-full justify-between p-4",shape:"text",onClick:()=>s(n=>!n),children:[e.jsx(d,{variant:"heading-S",children:l("flight_common:passengers")}),e.jsx(ge,{className:`h-4 w-4 transition-all ${a?"-rotate-90":"rotate-90"}`})]}),e.jsx(Ne,{children:a&&e.jsx(be.div,{initial:{opacity:0,height:0}
1,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.1},children:e.jsx("div",{className:"space-y-3 px-4 pb-4",children:t.booking_data.travelers.map((n,r)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/@wbk/flights/icons/user.svg",alt:"calendar",width:24,height:24}),e.jsxs("div",{children:[e.jsxs(d,{className:"capitalize",children:[n.firstName," ",n.lastName]}),e.jsx(d,{variant:"body-S",color:"text-secondary",children:n.birthDate})]})]},r))})})})]})},cn=on,dn=t=>e.jsx("svg",Z(F({width:"13",height:"11",viewBox:"0 0 13 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:e.jsx("path",{d:"M11.8235 0H1.3C0.585 0 0.00649999 0.61875 0.00649999 1.375V4.125C0.7215 4.125 1.3 4.74375 1.3 5.5C1.3 6.25625 0.7215 6.875 0 6.875V9.625C0 10.3813 0.585 11 1.3 11H11.7C12.415 11 13 10.3813 13 9.625V1.375C13 0.61875 12.4735 0 11.8235 0ZM10.2245 6.39375L4.4655 8.01625L3.3865 6.03625L3.991 5.86437L4.81 6.545L6.3635 6.105L4.8035 3.245L5.7135 2.98375L8.32 5.555L9.906 5.10813C10.2375 5.01188 10.582 5.225 10.673 5.57562C10.7575 5.92625 10.5625 6.29063 10.2245 6.39375Z",fill:"currentColor"})})),mn=({segment:t,stopOverDuration:a})=>{const{locale:s}=X(),{t:l}=S(["flight_common"]),{hour:n,minute:r}=Pe({from:new Date,to:te({date:new Date,value:t.durationInMinutes,interval:"minute"}),includeZero:!0}),{hour:i,minute:u}=Pe({from:new Date,to:te({date:new Date,value:a||0,interval:"minute"}),includeZero:!0});return e.jsxs("div",{children:[!!a&&e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:"text-text-secondary w-12 shrink-0 py-8 ltr:mr-5 rtl:ml-5",children:[e.jsx(Mt,{className:"text-secondary h-3 w-3"}),e.jsx(d,{variant:"body-XS",className:"mt-1 whitespace-nowrap",children:l("flight_common:duration_format",{hours:i.toString().padStart(2,"0"),minutes:u.toString().padStart(2,"0")})})]}),e.jsx("div",{className:"flex w-3 shrink-0 flex-col items-center self-stretch ltr:mr-3 rtl:ml-3",children:e.jsx("div",{className:"bg-body-dark/10 w-px shrink-0 grow"})}),e.jsx("div",{className:"py-8",children:e.jsxs("div",{className:"bg-secondary/10 text-text-secondary space-y-1 rounded-md p-2 text-xs",children:[e.jsx(d,{variant:"body-XS",children:l("flight_common:stop_over_duration",{hours:i.toString().padStart(2,"0"),minutes:u.toString().padStart(2,"0"),city:t.departureCityName})}),e.jsx(d,{variant:"body-XS",children:l("flight_common:travel_documents_required")})]})})]}),e.jsxs("div",{className:"flex",children:[e.jsxs("div",{className:"w-12 shrink-0 ltr:mr-5 rtl:ml-5",children:[e.jsx(d,{variant:"body-S",className:"whitespace-nowrap",children:B(new Date(t.departureDateTime),s,{hour:"2-digit",minute:"2-digit",hour12:!0,timeZone:void 0})}),e.jsx(d,{variant:"body-XS",color:"text-secondary",children:B(new Date(t.departureDateTime),s,{day:"2-digit",month:"short",hour12:!0,timeZone:void 0})})]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-center self-stretch ltr:mr-3 rtl:ml-3",children:[e.jsx("span",{className:"bg-body-level-1 h-3 w-3 rounded-full"}),e.jsx("div",{className:"bg-body-dark/10 w-px shrink-0 grow"})]}),e.jsxs("div",{children:[e.jsxs(d,{variant:"body-S",children:[t.departureAirportName," (",t.departureAirportCode,")"]}),!!t.departureTerminalNo&&t.departureTerminalNo!=="N/A"&&e.jsxs(d,{variant:"body-XS",color:"text-secondary",children:[l("flight_common:terminal")," ",t.departureTerminalNo]}),e.jsxs(d,{variant:"body-XS",color:"text-secondary",children:[t.departureCityName,", ",t.departureCountryName]})]})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:"text-text-secondary w-12 shrink-0 py-8 ltr:mr-5 rtl:ml-5",children:[e.jsx(Mt,{className:"text h-3 w-3"}),e.jsx(d,{variant:"body-XS",className:"mt-1 whitespace-nowrap",children:l("flight_common:duration_format",{hours:n.toString().padStart(2,"0"),minutes:r.toString().padStart(2,"0")})})]}),e.jsx("div",{className:"flex w-3 shrink-0 flex-col items-center self-stretch ltr:mr-3 rtl:ml-3",children:e.jsx("div",{className:"bg-body-dark/10 w-px shrink-0 grow"})}),e.jsxs("div",{className:"flex items-center gap-2 py-8",children:[t.airline.airlineLogoUrl&&e.jsx("img",{src:t.airline.airlineLogoUrl,alt:t.airline.airlineName,width:24,height:24}),e.jsxs("div",{children:[e.jsxs(d,{variant:"body-S",children:[t.airline.airlineName," - ",t.aircraft.airlineCode,"-",t.aircraft.flightNumber]}),t.aircraft.aircraftName!=="N/A"&&e.jsxs(d,{variant:"body-XS",color:"text-secondary",children:[t.aircraft.aircraftName," ",t.aircraft.aircraftCode?`(${t.aircraft.aircraftCode})`:""]}),e.jsx(d,{variant:"body-XS",color:"text-secondary",children:t.airline.class})]})]})]}),e.jsxs("div",{className:"flex",children:[e.jsxs("div",{className:"w-12 shrink-0 ltr:mr-5 rtl:ml-5",children:[e.jsx(d,{variant:"body-S",className:"whitespace-nowrap",children:B(new Date(t.arrivalDateTime),s,{hour:"2-digit",minute:"2-digit",hour12:!0,timeZone:void 0})}),e.jsx(d,{variant:"body-XS",color:"text-secondary",children:B(new Date(t.arrivalDateTime),s,{day:"2-digit",month:"short",timeZone:void 0})})]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-center self-stretch ltr:mr-3 rtl:ml-3",children:[e.jsx("span",{className:"bg-body-level-1 h-3 w-3 rounded-full"}),e.jsx("div",{className:"bg-body-dark/10 w-px shrink-0 grow"})]}),e.jsxs("div",{children:[e.jsxs(d,{variant:"body-S",children:[t.arrivalAirportName," (",t.arrivalAirportCode,")"]}),!!t.arrivalTerminalNo&&t.arrivalTerminalNo!=="N/A"&&e.jsxs(d,{variant:"body-XS",color:"text-secondary",children:[l("flight_common:terminal")," ",t.arr
1ivalTerminalNo]}),e.jsxs(d,{variant:"body-XS",color:"text-secondary",children:[t.arrivalCityName,", ",t.arrivalCountryName]})]})]})]})},un=mn,hn=({leg:t})=>e.jsx("div",{className:"bg-body py-2.5 text-start",children:t.segments.map((a,s)=>{var l,n;const r=(n=(l=t.layover)==null?void 0:l.find(i=>i.departureAirportCode===a.departureAirportCode))==null?void 0:n.duration;return e.jsx(un,{segment:a,stopOverDuration:r},s)})}),Da=hn,gn=({leg:t,showLegDetails:a})=>{const{locale:s}=X(),{t:l}=S(["flight_common"]),[n,r]=b.useState(a),i=t.segments[0],u=t.segments[t.segments.length-1],c=t.segments.length-1,{day:m,hour:o,minute:p}=Pe({from:new Date,to:te({date:new Date,value:t.durationInMinutes,interval:"minute"}),includeZero:!0}),g=m*24+o,v=new Set(t.segments.map(f=>f.airline.airlineName)).size>1;return e.jsxs("div",{className:"overflow-hidden",children:[e.jsxs("div",{className:"space-y-4 pb-2 pt-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(d,{variant:"body-L",children:i.departureCityName}),e.jsx(Te,{className:"ltr:rotate-180"}),e.jsx(d,{variant:"body-L",children:u.arrivalCityName})]}),e.jsx(d,{variant:"body-S",color:"text-secondary",children:l("flight_common:flight_departs_at",{date:B(new Date(i.departureDateTime),s,{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric",timeZone:void 0})})}),e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[v?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:"/@wbk/flights/multiple-airlines.svg",alt:"Mutiple Airlines",width:21,height:21}),e.jsx(d,{variant:"label-XS",color:"text-secondary",children:l("flight_common:multiple_airlines")})]}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:i.airline.airlineLogoUrl,alt:i.airline.airlineName,width:21,height:21}),e.jsx(d,{variant:"label-XS",color:"text-secondary",children:i.airline.airlineName})]}),e.jsxs(d,{variant:"label-XS",color:"text-secondary",children:["•"," ",l("flight_common:duration_format",{hours:g.toString().padStart(2,"0"),minutes:p.toString().padStart(2,"0")}),","]}),e.jsx(d,{variant:"label-XS",className:"lowercase",color:"text-secondary",children:l("flight_common:stops",{count:c})})]})]}),e.jsxs(L,{shape:"text",theme:"transparent",className:"px-px text-xs",onClick:()=>r(f=>!f),children:[e.jsx(dn,{className:"text-text-secondary shrink-0"}),e.jsx("span",{children:l("flight_common:flight_details")})," ",e.jsx(ge,{className:`h-2 w-2 ${n?"-rotate-90":"rotate-90"}`})]})]}),e.jsx(Ne,{children:n&&e.jsx(be.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3},className:"bg-body overflow-hidden rounded-xl py-2",children:e.jsx(Da,{leg:t})})})]})},La=gn,pn=({order:t})=>{const[a,s]=b.useState(!0),{t:l}=S(["flight_common"]),n=t.booking_data.legs;return e.jsxs("div",{className:"border-paper scroll-m-20 space-y-2 rounded-lg border",id:"flight-summary",children:[e.jsxs(L,{theme:"transparent",className:"w-full justify-between p-4",shape:"text",onClick:()=>s(r=>!r),children:[e.jsx(d,{variant:"heading-S",className:"font-semibold",children:l("flight_common:flight_details")}),e.jsx(ge,{className:`h-4 w-4 transition-all ${a?"-rotate-90":"rotate-90"}`})]}),e.jsx(Ne,{children:a&&e.jsx(be.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3},children:e.jsx("div",{className:"px-4 pb-4",children:n.map((r,i)=>e.jsxs(b.Fragment,{children:[e.jsx(d,{variant:"heading-S",className:"font-semibold",children:l(i===0?"flight_common:departure":"flight_common:return")}),e.jsx(La,{showLegDetails:!0,leg:r}),i!==n.length-1&&e.jsx("hr",{className:"border-paper my-4"})]},i))})})})]})},xn=pn,fn=({order:t})=>{const{trackEvent:a}=Y(),{t:s}=S(["flight_common"]),l=t==null?void 0:t.booking_data.orderNumber;return e.jsxs("div",{className:"border-paper flex flex-col gap-6 rounded-lg border p-4",children:[e.jsx(d,{variant:"heading-S",className:"font-semibold",children:s("flight_common:need_help")}),(t==null?void 0:t.booking_status)!=="failed"&&e.jsxs(L,{theme:"action",shape:"text",className:"justify-start p-0",as:"a",onClick:()=>a({event:"flights_support_clicked",data:{page_context:"Support contacted - WhatsApp"}}),href:`https://wa.me/+966533704256?text=${encodeURIComponent(s("flight_common:whatsapp_message",{orderNumber:l}))}`,children:[e.jsx(fs,{className:"h-5 w-5 shrink-0"}),e.jsx("span",{className:"underline",children:s("flight_common:contact_us_by_whatsapp")})]}),e.jsxs(L,{theme:"action",shape:"text",className:"justify-start p-0",as:"a",onClick:()=>a({event:"flights_support_clicked",data:{page_context:"Support contacted - Call"}}),href:"tel:+966920012117",children:[e.jsx(vs,{className:"h-5 w-5 shrink-0"}),e.jsxs("div",{className:"underline",children:[e.jsx("span",{children:s("flight_common:call_us")})," ",e.jsx("span",{dir:"ltr",className:"underline",children:"+966 92 001 2117"})]})]}),e.jsxs(L,{theme:"action",shape:"text",className:"justify-start p-0",as:"a",onClick:()=>a({event:"flights_support_clicked",data:{page_context:"Support contacted - Email"}}),href:"mailto:[email protected]",children:[e.jsx(ia,{className:"h-5 w-5 shrink-0"}),e.jsx("span",{className:"underline",children:s("flight_common:contact_us_by_email")})]})]})},vn=fn,_n=({id:t})=>{var a,s,l,n,r;const[i,u]=b.useState(!0),{isWebView:c}=je(),{locale:m}=X(),{bookingSource:o}=pt(),{isTawakkalnaUser:p}=bt(),{t:g}=S(["flight_common"]),{data:h,isLoading:v,isError:f,error:_}=Cs({lang:m,id:t},{refetchInterval:i?1e3*30:!1,refetchOnWindowFocus:i});b.useEffect(()=>{((h==null?void 0:h.booking_status)==="processed"||(h==null?void 0:h.booking_status)==="failed")&&u(!1)},[h==null?void 0:h.booking_status]);const{trackEvent:y}=Y(),x=(l=(s=(a=h==null?void 0:h.booking_data)==null?void 0:a.legs)==null?void 0:s[0].segments)==null?void 0:l[0],k=b.useMemo(()=>{var j,N;const A=((j=h==null?void 0:h.booking_data)==null?void 0:j.travelers)||[];let w=0,R=0,$=0;for(const M of A){const I=(N=M.ageGroup)==null?void 0:N.toLocaleLowerCase();I==="adult"?w++:I==="child"?R++:I==="infant"&&$++}return{adult:w,child:R,infant:$}},[h==null?void 0:h.booking_data.travelers]);return b.useEffect(()=>{var j,N,A,w,R,$,M,I,D,C,T,P,H,O;h&&y({event:"flights_confirmation_page_loaded",data:{booking_type:"flight",origin:(x==null?void 0:x.departureCityName)||"",destination:(x==null?void 0:x.arrivalCityName)||"",departure_in_date:(x==null?void 0:x.departureDateTime)||"",return_in_date:(x==null?void 0:x.arrivalDateTime)||"",flight_type:(N=(j=h==null?void 0:h.booking_data)==null?void 0:j.legs)!=null&&N.length?((w=(A=h==null?void 0:h.booking_data)==null?void 0:A.legs)==null?void 0:w.length)>1?"round_trip":"one_way":"",order_id:h._id,order_total:((M=($=(R=h==null?void 0:h.booking_data)==null?void 0:R.fareDetails)==null?void 0:$.totalPrice)==null?void 0:M.toString())||"",passengers_count:((D=(I=h==null?void 0:h.booking_data)==null?void 0:I.travelers)==null?void 0:D.length)||0,class:((C=x==null?void 0:x.airline)==null?void 0:C.class)||"",price:((H=(P=(T=h==null?void 0:h.booking_data)==null?void 0:T.fareDetails)==null?void 0:P.totalPrice)==null?void 0:H.toString())||"",airline:((O=x==null?void 0:x.airline)==null?void 0:O.airlineName)||"",booking_source:o,booking_status:h.booking_status}})},[h]),v?e.jsx(en,{}):!h||f?e.jsx("section",{className:"mx-auto max-w-xl p-4 pb-12",children:e.jsxs("div",{className:"space-y-8 shadow-md",children:[e.jsx(d,{color:"error",variant:"heading-M",className:"text-center",children:(_==null?void 0:_.message)||g("flight_common:unknown_error")}),e.jsx("div",{className:"mx-auto w-full max-w-xs",children:e.jsx(L,{as:Fe,href:`/${m}`,theme:"action",shape:"outlined",className:"w-full text-lg",children:g("flight_common:go_home")})})]})}):e.jsxs("section",{className:"container",children:[e.jsx("div",{className:"py-4 lg:p-6",children:e.jsxs(L,{as:c?"button":Fe,to:`/${m}/profile/bookings/flights`,theme:"secondary",shape:"text",className:"gap-2 px-px py-1",onClick:()=>{var j;c&&((j=window.ReactNativeWebView)==null||j.postMessage(JSON.stringify({eventName:"PAYMENTSUCCESS",source:"flights",order:{order_id:h._id,total:h.booking_data.fareDetails.totalPrice}})))},children:[e.jsx(ge,{className:"h-3 w-3 ltr:rotate-180"}),g("flight_common:back_to_orders")]})}),e.jsxs("div",{className:"space-y-4 pb-6 lg:p-6",children:[h.booking_status==="failed"?e.jsx(Le,{className:"text-error h-10 w-10"}):e.jsx(yt,{className:"h-14 w-14 text-transparent [&_path]:fill-green-500"}),e.jsx("div",{className:"space-y-2",children:h.booking_status==="failed"?e.jsxs(e.Fragment,{children:[e.jsx(d,{as:"h1",variant:"heading-XL",className:"lg:text-5xl",children:g("flight_common:unable_to_complete_booking")}),e.jsx(d,{variant:"body-L",color:"text-secondary",children:g("flight_common:refund_on_the_way",{amount:h.booking_data.fareDetails.totalPrice,currency:h.booking_data.fareDetails.totalCurrency})})]}):h.booking_status==="pending"?e.jsxs(e.Fragment,{children:[e.jsx(d,{as:"h1",variant:"heading-XL",className:"lg:text-5xl",children:g("flight_common:your_payment_has_been_received")}),e.jsx(d,{variant:"body-L",color:"text-secondary",children:g("flight_common:we_are_processing_your_booking")})]}):e.jsxs(e.Fragment,{children:[e.jsx(d,{as:"h1",variant:"heading-XL",className:"lg:text-5xl",children:g("flight_common:your_booking_is_confirmed")}),e.jsx(d,{variant:"body-L",color:"text-secondary",children:g("flight_common:pack_your_bags")}),p&&e.jsx(ts,{APP_STORE_URL:Gl,GOOGLE_PLAY_STORE_URL:Jl,HUAWEI_STORE_URL:Kl})]})})]}),e.jsxs("div",{className:"flex flex-col lg:gap-6 lg:p-6 xl:flex-row",children:[e.jsxs("div",{className:"grow space-y-6",children:[e.jsx(ln,{order:h,passengersCount:k}),e.jsx(Wt,{order:h,passengersCount:k,className:"block lg:hidden"}),!!h.booking_data.travelers.length&&e.jsx(cn,{order:h}),h.booking_status!=="failed"&&e.jsxs(e.Fragment,{children:[e.jsx(xn,{order:h}),e.jsxs(ae,{children:[e.jsx(it,{legs:h.booking_data.legs,triggerClassName:"mb-4 p-0"}),(n=h.booking_data.legs)==null?void 0:n.map((j,N)=>{var A,w,R,$;return e.jsxs(b.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1 pb-3",children:[e.jsx(d,{children:(w=(A=j.segments)==null?void 0:A[0])==null?void 0:w.departureCityName}),e.jsx(d,{className:"lowercase",children:g("flight_common:to")}),e.jsx(d,{children:($=(R=j.segments)==null?void 0:R[j.segments.length-1])==null?void 0:$.arrivalCityName})]}),e.jsx(ze,{baggage:j.baggage,className:N!==h.booking_data.legs.length-1?"pb-4":""}),N!==h.booking_data.legs.length-1&&e.jsx(ie,{className:"pb-4"})]},N)})]}),!!((r=h.booking_data.penalty)!=null&&r.length)&&e.jsxs(ae,{className:"scroll-m-2
10",children:[e.jsx(rt,{triggerClassName:"justify-between p-0 mb-4 text-start",penalty:h.booking_data.penalty,legs:h.booking_data.legs,passengers:{length:h.booking_data.travelers.length,passenger_type:h.booking_data.travelers[0].ageGroup}}),h.booking_data.penalty.map((j,N)=>{var A,w,R,$,M,I,D,C;return e.jsxs(e.Fragment,{children:[e.jsx(nt,{departureCity:($=(R=(w=(A=h.booking_data.legs)==null?void 0:A[N])==null?void 0:w.segments)==null?void 0:R[0])==null?void 0:$.departureCityName,arrivalCity:(C=(D=(I=(M=h.booking_data.legs)==null?void 0:M[N])==null?void 0:I.segments)==null?void 0:D[h.booking_data.legs[N].segments.length-1])==null?void 0:C.arrivalCityName,penalty:j,className:N!==h.booking_data.legs.length-1?"pb-4":""},j.refundableCode+N),N!==h.booking_data.penalty.length-1&&e.jsx(ie,{className:"pb-4"})]})})]})]})]}),e.jsx("div",{className:"mb-6 w-full shrink-0 grow space-y-6 lg:mb-0 xl:max-w-[36%]",children:e.jsxs("div",{className:"top-20 space-y-6 xl:sticky",children:[e.jsx(Wt,{order:h,passengersCount:k,className:"hidden lg:block"}),e.jsx(vn,{order:h})]})})]})]})},ai=_n,yn=({status:t})=>{const[a,s]=b.useState(0),[l,n]=b.useState(t==="IN_PROGRESS");return b.useEffect(()=>{if(t==="COMPLETED")s(100),setTimeout(()=>{n(!1)},500);else{const r=setInterval(()=>{s(i=>{const u=i<60?.5:.2;return i>=90?i:i+u})},100);return()=>clearInterval(r)}},[t]),e.jsx("div",{"data-show":l,className:"bg-body-level-1 h-0.5 w-full overflow-hidden transition-opacity duration-300 data-[show=false]:!mt-0 data-[show=false]:opacity-0 data-[show=true]:opacity-100",children:e.jsx("div",{className:"bg-primary h-full ltr:origin-left rtl:origin-right",style:{transform:`scaleX(${a/100})`,transition:"transform 0.1s ease-out"}})})},gt=yn,jn=({children:t,search:a,flightsData:s,initialDepartureFilters:l,initialReturnFilters:n,sId:r})=>{const{search:i}=oe(),u=a||i,c=(s==null?void 0:s.searchId)||new URLSearchParams(window.location.search).get("searchId")||"",m=tt({mode:"onBlur",defaultValues:Z(F({},Se),{search:u,departureFilters:l||Se.departureFilters,returnFilters:n||Se.returnFilters,flights:(s==null?void 0:s.flights)||[],sId:r,searchId:c})}),[o,p,g,h,v]=m.watch(["departureFilters","returnFilters","sortBy","selectedDepartureFlight","returnFlights"]);return b.useEffect(()=>{var f;(f=s==null?void 0:s.flights)!=null&&f.length&&m.setValue("departureListLoadTime",Date.now())},[s==null?void 0:s.flights]),b.useEffect(()=>{c&&c!==m.getValues("searchId")&&m.setValue("searchId",c)},[c]),b.useEffect(()=>{l&&m.setValue("departureFilters",l),n&&m.setValue("returnFilters",n)},[l,n,m]),b.useEffect(()=>{const f=(s==null?void 0:s.flights)||[],_=h?p:o,y=!!h,x=(h?v||[]:f).filter(k=>Object.entries(_).every(([j,N])=>{if(!N.length)return!0;const A=ul[j];return A==null?void 0:A(k,N)})).sort((k,j)=>hl[g](k,j,y));m.setValue("filteredFlights",x)},[s==null?void 0:s.flights,h,v,g,p,o]),e.jsx(ft,Z(F({},m),{children:t}))},Fa=jn,bn=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"bg-body-level-1 h-4 w-1/2 animate-pulse rounded-md"}),e.jsx("div",{className:"bg-body-level-1 h-4 w-8 animate-pulse rounded-md"})]}),Array.from({length:2}).map((t,a)=>e.jsx("div",{className:"bg-body-level-1 rounded-M h-40 animate-pulse"},a))]}),Aa=bn,Nn=({onFareSelect:t,sId:a})=>{const{t:s}=S("flight_common"),{locale:l}=X(),{control:n,watch:r,setValue:i}=_e(),[u,c,m]=r(["selectedDepartureFlight","search.legs","filteredFlights"]),{data:o,isLoading:p}=oa({sId:a||"",flightId:(u==null?void 0:u.id)||""},{enabled:!!a&&!!(u!=null&&u.id)}),{outboundDate:g,returnDate:h}=b.useMemo(()=>{var v;return{outboundDate:c[0].outboundDate,returnDate:(v=c[1])==null?void 0:v.outboundDate}},[c]);return b.useEffect(()=>{o!=null&&o.flights.length&&(i("returnFlights",o.flights),i("returnListLoadTime",Date.now()))},[o]),p?e.jsx(Aa,{}):!(o!=null&&o.flights.length)&&u?e.jsx(d,{className:"text-text-secondary flex justify-center",children:s("flight_common:no_available_flights")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{variant:"heading-XS",as:"h2",children:s(u?"flight_common:choose_return_flight":"flight_common:choose_departure_flight")}),e.jsx(d,{variant:"body-XS",color:"text-secondary",children:s("flight_common:cross_selling.flights_matching_event_date",{count:m.length,date:B(u?h:g,l,{month:"short",day:"2-digit",year:"numeric",timeZone:void 0})})})]}),e.jsx(K,{control:n,name:u?"returnFilters":"departureFilters",render:({field:{onCh
1ange:v,value:f}})=>e.jsx(wa,{value:f,onChange:v,className:"lg:flex"})},u?"returnFilters":"departureFilters")]}),m.map((v,f)=>e.jsx(Ye,{flight:v,position:f+1,onFareSelect:_=>{t==null||t({fareId:_,flight:v})}},`${f}-${u}`))]})},wn=Nn,Cn=()=>{const{watch:t,setValue:a}=_e(),s=t("selectedDepartureFlight"),{t:l}=S("flight_common"),n=()=>{a("selectedDepartureFlight",void 0)};return e.jsx(Ne,{children:!!s&&e.jsxs(be.div,{className:"bg-body-level-1 mb-8 scroll-mt-20 space-y-4 rounded-lg p-4",initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{duration:.6},ref:r=>{r&&et(r.id)},id:"selected-departure-flight",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yt,{className:"text-success [&>path]:stroke-body-level-1 h-4 w-4 shrink-0"}),e.jsx(d,{color:"text-secondary",className:"lg:text-body-L",children:l("flight_common:selected_departure_flight")})]}),e.jsx(L,{shape:"text",theme:"primary",onClick:n,type:"button",children:l("flight_common:change")})]}),e.jsx(Ye,{flight:s})]})})},kn=Cn,Sn=()=>{const{control:t,formState:{errors:a},watch:s,setValue:l}=de(),{locale:n}=X(),{t:r}=S(["flight_common"]),i=s("contactDetails.country");return e.jsxs("div",{className:"border-paper space-y-4 rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx(d,{as:"h2",variant:"heading-S",children:r("flight_common:contact_details.title")}),e.jsx(d,{color:"text-secondary",variant:"body-S",children:r("flight_common:contact_details.note")})]}),e.jsxs("div",{className:"flex justify-between gap-4 *:w-full",children:[e.jsx(K,{name:"contactDetails.firstName",control:t,rules:{required:r("flight_common:validation.first_name.empty"),pattern:{value:/^[a-zA-Z\s]*$/i,message:r("flight_common:validation.first_name.invalid")},maxLength:{value:20,message:r("flight_common:validation.max_length",{max:20})},minLength:{value:2,message:r("flight_common:validation.min_length",{min:2})}},render:u=>{var c=u,{field:m}=c,o=ee(m,[]),{fieldState:{error:p}}=c;return e.jsx(ye,F({id:"firstName",placeholder:r("flight_common:personal_information.first_name"),label:r("flight_common:personal_information.first_name"),error:p==null?void 0:p.message},o))}}),e.jsx(K,{name:"contactDetails.lastName",control:t,rules:{required:r("flight_common:validation.last_name.empty"),pattern:{value:/^[a-zA-Z\s]*$/i,message:r("flight_common:validation.last_name.invalid")},maxLength:{value:20,message:r("flight_common:validation.max_length",{max:20})},minLength:{value:2,message:r("flight_common:validation.min_length",{min:2})}},render:u=>{var c=u,{field:m}=c,o=ee(m,[]),{fieldState:{error:p}}=c;return e.jsx(ye,F({id:"lastName",placeholder:r("flight_common:personal_information.last_name"),label:r("flight_common:personal_information.last_name"),error:p==null?void 0:p.message},o))}})]}),e.jsx(K,{name:"contactDetails.email",control:t,rules:{required:r("flight_common:validation.email.empty"),pattern:{value:Za,message:r("flight_common:validation.email.invalid")}},render:u=>{var c=u,{field:m}=c,o=ee(m,[]),{fieldState:{error:p}}=c;return e.jsx(ye,F({id:"email",placeholder:r("flight_common:contact_details.email"),label:r("flight_common:contact_details.email"),error:p==null?void 0:p.message},o))}}),e.jsx(K,{name:"contactDetails.phone",control:t,rules:{required:r("flight_common:validation.phone.empty"),validate:u=>{var c,m,o;const p=(c=i==null?void 0:i.mobile_starts_with)==null?void 0:c.length;if(u!=null&&u.includes(" "))return r("flight_common:validation.invalid_mobile");if(p){const g=(m=i==null?void 0:i.mobile_starts_with)==null?void 0:m.some(v=>u==null?void 0:u.startsWith(v)),h=(u==null?void 0:u.length)&&(u==null?void 0:u.length)>=Number((o=i==null?void 0:i.phone_number_lengths)==null?void 0:o[0]);return g&&h||r("flight_common:validation.invalid_mobile")}}},render:({field:{value:u}})=>{var c,m;return e.jsx(ns,{lang:n,label:r("flight_common:contact_details.mobile_number"),country:i,mobile:u||"",onChange:(o,p)=>{l(o==="country"?"contactDetails.country":"contactDetails.phone",p)},error:(m=(c=a==null?void 0:a.contactDetails)==null?void 0:c.phone)==null?void 0:m.message})}})]})}
1,Ta=Sn,Dn=({savedPassengers:t,onSelect:a})=>e.jsx(rs,{label:"",name:"suggested_passengers",className:"flex-row-reverse gap-3 rounded-none border-0 pl-0",groupClassName:"divide-y divide-body-dark/10",options:t.map(s=>({text:e.jsxs(b.Fragment,{children:[e.jsxs(d,{className:"capitalize",children:[s.first_name," ",s.last_name]}),e.jsx(d,{variant:"body-S",color:"text-secondary",children:s.date_of_birth})]},s.id),value:s.id})),onChange:s=>{const l=t.find(n=>n.id===s);l&&a(l)}}),Ln=Dn,Fn=({limitReached:t,passenger:a,suggestedPassengers:s,suggestSavedPassengers:l,selectedFare:n,number:r,error:i,onChange:u,ref:c})=>{const{clearErrors:m,setValue:o}=de(),{t:p}=S(["flight_common"]),g=a==null?void 0:a.selected,h=n==null?void 0:n.passengerSettings[a.type],v=h==null?void 0:h.docType;return e.jsxs("div",{ref:c,id:`passenger-${r}`,className:"border-paper aria-[invalid=true]:border-error rounded-lg border p-4 transition-all",tabIndex:-1,"aria-invalid":!!i,children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex w-full gap-3",children:[g!=null&&g.id&&!i?e.jsx($e,{className:"mt-1 h-5 w-5 shrink-0 text-green-500"}):i?e.jsx(Ie,{className:"text-error mt-1 h-5 w-5 shrink-0"}):null,e.jsxs("div",{className:`flex w-full justify-between gap-3 rounded-xl ${g!=null&&g.id?"flex-col items-start":"flex-row items-center"}`,children:[e.jsxs("div",{children:[e.jsxs(d,{variant:"body-L",className:`flex capitalize md:items-center ${i?"text-error":""}`,children:[p(`flight_common:${a.type}`)," ",r,": ",g==null?void 0:g.first_name," ",(g==null?void 0:g.middle_name)||""," ",g==null?void 0:g.last_name]}),(g==null?void 0:g.date_of_birth)&&e.jsx(d,{variant:"body-S",color:"text-secondary",children:g.date_of_birth}),i&&e.jsx(d,{className:"text-error",children:i})]}),e.jsx(Ke,{limitReached:t,showTravelDocs:!!(v!=null&&v.length),initialPassenger:Z(F({},g),{passenger_type:a.type}),renderAction:({open:f})=>e.jsxs(L,{shape:g?"text":"outlined",type:"button",theme:"action",onClick:f,className:g?"px-px underline underline-offset-2":"whitespace-nowrap",children:[!g&&e.jsx(lt,{className:"h-2.5 w-2.5 shrink-0"}),e.jsx("span",{children:p(g?"flight_common:edit":"flight_common:add_new")})]}),onSuccess:f=>{u({id:a.id,type:a.type,selected:f})}})]})]}),(g==null?void 0:g.id)&&e.jsx(L,{shape:"outlined",type:"button",theme:"action",onClick:()=>{m(`passengersList.${r-1}`),o(`passengersList.${r-1}.selected`,void 0)},children:e.jsx("span",{children:p("flight_common:change")})})]}),l&&e.jsx(e.Fragment,{children:s?s!=null&&s.length?e.jsx("div",{className:"mini-scrollbar max-h-96 space-y-2 overflow-auto pb-4",children:e.jsx(Ln,{savedPassengers:s,onSelect:f=>{u({id:a.id,type:a.type,selected:f})}})}):null:e.jsx("div",{className:"space-y-3 py-4",children:Array.from({length:3}).map((f,_)=>e.jsx("div",{className:"bg-body-dark/10 h-20 animate-pulse items-center rounded-lg p-4"},_))})})]})},An=Fn,Tn=()=>{const{data:t,isLoading:a}=ua(),{control:s,trigger:l,watch:n}
1=de(),r=t&&(t==null?void 0:t.length)>=20,{t:i}=S(["flight_common"]),{selectedFare:u}=ne(),c=n("passengersList"),m=c==null?void 0:c.findIndex(g=>!g.selected),o=u==null?void 0:u.legs[u.legs.length-1],p=o==null?void 0:o.segments[(o==null?void 0:o.segments.length)-1];return c==null?void 0:c.map((g,h)=>{var v;const f=(t==null?void 0:t.filter(_=>{var y;return!c.some(k=>{var j;return((j=k.selected)==null?void 0:j.id)===_.id})&&_.passenger_type===g.type&&_.id!==((y=g.selected)==null?void 0:y.id)}))||[];return e.jsx(K,{control:s,name:`passengersList.${h}`,rules:{required:i("flight_common:please_select_passenger"),validate:_=>{var y,x;const k=u==null?void 0:u.passengerSettings[g.type],j=_.selected,N=k==null?void 0:k.docType,A=(y=j==null?void 0:j.documents)==null?void 0:y.map(T=>T.document_type),w=c==null?void 0:c.findIndex(T=>{var P,H,O,q,z,J;return T.id!==(_==null?void 0:_.id)&&((P=j==null?void 0:j.first_name)==null?void 0:P.toLocaleLowerCase())===((O=(H=T.selected)==null?void 0:H.first_name)==null?void 0:O.toLocaleLowerCase())&&((q=j==null?void 0:j.last_name)==null?void 0:q.toLocaleLowerCase())===((J=(z=T.selected)==null?void 0:z.last_name)==null?void 0:J.toLocaleLowerCase())}),R=!!(j!=null&&j.id)&&w!==-1,$=!(N!=null&&N.length)||(A==null?void 0:A.some(T=>{var P;return(P=k==null?void 0:k.docType)==null?void 0:P.includes(T)})),M=(x=j==null?void 0:j.documents)==null?void 0:x.filter(T=>N==null?void 0:N.includes(T.document_type)),D=((M==null?void 0:M.every(T=>Date.now()>new Date(T.expiry_date).getTime()||(p==null?void 0:p.arrivalDateTime)&&new Date(p.arrivalDateTime).getTime()>new Date(T.expiry_date).getTime()))||!$)&&!!(N!=null&&N.length),C=!!(j!=null&&j.id)&&D&&!!(N!=null&&N.length);if(R)return i("flight_common:duplicate_passenger");if(!(j!=null&&j.id))return i("flight_common:please_select_passenger");if(C||D)return i("flight_common:please_update_travel_documents")},onChange:()=>{const _=[];for(let y=0;y<c.length;y++)c[y].selected&&_.push(`passengersList.${y}`);l(_)}},render:_=>{var y=_,{field:x}=y,k=x,{value:j,onChange:N,onBlur:A}=k,w=ee(k,["value","onChange","onBlur"]),{fieldState:{error:R}}=y;return e.jsx(An,F({limitReached:r,selectedFare:u,number:h+1,suggestSavedPassengers:m===h,passenger:j,suggestedPassengers:a?void 0:f,error:R==null?void 0:R.message,onChange:$=>{N($),A()}},w))}},`${(v=g.selected)==null?void 0:v.id}-${h}`)})},Pa=Tn,Pn=()=>{const{t}=S("flight_common");return e.jsxs("div",{className:"space-y-4",children:[e.jsx(d,{variant:"heading-S",children:t("flight_common:cross_selling.traveler_information")}),e.jsx(Pa,{}),e.jsx(Ta,{})]})},Mn=Pn,In=({legs:t,passengers:a,onFinish:s,onReview:l})=>{const{searchId:n,flightId:r}=ne(),{watch:i,trigger:u,handleSubmit:c,setValue:m}=de(),{t:o}=S(["flight_common"]),[p,g]=i(["contactDetails","passengersList"]),{locale:h}=X(),v=c(()=>{u(["contactDetails","passengersList"]).then(f=>{f&&s({searchId:n||"",flightId:r||"",email:p==null?void 0:p.email,areaCode:p.country.dial_code,phone:p.phone,passengers:g.map(_=>{var y;return{id:((y=_.selected)==null?void 0:y.id)||""}})})})});return b.useEffect(()=>{a!=null&&a.length&&m("passengersList",a)},[a]),b.useEffect(()=>{r&&n&&l({searchId:n,flightId:r})},[r,n]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("form",{onSubmit:v,id:"flight-form",className:"space-y-4",children:[e.jsx(d,{variant:"heading-M",children:o("flight_common:cross_selling.review_flight")}),t.map((f,_)=>{const y=f.segments[0],x=f.segments[f.segments.length-1];return e.jsxs(ae,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(d,{variant:"label-L",children:[y.departureCityName," ",o("flight_common:to")," ",x.arrivalCityName]}),e.jsx(d,{variant:"body-S",color:"text-secondary",children:o("flight_common:cross_selling.departs",{date:B(new Date(y.departureDateTime),h,{day:"2-digit",month:"short",year:"numeric",weekday:"short",timeZone:void 0})})})]}),e.jsx(ls,{className:"group flex flex-col-reverse",trigger:e.jsxs(L,{shape:"text",type:"button",theme:"transparent",className:"w-full justify-start p-px pb-0 group-data-[state=open]:mt-4",children:[e.jsx(d,{variant:"link-S",className:"hidden group-data-[state=open]:block",children:o("flight_common:cross_selling.hide_details")}),e.jsx(d,{variant:"link-S",className:"group-data-[state=open]:hidden",children:o("flight_common:cross_selling.show_details")}),e.jsx(ge,{className:"h-2.5 w-2.5 shrink-0 rotate-90 transition-all group-data-[state=open]:-rotate-90"})]}),defaultOpen:!0,children:e.jsx(Da,{leg:f})})]},_)})]}),e.jsx(Mn,{})]})},En=In,$n=({onSubmit:t,search:a})=>{var s,l,n,r;const{watch:i,setValue:u}=_e(),c=i("selectedDepartureFlight"),{t:m}=S(["flight_common"]),{locale:o}=X(),{passengers:p,fromDate:g,toDate:h}=b.useMemo(()=>{var v;return{passengers:(a==null?void 0:a.adultsCount)+(a==null?void 0:a.childrenCount)+(a==null?void 0:a.infantsCount),fromDate:B(a==null?void 0:a.legs[0].outboundDate,o,{month:"short",day:"2-digit",timeZone:void 0}),toDate:B((v=a.legs[1])==null?void 0:v.outboundDate,o,{month:"short",day:"2-digit",timeZone:void 0})}},[a,o]);return c?null:e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"heading-S",children:m("flight_common:cross_selling.book_a_flight")}),e.jsxs(ae,{surface:"level-1",border:!1,className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[(s=a.legs[0].departureAirport)!=null&&s.city&&((l=a.legs[0].arrivalAirport)!=null&&l.city)?e.jsx(d,{variant:"label-S",color:"text-secondary",children:m("flight_common:cross_selling.from_and_to",{from:(n=a.legs[0].departureAirport)==null?void 0:n.city,to:(r=a.legs[0].arrivalAirport)==null?void 0:r.city,connection:m(`flight_common:${a.connectionType}`)})}):e.jsx(d,{variant:"label-S",color:"text-secondary",children:m(`flight_common:${a.connectionType}`)}),e.jsxs(d,{variant:"label-S",children:[m("flight_common:cross_selling.travelers",{count:p,from:g})," ",a.connectionType==="round_trip"&&e.jsxs(e.Fragment,{children:[" - ",h]})]})]}),e.jsx(Ae,{title:m("flight_common:cross_selling.update_flight_search"),action:{className:"w-full",form:"flights_search_form",type:"submit",label:m("flight_common:cross_selling.update")},cancel:!1,ignoreHistory:!0,size:"2xl",render:({open:v})=>e.jsx(L,{shape:"text",onClick:v,children:e.jsx(d,{variant:"body-S",strong:!0,children:m("flight_common:cross_selling.change")})}),body:({close:v})=>e.jsx(Ze,{className:"max-w-none",search:a,id:"flights_search_form",showSubmit:!1,small:!0,onFormSubmit:f=>{u("search",f),v(),t(f)}})})]})]})}
1,Rn=$n,On=({initialSearch:t,onFinish:a,flight:s,onReview:l,event:n})=>{var r,i,u,c;const[m,o]=b.useState(),[p,g]=b.useState(!0),[h,v]=b.useState(t),[f,_]=b.useState(""),[y,x]=b.useState(),{t:k}=S("flight_common"),{locale:j}=X(),{data:N,isLoading:A}=ht({lang:j}),{data:w,isLoading:R}=ht({lang:j,lat:Number((r=n==null?void 0:n.location)==null?void 0:r.lat),lng:Number((i=n==null?void 0:n.location)==null?void 0:i.lng),city:n==null?void 0:n.city}),{data:$,isLoading:M,isError:I,isRefetching:D}=ca(Z(F({},h),{lang:j,legs:(u=h.legs)==null?void 0:u.map(({arrivalAirport:z,departureAirport:J,outboundDate:me})=>{const{date:pe}=Qt(new Date(me).getTime(),"en",{year:"numeric",month:"2-digit",day:"2-digit",timeZone:void 0});return{outboundDate:pe,departureCode:(J==null?void 0:J.code)||"",arrivalCode:(z==null?void 0:z.code)||""}})}),{enabled:!!h&&!s&&!!N&&!!w&&!A&&!R&&!!((c=h.legs)!=null&&c.length)&&h.legs.every(z=>{var J,me;return!!((J=z.departureAirport)!=null&&J.code)&&!!((me=z.arrivalAirport)!=null&&me.code)})}),{data:C,isLoading:T}=da(($==null?void 0:$.sId)||"",{enabled:!!($!=null&&$.sId)&&!s,refetchInterval:p?1e3:!1,refetchOnWindowFocus:p}),{data:P,isLoading:H}=ma({searchId:($==null?void 0:$.sId)||"",flightId:f,lang:j});b.useEffect(()=>{(C!=null&&C.status&&(C==null?void 0:C.status)!=="IN_PROGRESS"&&p||I)&&g(!1)},[C==null?void 0:C.status,I,p]),b.useEffect(()=>{var z,J;const me=((n==null?void 0:n.start_date_time)||0)*1e3,pe=((n==null?void 0:n.end_date_time)||0)*1e3,ce=Number((z=n==null?void 0:n.cross_selling_travel)==null?void 0:z.departure_time_buffer)||1,re=Number((J=n==null?void 0:n.cross_selling_travel)==null?void 0:J.return_time_buffer)||1,E=Ge(me,new Date().getTime()),V=Ge(pe,new Date().getTime());if(N&&w){const U={_id:"",code:N.iata,city:N.city,country:N.country,name:N.name},W={_id:"",code:w.iata,city:w.city,country:w.country,name:w.name};let se=E?new Date:te({date:Tt(new Date(me).toISOString()),interval:"hour",value:-ce});const le=se.getHours();le===0&&(se=te({date:se,interval:"day",value:-1}));const ue=V?new Date:te({date:Tt(new Date(pe).toISOString()),interval:"hour",value:re}),xe=ue.getHours(),he=E?[le,24]:le===0?[0,24]:[0,le];x({departureFilters:{departureTime:E?he:[],arrivalTime:E?[]:he,priceRanges:[],stops:[],airlines:[],departureAirports:[],arrivalAirports:[]},returnFilters:{departureTime:[xe,24],arrivalTime:[],priceRanges:[],stops:[],airlines:[],departureAirports:[],arrivalAirports:[]}}),v(Z(F({},h),{legs:[{departureAirport:U,arrivalAirport:W,outboundDate:se},{departureAirport:W,arrivalAirport:U,outboundDate:ue}]}))}},[N,w,n==null?void 0:n.start_date_time,n==null?void 0:n.end_date_time]);const O=b.useMemo(()=>{var z;if(s)return(z=s.booking_data.travelers)==null?void 0:z.map((ce,re)=>({selected:{id:ce.id,first_name:ce.firstName,last_name:ce.lastName,passenger_type:ce.ageGroup},type:ce.ageGroup,id:`${ce.ageGroup}-${re}`}));const J={adult:{count:h.adultsCount},child:{count:h.childrenCount},infant:{count:h.infantsCount}},me=Object.keys(J),pe=[];for(const ce of me){const re=ce,E=J[re];for(let V=0;V<E.count;V++)pe.push({id:`${re}-${V}`,selected:void 0,type:re})}return pe},[s,h]),q=M||D||A||R||T&&!C||(C==null?void 0:C.status)==="IN_PROGRESS"&&!(C!=null&&C.flights.length);return e.jsx(e.Fragment,{children:e.jsxs(kt,{sId:$==null?void 0:$.sId,flightId:f,selectedFare:P,searchId:C==null?void 0:C.searchId,children:[H?e.jsx("div",{className:"space-y-4",children:Array.from({length:2}).map((z,J)=>e.jsx("div",{className:"bg-body-level-1 rounded-M h-40 animate-pulse"},J))}):!s&&!P?null:e.jsx(En,{passengers:O,legs:s?s==null?void 0:s.booking_data.legs:(P==null?void 0:P.legs)||[],onFinish:a,onReview:l}),!m&&q?e.jsx("div",{className:"space-y-4",children:e.jsx(Aa,{})}):e.jsx(Fa,{search:h,flightsData:C,sId:$==null?void 0:$.sId,initialDepartureFilters:y==null?void 0:y.departureFilters,initialReturnFilters:y==null?void 0:y.returnFilters,children:!s&&!m&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(kn,{}),e.jsx(Rn,{onSubmit:z=>{v(z),g(!0)},search:h}),$!=null&&$.sId?C!=null&&C.flights.length?e.jsxs(e.Fragment,{children:[e.jsx(gt,{status:C==null?void 0:C.status}),e.jsx(wn,{onFareSelect:({fareId:z,flight:J})=>{_(z),o(J)},sId:$==null?void 0:$.sId})]}):e.jsx(d,{className:"text-text-secondary flex justify-center",children:k("flight_common:no_available_flights")}):null]})})]})})},si=On,Ma=t=>e.jsxs("svg",Z(F({width:"68",height:"65",viewBox:"0 0 68 65",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:[e.jsx("g",{clipPath:"url(#clip0_10022_34256)",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M38.7228 23.0515C36.9989 23.0515 35.3456 23.7363 34.1266 24.9553L28.2475 30.8344C27.8391 31.2429 27.2324 31.3805 26.6876 31.1882L10.1069 25.3362L7.87219 27.5708L19.8792 36.807C20.2214 37.0702 20.4335 37.468 20.4615 37.8988C20.4895 38.3295 20.3305 38.7514 20.0253 39.0566L15.9142 43.1677C15.6329 43.449 15.2514 43.6071 14.8535 43.6071H11.3638L8.31141 46.6594L14.3525 48.9248C14.7581 49.0769 15.0781 49.397 15.2303 49.8026L17.4956 55.8436L20.548 52.7913V49.3015C20.548 48.9037 20.706 48.5222 20.9873 48.2409L25.0984 44.1297C25.4037 43.8245 25.8256 43.6656 26.2563 43.6936C26.687 43.7215 27.0849 43.9337 27.348 44.2758L36.5842 56.2829L38.8189 54.0482L32.9668 37.4674C32.7746 36.9227 32.9122 36.316 33.3207 35.9075L39.1997 30.0284C40.4187 28.8095 41.1035 27.1562 41.1035 25.4322V23.0515H38.7228ZM32.0053 22.834C33.7869 21.0524 36.2033 20.0515 38.7228 20.0515H42.6035C43.432 20.0515 44.1035 20.7231 44.1035 21.5515V25.4322C44.1035 27.9518 43.1027 30.3682 41.3211 32.1498L36.1104 37.3604L41.9625 53.9412C42.1547 54.4859 42.0171 55.0926 41.6087 55.5011L37.4975 59.6122C37.1923 59.9174 36.7704 60.0763 36.3397 60.0484C35.9089 60.0204 35.5111 59.8082 35.2479 59.4661L26.0118 47.4591L23.548 49.9228V53.4126C23.548 53.8104 23.39 54.192 23.1086 54.4733L17.9698 59.6122C17.6091 59.9728 17.09 60.1255 16.5915 60.0175C16.0931 59.9095 15.6837 59.5557 15.5046 59.0782
1L12.6607 51.4944L5.07686 48.6505C4.59933 48.4714 4.24551 48.0619 4.13754 47.5635C4.02957 47.0651 4.18226 46.5459 4.54288 46.1853L9.68177 41.0464C9.96308 40.7651 10.3446 40.6071 10.7424 40.6071H14.2322L16.696 38.1433L4.68898 28.9071C4.34684 28.6439 4.13467 28.2461 4.1067 27.8154C4.07872 27.3847 4.23766 26.9627 4.54288 26.6575L8.65399 22.5464C9.06245 22.1379 9.66917 22.0003 10.2139 22.1926L26.7947 28.0446L32.0053 22.834Z",fill:"currentColor"})}),e.jsx("path",{d:"M60 7L61.6334 12.3666L67 14L61.6334 15.6334L60 21L58.3666 15.6334L53 14L58.3666 12.3666L60 7Z",fill:"currentColor"}),e.jsx("path",{d:"M52.5 2L53.5501 5.44995L57 6.5L53.5501 7.55005L52.5 11L51.4499 7.55005L48 6.5L51.4499 5.44995L52.5 2Z",fill:"currentColor"}),e.jsx("path",{d:"M49.5 14L50.5501 17.4499L54 18.5L50.5501 19.5501L49.5 23L48.4499 19.5501L45 18.5L48.4499 17.4499L49.5 14Z",fill:"currentColor"}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0_10022_34256",children:e.jsx("rect",{width:"48",height:"48",fill:"white",transform:"translate(0.103516 16.0515)"})})})]})),Bn=({onRefresh:t,initialSeconds:a=600,text:s})=>{const l=b.useRef(Date.now()+a*1e3),n=b.useId(),{t:r}=S(["flight_common"]),i=Ha({id:n,initialSeconds:a});return b.useEffect(()=>{const u=()=>{i.set((l.current-Date.now())/1e3)};return window.addEventListener("visibilitychange",u),()=>window.removeEventListener("visibilitychange",u)},[i,i.count]),e.jsxs(e.Fragment,{children:[s==null?void 0:s(i),e.jsx(st,{show:i.count<=0,ignoreHistory:!0,body:({close:u})=>e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 p-4 text-center",children:[e.jsx(Ma,{className:"h-20 w-20 shrink-0"}),e.jsx(d,{variant:"body-L",className:"font-semibold",children:r("flight_common:session_expired_message")}),e.jsx(L,{className:"w-full",onClick:()=>{u(),t(),i.reset()},children:r("flight_common:refresh")})]})})]})},Ia=Bn,Vn=({title:t,description:a,showModal:s,closeButton:l=!1,onClose:n,onRefresh:r,icon:i,className:u,actionButton:c})=>{const{t:m}=S(["flight_common"]);return e.jsx(st,{closeButton:l,onClose:n,show:s,body:()=>e.jsxs("div",{className:G("space-y-4 px-4 py-6",u),children:[i||e.jsx("img",{src:"/@wbk/flights/error.png",alt:"error",className:"w-20",height:80,width:80}),e.jsx(d,{as:"h3",variant:"heading-S",children:t}),e.jsx(d,{color:"text-secondary",variant:"body-S",children:a}),r&&e.jsx("div",{className:"flex justify-end",children:e.jsx(L,{theme:"action",onClick:r,children:m("flight_common:refresh")})}),c]})})},Qe=Vn,Zn=()=>{var t,a,s;const[l,n]=b.useState(!0),{locale:r}=X(),{trackEvent:i}=Y(),{t:u}=S(["flight_common"]),{isWebView:c}=je(),m=new URLSearchParams(window.location.search).get("search"),{setSearch:o,search:p}=oe(),{data:g,isLoading:h,isError:v,refetch:f,isRefetchError:_,isRefetching:y}=ca(Z(F({},p),{lang:r,legs:p.legs.map(({arrivalAirport:I,departureAirport:D,outboundDate:C})=>{const{year:T,month:P,day:H}=Qt(new Date(C).getTime(),"en",{year:"numeric",month:"2-digit",day:"2-digit",timeZone:void 0});return{outboundDate:`${T}-${P}-${H}`,departureCode:(D==null?void 0:D.code)||"",arrivalCode:(I==null?void 0:I.code)||""}})})),{data:x,isLoading:k}=da((g==null?void 0:g.sId)||"",{enabled:!!(g!=null&&g.sId)&&!y,refetchInterval:l?1e3:!1,refetchOnWindowFocus:l}),j=()=>{n(!0),f()};b.useEffect(()=>{i({event:"flights_results_page_loaded"})},[]),b.useEffect(()=>{(x!=null&&x.status&&(x==null?void 0:x.status)!=="IN_PROGRESS"&&l||v||_)&&n(!1)},[x==null?void 0:x.status,v,_,l]);const N=p.legs[p.legs.length-1],A=(t=p.legs[0].departureAirport)==null?void 0:t.code,w=p.connectionType==="one_way"?(a=N.arrivalAirport)==null?void 0:a.code:(s=N.departureAirport)==null?void 0:s.code,R=p.adultsCount+p.childrenCount+p.infantsCount,$=B(p.legs[0].outboundDate,r,{day:"numeric",month:"short",timeZone:void 0}),M=B(N.outboundDate,r,{month:"short",day:"numeric",timeZone:void 0});return h||y||k&&!x||(x==null?void 0:x.status)==="IN_PROGRESS"&&!(x!=null&&x.flights.length)?e.jsx(Dt,{}):e.jsxs(Fa,{flightsData:x,sId:g==null?void 0:g.sId,children:[e.jsxs("div",{className:"border-paper rounded-M hidden border-b lg:block",children:[e.jsx("div",{className:"container py-4",children:e.jsx(Ze,{search:p,className:"bg-transparent",id:"flights-search-form-desktop",onFormSubmit:I=>{n(!0),o(I)}})}),e.jsx(gt,{status:x==null?void 0:x.status})]}),e.jsxs("div",{className:`bg-body container sticky z-10 lg:hidden ${c?"top-0":"top-12"}`,children:[e.jsxs("div",{className:"flex items-center justify-between text-center",children:[!c&&e.jsx(L,{shape:"text",theme:"action",as:Fe,href:`/${r}/flights`,className:"px-0",children:e.jsx(ge,{className:"h-4 w-4 ltr:rotate-180 rtl:rotate-0"})}),e.jsx(Ae,{ignoreHistory:!0,render:({open:I})=>e.jsxs(L,{onClick:I,shape:"text",theme:"action",className:"w-full flex-col gap-0",children:[e.jsxs(d,{className:"flex items-center",variant:"label-L",children:[A,p.connectionType==="round_trip"?e.jsx(He,{className:"h-4 w-4 shrink-0 rotate-90"}):p.connectionType==="multi_city"?e.jsx(jt,{className:"h-4 w-4 shrink-0"}):e.jsx(Te,{className:"h-4 w-4 shrink-0 rotate-180"}),w]}),e.jsxs(d,{variant:"label-XS",color:"text-secondary",className:"flex items-center gap-1",children:[$," ",p.connectionType!=="one_way"&&`- ${M}
1`," ","• ",u("flight_common:passengers",{count:R})," ",e.jsx(ge,{className:"h-1.5 w-1.5 shrink-0 rotate-90"})]})]}),cancel:!1,action:{className:"w-full",form:"flights-search-form-mobile",label:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 shrink-0"}),u("flight_common:search_flights")]}),theme:"primary",type:"submit"},body:({close:I})=>e.jsx(Ze,{search:p,className:"mx-0 max-w-full",onFormSubmit:()=>{I(),n(!0)},showSubmit:!1,id:"flights-search-form-mobile"})})]}),e.jsx(gt,{status:x==null?void 0:x.status})]}),e.jsx(Qe,{showModal:v||_,title:u("flight_common:error_retrieving_flights"),description:u("flight_common:flight_error_description"),onRefresh:j}),e.jsx(Ia,{onRefresh:j},m),e.jsx("div",{className:"container py-6",children:e.jsx(Wl,{})})]})},li=Zn,Hn=()=>e.jsxs("div",{className:"relative z-10 shrink-0 basis-56 space-y-2 md:basis-[312px] ltr:mr-4 md:ltr:mr-6 rtl:ml-4 md:rtl:ml-6",children:[e.jsx(na,{className:"h-56 w-full animate-pulse rounded-xl object-cover md:h-[312px]"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"bg-body-level-1 h-2 w-1/2 animate-pulse rounded-md"}),e.jsx("div",{className:"bg-body-level-1 h-2 w-3/4 animate-pulse rounded-md"}),e.jsx("div",{className:"bg-body-level-1 h-2 w-1/2 animate-pulse rounded-md"})]})]}),zn=Hn,Xn={connectionType:"round_trip",adultsCount:1,childrenCount:0,class:"economy",infantsCount:0},qn=[{label:"jeddah",img:"/@wbk/flights/deals/jeddah.png",region:"saudi_arabia",arrivalAirport:{_id:"",code:"JED",name:"King Abdulaziz International Airport",city:"Jeddah",country:"Saudi Arabia"}},{label:"riyadh",img:"/@wbk/flights/deals/riyadh.png",region:"saudi_arabia",arrivalAirport:{_id:"",code:"RUH",name:"Prince Mohammad bin Abdulaziz International Airport",city:"Riyadh",country:"Saudi Arabia"}},{label:"jazan",img:"/@wbk/flights/deals/jazan.png",region:"saudi_arabia",arrivalAirport:{_id:"",code:"GIZ",name:"King Abdullah bin Abdulaziz International Airport",city:"Jazan",country:"Saudi Arabia"}},{label:"medina",img:"/@wbk/flights/deals/medina.png",region:"saudi_arabia",arrivalAirport:{_id:"",code:"MED",name:"Prince Mohammad Bin Abdulaziz Airport",city:"Madinah",country:"Saudi Arabia"}},{label:"cairo",img:"/@wbk/flights/deals/cairo.png",region:"egypt",arrivalAirport:{_id:"",code:"CAI",name:"King Abdulaziz International Airport",city:"Cairo",country:"Egypt"}}],Gt=t=>te({date:new Date,value:t,interval:"day"}),Un=({onSearch:t})=>{const{t:a}=S("flight_common"),{locale:s}=X(),{data:l,isLoading:n}=ht({lang:s});return!l&&!n?null:e.jsx("section",{className:"container py-8",children:e.jsx(Ee,{arrows:"top",title:e.jsx(d,{variant:"heading-XL",children:a("flight_common:webook_selected_flights")}),children:n?Array.from({length:2}).map((r,i)=>e.jsx(zn,{},i)):qn.map(r=>e.jsxs(L,{className:"block shrink-0 basis-56 space-y-2 p-0 text-start md:basis-[312px] ltr:mr-4 md:ltr:mr-6 rtl:ml-4 md:rtl:ml-6",theme:"transparent",shape:"text",onClick:()=>{t(Z(F({},Xn),{legs:[{outboundDate:Gt(1),departureAirport:{city:(l==null?void 0:l.city)||"",country:(l==null?void 0:l.country)||"",code:(l==null?void 0:l.iata)||"",_id:"",name:(l==null?void 0:l.name)||""},arrivalAirport:r.arrivalAirport},{outboundDate:Gt(3),departureAirport:r.arrivalAirport,arrivalAirport:{code:(l==null?void 0:l.iata)||"",_id:"",name:(l==null?void 0:l.name)||"",city:(l==null?void 0:l.city)||"",country:(l==null?void 0:l.country)||""}}]}))},children:[e.jsx(na,{width:312,height:312,className:"h-56 w-full rounded-xl object-cover md:h-[312px]",src:r.img,alt:r.label}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{variant:"label-L",children:a(`flight_common:${r.label}`)}),e.jsx(d,{variant:"body-S",color:"text-secondary",children:a(`flight_common:${r.region}`)})]})]},r.label))})})},Wn=Un,Gn=({search:t,onSearch:a})=>{var s,l,n,r;const{locale:i}=X(),{t:u}=S(["flight_common"]),{trackEvent:c}=Y(),m=B(t.legs[0].outboundDate,i,{month:"short",day:"numeric",weekday:"short",timeZone:void 0}),o=t.connectionType==="round_trip"?B((l=(s=t.legs)==null?void 0:s[1])==null?void 0:l.outboundDate,i,{month:"short",day:"numeric",weekday:"short",timeZone:void 0}):"";return e.jsxs(ae,{as:"button",className:"w-full max-w-xs space-y-4 text-start",onClick:()=>{var p,g;c({event:"flights_recent_search_clicked",data:{origin:((p=t.legs[0].departureAirport)==null?void 0:p.city)||"",destination:((g=t.legs[0].arrivalAirport)==null?void 0:g.city)||"",from:m,to:o?`${o}`:""}}),a(t)},children:[e.jsxs("div",{children:[e.jsx(d,{variant:"body-S",color:"text-tertiary",children:u(`flight_common:${t.connectionType}`)}),e.jsx(d,{variant:"label-M",children:u("flight_common:flight_from_to",{from:((n=t.legs[0].departureAirport)==null?void 0:n.city)||"",to:((r=t.legs[0].arrivalAirport)==null?void 0:r.city)||""})}),e.jsxs(d,{variant:"body-S",color:"text-secondary",children:[m," ",o?`- ${o}`:""]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(d,{variant:"body-S",color:"text-tertiary",children:[u("flight_common:passengers",{count:t.adultsCount+t.childrenCount+t.infantsCount})," ","• ",u(`flight_common:${t.class}`)]}),e.jsx(Be,{className:"[&_path]:fill-primary h-5 w-5 shrink-0"})]})]})},Jn=Gn,Kn=({onSearch:t,clearSearchHistory:a,recentSearch:s}
1)=>{const{t:l}=S("flight_common");return s!=null&&s.length?e.jsxs("div",{className:"space-y-L",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(d,{variant:"heading-M",as:"h2",children:l("flight_common:recent_searches")}),e.jsx(L,{shape:"text",theme:"action",onClick:a,children:e.jsx(d,{variant:"link-M",children:l("flight_common:clear_all")})})]}),e.jsx("div",{className:"gap-x-L gap-y-M flex flex-wrap",children:s.map((n,r)=>e.jsx(Jn,{search:n,onSearch:t},r))})]}):null},Yn=Kn,Qn=({showDeals:t=!0})=>{const{trackEvent:a}=Y(),{t:s}=S(["flight_common"]),{setSearch:l,clearSearchHistory:n,recentSearch:r,search:i}=oe(),{logo:u}=qa();return b.useEffect(()=>{a({event:"flights_home_page_loaded"})},[]),e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"container px-0",children:e.jsxs("div",{className:"xs:bg-[url(/@wbk/flights/search-bg-desktop.svg)] relative rounded-2xl bg-[url(/@wbk/flights/search-bg-mobile.svg)] bg-cover bg-center bg-no-repeat py-16 text-center",children:[e.jsx("img",{src:u||"/@wbk/flights/white-logo.svg",className:"relative mx-auto",width:70,height:22,alt:"logo"}),e.jsx(d,{variant:"heading-XXL",as:"h1",className:"relative mt-1 capitalize tracking-tighter",children:s("flight_common:flights")})]})}),e.jsxs("section",{className:"container space-y-16 pb-4",children:[e.jsx(ae,{rounded:!1,className:"bg-body rounded-M relative z-10 mx-auto -mt-10 max-w-lg lg:max-w-none",children:e.jsx(Ze,{search:i,onFormSubmit:l})}),t&&e.jsx(Wn,{onSearch:l}),e.jsx(Yn,{onSearch:l,clearSearchHistory:n,recentSearch:r})]})]})},ni=Qn,er=({showLegDetails:t=!0})=>{const{t:a}=S(["flight_common"]),{selectedFare:s}=ne();return s==null?void 0:s.legs.map((l,n)=>e.jsxs(b.Fragment,{children:[e.jsx(d,{className:"text-xl font-semibold",children:a(n===0?"flight_common:departure":"flight_common:return")}),e.jsx(La,{showLegDetails:t&&n<2,leg:l}),n!==(s==null?void 0:s.legs.length)-1&&e.jsx("hr",{className:"border-paper my-4"})]},n))},Lt=er,tr=()=>{const{selectedFare:t,user:a}=ne(),{search:s}=oe(),{trackEvent:l}=Y(),{locale:n}=X(),{t:r}=S(["flight_common"]);return b.useEffect(()=>{var i,u;l({event:"flights_summary_page_loaded",data:{flight_type:s.connectionType,price:`${t==null?void 0:t.fareDetails.totalPrice} ${t==null?void 0:t.fareDetails.totalCurrency}`,airline:(t==null?void 0:t.legs[0].segments[0].airline.airlineName)||"",user_status:a?"logged_in":"guest",destination:s.legs.map(c=>c.arrivalAirport),departure_in_date:{start_date:B((i=s.legs[0])==null?void 0:i.outboundDate,n,{weekday:"short",day:"2-digit",month:"short"}),end_date:(u=s.legs[1])!=null&&u.outboundDate?B(s.legs[1].outboundDate,n,{weekday:"short",day:"2-digit",month:"short"}):void 0}}})},[]),e.jsxs("div",{className:"space-y-6",children:[e.jsx(d,{variant:"heading-M",className:"lg:text-heading-XL",children:r("flight_common:flight_summary")}),e.jsx(ae,{children:e.jsx(Lt,{})})]})},ar=tr,sr=({className:t})=>{const{selectedFare:a}=ne(),{search:s}=oe(),{t:l}=S(["flight_common"]),n=s.adultsCount+s.childrenCount+s.infantsCount,r=s.connectionType,i=a==null?void 0:a.fareDetails,u=b.useMemo(()=>{const c=i==null?void 0:i.passengerFares,m=c==null?void 0:c.adult.priceDetails,o=c==null?void 0:c.child.priceDetails,p=c==null?void 0:c.infant.priceDetails,g=Array.from({length:s.adultsCount},()=>({type:"adult",total:m==null?void 0:m.totalPrice,tax:m==null?void 0:m.tax,base:m==null?void 0:m.baseFare})),h=Array.from({length:s.childrenCount},()=>({type:"child",total:o==null?void 0:o.totalPrice,tax:o==null?void 0:o.tax,base:o==null?void 0:o.baseFare})),v=Array.from({length:s.infantsCount},()=>({type:"infant",total:p==null?void 0:p.totalPrice,tax:p==null?void 0:p.tax,base:p==null?void 0:p.baseFare}));return[...g,...h,...v]},[i==null?void 0:i.passengerFares,s.adultsCount,s.childrenCount,s.infantsCount]);return e.jsxs("div",{className:G("space-y-6",t),children:[e.jsx(d,{variant:"heading-M",as:"h2",className:"lg:text-heading-L",children:l("flight_common:order_summary")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(d,{variant:"body-L",className:"flex items-center gap-1",children:[e.jsx("span",{children:l("flight_common:ticket",{count:n})}),e.jsx("span",{className:"bg-body-dark/50 h-1 w-1 rounded-full"}),e.jsx("span",{children:l(`flight_common:${r}`)})]}),e.jsxs("div",{children:[u.map((c,m)=>e.jsx(Sa,{index:m,passengerType:l(`flight_common:${c.type}`),total:c.total||0,currency:i==null?void 0:i.totalCurrency,base:c.base||0,tax:c.tax||0},m)),!!(i!=null&&i.vat)&&e.jsxs("div",{className:"text-text-secondary flex items-center justify-between pt-2 text-sm",children:[e.jsx(d,{children:l("flight_common:vat")}
1),e.jsx(Q,{originalPrice:i==null?void 0:i.vat,currency:i==null?void 0:i.totalCurrency})]}),i==null?void 0:i.fees.map((c,m)=>e.jsxs("div",{className:"text-text-secondary flex items-center justify-between pt-2 text-sm",children:[e.jsx(d,{children:l("flight_common:service_fee")}),e.jsx(Q,{originalPrice:c.price,currency:i==null?void 0:i.totalCurrency})]},m))]})]})]})},Ft=sr,lr=()=>{const[t,a]=b.useState(!1),{totals:s,selectedFare:l}=ne(),{search:n}=oe(),{t:r}=S(["flight_common"]),i=n.adultsCount+n.childrenCount+n.infantsCount,u=e.jsx("div",{className:"line-clamp-2 text-start md:px-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wt,{className:"hidden h-8 w-8 md:block"}),e.jsxs("div",{children:[e.jsx(d,{variant:"body-XS",color:"text-secondary",children:r("flight_common:tickets_total",{count:i})}),e.jsx(Q,{originalPrice:s.net,currency:l==null?void 0:l.fareDetails.totalCurrency,className:"text-sm font-medium"})]})]})});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden lg:block",children:u}),e.jsx(sa,{className:"bg-body/10 relative z-[99] mb-[9px] flex h-screen w-screen items-end p-0 backdrop-blur-sm",align:"start",open:t,onOpenChange:c=>a(c),onClick:()=>a(!1),content:e.jsxs(be.div,{className:"bg-body relative z-50 mx-auto w-full overflow-hidden",initial:{height:0},animate:{height:t?"auto":0},onClick:c=>c.stopPropagation(),children:[e.jsx("div",{className:"flex justify-end p-1",children:e.jsx("button",{className:"text-text-secondary m-1 flex items-center justify-center rounded-full p-2 font-bold",onClick:()=>a(!1),"aria-label":"Close Flight Ticket Summary",children:e.jsx(Le,{className:"h-3 w-3"})})}),e.jsx("div",{className:"h-full max-h-[calc(100vh-260px)] space-y-1 overflow-y-auto px-2 pt-2",children:e.jsx(Ft,{})}),e.jsx(ie,{className:"my-4 border-dashed"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between px-2 pb-4 lg:px-4",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(d,{as:"span",children:r("flight_common:total")}),e.jsxs(d,{as:"span",color:"text-secondary",children:["(",r("flight_common:includes_vat"),")"]})]}),e.jsx(Q,{originalPrice:s.net,currency:l==null?void 0:l.fareDetails.totalCurrency,changeable:!0})]})]}),children:e.jsx("div",{className:"w-full max-w-[33%] text-start md:max-w-[40%] lg:hidden",children:e.jsx(L,{type:"button",theme:"action",shape:"text",className:"focus:ring-input-border h-12 shrink-0 p-1",children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[u,e.jsx("svg",{width:"10",height:"7",className:`text-text-secondary shrink-0 transition ${i?"":"invisible"} ${t?"":"rotate-180"}`,children:e.jsx("path",{d:"M9.91148 5.92015L5.30211 0.792139C5.16825 0.643212 4.93098 0.624239 4.77216 0.749759L4.74901 0.769661L0.0892809 5.91931C-0.0450745 6.06785 -0.0255751 6.29039 0.132834 6.41637C0.200789 6.47042 0.287 6.50008 0.376106 6.50008H9.6239C9.83161 6.50008 10 6.34219 10 6.14742C10 6.06425 9.96865 5.98375 9.91148 5.92015Z",fill:"currentColor"})})]})})})})]})},nr=lr,rr=({disabled:t,loading:a,onNext:s})=>{const{t:l}=S(["flight_common"]),{summaryMode:n}=ne(),r=n==="flight_summary"?"passenger_details":"payment";return e.jsx(os,{"data-visible":n!=="payment",className:"bg-body bottom-0 translate-y-60 transition-transform data-[visible=true]:translate-y-0 lg:bottom-5",children:e.jsx("div",{className:"lg:container",children:e.jsxs("div",{className:"lg:rounded-M bg-body border-paper lg:bg-body-level-2 flex items-center gap-4 border-t p-5 transition-colors lg:border-none lg:p-6",children:[e.jsx(nr,{}),e.jsx("div",{className:"w-full grow lg:max-w-xs ltr:ml-auto rtl:mr-auto",children:e.jsx(L,{className:"h-12 w-full",theme:"action",onClick:s,disabled:t,loading:a,children:e.jsx(d,{variant:"body-L",children:l("flight_common:next_step",{step:l(`flight_common:${r}`)})})})})]})})})},Ea=rr,ir=()=>{const{selectedFare:t,setSummaryMode:a}=ne(),{handleSubmit:s}=de(),{search:l}=oe(),{t:n}=S(["flight_common"]),{trackEvent:r}=Y(),{locale:i}=X();b.useEffect(()=>{var m,o,p,g,h,v,f;const _=t==null?void 0:t.legs[0].segments[0];r({event:"flights_pax_details_page_loaded",data:{flight_type:l.connectionType,passengers_count:l.adultsCount+l.childrenCount+l.infantsCount,price:(m=t==null?void 0:t.fareDetails.totalPrice.toString())!=null?m:"0",airline:(o=_==null?void 0:_.airline.airlineName)!=null?o:"",departure_airport:(p=_==null?void 0:_.departureAirportCode)!=null?p:"",arrival_airport:(g=_==null?void 0:_.arrivalAirportCode)!=null?g:"",class:(h=_==null?void 0:_.airline.class)!=null?h:"",destination:l.legs.map(y=>y.arrivalAirport),departure_in_date:{start_date:B((v=l.legs[0])==null?void 0:v.outboundDate,i,{weekday:"short",day:"2-digit",month:"short"}),end_date:(f=l.legs[1])!=null&&f.outboundDate?B(l.legs[1].outboundDate,i,{weekday:"short",day:"2-digit",month:"short"}):void 0}}})},[]);const u=()=>{var m,o;a("payment"),r({event:"flights_pax__details_continue_clicked",data:{destination:l.legs.map(p=>p.arrivalAirport),departure_in_date:{start_date:B((m=l.legs[0])==null?void 0:m.outboundDate,i,{weekday:"short",day:"2-digit",month:"short"}),end_date:(o=l.legs[1])!=null&&o.outboundDate?B(l.legs[1].outboundDate,i,{weekday:"short",day:"2-digit",month:"short"}):void 0}}}),ea()},c=m=>{var o,p,g,h,v,f,_;const y=t==null?void 0:t.legs[0].segments[0];if(Array.isArray(m==null?void 0:m.passengersList)&&m.passengersList.length)for(const x of m.passengersList)x&&r({event:"flights_pax__details_error_occurred",data:{section:`passenger-${x.id}`,error_message:x.message||"",data:{flight_type:l.connectionType,passengers_count:l.adultsCount+l.childrenCount+l.infantsCount,price:(o=t==null?void 0:t.fareDetails.totalPrice.toString())!=null?o:"0",airline:(p=y==null?void 0:y.airline.airlineName)!=null?p:"",departure_airport:(g=y==null?void 0:y.departureAirportCode)!=null?g:"",arrival_airport:(h=y==null?void 0:y.arrivalAirportCode)!=null?h:"",class:(v=y==null?void 0:y.airline.class)!=null?v:"",destination:l.legs.map(k=>k.arrivalAirport),departure_in_date:{start_date:B((f=l.legs[0])==null?void 0:f.outboundDate,i,{weekday:"short",day:"2-digit",month:"short"}),end_date:(_=l.legs[1])!=null&&_.outboundDate?B(l.legs[1].outboundDate,i,{weekday:"short",day:"2-digit",month:"short"}):void 0}}}});m!=null&&m.contactDetails&&Object.entries(m.contactDetails).forEac
1h(([x,k])=>{var j,N,A,w,R,$,M;r({event:"flights_pax__details_error_occurred",data:{section:"contact_details_form",error_message:(k==null?void 0:k.message)||"",data:{flight_type:l.connectionType,passengers_count:l.adultsCount+l.childrenCount+l.infantsCount,price:(j=t==null?void 0:t.fareDetails.totalPrice.toString())!=null?j:"0",airline:(N=y==null?void 0:y.airline.airlineName)!=null?N:"",departure_airport:(A=y==null?void 0:y.departureAirportCode)!=null?A:"",arrival_airport:(w=y==null?void 0:y.arrivalAirportCode)!=null?w:"",class:(R=y==null?void 0:y.airline.class)!=null?R:"",destination:l.legs.map(I=>I.arrivalAirport),departure_in_date:{start_date:B(($=l.legs[0])==null?void 0:$.outboundDate,i,{weekday:"short",day:"2-digit",month:"short"}),end_date:(M=l.legs[1])!=null&&M.outboundDate?B(l.legs[1].outboundDate,i,{weekday:"short",day:"2-digit",month:"short"}):void 0}}}})})};return e.jsxs("div",{className:"space-y-L",children:[e.jsx(d,{variant:"heading-M",className:"lg:text-heading-XL",children:n("flight_common:who_is_traveling")}),e.jsx(Pa,{}),e.jsxs("form",{onSubmit:s(u,c),children:[e.jsx(Ta,{}),e.jsx(Ea,{})]})]})},or=ir,cr=({onNext:t,disabled:a,loading:s})=>{const{totals:l,selectedFare:n}=ne(),{recentSearch:r}=oe(),{paymentMethod:i}=Nt(),{trackEvent:u}=Y(),{t:c}=S("flight_common"),{locale:m}=X();return b.useEffect(()=>{var o,p,g,h;u({event:"flights_payment_method_selected",data:{payment_method:i==null?void 0:i.type,flight_type:r[0].connectionType,price:`${n==null?void 0:n.fareDetails.totalPrice} ${n==null?void 0:n.fareDetails.totalCurrency}`,airline:(n==null?void 0:n.legs[0].segments[0].airline.airlineName)||"",destination:r.map(v=>v.legs[0].arrivalAirport),departure_in_date:{start_date:B((p=(o=r[0])==null?void 0:o.legs[0])==null?void 0:p.outboundDate,m,{weekday:"short",day:"2-digit",month:"short"}),end_date:(h=(g=r[1])==null?void 0:g.legs[0])!=null&&h.outboundDate?B(r[1].legs[0].outboundDate,m,{weekday:"short",day:"2-digit",month:"short"}):void 0}}})},[i==null?void 0:i.type]),e.jsxs("div",{className:"space-y-4 lg:px-0.5",children:[e.jsx(Et,{totals:Z(F({},l),{net_after_discount:l.net}),applePayEnable:!0,tabbyEnable:!0,className:"[&_h2]:text-heading-M hidden lg:block"}),e.jsx(Ft,{className:"lg:hidden"}),e.jsx("hr",{className:"border-paper lg:hidden"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between lg:hidden",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(d,{as:"span",children:c("flight_common:total")}),e.jsx(d,{as:"span",color:"text-secondary",children:c("flight_common:includes_vat")})]}),e.jsx(Q,{originalPrice:l.net,currency:n==null?void 0:n.fareDetails.totalCurrency,changeable:!0})]})," ",e.jsx("hr",{className:"border-paper lg:hidden"}),e.jsx(Et,{totals:Z(F({},l),{net_after_discount:l.net}),applePayEnable:!0,tabbyEnable:!0,className:"[&_h2]:!text-heading-S lg:hidden"}),e.jsx(Ms,{}),e.jsx("div",{className:"mx-auto max-w-sm",children:e.jsx(Is,{className:"h-12",totals:Z(F({},l),{net_after_discount:l.net}),currency:n==null?void 0:n.fareDetails.totalCurrency,loading:s,disabled:a,onClick:t})}),e.jsx(d,{variant:"body-XS",color:"text-secondary",className:"text-center",children:e.jsxs(xt,{i18nKey:"payment_agree",ns:"flight_common",children:[e.jsx(L,{as:Fe,shape:"text",theme:"action","data-testid":"ticketing_summary_terms_page_link",className:"text-text-secondary px-0.5 py-0 font-semibold underline",href:`/${m}/terms`,target:"_blank",rel:"noreferrer",children:" "}),e.jsx(L,{as:Fe,shape:"text",theme:"action","data-testid":"ticketing_summary_privacy_page_link",className:"text-text-secondary px-0.5 py-0 font-semibold underline",href:`/${m}/privacy`,target:"_blank",rel:"noreferrer",children:" "})]})})]})},dr=cr,mr=()=>{var t,a;const{t:s}=S(["flight_common"]),{summaryMode:l,selectedFare:n,totals:r}=ne(),{watch:i}=de(),{search:u}=oe(),c=i("passengersList"),m=n==null?void 0:n.legs[0].segments[0],o=n==null?void 0:n.legs[0].segments[n.legs[0].segments.length-1],p=n==null?void 0:n.legs[n.legs.length-1].segments[0],g=m==null?void 0:m.departureCityName,h=u.connectionType==="multi_city"?p==null?void 0:p.arrivalCityName:o==null?void 0:o.arrivalCityName;return e.jsx("aside",{className:"hidden w-full max-w-md lg:block",children:e.jsxs("div",{className:"sticky top-4 space-y-4",children:[e.jsxs(ae,{children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("img",{src:"/@wbk/flights/plane.png",alt:"Airplane",height:106,width:106,className:"shrink-0"}),e.jsxs("div",{children:[e.jsx(d,{color:"text-secondary",variant:"body-S",children:s("flight_common:flight")}),e.jsxs(d,{variant:"body-L",className:"flex gap-1 font-medium",children:[e.jsx("span",{children:g}),e.jsx("span",{className:"lowercase",children:s("flight_common:to")}),e.jsx("span",{children:h})]}),e.jsx(d,{color:"text-secondary",variant:"body-S",children:s(`flight_common:${u.connectionType}`)})]})]}),l!=="flight_summary"&&e.jsx(Lt,{showLegDetails:!1})]}),e.jsxs("div",{className:"border-paper space-y-4 rounded-lg border p-4",children:[e.jsx(Ft,{}),e.jsx("hr",{className:"border-paper border-dashed"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(d,{as:"span",children:s("flight_common:total")}),e.jsxs(d,{as:"span",color:"text-secondary",children:["(",s("flight_common:includes_vat"),")"]})]}
1),e.jsx(Q,{originalPrice:r.net,currency:n==null?void 0:n.fareDetails.totalCurrency,changeable:!0})]})]}),l!=="flight_summary"&&e.jsxs(e.Fragment,{children:[n!=null&&n.legs?e.jsx(ae,{children:e.jsx(it,{legs:n.legs,triggerClassName:"p-0"})}):null,!!((t=n==null?void 0:n.penalty)!=null&&t.length)&&e.jsx(ae,{children:e.jsx(rt,{passengers:{length:c.length,passenger_type:(a=c[0])==null?void 0:a.type},legs:n.legs,penalty:n==null?void 0:n.penalty,triggerClassName:"p-0"})})]})]})})},ur=mr,hr=()=>{const{t}=S(["flight_common"]),{selectedFare:a}=ne(),{isMobile:s}=je(),{watch:l}=de(),n=l("passengersList"),r=({open:u})=>e.jsx(L,{className:"text-sm",shape:"text",theme:"primary",onClick:u,children:t("flight_common:view_flight_summary")}),i=()=>{var u,c;return e.jsxs("div",{className:"space-y-6 pb-20 lg:pb-0",children:[e.jsx(d,{variant:"heading-S",as:"h2",className:"lg:text-XL text-center lg:ltr:text-left lg:rtl:text-right",children:t("flight_common:flight_summary")}),e.jsx("div",{className:"border-paper rounded-lg border p-4",children:e.jsx(Lt,{})}),a!=null&&a.legs?e.jsxs(ae,{children:[e.jsx(it,{legs:a==null?void 0:a.legs,triggerClassName:"mb-4 p-0"}),a.legs.map((m,o)=>{var p,g,h,v;return e.jsxs(b.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1 pb-3",children:[e.jsx(d,{children:(g=(p=m.segments)==null?void 0:p[0])==null?void 0:g.departureCityName}),e.jsx(d,{className:"lowercase",children:t("flight_common:to")}),e.jsx(d,{children:(v=(h=m.segments)==null?void 0:h[m.segments.length-1])==null?void 0:v.arrivalCityName})]}),e.jsx(ze,{baggage:m.baggage,className:o!==a.legs.length-1?"pb-4":""}),o!==a.legs.length-1&&e.jsx(ie,{className:"pb-4"})]},o)})]}):null,!!((u=a==null?void 0:a.penalty)!=null&&u.length)&&e.jsxs(ae,{children:[e.jsx(rt,{passengers:{length:n.length,passenger_type:(c=n[0])==null?void 0:c.type},legs:a.legs,penalty:a.penalty,triggerClassName:"mb-4 p-0"}),a.penalty.map((m,o)=>{var p,g,h,v,f,_,y,x;return e.jsxs(b.Fragment,{children:[e.jsx(nt,{penalty:m,className:o!==a.legs.length-1?"pb-4":"",departureCity:(v=(h=(g=(p=a.legs)==null?void 0:p[o])==null?void 0:g.segments)==null?void 0:h[0])==null?void 0:v.departureCityName,arrivalCity:(x=(y=(_=(f=a.legs)==null?void 0:f[o])==null?void 0:_.segments)==null?void 0:y[a.legs[o].segments.length-1])==null?void 0:x.arrivalCityName},o),o!==a.penalty.length-1&&e.jsx(ie,{className:"pb-4"})]},o)})]})]})};return s?e.jsx(ra,{render:r,body:i,sectionClassName:"px-6 py-4",closeButton:!0}):e.jsx(st,{render:r,body:i,closeButton:!0,className:"p-4",size:"2xl"})},gr=hr,pr=()=>{var t,a,s,l,n;const[r,i]=b.useState(!1),{summaryMode:u,setSummaryMode:c,user:m,selectedFare:o,searchId:p,flightId:g,checkout:h}=ne(),{setSearch:v,search:f}=oe(),{watch:_,setValue:y}=de(),[x,k,j]=_(["passengersList","checkoutError","checkoutLoading"]),{trackEvent:N}=Y(),{paymentMethod:A}=Nt(),{locale:w,push:R,search:$}=X(),M=$.get("payment_status"),I=$.get("attempt"),D=I!==null&&I.trim()!==""?Number(I):NaN,{bookingSource:C}=pt(),{t:T}=S(["flight_common","payment_common"]);za({onShow:()=>{y("checkoutLoading",!1)}});const P=()=>ve(null,null,function*(){var E,V,U;if(!(!x.length||!p||!g))try{const W=(V=(E=o==null?void 0:o.legs)==null?void 0:E[0].segments)==null?void 0:V[0];N({event:"flights_proceed_to_payment_clicked",data:{origin:(W==null?void 0:W.departureCityName)||"",destination:(W==null?void 0:W.arrivalCityName)||"",departure_in_date:(W==null?void 0:W.departureDateTime)||"",return_in_date:(W==null?void 0:W.arrivalDateTime)||"",flight_type:f.connectionType,passengers_count:x.length,class:f.class,price:((U=o==null?void 0:o.fareDetails)==null?void 0:U.totalPrice.toString())||"",airline:(W==null?void 0:W.airline.airlineName)||"",booking_source:C}}),yield h(),M==="failed"&&N({event:"flights_payment_retried",data:{payment_method:(A==null?void 0:A.type)||"",attempt_number:D||1}})}catch{y("checkoutLoading",!1),et("passengers_pass_errors")}});if(!p||!g||!o)return e.jsx(Qe,{showModal:!0,title:T("flight_common:error_retrieving_flight"),description:T("flight_common:flight_error_description"),onRefresh:()=>v(f)});const H=o.legs[0].segments[0],O=o.legs[0].segments[o.legs[0].segments.length-1],q=o.legs[o.legs.length-1].segments[0],z=H==null?void 0:H.departureAirportCode,J=f.connectionType==="multi_city"?q.arrivalAirportCode:O==null?void 0:O.arrivalAirportCode,me=B(H.departureDateTime,w,{month:"short",day:"numeric",timeZone:void 0}),pe=B(new Date(q.departureDateTime),w,{month:"short",day:"numeric",timeZone:void 0}),ce=()=>{var E,V;m?u==="payment"?P():c(u==="flight_summary"?"passenger_details":"payment"):(i(!0),N({event:"flights_login_page_loaded",data:{flight_type:f.connectionType,price:`${o==null?void 0:o.fareDetails.totalPrice} ${o==null?void 0:o.fareDetails.totalCurrency}`,airline:(o==null?void 0:o.legs[0].segments[0].airline.airlineName)||"",user_status:m?"logged_in":"guest",destination:f.legs.map(W=>W.arrivalAirport),departure_in_date:{start_date:B((E=f.legs[0])==null?void 0:E.outboundDate,w,{weekday:"short",day:"2-digit",month:"short"}),end_date:(V=f.legs[1])!=null&&V.outboundDate?B(f.legs[1].outboundDate,w,{weekday:"short",day:"2-digit",month:"short"}):void 0}}})),ea()},re=(k==null?void 0:k.status)===404;return r?e.jsx("div",{className:"mx-auto max-w-lg py-20",children:e.jsx(As,{title:T("flight_common:login_to_book"),initialMode:m!=null&&m.force_verify_email?"otp":"email",onSuccess:()=>{c("passenger_details"),i(!1)}})}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{onClose:()=>{const E=new URLSearchParams(window.location.search);E.delete("payment_status"),R(`${window.location.pathname}?${E.toString()}`)},closeButton:!re,showModal:M==="failed"||!!k,title:T(re?"flight_common:flight_not_available":"flight_common:we_have_a_small_problem"),description:re?void 0:T("flight_common:payment_failed_description"),icon:re?e.jsx(Ma,{className:"mx-auto h-20 w-20 shrink-0"}):void 0,className:re?"text-center":void 0,actionButton:e.jsx(L,{onClick:()=>v(f),children:T("flight_common:explore_other_options")})}),e.jsxs("section",{className:"container relative flex max-w-screen-2xl grow flex-col overflow-hidden pb-36 pt-6 lg:flex-row lg:gap-4 lg:overflow-visible",children:[e.jsxs("div",{className:"grow space-y-6",children:[u!=="flight_summary"&&!!u&&e.jsxs("div",{className:"block lg:hidden",children:[e.jsxs(d,{className:"flex items-center",variant:"label-L",children:[z,f.connectionType==="round_trip"?e.jsx(He,{className:"h-4 w-4 shrink-0 rotate-90"}):f.connectionType==="multi_city"?e.jsx(jt,{className:"h-4 w-4 shrink-0 rtl:rotate-180"}):e.jsx(Te,{className:"h-4 w-4 shrink-0 ltr:rotate-180 rtl:-mt-1"}),J]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(d,{color:"text-secondary",variant:"body-S",children:[T(`flight_common:${f.connectionType}`)," • ",me," ",f.connectionType!=="one_way"&&`- ${pe}`]}),e.jsx(gr,{})]}),e.jsx(ie,{type:"zigzag",className:"text-body-level-1 mt-6"})]}),u==="flight_summary"?e.jsx(ar,{}):u==="passenger_details"?e.jsx(or,{}):e.jsx(dr,{onNext:ce,loading:j}),u==="flight_summary"&&e.jsxs(e.Fragment,{children:[o!=null&&o.legs?e.jsxs(ae,{children:[e.jsx(it,{legs:o.legs,triggerClassName:"mb-4 p-0"}),o.legs.map((E,V)=>{var U,W,se,le;return e.jsxs(b.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1 pb-3",children:[e.jsx(d,{children:(W=(U=E.segments)==null?void 0:U[0])==null?void 0:W.departureCityName}),e.jsx(d,{className:"lowercase",children:T("flight_common:to")}),e.jsx(d,{children:(le=(se=E.segments)==null?void 0:se[E.segments.length-1])==null?void 0:le.arrivalCityName})]}),e.jsx(ze,{baggage:E.baggage,className:V!==o.legs.length-1?"pb-4":""}),V!==o.legs.length-1&&e.jsx(ie,{className:"pb-4"})]},V)})]}):null,!!o.penalty.length&&e.jsxs(ae,{children:[e.jsx(rt,{passengers:{length:x.length,passenger_type:(t=x[0])==null?void 0:t.type},legs:o.legs,penalty:o.penalty,triggerClassName:"mb-4 p-0"}),o.penalty.map((E,V)=>{var U,W,se,le,ue,xe,he,Re;return e.jsxs(b.Fragment,{children:[e.jsx(nt,{penalty:E,className:V!==o.legs.length-1?"pb-4":"",departureCity:(le=(se=(W=(U=o.legs)==null?void 0:U[V])==null?void 0:W.segments)==null?void 0:se[0])==null?void 0:le.departureCityName,arrivalCity:(Re=(he=(xe=(ue=o.legs)==null?void 0:ue[V])==null?void 0:xe.segments)==null?void 0:he[o.legs[V].segments.length-1])==null?void 0:Re.arrivalCityName},V),V!==o.penalty.length-1&&e.jsx(ie,{className:"pb-4"})]},V)})]})]}),e.jsx("div",{className:"space-y-1",id:"passengers_pass_errors",children:!!((s=(a=k==null?void 0:k.errors)==null?void 0:a.passengers_pass)!=null&&s.length)&&((n=(l=k==null?void 0:k.errors)==null?void 0:l.passengers_pass)==null?void 0:n.map((E,V)=>e.jsx(d,{variant:"body-S",color:"error",children:E},`${E}-${V}`)))})]}),e.jsx(ur,{})]}),u!=="passenger_details"&&e.jsx(Ea,{onNext:ce,loading:j})]})},xr=pr,fr=t=>{var a=t,{text:s,className:l=""}=a,n=ee(a,["text","className"]);return e.jsxs(L,Z(F({theme:"transparent",shape:"text",className:G("hover:bg-primary/10 shrink-0 items-center gap-1 px-0 py-0.5 text-xs !ring-0 focus:underline",l)},n),{children:[e.jsx("svg",{className:"h-5 w-5 shrink-0 ltr:rotate-180",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8.58984 16.59L13.1698 12L8.58984 7.41L9.99984 6L15.9998 12L9.99984 18L8.58984 16.59Z",fill:"currentColor"})}),e.jsx("span",{className:"ltr:pr-2 rtl:pl-2",children:s})]}))},vr=fr,_r=()=>
1{const{summaryMode:t,setSummaryMode:a}=ne(),{setSearch:s,search:l}=oe(),{isWebView:n}=je(),{t:r}=S("flight_common"),i=()=>{t==="payment"?a("passenger_details"):t==="passenger_details"?a("flight_summary"):s(l)};return!n&&e.jsx(vr,{text:r("flight_common:back"),onClick:i})},yr=_r,jr=()=>{const{selectionTime:t}=ne(),{setSearch:a,search:s}=oe(),l=t||Date.now(),n=b.useMemo(()=>new Date(l).getTime()/1e3+600-Date.now()/1e3,[l]),{t:r}=S(["flight_common"]);return e.jsx(Ia,{initialSeconds:n,onRefresh:()=>{a(s)},text:({count:i})=>{const u=Date.now()/1e3,m=u+i-u,o=B(m,"en",{minute:"2-digit",second:"2-digit"});return e.jsx(Ne,{children:e.jsx(be.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.3,ease:"easeOut"},opacity:{duration:.2}},className:"bg-body-level-1 overflow-hidden",children:e.jsx("div",{className:"flex items-center justify-center p-1 text-center",children:e.jsx(d,{variant:"label-S",className:"text-body-contrast shrink-0",children:i<=0?r("flight_common:time_out"):e.jsx(xt,{i18nKey:"flight_common:time_left",values:{time:o},children:e.jsx("span",{className:i>30?"text-success":"text-notice"})})})})})})}})},br=jr,Nr=()=>{const{trackEvent:t}=Y(),{currency:a,currencies:s,setCurrency:l}=Fs(),{summaryMode:n}=ne(),r=[{id:"flight_summary",label:"tickets"},{id:"passenger_details",label:"passenger_details"},{id:"payment",label:"checkout"}],i=r.findIndex(u=>u.id===n);return e.jsx(is,{isMini:!1,steps:r,activeStep:i,backButtonComponent:e.jsx(yr,{}),countdownComponent:e.jsx(br,{}),currency:a,currencies:s,setCurrency:l,trackEvent:t})},wr=Nr,Cr=()=>{var t;const{locale:a,search:s}=X(),{supportedCountryCode:l}=Ua(),{user:n}=bt(),{data:r,isLoading:i}=Ss({slug:((t=Ts.config)==null?void 0:t.flightsSlug)||""}),u=s.get("searchId")||"",c=s.get("flightId")||"",{data:m,isLoading:o,isError:p}=ma({searchId:u,flightId:c,lang:a});return o||i?e.jsx(Dt,{}):e.jsx(Ps,{user:n,locale:a,supportedCountryCode:l??void 0,isTabbyEnabled:(r==null?void 0:r.is_tabby)==="1",isWalletEnabled:r==null?void 0:r.is_wallet_enabled,isApplePayEnabled:r==null?void 0:r.is_apple_pay_allowed,currency:r==null?void 0:r.currency,event:{_id:(r==null?void 0:r._id)||"",title:(r==null?void 0:r.title)||"",vat_percent:(r==null?void 0:r.vat_percent)||"",enable_payment_methods:r==null?void 0:r.enable_payment_methods,tabby_min_order_limit:(r==null?void 0:r.tabby_min_order_limit)||"",card_types:(r==null?void 0:r.card_types)||[],card_discounts:(r==null?void 0:r.card_discounts)||[]},payable:{type:"event",id:(r==null?void 0:r._id)||""},vertical:"flights",children:e.jsxs(kt,{selectedFare:m,searchId:u,flightId:c,children:[e.jsx(wr,{}),p||!m?e.jsx(kr,{}):e.jsx(xr,{})]})})},kr=()=>{const{setSearch:t,search:a}=oe(),{t:s}=S(["flight_common"]);return e.jsx(Qe,{showModal:!0,title:s("flight_common:error_retrieving_flight"),description:s("flight_common:flight_error_description"),onRefresh:()=>{t(a)}})},ri=Cr,Sr=()=>e.jsxs("div",{className:"space-y-4 lg:max-w-2xl",children:[e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("div",{className:"bg-body-dark/10 max-w-xs grow animate-pulse rounded-lg p-4"}),e.jsx("div",{className:"bg-body-dark/10 max-w-[100px] grow animate-pulse rounded-lg p-4"})]}),Array.from({length:3}).map((t,a)=>e.jsx("div",{className:"bg-body-dark/10 h-20 animate-pulse items-center rounded-lg p-4"},a))]}),Dr=Sr,Lr=({passenger:t})=>{const[a,s]=b.useState(!1),{t:l}=S(["flight_common"]),{isMobile:n}=je(),{mutateAsync:r}=Ds(),i=m=>ve(null,null,function*(){s(!0);try{yield r(t.id)}catch{}finally{s(!1),m()}}),u=({close:m})=>e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx(d,{as:"h2",variant:"heading-S",className:"capitalize",children:l("flight_common:remove_passenger")}),e.jsx(d,{color:"text-secondary",variant:"body-S",children:l("flight_common:remove_passenger_notice")}),e.jsxs("div",{className:"flex items-center justify-end gap-4",children:[e.jsx(L,{shape:"text",theme:"action",type:"button",onClick:m,children:l("flight_common:cancel")}),e.jsx(L,{shape:"solid",type:"button",theme:"action",onClick:()=>i(m),disabled:a,children:l("flight_common:yes")})]})]}),c=({open:m})=>e.jsx(L,{shape:"text",className:"underline underline-offset-2",type:"button",theme:"action",onClick:m,children:l("flight_common:remove")});return n?e.jsx(ra,{render:c,body:u}):e.jsx(st,{render:c,body:u,closeButton:!0})},Fr=Lr,Ar=({passenger:t})=>{var a;const{t:s}=S(["flight_common"]),l=(a=t.documents)==null?void 0:a.some(n=>Date.now()>new Date(n.expiry_date).getTime());return e.jsxs("div",{className:"border-paper flex flex-col justify-between gap-6 rounded-lg border p-4 sm:flex-row",children:[e.jsxs("div",{children:[e.jsxs(d,{className:"text-xl capitalize",children:[t.first_name," ",t.middle_name," ",t.last_name]}),t.date_of_birth&&e.jsx(d,{color:"text-secondary",children:t.date_of_birth}),l&&e.jsx(d,{color:"secondary",children:s("flight_common:please_update_travel_documents")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ke,{showTravelDocs:!0,initialPassenger:t,renderAction:({open:n})=>e.jsx(L,{shape:"outlined",type:"button",theme:"action",onClick:n,children:s("flight_common:edit")})}),e.jsx(Fr,{passenger:t})]})]})},Tr=Ar,Pr=()=>{const{t}=S(["flight_common"]),{data:a,isLoading:s,isError:l,error:n}=ua();if(s)return e.jsx(Dr,{});const r=a&&(a==null?void 0:a.length)>=20;return e.jsxs("div",{className:"mt-px space-y-6 lg:max-w-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-2xl capitalize",children:t("flight_common:my_travelers")}),e.jsx(Ke,{limitReached:r,showTravelDocs:!0,renderAction:({open:i})=>e.jsx(L,{shape:"text",type:"button",theme:"action",className:"px-2 py-1 underline underline-offset-2",onClick:i,children:t("flight_common:add_traveler")})},a==null?void 0:a.length)]}),e.jsx("div",{className:"space-y-4",children:l?e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(d,{color:"error",children:(n==null?void 0:n.message)||t("flight_common:unknown_error")})}):a!=null&&a.length?a==null?void 0:a.map(i=>e.jsx(Tr,{passenger:i},i.id)):e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 lg:py-6",children:[e.jsx(_t,{className:"h-12 w-12 shrink-0"}),e.jsx(d,{variant:"heading-S",className:"lg:text-heading-M text-center font-semibold",children:t("flight_common:no_saved_passengers")}),e.jsx(Ke,{limitReached:r,showTravelDocs:!0,renderAction:({open:i})=>e.jsx(L,{shape:"text",type:"button",theme:"action",className:"underline underline-offset-2",onClick:i,children:t("flight_common:add_traveler")})})]})})]})},ii=Pr,Mr=()=>e.jsxs("div",{className:"bg-body-dark/10 relative flex h-56 w-full max-w-[520px] animate-pulse flex-col items-start justify-start px-4 py-3",children:[e.jsx("div",{className:"bg-body absolute -left-2 -top-2 h-4 w-4 rotate-45"}),e.jsx("div",{className:"bg-body absolute -bottom-2 -left-2 h-4 w-4 rotate-45"}),e.jsx("div",{className:"bg-body absolute -right-2 -top-2 h-4 w-4 rotate-45"}),e.jsx("div",{className:"bg-body absolute -bottom-2 -right-2 h-4 w-4 rotate-45"}),e.jsx("div",{className:"bg-body absolute -left-2 top-1/2 h-4 w-4 translate-y-1/2 rotate-45"})]}),Ir=Mr,Er=({status:t,className:a,showIcon:s=!0})=>{const{t:l}=S("flight_common");return e.jsx("div",{className:G("bg-body border-paper w-fit roun
1ded border p-1",a),children:t==="processed"?e.jsxs(d,{color:"success",className:"flex items-center gap-1",children:[s&&e.jsx($e,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{children:l("flight_common:booking_confirmed")})]}):t==="failed"?e.jsxs(d,{color:"error",className:"flex items-center gap-1",children:[s&&e.jsx(Ie,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{children:l("flight_common:booking_failed")})]}):e.jsxs(d,{className:"flex items-center gap-1 text-blue-500",children:[s&&e.jsx(ut,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{children:l("flight_common:confirming_your_booking")})]})})},$r=Er,Rr=({order:t})=>{const{locale:a}=X(),{trackEvent:s}=Y(),{t:l}=S(["flight_common"]),n=t.booking_data.legs,r=n[0].segments[0],i=n[n.length-1].segments[n[n.length-1].segments.length-1],u=n.length===1,c=r.departureCityName,m=u?i.arrivalCityName:n[n.length-1].segments[0].departureCityName,o=new Date(r.departureDateTime).getTime()-Date.now(),p=Math.round(o/(1e3*60*60*24)),{hour:g,minute:h}=Pe({from:new Date,to:te({date:new Date,value:o/1e3,interval:"second"}),includeZero:!0});return e.jsxs(L,{className:"bg-body-level-1 relative flex w-full max-w-[520px] flex-col items-start justify-start px-4 py-3",theme:"transparent",shape:"text",as:Fe,to:`/profile/bookings/flights/${t._id}`,onClick:()=>{s({event:"flights_bookings_card_clicked"})},children:[e.jsx("div",{className:"bg-body absolute -left-2 -top-2 h-4 w-4 rotate-45"}),e.jsx("div",{className:"bg-body absolute -bottom-2 -left-2 h-4 w-4 rotate-45"}),e.jsx("div",{className:"bg-body absolute -right-2 -top-2 h-4 w-4 rotate-45"}),e.jsx("div",{className:"bg-body absolute -bottom-2 -right-2 h-4 w-4 rotate-45"}),e.jsx("div",{className:"bg-body absolute -left-2 top-1/2 h-4 w-4 translate-y-1/2 rotate-45"}),e.jsxs("div",{className:"space-y-6 text-start",children:[e.jsxs("div",{children:[e.jsxs(d,{variant:"heading-S",className:"flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{children:c}),e.jsx(He,{className:"h-4 w-4 shrink-0 rotate-90"}),e.jsx("span",{children:m})]}),t.booking_status!=="failed"&&e.jsx(d,{color:"text-secondary",className:"text-start",children:o>=0?l("flight_common:departs_in",{count:p,hours:g.toString().padStart(2,"0"),minutes:h.toString().padStart(2,"0")}):l("flight_common:departed")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx($r,{status:t.booking_status}),t.booking_status==="approved"&&e.jsx(d,{variant:"body-XS",color:"text-secondary",children:l("flight_common:we_are_processing_your_booking")})]}),e.jsxs("div",{children:[e.jsx(d,{variant:"body-S",children:u?B(new Date(r.departureDateTime),a,{day:"numeric",month:"short",year:"numeric",timeZone:void 0}):`${B(new Date(r.departureDateTime),a,{day:"numeric",month:"short",timeZone:void 0})} - ${B(new Date(i.arrivalDateTime),a,{day:"numeric",month:"short",year:"numeric",timeZone:void 0})}`}),e.jsxs(d,{variant:"body-S",children:[e.jsxs("span",{children:[l("flight_common:booking_id"),":"]})," ",e.jsx("span",{children:t.booking_data.orderNumber})]}),t.booking_data.pnrNumber&&e.jsxs(d,{variant:"body-S",children:[e.jsxs("span",{children:[l("flight_common:pnr"),":"]})," ",e.jsx("span",{children:t.booking_data.pnrNumber})]})]})]}),e.jsxs("div",{className:"flex w-full items-center justify-end gap-1 text-sm",children:[e.jsx(d,{children:l("flight_common:passengers",{count:t.booking_data.travelers.length})}),e.jsx(ge,{className:"mt-0.5 h-2 w-2 shrink-0 rtl:rotate-180"})]})]})},Or=Rr,Br=({orders:t,title:a})=>e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base capitalize",children:a}),e.jsx("ul",{className:"space-y-6",children:t.map(s=>e.jsx("li",{children:e.jsx(Or,{order:s},s._id)},s._id))})]}),Jt=Br,Vr=()=>{const{locale:t}=X(),{t:a}=S(["flight_common"]),{data:s,isLoading:l,error:n}=Ls({lang:t}),{trackEvent:r}=Y(),{pastFlightOrders:i,upcomingFlightOrders:u}=b.useMemo(()=>{const c=s==null?void 0:s.filter(p=>!!p.booking_data.legs),m=[],o=[];for(const p of c||[]){const g=p.booking_data.legs[0].segments[0];new Date(g.departureDateTime).getTime()<Date.now()?o.push(p):m.push(p)}return{pastFlightOrders:o,upcomingFlightOrders:m}},[s]);return b.useEffect(()=>{const c=u.map(m=>m.booking_data.orderNumber);r({event:"flights_bookings_tab_clicked",data:{active_bookings:c}})},[]),l?e.jsx("div",{className:"space-y-4 py-4",children:[1,2,3,4].map(c=>e.jsx(Ir,{},c))}
1):n?e.jsx("div",{className:"mx-auto max-w-xl p-4 pb-12",children:e.jsxs("div",{className:"space-y-8 shadow-md",children:[e.jsx(d,{color:"error",variant:"heading-M",className:"text-center",children:(n==null?void 0:n.message)||a("flight_common:unknown_error")}),e.jsx("div",{className:"mx-auto w-full max-w-xs",children:e.jsx(L,{as:Fe,href:`/${t}`,theme:"action",shape:"outlined",className:"w-full text-lg",children:a("flight_common:go_home")})})]})}):s!=null&&s.length?e.jsxs("div",{className:"space-y-10 px-0.5",children:[u.length>0&&e.jsx(Jt,{orders:u,title:a("flight_common:upcoming_bookings")}),i.length>0&&e.jsx(Jt,{orders:i,title:a("flight_common:past_bookings")})]}):e.jsxs("div",{className:"px-4 py-8 text-center",children:[e.jsx("div",{className:"mx-auto flex items-center justify-center rounded-full",children:e.jsx(wt,{className:"text-text-primary h-12 w-12"})}),e.jsx(d,{variant:"heading-L",className:"py-3",children:a("flight_common:no_bookings")})]})},oi=Vr;export{ai as ConfirmationPage,wa as FilterButton,Na as FiltersMenu,si as FlightBooking,ai as FlightOrderDetails,oi as FlightsOrderHistory,li as FlightsPage,ti as FlightsSearchSection,ii as MyPassengersList,Ze as SearchForm,ni as SearchPage,Tl as SortButton,ri as SummaryPage};

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.