import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{Mi as s,ki as a}from"./vendor-frame-CwiylG4Y.js";import{ph as t}from"./shared-1-3-6x7RKF.js";import{Ao as l}from"./shared-6-Cf_fMhRZ.js";import{nn as r,rn as i}from"./vendor-all-2-BJdkbLSj.js";import{R as n}from"./shared-frame-DbQbH4Yr.js";import{wa as o}from"./shared-4-6CEyRAHb.js";import{An as c,On as d,Tn as m,in as p,wn as f}from"./shared-8-C1HP2d2B.js";var u=e(s()),h=a(),g="calc((var(--cds-pad-lg) + var(--cds-pad-xl)) / 2)",x=(0,u.memo)(function({data:e,onPageChange:s}){const a=i(),{options:t}=e,[l,r]=(0,u.useState)(0),o=Math.min(l,Math.max(0,t.length-1)),m=t[o],p=(0,u.useCallback)(e=>{r(e),e!==o&&s?.(e)},[o,s]),x=(0,u.useCallback)(()=>p((o-1+t.length)%t.length),[p,o,t.length]),j=(0,u.useCallback)(()=>p((o+1)%t.length),[p,o,t.length]),v=(0,u.useMemo)(()=>Array.from({length:t.length},(e,s)=>()=>p(s)),[t.length,p]);return m?(0,h.jsxs)("div",{className:"@container flex flex-col gap-md font-ui",children:[(0,h.jsxs)("div",{className:"relative flex flex-col overflow-hidden bg-surface-2",style:{borderRadius:f},children:[(0,h.jsx)("div",{className:"grid",children:t.map((e,s)=>(0,h.jsxs)("div",{className:"col-start-1 row-start-1 flex min-w-0 flex-col gap-sm pb-xs pt-lg "+(s===o?"":"invisible"),style:{paddingInline:g},children:[(0,h.jsx)("span",{className:"break-words text-title font-medium text-primary @[480px]:truncate",children:e.title}),e.description&&(0,h.jsx)("span",{className:"text-body text-secondary",children:e.description})]},s))}),(0,h.jsx)("div",{className:"grid px-sm pb-sm pt-lg",children:t.map((e,s)=>{const a=(e.bullets??[]).slice(0,3);return(0,h.jsx)("div",{className:"col-start-1 row-start-1 grid grid-cols-1 content-start @[480px]:grid-cols-3 "+(s===o?"":"invisible"),style:{gap:"var(--cds-pad-sm)"},children:Array.from({length:3},(e,s)=>(0,h.jsx)("div",{className:`rounded bg-neutral ${c} ${a[s]?"":"hidden @[480px]:block"}`,style:{paddingBlock:`calc(${g} - var(--cds-pad-sm))`,paddingInline:`calc(${g} - var(--cds-pad-sm) + 2px)`},children:(0,h.jsx)("span",{className:"break-words @[480px]:line-clamp-3 @[480px]:min-h-[3lh]",children:a[s]??""})},`${a[s]??"pad"}-${s}`))},s)})}),(0,h.jsx)(d,{})]}),t.length>1&&(0,h.jsxs)("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center",children:[(0,h.jsx)(n,{variant:"secondary",icon:"ArrowLeft",iconOnly:!0,tooltip:!1,"aria-label":a.formatMessage({defaultMessage:"Previous option",id:"eTNi1bQmuV"}),onClick:x,className:"justify-self-start"}),(0,h.jsx)("div",{className:"flex items-center gap-xs",children:t.map((e,s)=>(0,h.jsx)("button",{type:"button","aria-current":s===o,"aria-label":a.formatMessage({defaultMessage:"Go to option {n}",id:"NIks2vMYl/"},{n:s+1}),onClick:v[s],className:"size-1.5 rounded-full transition-colors "+(s===o?"bg-fill-primary":"bg-alpha-4")},`${e.title}-${s}`))}),(0,h.jsx)(n,{variant:"secondary",icon:"ArrowRight",iconOnly:!0,tooltip:!1,"aria-label":a.formatMessage({defaultMessage:"Next option",id:"hGtbYjc8dL"}),onClick:j,className:"justify-self-end"})]})]}):null});function j(e){return"string"==typeof e?e:void 0}function v(e){if(!e||"object"!=typeof e)return null;const s=e,a=j(s.title);if(!a)return null;const t=Array.isArray(s.bullets)?s.bullets.map(j).filter(e=>void 0!==e&&e.length>0).slice(0,8):void 0;return{title:a,description:j(s.description),bullets:t&&t.length>0?t:void 0}}var b=(0,u.memo)(function(){return(0,h.jsxs)("div",{className:"flex flex-col gap-4 bg-surface-2 p-lg font-ui",style:{borderRadius:f},children:[(0,h.jsx)(p,{width:"40%",height:22}),(0,h.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,h.jsx)(p,{width:"85%",height:48}),(0,h.jsx)(p,{width:"80%",height:48}),(0,h.jsx)(p,{width:"75%",height:48})]})]})}),y=(0,u.memo)(function({input:e,isStreaming:s,partialJson:a,conversationUuid:i,disableAnalytics:n}){const{shownRef:c,trackClick:d,trackRender:p}=l("options_card",i,n),f=(0,u.useMemo)(()=>function(e){let s;if("string"==typeof e)try{s=t(e)}catch{return null}else{if(!e||"object"!=typeof e)return null;s=e}if(!s||"object"!=typeof s)return null;const a=s,l=Array.isArray(a.options)?a.options.map(v).filter(e=>null!==e).slice(0,8):[];return 0===l.length?null:{title:j(a.title),options:l,summary:j(a.summary)}}(a??e),[a,e]);(0,u.useEffect)(()=>{s||p(f?"rendered":"blank")},[s,f,p]);const g=(0,u.useCallback)(()=>d("page_change"),[d]);return f?(0,h.jsxs)("div",{ref:c,className:"flex flex-col gap-md",children:[(0,h.jsx)(o,{variant:"neutral",className:m,"data-testid":"options-card-disclaimer",children:(0,h.jsx)(r,{defaultMessage:"This is general information, not medical advice. If your symptoms are severe, sudden, or don\u2019t improve, talk to a healthcare professional.",id:"nkEBqIu79z"})}),(0,h.jsx)(x,{data:f,onPageChange:g})]}):s?(0,h.jsx)(b,{}):null});export{y as default};