1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,68530,e=>{"use strict";var t=e.i(843476),r=e.i(256894),a=e.i(10345),n=e.i(584932),s=e.i(617657),i=e.i(372026),l=e.i(437902),o=e.i(271645),c=e.i(373375),u=e.i(463059);function d(e){let t=Number(e);return Number.isFinite(t)?t:0}function m(e,t={}){let r,a=e.pricing_mode||"per_unit",n=Math.max(1,Math.floor(d(t.quantity)||1)),s=e.multiply_by_nights?Math.max(1,Math.floor(d(t.nights)||1)):1;switch(a){case"per_unit":{let t=d(e.rate);if(t<=0)return null;r=t*n;break}case"per_guest":{let a=d(e.price_per_adult),n=d(e.price_per_child);if(a<=0&&n<=0)return null;let s=Math.max(0,Math.floor(d(t.adults))),i=Math.max(0,Math.floor(d(t.children)));if(s+i===0)return null;r=a*s+n*i;break}case"shuttle":{let a=d("round_trip"===(t.shuttleTrip||"one_way")?e.shuttle_config?.round_trip_price:e.shuttle_config?.one_way_price);if(a<=0)return null;r=a*n;break}default:return null}let i=r*s;return!Number.isFinite(i)||i<=0?null:Number(i.toFixed(2))}function p(e,t){if(!Number.isFinite(t)||t<=0)return null;let r=Number(t.toFixed(2)),a=e.charge_timing||"online";if("at_property"===a)return{total:r,pay_now:0,pay_later:r,charge_timing:"at_property"};if("partial"===a){let t=d(e.advance_rate);if(t>0&&t<100){let e=Number((t/100*r).toFixed(2));return{total:r,pay_now:e,pay_later:Number((r-e).toFixed(2)),charge_timing:"partial"}}}return{total:r,pay_now:r,pay_later:0,charge_timing:"online"}}e.i(745075);var h=e.i(728174),y=e.i(451338),f=e.i(431123),x=e.i(804005),_=e.i(178488),g=e.i(962567);function v({name:e,image:r,price:a,children:n,currency:s,exchangeRate:i}){let l=(0,_.useScopedI18nWebsiteSet)("checkout.payment.extras");return(0,t.jsxs)("div",{className:"w-full bg-secondary text-secondary-foreground overflow-hidden rounded-md border keen-slider__slide",children:[(0,t.jsx)("div",{className:"w-full pb-[60%] bg-black/20 relative overflow-hidden",children:(0,t.jsx)("img",{src:r,className:"object-cover h-full w-full absolute left-0 top-0",alt:e})}),(0,t.jsxs)("div",{className:"w-full px-4 py-2 flex flex-col",children:[(0,t.jsx)("h2",{className:"font-semibold h-[52px]",children:e}),(0,t.jsxs)("div",{className:"w-full flex flex-col mb-2",children:[(0,t.jsx)("p",{className:"text-xs opacity-60",children:l("common.startingAt")}
1),(0,t.jsx)("p",{children:(0,g.default)(Number(a||0)*i,String(s||"USD"))})]}),n]})]})}var b=e.i(618566),w=e.i(678784),N=e.i(397882),j=e.i(754079),S=e.i(837007);e.i(592338);var k=e.i(159570),C=e.i(690923),R=e.i(528390),P=e.i(104766),I=e.i(64413),F=e.i(114542);function T(e){return(e||[]).reduce((e,t)=>({adults:e.adults+(Number(t?.adults)||0),children:e.children+(Number(t?.children)||0)}),{adults:0,children:0})}function E({label:e,value:r,setValue:a,min:n,max:s,disabled:i}){return(0,t.jsxs)("div",{className:"w-full flex justify-between",children:[(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("p",{className:"font-semibold",children:e})}),(0,t.jsxs)("div",{className:"w-full flex items-center justify-end gap-4",children:[(0,t.jsx)(k.Button,{size:"sm",className:"h-6 w-6 p-0 rounded-full",onClick:()=>{r>n&&a(r-1)},disabled:i,children:"-"}),(0,t.jsx)("div",{className:"w-6 text-center",children:(0,t.jsx)("p",{children:r})}),(0,t.jsx)(k.Button,{size:"sm",className:"h-6 w-6 p-0 rounded-full",onClick:()=>{r<s&&a(r+1)},disabled:i,children:"+"})]})]})}var z=e.i(927946),O=e.i(432763),O=O,A=e.i(988846);function D({direction:e,date:r,flight:a,onFlightChange:n,disabled:s}){let i=(0,_.useScopedI18nWebsiteSet)("checkout.payment.extras"),[l,c]=(0,o.useState)(a?.flight_number||""),[u,d]=(0,o.useState)(!1);async function m(){let t=l.trim();if(t&&!u){d(!0);try{let a=await fetch(`/api/flights/lookup?number=${encodeURIComponent(t)}&date=${encodeURIComponent(r)}`),s=await a.json(),i=s?.success?s.flights?.[0]:void 0;if(!i)return void n({direction:e,flight_number:t.toUpperCase(),date:r,verified:!1});let l="arrival"===e?i.arrival:i.departure;n({direction:e,flight_number:i.number||t.toUpperCase(),date:r,verified:!0,...i.airline?{airline:i.airline}:{},...l?.airport_iata?{airport_iata:l.airport_iata}:{},...l?.airport_name?{airport_name:l.airport_name}:{},...l?.time_local?{scheduled_time:l.time_local}:{},...l?.terminal?{terminal:l.terminal}:{}})}catch{n({direction:e,flight_number:t.toUpperCase(),date:r,verified:!1})}finally{d(!1)}}}return(0,t.jsxs)("div",{className:"w-full flex flex-col gap-1",children:[(0,t.jsx)(P.Label,{className:"font-semibold",children:i("arrival"===e?"checkout.flights.arrivalFlight":"checkout.flights.departureFlight")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"text",className:"w-full border rounded-md px-3 py-2 text-sm bg-background",placeholder:i("checkout.flights.flightNumberPlaceholder"),value:l,onChange:e=>{c(e.target.value),a&&n(null)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),m())},disabled:s}),(0,t.jsx)(k.Button,{size:"sm",variant:"outline",className:"shrink-0 h-auto",onClick:m,disabled:s||u||!l.trim(),children:u?(0,t.jsx)(N.LoaderIcon,{className:"animate-spin",size:16}):(0,t.jsx)(A.SearchIcon,{size:16})})]}),a?.verified&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-sm border rounded-sm p-2 bg-secondary/50",children:[(0,t.jsx)(z.CheckCircle2Icon,{size:16,className:"mt-0.5 shrink-0 text-green-600"}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"font-medium",children:[a.airline,a.flight_number].filter(Boolean).join(" ")}),(0,t.jsx)("span",{className:"opacity-70",children:[a.airport_name||a.airport_iata,a.scheduled_time?i("arrival"===e?"checkout.flights.arrivesAt":"checkout.flights.departsAt",{time:a.scheduled_time}):void 0,a.terminal?i("checkout.flights.terminal",{terminal:a.terminal}):void 0].filter(Boolean).join(" · ")})]})]}),a&&!a.verified&&!u&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-xs opacity-70",children:[(0,t.jsx)(O.default,{size:14,className:"mt-0.5 shrink-0"}),(0,t.jsx)("span",{children:i("checkout.flights.notVerified")})]})]})}function M({extra:e,image:r,checkin:a,checkout:n,nights:s,locale:i,currency:l,exchangeRate:c=1}){let u=(0,_.useScopedI18nWebsiteSet)("checkout.payment.extras"),d=(0,b.useRouter)(),{currentReservation:h,handleUpdateReservation:y}=(0,f.useCheckoutPayment)(),x=h?.metadata?.extras||[],v=T(h?.occupancy),z=e.pricing_mode||"per_unit",O="shuttle"===z,A=!!e.requires_date,q=Math.floor(Number(e.max_per_reservation)||0),$=q>0?q:Math.max(1,v.adults+v.children),[L,B]=(0,o.useState)(!1),[U,W]=(0,o.useState)(!1),[V,G]=(0,o.useState)(1),[J,K]=(0,o.useState)(1),[H,X]=(0,o.useState)(0),[Y,Z]=(0,o.useState)(""),[Q,ee]=(0,o.useState)("one_way"),[et,er]=(0,o.useState)(null),[ea,en]=(0,o.useState)(null),es=!!x.find(t=>String(t.extra_id)===String(e.id)),ei=(0,o.useMemo)(()=>
1{if(!O)return;let e=[et,"round_trip"===Q?ea:null].filter(Boolean);return e.length>0?e:void 0},[O,et,ea,Q]),el=(0,o.useMemo)(()=>(function({product:e,selection:t,locale:r}){var a,n;let s,i;if(!e?.is_booking_extra)return null;let l=m(e,{quantity:t.quantity,adults:t.adults,children:t.children,nights:t.nights,shuttleTrip:t.shuttle_trip});if(null===l)return null;let o=p(e,l);if(!o)return null;let c=Math.floor(Number(e.max_per_reservation)||0),u=Math.max(1,Math.floor(Number(t.quantity)||1));if(c>0&&u>c)return null;let d=e.multiply_by_nights?Math.max(1,Math.floor(Number(t.nights)||1)):1,h=(t.flights||[]).filter(e=>(e?.direction==="arrival"||e?.direction==="departure")&&String(e?.flight_number||"").trim()&&String(e?.date||"").trim()).slice(0,2).map(e=>({direction:e.direction,flight_number:String(e.flight_number).trim().toUpperCase(),date:String(e.date).trim(),verified:!!e.verified,...e.airline?{airline:String(e.airline)}:{},...e.airport_iata?{airport_iata:String(e.airport_iata).toUpperCase()}:{},...e.airport_name?{airport_name:String(e.airport_name)}:{},...e.scheduled_time?{scheduled_time:String(e.scheduled_time)}:{},...e.terminal?{terminal:String(e.terminal)}:{}}));return{extra_id:String(e.id),name:(a=e.name,a?r&&a[r]?a[r]:a.en||a.es||"":""),image:(n=e.images,s=n?.[0]?.links,(i=s?.["350px"]?.href||s?.original?.href)?String(i):void 0),quantity:u,adults:Math.max(0,Math.floor(Number(t.adults)||0)),children:Math.max(0,Math.floor(Number(t.children)||0)),days:d,...t.date?{date:t.date}:{},..."shuttle"===e.pricing_mode?{shuttle_trip:t.shuttle_trip||"one_way",...h.length>0?{flights:h}:{}}:{},pricing_mode:e.pricing_mode||"per_unit",charge_timing:o.charge_timing,..."partial"===o.charge_timing?{advance_rate:String(e.advance_rate)}:{},currency:String(e.currency||""),total:o.total,pay_now:o.pay_now,pay_later:o.pay_later}})({product:e,selection:{extra_id:String(e.id),quantity:V,adults:J,children:H,nights:s,date:A?Y:void 0,shuttle_trip:O?Q:void 0,flights:ei},locale:i}),[e,V,J,H,s,Y,A,O,Q,ei,i]),eo=!A||!!Y&&Y>=a&&Y<=n&&function(e,t){if(!t||0===t.length)return!0;let r=new Date(`${e}T12:00:00`).getDay();return t.includes(r)}(Y,e.allowed_week_days),ec=!!el&&eo,eu=el?p(e,el.total):null;async function ed(){el&&(B(!0),await y({current_step:"refetch_totals",metadata:{...h?.metadata,extras:[...x.filter(t=>String(t.extra_id)!==String(e.id)),{...el,image:el.image||r}]}}),await (0,F.default)("current-reservation"),await (0,F.default)("totals"),d.refresh(),W(!1),B(!1))}async function em(){B(!0),await y({current_step:"refetch_totals",metadata:{...h?.metadata,extras:x.filter(t=>String(t.extra_id)!==String(e.id))}}),await (0,F.default)("current-reservation"),await (0,F.default)("totals"),d.refresh(),W(!1),B(!1)}return(0,t.jsxs)(R.Dialog,{open:U,onOpenChange:W,children:[(0,t.jsx)(R.DialogTrigger,{asChild:!0,children:(0,t.jsx)(k.Button,{size:"sm",className:(0,C.cn)("w-full mb-2 gap-2 bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground",{"opacity-60":es}),children:es?(0,t.jsxs)(t.Fragment,{children:[u("common.added")," ",(0,t.jsx)(w.CheckIcon,{size:16})]}):(0,t.jsxs)(t.Fragment,{children:[u("common.add")," ",(0,t.jsx)(S.PlusIcon,{size:16})]})})}),(0,t.jsx)(R.DialogContent,{className:"border-border shadow-none",children:(0,t.jsx)(I.ScrollArea,{className:"pb-2 max-h-[560px]",children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[r&&(0,t.jsx)("div",{className:"pb-[50%] relative overflow-hidden rounded-md",children:(0,t.jsx)("img",{alt:el?.name||"",src:r,className:"object-cover h-full w-full absolute left-0 top-0"})}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,t.jsx)("h4",{className:"font-semibold text-xl",children:e.name?.[i]||e.name?.en||e.name?.es}),(e.description?.[i]||e.description?.en)&&(0,t.jsx)("p",{className:"text-sm mb-2",children:e.description?.[i]||e.description?.en}),(0,t.jsxs)("div",{className:"w-full flex flex-col gap-3 border p-4 rounded-sm",children:["per_guest"===z?(0,t.jsxs)(t.Fragment,{children:[Number(e.price_per_adult||0)>0&&0!==v.adults&&(0,t.jsx)(E,{label:u("checkout.adults"),value:J,setValue:K,min:1,max:v.adults,disabled:es}),Number(e.price_per_child||0)>
10&&0!==v.children&&(0,t.jsx)(E,{label:u("checkout.children"),value:H,setValue:X,min:0,max:v.children,disabled:es})]}):(0,t.jsx)(E,{label:u("checkout.quantity"),value:V,setValue:G,min:1,max:$,disabled:es}),O&&(0,t.jsxs)("div",{className:"w-full flex justify-between items-center",children:[(0,t.jsx)("p",{className:"font-semibold",children:u("checkout.flights.type")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(k.Button,{size:"sm",variant:"one_way"===Q?"default":"outline",onClick:()=>ee("one_way"),disabled:es||!Number(e.shuttle_config?.one_way_price||0),children:u("checkout.flights.oneWay")}),(0,t.jsx)(k.Button,{size:"sm",variant:"round_trip"===Q?"default":"outline",onClick:()=>ee("round_trip"),disabled:es||!Number(e.shuttle_config?.round_trip_price||0),children:u("checkout.flights.roundtrip")})]})]}),O&&(0,t.jsx)(D,{direction:"arrival",date:a,flight:et,onFlightChange:er,disabled:es}),O&&"round_trip"===Q&&(0,t.jsx)(D,{direction:"departure",date:n,flight:ea,onFlightChange:en,disabled:es}),A&&(0,t.jsxs)("div",{className:"w-full flex flex-col gap-1",children:[(0,t.jsx)(P.Label,{className:"font-semibold",children:u("charge.serviceDate")}),(0,t.jsx)("input",{type:"date",className:"w-full border rounded-md px-3 py-2 text-sm bg-background",value:Y,min:a,max:n,onChange:e=>Z(e.target.value),disabled:es}),Y&&!eo&&(0,t.jsx)("p",{className:"text-xs text-red-600",children:u("charge.dateUnavailable")})]}),!!e.multiply_by_nights&&(0,t.jsx)("p",{className:"text-xs opacity-60",children:u("charge.perNightNote",{nights:s})})]}),(0,t.jsxs)("div",{className:"w-full flex justify-between my-2 items-center",children:[(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("p",{className:"font-semibold text-lg",children:u("checkout.total")})}),(0,t.jsx)("div",{className:"w-full justify-end flex",children:(0,t.jsx)("p",{className:"text-lg",children:(0,g.default)(Number((el?.total||0)*c),String(l||"USD"))})})]}),eu&&eu.pay_later>0&&(0,t.jsxs)("div",{className:"w-full flex flex-col gap-1 text-sm border rounded-sm p-3 bg-secondary/50",children:[eu.pay_now>0&&(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"opacity-70",children:u("charge.chargedNow")}),(0,t.jsx)("span",{children:(0,g.default)(Number(eu.pay_now*c),String(l||"USD"))})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"opacity-70",children:u("charge.payAtProperty")}),(0,t.jsx)("span",{children:(0,g.default)(Number(eu.pay_later*c),String(l||"USD"))})]})]}),(0,t.jsx)(k.Button,{size:"sm",className:"w-full gap-2 bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground",onClick:()=>{es?em():ed()},disabled:!es&&!ec||L,children:L?(0,t.jsx)(N.LoaderIcon,{className:"animate-spin",size:16}):es?(0,t.jsxs)(t.Fragment,{children:[u("common.removeFromCart")," ",(0,t.jsx)(j.MinusIcon,{size:16})]}):(0,t.jsxs)(t.Fragment,{children:[u("common.addToCart")," ",(0,t.jsx)(S.PlusIcon,{size:16})]})})]})]})})})]})}function q({website:e}){let{currentReservation:r}=(0,f.useCheckoutPayment)(),a=(e?.engineExtras||[]).filter(e=>e?.is_booking_extra),n=new Date,s=r?.lang||"en",i=r?.checkin||"",d=r?.checkout||"",p=Math.max(1,Number(r?.nights)||1),_=r?.currency||r?.totals?.requested?.currency||"USD",g=r?.request_currency||_,b=(0,x.resolveCurrencyConversionRate)({requestCurrency:_,currency:g,paymentsCurrencyRate:e?.providerOptions?.paymentsCurrencyRate}),w=b?g:_,N=b??1,j=(0,o.useRef)(null),[S,k]=(0,o.useState)(!1),[C,R]=(0,o.useState)(!1),P=()=>{let e=j.current;e&&(k(e.scrollLeft>0),R(e.scrollLeft<e.scrollWidth-e.clientWidth-1))},I=e=>{let t=j.current;if(t){let r=t.clientWidth/2,a="left"===e?t.scrollLeft-r:t.scrollLeft+r;t.scrollTo({left:a,behavior:"smooth"})}};(0,o.useEffect)(()=>(P(),window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)),[]);let F=a.map(e=>{var t,r;let a=m(e,{quantity:1,adults:1,children:0,nights:1})??m(e,{quantity:1,adults:0,children:1,nights:1});if(null===a||(t=new Date(i),!(!(r=Math.floor(Number(e.min_advance_days)||0))||Math.ceil((t.getTime()-n.getTime())/864e5)>=r)))return null;let l=(0,y.default)(e?.images)?.map(e=>(0,h.modifyImagesToWebP)(e,"800"));return{extra:e,id:String(e.id),name:e.name?.[s]||e.name?.en||e.name?.es,image:l?.[0],price:a}}
1).filter(Boolean);return F.length?(0,t.jsxs)("div",{className:"jsx-d1e1d09fdfc6c76b w-full relative",children:[S&&(0,t.jsx)("button",{onClick:()=>I("left"),"aria-label":"Scroll left",className:"jsx-d1e1d09fdfc6c76b absolute left-0 top-1/2 transform -translate-y-1/2 z-10 bg-white/80 rounded-full p-1 shadow-md",children:(0,t.jsx)(c.ChevronLeft,{size:24})}),(0,t.jsx)("div",{ref:j,style:{display:"flex",flexWrap:"nowrap",overflowX:"auto",scrollbarWidth:"none",msOverflowStyle:"none"},onScroll:P,className:"jsx-d1e1d09fdfc6c76b w-full grid grid-cols-2 md:grid-cols-4 gap-3 overflow-x-auto pb-2 scroll-smooth hide-scrollbar",children:F.map(e=>(0,t.jsx)("div",{className:"jsx-d1e1d09fdfc6c76b flex-shrink-0 w-full sm:w-1/2 md:w-1/4 px-1",children:(0,t.jsx)(v,{name:e.name,image:e.image,price:e.price,currency:w,exchangeRate:N,children:(0,t.jsx)(M,{extra:e.extra,image:e.image,checkin:i,checkout:d,nights:p,locale:s,currency:w,exchangeRate:N})})},e.id))}),C&&(0,t.jsx)("button",{onClick:()=>I("right"),"aria-label":"Scroll right",className:"jsx-d1e1d09fdfc6c76b absolute right-0 top-1/2 transform -translate-y-1/2 z-10 bg-white/80 rounded-full p-1 shadow-md",children:(0,t.jsx)(u.ChevronRight,{size:24})}),(0,t.jsx)(l.default,{id:"d1e1d09fdfc6c76b",children:".hide-scrollbar.jsx-d1e1d09fdfc6c76b::-webkit-scrollbar{display:none}"})]}):null}var $=e.i(596150),L=e.i(754473),B=e.i(475254);let U=(0,B.default)("hotel",[["path",{d:"M10 22v-6.57",key:"1wmca3"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M12 7h.01",key:"1ivr5q"}],["path",{d:"M14 15.43V22",key:"1q2vjd"}],["path",{d:"M15 16a5 5 0 0 0-6 0",key:"o9wqvi"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 7h.01",key:"1vti4s"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]]);var W=e.i(960606),V=e.i(582149),G=e.i(734161),J=e.i(610742),K=e.i(416681),H=e.i(534267),X=e.i(323196),Y=e.i(995926),Z=e.i(688299);function Q({children:e,className:r}){let a=(0,_.useScopedI18nWebsiteSet)("global.asyncStepper"),{toast:n}=(0,Z.useToast)(),{currentStep:s,setCurrentStep:i,errorMessage:l,handleUpdateReservation:c,setErrorMessage:u}=(0,f.useCheckoutPayment)(),[d,m]=(0,o.useState)(!1),p=s.includes("manual_review_required"),h=[{id:"payment",index:0},{id:"itinerary",index:1},{id:"reservation",index:2}];async function y(e){m(!0),u(null);let t=await c({current_step:e});t.errors?(n({title:t?.errors?.[0]?.message}),console.error("updateReservationOnPaymentError",t?.errors)):i(e),m(!1)}let x=e=>s.includes(e)?p&&"itinerary"===e?"processing":s.includes(`${e}_success`)?"success":s.includes(`${e}_error`)?"error":s.includes(`${e}_processing`)?"processing":"inactive":"inactive";return(0,t.jsx)("div",{className:(0,C.cn)("w-full flex justify-center items-center h-full",r),children:(0,t.jsxs)("div",{className:"w-full max-w-sm flex flex-col justify-center items-center p-6 gap-6",children:[(0,t.jsx)("div",{className:"w-full flex items-center justify-center mb-2",children:(0,t.jsx)("div",{className:"flex items-center",children:h.map((e,r)=>{let a=s.includes(e.id),n=x(e.id),i=(()=>{for(let e of h)if(s.includes(e.id))return e.index;return -1})(),l="success"===n||h[r+1]&&s.includes(h[r+1].id)||e.index<i;return(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:(0,C.cn)("h-10 w-10 flex items-center justify-center rounded-full transition-all duration-200",{"bg-green-600 text-white":"success"===n||!a&&l,"bg-red-600 text-white":"error"===n,"bg-primary text-primary-foreground":"processing"===n,"bg-gray-200 text-gray-400":!a&&!l}),children:"success"===n||!a&&l?(0,t.jsx)(w.CheckIcon,{size:20}):"error"===n?(0,t.jsx)(Y.XIcon,{size:20}):"processing"===n?(0,t.jsx)(N.LoaderIcon,{size:20,className:"animate-spin"}):(0,t.jsx)("span",{className:"font-semibold",children:r+1})}),r<h.length-1&&(0,t.jsx)("div",{className:(0,C.cn)("h-1 w-12 mx-1",{"bg-green-600":l,"bg-gray-200":!l})})]},e.id)})})}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold mb-1",children:(()=>
1{if(p)return a("itinerary.processing");for(let e of h)if(s.includes(e.id)){let t=x(e.id);if("payment"===e.id){if("success"===t)return a("payment.success");if("error"===t)return a("payment.error");return a("payment.processing")}if("itinerary"===e.id){if("success"===t)return a("itinerary.success");if("error"===t)return a("itinerary.error");return a("itinerary.processing")}if("reservation"===e.id){if("success"===t)return a("reservation.success");if("error"===t)return a("reservation.error");return a("reservation.processing")}}return""})()}),(0,t.jsx)("p",{className:"text-sm text-gray-500",children:a("disclaimer")})]}),p&&l&&(0,t.jsx)("div",{className:"w-full px-4",children:(0,t.jsx)("div",{className:"w-full flex items-center justify-center border border-amber-200 bg-amber-50 text-amber-900 rounded-lg py-3 px-4",children:(0,t.jsx)("p",{className:"text-sm",children:l})})}),s.includes("error")&&l&&(0,t.jsx)("div",{className:"w-full px-4",children:(0,t.jsx)("div",{className:"w-full flex items-center justify-center border border-red-200 bg-red-50 text-red-800 rounded-lg py-3 px-4",children:(0,t.jsx)("p",{className:"text-sm",children:l})})}),s.includes("payment_error")&&(0,t.jsxs)(k.Button,{size:"sm",className:"bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground gap-2",onClick:()=>y("guest_information"),disabled:d,children:[a("paymentErrorButton"),d?(0,t.jsx)(N.LoaderIcon,{size:14,className:"animate-spin"}):(0,t.jsx)(X.Undo2Icon,{size:14})]}),(0,t.jsx)("div",{className:"w-full",children:e})]})})}var ee=e.i(58718),et=e.i(696885),er=e.i(932410);let ea=(0,B.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);var en=e.i(775786);function es({retriesFromCurrentStepGlobal:e,currentStep:r,locale:a,currentReservation:n,loading:s,createItineraryAction:i}){let l=(0,_.useI18nWebsiteSet)(),{toast:c}=(0,Z.useToast)(),[u,d]=(0,o.useState)(!1),[m,p]=(0,o.useState)(!1),{handleCancelPayment:h,handleUpdateReservation:y,setCurrentStep:x,isPlainFormPayment:g}=(0,f.useCheckoutPayment)();async function v(){d(!0);
1let e=await (0,en.getCheckoutReservation)(n?.id),t=e.reservation;if(e.errors.length>0||!t){d(!1),c({title:l("global.asyncStepper.itinerary.requestRefund.error")}),console.error("errorOnRefundPaymentAfterRetryItinerary",e.errors[0]?.message||"Missing reservation");return}let r=await h({orderReference:t?.order_reference,paymentReference:t?.payment_reference,amount:t?.metadata?.payment?.amount_paid}),a=(0,ee.buildGuestRefundAttempt)({context:"itinerary_retry_refund",amountRequestedMinor:t?.metadata?.payment?.amount_paid,response:r}),s=(0,ee.withRefundAttempt)(t?.metadata,a);r.result.success?(await y({status:"refunded",current_step:"payment_refunded_requested_by_guest_after_retry",metadata:s}),c({title:l("global.asyncStepper.itinerary.requestRefund.success")}),p(!0),await new Promise(e=>setTimeout(e,2e3))):(await y({status:"refund_error",error_message:r.result.message,current_step:"payment_refund_error_after_retry",metadata:s}),c({title:l("global.asyncStepper.itinerary.requestRefund.error")}),console.error("errorOnRefundPaymentAfterRetryItinerary",r.result.message),await new Promise(e=>setTimeout(e,2e3))),window.location.reload()}async function b(){await y({current_step:"guest_information"}),x("guest_information")}let w=u||m||n?.status==="refunded";return(0,t.jsxs)(t.Fragment,{children:[e>=3?r.includes("itinerary")?(0,t.jsxs)("div",{className:"w-full flex flex-col gap-2 items-center justify-center",children:[(0,t.jsxs)("p",{className:"max-w-xl mx-auto text-sm text-center text-foreground",children:[l("global.asyncStepper.itinerary.afterRetryMessageOne")," ",(0,t.jsx)("b",{children:l("global.asyncStepper.itinerary.afterRetryMessageTwo")})]}),(0,t.jsx)("div",{className:"max-w-md mx-auto w-full mt-2 text-center",children:(0,t.jsxs)(k.Button,{size:"sm",variant:"outline",className:"bg-transparent border-amber-500 hover:border-amber-500 text-amber-500 hover:bg-transparent hover:text-amber-500 gap-2 w-fit mx-auto",onClick:()=>v(),disabled:w,children:[m||n?.status==="refunded"?l("global.asyncStepper.itinerary.requestRefund.refunded"):l("global.asyncStepper.itinerary.requestRefund.button")," ",u?(0,t.jsx)(N.LoaderIcon,{size:14,className:"animate-spin"}):(0,t.jsx)(ea,{size:14})]})})]}):(0,t.jsxs)("div",{className:"w-full flex flex-col gap-2 items-center justify-center",children:[(0,t.jsx)("p",{className:"max-w-xl mx-auto text-sm text-center text-foreground",children:l("global.asyncStepper.reservation.afterRetryMessage")}),(0,t.jsx)(et.default,{href:`/${a}/guest/reservation?email=${encodeURIComponent(n?.guest?.email||"")}&itineraryId=${n?.itinerary_id}`,children:(0,t.jsxs)(k.Button,{size:"sm",className:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground gap-2 w-fit mx-auto",disabled:w,children:[l("global.asyncStepper.goToReservation"),(0,t.jsx)(er.ArrowUpRightIcon,{size:14})]})})]}):r.includes("itinerary_error")?(0,t.jsxs)("div",{className:"w-full flex flex-col gap-2 items-center justify-center",children:[!m&&!g&&(0,t.jsxs)(k.Button,{size:"sm",className:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground gap-2",onClick:()=>i(),disabled:s||w,children:[l("global.asyncStepper.itineraryErrorButton")," (",e," / 3)",s?(0,t.jsx)(N.LoaderIcon,{size:14,className:"animate-spin"}):(0,t.jsx)(X.Undo2Icon,{size:14})]}),g&&(0,t.jsx)(k.Button,{size:"sm",className:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground gap-2",disabled:s||w,onClick:()=>b(),children:l("global.asyncStepper.itinerary.backAndTryAgain")}),!g&&e>0&&!m&&n?.status!=="refunded"&&(0,t.jsxs)("div",{className:"mt-3 text-center",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:l("global.asyncStepper.itinerary.requestRefund.requestRefundInstead")}),(0,t.jsxs)(k.Button,{size:"sm",variant:"outline",className:"bg-transparent border-amber-500 hover:border-amber-500 text-amber-500 hover:bg-transparent hover:text-amber-500 gap-2 w-fit mx-auto",onClick:()=>v(),disabled:w,children:[l("global.asyncStepper.itinerary.requestRefund.button")," ",u?(0,t.jsx)(N.LoaderIcon,{size:14,className:"animate-spin"}):(0,t.jsx)(ea,{size:14})]})]}),(m||n?.status==="refunded")&&(0,t.jsxs)("div",{className:"mt-2 text-center",children:[(0,t.jsx)("p",{className:"text-sm text-green-600 font-medium",children:l("global.asyncStepper.itinerary.requestRefund.refunded")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:l("global.asyncStepper.itinerary.requestRefund.backToHome")}),u&&(0,t.jsx)("div",{className:"mt-2 flex justify-center",children:(0,t.jsx)(N.LoaderIcon,{size:16,className:"animate-spin text-amber-500"})})]})]}):r.includes("reservation_error")?!g&&(0,t.jsxs)(k.Button,{size:"sm",className:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground gap-2",onClick:()=>i(),disabled:s||w,children:[l("global.asyncStepper.itineraryErrorButton")," (",e," / 3)",s?(0,t.jsx)(N.LoaderIcon,{size:14,className:"animate-spin"}):(0,t.jsx)(X.Undo2Icon,{size:14})]}):null,"reservation_success"===r&&(0,t.jsxs)("div",{className:"w-full flex flex-col items-center justify-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm font-normal text-foreground text-center mx-auto px-12 py-3",children:l("global.asyncStepper.redirectToReservation")}),(0,t.jsx)(N.LoaderIcon,{size:16,className:"animate-spin"})]})]})}var ei=e.i(84516),el=e.i(493510);let eo=e=>Number(Number(e).toFixed(2));function ec(e){return(e||[]).filter(e=>Number.isFinite(Number(e?.total))&&Number(e?.total)>0).reduce((e,t)=>
1({total:eo(e.total+Number(t.total||0)),pay_now:eo(e.pay_now+Number(t.pay_now||0)),pay_later:eo(e.pay_later+Number(t.pay_later||0))}),{total:0,pay_now:0,pay_later:0})}var eu=e.i(250603),ed=e.i(498595),em=e.i(770703);let ep=(0,em.default)(()=>e.A(931402),{loadableGenerated:{modules:[686957]},ssr:!1}),eh=(0,em.default)(()=>e.A(486378),{loadableGenerated:{modules:[701216]},ssr:!1}),ey=(0,em.default)(()=>e.A(302654),{loadableGenerated:{modules:[265363]},ssr:!1});function ef({allowedMethods:e,paymentMethod:r,setPaymentMethod:a,loadingPayment:n,website:s,setPaymentToken:i,currentReservation:l,paymentIntent:o}){let c=(0,_.useScopedI18nWebsiteSet)("checkout.payment"),u=[{id:"STRIPE",image:"/payment-methods/stripe.svg",logos:["/payment-methods/sub/visa.svg","/payment-methods/sub/mastercard.svg","/payment-methods/sub/apple-pay.svg","/payment-methods/sub/google-pay.svg","/payment-methods/sub/link.svg"],description:c("methods.stripe.description"),name:"Stripe",key:s.providerOptions?.providers?.find(e=>"STRIPE"===e.provider)?.account},{id:"FINTOC",image:"/payment-methods/fintoc.svg",logos:["/payment-methods/sub/spei.svg","/payment-methods/sub/codi.svg"],description:c("methods.fintoc.description"),name:"Fintoc",key:s.providerOptions?.providers?.find(e=>"FINTOC"===e.provider)?.account},{id:"CLIP",image:"/payment-methods/clip.svg",logos:["/payment-methods/sub/visa.svg","/payment-methods/sub/mastercard.svg","/payment-methods/sub/amex.png"],description:c("methods.clip.description"),name:"Clip",key:s.providerOptions?.providers?.find(e=>"CLIP"===e.provider)?.account}];return(0,t.jsxs)("div",{className:"w-full flex flex-col bg-neutral-100 text-neutral-950 p-2 rounded-md border border-neutral-200",children:[(0,t.jsx)(eu.default,{}),u.filter(t=>e.includes(t.id)).map(e=>(0,t.jsxs)("div",{className:(0,C.cn)("bg-white rounded-md border mb-3 p-6 ring-1 ring-transparent hover:ring-neutral-300",{"ring-neutral-300 hover:ring-neutral-300":e.id===r}),children:[(0,t.jsxs)("div",{className:"flex items-center gap-6",onClick:()=>a(e.id),role:"button",children:[(0,t.jsx)("div",{className:(0,C.cn)("w-[20px] flex justify-center h-[20px] rounded-full ring-1 ring-neutral-200 bg-white shrink-0 items-center",{"bg-neutral-950 text-white":e.id===r}),children:(0,t.jsx)("span",{className:(0,C.cn)("w-[12px] h-[12px] rounded-full bg-white flex")})}),(0,t.jsx)("div",{className:"w-full flex flex-col gap-2",children:"STRIPE"===e.id?(0,t.jsx)("div",{className:"w-full flex items-center",children:(0,t.jsx)("img",{src:e.image,alt:e.name,className:"h-7"})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:e.description}),(0,t.jsxs)("div",{className:"w-full flex gap-3 md:gap-6 items-center whitespace-nowrap overflow-x-auto",children:[(0,t.jsx)("img",{src:e.image,alt:e.name,className:"h-7"}),e.logos?.map(e=>(0,t.jsx)("img",{src:e,alt:e,className:"h-7"},e))]})]})})]}),(0,t.jsx)("div",{className:(0,C.cn)("w-full",{"mt-3":e.id===r}),children:n&&e.id===r&&"STRIPE"!==e.id?(0,t.jsx)(ed.Skeleton,{className:(0,C.cn)("w-full h-96 opacity-20",{"h-20":"FINTOC"===r})}):(0,t.jsx)(ex,{setPaymentMethod:a,paymentMethod:e.id,active:r,publicKey:e.key,setPaymentToken:i,website:s,currentReservation:l,paymentIntent:o})})]},e.id))]})}let ex=({setPaymentMethod:e,paymentMethod:r,active:a,publicKey:n,setPaymentToken:s,website:i,currentReservation:l,paymentIntent:o})=>"STRIPE"===r?"STRIPE"===a?(0,t.jsx)(ey,{website:i,currentReservation:l,paymentIntent:o}):null:"FINTOC"===r?"FINTOC"===a?(0,t.jsx)(eh,{setPaymentMethod:e,publicKey:n||"",currentReservation:l,paymentIntent:o}):null:"CLIP"===r&&"CLIP"===a?(0,t.jsx)(ep,{paymentMethod:r,active:a,publicKey:n,setPaymentToken:s}):null,e_=(0,B.default)("asterisk",[["path",{d:"M12 6v12",key:"1vza4d"}],["path",{d:"M17.196 9 6.804 15",key:"1ah31z"}],["path",{d:"m6.804 9 10.392 6",key:"1b6pxd"}]]);var eg=e.i(627179);function ev(e){let t=e.replace(/\s+/g,"").replace(/[^0-9]/gi,"").substr(0,16),r=[];for(let e=0;e<t.length;e+=4)r.push(t.substr(e,4));return r.length>1?r.join(" "):e}function eb(e){return e.replace(/[^0-9]/g,"").replace(/^([2-9])$/g,"0$1").replace(/^(1{1})([3-9]{1})$/g,"0$1/$2").replace(/^0{1,}/g,"0").replace(/^([0-1]{1}[0-9]{1})([0-9]{1,2}).*/g,"$1/$2")}
1function ew({onChange:e}){let r=(0,_.useScopedI18nWebsiteSet)("checkout.payment"),{currentStep:a,setCurrentStep:n,handleUpdateReservation:s,setIsPlainFormPayment:i,isUpdatingPayment:l,currentReservation:c}=(0,f.useCheckoutPayment)(),u="refetch_totals"===a||c?.current_step==="refetch_totals",d=l||u,[m,p]=(0,o.useState)(!1),[h,y]=(0,o.useState)({number:"",expiry:"",cvc:""}),x=(0,o.useRef)(e);x.current=e,(0,o.useEffect)(()=>{x.current?.({cvc:h.cvc,month:h.expiry?.slice(0,2),number:h.number?.replaceAll(/\s/g,""),year:h.expiry?.slice(3,5)})},[h]);let g=async e=>{e.preventDefault(),"plain_form_payment_success"===a||d||(p(!0),await s({current_step:"plain_form_payment_success",error_message:null,payment_provider:"PLAIN_FORM"}),i(!0),n("plain_form_payment_success"),p(!1))};function v(e){let t=e.code;"Backspace"!==t&&"Delete"!==t&&"Tab"!==t&&(/^[0-9]$/.test(e.key)||e.preventDefault())}return(0,t.jsxs)("form",{onSubmit:g,className:"w-full",children:[(0,t.jsxs)("div",{className:"w-full flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"w-full flex gap-6 items-center",children:[(0,t.jsx)(L.CreditCardIcon,{size:18,className:"text-neutral-600",strokeWidth:2.4}),(0,t.jsx)(P.Label,{className:"font-semibold",children:r("methods.plainForm.title")})]}),(0,t.jsxs)("div",{className:"w-full grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,t.jsxs)("div",{className:"w-full flex flex-col gap-1 col-span-2",children:[(0,t.jsx)(P.Label,{htmlFor:"card",className:"text-neutral-600 text-sm",children:r("methods.plainForm.number")}),(0,t.jsxs)("div",{className:"w-full relative flex items-center",children:[(0,t.jsx)(eg.Input,{id:"card",type:"text",placeholder:"1234 1234 1234 1234",required:!0,className:"w-full bg-neutral-100 rounded-xl h-auto py-3 px-4 placeholder:text-neutral-400 focus-visible:ring-neutral-200 text-md border-none",value:ev(h.number),onChange:e=>{let t=e.target.value;y(e=>({...e,number:ev(t)}))},onKeyDown:e=>{v(e)}}),(0,t.jsx)(L.CreditCardIcon,{size:16,className:"absolute right-3 text-neutral-300"})]})]}),(0,t.jsxs)("div",{className:"w-full flex flex-col gap-1",children:[(0,t.jsx)(P.Label,{htmlFor:"expiry",className:"text-neutral-600 text-sm",children:r("methods.plainForm.expiry")}),(0,t.jsx)(eg.Input,{id:"expiry",type:"text",placeholder:"MM / AA",required:!0,className:"w-full bg-neutral-100 rounded-xl h-auto py-3 px-4 placeholder:text-neutral-400 focus-visible:ring-neutral-200 text-md border-none",value:eb(h.expiry),onChange:e=>{let t=e.target.value;y(e=>({...e,expiry:eb(t)}))},onKeyDown:e=>{v(e)}})]}),(0,t.jsxs)("div",{className:"w-full flex flex-col gap-1",children:[(0,t.jsx)(P.Label,{htmlFor:"cvc",className:"text-neutral-600 text-sm",children:r("methods.plainForm.cvc")}),(0,t.jsxs)("div",{className:"w-full relative flex items-center",children:[(0,t.jsx)(eg.Input,{id:"cvc",type:"text",placeholder:"CVC",required:!0,className:"w-full bg-neutral-100 rounded-xl h-auto py-3 px-4 placeholder:text-neutral-400 focus-visible:ring-neutral-200 text-md border-none",minLength:3,maxLength:4,onChange:e=>{let t=e.target.value;t?.replace(/[^\d]/g,"")&&y(t=>({...t,cvc:e.target.value.replace(/\D/g,"")}))},onKeyDown:e=>{v(e)}}),(0,t.jsx)(e_,{size:16,className:"absolute right-3 text-neutral-300"})]})]})]})]}),(0,t.jsx)(k.Button,{id:"eventButtonBookRoomPlainForm",type:"submit",disabled:m||d,className:"w-full mt-4 bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground text-md font-semibold",size:"lg",children:m||d?(0,t.jsx)(N.LoaderIcon,{size:16,className:"animate-spin"}):r("methods.plainForm.submit")})]})}function eN({onChange:e,isPayOnline:r}){let a=(0,_.useScopedI18nWebsiteSet)("checkout.payment.methods.plainForm");return(0,t.jsxs)("div",{className:"w-full bg-neutral-100 text-neutral-950 p-2 rounded-md border border-neutral-200",children:[!r&&(0,t.jsx)("div",{className:"border border-amber-800/10 bg-yellow-500/10 text-amber-600 text-sm py-1 px-3 text-center rounded-md mb-4",children:(0,t.jsx)("p",{className:"text-center mx-auto max-w-lg",children:a("disclaimer")})}),(0,t.jsx)(eu.default,{}),(0,t.jsx)("div",{className:"bg-white rounded-lg p-4",children:(0,t.jsx)(ew,{onChange:e})})]})}var ej=e.i(247167),eS=e.i(860947),ek=e.i(429075);async function eC(e){let t=await e.text();if(!t||0===t.trim().length)return{result:null,parseError:null,isEmptyBody:!0};try{return{result:JSON.parse(t),parseError:null,isEmptyBody:!1}}catch(e){return{result:null,parseError:e instanceof Error?e.message:"Invalid JSON response",isEmptyBody:!1}}}
1function eR(e,t){return e.ok?t||"Engine route returned invalid JSON response":`Engine route failed (${e.status})`}function eP({website:e}){var r;let a,n,s,i=(0,_.useI18nWebsiteSet)(),l=(0,b.useRouter)(),{currentReservation:c,currentStep:u,setCurrentStep:d,handleUpdateReservation:m,setErrorMessage:p,setIsUpdatingPayment:h}=(0,f.useCheckoutPayment)(),y=c||e?.currentReservation,v=e?.providerOptions,w=(a=v?.pay_online??!0,n=v?.pay_at_hotel??!1,(s=(Array.isArray(y?.occupancy)?y.occupancy:[]).map(e=>e?.room).filter(Boolean)).length?s.reduce((e,t)=>({payOnline:e.payOnline&&(t.pay_online??a),payAtHotel:e.payAtHotel&&(t.pay_at_hotel??n)}),{payOnline:!0,payAtHotel:!0}):{payOnline:a,payAtHotel:n}),N=w.payOnline,j=w.payAtHotel,S=N&&j,k=y?.lang||"en",C=y?.currency||"USD",R=y?.request_currency||"USD",P=y?.checkin||"",I=y?.checkout||"",T=Number(e?.providerOptions?.accountFee),E=Number.isFinite(T)&&T>=0?T:5,z=(0,o.useCallback)(e=>{let t=Number(y?.fee||0),r=Number(y?.subtotal||0);if(!(0,ek.isFeeConfigEnabled)()||r<=0)return{pct:E,amount:t};let a=(0,ek.resolveAccountFee)({schedule:v?.feeSchedule,bookingType:e>0?"hotel_collect":"pay_now",resolvedFee:v?.resolvedFee,feeSource:v?.feeSource,accountFee:E}),n=a/100*r;return{pct:a,amount:Number((n+.16*n).toFixed(2))}},[E,y?.fee,y?.subtotal,v?.feeSchedule,v?.resolvedFee,v?.feeSource]),O=y?.metadata?.attribution?.referrer||y?.metadata?.attribution?.landing_url||document.referrer,A=(0,ei.useTracking)(),D=(0,ei.useIntercom)(),M=e.default_payment_method,[q,B]=(0,o.useState)(M||"STRIPE"),[X,Y]=(0,o.useState)(null),[Z,ee]=(0,o.useState)(Number(y?.total)),[et,er]=(0,o.useState)(y?.type==="hotel_collect"&&j||j&&!N?"payAtProperty":"payOnline"),[ea,en]=(0,o.useState)(),[eu,ed]=(0,o.useState)(!1),[em,ep]=(0,o.useState)(!1);(0,o.useEffect)(()=>(h(eu),()=>{h(!1)}),[eu,h]);let eh=(0,o.useRef)(!1),ey=(0,o.useRef)(null),ex=(0,o.useRef)(null),e_=(0,o.useRef)(""),eg=(0,o.useRef)(""),ev=(0,o.useRef)(""),eb=(0,o.useRef)(et),ew=(0,o.useRef)(0),eI=(0,o.useRef)(null),eF=(0,o.useRef)(J.default.generate()).current,[eT,eE]=(0,o.useState)(y?.metadata?.payment||null),ez=(r=String(e?.property?.id||y?.property_id||""),"true"===String(ej.default.env.ENABLE_ENGINE_BOOKING_V2||"FALSE").trim().toLowerCase()&&function(e){if(!e)return!1;let t=new Set(String(ej.default.env.ENGINE_ROLLOUT_PROPERTY_IDS||"FALSE").split(",").map(e=>e.trim()).filter(Boolean));return 0!==t.size&&(!!t.has("*")||t.has(e))}(r));(0,o.useEffect)(()=>{eb.current=et},[et]);let eO=(0,o.useCallback)((e,t={})=>(0,el.buildBookingFunnelEventData)({provider:"engine",bookingStep:e,arrival:P,departure:I,currency:C,originalCurrency:R,nights:y?.nights,rooms:y?.occupancy?.length,lang:k,searchIntentId:y?.metadata?.search_intent_id,payment_provider:q,payment_type:"payOnline"===et?"guru_collect":"hotel_collect",pay_now:y?.pay_now||y?.total,pay_later:y?.pay_later,total:y?.total,...t}),[P,I,R,y?.metadata?.search_intent_id,y?.nights,y?.occupancy?.length,y?.pay_later,y?.pay_now,y?.total,et,k,q,C]),[eA,eD]=(0,o.useState)(u),eM=(0,o.useCallback)(e=>{e!==eA&&(eD(e),d(e))},[eA,d]),eq=e?.providerOptions?.paymentsCurrencyRate,e$=(0,x.resolveCurrencyConversionRate)({requestCurrency:C,currency:R,paymentsCurrencyRate:eq}),eL=C===R||null!==e$,eB=e$??1,eU=eL?R:C,eW=(0,o.useMemo)(()=>y?.metadata?.extras||[],[y?.metadata?.extras]),eV=(0,o.useMemo)(()=>ec(eW),[eW]);(0,o.useEffect)(()=>{"payOnline"===et&&!N&&j?er("payAtProperty"):"payAtProperty"===et&&!j&&N&&er("payOnline")},[N,j,et]),(0,o.useEffect)(()=>{ee(Number((("payOnline"===et?Number(y?.total):j?(0,eS.getEngineReservationDepositAmount)({reservation:y,providerOptions:v}):Number(y?.total))+eV.pay_now).toFixed(2)))},[et,eV.pay_now,y,j,v]);let eG=Number(u?.match(/\d+/)||0),eJ="CLIP"===q&&X,eK=(0,o.useCallback)(t=>{let r=String(t?.payment_reference||""),a=String(t?.order_reference||"");if(!r&&!a)return;let n=`${q}:${r}:${a}`;n!==e_.current&&(e_.current=n,A({eventName:"Payment setup",trackingContext:{website:e,reservation:y},eventData:{provider:"engine",booking_step:"payment_setup",payment_provider:q,payment_reference:r||void 0,order_reference:a||void 0,payment_status:t?.status}}))},[y,q,A,e]),eH=(0,o.useCallback)((e=0)=>({order_reference:y?.order_reference||eF,payment_reference:y?.payment_reference||"",monthly_installments:0,payment_method:String("STRIPE"===q?"CARD":q||"CARD"),status:"DETAILS_ONLY",amount_paid:Math.max(0,Math.round(100*e)),createdAt:new Date().toISOString(),currency:y?.currency||"USD",metadata:JSON.stringify({amount:e,details_only:!0,pay_at_business:!0}),client_info:{client_reference:`Client-${eF}`},account:null,account_currency:null,gurufee:Math.max(0,Math.round(100*z(1).amount))}),[eF,y?.currency,y?.order_reference,y?.payment_reference,q,z]),eX=(0,o.useCallback)(async(e,t,r)=>{try{let a=$.default.find(e=>e.name.toUpperCase()===y?.guest?.country.toUpperCase())?.iso2;return await (0,G.default)(`itineraries/book?token=${y.itinerary_id||""}`,{},{payment:{status:0===r?"details_only":"paid",amount:Number(r).toFixed(2),currency:y.currency,method:"credit_card",payment_reference:t?.payment_reference,order_reference:t?.order_reference,type:"payOnline"===e?"guru_collect":"hotel_collect"},guest:{first_name:y?.guest?.first_name,last_name:y?.guest?.last_name,email:y?.guest?.email,phone:y?.guest?.phone,phone_code:y?.guest?.phoneCode,address:y?.guest?.billing_address,country:a,state:y?.guest?.state,city:y?.guest?.city,zip_code:y?.guest?.zip_code}})}catch(e){return console.error("Error creating itinerary with Engine API:",e),{success:!1,data:{},error:e.message||"Unknown error occurred"}}},[y]),eY=(0,o.useCallback)(async(t,r,a)=>{if(!u.includes("payment_success")&&!u.includes("itinerary_processing")||em||eh.current)return;if(!r?.order_reference)return void console.error("No valid payment intent available");let n=[String(y?.id||""),String(r?.order_reference||""),String(r?.payment_reference||""),String(t||"")].join(":");if(ex.current===n||ey.current===n&&eh.current)return;ey.current=n,eh.current=!0,ep(!0);let s=Number(u?.match(/\d+/)||0)+1;if("itinerary_success"!==u)if(u.includes("reservation_error")){let e=await m({status:"booked",current_step:"reservation_success",error_message:null});e.errors?(await m({current_step:`reservation_error_${Number(s)}`,error_message:e?.errors?.[0]?.message}),eM(`reservation_error_${Number(s)}`),console.error("updateReservationOnReservationError",e?.errors),p(e?.errors?.[0]?.message),ep(!1)):eM("reservation_success"),ep(!1),eh.current=!1;return}else{let i=`${r.payment_reference||""}:${r.order_reference||""}`;i&&eg.current!==i&&(eg.current=i,A({eventName:"Payment success",trackingContext:{website:e,reservation:y},eventData:eO("payment_success",{payment_reference:r.payment_reference,order_reference:r.order_reference,payment_status:r.status})}));let o=`${y?.id||""}:${r.order_reference||""}`;o&&ev.current!==o&&(ev.current=o,A({eventName:"Itinerary processing",trackingContext:{website:e,reservation:y},eventData:eO("itinerary_processing",{payment_reference:r.payment_reference,order_reference:r.order_reference,payment_status:r.status})})),eM("itinerary_processing");try{let i,o;if(ez)o={engineRouteV2:!0,reservationId:y?.id,payment_reference:r?.payment_reference,order_reference:r?.order_reference,referrer:O};else{let n=await eX(t,r,Z);o={currentReservation:y,website:e,paymentIntent:r,plainFormCardData:a,referrer:O,itineraryResponse:n}}let c=async()=>{let e=await fetch("/api/bookings/create-itinerary/engine",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}
1),t=await eC(e);return{response:e,parsed:t}},u=await c();if(u.parsed.result)i=u.parsed.result;else if(u.parsed.isEmptyBody&&u.response.ok){console.warn("Engine create-itinerary returned empty body, retrying once",{reservationId:y?.id});let e=await c();i=e.parsed.result?e.parsed.result:e.parsed.isEmptyBody&&e.response.ok?{success:!0,processing:!0}:{success:!1,error:eR(e.response,e.parsed.parseError)}}else i={success:!1,error:eR(u.response,u.parsed.parseError)};if(i?.success&&i?.processing)return void eM("itinerary_processing");if(i?.success&&i?.itineraryId){ex.current=n;let t=y?.occupancy?.map(e=>({room_id:e?.room?.room_id??void 0,rate_plan_id:e?.room?.rate_plan_id??void 0,room_name:e?.room?.name??void 0})).filter(e=>e.room_name||e.room_id),a=t?.map(e=>e.room_name).filter(Boolean).join(", ")||void 0;A({eventName:"Complete booking",trackingContext:{website:e,reservation:y},eventData:{provider:"engine",booking_step:"booking_completed",hotel:e.name,arrival:P,departure:I,currency:y?.currency,original_currency:y?.request_currency,itinerary_id:i.itineraryId,nights:y?.nights,rooms:y?.occupancy?.length,room_name:a,selected_room_details:t,lang:y?.lang,pay_now:Number(y?.pay_now||y?.total||0).toFixed(2)}}),D.trackEvent("itinerary",{property:e.name,checkin:P,checkout:I,currency:y?.currency,lang:y?.lang||"en",orderReference:r?.order_reference,paymentReference:r?.payment_reference,user:{first_name:y?.guest?.first_name,last_name:y?.guest?.last_name,email:y?.guest?.email,phone:`+${y?.guest?.phoneCode}${y?.guest?.phone}`,reservation_id:i.itineraryId}}),eM("reservation_success");let s=`/${k}/guest/reservation?itineraryId=${encodeURIComponent(i.itineraryId)}`;l.replace(s)}else A({eventName:"Booking error",trackingContext:{website:e,reservation:y},eventData:{provider:"engine",booking_step:"booking_error",hotel:e.name,arrival:P,departure:I,currency:y?.currency,original_currency:y?.request_currency,error:i?.error}}),await m({current_step:`itinerary_error_${Number(s)}`,error_message:i?.error||"Error creating itinerary"}),eM(`itinerary_error_${Number(s)}`),p(i?.error||"Error creating itinerary"),ep(!1)}catch(e){console.error("Error in itinerary creation process:",e),await m({current_step:`itinerary_error_${Number(s)}`,error_message:e.message||"Error creating itinerary"}),eM(`itinerary_error_${Number(s)}`),p(e.message||"Error creating itinerary"),ep(!1)}finally{ex.current!==n&&(ey.current=null),ep(!1),eh.current=!1}}},[u,eX,k,y,e,m,p,eM,em,Z,l,A,D,P,I,O,ez,eO]);(0,o.useEffect)(()=>{if(u.includes("payment_success")&&!em&&eT){let e=setTimeout(()=>{eY(et,eT,ea)},100);return()=>clearTimeout(e)}if(u.includes("payment_success")&&u.includes("_processing")&&!em&&eT){let e=setTimeout(()=>{eY(et,eT,ea)},5e3);return()=>clearTimeout(e)}},[u,em,eT]),(0,o.useEffect)(()=>{let t=!1,r=Number(Number("payOnline"===et?Number(y?.total):j?(0,eS.getEngineReservationDepositAmount)({reservation:y,providerOptions:v}):Number(y?.total)).toFixed(2)),a="payOnline"===et?0:Number((Number(y?.total||0)-r).toFixed(2)),n=function({totals:e,roomPayNow:t,roomPayLater:r,extras:a,requestCurrency:n,currency:s,currentCurrencyConversionRate:i,canConvertCurrency:l}){let o=e?.requested,c=e?.converted,u=ec(a),d=u.total>0,m=eo(t),p=eo(r),h=i||1;return{requested:{...o,currency:n,extras_subtotal:d?u.total:0,extras_taxes:0,extras_total:d?u.total:0,subtotal_with_extras:d?eo(Number(o?.subtotal||0)+u.total):0,taxes_with_extras:d?eo(Number(o?.taxes_inclusive||0)):0,total_with_extras:d?eo(Number(o?.total||0)+u.total):0,policyPayment:{...o?.policyPayment,pay_now:m,pay_later:p,pay_now_with_extras:eo(m+u.pay_now),pay_later_with_extras:eo(p+u.pay_later)}},converted:n!==s&&l?{...c,currency:s,extras_subtotal:d?eo(u.total*h):0,extras_taxes:0,extras_total:d?eo(u.total*h):0,subtotal_with_extras:d?eo(Number(c?.subtotal||0)+eo(u.total*h)):0,taxes_with_extras:d?eo(Number(c?.taxes_inclusive||0)):0,total_with_extras:d?eo(Number(c?.total||0)+eo(u.total*h)):0,policyPayment:{...c?.policyPayment,pay_now:eo(m*h),pay_later:eo(p*h),pay_now_with_extras:eo(eo(m*h)+eo(u.pay_now*h)),pay_later_with_extras:eo(eo(p*h)+eo(u.pay_later*h))}}:null}}({totals:y?.totals,roomPayNow:r,roomPayLater:a,extras:eW,requestCurrency:C,currency:R,currentCurrencyConversionRate:eB,canConvertCurrency:eL}),s=Number(n.requested.policyPayment?.pay_now_with_extras??r),i={pay_now:r.toFixed(2),pay_later:a.toFixed(2),subtotal_extras:String(n.requested.extras_
1subtotal??0),taxes_extras:String(n.requested.extras_taxes??0),total_extras:String(n.requested.extras_total??0),pay_now_with_extras:String(n.requested.policyPayment?.pay_now_with_extras??r),pay_later_with_extras:String(n.requested.policyPayment?.pay_later_with_extras??a),total_with_extras:String(n.requested.total_with_extras??0),totals:{requested:n.requested,converted:n.converted}},l=Number(i.pay_later||0),o=Number(n.requested.policyPayment?.pay_later_with_extras??l)>0,c="CLIP"===q&&!!X?.id;"CLIP"===q&&!c||c&&eI.current===X?.id||(y?.type!==({payOnline:"guru_collect",payAtProperty:"hotel_collect"})[et]?(async()=>{if(t||eu)return;t=!0,ed(!0);let r=++ew.current,a=s>0?await (0,V.fetchPaymentsAPI)(W.CREATE_PAYMENTS_PAYMENT_MUTATION,{input:{orderReference:eF,currency:y?.currency,amount:Math.round(100*s),monthlyInstallments:!1,paymentMethod:"STRIPE"===q?"CARD":q,paymentProvider:q,gurufee:Math.round(100*z(l).amount),futureUsage:!0,client:{client_reference:`Client-${eF}`,name:`${y?.guest?.first_name} ${y?.guest?.last_name}`,email:y?.guest?.email,phone:`+${y?.guest?.phoneCode}${y?.guest?.phone}`},business:{business_reference:String(e?.property?.id),name:e.name},origin:"HOTELS",preventionData:X?.preventionData,token:X?.id,payAtBusiness:o}}):{data:{createPayment:{payment:eH(s),result:{message:null,success:!0}}}};if(eb.current!==et||ew.current!==r){ew.current===r&&ed(!1),t=!1;return}if(a?.data?.createPayment?.result?.error){A({eventName:"Payment error",trackingContext:{website:e,reservation:y},eventData:{error:a?.data?.createPayment?.result?.message||"Unknown payment error",payment_provider:q}}),p(a?.data?.createPayment?.result?.message),eM("payment_error"),ed(!1),t=!1;return}eE(a?.data?.createPayment?.payment),eK(a?.data?.createPayment?.payment),await m({payment_reference:a?.data?.createPayment?.payment?.payment_reference,order_reference:a?.data?.createPayment?.payment?.order_reference,payment_provider:q,type:"payOnline"===et?"guru_collect":"hotel_collect",metadata:{...y?.metadata,paymentType:"payAtProperty"===et?"pay_at_property":"pay_online",payment:{...y?.metadata?.payment,...a?.data?.createPayment?.payment}},...i}),await (0,F.default)("current-reservation"),await (0,F.default)("totals"),ed(!1),t=!1})():y?.payment_provider===q&&y?.current_step!=="refetch_totals"&&y?.payment_reference===eT?.payment_reference&&eT?.payment_reference&&"payment_error"!==u||eu&&!c||(c&&X?.id&&(eI.current=X.id),ed(!0),(async()=>{let t=++ew.current;try{let r=await fetch("/api/bookings/update-payment",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentReservation:y,website:e,paymentMethod:q,paymentToken:X,extrasFromContext:eW,totalsExtras:i.totals,accountFee:z(Number(i?.pay_later||0)).pct,propertyAccountFee:z(Number(i?.pay_later||0)).amount,affiliateReferenceId:eF})}),a=await r.json();if(eb.current!==et||ew.current!==t)return;a.success?(eE(a.payment),eK(a.payment),"CLIP"===q&&a.payment?.status==="PAID"&&eM("clip_payment_success")):(A({eventName:"Payment error",trackingContext:{website:e,reservation:y},eventData:{error:a.error||"Unknown payment update error",payment_provider:q}}),p(a.error),eM("payment_error"))}catch(r){if(eb.current!==et||ew.current!==t)return;console.error("Payment update error:",r),A({eventName:"Payment error",trackingContext:{website:e,reservation:y},eventData:{error:r.message||"An unexpected error occurred",payment_provider:q}}),p(r.message||"An unexpected error occurred"),eM("payment_error")}finally{ew.current===t&&ed(!1)}})()))},[eH,y,et,eJ,eT,q,X,A,eK,e]);let eZ="refetch_totals"!==u&&"availability"!==u&&"guest_information"!==u&&"payment_retry"!==u&&!u.includes("initializing"),eQ=(0,o.useMemo)(()=>{let t=["STRIPE"];return e?.providerOptions?.currencies?.includes("MXN")&&"MXN"===R&&e?.providerOptions?.providers?.some(e=>"CLIP"===e.provider&&e.account&&e?.status==="true")&&t.push("CLIP"),M&&"STRIPE"!==M&&"FINTOC"!==M&&!t.includes(M)&&t.push(M),t},[e?.providerOptions?.providers,e?.providerOptions?.currencies,R,M]);if(y?.status==="cancelled"||y?.status==="refunded"||!N&&!j)return null;let e0=eu||em||u.includes("_processing");return(0,t.jsxs)("div",{className:"rounded-md overflow-hidden relative min-h-[400px]",children:[(0,t.jsxs)(K.Drawer,{open:eZ,children:[(0,t.jsx)(K.DrawerTrigger,{asChild:!0}),(0,t.jsx)(K.DrawerContent,{className:"w-full",children:(0,t.jsx)(Q,{children:(0,t.jsx)(es,{retriesFromCurrentStepGlobal:eG,currentStep:u,createItineraryAction:()=>{!em&&u.includes("payment_success")&&eY(et,eT,ea)},loading:em,locale:k,currentReservation:y})})})]}),(0,t.jsxs)(H.Tabs,{defaultValue:S||N?"payOnline":"payAtProperty",className:"w-full",value:et,onValueChange:e=>{e0||er(e)},children:[S&&(0,t.jsxs)(H.TabsList,{className:"w-full bg-neutral-100 border border-neutral-200 h-auto mb-2 p-2",children:[j&&(0,t.jsxs)(H.TabsTrigger,{value:"payAtProperty",disabled:e0,className:"w-full flex-col text-neutral-500 shadow-none h-auto gap-2 items-center py-4 data-[state=active]:text-neutral-950 data-[state=active]:shadow-none border border-transparent data-[state=active]:border-neutral-200",children:[(0,t.jsx)(U,{size:20}),(0,t.jsx)("span",{children:i("checkout.payment.payAtProperty")})]}),N&&(0,t.jsxs)(H.TabsTrigger,{value:"payOnline",disabled:e0,className:"w-full flex-col text-neutral-500 shadow-none h-auto gap-2 items-center py-4 data-[state=active]:text-neutral-950 data-[state=active]:shadow-none border border-transparent data-[state=active]:border-neutral-200",children:[(0,t.jsx)(L.CreditCardIcon,{size:20}),(0,t.jsx)("span",{children:i("checkout.payment.payOnline")})]})]}),(0,t.jsx)(H.TabsContent,{value:"payAtProperty",children:j&&(0===Z?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(eN,{onChange:e=>en(e)})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"border border-amber-800/10 bg-yellow-500/10 text-amber-600 text-sm py-1 px-3 text-center rounded-md mb-4",children:(0,t.jsx)("p",{className:"text-center mx-auto max-w-lg",children:i("checkout.payment.methods.plainForm.disclaimerWithDeposit",{deposit:(0,t.jsx)(t.Fragment,{children:(0,g.default)(Number(Number(Number(Z||0)*eB).toFixed(2)),eU)})})})}),(0,t.jsx)(ef,{allowedMethods:eQ,paymentMethod:q,setPaymentMethod:B,loadingPayment:eu,website:e,setPaymentToken:Y,currentReservation:y,paymentIntent:eT})]}))}),N&&(0,t.jsx)(H.TabsContent,{value:"payOnline",children:(0,t.jsx)(ef,{allowedMethods:eQ,paymentMethod:q,setPaymentMethod:B,loadingPayment:eu,website:e,setPaymentToken:Y,currentReservation:y,paymentIntent:eT})})]})]})}var eI=e.i(409306);function eF({website:e,currentReservation:r}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eI.default,{opened:!0,type:e?.property?.type,showRackRate:e?.property?.show_rack_rate!==!1,currentReservation:r,extrasCatalog:e?.extras||[],providerOptions:e?.providerOptions}),(0,t.jsx)(q,{website:e}),(0,t.jsx)(eP,{website:e})]})}var eT=e.i(191437),eE=e.i(888710);async function ez(e,t){let{propertyId:r,roomId:a,rateId:n,token:s}=e,i=`properties/${r}/rooms/${a}/rates/${n}`;return(0,eE.default)(i,{token:s},void 0,void 0,"no-cache",t)}var eO=e.i(901387);function eA({website:e}){let r=(0,_.useI18nWebsiteSet)(),a=(0,b.useRouter)(),n=(0,eO.isDev)(),s=(0,o.useMemo)(()=>({...e?.currentReservation,guest:e?.currentReservation?.guest}),[e?.currentReservation]),i=e.default_payment_method||"STRIPE",l=(0,o.useRef)(!1),c=(0,o.useRef)(null),[u,d]=(0,o.useState)(i),[m,p]=(0,o.useState)(null),{currentStep:h,setCurrentStep:y,handleUpdateReservation:x,setErrorMessage:g,paymentIntent:v,setPaymentIntent:w,handleCreatePayment:N}=(0,f.useCheckoutPayment)(),[j,S]=(0,o.useState)(h),k=(0,o.useCallback)(e=>{e!==j&&(S(e),y(e))},[j,y]),C=e?.providerConstants,R=s?.metadata?.bedGroupSelected?.expedia,P=s?.metadata?.bedGroupSelected?.property,I=s?.lang||"en",T=s?.request_currency||"USD",E=C?.cookies?.guestIP||"",z=s?.metadata?.attribution?.referrer||s?.metadata?.attribution?.landing_url||document.referrer,O=(0,ei.useTracking)(),A=(0,ei.useIntercom)(),D=J.default.generate(),[M,q]=(0,o.useState)(P?"payAtProperty":"payOnline"),[B,W]=(0,o.useState)(),[V,G]=(0,o.useState)(!1),[X,Y]=(0,o.useState)(s?.itinerary_id||null),Z=Number(h?.match(/\d+/)||0),{priceCheck:ee,refetchPriceCheck:et}=function(e,t,r){let a=function(e){if(!e)return null;try{let[t]=Object.keys(e),r=e[t];if(!r?.links?.price_check?.href)return null;let a=r.links.price_check.href.match(/properties\/(\d+)\/rooms\/([^/]+)\/rates\/([^/?]+)\?token=([^&]+)/);if(!a)return null;let[,n,s,i,l]=a;return{propertyId:n,roomId:s,rateId:i,token:l}}catch(e){return console.error("Error extracting price check parameters:",e),null}}("payAtProperty"===e?r:t),{data:n,refetch:s,error:i,isError:l}=(0,eT.useQuery)({queryKey:["price-check",a],queryFn:()=>
1{if(!a)throw Error("No price check parameters available");return ez(a,void 0)},enabled:!!a});return{priceCheck:n?.links?.book?.href?.replace("/v3/",""),refetchPriceCheck:s,error:i,isError:l,priceCheckParams:a}}(M,R,P),er="initial"!==h&&"availability"!==h&&"guest_information"!==h&&"payment_retry"!==h&&!h.includes("payment_")&&!h.includes("stripe_")&&!h.includes("clip_")&&!h.includes("fintoc_")&&!h.includes("plain_form_"),ea=(0,o.useCallback)(async()=>(l.current||v||c.current||(l.current=!0,c.current=(async()=>{try{let t=await N({orderReference:D,currency:s?.currency||"USD",amount:Math.round(100*Number(s?.total||0)),monthlyInstallments:!1,paymentMethod:"STRIPE"===u?"CARD":u,paymentProvider:u,futureUsage:!0,preventionData:m?.preventionData,client:{client_reference:`Client-${D}`,name:`${s?.guest?.first_name} ${s?.guest?.last_name}`,email:s?.guest?.email||"",phone:`+${s?.guest?.phoneCode}${s?.guest?.phone}`},business:{business_reference:String(s?.property_id||""),name:s?.property_name||""},origin:"EXPEDIA",metadata:JSON.stringify({payment_method:u,itinerary_id:String(s?.itinerary_id),reservation_id:s?.id,guest_id:s?.guest?.id,guest_currency:s?.request_currency,request_currency:s?.currency}),payAtBusiness:"0"!=s.pay_later});if(t?.payment)return w(t.payment),await x({order_reference:t.payment.order_reference,payment_reference:t.payment.payment_reference,payment_provider:u||"STRIPE",type:"payOnline"===M?"guru_collect":"hotel_collect",metadata:{...s?.metadata,payment:t.payment}}),await (0,F.default)("current-reservation"),await (0,F.default)("totals"),a.refresh(),O({eventName:"Payment setup",trackingContext:{website:e,reservation:s},eventData:{payment_provider:u,payment_reference:t.payment.payment_reference,order_reference:t.payment.order_reference}}),t;return null}catch(t){return console.error("Error creating payment:",t),g(t?.message||"An error occurred while creating the payment"),O({eventName:"Payment error",trackingContext:{website:e,reservation:s},eventData:{error:t?.message||"Unknown error",payment_provider:u}}),null}finally{l.current=!1,c.current=null}})()),c.current),[D,s,N,x,v,u,m,g,M,a,w,e,O]),en=(0,o.useRef)(ea);en.current=ea,(0,o.useEffect)(()=>{if(!er){if("payOnline"===M&&!v&&!l.current){let e=setTimeout(()=>{en.current().catch(e=>{console.error("Payment creation failed:",e),g("Failed to set up payment method. Please try again.")})},50);return()=>{clearTimeout(e),l.current=!1,c.current=null}}return()=>{l.current=!1,c.current=null}}},[M,er,v,g]);let el=(0,o.useRef)(et);el.current=et,(0,o.useEffect)(()=>{el.current()},[M]);let eo=(0,o.useMemo)(()=>{let t=e?.providerOptions?.providers?.some(e=>"CLIP"===e.provider&&e.account&&e?.status==="true"),r="STRIPE"!==i&&"FINTOC"!==i?[i]:["STRIPE"];return e?.providerOptions?.currency==="MXN"&&"MXN"===T&&t&&!r.includes("CLIP")&&"CLIP"!==i&&r.push("CLIP"),r},[e?.providerOptions?.providers,e?.providerOptions?.currency,T,i]);(0,o.useEffect)(()=>{eo.length>0&&!eo.includes(u)&&d(eo[0])},[eo,u]);let ec=e=>{e!==M&&(q(e),v&&w(null),m&&p(null),l.current=!1,c.current=null)},eu=$.default.find(e=>e.name.toUpperCase()===s?.guest?.country.toUpperCase())?.iso2,ed=(0,o.useCallback)(async(t,r)=>{if(V)return;if("payOnline"===t&&!v?.order_reference)return void console.error("No valid payment intent available for online payment");G(!0);let n=Number(h?.match(/\d+/)||0)+1;if("itinerary_success"!==h)if(s?.status==="timed_out"&&(s?.payment_reference||s?.order_reference)&&(await x({status:"active",current_step:"payment_success",error_message:null}),k("payment_success"),await new Promise(e=>setTimeout(e,1e3))),h.includes("reservation_error")){let e=await x({status:"booked",current_step:"reservation_success",error_message:null});if(e.errors)await x({current_step:`reservation_error_${Number(n)}`,error_message:e?.errors?.[0]?.message}),k(`reservation_error_${Number(n)}`),console.error("updateReservationOnReservationError",e?.errors),g(e?.errors?.[0]?.message),G(!1);else{g(null),k("reservation_success");let e=`/${I}/guest/reservation?email=${encodeURIComponent(s?.guest?.email||"")}&itineraryId=${X}`;a.replace(e)}}else try{k("itinerary_processing"),await x({current_step:"itinerary_processing"});let i=await fetch("/api/bookings/create-itinerary/expedia",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentReservation:s,website:e,paymentIntent:v,plainFormCardData:r,countryCode:eu,locale:I,currentSelectedMethod:t,priceCheck:ee,guestIP:E,referrer:z})}),l=await i.json();if(l.success){Y(l.itineraryId),A.trackEvent("itinerary",{property:s?.property_name,checkin:s?.checkin,checkout:s?.checkout,currency:s?.currency,lang:s?.lang||"en",orderReference:v?.order_reference,paymentReference:v?.payment_reference,user:{first_name:s?.guest?.first_name,last_name:s?.guest?.last_name,email:s?.guest?.email,phone:`+${s?.guest?.phoneCode}${s?.guest?.phone}`,reservation_id:l.itineraryId}}),O({eventName:"Complete booking",trackingContext:{website:e,reservation:s},eventData:{hotel:s?.property_name,arrival:s?.checkin,departure:s?.checkout,currency:s?.currency,original_currency:s?.request_currency,itinerary_id:l.itineraryId,nights:s?.nights,rooms:s?.occupancy?.length,lang:s?.lang,pay_now:Number(s?.pay_now||s?.total||0).toFixed(2)}}),k("reservation_success");let t=`/${I}/guest/reservation?email=${encodeURIComponent(s?.guest?.email||"")}&itineraryId=${l.itineraryId}`;a.replace(t)}else{let t=l.error||"Error creating itinerary";O({eventName:"Booking error",trackingContext:{website:e,reservation:s},eventData:{hotel:s?.property_name,arrival:s?.checkin,departure:s?.checkout,currency:s?.currency,original_currency:s?.request_currency,itinerary_id:String(s?.itinerary_id),error:t}}),await x({current_step:`itinerary_error_${Number(n)}`,error_message:t}),k(`itinerary_error_${Number(n)}`),g(t),G(!1)}}catch(e){console.error("Error creating itinerary:",e),await x({current_step:`itinerary_error_${Number(n)}`,error_message:e.message||"An unexpected error occurred"}),k(`itinerary_error_${Number(n)}`),g(e.message||"An unexpected error occurred"),G(!1)}},[h,v,x,k,g,s,E,a,X,I,e,eu,ee,z,O,A,V]);return((0,o.useEffect)(()=>
1{if(!er&&(h.includes("stripe_payment_success")||h.includes("plain_form_payment_success")||h.includes("fintoc_payment_success")||h.includes("clip_payment_success"))&&ee&&M){let e=setTimeout(()=>{("payOnline"===M||"payAtProperty"===M)&&ed(M,B)},100);return()=>clearTimeout(e)}},[h,ed,er,ee,M]),(0,o.useEffect)(()=>{"payOnline"!==M||v||l.current||(l.current=!1,c.current=null,ea())},[u,M,v,ea]),s?.status==="cancelled"||s?.status==="refunded")?null:(0,t.jsxs)("div",{className:"rounded-md overflow-hidden relative min-h-[400px]",children:[(0,t.jsxs)(K.Drawer,{open:er,children:[(0,t.jsx)(K.DrawerTrigger,{asChild:!0}),(0,t.jsx)(K.DrawerContent,{className:"w-full",children:(0,t.jsx)(Q,{children:(0,t.jsx)(es,{retriesFromCurrentStepGlobal:Z,currentStep:h,createItineraryAction:()=>{("payOnline"===M||"payAtProperty"===M)&&ed(M,B)},loading:V,locale:I,currentReservation:s})})})]}),(0,t.jsxs)(H.Tabs,{defaultValue:P?"payAtProperty":"payOnline",className:"w-full",value:M,onValueChange:e=>{("payOnline"===e||"payAtProperty"===e)&&ec(e)},children:[P&&R&&(0,t.jsxs)(H.TabsList,{className:"w-full bg-neutral-100 border border-neutral-200 h-auto mb-2 p-2",children:[P&&(0,t.jsxs)(H.TabsTrigger,{value:"payAtProperty",className:"w-full flex-col text-neutral-500 shadow-none h-auto gap-2 items-center py-4 data-[state=active]:text-neutral-950 data-[state=active]:shadow-none border border-transparent data-[state=active]:border-neutral-200",onClick:()=>{ec("payAtProperty")},children:[(0,t.jsx)(U,{size:20}),(0,t.jsx)("span",{children:r("checkout.payment.payAtProperty")})]}),n&&R&&(0,t.jsxs)(H.TabsTrigger,{value:"payOnline",className:"w-full flex-col text-neutral-500 shadow-none h-auto gap-2 items-center py-4 data-[state=active]:text-neutral-950 data-[state=active]:shadow-none border border-transparent data-[state=active]:border-neutral-200",onClick:()=>{ec("payOnline")},children:[(0,t.jsx)(L.CreditCardIcon,{size:20}),(0,t.jsx)("span",{children:r("checkout.payment.payOnline")})]})]}),P&&(0,t.jsx)(H.TabsContent,{value:"payAtProperty",children:(0,t.jsx)(eN,{onChange:e=>W(e)})}),n&&R&&(0,t.jsx)(H.TabsContent,{value:"payOnline",children:(0,t.jsx)(eN,{onChange:e=>W(e)})})]})]})}function eD({website:e,currentReservation:r}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eI.default,{opened:!0,type:e?.property?.type,showRackRate:e?.property?.show_rack_rate!==!1,currentReservation:r,extrasCatalog:e?.extras||[]}),(0,t.jsx)(eA,{website:e})]})}var eM=e.i(273169),eq=e.i(897191);function e$({website:e}){let t=e?.tracking_codes?.find(e=>"sojernTracker"===e.name),r=(0,o.useMemo)(()=>(0,eM.getSojernSiteConfig)(e),[e]),a=(0,o.useMemo)(()=>r?(0,eM.getSojernReservationParams)(e?.currentReservation,{priceExcludesTaxes:r.priceExcludesTaxes}):{},[r,e?.currentReservation]),n=(0,o.useMemo)(()=>{let e=r?(0,eM.getSojernAccountId)(r):"",a=!!(r&&e);return{id:t?.codes?.shopping,name:"Shopping",parameters:[],placement:"body",enabled:!r,nextGen:a?{mode:r.mode,accountId:e,event:"shoppingCart",params:(0,eM.getSojernFireParams)(r,"shoppingCart")}:void 0}},[t?.codes?.shopping,r]);return(0,eq.useSojernScript)({config:n,params:a}),null}var eL=e.i(903570),eB=e.i(479175);function eU({tripType:e,setTripType:r,origin:a,setOrigin:n,disabled:s,arrivalFlight:i,setArrivalFlight:l,departureFlight:o,setDepartureFlight:c,arrivalTime:u,setArrivalTime:d,departureTime:m,setDepartureTime:p,arrivalDate:h,setArrivalDate:y,departureDate:f,setDepartureDate:x}){let g=(0,_.useScopedI18nWebsiteSet)("checkout.payment.extras");return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eB.Separator,{}),(0,t.jsxs)("div",{className:"w-full flex justify-between items-center gap-2",children:[(0,t.jsx)("p",{className:"font-semibold w-full",children:g("checkout.flights.type")}),(0,t.jsx)("div",{className:"w-full flex gap-2 justify-end",children:["roundtrip","oneway"].map(a=>(0,t.jsx)(k.Button,{size:"sm",variant:e===a?"default":"outline",onClick:()=>r(a),disabled:s,children:"roundtrip"===a?g("checkout.flights.roundtrip"):g("checkout.flights.oneWay")},a))})]}),(0,t.jsxs)("div",{className:"w-full flex justify-between items-center gap-2",children:[(0,t.jsx)("p",{className:"font-semibold w-full",children:g("checkout.flights.origin")}),(0,t.jsx)("div",{className:"w-full flex gap-2 justify-end",children:["airport","property"].map(e=>(0,t.jsx)(k.Button,{size:"sm",variant:a===e?"default":"outline",onClick:()=>n(e),disabled:s,children:"airport"===e?g("checkout.flights.airport"):g("checkout.flights.property")},e))})]}),"airport"===a||"roundtrip"===e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eB.Separator,{}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)("p",{className:"text-xs font-semibold",children:g("checkout.flights.arrival")}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(P.Label,{htmlFor:"flight-checkin",children:g("checkout.flights.flightAndAirline")}),(0,t.jsx)(eg.Input,{className:"w-full",id:"flight-checkin",type:"text",disabled:s,defaultValue:i,onChange:e=>l(e.target.value)})]}),(0,t.jsxs)("div",{className:"w-full flex gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,t.jsx)(P.Label,{htmlFor:"date-checkin",children:g("checkout.flights.date")}),(0,t.jsx)(eg.Input,{className:"w-full",id:"date-checkin",type:"date",disabled:s,defaultValue:h,onChange:e=>y(e.target.value)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,t.jsx)(P.Label,{htmlFor:"time-checkin",children:g("checkout.flights.time")}
1),(0,t.jsx)(eg.Input,{className:"w-full",id:"time-checkin",type:"time",disabled:s,defaultValue:u,onChange:e=>d(e.target.value)})]})]})]})]}):null,"oneway"===e&&"property"===a||"roundtrip"===e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eB.Separator,{}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)("p",{className:"text-xs font-semibold",children:g("checkout.flights.departure")}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(P.Label,{htmlFor:"flight-checkout",children:g("checkout.flights.flightAndAirline")}),(0,t.jsx)(eg.Input,{className:"w-full",id:"flight-checkout",type:"text",disabled:s,defaultValue:o,onChange:e=>c(e.target.value)})]}),(0,t.jsxs)("div",{className:"w-full flex gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,t.jsx)(P.Label,{htmlFor:"date-checkout",children:g("checkout.flights.date")}),(0,t.jsx)(eg.Input,{className:"w-full",id:"date-checkout",type:"date",disabled:s,defaultValue:f,onChange:e=>x(e.target.value)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,t.jsx)(P.Label,{htmlFor:"time-checkout",children:g("checkout.flights.time")}),(0,t.jsx)(eg.Input,{className:"w-full",id:"time-checkout",type:"time",disabled:s,defaultValue:m,onChange:e=>p(e.target.value)})]})]})]})]}):null]})}let eW=/(transfer|traslado|shuttle|transport|transportation|airport|aeropuerto|one[\s-]?way|round[\s-]?trip|solo\s*ida|ida\s*y\s*vuelta|viaje\s+redondo|viaje\s+(solo\s+)?ida|transporte)/i,eV=/(round[\s-]?trip|redondo|ida\s*y\s*vuelta|roundtrip)/i;function eG(e){return!!e?.extra_data?.serviceType}function eJ({extra:e,checkin:r,checkout:a,image:n,occupancy:s,currency:i,exchangeRate:l=1}){var c,u;let d,m,p=(0,_.useScopedI18nWebsiteSet)("checkout.payment.extras"),h=(0,b.useRouter)(),{currentReservation:y,handleUpdateReservation:x,setCurrentStep:v}=(0,f.useCheckoutPayment)(),P=y?.metadata?.extras||[],z=T(s),[O,A]=(0,o.useState)(!1),[D,M]=(0,o.useState)(!1),[q,$]=(0,o.useState)(1),[L,B]=(0,o.useState)(0),[U,W]=(0,o.useState)(1),[V,G]=(0,o.useState)(1),[J,K]=(0,o.useState)(""),[H,X]=(0,o.useState)(""),[Y,Z]=(0,o.useState)(""),[Q,ee]=(0,o.useState)(""),[et,er]=(0,o.useState)(""),[ea,en]=(0,o.useState)(""),[es,ei]=(0,o.useState)(e?.extra_data?.serviceType==="roundtrip"?"roundtrip":e?.extra_data?.serviceType==="oneway"?"oneway":eV.test(String(e?.name||""))?"roundtrip":"oneway"),[el,eo]=(0,o.useState)("airport"),ec=e?.price_quantity!==0?e?.price_quantity:e?.price_adults!==0?e?.price_adults:e?.price_children!==0?e?.price_children:e?.extra_data.onewayPrice||0,[eu,ed]=(0,o.useState)(Number(ec)),em=eG(e),ep=eG(e)||!!(d=[e?.name,e?.category?.name].map(e=>String(e||"").trim()).filter(Boolean).join(" "))&&eW.test(d);(0,o.useEffect)(()=>{let t=(Number(e?.price_adults)*q+Number(e?.price_children)*L+Number(e?.price_quantity)*U)*V,r="roundtrip"===es?Number(e?.extra_data.roundtripPrice)*q+Number(e?.extra_data.roundtripPrice)*L:Number(e?.extra_data.onewayPrice)*q+Number(e?.extra_data.onewayPrice)*L;ed(em?r:t)},[q,L,U,V,es,e?.price_adults,e?.price_children,e?.price_quantity,e?.extra_data.onewayPrice,e?.extra_data.roundtripPrice,em]);let eh=!!P.find(t=>String(t.extra_id)===String(e?.id)),ey=Number((c=new Date(r),u=new Date(a),m=Date.UTC(c.getFullYear(),c.getMonth(),c.getDate()),Math.floor((Date.UTC(u.getFullYear(),u.getMonth(),u.getDate())-m)/864e5))),ef="roundtrip"===es,ex=ep&&(ef&&(!J||!H||!Y||!Q||!et||!ea)||!ef&&("airport"===el?!J||!Y||!et:!H||!Q||!ea));async function e_(){A(!0);let t={extra_id:String(e?.id),name:String(e?.name),image:String(n),quantity:U,adults:q,children:L,days:V,...ep?{travel_origin:"property"===el?"hotel":"airport",trip_type:es,arrival_date:et,departure_date:ea,arrival_flight:J,departure_flight:H,arrival_time:Y,departure_time:Q}:{}};await x({current_step:"refetch_totals",metadata:{...y?.metadata,extras:[...P,t]}}),await (0,F.default)("current-reservation"),await (0,F.default)("totals"),h.refresh(),M(!1),A(!1)}async function eg(){A(!0),await x({current_step:"refetch_totals",metadata:{...y?.metadata,extras:P.filter(t=>String(t.extra_id)!==String(e?.id))}}),await (0,F.default)("current-reservation"),await (0,F.default)("totals"),h.refresh(),M(!1),A(!1)}return(0,o.useEffect)(()=>{ef||"property"!==el||(K(""),Z(""),er(""))},[ef,el]),(0,t.jsxs)(R.Dialog,{open:D,onOpenChange:M,children:[(0,t.jsx)(R.DialogTrigger,{asChild:!0,children:(0,t.jsx)(k.Button,{size:"sm",className:(0,C.cn)("w-full mb-2 gap-2 bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground",{"opacity-60":eh}),children:eh?(0,t.jsxs)(t.Fragment,{children:[p("common.added")," ",(0,t.jsx)(w.CheckIcon,{size:16})]}):(0,t.jsxs)(t.Fragment,{children:[p("common.add")," ",(0,t.jsx)(S.PlusIcon,{size:16})]})})}),(0,t.jsx)(R.DialogContent,{className:"border-border shadow-none",children:(0,t.jsx)(I.ScrollArea,{className:"pb-2 max-h-[560px]",children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)("div",{className:"pb-[50%] relative overflow-hidden rounded-md",children:n&&(0,t.jsx)("img",{alt:e?.name,src:n,className:"object-cover h-full w-full absolute left-0 top-0"})}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[e?.availability_label&&(0,t.jsx)(eL.Alert,{variant:"warning",className:"h-auto py-2",children:(0,t.jsx)(eL.AlertDescription,{children:e?.availability_label})}),(0,t.jsx)("h4",{className:"font-semibold text-xl",children:e?.name}),e?.description&&(0,t.jsx)("p",{className:"text-sm mb-2",children:e?.description}),(0,t.jsxs)("div",{className:"w-full flex flex-col gap-3 border p-4 rounded-sm",children:[em?0!==z.adults&&(0,t.jsx)(E,{label:p("checkout.adults"),value:q,setValue:$,min:1,max:z.adults,disabled:eh}):e?.price_adults!==0&&(0,t.jsx)(E,{label:p("checkout.adults"),value:q,setValue:$,min:1,max:z.adults,disabled:eh}),em?0!==z.children&&(0,t.jsx)(E,{label:p("checkout.children"),value:L,setValue:B,min:1,max:z.children,disabled:eh}):0!==z.children&&e?.price_children!==0&&(0,t.jsx)(E,{label:p("checkout.children"),value:L,setValue:B,min:1,max:z.children,disabled:eh}),!!e?.price_quantity&&(0,t.jsx)(E,{label:p("checkout.quantity"),value:U,setValue:W,min:1,max:0!==Number(e?.max_per_res)?Number(e?.max_per_res):z.adults+z.children,disabled:eh}),!em&&e?.multiple_days&&1!==ey&&(0,t.jsx)(E,{label:p("checkout.days"),value:V,setValue:G,min:1,max:ey,disabled:eh}),ep&&(0,t.jsx)(eU,{tripType:es,setTripType:ei,origin:el,setOrigin:eo,disabled:eh,arrivalFlight:J,setArrivalFlight:K,departureFlight:H,setDepartureFlight:X,arrivalTime:Y,setArrivalTime:Z,departureTime:Q,setDepartureTime:ee,arrivalDate:et,setArrivalDate:er,departureDate:ea,setDepartureDate:en})]}),(0,t.jsxs)("div",{className:"w-full flex justify-between my-2 items-center",children:[(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("p",{className:"font-semibold text-lg",children:p("checkout.total")})}),(0,t.jsx)("div",{className:"w-full justify-end flex",children:(0,t.jsx)("p",{className:"text-lg",children:(0,g.default)(Number(eu*l),String(i||"USD"))})})]}),(0,t.jsx)(k.Button,{size:"sm",className:"w-full gap-2 bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground",onClick:()=>{eh?eg():e_()},disabled:ex||O,children:O?(0,t.jsx)(N.LoaderIcon,{className:"animate-spin",size:16}):eh?(0,t.jsxs)(t.Fragment,{children:[p("common.removeFromCart")," ",(0,t.jsx)(j.MinusIcon,{size:16})]}):(0,t.jsxs)(t.Fragment,{children:[p("common.addToCart")," ",(0,t.jsx)(S.PlusIcon,{size:16})]})})]})]})})})]})}function eK({website:e}){let{currentReservation:r}=(0,f.useCheckoutPayment)(),a=e?.extras,n=new Date,s=r?.checkin||"",i=r?.checkout||"",d=r?.currency||r?.totals?.requested?.currency||"USD",m=r?.request_currency||d,p=(0,x.resolveCurrencyConversionRate)({requestCurrency:d,currency:m,paymentsCurrencyRate:e?.providerOptions?.paymentsCurrencyRate}),_=p?m:d,g=p??1,b=(0,o.useRef)(null),[w,N]=(0,o.useState)(!1),[j,S]=(0,o.useState)(!1),k=()=>{let e=b.current;e&&(N(e.scrollLeft>0),S(e.scrollLeft<e.scrollWidth-e.clientWidth-1))},C=e=>{let t=b.current;if(t){let r=t.clientWidth/2,a="left"===e?t.scrollLeft-r:t.scrollLeft+r;t.scrollTo({left:a,behavior:"smooth"})}};(0,o.useEffect)(()=>(k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)),[]);let R=a?.map(e=>{var t,r;let a=(0,y.default)(e?.images)?.map(e=>(0,h.modifyImagesToWebP)(e,"800")),i=0!==e.price_quantity?e.price_quantity:0!==e.price_adults?e.price_adults:0!==e.price_children?e.price_children:e.extra_data.onewayPrice;return(t=new Date(s),r=e.min_prev_days,Math.ceil((t.getTime()-n.getTime())/864e5)>=r)?{id:String(e.id),name:e.name,description:e.description,image:a?.[0],price:i}:null});return(0,t.jsxs)("div",{className:"jsx-d1e1d09fdfc6c76b w-full relative",children:[w&&(0,t.jsx)("button",{onClick:()=>C("left"),"aria-label":"Scroll left",className:"jsx-d1e1d09fdfc6c76b absolute left-0 top-1/2 transform -translate-y-1/2 z-10 bg-white/80 rounded-full p-1 shadow-md",children:(0,t.jsx)(c.ChevronLeft,{size:24})}),(0,t.jsx)("div",{ref:b,style:{display:"flex",flexWrap:"nowrap",overflowX:"auto",scrollbarWidth:"none",msOverflowStyle:"none"},onScroll:k,className:"jsx-d1e1d09fdfc6c76b w-full grid grid-cols-2 md:grid-cols-4 gap-3 overflow-x-auto pb-2 scroll-smooth hide-scrollbar",children:R?.filter(e=>e?.name)?.map(e=>{let n=a?.find(t=>String(t.id)===String(e?.id));return(0,t.jsx)("div",{className:"jsx-d1e1d09fdfc6c76b flex-shrink-0 w-full sm:w-1/2 md:w-1/4 px-1",children:(0,t.jsx)(v,{name:e?.name,image:e?.image,price:e?.price,currency:_,exchangeRate:g,children:(0,t.jsx)(eJ,{extra:n,checkin:s,checkout:i,image:e?.image,occupancy:r?.occupancy,currency:_,exchangeRate:g})})},e?.id)})}),j&&(0,t.jsx)("button",{onClick:()=>C("right"),"aria-label":"Scroll right",className:"jsx-d1e1d09fdfc6c76b absolute right-0 top-1/2 transform -translate-y-1/2 z-10 bg-white/80 rounded-full p-1 shadow-md",children:(0,t.jsx)(u.ChevronRight,{size:24})}),(0,t.jsx)(l.default,{id:"d1e1d09fdfc6c76b",children:".hide-scrollbar.
1jsx-d1e1d09fdfc6c76b::-webkit-scrollbar{display:none}"})]})}var eH=e.i(534614);let eX=[];function eY({website:e,totals:r,extras:a,totalsExtras:n}){let s=(0,b.useRouter)(),{currentReservation:i,currentStep:l,setCurrentStep:c,handleUpdateReservation:u,setErrorMessage:d,setIsUpdatingPayment:m}=(0,f.useCheckoutPayment)(),p=(0,o.useMemo)(()=>i||{...e?.currentReservation,guest:e?.currentReservation?.guest},[i,e?.currentReservation]),h=p?.metadata?.attribution?.referrer||p?.metadata?.attribution?.landing_url||document.referrer,y=(0,o.useMemo)(()=>p?.metadata?.extras||a||eX,[p?.metadata?.extras,a]),[x,_]=(0,o.useState)(p?.metadata?.payment||null),[g,v]=(0,o.useState)(l),w=(0,o.useCallback)(e=>{e!==g&&(v(e),c(e))},[g,c]),N=p?.lang||"en",j=p?.request_currency||"USD",S=p?.checkin||"",k=p?.checkout||"",C=!!p?.metadata?.test_run_id&&p?.metadata?.test_run_mode==="direct_zavia"&&!1,R=(0,eH.isZaviaMultiRoomV2Enabled)({websiteType:e?.property?.type,reservation:p}),P=R?"/api/bookings/create-itinerary/zavia-v2":"/api/bookings/create-itinerary/zavia",I=R?"/api/bookings/update-payment/zavia-v2":"/api/bookings/update-payment",F=Number(e?.providerOptions?.accountFee),T=Number.isFinite(F)&&F>=0?F:5,E=Number(n?.requested?.policyPayment?.pay_later_with_extras??n?.requested?.policyPayment?.pay_later??0),z=(0,ek.isFeeConfigEnabled)()?(0,ek.resolveAccountFee)({schedule:e?.providerOptions?.feeSchedule,bookingType:E>0?"hotel_collect":"pay_now",resolvedFee:e?.providerOptions?.resolvedFee,feeSource:e?.providerOptions?.feeSource,accountFee:T}):T,O=(0,ei.useTracking)(),A=(0,ei.useIntercom)(),D=e.default_payment_method,[M,q]=(0,o.useState)(p?.payment_provider||"STRIPE"),[L,B]=(0,o.useState)(null),[U,W]=(0,o.useState)(!1),[V,G]=(0,o.useState)(!1);(0,o.useEffect)(()=>(m(U),()=>{m(!1)}),[U,m]);let H=(0,o.useMemo)(()=>J.default.generate(),[]),X=(0,o.useRef)(""),Y=(0,o.useRef)(""),Z=(0,o.useRef)(null),ee=(Number(r?.subtotalGeneral)||0)*(z/100),et=Number((ee+.16*ee).toFixed(2))||0,er=Number(l?.match(/\d+/)||0),ea="CLIP"===M&&L,en=$.default.find(e=>e.name.toUpperCase()===p?.guest?.country.toUpperCase())?.iso2,el=(0,o.useCallback)(t=>{let r=String(t?.payment_reference||""),a=String(t?.order_reference||"");if(!r&&!a)return;let n=`${M}:${r}:${a}`;n!==Y.current&&(Y.current=n,O({eventName:"Payment setup",trackingContext:{website:e,reservation:p},eventData:{payment_provider:M,payment_reference:r||void 0,order_reference:a||void 0,payment_status:t?.status}}))},[p,M,O,e]),eo=(0,o.useCallback)(async t=>{if(!l.includes("payment_success")&&!l.includes("itinerary_processing")||V)return;if(!x?.order_reference)return void console.error("No valid payment intent available");G(!0);let r=Number(l?.match(/\d+/)||0)+1;if("itinerary_success"!==l)if(l.includes("reservation_error")){let e=await u({status:"booked",current_step:"reservation_success",error_message:null});e.errors&&(await u({current_step:`reservation_error_${Number(r)}`,error_message:e?.errors?.[0]?.message}),w(`reservation_error_${Number(r)}`),console.error("updateReservationOnReservationError",e?.errors),d(e?.errors?.[0]?.message),G(!1))}else try{w("itinerary_processing");let a=await fetch(P,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentReservation:p,website:e,paymentIntent:x,extrasFromContext:y,totals:t,totalsExtras:n,countryCode:en,locale:N,referrer:h})}),i=await a.json();if(i.success){O({eventName:"Complete booking",trackingContext:{website:e,reservation:p},eventData:{hotel:e.name,arrival:S,departure:k,currency:p?.currency,original_currency:p?.request_currency,itinerary_id:i.itineraryId,nights:p?.nights,rooms:p?.occupancy?.length,lang:p?.lang,pay_now:Number(n?.requested?.policyPayment?.pay_now).toFixed(2),pay_later:Number(n?.requested?.policyPayment?.pay_later).toFixed(2)}}),A.trackEvent("itinerary",{property:e.name,checkin:S,checkout:k,currency:p?.currency,lang:p?.lang||"en",orderReference:x?.order_reference,paymentReference:x?.payment_reference,user:{first_name:p?.guest?.first_name,last_name:p?.guest?.last_name,email:p?.guest?.email,phone:`+${p?.guest?.phoneCode}${p?.guest?.phone}`,reservation_id:i.itineraryId}}),w("reservation_success");let t=`/${N}/guest/reservation?itineraryId=${encodeURIComponent(i.itineraryId)}`;s.replace(t)}else{let t=i?.code==="zavia_manual_review_required"||i?.manualReview===!0;if(O({eventName:"Booking error",trackingContext:{website:e,reservation:p},eventData:{hotel:e.name,arrival:S,departure:k,currency:p?.currency,original_currency:p?.request_currency,error:i.error,code:i?.code}}),t){w("itinerary_manual_review_required"),d(i.error||"We are reviewing your reservation. Our team has been notified and will contact you shortly."),G(!1);return}w(`itinerary_error_${Number(r)}`),d(i.error||"Error creating itinerary"),G(!1)}}catch(e){console.error("Error creating itinerary:",e),await u({current_step:`itinerary_error_${Number(r)}`,error_message:e.message||"An unexpected error occurred"}),w(`itinerary_error_${Number(r)}`),d(e.message||"An unexpected error occurred"),G(!1)}},[l,n,x,V,w,p,e,y,S,k,en,N,h,P,u,A,s,d,O]);(0,o.useEffect)(()=>
1{if(l.includes("payment_success")&&r&&!V&&x){let e=setTimeout(()=>{eo(r)},100);return()=>clearTimeout(e)}if(!l.includes("payment_success")&&l.includes("itinerary_processing")&&!V&&x&&r){let e=setTimeout(()=>{eo(r)},5e3);return()=>clearTimeout(e)}},[l,V,x]),(0,o.useEffect)(()=>{if(l.startsWith("stripe_payment_"))return;let t=p?.current_step==="refetch_totals"||"refetch_totals"===l,r="CLIP"===M&&!!L?.id;if("CLIP"===M&&!r||r&&Z.current===L?.id||!r&&"guest_information"===l&&p?.payment_reference&&x?.payment_reference&&p?.payment_reference===x?.payment_reference&&!t)return;let a=!!x?.payment_reference&&String(x?.payment_method||"").toUpperCase()===String(M);if(!r&&a&&!t&&!l.includes("payment_error")||!r&&p?.payment_provider===M&&!t&&p?.payment_reference===x?.payment_reference&&x?.payment_reference&&"payment_error"!==l||!r&&l.includes("payment_error"))return;let s=JSON.stringify({reservationId:p?.id,paymentMethod:M,paymentTokenId:L?.id||null,extrasCount:y.length,extrasHash:y.map(e=>`${e?.extra_id}:${e?.quantity}:${e?.adults}:${e?.children}`).join("|"),payNowWithExtras:n?.requested?.policyPayment?.pay_now_with_extras||0,totalWithExtras:n?.requested?.total_with_extras||0});s===X.current||U&&!r||(r&&L?.id&&(Z.current=L.id),W(!0),X.current=s,(async()=>{try{let t=await fetch(I,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentReservation:p,website:e,paymentMethod:M,paymentToken:L,extrasFromContext:y,totalsExtras:n,accountFee:z,propertyAccountFee:et,affiliateReferenceId:H})}),r=await t.json();if(r.success)_(r.payment),el(r.payment),w(function({isDirectZaviaTestMode:e,paymentMethod:t,paymentStatus:r}){return e&&"PAID"===r?"payment_success":"CLIP"===t&&"PAID"===r?"clip_payment_success":"guest_information"}({isDirectZaviaTestMode:C,paymentMethod:M,paymentStatus:r.payment?.status}));else{if(r?.code==="multi_room_extras_not_consolidated"){d(r?.error||("es"===N?"Los extras aun se estan actualizando. Actualiza e intenta nuevamente.":"Extras are still syncing. Please refresh and try again.")),X.current="",O({eventName:"Payment error",trackingContext:{website:e,reservation:p},eventData:{code:"multi_room_extras_not_consolidated",error:r?.error||"Extras are not consolidated",payment_provider:M,extras_count:y.length,room_count:p?.occupancy?.length||0}}),w("payment_error");return}d(r.error),X.current="",O({eventName:"Payment error",trackingContext:{website:e,reservation:p},eventData:{error:r.error||"Unknown payment update error",payment_provider:M}}),w("payment_error")}}catch(t){console.error("Payment update error:",t),X.current="",O({eventName:"Payment error",trackingContext:{website:e,reservation:p},eventData:{error:t.message||"An unexpected error occurred",payment_provider:M}}),d(t.message||"An unexpected error occurred"),w("payment_error")}finally{W(!1)}})())},[M,L,y,l,p?.current_step,x?.payment_reference,x?.payment_method,n?.requested?.total,n?.requested?.policyPayment?.pay_now_with_extras,ea,C,I,N,el]);let ec="refetch_totals"!==l&&"availability"!==l&&"guest_information"!==l&&"payment_retry"!==l&&!l.includes("initializing"),eu=(0,o.useMemo)(()=>{let t=["STRIPE"];return e?.providerOptions?.currencies?.includes("MXN")&&"MXN"===j&&e?.providerOptions?.providers?.some(e=>"CLIP"===e.provider&&e.account&&e?.status==="true")&&t.push("CLIP"),D&&"STRIPE"!==D&&"FINTOC"!==D&&!t.includes(D)&&t.push(D),t},[e?.providerOptions?.providers,e?.providerOptions?.currencies,j,D]);return p?.status==="cancelled"||p?.status==="refunded"?null:(0,t.jsxs)("div",{className:"rounded-md overflow-hidden relative min-h-[400px]",children:[(0,t.jsxs)(K.Drawer,{open:ec,children:[(0,t.jsx)(K.DrawerTrigger,{asChild:!0}),(0,t.jsx)(K.DrawerContent,{className:"w-full",children:(0,t.jsx)(Q,{children:(0,t.jsx)(es,{retriesFromCurrentStepGlobal:er,currentStep:l,createItineraryAction:()=>{!V&&l.includes("payment_success")&&eo(r)},loading:V,locale:N,currentReservation:p})})})]}),(0,t.jsx)(ef,{allowedMethods:eu,paymentMethod:M,setPaymentMethod:q,loadingPayment:U,website:e,setPaymentToken:B,currentReservation:p,paymentIntent:x})]})}function eZ({website:e,currentReservation:r,totalsExtras:a,zaviaTotals:n,extras:s}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eI.default,{opened:!0,type:e?.property?.type,showRackRate:e?.property?.show_rack_rate!==!1,currentReservation:r,totalsExtras:a,extrasCatalog:e?.extras||[]}),(0,t.jsx)(eK,{website:e}),(0,t.jsx)(eY,{website:e,totals:n,extras:s,totalsExtras:a})]})}
1var eQ=e.i(782391);function e0(e){if(null==e)return null;let t=String(e).trim();return t&&/^\d+$/.test(t)?t:null}function e1(e){let t=e0(e);return t?`gzav-${t}`:null}var e2=e.i(11869);async function e6({website:e,currentReservation:t}){let r=e?.providerOptions,a=t?.checkin||"",n=t?.checkout||"",s=t?.lang||"en",i=t?.currency||"USD",l=t?.request_currency||"USD",o=e?.providerOptions?.paymentsCurrencyRate,c=(0,x.resolveCurrencyConversionRateOrOne)({requestCurrency:i,currency:l,paymentsCurrencyRate:o}),u=t?.metadata?.extras||[],d=function({currentReservation:e,childrenMinAge:t}){let r=e?.occupancy||[],a=e?.metadata?.room_mix?.slots;if(!r.length)return[];let n=e?.metadata?.availability?.id,s=e?.metadata?.availability?.promotion_id,i=Array.isArray(a)&&a.length===r.length&&a.every(e=>!!e?.room_id&&!!e?.rate_id),l=[];return r.forEach((e,r)=>{let o=i?a?.[r]:null,c=o?.room_id||e?.room?.id,u=o?.rate_id||n,d=o?.promotion_id!==void 0?o.promotion_id:s;if(c&&u){let r;l.push({room_type_id:String(c),rate_type_id:u,promotion_id:d,quantity:1,pax:[{adults:e?.adults||2,children:e?.children||0,infants:Number.isFinite(r=Number(t))?Number(e?.childrenAges?.filter(e=>Number(e)<r)?.length||0):0}]})}}),l}({currentReservation:t,childrenMinAge:r?.childrenMinAge}),m=e1(function({websiteZaviaId:e,reservationMetadataZaviaId:t,providerConstantsZaviaId:r,testRunMode:a}){let n=e0(e),s=e0(t)||e0(r);return(0,eQ.isDirectZaviaTestRunEnabled)()&&"direct_zavia"===a&&s?s:n}({websiteZaviaId:e?.property?.zavia_id,reservationMetadataZaviaId:t?.metadata?.test_hotel_zavia_id,testRunMode:t?.metadata?.test_run_mode}))||e1(e?.property?.zavia_id)||`gzav-${e.property.zavia_id}`,p={currency:i,arrival:a,departure:n,rooms:d,extras:u?.map(({image:e,...t})=>t)||[]},h=await (0,e2.default)("summary/get-totals",{lang:s,hotel_id:m,currency:i,arrival:a,departure:n},p,"no-cache",["totals"]),y=h?.data,f=function({totals:e,priceCheck:t,requestCurrency:r,currency:a,currentCurrencyConversionRate:n}){let s=e?.converted,i=e?.requested,l=0!==Number(t?.subtotalExtras||0),o=l?Number(t?.totalExtras||0):0,c=Number(i?.policyPayment?.pay_now||0),u=Number(i?.policyPayment?.pay_later||0),d=l?Number((o*n).toFixed(2)):0,m=Number(s?.policyPayment?.pay_now||0),p=Number(s?.policyPayment?.pay_later||0);return{requested:{...i,extras_subtotal:l?t?.subtotalExtras:0,extras_taxes:l?t?.taxesExtras:0,extras_total:l?t?.totalExtras:0,currency:r,subtotal_with_extras:l?Number(Number(Number(Number(i?.subtotal)+Number(t?.subtotalExtras)).toFixed(2)).toFixed(2)):Number(0),taxes_with_extras:l?Number(Number(Number(Number(i?.taxes_inclusive)+Number(t?.taxesExtras)).toFixed(2)).toFixed(2)):Number(0),total_with_extras:l?Number(Number(Number(Number(t?.totalExtras)+Number(i?.total)).toFixed(2)).toFixed(2)):Number(0),policyPayment:l?{...i?.policyPayment,pay_now_with_extras:Number((c+o).toFixed(2)),pay_later_with_extras:Number(u.toFixed(2))}:{...i?.policyPayment,pay_now_with_extras:Number(i?.policyPayment?.pay_now||0),pay_later_with_extras:Number(i?.policyPayment?.pay_later||0)}},converted:r!==a?{...s,extras_subtotal:l?Number(Number((Number(t?.subtotalExtras)*n).toFixed(2)).toFixed(2)):0,extras_taxes:l?Number(Number((Number(t?.taxesExtras)*n).toFixed(2)).toFixed(2)):0,extras_total:l?Number(Number((Number(t?.totalExtras)*n).toFixed(2)).toFixed(2)):0,currency:a,subtotal_with_extras:l?Number(Number(Number(s?.subtotal)+Number((Number(t?.subtotalExtras)*n).toFixed(2))).toFixed(2)):Number(0),taxes_with_extras:l?Number(Number(Number(s?.taxes_inclusive)+Number((Number(t?.taxesExtras)*n).toFixed(2))).toFixed(2)):Number(0),total_with_extras:l?Number(Number(Number((Number(t?.totalExtras)*n).toFixed(2))+Number(s?.total)).toFixed(2)):Number(0),policyPayment:l?{...s?.policyPayment,pay_now_with_extras:Number((m+d).toFixed(2)),pay_later_with_extras:Number(p.toFixed(2))}:{...s?.policyPayment,pay_now_with_extras:Number(s?.policyPayment?.pay_now||0),pay_later_with_extras:Number(s?.policyPayment?.pay_later||0)}}:null}}({totals:t?.totals,priceCheck:y,requestCurrency:i,currency:l,currentCurrencyConversionRate:c});return{zaviaTotals:y,formattedZaviaTotals:f,extras:u}}async function e4({website:e,currentReservation:r}
1){let{zaviaTotals:a,formattedZaviaTotals:n,extras:s}=await e6({website:e,currentReservation:r});return(0,t.jsx)(eZ,{website:e,currentReservation:r,totalsExtras:n,zaviaTotals:a,extras:s})}var e5=e.i(899237),e3=e.i(441571),e7=e.i(70363);function e9(){let e=(0,b.useParams)(),r=(0,b.usePathname)(),a=(0,b.useSearchParams)(),n="es"===e.locale,s=(0,e7.getBuilderPreviewHref)({href:`/guest/reservation?itineraryId=${e7.BUILDER_PREVIEW_ITINERARY_ID}`,pathname:r,locale:e.locale,searchParams:a});return(0,t.jsxs)(e3.Card,{className:"space-y-5 border p-5",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3 rounded-md border border-blue-200 bg-blue-50 p-3 text-blue-950",children:[(0,t.jsx)(e5.ShieldCheckIcon,{className:"mt-0.5 h-5 w-5 shrink-0"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-semibold",children:n?"Vista previa segura":"Safe preview"}),(0,t.jsx)("p",{className:"text-sm opacity-80",children:n?"Puedes probar este formulario. No se realizará ningún cargo ni reservación.":"You can test this form. No charge or reservation will be created."})]})]}),(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-2 md:col-span-2",children:[(0,t.jsx)(P.Label,{children:n?"Número de tarjeta":"Card number"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(L.CreditCardIcon,{className:"absolute left-3 top-3 h-4 w-4 opacity-50"}),(0,t.jsx)(eg.Input,{className:"pl-9",placeholder:"4242 4242 4242 4242"})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(P.Label,{children:n?"Vencimiento":"Expiration"}),(0,t.jsx)(eg.Input,{placeholder:"12 / 30"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(P.Label,{children:"CVC"}),(0,t.jsx)(eg.Input,{placeholder:"123"})]})]}),(0,t.jsx)(k.Button,{asChild:!0,className:"w-full",children:(0,t.jsx)(et.default,{href:s,children:n?"Completar reservación de prueba":"Complete preview reservation"})})]})}e.s(["default",0,function({component:e,website:l}){let o=(0,r.default)(e,l),c=l?.currentReservation,u=c?.status==="timed_out";return(0,t.jsxs)("section",{...(0,a.blockCustomStyleProps)(e,"root"),className:"w-full py-4 bg-background text-foreground",style:o,children:[(0,t.jsxs)(n.default,{...(0,a.blockCustomStyleProps)(e,"container"),className:"flex flex-col gap-4 max-w-4xl md:px-0",children:[u?(0,t.jsx)(i.default,{}):(0,t.jsx)(s.default,{currentReservation:c,stopCountdown:l.builderPreview}),!u&&l.builderPreview&&(0,t.jsx)(e9,{}),!u&&!l.builderPreview&&(0,t.jsxs)(t.Fragment,{children:[l?.property?.type==="engine"&&(0,t.jsx)(eF,{website:l,currentReservation:c}),l?.property?.type==="expedia"&&(0,t.jsx)(eD,{website:l,currentReservation:c}),l?.property?.type==="zavia"&&(l.zaviaCheckoutPaymentPayload?(0,t.jsx)(eZ,{website:l,currentReservation:c,totalsExtras:l.zaviaCheckoutPaymentPayload.formattedZaviaTotals,zaviaTotals:l.zaviaCheckoutPaymentPayload.zaviaTotals,extras:l.zaviaCheckoutPaymentPayload.extras}):(0,t.jsx)(e4,{website:l,currentReservation:c}))]})]}),(0,t.jsx)(e$,{website:l})]})}],68530)},898547,(e,t,r)=>{var a=e.i(247167);e.r(516015);var n=e.r(271645),s=n&&"object"==typeof n&&"default"in n?n:{default:n},i=void 0!==a.default&&a.default.env&&!0,l=function(e){return"[object String]"===Object.prototype.toString.call(e)},o=function(){function e(e){var t=void 0===e?{}:e,r=t.name,a=void 0===r?"stylesheet":r,n=t.optimizeForSpeed,s=void 0===n?i:n;c(l(a),"`name` must be a string"),this._name=a,this._deletedRulePlaceholder="#"+a+"-deleted-rule____{}",c("boolean"==typeof s,"`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=s,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var o="u">typeof window&&document.querySelector('meta[property="csp-nonce"]');this._nonce=o?o.getAttribute("content"):null}var t,r=e.prototype;return r.setOptimizeForSpeed=function(e){c("boolean"==typeof e,"`setOptimizeForSpeed` accepts a boolean"),c(0===this._rulesCount,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=e,this.inject()},r.isOptimizeForSpeed=function(){return this._optimizeForSpeed},r.inject=function(){var e=this;if(c(!this._injected,"sheet already injected"),this._injected=!0,"u">typeof window&&this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.get
1Sheet(),this._optimizeForSpeed||(i||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(t,r){return"number"==typeof r?e._serverSheet.cssRules[r]={cssText:t}:e._serverSheet.cssRules.push({cssText:t}),r},deleteRule:function(t){e._serverSheet.cssRules[t]=null}}},r.getSheetForTag=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]},r.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},r.insertRule=function(e,t){if(c(l(e),"`insertRule` accepts only strings"),"u"<typeof window)return"number"!=typeof t&&(t=this._serverSheet.cssRules.length),this._serverSheet.insertRule(e,t),this._rulesCount++;if(this._optimizeForSpeed){var r=this.getSheet();"number"!=typeof t&&(t=r.cssRules.length);try{r.insertRule(e,t)}catch(t){return i||console.warn("StyleSheet: illegal rule: \n\n"+e+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),-1}}else{var a=this._tags[t];this._tags.push(this.makeStyleTag(this._name,e,a))}return this._rulesCount++},r.replaceRule=function(e,t){if(this._optimizeForSpeed||"u"<typeof window){var r="u">typeof window?this.getSheet():this._serverSheet;if(t.trim()||(t=this._deletedRulePlaceholder),!r.cssRules[e])return e;r.deleteRule(e);try{r.insertRule(t,e)}catch(a){i||console.warn("StyleSheet: illegal rule: \n\n"+t+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),r.insertRule(this._deletedRulePlaceholder,e)}}else{var a=this._tags[e];c(a,"old rule at index `"+e+"` not found"),a.textContent=t}return e},r.deleteRule=function(e){if("u"<typeof window)return void this._serverSheet.deleteRule(e);if(this._optimizeForSpeed)this.replaceRule(e,"");else{var t=this._tags[e];c(t,"rule at index `"+e+"` not found"),t.parentNode.removeChild(t),this._tags[e]=null}},r.flush=function(){this._injected=!1,this._rulesCount=0,"u">
1typeof window?(this._tags.forEach(function(e){return e&&e.parentNode.removeChild(e)}),this._tags=[]):this._serverSheet.cssRules=[]},r.cssRules=function(){var e=this;return"u"<typeof window?this._serverSheet.cssRules:this._tags.reduce(function(t,r){return r?t=t.concat(Array.prototype.map.call(e.getSheetForTag(r).cssRules,function(t){return t.cssText===e._deletedRulePlaceholder?null:t})):t.push(null),t},[])},r.makeStyleTag=function(e,t,r){t&&c(l(t),"makeStyleTag accepts only strings as second parameter");var a=document.createElement("style");this._nonce&&a.setAttribute("nonce",this._nonce),a.type="text/css",a.setAttribute("data-"+e,""),t&&a.appendChild(document.createTextNode(t));var n=document.head||document.getElementsByTagName("head")[0];return r?n.insertBefore(a,r):n.appendChild(a),a},t=[{key:"length",get:function(){return this._rulesCount}}],function(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}(e.prototype,t),e}();function c(e,t){if(!e)throw Error("StyleSheet: "+t+".")}var u=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return t>>>0},d={};function m(e,t){if(!t)return"jsx-"+e;var r=String(t),a=e+r;return d[a]||(d[a]="jsx-"+u(e+"-"+r)),d[a]}function p(e,t){"u"<typeof window&&(t=t.replace(/\/style/gi,"\\/style"));var r=e+t;return d[r]||(d[r]=t.replace(/__jsx-style-dynamic-selector/g,e)),d[r]}var h=function(){function e(e){var t=void 0===e?{}:e,r=t.styleSheet,a=void 0===r?null:r,n=t.optimizeForSpeed,s=void 0!==n&&n;this._sheet=a||new o({name:"styled-jsx",optimizeForSpeed:s}),this._sheet.inject(),a&&"boolean"==typeof s&&(this._sheet.setOptimizeForSpeed(s),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var t=e.prototype;return t.add=function(e){var t=this;void 0===this._optimizeForSpeed&&(this._optimizeForSpeed=Array.isArray(e.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),"u">typeof window&&!this._fromServer&&(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(e,t){return e[t]=0,e},{}));var r=this.getIdAndRules(e),a=r.styleId,n=r.rules;if(a in this._instancesCounts){this._instancesCounts[a]+=1;return}var s=n.map(function(e){return t._sheet.insertRule(e)}).filter(function(e){return -1!==e});this._indices[a]=s,this._instancesCounts[a]=1},t.remove=function(e){var t=this,r=this.getIdAndRules(e).styleId;if(function(e,t){if(!e)throw Error("StyleSheetRegistry: "+t+".")}(r in this._instancesCounts,"styleId: `"+r+"` not found"),this._instancesCounts[r]-=1,this._instancesCounts[r]<1){var a=this._fromServer&&this._fromServer[r];a?(a.parentNode.removeChild(a),delete this._fromServer[r]):(this._indices[r].forEach(function(e){return t._sheet.deleteRule(e)}),delete this._indices[r]),delete this._instancesCounts[r]}},t.update=function(e,t){this.add(t),this.remove(e)},t.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},t.cssRules=function(){var e=this,t=this._fromServer?Object.keys(this._fromServer).map(function(t){return[t,e._fromServer[t]]}):[],r=this._sheet.cssRules();return t.concat(Object.keys(this._indices).map(function(t){return[t,e._indices[t].map(function(e){return r[e].cssText}).join(e._optimizeForSpeed?"":"\n")]}).filter(function(e){return!!e[1]}))},t.styles=function(e){var t,r;return t=this.cssRules(),void 0===(r=e)&&(r={}),t.map(function(e){var t=e[0],a=e[1];return s.default.createElement("style",{id:"__"+t,key:"__"+t,nonce:r.nonce?r.nonce:void 0,dangerouslySetInnerHTML:{__html:a}})})},t.getIdAndRules=function(e){var t=e.children,r=e.dynamic,a=e.id;if(r){var n=m(a,r);return{styleId:n,rules:Array.isArray(t)?t.map(function(e){return p(n,e)}):[p(n,t)]}}return{styleId:m(a),rules:Array.isArray(t)?t:[t]}},t.selectFromServer=function(){return Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]')).reduce(function(e,t){return e[t.id.slice(2)]=t,e},{})},e}(),y=n.createContext(null);function f(){return new h}function x(){return n.useContext(y)}y.displayName="StyleSheetContext";var _=s.default.useInsertionEffect||s.default.useLayoutEffect,g="u">typeof window?f():void 0;function v(e){var t=g||x();return t&&("u"<typeof window?t.add(e):_(function(){return t.add(e),function(){t.remove(e)}},[e.id,String(e.dynamic)])),null}v.dynamic=function(e){return e.map(function(e){return m(e[0],e[1])}).join(" ")},r.StyleRegistry=function(e){var t=e.registry,r=e.children,a=n.useContext(y),i=n.useState(function(){return a||t||f()})[0];return s.default.createElement(y.Provider,{value:i},r)},r.createStyleRegistry=f,r.style=v,r.useStyleRegistry=x},437902,(e,t,r)=>{t.exports=e.r(898547).style}]);
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.