import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{Mi as s,ki as a}from"./vendor-frame-CwiylG4Y.js";import{ph as l}from"./shared-1-3-6x7RKF.js";import{Ao as t}from"./shared-6-Cf_fMhRZ.js";import{ls as n}from"./shared-5-UQAFGbWu.js";import{An as r,Mn as i,On as o,in as c,wn as d}from"./shared-8-C1HP2d2B.js";var m=e(s()),u=a(),x={height:"var(--cds-pad-md)"},f=(0,m.memo)(function({day:e}){const s=e.stops.some(e=>e.time);return(0,u.jsx)("ol",{role:"list",className:"flex flex-col pb-xl pl-xl pr-xl pt-md",children:e.stops.map((a,l)=>{const t=0===l,n=l===e.stops.length-1;return(0,u.jsxs)("li",{className:"flex gap-md",children:[s&&(0,u.jsx)("span",{className:"flex w-16 shrink-0 items-start justify-end pt-md",children:(0,u.jsx)("span",{className:"flex min-h-6 items-center justify-end text-right text-footnote tabular-nums text-secondary",children:a.time})}),(0,u.jsxs)("div",{className:"flex shrink-0 flex-col items-center",children:[(0,u.jsx)("span",{className:"w-px "+(t?"invisible":"bg-alpha-2"),style:x}),(0,u.jsx)("span",{className:"flex h-6 items-center",children:(0,u.jsx)("span",{className:"size-2 rounded-full bg-alpha-3"})}),(0,u.jsx)("span",{className:"w-px flex-1 "+(n?"invisible":"bg-alpha-2")})]}),(0,u.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-xs pt-md "+(n?"pb-sm":"pb-md"),children:[(0,u.jsx)("span",{className:`flex min-h-6 items-center ${i}`,children:a.name}),a.blurb&&(0,u.jsx)("span",{className:"text-body text-secondary",children:a.blurb})]})]},`${a.name}-${l}`)})})}),p=(0,m.memo)(function({data:e,onDayChange:s}){const a=e.days.length>1,[l,t]=(0,m.useState)(0);(0,m.useEffect)(()=>{l>e.days.length-1&&t(0)},[l,e.days.length]);const r=e.days[l]??e.days[0],i=(0,m.useCallback)(e=>{const a=Number(e);t(a),s?.(a)},[s]);return(0,u.jsxs)("div",{className:"relative overflow-hidden bg-surface-2 font-ui",style:{borderRadius:d},children:[a?(0,u.jsxs)(n.Root,{value:String(l),onValueChange:i,children:[(0,u.jsx)("div",{className:"border-b px-lg pb-[calc(var(--cds-pad-lg)-1px)] pt-lg",children:(0,u.jsx)("div",{className:"-mx-pad-lg -my-2 overflow-x-auto px-lg py-2",children:(0,u.jsx)(n.List,{children:e.days.map((e,s)=>(0,u.jsx)(n.Tab,{value:String(s),children:e.day_label||`Day ${s+1}`},`${e.day_label}-${s}`))})})}),(0,u.jsx)(n.Panel,{value:String(l),children:(0,u.jsx)(f,{day:r})})]}):(0,u.jsx)(f,{day:r}),(0,u.jsx)(o,{})]})});function h(e){return"string"==typeof e?e:void 0}function y(e){if(!e||"object"!=typeof e)return null;const s=e,a=h(s.name);return a?{name:a,time:h(s.time),blurb:h(s.blurb)}:null}function j(e){if(!e||"object"!=typeof e)return null;const s=e,a=Array.isArray(s.stops)?s.stops.map(y).filter(e=>null!==e).slice(0,12):[];return 0===a.length?null:{day_label:h(s.day_label)??"",stops:a}}var b=(0,m.memo)(function(){return(0,u.jsxs)("div",{className:"flex flex-col gap-4 bg-surface-2 p-lg font-ui",style:{borderRadius:d},children:[(0,u.jsx)(c,{width:"40%",height:22}),(0,u.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,u.jsx)(c,{width:"85%",height:48}),(0,u.jsx)(c,{width:"80%",height:48}),(0,u.jsx)(c,{width:"75%",height:48})]})]})}),g=(0,m.memo)(function({input:e,isStreaming:s,partialJson:a,conversationUuid:n,disableAnalytics:r}){const{shownRef:i,trackClick:o,trackRender:c}=t("itinerary",n,r),d=(0,m.useMemo)(()=>function(e){let s;if("string"==typeof e)try{s=l(e)}catch{return null}else{if(!e||"object"!=typeof e)return null;s=e}if(!s||"object"!=typeof s)return null;const a=s,t=Array.isArray(a.days)?a.days.map(j).filter(e=>null!==e).slice(0,7):[];return 0===t.length?null:{title:h(a.title),days:t,summary:h(a.summary)}}(a??e),[a,e]);(0,m.useEffect)(()=>{s||c(d?"rendered":"blank")},[s,d,c]);const x=(0,m.useCallback)(()=>o("day_tab"),[o]);return d?(0,u.jsx)("div",{ref:i,children:(0,u.jsx)(p,{data:d,onDayChange:x})}):s?(0,u.jsx)(b,{}):null});export{g as default};