import{r,j as e}from"./vendor-react-Dp9pL_Wn.js";import{_ as o,$ as n,a0 as s,a1 as t}from"./index-DhMXk6CR.js";import{Q as i}from"./c6eedc03a-CsEFTfjy.js";import{P as a}from"./cb9398eea-D4LfAUhV.js";import"./vendor-infra-DayZK7Ds.js";import"./vendor-zod-0xcuG3aM.js";import"./vendor-router-qG5OCEmI.js";import"./vendor-intl-D2wGIp4M.js";import"./vendor-base-5_f7mmWg.js";import"./vendor-ant-cds-bBedrtIN.js";import"./vendor-base-ui-DNypCIlh.js";import"./vendor-radix-Ch96tRrt.js";import"./vendor-virtual-DRz8lJfQ.js";import"./vendor-query-BwvgHhJ1.js";import"./vendor-zustand-BeF8W8xk.js";import"./caf7c7e06-DJYXCm3T.js";import"./vendor-lodash-BvMLws5K.js";import"./vendor-icons-CokWnmlw.js";import"./vendor-motion-EDlUw66k.js";import"./c5669b8e4-DFSq88jr.js";import"./vendor-luxon-CZxT8ieM.js";import"./c5f4e1303-CiyIFgnl.js";import"./cbaad2c48-DaP34LG2.js";import"./vendor-growthbook-C66YtMMX.js";import"./vendor-zod-v3-CZy0YPWu.js";import"./c9bc02337-DAknS3Mi.js";function c(r){return"string"==typeof r?r:void 0}function d(r){if(!r||"object"!=typeof r)return null;const e=r,o=c(e.name);return o?{name:o,price:c(e.price),blurb:c(e.blurb),url:c(e.url)}:null}const l=r.memo(function({data:r,disableAnalytics:o,onLearnMore:n,onDomainClick:s,onSourcesInfoOpen:t}){const{products:i}=r;return e.jsx("div",{className:"@container flex w-full flex-col gap-md font-ui",children:e.jsx("div",{className:"grid grid-cols-1 gap-md "+(1===i.length?"":"@[480px]:grid-cols-2"),children:i.map((r,i)=>e.jsx(a,{product:r,widgetType:"featured_card",disableAnalytics:o,onLearnMore:n,onDomainClick:s,onSourcesInfoOpen:t},`${r.name}-${i}`))})})}),u=r.memo(function(){return e.jsx("div",{className:"grid grid-cols-2 gap-md font-ui",children:Array.from({length:2},(r,o)=>e.jsxs("div",{className:"flex flex-col gap-3 bg-surface-2 p-lg",style:{borderRadius:s},children:[e.jsx(t,{width:"70%",height:22}),e.jsx(t,{width:"40%",height:14}),e.jsx(t,{width:"100%",height:48})]},o))})}),m=r.memo(function({input:s,isStreaming:t,partialJson:a,conversationUuid:m,disableAnalytics:p}){const{shownRef:f,trackClick:j,trackRender:g}=o("featured_card",m,p),v=n(),b=r.useMemo(()=>{const r=function(r){let e;if("string"==typeof r)try{e=i(r)}catch{return null}else{if(!r||"object"!=typeof r)return null;e=r}if(!e||"object"!=typeof e)return null;const o=e,n=[],s=[];if(Array.isArray(o.products))for(let t=0;t<o.products.length&&n.length<6;t++){const r=d(o.products[t]);r&&(n.push(r),s.push(t))}return 0===n.length?null:{products:n,sourceIndices:s,summary:c(o.summary)}}(a??s);if(!r)return null;const e=s&&"object"==typeof s?s.products:void 0,o=r.products.map((o,n)=>{const s=e?.[r.sourceIndices[n]];return Array.isArray(s?.images)?{...o,images:s.images}:o});return{...r,products:o}},[a,s]);r.useEffect(()=>{t||g(b?"rendered":"blank")},[t,b,g]);const h=r.useCallback(()=>j("learn_more"),[j]),y=r.useCallback(()=>j("sources_info_open"),[j]),x=r.useCallback(r=>v(r.telemetry),[v]);return b?e.jsx("div",{ref:f,children:e.jsx(l,{data:b,disableAnalytics:p,onLearnMore:h,onDomainClick:x,onSourcesInfoOpen:y})}):t?e.jsx(u,{}):null});export{m as default};
