import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{Mi as r,ki as s}from"./vendor-frame-CwiylG4Y.js";import{ph as t}from"./shared-1-3-6x7RKF.js";import{Ao as a}from"./shared-6-Cf_fMhRZ.js";import{rn as n}from"./vendor-all-2-BJdkbLSj.js";import{$ as l}from"./shared-frame-DbQbH4Yr.js";import{Mn as o,On as i,in as c,wn as d}from"./shared-8-C1HP2d2B.js";var u=e(r()),m=s(),p={"--row-hover":"hsl(from var(--cds-neutral-900) h s l / 2.5%)"},f=(0,u.memo)(function({value:e}){const r=n();if("string"==typeof e)return(0,m.jsx)("span",{className:"text-body text-primary",children:e});const s=e?r.formatMessage({defaultMessage:"Yes",id:"a5msuh5ORp"}):r.formatMessage({defaultMessage:"No",id:"oUWADlOjJt"});return(0,m.jsxs)("span",{className:"inline-flex items-center",children:[(0,m.jsx)(l,{name:e?"Check":"X",size:"md","aria-hidden":!0,className:e?"text-success":"text-danger"}),(0,m.jsx)("span",{className:"sr-only",children:s})]})}),h=(0,u.memo)(function({data:e}){const{products:r}=e,s={gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`,...p,borderRadius:d},t=r.reduce((e,r)=>Math.max(e,r.attributes.length),0);return(0,m.jsxs)("div",{className:"relative grid overflow-hidden bg-surface-2 font-ui",style:s,children:[r.map((e,r)=>(0,m.jsxs)("div",{className:"flex min-w-0 flex-col gap-xs px-lg pb-md pt-lg",children:[(0,m.jsx)("span",{className:o,children:e.name}),e.price&&(0,m.jsx)("span",{className:"text-body text-primary",children:e.price})]},`hd-${e.name}-${r}`)),(0,m.jsx)("div",{className:"group/rows contents",children:Array.from({length:t},(e,s)=>(0,m.jsx)("div",{className:"group/row contents",children:r.map((e,r)=>{const a=e.attributes[s];return(0,m.jsx)("div",{className:"min-w-0 border-t px-lg pt-md group-hover/row:bg-[var(--row-hover)] "+(s===t-1?"pb-lg":"pb-md"),children:(0,m.jsx)("div",{className:"flex flex-col gap-xs group-hover/rows:opacity-50 group-hover/row:!opacity-100",children:a&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("span",{className:"text-footnote text-secondary",children:a.label}),(0,m.jsx)(f,{value:a.value})]})})},`a-${s}-${r}`)})},`r-${s}`))}),(0,m.jsx)(i,{})]})});function x(e){return"string"==typeof e?e:void 0}function g(e){if(!e||"object"!=typeof e)return null;const r=e,s=x(r.label),t="boolean"==typeof r.value?r.value:x(r.value);return s&&void 0!==t&&""!==t?{label:s,value:t}:null}function j(e){if(!e||"object"!=typeof e)return null;const r=e,s=x(r.name);if(!s)return null;const t=Array.isArray(r.attributes)?r.attributes.map(g).filter(e=>null!==e).slice(0,8):[];return{name:s,price:x(r.price),attributes:t,url:x(r.url)}}var v=(0,u.memo)(function(){return(0,m.jsx)("div",{className:"grid grid-cols-3 gap-4 bg-surface-2 p-lg font-ui",style:{borderRadius:d},children:Array.from({length:3},(e,r)=>(0,m.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,m.jsx)(c,{width:"80%",height:22}),(0,m.jsx)(c,{width:"50%",height:14}),(0,m.jsx)(c,{width:"100%",height:56}),(0,m.jsx)(c,{width:"100%",height:56})]},r))})}),y=(0,u.memo)(function({input:e,isStreaming:r,partialJson:s,conversationUuid:n,disableAnalytics:l}){const{shownRef:o,trackRender:i}=a("comparison_card",n,l),c=(0,u.useMemo)(()=>function(e){let r;if("string"==typeof e)try{r=t(e)}catch{return null}else{if(!e||"object"!=typeof e)return null;r=e}if(!r||"object"!=typeof r)return null;const s=r,a=Array.isArray(s.products)?s.products.map(j).filter(e=>null!==e).slice(0,3):[];return 0===a.length?null:{products:a,summary:x(s.summary)}}(s??e),[s,e]);return(0,u.useEffect)(()=>{r||i(c?"rendered":"blank")},[r,c,i]),c?(0,m.jsx)("div",{ref:o,children:(0,m.jsx)(h,{data:c})}):r?(0,m.jsx)(v,{}):null});export{y as default};