1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[951],{18513:(e,t,n)=>{n.d(t,{VA:()=>g.V,pp:()=>m,Mf:()=>eF});var r=n(70862),s=n(18526),a=n(5859),i=n(50246),l=n(99049),o=n(49432);let c=[{src:"/images/cards/sailcard.png",alt:"Sailboat",bg:"#ffd18c"},{src:"/images/cards/brickcard.png",alt:"Brick building",bg:"#6bc7b5"},{src:"/images/cards/drillcard.png",alt:"Power drill",bg:"#8270ff"}],d=[{rotation:-22,xPct:-.38,yBefore:20,z:1},{rotation:-12,xPct:-.15,yBefore:15,z:2},{rotation:5,xPct:.12,yBefore:10,z:3}];function u(e){let{className:t}=e,[n,i]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=setTimeout(()=>i(!0),400);return()=>clearTimeout(e)},[]);let u="clamp(72px, 14vw, 110px)";return(0,r.jsx)("div",{className:(0,l.cn)("relative w-full flex items-center justify-center",t),style:{height:200},children:(0,r.jsx)("div",{className:"relative",style:{width:u,height:u},children:c.map((e,t)=>{let s=d[t];return(0,r.jsx)(a.P.div,{className:"absolute inset-0 will-change-transform",style:{zIndex:s.z},initial:{x:0,y:s.yBefore,rotate:s.rotation/2,scale:.8+.05*t,opacity:0},animate:n?{x:"calc(".concat(s.xPct," * ").concat(u,")"),y:0,rotate:s.rotation,scale:1,opacity:1}:{x:0,y:s.yBefore,rotate:s.rotation/2,scale:.8+.05*t,opacity:0},transition:{type:"spring",stiffness:300,damping:20,delay:.08*t,opacity:{duration:.3,delay:.06*t}},children:(0,r.jsx)("div",{className:"rounded-[16%] bg-white shadow-lg overflow-hidden",style:{padding:"2px",boxShadow:"0 ".concat(4+2*t,"px ").concat(6+4*t,"px rgba(0,0,0,").concat(.15+.05*t,")")},children:(0,r.jsx)("div",{className:"rounded-[14%] overflow-hidden relative",style:{width:"100%",aspectRatio:"1",backgroundColor:e.bg},children:(0,r.jsx)(o.default,{src:e.src,alt:e.alt,fill:!0,sizes:"(max-width: 640px) 80px, 110px",className:"object-cover",priority:t<3})})})},t)})})})}function m(e){let{className:t}=e,[n,o]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{let e=()=>{o(window.innerHeight>=520)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,r.jsxs)(a.P.div,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.4,ease:"easeOut"},className:(0,l.cn)("flex flex-col items-center justify-center text-center",t),children:[(0,r.jsx)(i.N,{children:n&&(0,r.jsx)(a.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20,height:0,marginBottom:0},transition:{duration:.3,ease:"easeOut"},className:"w-full mb-6",children:(0,r.jsx)(u,{})})}),(0,r.jsx)(a.P.h1,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:n?.25:.1,duration:.4},className:"relative z-20 text-xl sm:text-2xl md:text-3xl font-semibold tracking-tight atlas-gradient text-balance px-4 sm:px-6",children:"What can we help you build or fix?"})]})}var g=n(80402),p=n(61446);let h=s.forwardRef((e,t)=>{let{className:n,children:a,onScrollChange:i,viewportRef:o,...c}=e,d=s.useRef(null),u=s.useCallback(e=>{d.current=e,o&&(o.current=e)},[o]);return s.useEffect(()=>{let e=d.current;if(!e||!i)return;let t=()=>{i(e.scrollTop)};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[i]),(0,r.jsxs)(p.bL,{ref:t,className:(0,l.cn)("relative overflow-hidden",n),...c,children:[(0,r.jsx)(p.LM,{ref:u,className:"h-full w-full rounded-[inherit]",children:a}),(0,r.jsx)(f,{}),(0,r.jsx)(p.OK,{})]})});h.displayName=p.bL.displayName;let f=s.forwardRef((e,t)=>{let{className:n,orientation:s="vertical",...a}=e;return(0,r.jsx)(p.VM,{ref:t,orientation:s,className:(0,l.cn)("touch-none select-none transition-colors","hidden sm:flex","vertical"===s&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===s&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",n),...a,children:(0,r.jsx)(p.lr,{className:"relative flex-1 rounded-full bg-border"})})});f.displayName=p.VM.displayName;var x=n(34205);let v={"electrical-panel":"Electrical Panel Assessment","electrical-safety":"Electrical Safety Assessment","hvac-system":"HVAC System Assessment","ductwork-airflow":"Ductwork & Airflow Assessment","water-damage":"Water Damage Assessment","water-heater":"Water Heater Assessment","roof-damage":"Roof Damage Assessment","plumbing-issue":"Plumbing Assessment","foundation-cracks":"Foundation Assessment","siding-damage":"Siding Damage Assessment","solar-panel":"Solar Panel Assessment","energy-efficiency":"Energy Efficiency Assessment","fireplace-chimney":"Chimney & Fireplace Assessment","appliance-diagnosis":"Appliance Assessment","pipeline-corrosion":"Pipeline Corrosion Assessment","garage-door":"Garage Door Assessment","septic-system":"Septic System Assessment","well-system":"Well System Assessment","pool-spa-equipment":"Pool & Spa Assessment","termite-damage":"Termite Damage Assessment","pre-renovation":"Pre-Renovation Assessment","flood-documentation":"Flood Documentation Assessment","smoke-co-compliance":"Smoke/CO Compliance Assessment","gutter-downspout":"Gutter & Downspout Assessment","window-door-leak":"Window & Door Assessment","drainage-grading":"Drainage & Grading Assessment","tank-inspection":"Tank Inspection Assessment","valve-leak-detection":"Valve Leak Assessment","conveyor-belt":"Conveyor Belt Assessment","haul-truck-inspection":"Haul Truck Assessment","site-equipment":"Site Equipment Assessment","tailings-dam":"Tailings Dam Assessment","cell-tower-structural":"Cell Tower Assessment","fiber-splice-enclosure":"Fiber Splice Assessment"};var b=n(3912),y=n(79589);let w={flash:y.gXB,"shield-flash":y.cz_,thermometer:y.cqn,"air-vent":y.TKe,droplet:y.oXG,"water-heater":y.cqn,wrench:y.UE1,"home-roof":y.wfd,foundation:y.oDY,siding:y.wfd,window:y.wfd,garage:y.$tJ,gutter:y.wfd,solar:y.vIz,energy:y.vIz,flame:y.Y3C,"smoke-alarm":y.cz_,flood:y.oXG,drainage:y.oXG,septic:y.UE1,well:y.oXG,pool:y.oXG,bug:y.Fbp,appliance:y.UE1,renovation:y.wfd,pipeline:y.hjv,tank:y.hjv,valve:y.UE1,conveyor:y.hjv,truck:y.X3C,equipment:y.UE1,dam:y.zrb,"signal-tower":y.eFm,fiber:y.eFm,assessment:y.uiJ,report:y.hhb},j={"electrical-panel":y.gXB,"electrical-safety":y.cz_,"hvac-system":y.cqn,"ductwork-airflow":y.TKe,"water-damage":y.oXG,"roof-damage":y.wfd,"plumbing-issue":y.UE1,"pipeline-corrosion":y.hjv,"appliance-diagnosis":y.UE1,"solar-panel":y.vIz,"fireplace-chimney":y.Y3C},k=y.uiJ;function N(e){let{assessmentId:t,iconKey:n,size:s=18,className:a}=e,i=n&&w[n]||t&&j[t]||k;return(0,r.jsx)(b.n,{icon:i,size:s,className:(0,l.cn)("shrink-0",a),"aria-hidden":!0})}let _={electrical:"text-amber-500",hvac:"text-sky-500",plumbing:"text-blue-500",roofing:"text-orange-600",structural
1:"text-stone-600","water-damage":"text-blue-400","fire-safety":"text-red-500","pest-control":"text-lime-600",energy:"text-green-500",solar:"text-yellow-500",industrial:"text-slate-500","oil-gas":"text-slate-600",mining:"text-amber-700",telecom:"text-violet-500",appliances:"text-teal-500","pool-spa":"text-cyan-500","general-contracting":"text-stone-500",general:"text-[hsl(var(--success))]"};function S(e){return _[e||""]||_.general}var C=n(64086),L=n(17169),A=n(40660);function z(e){let{attachment:t,className:n}=e,[a,i]=(0,s.useState)("idle"),o=(0,s.useCallback)(async()=>{if("idle"===a&&t.file){i("uploading");try{await A.F.uploadFile(t.file,{displayName:t.name}),i("done")}catch(e){i("error"),setTimeout(()=>i("idle"),2e3)}}},[t,a]);return"done"===a?(0,r.jsxs)("span",{className:(0,l.cn)("flex items-center gap-1 text-[10px] text-accent font-medium",n),children:[(0,r.jsx)(b.n,{icon:y.XL2,size:12}),"Added to KB"]}):(0,r.jsxs)("button",{onClick:o,disabled:"uploading"===a||!t.file,className:(0,l.cn)("flex items-center gap-1 text-[10px] font-medium transition-colors rounded px-1 py-0.5","uploading"===a?"text-muted-foreground cursor-wait":"error"===a?"text-destructive":"text-muted-foreground hover:text-accent hover:bg-accent/10",n),title:"Save to your knowledge base for future conversations",children:[(0,r.jsx)(b.n,{icon:y.TYE,size:10}),"uploading"===a?"Addingâ¦":"error"===a?"Failed":"Add to KB"]})}function I(e){let{attachment:t,className:n}=e,s=(0,L.hL)(t.name,t.mimeType),a=(0,L.v7)(t.size),i=a?"".concat(s.subtitle," \xb7 ").concat(a):s.subtitle;return(0,r.jsxs)("div",{className:(0,l.cn)("group/file relative flex items-center gap-3 w-full max-w-[320px] min-w-[220px]","rounded-2xl border border-border bg-card pl-2.5 pr-3 py-2.5 shadow-soft",n),role:"group","aria-label":"".concat(s.kindLabel,", ").concat(t.name),children:[(0,r.jsx)("div",{className:(0,l.cn)("flex h-11 w-11 shrink-0 items-center justify-center rounded-xl","shadow-sm",s.gradientClass,s.badgeForeground),"aria-hidden":!0,children:(0,r.jsx)("span",{className:(0,l.cn)("font-extrabold tracking-tight leading-none",s.abbreviation.length>4?"text-[9px]":"text-[11px]"),children:s.abbreviation})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"truncate text-[13px] font-semibold text-foreground",title:t.name,children:t.name}),(0,r.jsx)("p",{className:"truncate text-[11px] text-muted-foreground",children:i})]}),t.file&&(0,r.jsx)(z,{attachment:t,className:"shrink-0 opacity-0 group-hover/file:opacity-100 focus-visible:opacity-100 transition-opacity"})]})}var E=n(20918),F=n(31331),P=n(22765),T=n(70762);let R=(0,s.createContext)(null),M=R.Provider;function q(e){let{open:t,defaultOpen:n,onOpenChange:s,isStreaming:a=!1,durationSeconds:i=0,children:o,className:c,...d}=e,u=i>0?i<60?"".concat(i,"s"):"".concat(Math.floor(i/60),"m ").concat(i%60,"s"):null;return(0,r.jsx)(M,{value:{onOpenChange:null!=s?s:()=>{},isStreaming:a,durationSeconds:i,formattedDuration:u},children:(0,r.jsx)(T.bL,{open:t,defaultOpen:n,onOpenChange:s,className:(0,l.cn)("group w-full",c),...d,children:o})})}function B(e){var t,n;let{children:a,label:i,leftIcon:o,showChevron:c=!0,className:d,...u}=e,m=(0,s.useContext)(R),g=null!=(t=null==m?void 0:m.isStreaming)&&t,p=null!=(n=null==m?void 0:m.formattedDuration)?n:null,h=g?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"Searching"}),p&&(0,r.jsxs)("span",{className:"text-xs font-normal text-muted-foreground/70 tabular-nums ml-1",children:["for ",p]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:null!=i?i:"Chain of Thought"}),p&&(0,r.jsxs)("span",{className:"text-xs font-normal opacity-70 ml-1",children:["for ",p]})]});return(0,r.jsxs)(T.l9,{className:(0,l.cn)("group w-full flex items-center gap-2 py-1.5","text-sm font-medium text-muted-foreground","cursor-pointer rounded-sm hover:text-foreground/80 transition-colors",d),...u,children:[null!=o&&(0,r.jsx)("span",{className:"inline-flex size-6 min-w-6 min-h-6 items-center justify-center shrink-0 overflow-visible",children:o}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[null!=a?a:h,c&&null==a&&(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:(0,l.cn)("shrink-0 transition-transform duration-200","group-data-[state=open]:rotate-90"),"aria-hidden":!0,
1children:(0,r.jsx)("path",{d:"M9 18l6-6-6-6"})})]})]})}function U(e){let{children:t,className:n,...s}=e;return(0,r.jsx)(T.UC,{className:(0,l.cn)("data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down","overflow-hidden",n),...s,children:t})}let D={complete:"text-muted-foreground",active:"text-foreground/90",pending:"text-muted-foreground/60"};function O(e){let{label:t,description:n,status:s="complete",icon:a,className:i,children:o}=e;return(0,r.jsxs)("div",{className:(0,l.cn)("flex gap-3 text-sm animate-fade-in relative",D[s],i),children:[(0,r.jsx)("span",{className:"shrink-0 flex items-start pt-[2px] justify-center w-2 relative z-10",children:null!=a?a:(0,r.jsx)("span",{className:(0,l.cn)("size-1.5 rounded-full mt-1 ring-2 ring-background","complete"===s&&"bg-muted-foreground","active"===s&&"bg-foreground animate-pulse","pending"===s&&"bg-muted-foreground")})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 space-y-1 pb-1",children:[(0,r.jsx)("div",{className:(0,l.cn)("font-medium","active"===s&&"font-semibold"),children:t}),null!=n&&""!==n&&(0,r.jsx)("div",{className:"text-muted-foreground text-sm leading-relaxed",children:n}),o]})]})}function V(e){let{children:t,className:n,...s}=e;return(0,r.jsx)("div",{className:(0,l.cn)("flex flex-wrap gap-1.5",n),...s,children:t})}function Q(e){let{children:t,className:n,...s}=e;return(0,r.jsx)("span",{className:(0,l.cn)("inline-flex items-center px-2 py-0.5 rounded-md","text-xs font-medium text-muted-foreground","bg-muted/80 border border-border/50",n),...s,children:t})}function K(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14;return function(n){let{className:s}=n;return(0,r.jsx)(b.n,{icon:e,size:t,className:(0,l.cn)("shrink-0",s),"aria-hidden":!0})}}n(57068);let G={electrical:{short:"Electrician",Icon:K(y.apx),runningVerb:"working",doneVerb:"finished"},plumbing:{short:"Plumber",Icon:K(y.bsN),runningVerb:"working",doneVerb:"finished"},hvac:{short:"HVAC specialist",Icon:K(y.Q5K),runningVerb:"working",doneVerb:"finished"},"general-contracting":{short:"General contractor",Icon:K(y.NVp),runningVerb:"working",doneVerb:"finished"},general_contracting:{short:"General contractor",Icon:K(y.NVp),runningVerb:"working",doneVerb:"finished"},code_compliance:{short:"Code compliance",Icon:K(y.F8Z),runningVerb:"reviewing",doneVerb:"complete"},web_research:{short:"Web research",Icon:K(y.FuU),runningVerb:"researching",doneVerb:"done"},research:{short:"Research",Icon:K(y.Bbl),runningVerb:"researching",doneVerb:"done"},code:{short:"Code",Icon:K(y.loI),runningVerb:"coding",doneVerb:"done"},vision:{short:"Vision",Icon:K(y.ExN),runningVerb:"analyzing",doneVerb:"done"},specialty_vision:{short:"Vision",Icon:K(y.ExN),runningVerb:"analyzing",doneVerb:"done"}};function H(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14;return function(n){let{className:s}=n;return(0,r.jsx)(b.n,{icon:e,size:t,className:(0,l.cn)("shrink-0",s),"aria-hidden":!0})}}let W={google_search:{runningLabel:"Searching the web",completeLabel:"Searched the web",Icon:H(y.Bbl)},web_search:{runningLabel:"Searching the web",completeLabel:"Searched the web",Icon:H(y.Bbl)},google_drive__search_drive_files:{runningLabel:"Searching Google Drive",completeLabel:"Searched Google Drive",Icon:H(y.e$2)},google_drive__get_drive_file_content:{runningLabel:"Reading from Google Drive",completeLabel:"Read from Google Drive",Icon:H(y.JS8)},delegate_to_claude:{runningLabel:"Deploying specialist subagent",completeLabel:"Completed specialist subagent",Icon:H(y.mHh)},sandbox_execute:{runningLabel:"Running code",completeLabel:"Ran code",Icon:H(y.loI)},browser_automation:{runningLabel:"Browsing the web",completeLabel:"Browsed the web",Icon:H(y.Bbl)},query_trade_knowledge:{runningLabel:"Searching knowledge",completeLabel:"Searched knowledge",Icon:H(y.BHf)},lookup_code_section:{runningLabel:"Looking up code section",completeLabel:"Used Lookup Code Section",Icon:H(y.F8Z)},delegate_code_compliance:{runningLabel:"Consulting code compliance specialist",completeLabel:"Code compliance specialist",Icon:H(y.F8Z)},save_user_fact:{runningLabel:"Saving memory",completeLabel:"Saved memory",Icon:H(y.aPY)},ask_questions:{runningLabel:"Preparing clarifying questions",completeLabel:"Prepared clarifying questions",Icon:H(y.pcb)},get_weather:{runningLabel:"Checking weather",completeLabel:"Checked weather",Icon:H(y.WG1)}};
1function X(e){return e.split(" ").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function $(e){let t=function(e,t){var n;let r=null!=(n=function(e){if(e)return e.trim().toLowerCase().replace(/\s+/g,"_")}(e))?n:function(e){if(!e)return;let t=e.toLowerCase();return t.includes("electrician")?"electrical":t.includes("plumber")?"plumbing":t.includes("hvac")?"hvac":t.includes("general contractor")?"general-contracting":t.includes("code compliance")?"code_compliance":t.includes("web research")?"web_research":void 0}(t);if(!r)return null;let s=G[r];if(!s)return null;let a=s.short;return{runningLabel:"".concat(a," ").concat(s.runningVerb,"â¦"),completeLabel:"".concat(a," ").concat(s.doneVerb),Icon:s.Icon}}(e.subagent_type,e.subagent_label);if(t)return t;let n=e.tool_name;if(W[n])return W[n];let r=n.split("__"),s=X((r[0]||n).replace(/_/g," ")),a=X((r[1]||"Using tool").replace(/_/g," "));return{runningLabel:"".concat(a," ").concat(s).trim(),completeLabel:"Used ".concat(s),Icon:H(y.AU2)}}let Y=(0,s.memo)(function(e){var t,n,a,i,o,c,d,u;let{thoughts:m,isStreaming:g=!1,isThinking:p=!1,durationSeconds:h,searchQueries:f,toolCalls:x,grounding:v,thoughtIndex:w,className:j,askQuestions:k,assessments:N=[],artifacts:_=[],kbCitations:S=[],images:C=[]}=e,L=(0,s.useRef)(null!=w?w:Math.floor(256*Math.random())),[A,z]=(0,s.useState)(!1),[I,E]=(0,s.useState)(!1),[T,R]=(0,s.use
1State)(0),M=(0,s.useRef)(null),D=(0,s.useMemo)(()=>{var e;return f&&f.length>0?f:null!=(e=null==v?void 0:v.webSearchQueries)?e:[]},[f,null==v?void 0:v.webSearchQueries]),K=null!=(c=null==k||null==(n=k.payload)||null==(t=n.questions)?void 0:t.length)?c:0,G=K>0||N.length>0||_.length>0||S.length>0||C.length>0,H=!!v&&((null!=(d=null==(a=v.webSearchQueries)?void 0:a.length)?d:0)>0||(null!=(u=null==(i=v.groundingChunks)?void 0:i.length)?u:0)>0),W=D.length>0||x&&x.length>0||!!(null==v||null==(o=v.webSearchQueries)?void 0:o.length)||G,X=!g||!p||W;if((0,s.useEffect)(()=>{if(g){R(0),M.current=Date.now();let e=setInterval(()=>{M.current&&R(Math.floor((Date.now()-M.current)/1e3))},1e3);return()=>clearInterval(e)}M.current=null},[g]),(0,s.useEffect)(()=>{g&&!I&&(z(!0),E(!0)),!g&&I&&(z(!1),E(!1))},[g,I]),!(m.trim().length>0||D.length>0||x&&x.length>0||g||H||G))return null;let Y=(m?m.split("\n").filter(e=>e.trim()):[]).map(e=>{let t=e.trim();return/^\s*\*\*[^*]+\*\*\s*$/.test(t)||t.startsWith("**")&&t.endsWith("**")?{text:e,type:"header"}:/^[â¢Â·]\s*Searched:/i.test(t)||/^Searched:/i.test(t)?{text:e,type:"search"}:{text:e,type:"body"}}),Z=g||void 0===h?T:h,J=function(e){let t=[],n="",r=[];for(let s of e)"search"!==s.type&&("header"===s.type?((n||r.length>0)&&t.push({label:n||"Thinking",description:r.join("\n").trim()}),n=s.text.replace(/^\s*\*\*|\*\*\s*$/g,"").trim(),r=[]):"body"===s.type&&r.push(s.text));return(n||r.length>0)&&t.push({label:n||"Thinking",description:r.join("\n").trim()}),t}(Y),ee=J.length>0,et=(D.length>0||H)&&(g||!!v),en=(0,r.jsxs)(r.Fragment,{children:[K>0&&(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm text-muted-foreground pl-1",children:[(0,r.jsx)(b.n,{icon:y.pcb,size:14,className:"mt-0.5 shrink-0 opacity-80"}),(0,r.jsxs)("span",{className:"min-w-0 leading-relaxed font-normal",children:["Asked clarifying questions",(0,r.jsxs)("span",{className:"text-muted-foreground/80",children:[" \xb7 ",K]})]})]}),N.length>0&&(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm text-muted-foreground pl-1",children:[(0,r.jsx)(b.n,{icon:y.aNM,size:14,className:"mt-0.5 shrink-0 opacity-80"}),(0,r.jsxs)("span",{className:"min-w-0 leading-relaxed font-normal",children:["Offered ",N.length," assessment",1!==N.length?"s":""]})]}),_.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm text-muted-foreground pl-1",children:[(0,r.jsx)(b.n,{icon:"pdf"===e.format?y.B3q:y.gLZ,size:14,className:"mt-0.5 shrink-0 opacity-80"}),(0,r.jsxs)("span",{className:"min-w-0 leading-relaxed font-normal",children:["Built ",e.title]})]},"".concat(e.artifact_id,"-").concat(t))),S.length>0&&(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm text-muted-foreground pl-1",children:[(0,r.jsx)(b.n,{icon:y.BHf,size:14,className:"mt-0.5 shrink-0 opacity-80"}),(0,r.jsxs)("span",{className:"min-w-0 leading-relaxed font-normal",children:["Cited ",S.length," knowledge base file",1!==S.length?"s":""]})]}),C.length>0&&(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm text-muted-foreground pl-1",children:[(0,r.jsx)(b.n,{icon:y.ExN,size:14,className:"mt-0.5 shrink-0 opacity-80"}),(0,r.jsxs)("span",{className:"min-w-0 leading-relaxed font-normal",children:["Found ",C.length," image",1!==C.length?"s":""]})]})]});return(0,r.jsxs)(q,{open:A,onOpenChange:z,isStreaming:g,durationSeconds:Z,className:j,children:[(0,r.jsx)(B,{leftIcon:p?(0,r.jsx)(P.a,{thoughtIndex:L.current,isAnimating:!0}):void 0,label:null,children:(0,r.jsx)("div",{className:"flex flex-col gap-1 flex-1 min-w-0",children:(0,r.jsx)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:p?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"Searching"}),Z>0&&(0,r.jsx)("span",{className:"text-xs font-normal text-muted-foreground/70 tabular-nums",children:Z<60?"".concat(Z,"s"):"".concat(Math.floor(Z/60),"m ").concat(Z%60,"s")})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"Thought"}),Z>0&&(0,r.jsxs)("span",{className:"text-xs font-normal opacity-70",children:["for"," ",Z<60?"".concat(Z,"s"):"".concat(Math.floor(Z/60),"m ").concat(Z%60,"s")]}),(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:(0,l.cn)("shrink-0 transition-transform duration-200",A&&"rotate-90"),"aria-hidden":!0,
1children:(0,r.jsx)("path",{d:"M9 18l6-6-6-6"})})]})})})}),(0,r.jsx)(U,{children:(0,r.jsxs)("div",{className:"pl-1 pb-3 pt-0",children:[X&&et&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pl-5 pb-2 text-sm text-muted-foreground",children:[(0,r.jsx)(b.n,{icon:y.FuU,size:14,className:"shrink-0 opacity-80"}),(0,r.jsx)("span",{className:"font-normal",children:"Searched web"})]}),X?ee?(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"absolute left-[4px] top-2 bottom-2 w-px bg-border/50 z-0"}),(0,r.jsxs)("div",{className:"space-y-1 relative z-10",children:[D.length>0&&(0,r.jsx)("div",{className:"pl-5 pb-2",children:(0,r.jsx)(V,{children:D.map((e,t)=>(0,r.jsx)(Q,{children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(b.n,{icon:y.Bbl,size:12,className:"shrink-0 opacity-70"}),e]})},t))})}),x&&x.length>0&&(0,r.jsx)("div",{className:"pl-5 space-y-1.5 pb-2",children:x.map((e,t)=>{var n;let s=$(e),a="running"===e.status?s.runningLabel:s.completeLabel;return(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm text-muted-foreground pl-1",children:[(0,r.jsx)(s.Icon,{className:"mt-0.5 opacity-80"}),(0,r.jsx)("span",{className:"min-w-0 leading-relaxed font-normal",children:a})]},null!=(n=e.tool_call_id)?n:"".concat(e.tool_name,"-").concat(t))})}),G&&(0,r.jsx)("div",{className:"pl-5 space-y-1.5 pb-2",children:en}),J.map((e,t)=>{let n=t===J.length-1,s=g&&n?"active":"complete";return(0,r.jsx)(O,{label:e.label,status:s,description:e.description?(0,r.jsx)(F.oz,{components:{p:e=>{let{children:t}=e;return(0,r.jsx)("span",{children:t})},strong:e=>{let{children:t}=e;return(0,r.jsx)("strong",{className:"font-semibold text-foreground/90",children:t})},a:e=>{let{href:t,children:n}=e;return(0,r.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:n})}},children:e.description}):void 0},t)})]})]}):(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"absolute left-[4px] top-2 bottom-2 w-px bg-border/50 z-0"}),(0,r.jsxs)("div",{className:"space-y-2 relative z-10",children:[D.length>0&&(0,r.jsx)("div",{className:"pl-5 pb-2",children:(0,r.jsx)(V,{children:D.map((e,t)=>(0,r.jsx)(Q,{children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(b.n,{icon:y.Bbl,size:12,className:"shrink-0 opacity-70"}),e]})},t))})}),x&&x.length>0&&(0,r.jsx)("div",{className:"pl-5 space-y-1.5 pb-2",children:x.map((e,t)=>{var n;let s=$(e),a="running"===e.status?s.runningLabel:s.completeLabel;return(0,r.jsxs)("div",{className:"flex items-start gap-2 pl-1 text-sm text-muted-foreground",children:[(0,r.jsx)(s.Icon,{className:"mt-0.5 opacity-80"}),(0,r.jsx)("span",{className:"font-normal",children:a})]},null!=(n=e.tool_call_id)?n:"".concat(e.tool_name,"-").concat(t))})}),G&&(0,r.jsx)("div",{className:"pl-5 space-y-1.5 pb-2",children:en}),Y.map((e,t)=>{let n="header"===e.type,s="search"===e.type,a="body"===e.type;return(0,r.jsxs)("div",{className:(0,l.cn)("flex gap-3 text-sm animate-fade-in relative",n&&"mt-4 first:mt-0",s&&"text-xs text-muted-foreground/70",a&&"text-muted-foreground leading-relaxed"),style:{animationDelay:"".concat(20*t,"ms")},children:[(0,r.jsx)("span",{className:"shrink-0 flex items-start pt-[2px] justify-center w-2 relative z-10",children:n?(0,r.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground mt-1 ring-2 ring-background"}):s?(0,r.jsx)("span",{className:"size-1 rounded-full bg-border mt-1 ring-2 ring-background"}):(0,r.jsx)("span",{className:"size-0"})}),(0,r.jsx)("div",{className:"min-w-0 flex-1 space-y-1 pb-1",children:(0,r.jsx)("div",{className:(0,l.cn)(n&&"font-semibold text-foreground/90"),children:(0,r.jsx)(F.oz,{components:{p:e=>{let{children:t}=e;return(0,r.jsx)("span",{children:t})},strong:e=>{let{children:t}=e;return(0,r.jsx)("strong",{className:"font-semibold text-foreground/90",children:t})},a:e=>{let{href:t,children:n}=e;return(0,r.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:n})}},children:e.text})})})]},t)})]})]}):null]})})]})});var Z=n(458),J=n(65594);function ee(e){let{question:t,index:n,state:s,onOptionToggle:i,onOtherTextChange:o}=e,{id:c,prompt:d,options:u,allow_multiple:m,allow_other:g,required:p}=t;return(0,r.jsxs)(a.P.div,{initial:{opacity:0,x:-10}
1,animate:{opacity:1,x:0},transition:{delay:.1*n},className:"space-y-3",children:[(0,r.jsxs)("p",{className:"text-sm font-normal text-foreground",children:[d,p&&(0,r.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:u.map(e=>{let t=s.selectedOptions.includes(e.id);return(0,r.jsx)("button",{onClick:()=>i(c,e.id,!!m),className:(0,l.cn)("px-3 py-2 rounded-lg text-sm font-normal","border transition-all duration-200",t?"bg-primary text-primary-foreground border-primary":"bg-background border-border hover:border-foreground/20 hover:bg-muted"),children:e.label},e.id)})}),g&&(0,r.jsx)("input",{type:"text",placeholder:"Other (specify)...",value:s.otherText,onChange:e=>o(c,e.target.value),className:(0,l.cn)("w-full px-3 py-2 rounded-lg text-sm","bg-background border border-border","placeholder:text-muted-foreground","focus:outline-none focus:ring-0 focus:ring-offset-0")}),m&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Select all that apply"})]})}let et=(0,s.memo)(function(e){let{event:t,onSubmit:n,className:i}=e,{tool_call_id:o,payload:c}=t,{title:d,questions:u}=c,[m,g]=(0,s.useState)(()=>u.reduce((e,t)=>({...e,[t.id]:{selectedOptions:[],otherText:""}}),{}
1)),[p,h]=(0,s.useState)(!1),f=(0,s.useCallback)((e,t,n)=>{g(r=>{let s,a=r[e];return s=n?a.selectedOptions.includes(t)?a.selectedOptions.filter(e=>e!==t):[...a.selectedOptions,t]:a.selectedOptions.includes(t)?[]:[t],{...r,[e]:{...a,selectedOptions:s}}})},[]),x=(0,s.useCallback)((e,t)=>{g(n=>({...n,[e]:{...n[e],otherText:t}}))},[]),v=(0,s.useCallback)(()=>{let e=u.map(e=>({question_id:e.id,selected_options:m[e.id].selectedOptions,other_text:m[e.id].otherText||void 0}));null==n||n(o,e),h(!0)},[u,m,o,n]),w=u.every(e=>{if(!e.required)return!0;let t=m[e.id];return t.selectedOptions.length>0||t.otherText});return p?(0,r.jsxs)(a.P.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:(0,l.cn)("flex items-center gap-2 px-4 py-3 rounded-xl","bg-[hsl(var(--success)/0.1)] text-[hsl(var(--success))]",i),children:[(0,r.jsx)(b.n,{icon:y.aBP,size:16}),(0,r.jsx)("span",{className:"text-sm font-normal",children:"Response submitted"})]}):(0,r.jsxs)(a.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:(0,l.cn)("w-full rounded-xl border border-border bg-card overflow-hidden",i),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border bg-muted/30",children:[(0,r.jsx)(b.n,{icon:y.pcb,size:16,className:"text-primary"}),(0,r.jsx)("span",{className:"text-sm font-normal text-foreground",children:d||"I have some questions to help you better"})]}),(0,r.jsx)("div",{className:"p-4 space-y-6",children:u.map((e,t)=>(0,r.jsx)(ee,{question:e,index:t,state:m[e.id],onOptionToggle:f,onOtherTextChange:x},e.id))}),(0,r.jsx)("div",{className:"px-4 pb-4",children:(0,r.jsx)(J.$,{onClick:v,disabled:!w,className:"w-full",children:"Submit Answers"})})]})});var en=n(79851);let er={rate_limit:{icon:y.p19,titleKey:"rate_limit",color:"text-yellow-600 dark:text-yellow-400 bg-yellow-500/10"},rate_limited:{icon:y.p19,titleKey:"rate_limit",color:"text-yellow-600 dark:text-yellow-400 bg-yellow-500/10"},safety:{icon:y.zzI,titleKey:"safety",color:"text-orange-600 dark:text-orange-400 bg-orange-500/10"},blocklist:{icon:y.zzI,titleKey:"blocklist",color:"text-orange-600 dark:text-orange-400 bg-orange-500/10"},prohibited_content:{icon:y.zzI,titleKey:"prohibited_content",color:"text-orange-600 dark:text-orange-400 bg-orange-500/10"},spii:{icon:y.zzI,titleKey:"spii",color:"text-orange-600 dark:text-orange-400 bg-orange-500/10"},image_safety:{icon:y.zzI,titleKey:"image_safety",color:"text-orange-600 dark:text-orange-400 bg-orange-500/10"},max_tokens:{icon:y.eMY,titleKey:"max_tokens",color:"text-blue-600 dark:text-blue-400 bg-blue-500/10"},recitation:{icon:y.N$3,titleKey:"recitation",color:"text-yellow-600 dark:text-yellow-400 bg-yellow-500/10"},auth_error:{icon:y.k6p,titleKey:"auth_error",color:"text-red-600 dark:text-red-400 bg-red-500/10"},network_error:{icon:y.msl,titleKey:"network_error",color:"text-red-600 dark:text-red-400 bg-red-500/10"},timeout:{icon:y.p19,titleKey:"timeout",color:"text-yellow-600 dark:text-yellow-400 bg-yellow-500/10"},bad_request:{icon:y.msl,titleKey:"bad_request",color:"text-red-600 dark:text-red-400 bg-red-500/10"},no_response:{icon:y.msl,titleKey:"no_response",color:"text-yellow-600 dark:text-yellow-400 bg-yellow-500/10"},default:{icon:y.msl,titleKey:"default",color:"text-red-600 dark:text-red-400 bg-red-500/10"}},es=(0,s.memo)(function(e){let{error:t,onRetry:n,className:s}=e,i=(0,en.useTranslations)("errors"),o=er[t.code]||er.default;return(0,r.jsxs)(a.P.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:(0,l.cn)("w-full rounded-xl border border-border overflow-hidden",s),children:[(0,r.jsx)("div",{className:(0,l.cn)("px-4 py-3",o.color),children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)(b.n,{icon:o.icon,size:20,className:"shrink-0 mt-0.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"font-medium text-sm",children:i("titles.".concat(o.titleKey))}),(0,r.jsx)("p",{className:"text-sm opacity-80 mt-0.5",children:t.message}),t.status>0&&(0,r.jsx)("p",{className:"text-xs opacity-60 mt-1",children:i("errorCode",{code:t.code,status:t.status})})]})]})}),n&&(0,r.jsx)("div",{className:"px-4 py-3 bg-card border-t border-border",children:(0,r.jsxs)(J.$,{variant:"outline",size:"sm",onClick:n,className:"gap-2",children:[(0,r.jsx)(b.n,{icon:y.fNY,size:16}),i("tryAgain")]})})]})}),ea=new Set(["vertexaisearch.cloud.google.com"]),ei=/(?:https?:\/\/)?(?:www\.)?((?:[a-z0-9-]+\.)+[a-z]{2,})/i;function el(e){var t,n;let r=(e.url||e.uri||"").trim(),s=(null!=(t=e.title)?t:"").trim();try{let e=new URL(s);if("http:"===e.protocol||"https:"===e.protocol)return s}catch(e){}let a=(null!=(n=e.domain)?n:"").trim().replace(/^www\./i,"").toLowerCase();if(a&&!ea.has(a))return"https://".concat(a);if(r)try{let e=new URL(r);for(let t of["url","uri","u","q","target","dest","destination","redirect","r"]){let n=e.searchParams.get(t);if(n){let e=decodeURIComponent(n.replace(/\+/g," "));try{let t=new URL(e);if("http:"===t.protocol||"https:"===t.protocol)return e}catch(e){}}}}catch(e){}if(r)try{let e=decodeURIComponent(r).match(/https?:\/\/[^\s"'<>]+/);if(null==e?void 0:e[0])return new URL(e[0]),e[0]}catch(e){}if(r)try{let e=new URL(r);if(("http:"===e.protocol||"https:"===e.protocol)&&!ea.has(e.hostname))return r}catch(e){}let i=function(e){let t=e.trim();if(!t)return null;let n=t.match(ei);if(!(null==n?void 0:n[1]))return null;let r=n[1].replace(/\.$/,"").toLowerCase();return(r=r.replace(/^www\./,""),ea.has(r))?null:r}(s);return i?"https://".concat(i):r}function eo(e){try{return new URL(e).hostname.replace(/^www\./i,"")}catch(t){return e}}var ec=n(88910);let ed={google:"Google",brave:"Brave",parallel:"Parallel",browser:"Browser"};function eu(e){let{host:t,size:n,className:a,style:i}
1=e,[o,c]=(0,s.useState)(0),[d,u]=(0,s.useState)(!1),m=t.replace(/^www\./,""),g=m.charAt(0).toUpperCase(),p=(0,s.useMemo)(()=>["https://icons.duckduckgo.com/ip3/".concat(m,".ico"),"https://www.google.com/s2/favicons?domain=".concat(m,"&sz=").concat(2*n)],[m,n]);return o>=p.length?(0,r.jsx)("div",{className:(0,l.cn)("flex items-center justify-center bg-muted text-muted-foreground font-bold",a),style:{width:n,height:n,fontSize:Math.max(8,.5*n),...i},children:g}):(0,r.jsx)("img",{src:p[o],alt:m,width:n,height:n,className:(0,l.cn)(!d&&"opacity-0","transition-opacity duration-150",a),style:i,onLoad:()=>u(!0),onError:()=>{u(!1),c(e=>e+1)}})}let em=(0,s.memo)(function(e){let{sources:t,grounding:n}=e,[a,i]=(0,s.useState)(!1),o=(0,s.useMemo)(()=>(function(e,t){var n;if(e&&e.length>0){let t=new Set;return e.filter(e=>{let n="google"===e.provider?eo(el(e)):el(e);return!t.has(n)&&(t.add(n),!0)})}if(!t)return[];let r=new Map((null!=(n=t.sources)?n:[]).map(e=>[e.index,e])),s=new Set,a=[];return t.groundingChunks.forEach((e,t)=>{var n,s,i;let l=e.web;if(!(null==l?void 0:l.uri))return;let o=r.get(t),c=(null!=(n=null==o?void 0:o.title)?n:"").trim(),d=(null!=(s=null==o?void 0:o.domain)?s:"").trim(),u=c||l.title||"",m=d||(null!=(i=l.domain)?i:"")||eo(el({uri:l.uri,title:u,domain:d||l.domain}));a.push({provider:"google",title:u,url:l.uri,domain:m})}),a.filter(e=>{let t=eo(el(e));return!s.has(t)&&(s.add(t),!0)})})(t,n),[t,n]),c=(0,s.useMemo)(()=>(function(e,t){if(e&&e.length>0){let t=new Set,n=[];for(let r of e)r.query&&!t.has(r.query)&&(t.add(r.query),n.push({query:r.query,provider:r.provider}));return n}return t?t.webSearchQueries.map(e=>({query:e,provider:"google"})):[]})(t,n),[t,n]),d=(0,s.useMemo)(()=>o.slice(0,3).map(e=>eo(el(e))),[o]),u=(0,s.useMemo)(()=>!!t&&0!==t.length&&new Set(t.map(e=>e.provider)).size>1,[t]);return 0===o.length?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{onClick:()=>i(!0),"aria-label":"".concat(o.length," sources"),"aria-expanded":a,className:(0,l.cn)("inline-flex items-center gap-2 cursor-pointer select-none whitespace-nowrap","text-muted-foreground/75 hover:text-foreground/85","transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/15 focus-visible:ring-offset-2 focus-visible:ring-offset-background rounded-sm"),children:[(0,r.jsx)("div",{className:"flex items-center",style:{width:"".concat(18+11*Math.max(0,d.length-1),"px")},children:d.map((e,t)=>(0,r.jsx)(eu,{host:e,size:18,className:"rounded-full",style:{marginLeft:t>0?"-7px":0,zIndex:d.length-t,position:"relative"}},e))}),(0,r.jsxs)("span",{className:"text-[13px] font-medium tracking-[-0.01em]",children:[o.length," ",1===o.length?"source":"sources"]})]}),(0,r.jsx)(ec.lG,{open:a,onOpenChange:i,children:(0,r.jsxs)(ec.Cf,{className:"max-h-[60vh] flex flex-col sm:max-w-md",children:[(0,r.jsxs)(ec.c7,{children:[(0,r.jsxs)(ec.L3,{className:"flex items-center gap-2",children:[(0,r.jsx)(b.n,{icon:y.FuU,size:18}),"Sources"]}),(0,r.jsxs)(ec.rr,{children:[o.length," ",1===o.length?"source":"sources"," referenced in this response"]})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto -mx-6 px-6 space-y-1",children:[o.map((e,t)=>{var n;let s=el(e),a=eo(s);return(0,r.jsxs)("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:(0,l.cn)("flex items-center gap-3 px-3 py-2.5 rounded-lg","hover:bg-muted/50 transition-colors duration-150","group"),children:[(0,r.jsxs)("span",{className:"text-xs font-medium text-muted-foreground/60 w-5 text-right shrink-0",children:[t+1,"."]}),(0,r.jsx)(eu,{host:a,size:16,className:"rounded-full shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium truncate text-foreground",children:e.title||a}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:[a,u&&e.provider&&(0,r.jsxs)("span",{className:"ml-1.5 opacity-60",children:["\xb7 ",null!=(n=ed[e.provider])?n:e.provider]})]})]}),(0,r.jsx)(b.n,{icon:y.BgT,size:14,className:"text-muted-foreground/40 group-hover:text-muted-foreground shrink-0 transition-colors"})]},"".concat(s,"-").concat(t))}),c.length>0&&(0,r.jsxs)("div",{className:"pt-2 pb-1",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-2 px-3",children:"Search queries"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 px-3",children:c.map((e,t)=>{let{query:n,provider:s}=e,a="google"===s?"https://www.google.com/search?q=".concat(encodeURIComponent(n)):"brave"===s?"https://search.brave.com/search?q=".concat(encodeURIComponent(n)):null,i=(0,l.cn)("inline-flex items-center px-2.5 py-1","text-xs rounded-full","bg-muted hover:bg-muted/80 text-muted-foreground","transition-colors");return a?(0,r.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:i,children:n},t):(0,r.jsx)("span",{className:i,children:n},t)})})]})]})]})})]})}),eg=(0,s.memo)(function(e){let{citations:t}
1=e,[n,a]=(0,s.useState)(!1);if(!t||0===t.length)return null;let i=new Map;for(let e of t){let t=i.get(e.file_id)||[];t.push(e),i.set(e.file_id,t)}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{onClick:()=>a(!0),className:(0,l.cn)("inline-flex items-center gap-1.5 rounded-full px-3 py-1.5","bg-accent/10 text-accent hover:bg-accent/15","text-xs font-medium transition-colors cursor-pointer","ring-1 ring-accent/20"),children:[(0,r.jsx)(b.n,{icon:y.TYE,size:14}),(0,r.jsxs)("span",{children:[i.size," source",1!==i.size?"s":""]})]}),(0,r.jsx)(ec.lG,{open:n,onOpenChange:a,children:(0,r.jsxs)(ec.Cf,{className:"max-w-md",children:[(0,r.jsxs)(ec.c7,{children:[(0,r.jsxs)(ec.L3,{className:"flex items-center gap-2",children:[(0,r.jsx)(b.n,{icon:y.TYE,size:18}),"Knowledge Base Sources"]}),(0,r.jsx)(ec.rr,{children:"Sources referenced in this response"})]}),(0,r.jsx)("div",{className:"space-y-3 max-h-80 overflow-y-auto",children:Array.from(i.entries()).map(e=>{let[t,n]=e;return(0,r.jsxs)("div",{className:"rounded-lg border border-border/50 p-3 space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-foreground truncate",children:n[0].file_name}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:n.map(e=>(0,r.jsx)("span",{className:"inline-flex items-center rounded-md bg-muted px-2 py-0.5 text-xs text-muted-foreground",children:e.page_number?"Page ".concat(e.page_number):e.section_title?e.section_title.slice(0,40):"Source ".concat(e.index)},"".concat(e.file_id,"-").concat(e.index)))})]},t)})})]})})]})});var ep=n(73360);function eh(e){let{icon:t,label:n,onClick:s,disabled:a=!1,active:i=!1}=e;return(0,r.jsx)("button",{onClick:s,disabled:a,"aria-label":n,className:(0,l.cn)("p-1 rounded-md cursor-pointer transition-colors duration-150","text-muted-foreground/60 hover:text-foreground","hover:bg-muted/50","disabled:opacity-40 disabled:cursor-not-allowed",i&&"text-foreground"),children:(0,r.jsx)(b.n,{icon:t,size:15,strokeWidth:1.75})})}let ef=(0,s.memo)(function(e){var t;let{message:n,isLastAssistant:i,isStreaming:l,conversationId:o,onRegenerate:c}=e,{copyMessage:d,shareConversation:u,isSharing:m}=function(e){let{conversationId:t}=e,[n,r]=(0,s.useState)(!1),a=(0,s.useCallback)(async e=>{if(e)try{await navigator.clipboard.writeText(e),ep.o.success("Copied to clipboard")}catch(t){try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),ep.o.success("Copied to clipboard")}catch(e){ep.o.error("Failed to copy")}}},[]),i=(0,s.useCallback)(async()=>{if(!t)return void ep.o.error("Save conversation first");r(!0);try{let e=(await A.F.createShareLink(t)).share_url;if(navigator.share)try{await navigator.share({url:e});return}catch(e){}await navigator.clipboard.writeText(e),ep.o.success("Share link copied")}catch(e){console.error("Failed to create share link:",e),ep.o.error("Failed to create share link")}finally{r(!1)}},[t]);return{copyMessage:a,shareConversation:i,isSharing:n}}({conversationId:o}),[g,p]=(0,s.useState)(!1),h=(0,s.useCallback)(async()=>{g||(await d(n.content),p(!0),setTimeout(()=>p(!1),2e3))},[d,n.content,g]);return(0,r.jsxs)(a.P.div,{initial:{opacity:0,y:8,scale:.96,filter:"blur(6px)"},animate:{opacity:1,y:0,scale:1,filter:"blur(0px)"},transition:{duration:.35,ease:[.25,.46,.45,.94]},className:"flex items-center justify-start gap-2 pt-1 -ml-1",children:[(0,r.jsx)(eh,{icon:g?y.aBP:y.ef,label:g?"Copied":"Copy",onClick:h,active:g}),(0,r.jsx)(eh,{icon:y.ap1,label:"Share",onClick:u,disabled:m}),i&&!l&&!!c&&(0,r.jsx)(eh,{icon:y.y1Q,label:"Regenerate",onClick:c}),((null==(t=n.sources)?void 0:t.length)||n.grounding)&&(0,r.jsx)(em,{sources:n.sources,grounding:n.grounding}),n.kbCitations&&n.kbCitations.length>0&&(0,r.jsx)(eg,{citations:n.kbCitations})]})}),ex={hidden:{},visible:{transition:{staggerChildren:.07}}},ev={hidden:{opacity:0,y:8,scale:.96,filter:"blur(6px)"},visible:{opacity:1,y:0,scale:1,filter:"blur(0px)",transition:{duration:.35,ease:[.25,.46,.45,.94]}}},eb=(0,s.memo)(function(e){let{suggestions:t,onSuggestionTap:n,className:s}=e;return t.length?(0,r.jsx)(a.P.div,{variants:ex,initial:"hidden",animate:"visible",className:(0,l.cn)("flex flex-col items-start gap-1.5 mt-1",s),children:t.map(e=>(0,r.jsx)(a.P.button,{variants:ev,onClick:()=>n(e.label),className:(0,l.cn)("text-left rounded-md","bg-blue-500/[0.07] dark:bg-blue-400/[0.12]","px-3 py-1.5 text-[13px] font-medium","text-blue-700 dark:text-blue-300","hover:bg-blue-500/[0.12] dark:hover:bg-blue-400/[0.2]","active:scale-[0.97] transition-all duration-150","focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0"),children:(0,r.jsx)("span",{className:"leading-snug",children:e.label})},e.id))}):null}),ey={hidden:{},visible:{transition:{staggerChildren:.12}}},ew={hidden:{opacity:0,y:16,scale:.97,filter:"blur(6px)"},visible:{opacity:1,y:0,scale:1,filter:"blur(0px)",transition:{duration:.45,ease:[.22,.61,.36,1]}}};function ej(e){let{category:t}=e;if(!t||"general"===t)return null;let n=t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");return(0,r.jsx)("span",{className:(0,l.cn)("inline-flex items-center rounded-full px-2 py-0.5","text-[10px] font-medium tracking-wide uppercase","bg-muted/60 text-muted-foreground"),children:n})}let ek=(0,s.memo)(function(e){let{assessments:t,onAssessmentTap:n,className:s}=e;return t.length?(0,r.jsx)(a.P.div,{variants:ey,initial:"hidden",animate:"visible",className:(0,l.cn)("flex flex-col items-stretch gap-2.5 mt-3",s),children:t.map(e=>{let t=S(e.trade_category);return(0,r.jsxs)(a.P.button,{type:"button",variants:ew,onClick:()=>n("__ASSESS:".concat(e.id,"__")),className:(0,l.cn)("relative flex items-start gap-3.5 rounded-2xl text-left overflow-hidden","border border-border/80","px-4 py-3.5","bg-card hover:bg-accent/40","active:scale-[0.985] transition-all duration-200 ease-out","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30","group cursor-pointer","shadow-sm hover:shadow-md"),children:[(0,r.jsx)("div",{className:(0,l.cn)("flex items-center justify-center rounded-xl","w-10 h-10 shrink-0 mt-0.5","bg-muted/70 group-hover:bg-muted transition-colors"),children:(0,r.jsx)(N,{assessmentId:e.id,iconKey:e.icon_key,size:20,className:t})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[13px] font-semibold text-foreground leading-tight truncate",children:e.label}),(0,r.jsx)(ej,{category:e.trade_category})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground leading-snug line-clamp-2",children:e.description}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-0.5",children:[e.savings_hint&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground
1/80",children:e.savings_hint}),e.artifact_promise&&(0,r.jsxs)(r.Fragment,{children:[e.savings_hint&&(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground/40",children:"\xb7"}),(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground/80",children:e.artifact_promise})]})]})]}),(0,r.jsx)("div",{className:"flex items-center self-center shrink-0",children:(0,r.jsx)(b.n,{icon:y.eXO,size:16,className:"text-muted-foreground/50 group-hover:text-foreground/70 transition-colors","aria-hidden":!0})})]},e.id)})}):null}),eN={hidden:{opacity:0,y:10,scale:.98},visible:{opacity:1,y:0,scale:1,transition:{duration:.35,ease:[.22,.61,.36,1]}}};function e_(e){let{artifact:t}=e,[n,i]=(0,s.useState)(!1),o=S(t.trade_category),c=(0,s.useCallback)(async()=>{if(t.file_id&&!n){i(!0);try{let e="pdf"===t.format?".pdf":".md",n=t.title.replace(/[^a-zA-Z0-9 _-]/g,"").trim();await A.F.downloadFile(t.file_id,"".concat(n||"assessment-report").concat(e))}catch(e){console.error("[artifact-download]",e)}finally{i(!1)}}},[t,n]);return(0,r.jsxs)(a.P.div,{variants:eN,className:(0,l.cn)("relative flex items-start gap-3.5 rounded-2xl overflow-hidden","border border-border/80","px-4 py-3.5","bg-card","shadow-sm"),children:[(0,r.jsx)("div",{className:(0,l.cn)("flex items-center justify-center rounded-xl","w-10 h-10 shrink-0 mt-0.5","bg-muted/70"),children:(0,r.jsx)(N,{assessmentId:t.assessment_id,iconKey:t.icon_key||"report",size:20,className:o})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[13px] font-semibold text-foreground leading-tight truncate",children:t.title}),(0,r.jsx)("span",{className:(0,l.cn)("inline-flex items-center rounded px-1.5 py-px","text-[9px] font-bold tracking-wider uppercase","bg-muted text-muted-foreground"),children:function(e){switch(e){case"markdown":return"MD";case"pdf":return"PDF";default:return e.toUpperCase()}}(t.format)})]}),t.preview_text&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground leading-snug line-clamp-2",children:t.preview_text}),(0,r.jsxs)("button",{type:"button",onClick:c,disabled:n||!t.file_id,className:(0,l.cn)("inline-flex items-center gap-1.5 rounded-lg","px-3 py-1.5 mt-0.5","text-xs font-medium","bg-primary text-primary-foreground","hover:bg-primary/90 active:scale-[0.97]","disabled:opacity-50 disabled:pointer-events-none","transition-all duration-150"),children:[(0,r.jsx)(b.n,{icon:y.eWi,size:14,"aria-hidden":!0}),n?"Downloading...":"Download Report"]})]}),(0,r.jsx)("div",{className:"absolute top-3 right-3 opacity-[0.06]",children:(0,r.jsx)(b.n,{icon:y.hhb,size:48,"aria-hidden":!0})})]})}let eS=(0,s.memo)(function(e){let{artifacts:t,className:n}=e;return(null==t?void 0:t.length)?(0,r.jsx)(a.P.div,{initial:"hidden",animate:"visible",transition:{staggerChildren:.1},className:(0,l.cn)("flex flex-col gap-2.5 mt-3",n),children:t.map(e=>(0,r.jsx)(e_,{artifact:e},e.artifact_id))}):null});var eC=n(9437);let eL=(0,s.memo)(function(){return(0,r.jsxs)(a.P.div,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.3,delay:.15},className:"flex items-center gap-1.5 pt-1",role:"status",children:[(0,r.jsx)(b.n,{icon:y.aBP,size:16,className:"text-[hsl(var(--success))]","aria-hidden":"true"}),(0,r.jsx)("span",{className:"text-sm text-[hsl(var(--success))] font-medium",children:"Task completed"})]})});function eA(e){let{attachments:t}=e,n=t.filter(e=>"image"===e.type),a=t.filter(e=>"image"!==e.type),[i,o]=(0,s.useState)(null),c=(0,s.useMemo)(()=>n.map(e=>({id:e.id,src:e.url,alt:e.name,title:e.name,subtitle:e.mimeType})),[n]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col items-end gap-2 w-full",children:[n.length>0&&(0,r.jsx)("div",{className:(0,l.cn)("grid gap-1 rounded-xl overflow-hidden max-w-[50%]",1===n.length?"grid-cols-1":"grid-cols-2"),children:n.slice(0,4).map((e,t)=>{var s,a,i;let c="number"==typeof e.uploadProgress&&e.uploadProgress<1,d=!!e.uploadError;return(0,r.jsxs)("button",{type:"button",onClick:()=>o(t),className:(0,l.cn)("relative bg-muted text-left transition-transform duration-200 hover:scale-[1.01]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",1===n.length?"":"aspect-square",3===n.length&&0===t&&"col-span-2 aspect-video"),"aria-label":"Expand ".concat(e.name),"aria-busy":c||void 0,children:[(0,r.jsx)("img",{src:e.thumbnailUrl||e.url,alt:e.name,className:(0,l.cn)(1===n.length?"w-full h-auto rounded-xl":"w-full h-full object-cover")}),c&&(0,r.jsx)("div",{role:"progressbar","aria-label":"Uploading ".concat(e.name),"aria-valuenow":Math.round((null!=(s=e.uploadProgress)?s:0)*100),"aria-valuemin":0,"aria-valuemax":100,className:"absolute inset-0 flex items-end bg-background/40",children:(0,r.jsx)("div",{className:"h-1 bg-accent-blue motion-reduce:transition-none",style:{width:"".concat(Math.round((null!=(a=e.uploadProgress)?a:0)*100),"%")}})}),d&&(0,r.jsx)("div",{role:"alert",className:"absolute inset-x-0 bottom-0 px-1 py-0.5 text-[10px] bg-destructive text-destructive-foreground truncate",title:null!=(i=e.uploadError)?i:"Upload failed",children:"upload failed"}),n.length>4&&3===t&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:(0,r.jsxs)("span",{className:"text-white text-lg font-semibold",children:["+",n.length-4]})})]},e.id)})}),a.length>0&&(0,r.jsx)("div",{className:"flex flex-col items-end gap-1.5",children:a.map(e=>(0,r.jsx)(I,{attachment:e},e.id))})]}),(0,r.jsx)(C.B,{images:c,selectedIndex:i,onSelect:o,onClose:()=>o(null)})]})}function ez(e){let{assessmentId:t,sendFailed:n}=e,s=function(e){let t=v[e];if(t)return t;let n=e.split("-").filter(Boolean),r=n.length>0?n.map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):e;return"".concat(r," Assessment")}(t),a=S();return(0,r.jsxs)("div",{role:"status","aria-label":"Assessment request: ".concat(s),className:(0,l.cn)("flex items-center gap-2.5 rounded-2xl px-4 py-2","border border-border/80","bg-card shadow-sm",n&&"opacity-70"),children:[(0,r.jsx)(N,{assessmentId:t,size:18,className:a}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:s})]})}let eI=(0,s.memo)(function(e){var t,n,s,i;let{message:o,isStreaming:c=!1,skipEntrance:d=!1,isLastAssistant:u=!1,conversationId:m=null,onAskQuestionsSubmit:g,onRetry:p,onRegenerate:h,onSuggestionTap:f}=e,x="user"===o.role,v=x&&o.content?o.content.match(/^__ASSESS:(.+)__$/):null,b=v?v[1]:null;return(0,r.jsx)(a.P.div,{"data-message-id":o.id,initial:!d&&{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:(0,l.cn)("flex w-full min-w-0",x?"justify-end":"justify-start"),children:(0,r.jsxs)("div",{className:(0,l.cn)("flex flex-col gap-1 min-w-0",x?"items-end max-w-[85%] sm:max-w-[75%]":"items-start w-full"),children:[x&&o.attachments&&o.attachments.length>0&&(0,r.jsx)(eA,{attachments:o.attachments}),!x&&(o.thoughts||o.toolCalls&&o.toolCalls.length>0||o.searchQueries&&o.searchQueries.length>0||o.grounding||o.askQuestions||o.assessments&&o.assessments.length>0||o.artifacts&&o.artifacts.length>0||o.kbCitations&&o.kbCitations.length>0||o.images&&o.images.length>0)&&(0,r.jsx)(Y,{thoughts:o.thoughts||"",isStreaming:!1,isThinking:!1,tokenCount:null==(t=o.meta)?void 0:t.thoughtsTokens,durationSeconds:null==(n=o.meta)?void 0:n.thinkingDurationSeconds,searchQueries:null!=(i=o.searchQueries)?i:null==(s=o.grounding)?void 0:s.webSearchQueries,toolCalls:o.toolCalls,grounding:o.grounding,askQuestions:o.askQuestions,assessments:o.assessments,artifacts:o.artifacts,kbCitations:o.kbCitations,images:o.images}),o.content&&(x?b?(0,r.jsxs)("div",{children:[(0,r.jsx)(ez,{assessmentId:b,sendFailed:o.sendFailed}),o.sendFailed&&(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 mt-1",children:[(0,r.jsx)("span",{className:"text-xs text-destructive",children:"Failed to send"}),p&&(0,r.jsx)("button",{type:"button",onClick:()=>p(o),className:"text-xs text-primary hover:underline cursor-pointer font-medium",children:"Retry"})]})]}):(0,r.jsxs)("div",{className:"max-w-full min-w-0",children:[(0,r.jsx)("div",{className:(0,l.cn)("rounded-2xl px-3.5 py-1.5 bg-secondary text-secondary-foreground max-w-full min-w-0 overflow-hidden",o.sendFailed&&"opacity-70"),children:(0,r.jsx)("p",{className:"text-[15px] leading-6 tracking-normal whitespace-pre-wrap [overflow-wrap:anywhere]",children:o.content})}),o.sendFailed&&(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 mt-1",children:[(0,r.jsx)("span",{className:"text-xs text-destructive",children:"Failed to send"}),p&&(0,r.jsx)("button",{type:"button",onClick:()=>p(o),className:"text-xs text-primary hover:underline cursor-pointer font-medium",children:"Retry"})]})]}):(0,r.jsx)("div",{className:"py-1",children:(0,r.jsx)(E.S,{content:o.content,isStreaming:!1,className:""})})),!x&&(0,r.jsxs)(r.Fragment,{children:[o.images&&o.images.length>0&&(0,r.jsx)(Z.H,{images:o.images}),o.askQuestions&&(0,r.jsx)(et,{event:o.askQuestions,onSubmit:g}),o.error&&(0,r.jsx)(es,{error:o.error,onRetry:p?()=>p(o):void 0}),(o.content||o.grounding)&&(!u||!c)&&(0,r.jsx)(ef,{message:o,isLastAssistant:u,isStreaming:c,conversationId:m,onRegenerate:h}),!c&&function(e){var t,n,r,s,a;if("assistant"!==e.role)return!1;let i=(null!=(r=null==(t=e.toolCalls)?void 0:t.length)?r:0)>0,l=(null!=(s=e.iterationsUsed)?s:0)>1,o=(null!=(a=null==(n=e.meta)?void 0:n.thinkingDurationSeconds)?a:0)>=5;return i||l||o}(o)&&(0,r.jsx)(eL,{}),u&&!c&&o.assessments&&o.assessments.length>0&&f&&(0,r.jsx)(ek,{assessments:o.assessments,onAssessmentTap:f}),o.writingArtifacts&&o.writingArtifacts.length>0&&(0,r.jsx)(eC.L,{artifacts:o.writingArtifacts}),o.artifacts&&o.artifacts.length>0&&(0,r.jsx)(eS,{artifacts:o.artifacts}),u&&!c&&o.suggestions&&o.suggestions.length>0&&f&&(0,r.jsx)(eb,{suggestions:o.suggestions,onSuggestionTap:f})]})]})})});function eE(e){var t,n;let{streamingMessage:s,isStreaming:i=!0,onAskQuestionsSubmit:l}=e;return s.content||s.thoughts||s.images.length>
10||s.askQuestions||s.toolCalls.length>0||s.writingArtifacts.length>0||i?(0,r.jsx)(a.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"flex justify-start",children:(0,r.jsxs)("div",{className:"flex flex-col gap-1 w-full items-start",children:[(s.thoughts||s.isThinking||s.toolCalls.length>0||s.grounding||s.askQuestions||s.assessments.length>0||s.artifacts.length>0||s.kbCitations.length>0||s.images.length>0)&&(0,r.jsx)(Y,{thoughts:s.thoughts,isStreaming:i,isThinking:s.isThinking,tokenCount:null==(t=s.meta)?void 0:t.thoughtsTokens,searchQueries:null==(n=s.grounding)?void 0:n.webSearchQueries,toolCalls:s.toolCalls,grounding:s.grounding,askQuestions:s.askQuestions,assessments:s.assessments,artifacts:s.artifacts,kbCitations:s.kbCitations,images:s.images}),(s.content||!s.isThinking&&i)&&(0,r.jsx)("div",{className:"py-1",children:(0,r.jsx)(E.S,{content:s.content||"",isStreaming:i,className:""})}),s.images.length>0&&(0,r.jsx)(Z.H,{images:s.images}),s.askQuestions&&(0,r.jsx)(et,{event:s.askQuestions,onSubmit:l}),s.writingArtifacts.length>0&&(0,r.jsx)(eC.L,{artifacts:s.writingArtifacts})]})}):null}let eF=(0,s.forwardRef)(function(e,t){let{messages:n,streamingMessage:a,isStreaming:o=!1,conversationId:c,onAskQuestionsSubmit:d,onRetry:u,onRegenerate:m,onSuggestionTap:g,onScrollToBottomChange:p,className:f}=e,v=(0,s.useRef)(null),b=(0,s.useRef)(!0),y=(0,s.useRef)(null),w=(0,s.useRef)(null),[j,k]=(0,s.useState)(!1),[N,_]=(0,s.useState)(0),S=(0,x.j_)(e=>e.setContentScrolled);!a&&y.current?(w.current=y.current,y.current=null):a&&(y.current=a.id);let C=(0,s.useCallback)(e=>{S(e>0);let t=v.current;if(!t)return;let n=t.scrollHeight-t.scrollTop-t.clientHeight<50;b.current=n,k(!n)},[S]),L=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{S(!1)},[S]);let A=(0,s.useCallback)(()=>{let e=v.current;e&&(e.scrollTop=e.scrollHeight),b.current=!0,k(!1)},[]),z=(0,s.useCallback)(e=>{let t=v.current;t&&(_(t.clientHeight),b.current=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{let n=t.querySelector('[data-message-id="'.concat(e,'"]'));if(!n)return;let r=L.current,s=r&&parseFloat(getComputedStyle(r).paddingTop)||0,a=n.getBoundingClientRect().top-t.getBoundingClientRect().top;t.scrollTop=t.scrollTop+a-s,k(!0)})}))},[]),I=(0,s.useRef)(n.length);(0,s.useEffect)(()=>{let e=I.current;if(I.current=n.length,0===n.length)return void _(0);let t=n[n.length-1];n.length===e+1&&(null==t?void 0:t.role)==="user"&&z(t.id)},[n,z]),(0,s.useImperativeHandle)(t,()=>({scrollToBottom:A}),[A]),(0,s.useEffect)(()=>{null==p||p(j)},[j,p]);let E=n.length>0||!!a;return(0,r.jsx)("div",{className:"relative h-full min-h-0 flex flex-col",children:(0,r.jsx)(h,{className:(0,l.cn)("flex-1 min-h-0 chat-scroll-edge",f),onScrollChange:C,viewportRef:v,children:(0,r.jsx)("div",{className:"px-4 sm:px-6 min-w-0",children:(0,r.jsxs)("div",{ref:L,className:(0,l.cn)("max-w-3xl mx-auto pb-44 space-y-4 min-w-0",E?"pt-16 sm:pt-20":"pt-0"),children:[(0,r.jsxs)(i.N,{mode:"popLayout",children:[n.map((e,t)=>{let s="assistant"===e.role&&n.slice(t+1).every(e=>"assistant"!==e.role);
1return(0,r.jsx)(eI,{message:e,skipEntrance:e.id===w.current,isLastAssistant:s,isStreaming:o,conversationId:c,onAskQuestionsSubmit:d,onRetry:u,onRegenerate:m,onSuggestionTap:g},e.id)}),a&&(0,r.jsx)(eE,{streamingMessage:a,isStreaming:o,onAskQuestionsSubmit:d},"streaming")]}),(0,r.jsx)("div",{className:"h-px"}),(0,r.jsx)("div",{"aria-hidden":!0,style:{height:N}})]})})})})});n(79804),n(29244);let eP=function(e,t){let n=[],r=Math.max(e.length,t.length);for(let s=0;s<r;s++)s<e.length&&n.push(e[s]),s<t.length&&n.push(t[s]);return n}([{src:"/images/carousel/bgcards/cowboys.jpg",alt:"Cowboys"},{src:"/images/carousel/bgcards/Joseph-Lucia-II-Georges-Bank-1980.jpg",alt:"Fishing boat"},{src:"/images/carousel/bgcards/lobster boat.jpg",alt:"Lobster boat"},{src:"/images/carousel/bgcards/mountaineer.png",alt:"Mountaineer"},{src:"/images/carousel/bgcards/Roper.jpg",alt:"Roper"},{src:"/images/carousel/bgcards/the-new-york-public-library-_5lkZTHtmyg-unsplash.jpg",alt:"Archive photo"},{src:"/images/carousel/bgcards/the-oregon-state-university-collections-and-archives--FskfFf8IpM-unsplash.jpg",alt:"Historical archive"}],[{src:"/images/carousel/colorcards/electric.jpg",alt:"Electrical work"},{src:"/images/carousel/colorcards/marine.jpg",alt:"Marine industry"},{src:"/images/carousel/colorcards/mining.jpg",alt:"Mining operations"},{src:"/images/carousel/colorcards/oilgas.jpg",alt:"Oil and gas"},{src:"/images/carousel/colorcards/plumbing.jpg",alt:"Plumbing work"},{src:"/images/carousel/colorcards/redcar.jpg",alt:"Red car"},{src:"/images/carousel/colorcards/telecom.jpg",alt:"Telecommunications"},{src:"/images/carousel/colorcards/wires.jpg",alt:"Wiring"}]);Array.from({length:24},(e,t)=>eP[t%eP.length]),n(44650)},22765:(e,t,n)=>{n.d(t,{a:()=>l});var r=n(70862),s=n(18526),a=n(99049);let i=[{name:"spiral-cw",delays:[0,80,160,560,640,240,480,400,320],duration:220},{name:"center-out",delays:[240,120,240,120,0,120,240,120,240],duration:240},{name:"wave-lr",delays:[0,120,240,0,120,240,0,120,240],duration:240},{name:"snake",delays:[0,80,160,400,320,240,480,560,640],duration:200},{name:"corners-first",delays:[0,200,0,200,400,200,0,200,0],duration:240}],l=(0,s.memo)(function(e){let{thoughtIndex:t=0,isAnimating:n=!0,autoCycle:l=!0,className:o}=e,[c,d]=(0,s.useState)(()=>{var e;return(t%(e=i.length)+e)%e}),[u,m]=(0,s.useState)(()=>Array(9).fill(0)),[g,p]=(0,s.useState)(!1),h=(0,s.useRef)(null),f=(0,s.useRef)(null);(0,s.useEffect)(()=>{var e;l||d((t%(e=i.length)+e)%e)},[t,l]),(0,s.useEffect)(()=>{if(!n||!l||g)return;let e=setInterval(()=>{d(e=>(e+1)%i.length)},2500);return()=>clearInterval(e)},[n,l,g]);let x=i[c],{phaseTime:v,cycleTime:b}=(0,s.useMemo)(()=>{let e=Math.max(...x.delays)+x.duration;return{phaseTime:e,cycleTime:2*e+60}},[x]);return(0,s.useEffect)(()=>{if(!window.matchMedia)return;let e=window.matchMedia("(prefers-reduced-motion: reduce)"),t=()=>p(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),(0,s.useEffect)(()=>{if(f.current=null,!n)return void m(Array(9).fill(0));if(g)return void m(Array(9).fill(1));let e=t=>{null===f.current&&(f.current=t);let n=t-f.current;m(x.delays.map(e=>(function(e,t,n,r,s){let a=(e%r+r)%r,i=n+t;if(a>=i)return Math.max(0,1-(a-i)/280);if(a>=t)return Math.min(1,(a-t)/280);let l=a-i+r;return l<s?Math.max(0,1-l/s):0})(n,e,v,b,280))),h.current=requestAnimationFrame(e)};return h.current=requestAnimationFrame(e),()=>{h.current&&cancelAnimationFrame(h.current)}},[n,g,x,v,b]),(0,r.jsx)("svg",{width:21.5,height:21.5,viewBox:"0 0 ".concat(21.5," ").concat(21.5),className:(0,a.cn)("text-muted-foreground",o),"aria-hidden":"true",children:u.map((e,t)=>{let n=Math.floor(t/3),s=4+t%3*5,a=4+5*n;return(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{x:s,y:a,width:3.5,height:3.5,rx:.7,ry:.7,opacity:.22}),(0,r.jsx)("rect",{x:s,y:a,width:3.5,height:3.5,rx:.7,ry:.7,opacity:e})]},t)})})})},23195:(e,t,n)=>{n.d(t,{S:()=>l});var r=n(8107),s=n(40660);let a={photo_analysis:1,chat_message:1,video_analysis:5,pdf_analysis:10,live_voice_minute:20,measure:2,doc_search:1,barcode_scan:1};function i(e){if(!(null==e?void 0:e.expires_at)||!e.is_personal)return null;let t=new Date(e.expires_at).getTime(),n=Date.now();return t-n>0&&t-n<=6048e5&&!1!==e.will_renew?e.expires_at:null}let l=(0,r.v)((e,t)=>({status:null,isPersonal:!1,isProfessional:!1,tier:"free",isLoading:!0,creditsRemaining:0,error:null,paymentMethod:null,invoices:[],usageDetail:null,isBillingLoading:!1,portalUrl:null,trialEndsAt:null,overagePrompt:null,fetchStatus:async()=>{e({isLoading:!0,error:null});try{let t=await s.F.getSubscriptionStatus();e({status:t,isPersonal:t.is_personal,isProfessional:t.is_professional,tier:t.tier,creditsRemaining:t.credits.total_remaining,trialEndsAt:i(t),isLoading:!1})}catch(n){let t=n instanceof Error?n.message:"Failed to fetch subscription status";console.error("[subscriptionStore] fetchStatus error:",t),e({isLoading:!1,error:t})}}
1,verifySubscription:async()=>{e({isLoading:!0,error:null});try{let t=await s.F.verifySubscription();e({status:t,isPersonal:t.is_personal,isProfessional:t.is_professional,tier:t.tier,creditsRemaining:t.credits.total_remaining,trialEndsAt:i(t),isLoading:!1})}catch(n){let t=n instanceof Error?n.message:"Failed to verify subscription";console.error("[subscriptionStore] verifySubscription error:",t),e({isLoading:!1,error:t})}},consumeCredits:async(n,r)=>{try{let t=await s.F.consumeCredits(n,r);if(e({creditsRemaining:t.credits_remaining}),t.overage_required){var i;e({overagePrompt:{feature:n,required:null!=(i=a[n])?i:1,remaining:t.credits_remaining,tierStatus:void 0}})}return{success:t.success,overage_required:t.overage_required,credits_remaining:t.credits_remaining}}catch(e){return console.error("[subscriptionStore] consumeCredits error:",e),{success:!1,overage_required:!0,credits_remaining:t().creditsRemaining}}},canAfford:e=>{var n;let r=null!=(n=a[e])?n:1;return t().creditsRemaining>=r},fetchBilling:async()=>{e({isBillingLoading:!0});try{var t,n;let[r,a]=await Promise.all([s.F.getBillingInvoices().catch(()=>({invoices:[],payment_method:null})),s.F.getBillingUsage(30).catch(()=>null)]);e({invoices:null!=(t=r.invoices)?t:[],paymentMethod:null!=(n=r.payment_method)?n:null,usageDetail:a,isBillingLoading:!1})}catch(t){console.error("[subscriptionStore] fetchBilling error:",t),e({isBillingLoading:!1})}},fetchUsage:async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30;try{let n=await s.F.getBillingUsage(t);e({usageDetail:n})}catch(e){console.error("[subscriptionStore] fetchUsage error:",e)}},fetchPortalLink:async()=>{try{let t=await s.F.getBillingPortalLink();return e({portalUrl:t.url}),t.url}catch(e){return console.error("[subscriptionStore] fetchPortalLink error:",e),null}},showOverage:t=>e({overagePrompt:t}),dismissOverage:()=>e({overagePrompt:null}),reset:()=>{e({status:null,isPersonal:!1,isProfessional:!1,tier:"free",isLoading:!1,creditsRemaining:0,error:null,paymentMethod:null,invoices:[],usageDetail:null,isBillingLoading:!1,portalUrl:null,trialEndsAt:null,overagePrompt:null})}}))},29244:(e,t,n)=>{n.d(t,{Providers:()=>v,Z2:()=>c,DP:()=>h,fP:()=>x.f});var r=n(70862),s=n(34059),a=n(18526),i=n(73973),l=n(68605);let o=(0,a.createContext)({user:null,loading:!0,isConfigured:!1,gateState:"unauthenticated"});function c(){return(0,a.useContext)(o)}let d=["/login","/signup","/forgot-password"],u="/verify-email",m="camerasearch_logged_in";function g(e){let{children:t}=e,[n,s]=(0,a.useState)(0),[c,g]=(0,a.useState)(!0),p=(0,i.useRouter)(),h=(0,i.usePathname)(),f=(0,a.useMemo)(()=>{var e,t;return null!=(t=null==(e=(0,l.Cy)())?void 0:e.currentUser)?t:null},[n]),x=(0,a.useMemo)(()=>f?(0,l.aJ)(f):"unauthenticated",[f,n]);return(0,a.useEffect)(()=>{let e=(0,l.H$)(()=>{var e,t;g(!1),s(e=>e+1),(null!=(t=null==(e=(0,l.Cy)())?void 0:e.currentUser)?t:null)?function(){if("undefined"==typeof document)return;let e=window.location.hostname.includes("camerasearch.ai");document.cookie="".concat(m,"=true; path=/; max-age=").concat(2592e3,"; samesite=lax").concat(e?"; domain=.camerasearch.ai":"").concat(e?"; secure":"")}():function(){if("undefined"==typeof document)return;let e=window.location.hostname.includes("camerasearch.ai"),t=e?"; secure":"";document.cookie="".concat(m,"=; path=/; max-age=0; samesite=lax").concat(e?"; domain=.camerasearch.ai":"").concat(t),document.cookie="NEXT_LOCALE=en; path=/; max-age=31536000; samesite=lax".concat(t)}()});return()=>e()},[]),(0,a.useEffect)(()=>{if(c||!l.Gg)return;let e=d.some(e=>h.startsWith(e)),t=h.startsWith(u);"unauthenticated"!==x||e?"needsEmailVerification"!==x||t?"ready"===x&&(e||t)&&p.push("/chat"):p.push(u):p.push("/login")},[f,c,h,p,x]),(0,r.jsx)(o.Provider,{value:{user:f,loading:c,isConfigured:l.Gg,gateState:x},children:t})}let p=(0,a.createContext)({theme:"system",setTheme:()=>{},resolvedTheme:"light"});function h(){return(0,a.useContext)(p)}function f(e){let{children:t,defaultTheme:n="system"}=e,[s,i]=(0,a.useState)(n),[l,o]=(0,a.useState)("light");return(0,a.useEffect)(()=>{let e=localStorage.getItem("theme");e&&i(e)},[]),(0,a.useEffect)(()=>{let e=document.documentElement,t=t=>{t?(e.classList.add("dark"),o("dark")):(e.classList.remove("dark"),o("light"))};if("system"===s){let e=window.matchMedia("(prefers-color-scheme: dark)");t(e.matches);let n=e=>t(e.matches);
1return e.addEventListener("change",n),()=>e.removeEventListener("change",n)}t("dark"===s)},[s]),(0,r.jsx)(p.Provider,{value:{theme:s,setTheme:e=>{i(e),localStorage.setItem("theme",e)},resolvedTheme:l},children:t})}var x=n(34297);function v(e){let{children:t}=e;return(0,r.jsx)(s.x,{reducedMotion:"user",children:(0,r.jsx)(f,{defaultTheme:"system",children:(0,r.jsx)(g,{children:(0,r.jsx)(x.Q,{children:t})})})})}},44455:(e,t,n)=>{n.d(t,{L:()=>h});var r=n(18526),s=n(64503),a=n(40660),i=n(20746),l=n(46332),o=n(23195);let c=null;async function d(){var e;if("undefined"==typeof navigator||!(null==(e=navigator.permissions)?void 0:e.query))return"unsupported";try{let e=await navigator.permissions.query({name:"geolocation"});if("granted"===e.state||"denied"===e.state||"prompt"===e.state)return e.state;return"unsupported"}catch(e){return"unsupported"}}function u(){return c?Date.now()-c.at>3e5?(c=null,null):c.coords:null}function m(){return"undefined"!=typeof navigator&&navigator.geolocation?new Promise(e=>{navigator.geolocation.getCurrentPosition(t=>{let n={lat:t.coords.latitude,lon:t.coords.longitude,accuracy_m:t.coords.accuracy?Math.round(t.coords.accuracy):void 0,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,source:"gps",captured_at:new Date().toISOString()};c={coords:n,at:Date.now()},e(n)},()=>e(null),{enableHighAccuracy:!1,timeout:1e4,maximumAge:3e5})}):Promise.resolve(null)}let g=[900,1800,3200],p=new Set(["image/jpeg","image/jpg","image/png","image/webp","image/heic","image/heif","image/gif"]);function h(){let e=(0,r.useRef)(""),t=(0,r.useRef)([]),n=(0,r.useRef)(!1),{requestLocationForMessage:c,requestSessionLocationForNewConversation:h}={requestLocationForMessage:(0,r.useCallback)(async()=>{let e=u();return e||("denied"===await d()?null:m())},[]),requestSessionLocationForNewConversation:(0,r.useCallback)(async()=>{let e=u();return e||("denied"===await d()?null:m())},[])},{currentConversationId:f,setCurrentConversation:x,addConversation:v,updateConversation:b,messages:y,addMessage:w,setMessages:j,clearMessages:k,markMessageFailed:N,startStreaming:_,handleSSEEvent:S,setStreamState:C,abortStream:L,clearAttachments:A}=(0,i.Lo)(),z=(0,r.useCallback)(e=>{S(e)},[S]),I=(0,r.useCallback)(e=>{console.error("Stream error:",e),C("error")},[C]),E=(0,r.useCallback)(e=>{o.S.getState().showOverage({feature:e.feature,required:e.credits_required,remaining:e.credits_remaining,tierStatus:e.tier_status}),C("error")},[C]),F=(0,r.useCallback)(()=>{var e;i.Lo.getState().finalizeMessage(),C("complete");let{currentConversationId:n,conversations:r}=i.Lo.getState(),s=r.find(e=>e.id===n);!n||(null==s||null==(e=s.title)?void 0:e.trim())||function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;(async()=>{try{var r;let e=null==(r=(await a.F.getConversation(t,void 0,1)).conversation.title)?void 0:r.trim();if(e)return void i.Lo.getState().updateConversation(t,{title:e})}catch(e){console.warn("Failed to sync conversation title:",e)}let s=g[n];void 0!==s&&window.setTimeout(()=>{e(t,n+1)},s)})()}(n),n&&(t.current=t.current.filter(e=>e.conversationId===n));let l=t.current.shift();l&&l.conversationId===n&&(async()=>{try{var e;i.Lo.getState().startStreaming(),await a.F.sendMessage(l.conversationId,l.parts,l.clientEventId,l.loc,l.kb,l.writing),await (null==(e=P.current)?void 0:e.call(P,l.conversationId,l.clientEventId))}catch(e){console.error("Failed to send queued follow-up:",e),C("error"),i.Lo.getState().markMessageFailed(l.optimisticUserMessageId),t.current=[]}})()},[C]),P=(0,r.useRef)(null),{startStream:T,abort:R,state:M}=(0,l.E)({onEvent:z,onError:I,onComplete:F,onCreditsBlocked:E});P.current=T;let q=(0,r.useCallback)(async e=>{try{let t=await h(),n=(await a.F.createConversation(e,null!=t?t:void 0)).conversation.conversationId,r={id:n,title:"",mode:"chat",messageCount:0,createdAt:new Date,updatedAt:new Date,projectId:e||null};return v(r),x(n),n}catch(e){throw console.error("Failed to create conversation:",e),e}},[v,x,h]),B=(0,r.useCallback)(async function(r){var l,o,d,u,m,g,h,x,v,b,y;let j=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],S=arguments.length>2?arguments[2]:void 0,L=arguments.length>3?arguments[3]:void 0,z=arguments.length>4?arguments[4]:void 0,I=f,E=!I,F=null!=(d=null==L||null==(o=L.pins)||null==(l=o.file_ids)?void 0:l.filter(Boolean))?d:[];if(!r&&0===j.length&&0===F.length)return;let P=!E&&I===i.Lo.getState().currentConversationId&&"streaming"===i.Lo.getState().streamState&&null!==i.Lo.getState().streamingMessage;if(!P&&n.current)return void console.warn("[useConversation] Ignoring duplicate sendMessage while previous send is still in flight");P||(n.current=!0);let R=i.Lo.getState(),M=!E&&I===R.currentConversationId&&"streaming"===R.streamState&&null!==R.streamingMessage,B={id:(0,s.Ak)(),role:"user",content:r||(F.length>0?" ":""),attachments:j.length>0?j:void 0,createdAt:new Date};E&&k(),w(B),A(),M||_();let U=i.Lo.getState().updatePendingAttachment,D=i.Lo.getState().updateMessageAttachment,O=(e,t)=>{U(e,t),D(B.id,e,t)},V=[],Q=[],K=0;for(let e of j){if(e.fileUri){Q.push({kind:"preuploaded",attachment:e});continue}if(!e.file)continue;let t=e.file,n=e.mimeType||t.type||"application/octet-stream";(y=K,"application/pdf"===n||t.name.toLowerCase().endsWith(".pdf")||n.startsWith("video/")&&t.size>0xa00000||t.size>0xa00000||y+t.size>0x1400000||!p.has(n.toLowerCase())?0:1)?(K+=t.size,Q.push({kind:"inline",attachment:e,file:t,mime:n})):Q.push({kind:"upload",attachment:e,file:t,mime:n})}let G=await Promise.all(Q.map(async e=>{if("preuploaded"===e.kind)return{type:"file_data",file_data:{mime_type:e.attachment.mimeType,file_uri:e.attachment.fileUri}};if("upload"===e.kind)try{O(e.attachment.id,{uploadProgress:0,uploadError:void 0});let t=await a.F.uploadFile(e.file,{displayName:e.attachment.name,onProgress:t=>{t.lengthComputable&&t.total>0&&O(e.attachment.id,{uploadProgress:Math.min(.99,t.loaded/t.total)})},onBytesSent:()=>{O(e.attachment.id,{uploadProgress:.99})}});return O(e.attachment.id,{uploadProgress:1,fileUri:t.file_uri}),e.attachment.fileUri=t.file_uri,{type:"file_data",file_data:{mime_type:t.mime_type||e.mime,file_uri:t.file_uri}}}catch(n){let t=n instanceof Error?n.message:"Upload failed";return O(e.attachment.id,{uploadError:t,uploadProgress:void 0}),V.push("".concat(e.attachment.name,": ").concat(t)),null}try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(e.split(",")[1])}
1,r.onerror=n,r.readAsDataURL(e.file)});return{type:"inline_data",inline_data:{mime_type:e.mime,data:t}}}catch(n){let t=n instanceof Error?n.message:"Encoding failed";return O(e.attachment.id,{uploadError:t}),V.push("".concat(e.attachment.name,": ").concat(t)),null}})),H=[];for(let e of(r&&H.push({type:"text",text:r}),G))e&&H.push(e);if(V.length>0&&console.error("Attachment upload(s) failed:",V),0===H.length)if((null!=(g=null==L||null==(m=L.pins)||null==(u=m.file_ids)?void 0:u.filter(Boolean))?g:[]).length>0)H.push({type:"text",text:" "});else{M||C("error"),N(B.id),P||(n.current=!1);return}e.current=(0,s.Ak)();try{if(E)try{I=await q(S),window.history.replaceState(null,"","/chat/".concat(I))}catch(e){C("error"),N(B.id);return}let n=I,r=await c();if(j.some(e=>"image"===e.type)){let e={capturedAt:new Date().toISOString(),timezone:(null==r?void 0:r.timezone)||Intl.DateTimeFormat().resolvedOptions().timeZone,location:r?{lat:r.lat,lon:r.lon,...null!=r.accuracy_m?{accuracy_m:r.accuracy_m}:{}}:null};H.push({type:"text",text:'<photo_sensor_data silent="true">\n'.concat(JSON.stringify(e),"\n</photo_sensor_data>")})}let s=null!=(v=null==L||null==(x=L.pins)||null==(h=x.file_ids)?void 0:h.filter(Boolean))?v:[],l=s.length>0,o=(null==L?void 0:L.enabled)||l?{enabled:!!(null==L?void 0:L.enabled),photos_enabled:null!=(b=null==L?void 0:L.photos_enabled)&&b,project_id:null!=S?S:null==L?void 0:L.project_id,...(null==L?void 0:L.selection)?{selection:L.selection}:{},...l?{pins:{file_ids:s}}:{}}:void 0;if(M&&"streaming"===i.Lo.getState().streamState&&null!==i.Lo.getState().streamingMessage){t.current.some(t=>t.clientEventId===e.current)||t.current.push({conversationId:n,parts:H,clientEventId:e.current,loc:null!=r?r:void 0,kb:o,writing:z,optimisticUserMessageId:B.id});return}await a.F.sendMessage(n,H,e.current,null!=r?r:void 0,o,z),await T(n,e.current)}catch(e){console.error("Failed to send message:",e),M||C("error"),N(B.id)}finally{P||(n.current=!1)}},[f,q,w,k,A,N,_,T,C,c]),U=(0,r.useCallback)(()=>{t.current=[],i.Lo.getState().finalizeMessage(),R(),L()},[R,L]),D=(0,r.useCallback)(async()=>{if(!f)return;let t=i.Lo.getState().removeLastAssistantMessage();_(),e.current=(0,s.Ak)();try{await a.F.regenerateResponse(f),await T(f,e.current)}catch(e){if(console.error("Failed to regenerate response:",e),C("error"),t){let e=i.Lo.getState();e.setMessages([...e.messages,t])}}},[f,_,T,C]),O=(0,r.useCallback)(async(t,n)=>{if(f)try{await a.F.submitAskQuestionsResponse(f,{tool_call_id:t,answers:n}),e.current=(0,s.Ak)(),_(),await T(f,e.current)}catch(e){console.error("Failed to submit ask questions response:",e),C("error")}},[f,_,T,C]);return{conversationId:f,messages:y,streamState:M,createConversation:q,sendMessage:B,cancelStream:U,regenerateResponse:D,submitAskQuestionsResponse:O,loadConversation:(0,r.useCallback)(async e=>{x(e),k();try{var t,n,r,l,o,c;let d=await a.F.getConversation(e),u=d.messages.map(e=>{var t,n,r,a,i,l,o,c;let d=[];if(e.parts)for(let t of e.parts)"file_data"===t.type&&t.file_data&&d.push({id:(0,s.Ak)(),type:t.file_data.mime_type.startsWith("image/")?"image":"file",mimeType:t.file_data.mime_type,fileUri:t.file_data.file_uri,name:t.file_data.file_uri.split("/").pop()||"file",url:t.file_data.file_uri});return{id:e.id,role:"model"===e.role?"assistant":e.role,content:e.content,attachments:d.length>0?d:void 0,thoughts:e.thoughts||void 0,grounding:e.grounding_sources?{type:"grounding",webSearchQueries:e.grounding_sources.webSearchQueries||[],sources:e.grounding_sources.sources||[],groundingChunks:e.grounding_sources.groundingChunks||[],groundingSupports:e.grounding_sources.groundingSupports||[]}:void 0,sources:(null==(t=e.extra_metadata)?void 0:t.normalized_sources)||void 0,images:e.rich_images||void 0,askQuestions:(null==(n=e.extra_metadata)?void 0:n.ask_questions_payload)?{type:"ask_questions",tool_call_id:e.extra_metadata.tool_call_id||"",payload:e.extra_metadata.ask_questions_payload}:void 0,searchQueries:e.search_queries||void 0,mediaPaths:e.media_paths||void 0,suggestions:(null==(r=e.suggestions)?void 0:r.length)?e.suggestions:void 0,assessments:(null==(a=e.assessments)?void 0:a.length)?e.assessments:void 0,artifacts:(null==(i=e.artifacts)?void 0:i.length)?e.artifacts:void 0,writingArtifacts:(null==(l=e.writing_artifacts)?void 0:l.length)?e.writing_artifacts:void 0,meta:{tokens:(null==(o=e.extra_metadata)?void 0:o.tokens)||0,thoughtsTokens:(null==(c=e.extra_metadata)?void 0:c.thoughtsTokens)||void 0,thinkingDurationSeconds:e.thinking_duration_seconds||void 0},createdAt:new Date(e.created_at)}});j(u);let{conversations:m}=i.Lo.getState(),g=d.conversation,p=m.find(t=>
1t.id===e);p?b(e,{projectId:null!=(t=g.project_id)?t:void 0,title:null!=(r=null!=(n=g.title)?n:p.title)?r:""}):v({id:e,title:null!=(l=g.title)?l:"",mode:"chat",messageCount:null!=(o=g.message_count)?o:0,createdAt:new Date(g.created_at),updatedAt:new Date(g.updated_at),projectId:null!=(c=g.project_id)?c:void 0})}catch(e){console.error("Failed to load conversation:",e)}},[x,k,j,v,b]),setMessages:j}}},46332:(e,t,n)=>{n.d(t,{E:()=>a});var r=n(18526),s=n(40660);function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onEvent:t,onError:n,onComplete:a,onCreditsBlocked:l}=e,[o,c]=(0,r.useState)("idle"),d=(0,r.useRef)(null),u=(0,r.useRef)(!1),m=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{var e;null==(e=d.current)||e.abort(),m.current&&clearTimeout(m.current),u.current=!1},[]);let g=(0,r.useCallback)(async(e,r)=>{var o,g,p;null==(o=d.current)||o.abort(),d.current=new AbortController,u.current=!1,c("connecting");try{let n=s.F.getStreamUrl(e,r),o=await s.F.getStreamHeaders(),h=await fetch(n,{headers:o,signal:d.current.signal});if(402===h.status){let e={};try{let t=await h.json(),n=t.detail;e="object"!=typeof n||null===n||Array.isArray(n)?t:n}catch(e){}null==l||l({tier_status:"string"==typeof e.tier_status?e.tier_status:void 0,credits_remaining:Number(null!=(g=e.credits_remaining)?g:0),credits_required:Number(null!=(p=e.credits_required)?p:0),feature:"string"==typeof e.feature?e.feature:"chat_message"}),c("idle");return}if(!h.ok)throw Error("HTTP ".concat(h.status,": ").concat(h.statusText));if(!h.body)throw Error("Response body is null");c("streaming");let f=h.body.getReader(),x=new TextDecoder,v="",b=()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{var e;console.warn("[useStream] Connection stalled â no data for",45,"s"),u.current=!0,null==(e=d.current)||e.abort()},45e3)};b();try{for(;;){let{done:e,value:n}=await f.read();if(e){v.trim()&&i(v.split("\n"),t);break}b();let r=(v+=x.decode(n,{stream:!0})).split("\n");v=r.pop()||"",i(r,t)}}finally{m.current&&(clearTimeout(m.current),m.current=null)}c("complete"),null==a||a()}catch(r){if(r instanceof Error&&"AbortError"===r.name){if(u.current){u.current=!1;let e=Error("Stream connection lost â no data received for an extended period.");console.error("Stream stall abort:",e),c("error"),null==n||n(e),null==t||t({type:"error",code:"network_error",status:0,message:e.message});return}c("idle");return}console.error("Stream error:",r),c("error");let e=r instanceof Error?r:Error(String(r));null==n||n(e),null==t||t({type:"error",code:"network_error",status:0,message:e.message})}},[t,n,a,l]);return{state:o,isStreaming:"streaming"===o,isConnecting:"connecting"===o,isComplete:"complete"===o,isError:"error"===o,isIdle:"idle"===o,startStream:g,abort:(0,r.useCallback)(()=>{var e;null==(e=d.current)||e.abort(),d.current=null,c("idle")},[]),reset:(0,r.useCallback)(()=>{var e;null==(e=d.current)||e.abort(),d.current=null,c("idle")},[])}}function i(e,t){for(let n of e){let e=n.trim();if(!(!e||e.startsWith(":"))&&e.startsWith("data: ")){let n=e.slice(6);if("[DONE]"===n)continue;try{let e=JSON.parse(n);null==t||t(e)}catch(e){console.warn("Failed to parse SSE event:",n,e)}}}}},57068:(e,t,n)=>{n.d(t,{n:()=>a});var r=n(70862),s=n(99049);function a(e){let{as:t="span",className:n,duration:a=4,spread:i=20,children:l,...o}=e,c=Math.min(Math.max(i,5),45);return(0,r.jsx)(t,{className:(0,s.cn)("bg-[length:200%_auto] bg-clip-text font-medium text-transparent","animate-shimmer",n),style:{backgroundImage:"linear-gradient(to right, hsl(var(--muted-foreground)) ".concat(50-c,"%, hsl(var(--foreground)) 50%, hsl(var(--muted-foreground)) ").concat(50+c,"%)"),animationDuration:"".concat(a,"s")},...o,children:l})}}}]);
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.