@qredence/fleet 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/web/client/assets/{chat-command-palette-DdPlRVuL.js → chat-command-palette-AjGusIEp.js} +1 -1
- package/dist/web/client/assets/{create-project-dialog-CaXurRpm.js → create-project-dialog-zTSeGUup.js} +1 -1
- package/dist/web/client/assets/globals-BiAbxPQ2.css +2 -0
- package/dist/web/client/assets/{index-BJIGh8ag.js → index-NhnAdIsR.js} +2 -2
- package/dist/web/client/assets/{message-queue-CPYj2iaw.js → message-queue-BoNn57Po.js} +1 -1
- package/dist/web/client/assets/prompt-input-BhVQxoyh.js +1 -0
- package/dist/web/client/assets/{prompt-suggestions-ULqmPijZ.js → prompt-suggestions-BRFWFm5y.js} +1 -1
- package/dist/web/client/assets/right-panel-registry-gwgnEeUz.js +2 -0
- package/dist/web/client/assets/routes-umGEy_Ak.js +16 -0
- package/dist/web/client/assets/{settings-dialog-BRWheaBZ.js → settings-dialog-C8YN5D1V.js} +1 -1
- package/dist/web/client/assets/{subagent-chat-panel-B6d4Z3bV.js → subagent-chat-panel-BIsmzS45.js} +1 -1
- package/dist/web/client/assets/{subagent-transcript-CQuPs6N4.js → subagent-transcript-CEUBL9sF.js} +1 -1
- package/dist/web/client/assets/{subagents-panel-ajf--C_-.js → subagents-panel-CFxWpUT0.js} +1 -1
- package/dist/web/client/assets/{tokens-BcUIpW6Y.js → tokens-CtP2s1Y3.js} +1 -1
- package/dist/web/client/assets/types-D5hZ8IyV.js +1 -0
- package/dist/web/client/assets/virtualized-turn-list-DkJIWXFJ.js +6 -0
- package/dist/web/client/bundle-budget.json +6 -6
- package/dist/web/server/{_tanstack-start-manifest_v-BZR0i182-OLTGGEDQ.js → _tanstack-start-manifest_v-B3Gb4p5p-DO2GL5VM.js} +9 -10
- package/dist/web/server/{artifacts-panel-BySfu7im-AKBWHYJS.js → artifacts-panel-CGgpyc85-V3KXDVAX.js} +2 -2
- package/dist/web/server/{chat-command-palette-BLGKnp-w-OKFIKD3T.js → chat-command-palette-BMR7RsuI-U5S4X44U.js} +2 -2
- package/dist/web/server/{chunk-4B2PJSK5.js → chunk-5TXDGMCK.js} +14 -4
- package/dist/web/server/{chunk-ONWT54IL.js → chunk-BS4D5LRR.js} +5 -1
- package/dist/web/server/{chunk-JLGBOCFM.js → chunk-ELRLMFHT.js} +49 -33
- package/dist/web/server/{chunk-JZ2WBCIH.js → chunk-G6NMFFZX.js} +624 -624
- package/dist/web/server/{chunk-47TH5VUT.js → chunk-LBUHLBKK.js} +2 -2
- package/dist/web/server/{chunk-2GQATGF4.js → chunk-N47UN47Y.js} +3 -3
- package/dist/web/server/{chunk-CIE2PLNB.js → chunk-PX7B5BTI.js} +2 -2
- package/dist/web/server/{chunk-NHZRY22Z.js → chunk-SOZKLVNI.js} +59 -19
- package/dist/web/server/{create-project-dialog-CigfFgAj-QS27NAJH.js → create-project-dialog-xhTWmcx1-UQQU3MAT.js} +2 -2
- package/dist/web/server/{message-queue-BsrLcNPX-CUCBSF6U.js → message-queue-Dg2okv2L-SJTUUJS7.js} +4 -4
- package/dist/web/server/{openui-renderer-TbIFXEW2-BET2OXM2.js → openui-renderer-CiWvcD3p-N6I66FOC.js} +1 -1
- package/dist/web/server/{prompt-suggestions-D6RXFQF4-7WHYRNMN.js → prompt-suggestions-h17Gu7u1-BS5SU2FY.js} +2 -2
- package/dist/web/server/{router-RPObiwZR-AFMFSYSZ.js → router-DOPFvRSC-G7G75P7U.js} +84 -28
- package/dist/web/server/{routes-Dn-deuPY-MDXEQXRU.js → routes-i2Ai-ZwX-SMSFONDQ.js} +469 -352
- package/dist/web/server/server.js +2 -2
- package/dist/web/server/{settings-dialog-CzeangBl-YKL7CLPF.js → settings-dialog-C-xwPYy8-TFICZWEM.js} +7 -7
- package/dist/web/server/{subagent-chat-panel-Fa31QewE-YDPOKN74.js → subagent-chat-panel-VEVu0QXU-DPWJFCYR.js} +5 -4
- package/dist/web/server/{subagents-panel-DjOcQxp4-GZYOZOYC.js → subagents-panel-Cs3cBcsy-HTQBIYAS.js} +4 -3
- package/package.json +1 -1
- package/dist/web/client/assets/globals-B-fD_O7k.css +0 -2
- package/dist/web/client/assets/prompt-input-a7UP_MAw.js +0 -1
- package/dist/web/client/assets/right-panel-registry-BqtgZw7Z.js +0 -2
- package/dist/web/client/assets/routes-C37r2W1K.js +0 -16
- package/dist/web/client/assets/types-Cr5Z97oW.js +0 -1
- package/dist/web/client/assets/virtualized-turn-list-Bcq088gZ.js +0 -6
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-CQY2ECfR.js";import{d as t,i as n,l as r,u as i}from"./chat-helpers-Bj7_hES7.js";import{t as a}from"./safe-storage-s25GrfpH.js";var o={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};o.node;var s=e(o),c={name:`folder-tree`,size:24,node:[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]};c.node;var l=e(c),u=`https://docs.qredence.ai`,d=`fleet-prime:v1:sidebar-expanded-projects`,f=[],p=`new-session:`,m=`project:`,h=`session:`;function g(e){return`${m}${e}`}function _(e){return`${h}${e}`}function v(e){return`${p}${e}`}function y(e,t){return e.startsWith(t)?e.slice(t.length):null}function b(e){return n(t({sessionId:e.sessionId,title:e.title,firstMessage:e.firstMessage}))||i(e.sessionId)}function x(e,t){let n=b(e);if(!t)return n;let i=0;for(let e of t)b(e)===n&&(i+=1);return r(n,e.sessionId,i)}function S(e,t){return`${e.projectId?t.get(e.projectId)?.name??`Unassigned`:`Unassigned`} · ${e.status===`idle`?`Ready`:e.status} · ${`${String(e.messageCount)} ${e.messageCount===1?`message`:`messages`}`}`}function C(e){let t=Date.parse(e);if(!Number.isFinite(t))return`Earlier`;let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=Math.floor((r-new Date(t).setHours(0,0,0,0))/864e5);return i<=0?`Today`:i===1?`Yesterday`:`Earlier`}function w(e){return e.hasChildren?`${e.name}/`:e.name}function T(e,t){return e instanceof Error&&e.message.trim()?e.message:t}function E(e){let t=a(d);if(!t)return e?[g(e)]:[];try{let e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return e?[g(e)]:[]}}export{l as _,m as a,y as c,g as d,E as f,C as g,_ as h,p as i,v as l,x as m,f as n,h as o,S as p,d as r,T as s,u as t,w as u,s as v};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/openui-renderer-l1qI5JDt.js","assets/rolldown-runtime-hePW80VL.js","assets/react-Cvdyeg_0.js","assets/react-dom-B7th3XGm.js","assets/jsx-runtime-NZYk81nU.js","assets/button-BrwYi6QP.js","assets/utils-Dpy9ZFOr.js","assets/createBaseUIEventDetails-DklXWq23.js","assets/dist-BogNzeK9.js","assets/clsx-DB0hHKMi.js","assets/card-BScRdZNS.js","assets/provider-catalog-L0c-bZv6.js","assets/DialogTitle-BwQ9k-MZ.js","assets/useBaseUiId-BlzQUkVG.js","assets/check-BTwIaCtI.js","assets/createLucideIcon-CQY2ECfR.js","assets/chevron-down-Bse1ggZM.js","assets/useControlled-CkQSkSv1.js","assets/input-BceH49B1.js","assets/safe-external-url-BnEhm9A0.js","assets/chunk-YOKDWASO-C8deEx7Z.js","assets/preload-helper-Czpn1I53.js","assets/lib-ChrQ49PO.js","assets/character-entities-legacy-Wut6vMuj.js","assets/openui-utils-DawGoQNp.js","assets/composer-intent-C5pz72T6.js","assets/dialog-B9nXTto4.js","assets/x-DEU6H3M-.js","assets/markdown-C-Y9gskI.js","assets/switch-CoSNSJEY.js","assets/dist-BJJVCio8.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./react-dom-B7th3XGm.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{t as i}from"./utils-Dpy9ZFOr.js";import{d as a,o,r as s}from"./ease-2UPBQU5v.js";import{n as c,t as l}from"./use-reduced-motion-CaQBb3Qc.js";import{t as u}from"./createLucideIcon-CQY2ECfR.js";import{i as d}from"./citations-DOkXsdCi.js";import{t as f}from"./check-BTwIaCtI.js";import{t as p}from"./chevron-right-BPCB1mOg.js";import{n as m,t as h}from"./file-text-cqOanUYv.js";import{t as g}from"./circle-check-DBhaebaM.js";import{a as _,i as v}from"./agent-disclosure-YgLa4c2y.js";import{t as y}from"./loader-circle-BmKYM_C4.js";import{t as b}from"./x-DEU6H3M-.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{t as S}from"./notify-GSsGEKtR.js";import{i as C}from"./workspace-path-nav-DmxBrMV6.js";import{t as w}from"./openui-utils-DawGoQNp.js";var T={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};T.node;var E=u(T),D={name:`file-braces`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]],aliases:[`file-json`]};D.node;var O=u(D),k={name:`file-code`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]};k.node;var A=u(k),j={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};j.node;var M=u(j),N={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};N.node;var P=u(N),F=e(t(),1),I=(0,F.createContext)(void 0),L=r(),R=(0,F.createContext)({animateIn:!0,variant:`soft`}),z=(0,F.createContext)(()=>{});function B(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&(n.current=t)}}var V={duration:.12,ease:s,delay:.04},H={type:`spring`,stiffness:520,damping:27,mass:.52};function U({variant:e=`soft`,align:t,animateIn:n=!1,className:r,children:s,initial:c,animate:u,exit:d,transition:f,layout:p,...m}){let h=l()??!1,g=(0,F.useContext)(I),_=t??g??`start`,v=(0,F.useMemo)(()=>({align:_,animateIn:n,variant:e}),[n,_,e]);return(0,L.jsx)(R.Provider,{value:v,children:(0,L.jsx)(a.div,{"data-slot":`message-bubble`,"data-align":_,"data-variant":e,layout:p,initial:c??!1,animate:u,exit:d??(h?{opacity:0}:{opacity:0,y:-3,scale:.99}),transition:f??(h?{duration:.12}:o),className:i(`group/bubble flex w-full flex-col`,_===`end`?`items-end`:`items-start`,r),...m,children:s})})}function ee(e,t){return i(`relative z-0 min-w-9 max-w-[82%] rounded-2xl px-3.5 py-2.5 text-sm leading-6 text-foreground`,`[&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[90%] [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p+p]:mt-2 [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:bg-background/60 [&_pre]:p-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5`,e===`solid`&&`text-background`,e===`ghost`&&`w-full max-w-none rounded-none px-0 py-0`,e===`danger`&&`text-destructive`,t&&`cursor-pointer text-left outline-none transition-[background-color,color,transform] duration-150 hover:brightness-[0.98] focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.99]`)}function W(e,t){return i(`pointer-events-none absolute inset-0 -z-10 rounded-[inherit]`,t===`end`?`origin-bottom-right`:`origin-bottom-left`,e===`solid`&&`bg-foreground`,e===`soft`&&`bg-muted`,e===`tint`&&`bg-primary/10`,e===`outline`&&`border border-border/70 bg-background`,e===`danger`&&`bg-destructive/10`)}function G({render:e,className:t,children:n,ref:r,...c}){let u=l()??!1,{align:d=`start`,animateIn:f,variant:p}=(0,F.useContext)(R),[m,h]=(0,F.useState)(0),g=(0,F.useCallback)(()=>h(e=>e+1),[]),_=e?.type===`button`||e?.type===`a`,v=i(ee(p,_),t),y=(0,L.jsxs)(L.Fragment,{children:[p===`ghost`?null:(0,L.jsx)(a.span,{"aria-hidden":`true`,layout:!1,layoutDependency:m,initial:f&&!u?{opacity:0,scale:.92}:!1,animate:{opacity:1,scale:1},transition:u?{duration:0}:{opacity:{duration:.12,ease:s},scale:H,layout:o},className:W(p,d)}),(0,L.jsx)(z.Provider,{value:g,children:(0,L.jsx)(a.div,{initial:f?{opacity:0}:!1,animate:{opacity:1},transition:u?{duration:.12,ease:s}:V,className:`relative`,children:n})})]});if(e){let t=e;return(0,F.cloneElement)(t,{...c,ref:B(t.props.ref,r),className:i(v,t.props.className),children:y,"data-slot":`message-bubble-content`})}return(0,L.jsx)(`div`,{ref:r,"data-slot":`message-bubble-content`,className:v,...c,children:y})}function te({item:e}){return(0,L.jsxs)(`div`,{"data-slot":`preview-rail-card`,className:`rounded-2xl border border-border bg-card p-4 shadow-sm`,children:[(0,L.jsx)(`p`,{"data-slot":`preview-rail-title`,className:`font-medium text-card-foreground`,children:e.label}),e.description?(0,L.jsx)(`div`,{"data-slot":`preview-rail-description`,className:`mt-1 text-sm leading-6 text-muted-foreground`,children:e.description}):null]})}function ne({items:e,label:t=`Section navigation`,orientation:n=`vertical`,activeId:r,defaultActiveId:u,onActiveChange:f,onItemSelect:p,renderPreview:m,showPreview:h=!0,previewSide:g=`after`,highlightActive:_=!1,itemSize:v=24,children:y,className:b,railClassName:x,previewContainerClassName:S,previewClassName:C}){let w=(0,F.useId)(),T=l(),E=d(),[D,O]=(0,F.useState)(u??e[0]?.id??``),[k,A]=(0,F.useState)(null),[j,M]=(0,F.useState)(null),N=r??D,P=e.some(e=>e.id===N)?N:e[0]?.id??``,I=k??j??``,R=I||(_?P:``),z=e.findIndex(e=>e.id===R),B=e.length?`repeat(${e.length}, ${v}px)`:void 0,V=n===`horizontal`,H=e=>{r===void 0&&O(e),f?.(e)};return(0,L.jsxs)(a.div,{layoutRoot:!0,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||M(null)},className:i(`isolate relative flex w-full overflow-visible`,V?`min-h-64 flex-col items-center justify-center`:`min-h-80`,b),children:[(0,L.jsx)(`nav`,{"aria-label":t,onPointerLeave:()=>A(null),style:V?{gridTemplateColumns:B}:{gridTemplateRows:B},className:i(`relative z-10 grid shrink-0`,V?`h-12 w-fit max-w-full self-center justify-center`:`w-12 content-center`,x),children:e.map((e,t)=>{let n=e.id===P,r=e.id===R,s=z<0?1/0:Math.abs(t-z),c=r?1:s===1?.68:s===2?.44:.25,l=(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(a.span,{"data-slot":`preview-rail-tick`,"aria-hidden":`true`,animate:V?{scaleY:c}:{scaleX:c},transition:T?{duration:0}:o,className:i(`block bg-current`,V?`h-12 w-0.5 origin-bottom`:`h-0.5 w-12 origin-left`,r?`text-foreground`:void 0)})}),u=i(`relative flex text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,V?`h-12 w-6 items-end justify-center`:`h-6 w-12 items-center`),d=V?{width:v}:{height:v},f=()=>{E&&A(e.id)},m=t=>{t.matches(`:focus-visible`)&&M(e.id)},h=()=>{H(e.id),p?.(e)};return e.href?(0,L.jsx)(`a`,{"data-slot":`preview-rail-item`,href:e.href,target:e.target,rel:e.rel??(e.target===`_blank`?`noreferrer noopener`:void 0),"aria-label":e.ariaLabel??e.label,"aria-current":n?`page`:void 0,onPointerEnter:f,onMouseEnter:f,onPointerDown:()=>M(null),onFocus:e=>m(e.currentTarget),onClick:h,style:d,className:u,children:l},e.id):(0,L.jsx)(`button`,{"data-slot":`preview-rail-item`,type:`button`,"aria-label":e.ariaLabel??e.label,"aria-current":n?`location`:void 0,onPointerEnter:f,onMouseEnter:f,onPointerDown:()=>M(null),onFocus:e=>m(e.currentTarget),onClick:h,style:d,className:u,children:l},e.id)})}),h?(0,L.jsx)(`div`,{"aria-hidden":`true`,style:V?{gridTemplateColumns:B}:{gridTemplateRows:B},className:i(`pointer-events-none absolute z-50 grid`,V?`top-1/2 left-1/2 h-5 w-fit max-w-full -translate-x-1/2 -translate-y-1/2 justify-center`:g===`before`?`inset-y-0 right-16 left-4 content-center`:`inset-y-0 right-4 left-16 content-center`,S),children:e.map(e=>(0,L.jsx)(`div`,{style:V?{width:v}:{height:v},className:i(`relative flex items-center`,V?`justify-center`:void 0),children:(0,L.jsx)(c,{mode:`wait`,initial:!1,children:e.id===I?(0,L.jsx)(a.div,{initial:T?{opacity:0}:{opacity:0,y:4,filter:`blur(6px)`},animate:T?{opacity:1}:{opacity:1,y:0,filter:`blur(0px)`},exit:T?{opacity:0}:{opacity:0,y:-2,filter:`blur(4px)`,transition:{duration:.12,ease:s}},transition:{duration:T?0:.18,ease:s},className:i(V?`absolute bottom-12 left-1/2 w-72 -translate-x-1/2`:i(`w-full max-w-sm`,g===`before`&&`ml-auto`),C),children:(0,L.jsx)(a.div,{layoutId:`preview-rail-card-${w}`,transition:T?{duration:0}:o,children:m?m(e):(0,L.jsx)(te,{item:e})})},e.id):null})},e.id))}):null,y?(0,L.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:y}):null]})}var K=56,re=88;function ie(e,t){if(e.length<=t)return e;let n=e.slice(0,t),r=n.lastIndexOf(` `);return`${n.slice(0,r>t*.65?r:t).trim()}…`}function q(e){return((e.querySelector(`[data-slot="message-bubble-content"]`)??e.querySelector(`[data-slot="message-content"]`)??e).textContent??``).replace(/\s+/g,` `).trim()}function ae(e,t){let n=q(e);if(!n)return{label:`Message`,description:void 0};if(n.length<=K){let e=t?q(t):``;return{label:n,description:e?ie(e,re):void 0}}let r=n.slice(0,K).lastIndexOf(` `),i=r>K*.65?r:K,a=`${n.slice(0,i).trim()}…`,o=t?q(t):n.slice(i).trim();return{label:a,description:o?ie(o,re):void 0}}function oe({navigation:e,followThreshold:t,contentRef:n,viewportRef:r,reduce:i,smooth:a,scrollToEnd:o,setFollowing:s,markProgrammaticScroll:c}){let l=(0,F.useRef)(void 0),u=(0,F.useRef)(new WeakMap),d=(0,F.useRef)(0),f=(0,F.useRef)(new Map),[p,m]=(0,F.useState)([]),[h,g]=(0,F.useState)(``),[_,v]=(0,F.useState)(!1),y=(0,F.useCallback)(()=>{if(e!==`rail`)return;let n=r.current,i=[...f.current.entries()];if(!n||i.length===0)return;let a=n.getBoundingClientRect();if(n.scrollTop<=t){let e=i[0]?.[0]??``;g(t=>t===e?t:e);return}if(n.scrollHeight-n.scrollTop-n.clientHeight<=t){let e=i.at(-1)?.[0]??``;g(t=>t===e?t:e);return}let o=a.top+a.height/2,s=i[0]?.[0]??``,c=1/0;for(let[e,t]of i){let n=t.getBoundingClientRect(),r=Math.abs(n.top+n.height/2-o);r<c&&(c=r,s=e)}g(e=>e===s?e:s)},[t,e,r]),b=(0,F.useCallback)(()=>{if(e!==`rail`)return;let t=n.current,i=r.current;if(!t||!i)return;let a=Array.from(t.querySelectorAll(`[data-slot="message"]`)),o=new Map,s=a.map((e,t)=>{let n=u.current.get(e);n||(d.current+=1,n=`message-rail-${d.current}`,u.current.set(e,n)),o.set(n,e);let r=e.dataset.from??`conversation`,i=ae(e,r===`user`?a.slice(t+1).find(e=>e.dataset.from===`assistant`):void 0);return{id:n,label:i.label,description:i.description,ariaLabel:`Go to ${r} message ${t+1} of ${a.length}`}});f.current=o,m(e=>e.length===s.length&&e.every((e,t)=>e.id===s[t]?.id&&e.label===s[t]?.label&&e.description===s[t]?.description&&e.ariaLabel===s[t]?.ariaLabel)?e:s),v(i.scrollHeight>i.clientHeight+1&&a.length>1)},[n,e,r]),x=(0,F.useCallback)(()=>{e===`rail`&&(l.current&&cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{b(),y()}))},[e,b,y]);return(0,F.useEffect)(()=>{if(e!==`rail`){f.current.clear(),m([]),v(!1);return}let t=n.current,i=r.current;if(!t||!i)return;x();let a=typeof MutationObserver>`u`?null:new MutationObserver(x);a?.observe(t,{childList:!0,characterData:!0,subtree:!0});let o=typeof ResizeObserver>`u`?null:new ResizeObserver(x);return o?.observe(t),o?.observe(i),()=>{a?.disconnect(),o?.disconnect()}},[n,e,x,r]),(0,F.useEffect)(()=>()=>{l.current&&cancelAnimationFrame(l.current)},[]),{activeRailId:h,railItems:p,railOverflowing:_,scheduleRailSync:x,scrollToRailItem:(0,F.useCallback)(e=>{let t=r.current,n=f.current.get(e.id);if(!t||!n)return;let l=p.at(-1)?.id===e.id;if(g(e.id),l){s(!0),o(i||!a?`auto`:`smooth`);return}s(!1),c(i||!a?`auto`:`smooth`);let u=t.getBoundingClientRect(),d=n.getBoundingClientRect(),m=t.scrollTop+d.top-u.top-(t.clientHeight-d.height)/2,h=i||!a?`auto`:`smooth`;typeof t.scrollTo==`function`?t.scrollTo({top:m,behavior:h}):t.scrollTop=m},[c,p,i,o,s,a,r])}}function se({followOutput:e=!0,followThreshold:t=56,smooth:n=!0,onFollowChange:r,label:a=`Conversation`,busy:o,navigation:s,navigationLabel:c=`Message navigation`,viewportClassName:u,contentClassName:d,railClassName:f,viewportRef:p,viewportProps:m,contentProps:h,className:g,children:_,...v}){let y=l()??!1,b=(0,F.useRef)(null),x=(0,F.useRef)(null),S=(0,F.useRef)(e),C=(0,F.useRef)(!1),w=(0,F.useRef)(void 0),T=(0,F.useRef)(void 0),{onScroll:E,onWheel:D,onTouchStart:O,onKeyDown:k,...A}=m??{},j=(0,F.useCallback)(e=>{b.current=e,typeof p==`function`?p(e):p&&(p.current=e)},[p]),M=(0,F.useCallback)(e=>{S.current!==e&&(S.current=e,r?.(e))},[r]),N=(0,F.useCallback)(e=>{C.current=!0,w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{C.current=!1},e===`smooth`?320:0)},[]),P=(0,F.useCallback)(e=>{let t=b.current;t&&(N(e),typeof t.scrollTo==`function`?t.scrollTo({top:t.scrollHeight,behavior:e}):t.scrollTop=t.scrollHeight)},[N]),{activeRailId:I,railItems:R,railOverflowing:z,scheduleRailSync:B,scrollToRailItem:V}=oe({navigation:s,followThreshold:t,contentRef:x,viewportRef:b,reduce:y,smooth:n,scrollToEnd:P,setFollowing:M,markProgrammaticScroll:N}),H=(0,F.useEffectEvent)(B),U=(0,F.useEffectEvent)(P),ee=(0,F.useCallback)(()=>{let e=b.current;if(!e||C.current)return;let n=e.scrollHeight-e.scrollTop-e.clientHeight;M(n<=t),B()},[t,B,M]),W=(0,F.useCallback)(()=>{C.current=!1},[]);(0,F.useLayoutEffect)(()=>{if(S.current=e,e)return T.current=requestAnimationFrame(()=>U(`auto`)),()=>{T.current&&cancelAnimationFrame(T.current)}},[e]),(0,F.useEffect)(()=>{let t=x.current;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{H(),!(!e||!S.current)&&U(y||!n?`auto`:`smooth`)});return r.observe(t),()=>r.disconnect()},[e,y,n]),(0,F.useEffect)(()=>()=>{w.current&&window.clearTimeout(w.current),T.current&&cancelAnimationFrame(T.current)},[]);let G=(0,L.jsx)(`section`,{ref:j,"aria-label":a,...A,onScroll:e=>{ee(),E?.(e)},onWheel:e=>{W(),D?.(e)},onTouchStart:e=>{W(),O?.(e)},onKeyDown:e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)&&W(),k?.(e)},className:i(`h-full overflow-y-auto overscroll-contain outline-none [overflow-anchor:none] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,s===`rail`?`[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`:`[scrollbar-gutter:stable]`,u,s===`rail`&&z&&`pr-10`),children:(0,L.jsx)(`div`,{ref:x,role:`log`,"aria-live":o?`off`:`polite`,"aria-relevant":`additions text`,"aria-busy":o,className:d,...h,children:_})});return(0,L.jsx)(`div`,{"data-slot":`message-scroller`,className:i(`min-h-0`,g),...v,children:s===`rail`?(0,L.jsx)(ne,{items:z?R:[],label:c,activeId:I,onItemSelect:V,previewSide:`before`,highlightActive:!0,itemSize:14,className:`h-full min-h-0 overflow-hidden`,previewContainerClassName:`right-8 left-3`,previewClassName:`mr-1 w-64 max-w-full [&_[data-slot=preview-rail-card]]:h-20 [&_[data-slot=preview-rail-card]]:overflow-hidden [&_[data-slot=preview-rail-card]]:p-3 [&_[data-slot=preview-rail-title]]:line-clamp-1 [&_[data-slot=preview-rail-title]]:text-xs [&_[data-slot=preview-rail-title]]:leading-4 [&_[data-slot=preview-rail-description]]:line-clamp-2 [&_[data-slot=preview-rail-description]]:text-xs [&_[data-slot=preview-rail-description]]:leading-4`,railClassName:i(`absolute inset-y-3 right-1 w-7 content-center py-1 [&_[data-slot=preview-rail-item]]:w-7 [&_[data-slot=preview-rail-item]]:justify-end [&_[data-slot=preview-rail-tick]]:h-px [&_[data-slot=preview-rail-tick]]:w-4 [&_[data-slot=preview-rail-tick]]:origin-right`,z?`pointer-events-auto opacity-100`:`pointer-events-none opacity-0`,f),children:G}):G})}var ce=(0,F.createContext)({from:`assistant`}),le={type:`spring`,stiffness:480,damping:32,mass:.62};function ue({from:e,animateIn:t=!1,children:n,className:r,initial:o,animate:s,transition:c,exit:u,style:d,...f}){let p=l()??!1,m=(0,F.useMemo)(()=>({from:e}),[e]);return(0,L.jsx)(I.Provider,{value:e===`user`?`end`:`start`,children:(0,L.jsx)(ce.Provider,{value:m,children:(0,L.jsx)(a.article,{"data-slot":`message`,"data-from":e,"aria-label":f[`aria-label`]??`${e} message`,initial:o??(t&&!p?{opacity:0,transform:`translateY(8px) scale(0.95)`}:!1),animate:s??(t&&!p?{opacity:1,transform:`translateY(0px) scale(1)`}:{opacity:1}),exit:u??(p?{opacity:0}:{opacity:0,transform:`translateY(-3px) scale(0.99)`}),transition:c??(p?{duration:.12}:le),style:{transformOrigin:e===`user`?`100% 100%`:`0% 100%`,...d},className:i(`group/message flex w-full items-start gap-2`,e===`user`?`flex-row-reverse`:`flex-row`,r),...f,children:n})})})}function de({className:e,...t}){let{from:n}=(0,F.useContext)(ce);return(0,L.jsx)(`div`,{"data-slot":`message-content`,className:i(`flex min-w-0 flex-1 flex-col gap-1.5`,n===`user`?`items-end`:`items-start`,e),...t})}function fe(e){return typeof e==`object`&&!!e}function J(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t)return e;try{let n=JSON.parse(t);return fe(n)||Array.isArray(n)?n:e}catch{return e}}function pe(e){if(!fe(e)||typeof e.type!=`string`||!e.type.startsWith(`tool-`))return e;let t=J(e.input),n=J(e.output),r=J(e.result),i=t!==e.input,a=n!==e.output,o=r!==e.result;if(!i&&!a&&!o)return e;let s={...e};return i&&(s.input=t),a&&(s.output=n),o&&(s.result=r),s}function me(e){let t=!1,n=e.map(e=>{let n=pe(e);return n!==e&&(t=!0),n});return t?n:e}var he=(0,F.memo)(function({title:e=`Something went wrong`,message:t,className:n}){return(0,L.jsx)(`div`,{className:i(`flex justify-start`,n),children:(0,L.jsxs)(`div`,{className:`rounded-[8px] border border-red-500/30 bg-red-500/10 px-4 py-2.5 text-sm text-foreground`,children:[(0,L.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,L.jsx)(`div`,{className:`mt-0.5 text-muted-foreground`,children:t})]})})});function Y(e){return typeof e==`object`&&!!e}function X(e){return Y(e)&&e.type===`text`&&typeof e.text==`string`}function ge(e){return Y(e)&&e.type===`error`&&typeof e.message==`string`}function _e(e){return Y(e)&&e.type===`payload`&&typeof e.kind==`string`&&typeof e.title==`string`}function Z(e){if(!Y(e))return!1;let t=e.type;return t===`dynamic-tool`||typeof t==`string`&&t.startsWith(`tool-`)}function ve(e,t){let n=[];for(let t of e)X(t)&&n.push(t.text);return n.join(t)}var ye=new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,hour12:!0}),be=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`});function xe(e){let t=new Date;return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()?ye.format(e):be.format(e)}function Se({text:e,onCopied:t}){let[n,r]=(0,F.useState)(!1),a=(0,F.useRef)(null);return(0,F.useEffect)(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),(0,L.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":n?`Copied`:`Copy message`,onClick:async()=>{try{await navigator.clipboard.writeText(e),r(!0),a.current&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{r(!1),a.current=null},2e3),S.success(`Copied to clipboard`),t?.()}catch{S.error(`Failed to copy to clipboard`)}},onPointerDown:e=>{e.stopPropagation()},onMouseDown:e=>e.stopPropagation(),className:i(`flex size-6 items-center justify-center rounded-md transition-[background-color,opacity,transform] duration-150 ease-out active:scale-[0.97]`,`bg-transparent opacity-50 hover:bg-foreground/10 hover:opacity-100`),children:(0,L.jsxs)(`div`,{className:`relative size-3.5`,children:[(0,L.jsx)(v,{className:i(`absolute inset-0 h-3.5 w-3.5 text-muted-foreground transition-[opacity,transform] duration-150 ease-out`,n?`scale-50 opacity-0`:`scale-100 opacity-100`)}),(0,L.jsx)(f,{className:i(`absolute inset-0 h-3.5 w-3.5 text-muted-foreground transition-[opacity,transform] duration-150 ease-out`,n?`scale-100 opacity-100`:`scale-50 opacity-0`)})]})})}function Ce({text:e,timestamp:t,heightClass:n,hoverClass:r,isVisible:a,alignClass:o,onCopied:s}){return(0,L.jsxs)(`div`,{className:i(`pointer-events-none flex items-center gap-1 pt-1 text-xs text-muted-foreground/70 opacity-0 transition-opacity duration-100`,n,o,r,a&&`pointer-events-auto opacity-100`),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[t&&(0,L.jsx)(`span`,{children:t}),e&&(0,L.jsx)(Se,{text:e,onCopied:s})]})}function we(e){if(typeof e==`string`)return e;if(e===void 0)return``;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function Te({part:e}){let t=we(e.payload);return(0,L.jsxs)(`section`,{"data-payload-kind":e.kind,className:`w-full min-w-0 overflow-hidden rounded-xl border border-border/60 bg-muted/40 text-sm`,children:[(0,L.jsx)(`div`,{className:`border-b border-border/50 px-3 py-2 text-xs font-medium text-muted-foreground`,children:e.title}),e.text?(0,L.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words p-3 font-mono text-xs leading-5 text-foreground/80`,children:e.text}):null,t?(0,L.jsxs)(`details`,{open:!0,className:`border-t border-border/50 px-3 py-2`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-muted-foreground`,children:`Payload`}),(0,L.jsx)(`pre`,{className:`m-0 mt-2 max-w-full whitespace-pre-wrap break-words font-mono text-xs leading-5 text-foreground/70`,children:t})]}):null]})}var Ee=[];(0,F.memo)(function(e){let{message:t,UserMessageComponent:n,userMessageClassName:r,onCopied:i,display:a}=e,{enableImagePreview:o,showCopyToolbar:s,isMounted:c,isCopyVisible:l}=a,u=ve(t.parts??[],``),d=(t.parts??[]).length>0;if(!u&&!d)return null;let f=t?.createdAt,p=`user-${t.id}`,m=c&&f?xe(new Date(f)):void 0;return(0,L.jsxs)(`div`,{className:`group/user-message`,children:[(0,L.jsx)(n,{message:t,className:r,enableImagePreview:o}),(s&&!!u||!!m)&&(0,L.jsx)(Ce,{text:s?u:``,timestamp:m,heightClass:`h-[28px]`,hoverClass:`group-hover/user-message:opacity-100 group-hover/user-message:pointer-events-auto`,isVisible:l,alignClass:`justify-end`,onCopied:()=>i(p)})]})}),(0,F.memo)(function(e){let{assistantMsgs:t,turnKey:n,ToolRendererComponent:r,TextRendererComponent:i,toolRenderers:a,onOpenUIAction:o,onOpenUIArtifactReady:s,onOpenArtifact:c,onCopied:l,stream:u,copy:d,display:f}=e,{isLast:p,isStreaming:m}=u,{enabled:h,isVisible:g}=d,{suppressQuestionTool:_}=f,v=ve(t.flatMap(e=>e.parts??[]),`
|
|
3
|
-
|
|
4
|
-
`),y=m&&p,b=h&&!!v.trim()&&!y,x=`assistant-${n}-all`,S=h?v:``;return(0,L.jsxs)(`div`,{className:`group/assistant-turn`,children:[(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:t.map((e,n)=>{let l=p&&n===t.length-1;return(0,L.jsx)(je,{msg:e,isLast:l,isStreaming:m,suppressQuestionTool:_,ToolRendererComponent:r,TextRendererComponent:i,toolRenderers:a,onOpenUIAction:o,onOpenUIArtifactReady:s,onOpenArtifact:c},e.id)})}),(b||g)&&(0,L.jsx)(Ce,{text:S,heightClass:`h-[48px] flex items-start w-full`,hoverClass:`group-hover/assistant-turn:opacity-100 group-hover/assistant-turn:pointer-events-auto`,isVisible:g,alignClass:`justify-start`,onCopied:()=>l(x)})]})});var De=`tool-call:`,Oe=`unkeyed-tool:`;function ke(e,t,n){return t.toolCallId?`${De}${t.toolCallId}`:`${Oe}${e}:${t.type}:${n}`}function Ae(e,t){let{messageId:n,isLast:r,isStreaming:i,suppressQuestionTool:a,suppressTextWhenPlanWrite:o=!1,ToolRendererComponent:s,TextRendererComponent:c,toolRenderers:l,onOpenUIAction:u,onOpenUIArtifactReady:d,onOpenArtifact:f}=t,p=[],m=[],h=o&&e.some(e=>Z(e)&&e.type===`tool-PlanWrite`),g=new Set(e.filter(e=>Z(e)&&(e.type===`tool-Task`||e.type===`tool-Agent`)&&typeof e.toolCallId==`string`).map(e=>e.toolCallId)),_=new Map,v=new Set,y=new Map;for(let t of e){if(!Z(t)||t.type===`tool-TaskOutput`||!t.toolCallId||!t.toolCallId.includes(`:`))continue;let e=t.toolCallId.split(`:`)[0];g.has(e)&&(_.has(e)||_.set(e,[]),_.get(e).push(t),v.add(t.toolCallId))}let b=0;for(;b<e.length;){let t=e[b];if(Z(t)&&t.type===`tool-TaskOutput`){b++;continue}if(X(t)){let e=t.text;e&&!h&&m.push(e),b++;continue}if(ge(t)){p.push((0,L.jsx)(he,{title:t.title,message:t.message},`${n}-error-${t.title}-${t.message}`)),b++;continue}if(_e(t)){p.push((0,L.jsx)(Te,{part:t},`${n}-payload-${b}`)),b++;continue}if(Z(t)){if(a&&t.type===`tool-Question`){b++;continue}if(t.toolCallId&&v.has(t.toolCallId)){b++;continue}let e=r&&i?`streaming`:void 0,o=t.toolCallId,c=(t.type===`tool-Task`||t.type===`tool-Agent`)&&o?_.get(o)??Ee:void 0,u=t.toolCallId?0:y.get(t.type)??0;t.toolCallId||y.set(t.type,u+1),p.push((0,L.jsx)(s,{part:t,nestedTools:c,chatStatus:e,toolRenderers:l},ke(n,t,u))),b++;continue}b++}let x=m.join(`
|
|
5
|
-
|
|
6
|
-
`);return x&&p.push((0,L.jsx)(`div`,{className:`group/assistant-text text-body`,children:(0,L.jsx)(c,{content:x,isStreaming:i,messageId:n,onOpenUIAction:u,onOpenUIArtifactReady:d,onOpenArtifact:f,className:`leading-relaxed [&_p]:leading-relaxed`})},`${n}-text-final`)),p}function je({msg:e,isLast:t,isStreaming:n,suppressQuestionTool:r,ToolRendererComponent:i,TextRendererComponent:a,toolRenderers:o,onOpenUIAction:s,onOpenUIArtifactReady:c,onOpenArtifact:l}){let u=(0,F.useMemo)(()=>me(e.parts??[]),[e.parts]),d=(0,F.useMemo)(()=>Ae(u,{messageId:e.id,isLast:t,isStreaming:n,suppressQuestionTool:r,ToolRendererComponent:i,TextRendererComponent:a,toolRenderers:o,onOpenUIAction:s,onOpenUIArtifactReady:c,onOpenArtifact:l}),[u,e.id,t,n,r,i,a,o,s,c,l]);return d.length>1?(0,L.jsx)(`div`,{className:`group/assistant-turn flex flex-col gap-3`,children:d}):(0,L.jsx)(`div`,{className:`group/assistant-turn`,children:d})}var Me=e(n(),1);function Ne({open:e,onClose:t,images:n,initialIndex:r=0}){let[a,o]=(0,F.useState)(r),s=n.length>1;(0,F.useEffect)(()=>{e&&o(r)},[e,r]);let c=(0,F.useCallback)(e=>{e?.stopPropagation(),o(e=>e>0?e-1:n.length-1)},[n.length]),l=(0,F.useCallback)(e=>{e?.stopPropagation(),o(e=>e<n.length-1?e+1:0)},[n.length]),u=(0,F.useEffectEvent)(e=>{switch(e.key){case`ArrowLeft`:e.preventDefault(),s&&c();break;case`ArrowRight`:e.preventDefault(),s&&l()}});(0,F.useEffect)(()=>{if(!e)return;let t=e=>u(e);return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e]),(0,F.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e]);let d=(0,F.useRef)(null),f=(0,F.useEffectEvent)(e=>{d.current&&e.target===d.current&&t()});if((0,F.useEffect)(()=>{if(!e)return;let t=d.current;if(!t)return;t.open||t.showModal();let n=e=>f(e);return t.addEventListener(`click`,n),()=>{t.removeEventListener(`click`,n),t.open&&t.close()}},[e]),typeof document>`u`||!e)return null;let m=n[a]??n[0];return m?.url?(0,Me.createPortal)((0,L.jsxs)(`dialog`,{ref:d,"aria-label":`Image viewer`,onClose:()=>t(),className:`fixed inset-0 z-50 m-0 flex h-full max-h-none w-full max-w-none items-center justify-center border-0 bg-black/90 p-0 backdrop:bg-transparent`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close fullscreen (Esc)`,className:`absolute top-4 right-4 z-10 inline-flex size-9 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70`,children:(0,L.jsx)(b,{className:`size-5`})}),s&&(0,L.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Previous image (←)`,className:`absolute top-1/2 left-4 z-10 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70`,children:(0,L.jsx)(E,{className:`size-6`})}),(0,L.jsx)(`img`,{src:m.url,alt:m.filename??`Image preview`,className:`max-h-[85vh] max-w-[90vw] object-contain select-none`,onClick:e=>e.stopPropagation(),draggable:!1}),s&&(0,L.jsx)(`button`,{type:`button`,onClick:l,"aria-label":`Next image (→)`,className:`absolute top-1/2 right-4 z-10 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70`,children:(0,L.jsx)(p,{className:`size-6`})}),s&&(0,L.jsxs)(`div`,{className:`absolute bottom-6 left-1/2 flex -translate-x-1/2 flex-col items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex gap-2`,children:n.map((e,t)=>(0,L.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(t)},"aria-label":`Go to image ${t+1}`,className:i(`size-2 rounded-full transition-all`,t===a?`scale-125 bg-white`:`bg-white/40 hover:bg-white/60`)},e.url))}),(0,L.jsxs)(`span`,{className:`text-sm text-white/70`,children:[a+1,` / `,n.length]})]})]}),document.body):null}function Pe(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Fe(e,t){if(t)return`image`;let n=e.split(`.`).pop()?.toLowerCase();return[`js`,`ts`,`jsx`,`tsx`,`py`,`rb`,`go`,`rs`,`java`,`kt`,`swift`,`c`,`cpp`,`h`,`hpp`,`cs`,`php`].includes(n||``)?`code`:[`json`,`yaml`,`yml`,`xml`].includes(n||``)?`data`:`text`}function Ie(e){switch(e){case`image`:return(0,L.jsx)(M,{className:`size-4 text-muted-foreground`});case`code`:return(0,L.jsx)(A,{className:`size-4 text-muted-foreground`});case`data`:return(0,L.jsx)(O,{className:`size-4 text-muted-foreground`});default:return(0,L.jsx)(h,{className:`size-4 text-muted-foreground`})}}function Le({id:e,filename:t,size:n,isImage:r,url:a,onRemove:o,className:s,display:c=`chip`,enableImagePreview:l=!0}){let[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),m=Fe(t,r),h=c===`image-only`&&r&&!!a,g=!!(l&&r&&a),_=e=>{e?.stopPropagation(),p(!0)};return(0,L.jsxs)(`div`,{className:i(`relative rounded-[calc(var(--chat-input-radius)-var(--chat-context-padding))] bg-muted/50`,h?`flex size-10 items-center justify-center`:`flex max-w-[200px] min-w-[120px] items-center gap-2 py-1 pr-2 pl-1`,s),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[h?(0,L.jsx)(`div`,{className:i(`size-8 shrink-0 overflow-hidden rounded-[calc(var(--chat-input-radius)-var(--chat-context-padding)-2px)]`,g&&`cursor-pointer`),onClick:g?_:void 0,role:g?`button`:void 0,tabIndex:g?0:void 0,"aria-label":g?`Preview ${t}`:void 0,onKeyDown:g?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_())}:void 0,children:(0,L.jsx)(`img`,{src:a,alt:t,className:`h-full w-full object-cover`})}):(0,L.jsxs)(L.Fragment,{children:[r&&a?(0,L.jsx)(`div`,{className:i(`w-8 shrink-0 self-stretch overflow-hidden rounded-[calc(var(--chat-input-radius)-var(--chat-context-padding)-2px)]`,g&&`cursor-pointer`),onClick:g?_:void 0,role:g?`button`:void 0,tabIndex:g?0:void 0,"aria-label":g?`Preview ${t}`:void 0,onKeyDown:g?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_())}:void 0,children:(0,L.jsx)(`img`,{src:a,alt:t,className:`aspect-square h-full w-full object-cover`})}):(0,L.jsx)(`div`,{className:`flex w-8 shrink-0 items-center justify-center self-stretch rounded-[calc(var(--chat-input-radius)-var(--chat-context-padding)-2px)] bg-muted`,children:Ie(m)}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,L.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,title:t,children:t}),n!==void 0&&(0,L.jsx)(`span`,{className:`text-micro text-muted-foreground`,children:Pe(n)})]})]}),o&&(0,L.jsx)(`button`,{onClick:e=>{e.stopPropagation(),o()},"aria-label":`Remove ${t}`,className:`absolute -top-1.5 -right-1.5 z-10 flex size-4 items-center justify-center rounded-full border border-border bg-background text-muted-foreground transition-[opacity,transform] duration-150 ease-out hover:text-foreground active:scale-[0.97] ${u?`opacity-100`:`opacity-0`}`,type:`button`,children:(0,L.jsx)(b,{className:`size-3`})}),g&&a&&(0,L.jsx)(Ne,{open:f,onClose:()=>p(!1),images:[{id:e,url:a,filename:t}]})]})}function Q(e){return typeof e==`object`&&!!e}function Re(e){if(!Q(e))return null;let t=e.type;if(typeof t!=`string`)return null;if(t===`image`){let t=e;return t.url??t.image??null}if(t===`data-image`)return e.data?.url??null;if(t===`file`){let t=e;if(t.mimeType?.startsWith(`image/`)){if(t.url)return t.url;if(t.data)return`data:${t.mimeType};base64,${t.data}`}}return null}function ze(e){if(!Q(e)||e.type!==`file`)return null;let t=e,n=t.filename||t.name||t.fileName||`Attachment`;return t.mimeType?.startsWith(`image/`)??!1?null:{filename:n,size:t.size}}var Be=(0,F.memo)(function({message:e,className:t,enableImagePreview:n=!0}){let[r,a]=(0,F.useState)(null),o=(e.parts?.filter(X)??[]).map(e=>e.text).join(``),s=[],c=[];for(let t of e.parts??[]){let e=Re(t);e&&s.push(e);let n=ze(t);n&&c.push(n)}if(Q(e)&&Array.isArray(e.experimental_attachments))for(let t of e.experimental_attachments)t.contentType?.startsWith(`image/`)&&t.url&&s.push(t.url);if(!o&&s.length===0&&c.length===0)return null;let l=s.map((t,n)=>({id:`${e.id}-img-${n}`,url:t,filename:`image-${n+1}`}));return(0,L.jsxs)(`div`,{className:i(`flex flex-col items-end gap-1`,t),children:[s.length>0&&s.map((e,t)=>(0,L.jsx)(`div`,{className:i(`max-w-[200px] rounded-chat-message bg-foreground/4 p-1.5`,n&&`cursor-pointer`),onClick:n?()=>a(t):void 0,role:n?`button`:void 0,tabIndex:n?0:void 0,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a(t))}:void 0,children:(0,L.jsx)(`img`,{src:e,alt:`attachment`,width:184,height:120,className:`block max-h-[120px] max-w-[184px] rounded-chat-message-inner object-cover`})},e)),n&&l.length>0&&(0,L.jsx)(Ne,{open:r!==null,onClose:()=>a(null),images:l,initialIndex:r??0}),c.length>0&&(0,L.jsx)(`div`,{className:`flex flex-col items-end gap-2`,children:c.map((e,t)=>(0,L.jsx)(Le,{id:`${e.filename}-${t}`,filename:e.filename,size:e.size},`${e.filename}-${e.size}`))}),o&&(0,L.jsx)(`div`,{className:`ms-[70px] max-w-[calc(95%-40px)]`,children:(0,L.jsx)(`div`,{className:`rounded-chat-message bg-muted px-3.5 py-1.5 text-sm text-foreground transition-colors`,children:(0,L.jsx)(`p`,{className:`leading-5 wrap-break-word whitespace-pre-wrap text-pretty`,children:o})})})]})});function Ve(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set,i=[],a=e=>{if(r.has(e))return;r.add(e);let o=n.get(e);o&&i.push(o);for(let n of t?.nodes[e]?.childrenIds??[])a(n)};for(let e of t?.rootChildrenIds??[])a(e);for(let t of e)a(t.id);return i}function He(e){return e===`done`?(0,L.jsx)(g,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):e===`error`||e===`failed`?(0,L.jsx)(m,{className:`size-3.5 text-destructive`}):e===`cancelled`?(0,L.jsx)(_,{className:`size-3.5 text-muted-foreground`}):e===`recovering`?(0,L.jsx)(P,{className:`size-3.5 animate-spin text-amber-500 dark:text-amber-400`}):(0,L.jsx)(y,{className:`size-3.5 animate-spin text-primary`})}function Ue(e){let t=[],n;for(let r of e){if(r.role===`user`){n&&t.push(n),n={user:r,assistants:[]};continue}if(r.role===`assistant`){if(!n||r.source===`local`){n&&t.push(n),n={assistants:[r]};continue}n.assistants.push(r)}}return n&&t.push(n),t}var We=(0,F.lazy)(()=>x(async()=>{let{GenerativeTextRenderer:e}=await import(`./openui-renderer-l1qI5JDt.js`).then(e=>e.n);return{GenerativeTextRenderer:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])).then(({GenerativeTextRenderer:e})=>({default:e})));function Ge({className:e,content:t}){return(0,L.jsx)(`div`,{className:e?`${e} whitespace-pre-wrap`:`whitespace-pre-wrap`,children:t})}function Ke(e){return(0,F.useMemo)(()=>w(e.content).some(e=>e.type===`openui`),[e.content])?(0,L.jsx)(F.Suspense,{fallback:(0,L.jsx)(Ge,{className:e.className,content:e.content}),children:(0,L.jsx)(We,{...e})}):(0,L.jsx)(C,{className:e.className,content:e.content,isStreaming:e.isStreaming})}function $(e,t,n){if(n===0)return 0;let r=0,i=n;for(;r<i;){let n=Math.floor((r+i)/2);e[n]<=t?r=n+1:i=n}return Math.max(0,Math.min(n-1,r-1))}function qe(e,t,n,r){let i=[0];for(let[a,o]of e.entries())i.push(i[i.length-1]+(t.get(o)??n)+(a<e.length-1?r:0));return i}function Je({estimateSize:e,getItemKey:t,itemGap:n=0,items:r,overscan:i=1.5,renderItem:a,viewportRef:o}){let s=(0,F.useMemo)(()=>r.map((e,n)=>t(e,n)),[t,r]),c=r.length>=16,[l,u]=(0,F.useState)(()=>new Map),[d,f]=(0,F.useState)({height:0,scrollTop:0}),p=(0,F.useRef)(s),m=(0,F.useRef)(l),h=(0,F.useRef)(e),g=(0,F.useRef)(n),_=(0,F.useRef)([0]),v=(0,F.useRef)(0),y=(0,F.useRef)(new Map),b=(0,F.useRef)(new WeakMap),x=(0,F.useRef)(null),S=(0,F.useRef)(null),C=(0,F.useCallback)(()=>{let e=o.current;if(!e)return;let t={height:e.clientHeight,scrollTop:e.scrollTop};f(e=>e.height===t.height&&e.scrollTop===t.scrollTop?e:t)},[o]),w=(0,F.useCallback)(()=>{S.current??=window.requestAnimationFrame(()=>{S.current=null,C()})},[C]),T=(0,F.useCallback)((e,t)=>{let n=y.current.get(e);n&&n!==t&&(x.current?.unobserve(n),y.current.delete(e)),t&&(y.current.set(e,t),b.current.set(t,e),x.current?.observe(t))},[]),E=(0,F.useMemo)(()=>qe(s,l,e,n),[e,n,s,l]);(0,F.useLayoutEffect)(()=>{C()},[r.length,C]),(0,F.useLayoutEffect)(()=>{p.current=s,m.current=l,h.current=e,g.current=n,_.current=E},[e,n,s,l,E]),(0,F.useEffect)(()=>{let e=o.current;if(!e)return;e.addEventListener(`scroll`,w,{passive:!0}),window.addEventListener(`resize`,w),C();let t;return typeof ResizeObserver<`u`&&(t=new ResizeObserver(w),t.observe(e)),()=>{e.removeEventListener(`scroll`,w),window.removeEventListener(`resize`,w),t?.disconnect(),S.current!=null&&(window.cancelAnimationFrame(S.current),S.current=null)}},[w,C,o]);let D=(0,F.useCallback)(e=>{let t=m.current,n=t;for(let r of e){let e=b.current.get(r.target),i=r.contentRect.height;!e||i<=0||t.get(e)===i||(n===t&&(n=new Map(t)),n.set(e,i))}if(n===t)return;let r=o.current,i=p.current,a=qe(i,n,h.current,g.current);if(r&&i.length>0){let e=_.current,t=$(e,Math.max(0,r.scrollTop),i.length),n=i[t];if(n&&t>0){let r=(a[i.indexOf(n)]??0)-(e[t]??0);r!==0&&(v.current+=r)}}m.current=n,_.current=a,u(n)},[o]);if((0,F.useLayoutEffect)(()=>{if(!c||typeof ResizeObserver>`u`)return;let e=new ResizeObserver(e=>D(e));x.current=e;for(let t of y.current.values())e.observe(t);return()=>{e.disconnect(),x.current===e&&(x.current=null)}},[c,D]),(0,F.useEffect)(()=>{let e=m.current;if(e.size===0)return;let t=new Set(s),n=new Map([...e].filter(([e])=>t.has(e)));n.size!==e.size&&(m.current=n,u(n))},[s]),(0,F.useLayoutEffect)(()=>{let e=v.current,t=o.current;!t||e===0||(t.scrollTop+=e,v.current=0,C())},[l,C,o]),!c)return(0,L.jsx)(L.Fragment,{children:r.map((e,t)=>(0,L.jsx)(F.Fragment,{children:a(e,t)},s[t]))});let O=E[E.length-1]??0,k=Math.max(e,d.height*i),A=$(E,Math.max(0,d.scrollTop-k),r.length),j=Math.min(r.length-1,$(E,d.scrollTop+d.height+k,r.length)+1);return(0,L.jsx)(`div`,{"data-rendered-turn-count":j-A+1,"data-total-turn-count":r.length,"data-virtualized-transcript":`true`,style:{height:O,position:`relative`,width:`100%`},children:r.slice(A,j+1).map((e,t)=>{let n=A+t,r=s[n];return(0,L.jsx)(`div`,{ref:e=>T(r,e),"data-virtualized-turn-index":n,style:{left:0,position:`absolute`,right:0,top:E[n]},children:a(e,n)},r)})})}export{He as a,Ae as c,de as d,se as f,E as h,Ve as i,me as l,G as m,Ke as n,Be as o,U as p,Ue as r,Le as s,Je as t,ue as u};
|