@vellumai/web 0.10.5-staging.2 → 0.10.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.
Files changed (78) hide show
  1. package/dist/assets/{account-page-D7N_WAt8.js → account-page-B4_qrJXM.js} +1 -1
  2. package/dist/assets/{acp-run-detail-panel-DGXWy1zV.js → acp-run-detail-panel-ZJb9mPFf.js} +1 -1
  3. package/dist/assets/{advanced-page-CA-Fynld.js → advanced-page-BsF8JW-4.js} +1 -1
  4. package/dist/assets/{ai-page-zZGFrEzO.js → ai-page-BNaD9M7D.js} +1 -1
  5. package/dist/assets/{api-key-screen-CUEhMjCI.js → api-key-screen-DiW5rDSM.js} +1 -1
  6. package/dist/assets/{archive-page-hU8w9ytm.js → archive-page-DZ_8uaQt.js} +1 -1
  7. package/dist/assets/{background-task-detail-panel-BbCZGqHm.js → background-task-detail-panel-DRBcuGts.js} +1 -1
  8. package/dist/assets/{billing-page-DvW9-kBw.js → billing-page-Rw3ECU55.js} +1 -1
  9. package/dist/assets/{bookmarks-page-DnqyJXnk.js → bookmarks-page-DmPcHyC_.js} +1 -1
  10. package/dist/assets/{command-palette-B0pI8wFe.js → command-palette-DkJaPl6x.js} +1 -1
  11. package/dist/assets/{command-palette-window-page-BgQhfKX5.js → command-palette-window-page-v-j032zP.js} +1 -1
  12. package/dist/assets/{community-page-D85Cmkcv.js → community-page-BZ9IruGQ.js} +1 -1
  13. package/dist/assets/{contacts-page-route-BZz1O1XL.js → contacts-page-route-iggE95MQ.js} +1 -1
  14. package/dist/assets/{debug-page-BA2gOVPd.js → debug-page-DhYoaQMd.js} +1 -1
  15. package/dist/assets/{deploy-dialogs-wNJRqYiu.js → deploy-dialogs-Cbti_xsn.js} +1 -1
  16. package/dist/assets/{detail-panel-stop-button-Dc3MB_3r.js → detail-panel-stop-button-BHEQd627.js} +1 -1
  17. package/dist/assets/detail-shell-CPp3KhI8.js +4 -0
  18. package/dist/assets/{developer-page-B9c_NOq0.js → developer-page-D0Ttwt5o.js} +1 -1
  19. package/dist/assets/{devices-page-C_MPiuEN.js → devices-page-CkA_1aNA.js} +1 -1
  20. package/dist/assets/{dictation-overlay-page-dlmrZeaQ.js → dictation-overlay-page-BHrUGwJK.js} +1 -1
  21. package/dist/assets/{document-viewer-page-CVJKsLcz.js → document-viewer-page-CnFgbOqH.js} +1 -1
  22. package/dist/assets/{earn-credits-modal-gdB0QAos.js → earn-credits-modal-DOIDaArW.js} +1 -1
  23. package/dist/assets/{emails-page-wOQsKKch.js → emails-page-B0bc-Gj2.js} +1 -1
  24. package/dist/assets/{file-editor-sKfnpW-D.js → file-editor-Bm5LJXwA.js} +1 -1
  25. package/dist/assets/{general-page-C0EgypjR.js → general-page-Df1AoP_V.js} +1 -1
  26. package/dist/assets/{hatching-screen-B4dscGGq.js → hatching-screen-CENPVFoZ.js} +1 -1
  27. package/dist/assets/{home-page-route-BYUiByXT.js → home-page-route-mQBcsrfW.js} +1 -1
  28. package/dist/assets/{hosting-screen-oFxveMgT.js → hosting-screen-I6v4dE5d.js} +1 -1
  29. package/dist/assets/{identity-page-route-jU_Rzwhx.js → identity-page-route-DlM3U1hC.js} +1 -1
  30. package/dist/assets/index-B-S-gNKm.js +131 -0
  31. package/dist/assets/{inspect-page-BKOxlmBF.js → inspect-page-BIEfENnw.js} +1 -1
  32. package/dist/assets/{install-C22EWSPL.js → install-lYdVLxh2.js} +1 -1
  33. package/dist/assets/{integrations-page-BBcBVFLT.js → integrations-page-BBZ2VFVI.js} +1 -1
  34. package/dist/assets/{intelligence-layout-BqECxena.js → intelligence-layout-zqIx7Q-I.js} +1 -1
  35. package/dist/assets/{keyboard-shortcuts-page-BZTs62Wj.js → keyboard-shortcuts-page-H4mn2-og.js} +1 -1
  36. package/dist/assets/{library-detail-page-Ck65_rdB.js → library-detail-page-DTbtqnJW.js} +1 -1
  37. package/dist/assets/{library-page-BPrjQGL6.js → library-page-CtniKYuA.js} +1 -1
  38. package/dist/assets/{logout-page-8AH_ZU_7.js → logout-page-BbQCJKwL.js} +1 -1
  39. package/dist/assets/{logs-layout-DD-9gYta.js → logs-layout-xXeY2t6B.js} +1 -1
  40. package/dist/assets/{memory-router-playground-page-BRe1h0Mv.js → memory-router-playground-page-BhFJ0lwa.js} +1 -1
  41. package/dist/assets/{mobile-sidebar-drawer-CzcwUqpn.js → mobile-sidebar-drawer-BA9ERuJ7.js} +1 -1
  42. package/dist/assets/{notifications-page-CNz_ce_3.js → notifications-page-BSwHh8Mx.js} +1 -1
  43. package/dist/assets/{oauth-complete-page-BY4IUzM3.js → oauth-complete-page-KFGDIl3q.js} +1 -1
  44. package/dist/assets/{oauth-popup-complete-page-DFSwc7gE.js → oauth-popup-complete-page-C9FKG9VY.js} +1 -1
  45. package/dist/assets/{pairing-page-rN8Xn7wW.js → pairing-page-CT45DoH8.js} +1 -1
  46. package/dist/assets/{plugins-page-BQcsJgVb.js → plugins-page-H6DAm3HM.js} +1 -1
  47. package/dist/assets/{prechat-route-6ome-g7N.js → prechat-route-BfQPMYu8.js} +1 -1
  48. package/dist/assets/{privacy-page-DtQMDaEM.js → privacy-page-CLJnEPBh.js} +1 -1
  49. package/dist/assets/{privacy-screen-DdeTm5d2.js → privacy-screen-DWLF6KuW.js} +1 -1
  50. package/dist/assets/{provider-callback-page-CwplW9PX.js → provider-callback-page-UAlBgfqn.js} +1 -1
  51. package/dist/assets/{research-mock-page-DMXNiiqw.js → research-mock-page-5ewHxOuJ.js} +1 -1
  52. package/dist/assets/{research-onboarding-route-BYbFY_h9.js → research-onboarding-route-RxDDgsKx.js} +1 -1
  53. package/dist/assets/{review-terms-screen-73sQOI_T.js → review-terms-screen-BqGwop2y.js} +1 -1
  54. package/dist/assets/{select-assistant-screen-Y_lcjNSt.js → select-assistant-screen-BfhDJw-S.js} +1 -1
  55. package/dist/assets/{settings-layout-B99yx7iZ.js → settings-layout-D_5HXQhT.js} +1 -1
  56. package/dist/assets/{share-feedback-modal-BqFpqbwt.js → share-feedback-modal-B3axmWXR.js} +1 -1
  57. package/dist/assets/{sidebar-tree-nlZD0iQq.js → sidebar-tree-DM30_BN8.js} +1 -1
  58. package/dist/assets/{signup-page-BBz6b3Nv.js → signup-page-DlqG9kP3.js} +1 -1
  59. package/dist/assets/{skills-page-CyNFwtMm.js → skills-page-C303uEzv.js} +1 -1
  60. package/dist/assets/{sounds-page-DTwqrvjQ.js → sounds-page-DC_yF186.js} +1 -1
  61. package/dist/assets/{subagent-detail-panel-B7-EOosT.js → subagent-detail-panel-B69kOmY_.js} +2 -2
  62. package/dist/assets/{system-events-page-kz2QZXlf.js → system-events-page-CMXtS3Lt.js} +1 -1
  63. package/dist/assets/{tiptap-document-editor-BkhvVzHq.js → tiptap-document-editor-BILtD2S2.js} +1 -1
  64. package/dist/assets/{tool-detail-panel-Djpgj3--.js → tool-detail-panel-CG9Wp2NK.js} +2 -2
  65. package/dist/assets/{trace-page-BEyQxpBX.js → trace-page-k0cYj2Bt.js} +1 -1
  66. package/dist/assets/{upgrade-cancel-page-BMj8YpAx.js → upgrade-cancel-page-KGY9H9Mg.js} +1 -1
  67. package/dist/assets/{upgrade-success-page-BZjQzQQB.js → upgrade-success-page-9MHgGZFb.js} +1 -1
  68. package/dist/assets/{usage-page-YnMiaGbU.js → usage-page-CVI5PvbA.js} +1 -1
  69. package/dist/assets/{use-skill-categories-6bE1o8xC.js → use-skill-categories-nKUbiuQn.js} +1 -1
  70. package/dist/assets/{voice-page-CjOnnW4C.js → voice-page-ChYDqNwz.js} +1 -1
  71. package/dist/assets/{weather-forecast-display-Aqhg0YWH.js → weather-forecast-display-DaU-H5wf.js} +1 -1
  72. package/dist/assets/{welcome-screen-BYiDdI6u.js → welcome-screen-1tj61zH7.js} +1 -1
  73. package/dist/assets/{workflow-detail-panel-CEiMuzvs.js → workflow-detail-panel-Di63Av9t.js} +1 -1
  74. package/dist/assets/{workspace-page-CeCbEfiQ.js → workspace-page-C5nupXN6.js} +1 -1
  75. package/dist/index.html +2 -2
  76. package/package.json +1 -1
  77. package/dist/assets/detail-shell-CyXDiAEa.js +0 -4
  78. package/dist/assets/index-CZ2UBc_U.js +0 -130
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{d as r,h as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./dropdown-ChWAdhLG.js";import"./src-SCpl1O1B.js";import{t as c}from"./sparkles-Bla177ar.js";import{t as l}from"./triangle-alert-C3aHZq1F.js";import{ur as u}from"./sdk.gen-zA5ns5LT.js";import{At as d,Dt as f,Ot as ee,c as te,d as ne,ft as re,kt as ie}from"./react-query.gen-BwkZCSTW.js";import{t as p}from"./api-errors-DPruG7q9.js";import{An as ae,gn as m}from"./index-CZ2UBc_U.js";import{t as h}from"./use-active-assistant-id-BVzVN4_g.js";import{i as g,t as _}from"./format-BDkwdD2m.js";import{i as v,o as y,r as b}from"./llm-dimension-8g-Go8uq.js";import{n as x}from"./usage-window-B-YOzKJi.js";import{n as oe,t as se}from"./schedules-D_sclJNA.js";var S=e(t(),1);function ce(e){if(!e)return{};let t={};for(let n of e.callSites)!n.id||!n.displayName||(t[n.id]={id:n.id,displayName:n.displayName,description:n.description,domain:n.domain});return t}function C(e,t,n){if(e===`task`){let e=t.groupKey;return e?n.callSites?.[e]?.displayName??t.group:t.group}if(e===`profile`){let e=t.groupKey;return e?n.profiles?.[e]?.displayName??t.group:t.group||`Default / Unset`}return t.group}function le(e,t,n){return!e||e.length===0?[]:e.map(e=>{let r=C(t,e,n);return r===e.group?e:{...e,group:r}})}var w=6,T=`value:`,E=`null:`;function D(e,t=`schedule`){return e===null?`${E}${v(t)?y(t):t}`:`${T}${e}`}function O(e){return[...e].sort((e,t)=>{if(e.date!==t.date)return e.date<t.date?-1:1;let n=j(e.bucketId),r=j(t.bucketId);return n===r?e.bucketId===t.bucketId?0:e.bucketId<t.bucketId?-1:1:n-r})}function ue(e){return e.map(e=>({bucketId:e.bucketId,date:e.date,displayLabel:e.displayLabel,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,groups:{}}))}function de(e,t,n){return t!==`task`&&t!==`profile`?[...e]:e.map(e=>{let r=!1,i={};for(let[a,o]of Object.entries(e.groups)){let e=C(t,A(o),n);e===o.group?i[a]=o:(r=!0,i[a]={...o,group:e})}return r?{...e,groups:i}:e})}function k(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.groups)){let n=t.get(e);t.set(e,{label:n?.label??r.group,totalEstimatedCostUsd:(n?.totalEstimatedCostUsd??0)+r.totalEstimatedCostUsd})}let n=Array.from(t.entries()).sort(([e,t],[n,r])=>t.totalEstimatedCostUsd===r.totalEstimatedCostUsd?t.label===r.label?e===n?0:e<n?-1:1:t.label<r.label?-1:1:r.totalEstimatedCostUsd-t.totalEstimatedCostUsd).map(([e,t],n)=>({seriesKey:e,label:t.label,totalEstimatedCostUsd:t.totalEstimatedCostUsd,colorIndex:n}));return{items:n,visibleItems:n.slice(0,w)}}function A(e){return{group:e.group,groupId:e.groupKey,groupKey:e.groupKey,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalCacheCreationTokens:0,totalCacheReadTokens:0,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,turnCount:null}}function j(e){let t=e.lastIndexOf(`|`);if(t<0)return 0;let n=Number(e.slice(t+1));return Number.isFinite(n)?n:0}var M=o(),N=140,P=40,F=28,fe=2,pe=2,me=1e-6,I=12,L=220,R=56,he=[40,80,60,100,50,70,30],ge=[18,24,28,35,42,50,64,78,92,106,118,96,84,74,68,80,88,72,56,48,40,34,26,20],z=[`var(--usage-trend-stack-positive, var(--system-positive-strong, #10b981))`,`var(--usage-trend-stack-info, var(--system-info-strong, #3b82f6))`,`var(--usage-trend-stack-mid, var(--system-mid-strong, #f59e0b))`,`var(--usage-trend-stack-secondary, var(--content-secondary, #6b7280))`,`var(--usage-trend-stack-negative, var(--system-negative-strong, #f87171))`,`var(--usage-trend-stack-tertiary, var(--content-tertiary, #9ca3af))`];function B(e){return z[e%z.length]}function V(e){return e.displayLabel?e.displayLabel:e.date}function _e(e,t){let n=e+I,r=t+I;return n+L>window.innerWidth&&(n=e-L-I),r+R>window.innerHeight&&(r=t-R-I),{x:n,y:r}}function ve({buckets:e,isHourly:t,legendItems:n}){let[r,i]=(0,S.useState)(null),a=(0,S.useMemo)(()=>O(e),[e]),o=(0,S.useMemo)(()=>k(e),[e]),s=n??o.items,c=n??o.visibleItems,l=(0,S.useMemo)(()=>a.reduce((e,t)=>Math.max(e,t.totalEstimatedCostUsd),0),[a]),u=(0,S.useCallback)((e,t)=>{let n=_e(e.clientX,e.clientY);i({...t,x:n.x,y:n.y})},[]),d=(0,S.useCallback)(()=>i(null),[]);if(a.length===0){let e=(0,M.jsx)(Se,{title:t?`No hourly data`:`No daily data`,subtitle:`No usage recorded in this time range`});return c.length===0?e:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,(0,M.jsx)(H,{items:c})]})}let f=t?F:P;return(0,M.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${N}px`},"aria-hidden":`true`,children:a.map(e=>{let t=l>0?e.totalEstimatedCostUsd/l:0,r=Math.max(fe,N*t);return(0,M.jsx)(`div`,{className:`flex items-end`,style:{width:`${f}px`,minWidth:`${f}px`,height:`${r}px`,opacity:e.totalEstimatedCostUsd>0?1:.3},title:`${V(e)}: ${_(e.totalEstimatedCostUsd)}`,"data-usage-series-bar":e.bucketId,children:(0,M.jsx)(be,{bucket:e,height:r,legendItems:s,hasLegendOverride:n!=null,onSegmentHover:u,onSegmentLeave:d})},e.bucketId)})}),(0,M.jsx)(`div`,{className:`flex items-start gap-2`,children:a.map(e=>(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,style:{width:`${f}px`,minWidth:`${f}px`},children:[(0,M.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-secondary)`},children:_(e.totalEstimatedCostUsd)}),(0,M.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`},children:V(e)})]},e.bucketId))}),c.length>0?(0,M.jsx)(H,{items:c}):null]}),r?(0,M.jsx)(xe,{tooltip:r}):null]})}function ye({isHourly:e}){let t=e?ge:he,n=e?F:P;return(0,M.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${N}px`},"aria-hidden":`true`,children:t.map((e,t)=>(0,M.jsx)(`div`,{className:`rounded-sm`,style:{width:`${n}px`,height:`${e}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}},t))})}function be({bucket:e,height:t,legendItems:n,hasLegendOverride:r,onSegmentHover:i,onSegmentLeave:a}){let o=Object.keys(e.groups).length>0,s=n.filter(e=>(e.state??`active`)===`active`).flatMap(t=>{let n=e.groups[t.seriesKey];return!n||n.totalEstimatedCostUsd<=0?[]:[{item:t,value:n}]});if(s.length===0&&!o&&!r){let n={label:`Total`,bucketLabel:V(e),cost:_(e.totalEstimatedCostUsd)};return(0,M.jsx)(`div`,{className:`w-full rounded-sm`,title:`${n.label}: ${n.cost}`,onMouseEnter:e=>i(e,n),onMouseMove:e=>i(e,n),onMouseLeave:a,style:{height:`${t}px`,background:B(0)},"data-usage-series-segment-label":n.label,"data-usage-fallback-segment":`true`})}return s.length===0?null:(0,M.jsx)(`div`,{className:`flex w-full flex-col-reverse overflow-hidden rounded-sm`,style:{height:`${t}px`},"data-usage-series-stack":e.bucketId,children:s.map(({item:n,value:r})=>{let o={label:n.label,bucketLabel:V(e),cost:_(r.totalEstimatedCostUsd)};return(0,M.jsx)(`div`,{title:`${o.label}: ${o.cost}`,onMouseEnter:e=>i(e,o),onMouseMove:e=>i(e,o),onMouseLeave:a,style:{height:`${Math.max(pe,t*r.totalEstimatedCostUsd/Math.max(e.totalEstimatedCostUsd,me))}px`,background:B(n.colorIndex)},"data-usage-series-segment":n.seriesKey,"data-usage-series-segment-label":n.label,"data-usage-series-color-index":n.colorIndex},n.seriesKey)})})}function xe({tooltip:e}){return(0,M.jsxs)(`div`,{className:`pointer-events-none fixed z-50 max-w-[220px] rounded-md border px-2 py-1 shadow-xl`,style:{left:`${e.x}px`,top:`${e.y}px`,background:`var(--surface-overlay, var(--surface-lift))`,borderColor:`var(--border-base)`},"aria-hidden":`true`,children:[(0,M.jsx)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-default)`},children:e.label}),(0,M.jsxs)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[e.bucketLabel,` · `,e.cost]})]})}function H({items:e}){return(0,M.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pt-1`,children:e.map(e=>{let t=e.state??`active`,n=t===`inactive`;return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,"data-usage-legend-state":t,children:[(0,M.jsx)(`span`,{className:`h-[7px] w-[7px] shrink-0 rounded-full`,style:{background:n?`var(--content-tertiary)`:B(e.colorIndex),opacity:n?.45:1},"aria-hidden":`true`,"data-usage-series-color-index":e.colorIndex}),(0,M.jsx)(`span`,{className:n?`truncate text-[10px] line-through`:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`,opacity:n?.65:1},children:e.label})]},e.seriesKey)})})}function Se({title:e,subtitle:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md py-12 text-center`,style:{color:`var(--content-tertiary)`},children:[(0,M.jsx)(`p`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),(0,M.jsx)(`p`,{className:`mt-1 text-body-small-default`,children:t})]})}function U(e){return v(e)?y(e):e}function Ce(e){return G({from:e.from,to:e.to},e.scheduleId)}function we(e){return G({from:e.from,to:e.to,...e.granularity?{granularity:e.granularity}:{},...e.tz?{tz:e.tz}:{}},e.scheduleId)}function W(e){return G({from:e.from,to:e.to,groupBy:U(e.groupBy)},e.scheduleId)}function Te(e){return G({from:e.from,to:e.to,granularity:e.granularity,groupBy:U(e.groupBy),...e.tz?{tz:e.tz}:{}},e.scheduleId)}function G(e,t){return t?{...e,scheduleId:t}:e}function Ee(e){return[`${g(e.totalInputTokens)} direct`,`${g(e.totalCacheCreationTokens)} cache created`,`${g(e.totalCacheReadTokens)} cache read`,`${g(e.totalOutputTokens)} out`].join(` / `)}function K(e){return!Number.isFinite(e)||e===0?`0`:e>=1e6||e>=999950&&e<1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toLocaleString()}function De(e){return`${K(e.totalInputTokens+e.totalCacheCreationTokens+e.totalCacheReadTokens)} in / ${K(e.totalOutputTokens)} out`}var Oe=`task`,q=`model`,ke=new Set([400,404,422]),Ae=3,je=new Set([`today`,`yesterday`,`7d`,`30d`,`90d`,`all`]),Me=new Set([`actor`,`provider`,`model`,`conversation`,`task`,`profile`,`schedule`]),J={task:b.task,profile:b.profile,model:b.model,provider:`Provider`,actor:`Actor`,conversation:`Conversation`,schedule:`Schedule`},Ne=[{value:`task`,label:J.task},{value:`profile`,label:J.profile},{value:`model`,label:J.model},{value:`provider`,label:J.provider},{value:`schedule`,label:J.schedule},{value:`conversation`,label:J.conversation}];function Pe(e){let t=e.get(`range`),n=e.get(`groupBy`),r=Re(n)?n:Oe;return{range:Le(t)?t:`7d`,groupBy:r,scheduleId:r===`schedule`?Fe(e):void 0}}function Fe(e){let t=e.get(`scheduleId`);if(!(!t||t.trim().length===0))return t}function Ie(e,t){let n=new URLSearchParams(e);return t.range!==void 0&&n.set(`range`,t.range),t.groupBy!==void 0&&n.set(`groupBy`,t.groupBy),t.scheduleId!==void 0&&(t.scheduleId===null||t.scheduleId.trim().length===0?n.delete(`scheduleId`):n.set(`scheduleId`,t.scheduleId)),n.get(`groupBy`)!==`schedule`&&n.delete(`scheduleId`),n}function Le(e){return e!=null&&je.has(e)}function Re(e){return e!=null&&Me.has(e)}function ze(e){return e!==`conversation`}function Be(e,t){return e!==`task`&&e!==`profile`?!1:He(t)}function Ve(e,t){return!He(t)&&e<Ae}function He(e){return e instanceof p&&ke.has(e.status)}function Ue(e,t){let n=e===`hourly`?`Hourly Trend`:`Daily Trend`;return!t||t===`conversation`?n:`${n} by ${J[t]}`}function We({requestedGranularity:e,isLoading:t,buckets:n}){return e===`hourly`&&(t||!n||n.length===0||n.some(Ge))?`hourly`:`daily`}function Ge(e){return e.bucketId.includes(`|`)||Ke(e.date)}function Ke(e){return/^\d{4}-\d{2}-\d{2} ([01]\d|2[0-3]):00$/.test(e)}function qe(e,t,n=Date.now()){return x(e,t,n)}function Je(e){return e===`today`||e===`yesterday`?`hourly`:`daily`}function Ye({prompt:e,children:t,variant:i=`outlined`,size:a=`regular`,className:o}){let s=r(),l=(0,S.useCallback)(()=>{m(s,{prompt:e})},[s,e]);return(0,M.jsx)(n,{variant:i,size:a,leftIcon:(0,M.jsx)(c,{}),onClick:l,className:o,children:t})}var Xe=[{value:`today`,label:`Today`},{value:`yesterday`,label:`Yesterday`},{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}],Ze=300*1e3,Qe=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and explain the biggest cost contributors by call site, model, and profile.`,`Check my current llm.default, llm.callSites, and llm.profiles.`,`Give me a concise summary of what is driving cost and what you would optimize first.`,`Do not change config yet.`].join(` `),$e=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and current LLM config, then recommend the safest cost-optimization changes.`,`If changes are clearly safe, show me the exact config commands you would run and ask for confirmation before applying them.`].join(` `);function et({assistantId:e}){let[t,n]=i(),{range:r,groupBy:o,scheduleId:s}=(0,S.useMemo)(()=>Pe(t),[t]),c=ae(),l=(0,S.useCallback)(e=>{n(t=>Ie(t,e),{replace:!0})},[n]),p=(0,S.useMemo)(()=>qe(r,c),[r,c]),m=(0,S.useMemo)(()=>Je(r),[r]),h=a({queryKey:re({path:{assistant_id:e}}),queryFn:()=>se(e),staleTime:1e4}),g=(0,S.useCallback)(e=>{l({range:e})},[l]),_=a({...d({path:{assistant_id:e},query:Ce({from:p.from,to:p.to,scheduleId:s})})}),v=a({queryKey:f({path:{assistant_id:e},query:W({from:p.from,to:p.to,groupBy:o,scheduleId:s})}),queryFn:async({signal:t})=>{try{let{data:n}=await u({path:{assistant_id:e},query:W({from:p.from,to:p.to,groupBy:o,scheduleId:s}),signal:t,throwOnError:!0});return{groupBy:o,response:n}}catch(n){if(!Be(o,n))throw n;let{data:r}=await u({path:{assistant_id:e},query:W({from:p.from,to:p.to,groupBy:q,scheduleId:s}),signal:t,throwOnError:!0});return{groupBy:q,response:r}}},retry:Ve}),y=v.data?.groupBy??o,b=ze(y)?y:void 0,x=a({...ie({path:{assistant_id:e},query:Te({from:p.from,to:p.to,granularity:m,groupBy:b??`actor`,tz:c,scheduleId:s})}),enabled:!!b,retry:Ve}),C=a({...ee({path:{assistant_id:e},query:we({from:p.from,to:p.to,granularity:m,tz:c,scheduleId:s})}),enabled:!b||x.isError}),w=a({...ne({path:{assistant_id:e}}),enabled:y===`task`,staleTime:1/0}),T=a({...te({path:{assistant_id:e}}),select:oe,enabled:y===`profile`,staleTime:Ze}),E=(0,S.useMemo)(()=>({callSites:ce(w.data),profiles:T.data??{}}),[w.data,T.data]),D=(0,S.useMemo)(()=>{let e=v.data;if(e)return le(e.response.breakdown,e.groupBy,E)},[v.data,E]),O=(0,S.useMemo)(()=>{if(!(!b||!x.data))return de(x.data.buckets,b,E)},[x.data,b,E]),k=(0,S.useMemo)(()=>{if(C.data)return ue(C.data.buckets)},[C.data]),A=(0,S.useMemo)(()=>b?x.error?k?{isLoading:!1,error:null,data:k,refetch:C.refetch}:{isLoading:C.isLoading||!k&&!C.error,error:C.error??x.error,data:void 0,refetch:C.error?C.refetch:x.refetch}:{isLoading:x.isLoading,error:x.error,data:O,refetch:x.refetch}:{isLoading:C.isLoading,error:C.error,data:k,refetch:C.refetch},[k,C.error,C.isLoading,C.refetch,O,b,x.error,x.isLoading,x.refetch]),j=We({requestedGranularity:m,isLoading:A.isLoading,buckets:A.data}),N=j===`hourly`,P=b&&x.error?void 0:y,F=(0,S.useMemo)(()=>{if(!(y!==`schedule`||!s))return tt(h.data,s)},[y,s,h.data]);return(0,M.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,M.jsx)(`h3`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:`Usage`}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,M.jsx)(it,{range:r,onChange:g})})]}),(0,M.jsx)(`section`,{"aria-label":`Totals`,children:(0,M.jsx)(X,{query:_,skeleton:(0,M.jsx)(ot,{}),render:e=>(0,M.jsx)(at,{totals:e})})}),(0,M.jsx)(Y,{title:`Inference Usage`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,M.jsx)(`h4`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:Ue(j,P)}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,M.jsx)(st,{value:y,onChange:e=>{e===o&&y!==o&&(v.refetch(),x.refetch()),l({groupBy:e,scheduleId:e===`schedule`?void 0:null})}})})]}),(0,M.jsx)(X,{query:A,skeleton:(0,M.jsx)(ye,{isHourly:N}),render:e=>(0,M.jsx)(ve,{buckets:e,isHourly:N,legendItems:F})})]})}),(0,M.jsx)(ct,{query:v,groups:D}),(0,M.jsx)(rt,{})]})}function tt(e,t){let n=e??[];return[...n.some(e=>e.id===t)?[]:[{id:t,label:nt(t)}],...n.map(e=>({id:e.id,label:e.name||e.id}))].map((e,n)=>({seriesKey:D(e.id,`schedule`),label:e.label,colorIndex:n,state:e.id===t?`active`:`inactive`}))}function nt(e){return`Unknown schedule (${e})`}function rt(){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsx)(`div`,{className:`h-px w-full`,style:{background:`linear-gradient(to right, transparent, var(--border-base), transparent)`}}),(0,M.jsx)(Y,{title:`Cost assistant`,subtitle:`Review recent spend and tune model profile choices.`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md px-3 py-3 sm:flex-row sm:items-center`,children:[(0,M.jsx)(Ye,{prompt:Qe,children:`Analyze costs with assistant`}),(0,M.jsx)(Ye,{prompt:$e,variant:`ghost`,children:`Optimize settings`})]})})]})}function it({range:e,onChange:t}){return(0,M.jsx)(`div`,{className:`flex items-center`,children:(0,M.jsx)(s,{value:e,onChange:t,options:Xe.map(e=>({value:e.value,label:e.label}))})})}function Y({title:e,subtitle:t,children:n}){return(0,M.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-md border px-4 py-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`h3`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),t?(0,M.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t}):null]}),n]})}function X({query:e,skeleton:t,render:n}){return e.isLoading?(0,M.jsx)(M.Fragment,{children:t}):e.error?(0,M.jsx)(ft,{message:e.error instanceof Error?e.error.message:`Failed to load usage.`,onRetry:()=>e.refetch()}):e.data?(0,M.jsx)(M.Fragment,{children:n(e.data)}):(0,M.jsx)(M.Fragment,{children:t})}function at({totals:e}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`span`,{style:{fontSize:`30px`,fontWeight:600,lineHeight:1,color:`var(--content-default)`},children:_(e.totalEstimatedCostUsd)}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`Cost`})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`span`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:g(e.eventCount)}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`LLM Calls`})]})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,M.jsx)(Z,{label:`Direct Input Tokens`,value:g(e.totalInputTokens)}),(0,M.jsx)(Z,{label:`Output Tokens`,value:g(e.totalOutputTokens)}),(0,M.jsx)(Z,{label:`Cache Created`,value:g(e.totalCacheCreationTokens)}),(0,M.jsx)(Z,{label:`Cache Read`,value:g(e.totalCacheReadTokens)})]})]})}function Z({label:e,value:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-default)`},children:t}),(0,M.jsx)(`span`,{className:`text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:e})]})}function ot(){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)($,{width:140,height:30}),(0,M.jsx)($,{width:90,height:12})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)($,{width:60,height:16}),(0,M.jsx)($,{width:60,height:12})]})]}),(0,M.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,M.jsx)($,{width:`50%`,height:12}),(0,M.jsx)($,{width:`70%`,height:11})]},t))})]})}function st({value:e,onChange:t}){return(0,M.jsx)(`div`,{className:`flex items-center`,children:(0,M.jsx)(s,{value:e,onChange:t,menuAlign:`end`,menuMinWidth:196,options:Ne.map(e=>({value:e.value,label:e.label}))})})}function ct({query:e,groups:t}){let[n,r]=(0,S.useState)(new Set),i=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,M.jsx)(Y,{title:`Breakdown`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(Q,{label:`% of total`,active:n.has(`pct`),onClick:()=>i(`pct`)}),(0,M.jsx)(Q,{label:`Tokens`,active:n.has(`tokens`),onClick:()=>i(`tokens`)}),(0,M.jsx)(Q,{label:`Turns`,active:n.has(`turns`),onClick:()=>i(`turns`)})]}),(0,M.jsx)(X,{query:e,skeleton:(0,M.jsx)(ut,{}),render:e=>(0,M.jsx)(lt,{groups:t??e.response.breakdown,showPct:n.has(`pct`),showTokens:n.has(`tokens`),showTurns:n.has(`turns`)})})]})})}function Q({label:e,active:t,onClick:n}){return(0,M.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full border px-2.5 py-1 text-label-medium-default`,style:{borderColor:t?`var(--content-secondary)`:`var(--border-base)`,background:t?`color-mix(in srgb, var(--content-secondary) 15%, transparent)`:`transparent`,color:t?`var(--content-default)`:`var(--content-tertiary)`},children:e})}function lt({groups:e,showPct:t,showTokens:n,showTurns:r}){if(e.length===0)return(0,M.jsx)(dt,{title:`No breakdown data`,subtitle:`No usage recorded for this grouping`});let i=e.reduce((e,t)=>e+t.totalEstimatedCostUsd,0);return(0,M.jsx)(`div`,{className:`overflow-hidden rounded-md`,children:(0,M.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{style:{borderBottom:`1px solid var(--border-base)`},children:[(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:`Group`}),n?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`35%`},children:`Tokens`}):null,r?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`72px`},children:`Turns`}):null,t?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`64px`},children:`%`}):null,(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`100px`},children:`Cost`})]})}),(0,M.jsx)(`tbody`,{children:e.map((e,a)=>{let o=Ee(e),s=De(e),c=i>0?Math.round(e.totalEstimatedCostUsd/i*100):0;return(0,M.jsxs)(`tr`,{style:{borderTop:a===0?`none`:`1px solid var(--border-base)`},children:[(0,M.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-default)`},children:(0,M.jsx)(`span`,{className:`block truncate text-body-medium-lighter`,title:e.group,children:e.group})}),n?(0,M.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-secondary)`},children:(0,M.jsx)(`span`,{className:`block truncate text-body-small-default`,title:o,children:s})}):null,r?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.turnCount==null?`—`:e.turnCount.toLocaleString()})}):null,t?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsxs)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[c,`%`]})}):null,(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:_(e.totalEstimatedCostUsd)})})]},e.groupKey??e.groupId??`${e.group}-${a}`)})})]})})}function ut(){return(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,"aria-hidden":`true`,children:Array.from({length:4}).map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)($,{width:100,height:14}),(0,M.jsx)($,{width:`60%`,height:12}),(0,M.jsx)($,{width:50,height:14})]},t))})}function $({width:e,height:t}){return(0,M.jsx)(`div`,{className:`rounded-sm`,style:{width:typeof e==`number`?`${e}px`:e,height:`${t}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}})}function dt({title:e,subtitle:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-1 py-8 text-center`,children:[(0,M.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t})]})}function ft({message:e,onRetry:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(l,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-negative-strong, #f87171)`}}),(0,M.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:e})]}),t?(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`self-start rounded-md border px-3 py-1 text-body-small-default`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`,color:`var(--content-default)`},children:`Retry`}):null]})}function pt(){return(0,M.jsx)(et,{assistantId:h()})}export{pt as UsagePage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{d as r,h as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./dropdown-ChWAdhLG.js";import"./src-SCpl1O1B.js";import{t as c}from"./sparkles-Bla177ar.js";import{t as l}from"./triangle-alert-C3aHZq1F.js";import{ur as u}from"./sdk.gen-zA5ns5LT.js";import{At as d,Dt as f,Ot as ee,c as te,d as ne,ft as re,kt as ie}from"./react-query.gen-BwkZCSTW.js";import{t as p}from"./api-errors-DPruG7q9.js";import{An as ae,gn as m}from"./index-B-S-gNKm.js";import{t as h}from"./use-active-assistant-id-BVzVN4_g.js";import{i as g,t as _}from"./format-BDkwdD2m.js";import{i as v,o as y,r as b}from"./llm-dimension-8g-Go8uq.js";import{n as x}from"./usage-window-B-YOzKJi.js";import{n as oe,t as se}from"./schedules-D_sclJNA.js";var S=e(t(),1);function ce(e){if(!e)return{};let t={};for(let n of e.callSites)!n.id||!n.displayName||(t[n.id]={id:n.id,displayName:n.displayName,description:n.description,domain:n.domain});return t}function C(e,t,n){if(e===`task`){let e=t.groupKey;return e?n.callSites?.[e]?.displayName??t.group:t.group}if(e===`profile`){let e=t.groupKey;return e?n.profiles?.[e]?.displayName??t.group:t.group||`Default / Unset`}return t.group}function le(e,t,n){return!e||e.length===0?[]:e.map(e=>{let r=C(t,e,n);return r===e.group?e:{...e,group:r}})}var w=6,T=`value:`,E=`null:`;function D(e,t=`schedule`){return e===null?`${E}${v(t)?y(t):t}`:`${T}${e}`}function O(e){return[...e].sort((e,t)=>{if(e.date!==t.date)return e.date<t.date?-1:1;let n=j(e.bucketId),r=j(t.bucketId);return n===r?e.bucketId===t.bucketId?0:e.bucketId<t.bucketId?-1:1:n-r})}function ue(e){return e.map(e=>({bucketId:e.bucketId,date:e.date,displayLabel:e.displayLabel,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,groups:{}}))}function de(e,t,n){return t!==`task`&&t!==`profile`?[...e]:e.map(e=>{let r=!1,i={};for(let[a,o]of Object.entries(e.groups)){let e=C(t,A(o),n);e===o.group?i[a]=o:(r=!0,i[a]={...o,group:e})}return r?{...e,groups:i}:e})}function k(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.groups)){let n=t.get(e);t.set(e,{label:n?.label??r.group,totalEstimatedCostUsd:(n?.totalEstimatedCostUsd??0)+r.totalEstimatedCostUsd})}let n=Array.from(t.entries()).sort(([e,t],[n,r])=>t.totalEstimatedCostUsd===r.totalEstimatedCostUsd?t.label===r.label?e===n?0:e<n?-1:1:t.label<r.label?-1:1:r.totalEstimatedCostUsd-t.totalEstimatedCostUsd).map(([e,t],n)=>({seriesKey:e,label:t.label,totalEstimatedCostUsd:t.totalEstimatedCostUsd,colorIndex:n}));return{items:n,visibleItems:n.slice(0,w)}}function A(e){return{group:e.group,groupId:e.groupKey,groupKey:e.groupKey,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalCacheCreationTokens:0,totalCacheReadTokens:0,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,turnCount:null}}function j(e){let t=e.lastIndexOf(`|`);if(t<0)return 0;let n=Number(e.slice(t+1));return Number.isFinite(n)?n:0}var M=o(),N=140,P=40,F=28,fe=2,pe=2,me=1e-6,I=12,L=220,R=56,he=[40,80,60,100,50,70,30],ge=[18,24,28,35,42,50,64,78,92,106,118,96,84,74,68,80,88,72,56,48,40,34,26,20],z=[`var(--usage-trend-stack-positive, var(--system-positive-strong, #10b981))`,`var(--usage-trend-stack-info, var(--system-info-strong, #3b82f6))`,`var(--usage-trend-stack-mid, var(--system-mid-strong, #f59e0b))`,`var(--usage-trend-stack-secondary, var(--content-secondary, #6b7280))`,`var(--usage-trend-stack-negative, var(--system-negative-strong, #f87171))`,`var(--usage-trend-stack-tertiary, var(--content-tertiary, #9ca3af))`];function B(e){return z[e%z.length]}function V(e){return e.displayLabel?e.displayLabel:e.date}function _e(e,t){let n=e+I,r=t+I;return n+L>window.innerWidth&&(n=e-L-I),r+R>window.innerHeight&&(r=t-R-I),{x:n,y:r}}function ve({buckets:e,isHourly:t,legendItems:n}){let[r,i]=(0,S.useState)(null),a=(0,S.useMemo)(()=>O(e),[e]),o=(0,S.useMemo)(()=>k(e),[e]),s=n??o.items,c=n??o.visibleItems,l=(0,S.useMemo)(()=>a.reduce((e,t)=>Math.max(e,t.totalEstimatedCostUsd),0),[a]),u=(0,S.useCallback)((e,t)=>{let n=_e(e.clientX,e.clientY);i({...t,x:n.x,y:n.y})},[]),d=(0,S.useCallback)(()=>i(null),[]);if(a.length===0){let e=(0,M.jsx)(Se,{title:t?`No hourly data`:`No daily data`,subtitle:`No usage recorded in this time range`});return c.length===0?e:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,(0,M.jsx)(H,{items:c})]})}let f=t?F:P;return(0,M.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${N}px`},"aria-hidden":`true`,children:a.map(e=>{let t=l>0?e.totalEstimatedCostUsd/l:0,r=Math.max(fe,N*t);return(0,M.jsx)(`div`,{className:`flex items-end`,style:{width:`${f}px`,minWidth:`${f}px`,height:`${r}px`,opacity:e.totalEstimatedCostUsd>0?1:.3},title:`${V(e)}: ${_(e.totalEstimatedCostUsd)}`,"data-usage-series-bar":e.bucketId,children:(0,M.jsx)(be,{bucket:e,height:r,legendItems:s,hasLegendOverride:n!=null,onSegmentHover:u,onSegmentLeave:d})},e.bucketId)})}),(0,M.jsx)(`div`,{className:`flex items-start gap-2`,children:a.map(e=>(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,style:{width:`${f}px`,minWidth:`${f}px`},children:[(0,M.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-secondary)`},children:_(e.totalEstimatedCostUsd)}),(0,M.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`},children:V(e)})]},e.bucketId))}),c.length>0?(0,M.jsx)(H,{items:c}):null]}),r?(0,M.jsx)(xe,{tooltip:r}):null]})}function ye({isHourly:e}){let t=e?ge:he,n=e?F:P;return(0,M.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${N}px`},"aria-hidden":`true`,children:t.map((e,t)=>(0,M.jsx)(`div`,{className:`rounded-sm`,style:{width:`${n}px`,height:`${e}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}},t))})}function be({bucket:e,height:t,legendItems:n,hasLegendOverride:r,onSegmentHover:i,onSegmentLeave:a}){let o=Object.keys(e.groups).length>0,s=n.filter(e=>(e.state??`active`)===`active`).flatMap(t=>{let n=e.groups[t.seriesKey];return!n||n.totalEstimatedCostUsd<=0?[]:[{item:t,value:n}]});if(s.length===0&&!o&&!r){let n={label:`Total`,bucketLabel:V(e),cost:_(e.totalEstimatedCostUsd)};return(0,M.jsx)(`div`,{className:`w-full rounded-sm`,title:`${n.label}: ${n.cost}`,onMouseEnter:e=>i(e,n),onMouseMove:e=>i(e,n),onMouseLeave:a,style:{height:`${t}px`,background:B(0)},"data-usage-series-segment-label":n.label,"data-usage-fallback-segment":`true`})}return s.length===0?null:(0,M.jsx)(`div`,{className:`flex w-full flex-col-reverse overflow-hidden rounded-sm`,style:{height:`${t}px`},"data-usage-series-stack":e.bucketId,children:s.map(({item:n,value:r})=>{let o={label:n.label,bucketLabel:V(e),cost:_(r.totalEstimatedCostUsd)};return(0,M.jsx)(`div`,{title:`${o.label}: ${o.cost}`,onMouseEnter:e=>i(e,o),onMouseMove:e=>i(e,o),onMouseLeave:a,style:{height:`${Math.max(pe,t*r.totalEstimatedCostUsd/Math.max(e.totalEstimatedCostUsd,me))}px`,background:B(n.colorIndex)},"data-usage-series-segment":n.seriesKey,"data-usage-series-segment-label":n.label,"data-usage-series-color-index":n.colorIndex},n.seriesKey)})})}function xe({tooltip:e}){return(0,M.jsxs)(`div`,{className:`pointer-events-none fixed z-50 max-w-[220px] rounded-md border px-2 py-1 shadow-xl`,style:{left:`${e.x}px`,top:`${e.y}px`,background:`var(--surface-overlay, var(--surface-lift))`,borderColor:`var(--border-base)`},"aria-hidden":`true`,children:[(0,M.jsx)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-default)`},children:e.label}),(0,M.jsxs)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[e.bucketLabel,` · `,e.cost]})]})}function H({items:e}){return(0,M.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pt-1`,children:e.map(e=>{let t=e.state??`active`,n=t===`inactive`;return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,"data-usage-legend-state":t,children:[(0,M.jsx)(`span`,{className:`h-[7px] w-[7px] shrink-0 rounded-full`,style:{background:n?`var(--content-tertiary)`:B(e.colorIndex),opacity:n?.45:1},"aria-hidden":`true`,"data-usage-series-color-index":e.colorIndex}),(0,M.jsx)(`span`,{className:n?`truncate text-[10px] line-through`:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`,opacity:n?.65:1},children:e.label})]},e.seriesKey)})})}function Se({title:e,subtitle:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md py-12 text-center`,style:{color:`var(--content-tertiary)`},children:[(0,M.jsx)(`p`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),(0,M.jsx)(`p`,{className:`mt-1 text-body-small-default`,children:t})]})}function U(e){return v(e)?y(e):e}function Ce(e){return G({from:e.from,to:e.to},e.scheduleId)}function we(e){return G({from:e.from,to:e.to,...e.granularity?{granularity:e.granularity}:{},...e.tz?{tz:e.tz}:{}},e.scheduleId)}function W(e){return G({from:e.from,to:e.to,groupBy:U(e.groupBy)},e.scheduleId)}function Te(e){return G({from:e.from,to:e.to,granularity:e.granularity,groupBy:U(e.groupBy),...e.tz?{tz:e.tz}:{}},e.scheduleId)}function G(e,t){return t?{...e,scheduleId:t}:e}function Ee(e){return[`${g(e.totalInputTokens)} direct`,`${g(e.totalCacheCreationTokens)} cache created`,`${g(e.totalCacheReadTokens)} cache read`,`${g(e.totalOutputTokens)} out`].join(` / `)}function K(e){return!Number.isFinite(e)||e===0?`0`:e>=1e6||e>=999950&&e<1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toLocaleString()}function De(e){return`${K(e.totalInputTokens+e.totalCacheCreationTokens+e.totalCacheReadTokens)} in / ${K(e.totalOutputTokens)} out`}var Oe=`task`,q=`model`,ke=new Set([400,404,422]),Ae=3,je=new Set([`today`,`yesterday`,`7d`,`30d`,`90d`,`all`]),Me=new Set([`actor`,`provider`,`model`,`conversation`,`task`,`profile`,`schedule`]),J={task:b.task,profile:b.profile,model:b.model,provider:`Provider`,actor:`Actor`,conversation:`Conversation`,schedule:`Schedule`},Ne=[{value:`task`,label:J.task},{value:`profile`,label:J.profile},{value:`model`,label:J.model},{value:`provider`,label:J.provider},{value:`schedule`,label:J.schedule},{value:`conversation`,label:J.conversation}];function Pe(e){let t=e.get(`range`),n=e.get(`groupBy`),r=Re(n)?n:Oe;return{range:Le(t)?t:`7d`,groupBy:r,scheduleId:r===`schedule`?Fe(e):void 0}}function Fe(e){let t=e.get(`scheduleId`);if(!(!t||t.trim().length===0))return t}function Ie(e,t){let n=new URLSearchParams(e);return t.range!==void 0&&n.set(`range`,t.range),t.groupBy!==void 0&&n.set(`groupBy`,t.groupBy),t.scheduleId!==void 0&&(t.scheduleId===null||t.scheduleId.trim().length===0?n.delete(`scheduleId`):n.set(`scheduleId`,t.scheduleId)),n.get(`groupBy`)!==`schedule`&&n.delete(`scheduleId`),n}function Le(e){return e!=null&&je.has(e)}function Re(e){return e!=null&&Me.has(e)}function ze(e){return e!==`conversation`}function Be(e,t){return e!==`task`&&e!==`profile`?!1:He(t)}function Ve(e,t){return!He(t)&&e<Ae}function He(e){return e instanceof p&&ke.has(e.status)}function Ue(e,t){let n=e===`hourly`?`Hourly Trend`:`Daily Trend`;return!t||t===`conversation`?n:`${n} by ${J[t]}`}function We({requestedGranularity:e,isLoading:t,buckets:n}){return e===`hourly`&&(t||!n||n.length===0||n.some(Ge))?`hourly`:`daily`}function Ge(e){return e.bucketId.includes(`|`)||Ke(e.date)}function Ke(e){return/^\d{4}-\d{2}-\d{2} ([01]\d|2[0-3]):00$/.test(e)}function qe(e,t,n=Date.now()){return x(e,t,n)}function Je(e){return e===`today`||e===`yesterday`?`hourly`:`daily`}function Ye({prompt:e,children:t,variant:i=`outlined`,size:a=`regular`,className:o}){let s=r(),l=(0,S.useCallback)(()=>{m(s,{prompt:e})},[s,e]);return(0,M.jsx)(n,{variant:i,size:a,leftIcon:(0,M.jsx)(c,{}),onClick:l,className:o,children:t})}var Xe=[{value:`today`,label:`Today`},{value:`yesterday`,label:`Yesterday`},{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}],Ze=300*1e3,Qe=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and explain the biggest cost contributors by call site, model, and profile.`,`Check my current llm.default, llm.callSites, and llm.profiles.`,`Give me a concise summary of what is driving cost and what you would optimize first.`,`Do not change config yet.`].join(` `),$e=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and current LLM config, then recommend the safest cost-optimization changes.`,`If changes are clearly safe, show me the exact config commands you would run and ask for confirmation before applying them.`].join(` `);function et({assistantId:e}){let[t,n]=i(),{range:r,groupBy:o,scheduleId:s}=(0,S.useMemo)(()=>Pe(t),[t]),c=ae(),l=(0,S.useCallback)(e=>{n(t=>Ie(t,e),{replace:!0})},[n]),p=(0,S.useMemo)(()=>qe(r,c),[r,c]),m=(0,S.useMemo)(()=>Je(r),[r]),h=a({queryKey:re({path:{assistant_id:e}}),queryFn:()=>se(e),staleTime:1e4}),g=(0,S.useCallback)(e=>{l({range:e})},[l]),_=a({...d({path:{assistant_id:e},query:Ce({from:p.from,to:p.to,scheduleId:s})})}),v=a({queryKey:f({path:{assistant_id:e},query:W({from:p.from,to:p.to,groupBy:o,scheduleId:s})}),queryFn:async({signal:t})=>{try{let{data:n}=await u({path:{assistant_id:e},query:W({from:p.from,to:p.to,groupBy:o,scheduleId:s}),signal:t,throwOnError:!0});return{groupBy:o,response:n}}catch(n){if(!Be(o,n))throw n;let{data:r}=await u({path:{assistant_id:e},query:W({from:p.from,to:p.to,groupBy:q,scheduleId:s}),signal:t,throwOnError:!0});return{groupBy:q,response:r}}},retry:Ve}),y=v.data?.groupBy??o,b=ze(y)?y:void 0,x=a({...ie({path:{assistant_id:e},query:Te({from:p.from,to:p.to,granularity:m,groupBy:b??`actor`,tz:c,scheduleId:s})}),enabled:!!b,retry:Ve}),C=a({...ee({path:{assistant_id:e},query:we({from:p.from,to:p.to,granularity:m,tz:c,scheduleId:s})}),enabled:!b||x.isError}),w=a({...ne({path:{assistant_id:e}}),enabled:y===`task`,staleTime:1/0}),T=a({...te({path:{assistant_id:e}}),select:oe,enabled:y===`profile`,staleTime:Ze}),E=(0,S.useMemo)(()=>({callSites:ce(w.data),profiles:T.data??{}}),[w.data,T.data]),D=(0,S.useMemo)(()=>{let e=v.data;if(e)return le(e.response.breakdown,e.groupBy,E)},[v.data,E]),O=(0,S.useMemo)(()=>{if(!(!b||!x.data))return de(x.data.buckets,b,E)},[x.data,b,E]),k=(0,S.useMemo)(()=>{if(C.data)return ue(C.data.buckets)},[C.data]),A=(0,S.useMemo)(()=>b?x.error?k?{isLoading:!1,error:null,data:k,refetch:C.refetch}:{isLoading:C.isLoading||!k&&!C.error,error:C.error??x.error,data:void 0,refetch:C.error?C.refetch:x.refetch}:{isLoading:x.isLoading,error:x.error,data:O,refetch:x.refetch}:{isLoading:C.isLoading,error:C.error,data:k,refetch:C.refetch},[k,C.error,C.isLoading,C.refetch,O,b,x.error,x.isLoading,x.refetch]),j=We({requestedGranularity:m,isLoading:A.isLoading,buckets:A.data}),N=j===`hourly`,P=b&&x.error?void 0:y,F=(0,S.useMemo)(()=>{if(!(y!==`schedule`||!s))return tt(h.data,s)},[y,s,h.data]);return(0,M.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,M.jsx)(`h3`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:`Usage`}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,M.jsx)(it,{range:r,onChange:g})})]}),(0,M.jsx)(`section`,{"aria-label":`Totals`,children:(0,M.jsx)(X,{query:_,skeleton:(0,M.jsx)(ot,{}),render:e=>(0,M.jsx)(at,{totals:e})})}),(0,M.jsx)(Y,{title:`Inference Usage`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,M.jsx)(`h4`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:Ue(j,P)}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,M.jsx)(st,{value:y,onChange:e=>{e===o&&y!==o&&(v.refetch(),x.refetch()),l({groupBy:e,scheduleId:e===`schedule`?void 0:null})}})})]}),(0,M.jsx)(X,{query:A,skeleton:(0,M.jsx)(ye,{isHourly:N}),render:e=>(0,M.jsx)(ve,{buckets:e,isHourly:N,legendItems:F})})]})}),(0,M.jsx)(ct,{query:v,groups:D}),(0,M.jsx)(rt,{})]})}function tt(e,t){let n=e??[];return[...n.some(e=>e.id===t)?[]:[{id:t,label:nt(t)}],...n.map(e=>({id:e.id,label:e.name||e.id}))].map((e,n)=>({seriesKey:D(e.id,`schedule`),label:e.label,colorIndex:n,state:e.id===t?`active`:`inactive`}))}function nt(e){return`Unknown schedule (${e})`}function rt(){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsx)(`div`,{className:`h-px w-full`,style:{background:`linear-gradient(to right, transparent, var(--border-base), transparent)`}}),(0,M.jsx)(Y,{title:`Cost assistant`,subtitle:`Review recent spend and tune model profile choices.`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md px-3 py-3 sm:flex-row sm:items-center`,children:[(0,M.jsx)(Ye,{prompt:Qe,children:`Analyze costs with assistant`}),(0,M.jsx)(Ye,{prompt:$e,variant:`ghost`,children:`Optimize settings`})]})})]})}function it({range:e,onChange:t}){return(0,M.jsx)(`div`,{className:`flex items-center`,children:(0,M.jsx)(s,{value:e,onChange:t,options:Xe.map(e=>({value:e.value,label:e.label}))})})}function Y({title:e,subtitle:t,children:n}){return(0,M.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-md border px-4 py-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`h3`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),t?(0,M.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t}):null]}),n]})}function X({query:e,skeleton:t,render:n}){return e.isLoading?(0,M.jsx)(M.Fragment,{children:t}):e.error?(0,M.jsx)(ft,{message:e.error instanceof Error?e.error.message:`Failed to load usage.`,onRetry:()=>e.refetch()}):e.data?(0,M.jsx)(M.Fragment,{children:n(e.data)}):(0,M.jsx)(M.Fragment,{children:t})}function at({totals:e}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`span`,{style:{fontSize:`30px`,fontWeight:600,lineHeight:1,color:`var(--content-default)`},children:_(e.totalEstimatedCostUsd)}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`Cost`})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`span`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:g(e.eventCount)}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`LLM Calls`})]})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,M.jsx)(Z,{label:`Direct Input Tokens`,value:g(e.totalInputTokens)}),(0,M.jsx)(Z,{label:`Output Tokens`,value:g(e.totalOutputTokens)}),(0,M.jsx)(Z,{label:`Cache Created`,value:g(e.totalCacheCreationTokens)}),(0,M.jsx)(Z,{label:`Cache Read`,value:g(e.totalCacheReadTokens)})]})]})}function Z({label:e,value:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-default)`},children:t}),(0,M.jsx)(`span`,{className:`text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:e})]})}function ot(){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)($,{width:140,height:30}),(0,M.jsx)($,{width:90,height:12})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)($,{width:60,height:16}),(0,M.jsx)($,{width:60,height:12})]})]}),(0,M.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,M.jsx)($,{width:`50%`,height:12}),(0,M.jsx)($,{width:`70%`,height:11})]},t))})]})}function st({value:e,onChange:t}){return(0,M.jsx)(`div`,{className:`flex items-center`,children:(0,M.jsx)(s,{value:e,onChange:t,menuAlign:`end`,menuMinWidth:196,options:Ne.map(e=>({value:e.value,label:e.label}))})})}function ct({query:e,groups:t}){let[n,r]=(0,S.useState)(new Set),i=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,M.jsx)(Y,{title:`Breakdown`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(Q,{label:`% of total`,active:n.has(`pct`),onClick:()=>i(`pct`)}),(0,M.jsx)(Q,{label:`Tokens`,active:n.has(`tokens`),onClick:()=>i(`tokens`)}),(0,M.jsx)(Q,{label:`Turns`,active:n.has(`turns`),onClick:()=>i(`turns`)})]}),(0,M.jsx)(X,{query:e,skeleton:(0,M.jsx)(ut,{}),render:e=>(0,M.jsx)(lt,{groups:t??e.response.breakdown,showPct:n.has(`pct`),showTokens:n.has(`tokens`),showTurns:n.has(`turns`)})})]})})}function Q({label:e,active:t,onClick:n}){return(0,M.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full border px-2.5 py-1 text-label-medium-default`,style:{borderColor:t?`var(--content-secondary)`:`var(--border-base)`,background:t?`color-mix(in srgb, var(--content-secondary) 15%, transparent)`:`transparent`,color:t?`var(--content-default)`:`var(--content-tertiary)`},children:e})}function lt({groups:e,showPct:t,showTokens:n,showTurns:r}){if(e.length===0)return(0,M.jsx)(dt,{title:`No breakdown data`,subtitle:`No usage recorded for this grouping`});let i=e.reduce((e,t)=>e+t.totalEstimatedCostUsd,0);return(0,M.jsx)(`div`,{className:`overflow-hidden rounded-md`,children:(0,M.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{style:{borderBottom:`1px solid var(--border-base)`},children:[(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:`Group`}),n?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`35%`},children:`Tokens`}):null,r?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`72px`},children:`Turns`}):null,t?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`64px`},children:`%`}):null,(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`100px`},children:`Cost`})]})}),(0,M.jsx)(`tbody`,{children:e.map((e,a)=>{let o=Ee(e),s=De(e),c=i>0?Math.round(e.totalEstimatedCostUsd/i*100):0;return(0,M.jsxs)(`tr`,{style:{borderTop:a===0?`none`:`1px solid var(--border-base)`},children:[(0,M.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-default)`},children:(0,M.jsx)(`span`,{className:`block truncate text-body-medium-lighter`,title:e.group,children:e.group})}),n?(0,M.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-secondary)`},children:(0,M.jsx)(`span`,{className:`block truncate text-body-small-default`,title:o,children:s})}):null,r?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.turnCount==null?`—`:e.turnCount.toLocaleString()})}):null,t?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsxs)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[c,`%`]})}):null,(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:_(e.totalEstimatedCostUsd)})})]},e.groupKey??e.groupId??`${e.group}-${a}`)})})]})})}function ut(){return(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,"aria-hidden":`true`,children:Array.from({length:4}).map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)($,{width:100,height:14}),(0,M.jsx)($,{width:`60%`,height:12}),(0,M.jsx)($,{width:50,height:14})]},t))})}function $({width:e,height:t}){return(0,M.jsx)(`div`,{className:`rounded-sm`,style:{width:typeof e==`number`?`${e}px`:e,height:`${t}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}})}function dt({title:e,subtitle:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-1 py-8 text-center`,children:[(0,M.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t})]})}function ft({message:e,onRetry:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(l,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-negative-strong, #f87171)`}}),(0,M.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:e})]}),t?(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`self-start rounded-md border px-3 py-1 text-body-small-default`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`,color:`var(--content-default)`},children:`Retry`}):null]})}function pt(){return(0,M.jsx)(et,{assistantId:h()})}export{pt as UsagePage};
@@ -1 +1 @@
1
- import{t as e}from"./button-D-AX8Voo.js";import{t}from"./useQuery-B45lW1Kk.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import"./src-SCpl1O1B.js";import{t as r}from"./createLucideIcon-BlMXrA59.js";import{t as i}from"./calendar-CpgH8CqM.js";import{t as a}from"./code-aMX9iMYa.js";import{t as o}from"./globe-D3P5sSKJ.js";import{t as s}from"./link-2-r_QPxX18.js";import{_t as c}from"./react-query.gen-BwkZCSTW.js";import{$i as l,Ii as u,Ji as d,Vi as f,_i as p,bi as m,ni as h,zi as g}from"./index-CZ2UBc_U.js";var _=r(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),v={mail:f,calendar:i,"message-circle":g,globe:o,zap:h,code:a,mic:u,"shopping-cart":p,palette:r(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),heart:l,settings:m,"link-2":s};function y(e){return v[e]}var b=n();function x({selected:e,onSelect:t,counts:n,totalCount:r,showCounts:i,categories:a,ariaLabel:o=`Skill categories`}){let s=[...a].sort((e,t)=>e.label.localeCompare(t.label));return(0,b.jsxs)(`nav`,{className:`flex flex-col gap-1`,"aria-label":o,children:[(0,b.jsx)(S,{icon:d,label:`All`,count:r,isActive:e===null,showCount:i,onClick:()=>t(null)}),s.map(r=>(0,b.jsx)(S,{icon:y(r.icon)??d,label:r.label,count:n[r.slug]??0,isActive:e===r.slug,showCount:i,onClick:()=>t(r.slug)},r.slug))]})}function S({icon:t,label:n,count:r,isActive:i,showCount:a,onClick:o}){return(0,b.jsxs)(e,{variant:`ghost`,onClick:o,"aria-pressed":i,className:`h-auto justify-between gap-3 rounded-lg border-0 bg-transparent px-3 py-2 text-left hover:bg-[var(--ghost-hover)]`,style:{backgroundColor:i?`var(--surface-active)`:void 0,color:i?`var(--content-default)`:`var(--content-secondary)`},children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,b.jsx)(t,{className:`h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`text-body-medium-default`,children:n})]}),a&&(0,b.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:r})]})}function C(e){return t({...c({path:{assistant_id:e}}),select:e=>e.categories,staleTime:300*1e3})}export{_ as i,x as n,y as r,C as t};
1
+ import{t as e}from"./button-D-AX8Voo.js";import{t}from"./useQuery-B45lW1Kk.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import"./src-SCpl1O1B.js";import{t as r}from"./createLucideIcon-BlMXrA59.js";import{t as i}from"./calendar-CpgH8CqM.js";import{t as a}from"./code-aMX9iMYa.js";import{t as o}from"./globe-D3P5sSKJ.js";import{t as s}from"./link-2-r_QPxX18.js";import{_t as c}from"./react-query.gen-BwkZCSTW.js";import{$i as l,Ii as u,Ji as d,Vi as f,_i as p,bi as m,ni as h,zi as g}from"./index-B-S-gNKm.js";var _=r(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),v={mail:f,calendar:i,"message-circle":g,globe:o,zap:h,code:a,mic:u,"shopping-cart":p,palette:r(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),heart:l,settings:m,"link-2":s};function y(e){return v[e]}var b=n();function x({selected:e,onSelect:t,counts:n,totalCount:r,showCounts:i,categories:a,ariaLabel:o=`Skill categories`}){let s=[...a].sort((e,t)=>e.label.localeCompare(t.label));return(0,b.jsxs)(`nav`,{className:`flex flex-col gap-1`,"aria-label":o,children:[(0,b.jsx)(S,{icon:d,label:`All`,count:r,isActive:e===null,showCount:i,onClick:()=>t(null)}),s.map(r=>(0,b.jsx)(S,{icon:y(r.icon)??d,label:r.label,count:n[r.slug]??0,isActive:e===r.slug,showCount:i,onClick:()=>t(r.slug)},r.slug))]})}function S({icon:t,label:n,count:r,isActive:i,showCount:a,onClick:o}){return(0,b.jsxs)(e,{variant:`ghost`,onClick:o,"aria-pressed":i,className:`h-auto justify-between gap-3 rounded-lg border-0 bg-transparent px-3 py-2 text-left hover:bg-[var(--ghost-hover)]`,style:{backgroundColor:i?`var(--surface-active)`:void 0,color:i?`var(--content-default)`:`var(--content-secondary)`},children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,b.jsx)(t,{className:`h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`text-body-medium-default`,children:n})]}),a&&(0,b.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:r})]})}function C(e){return t({...c({path:{assistant_id:e}}),select:e=>e.categories,staleTime:300*1e3})}export{_ as i,x as n,y as r,C as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,r as n,s as r}from"./local-settings-lVNyIOJ_.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-D-AX8Voo.js";import{t as o}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./dropdown-ChWAdhLG.js";import{t as l}from"./toggle-X_kQW5my.js";import{t as u}from"./info-ciQS_i3y.js";import{a as d}from"./routes-C6gxiCrz.js";import{Bn as f,Fn as p,Hn as m,In as h,Ln as g,Pn as _,Rn as v,Un as y,Vn as b,Xn as x,Zn as S,ja as C,zn as w}from"./index-CZ2UBc_U.js";import{t as T}from"./detail-card-EsA9SOvZ.js";var E=e(i(),1),D=s(),O=`vellum:voice:conversationTimeoutSeconds`,k=[{label:`Ctrl`,activator:{kind:`modifierOnly`,modifiers:[`control`]}},{label:`Alt`,activator:{kind:`modifierOnly`,modifiers:[`option`]}},{label:`Ctrl+Shift`,activator:{kind:`modifierOnly`,modifiers:[`control`,`shift`]}}],A={label:`Fn`,activator:h},j=[{label:`5 seconds`,value:`5`},{label:`10 seconds`,value:`10`},{label:`15 seconds`,value:`15`},{label:`30 seconds`,value:`30`},{label:`60 seconds`,value:`60`}],M=`30`,N=`text-body-small-default text-[var(--content-tertiary)]`;function P(){return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,D.jsx)(F,{}),(0,D.jsx)(L,{}),(0,D.jsx)(R,{}),(0,D.jsx)(B,{})]})}function F(){return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--field-bg)] px-3 py-2`,children:[(0,D.jsx)(u,{className:`h-3.5 w-3.5 shrink-0 text-[var(--primary-base)]`}),(0,D.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Looking to configure Speech-to-Text or Text-to-Speech models?`}),(0,D.jsxs)(o,{to:d.settings.ai,className:`inline-flex items-center gap-1 text-body-medium-lighter text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Go to Models & Services`,(0,D.jsx)(C,{className:`h-3 w-3`})]})]})}var I=``;function L(){let[e,n]=(0,E.useState)([]),[i,o]=(0,E.useState)(!1),[s,l]=(0,E.useState)(()=>S()),u=(0,E.useCallback)(async()=>{if(navigator.mediaDevices?.enumerateDevices)try{let e=(await navigator.mediaDevices.enumerateDevices()).filter(e=>e.kind===`audioinput`);o(e.length>0&&e.every(e=>!e.label)),n(e.filter(e=>e.deviceId!==``&&e.deviceId!==`default`&&e.deviceId!==`communications`))}catch{n([]),o(!1)}},[]),d=(0,E.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop()}catch{}u()},[u]);(0,E.useEffect)(()=>{u();let e=navigator.mediaDevices;if(!e?.addEventListener)return;let t=()=>void u();return e.addEventListener(`devicechange`,t),()=>e.removeEventListener(`devicechange`,t)},[u]);let f=(0,E.useMemo)(()=>[{value:I,label:`System Default`},...e.map((e,t)=>({value:e.deviceId,label:e.label||`Microphone ${t+1}`}))],[e]),p=(0,E.useCallback)(e=>{l(e),e===I?t(x):r(x,e)},[]);return(0,D.jsx)(T,{title:`Microphone`,subtitle:`Which input device is used for dictation and voice conversations.`,children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,D.jsx)(`div`,{className:`max-w-xs`,children:(0,D.jsx)(c,{options:f,value:f.some(e=>e.value===s)?s:I,onChange:p,"aria-label":`Microphone`})}),i&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(a,{variant:`outlined`,onClick:d,children:`Allow Microphone Access`}),(0,D.jsx)(`span`,{className:N,children:`Grant microphone access to list your available input devices.`})]})]})})}function R(){let e=_(),[t,i]=(0,E.useState)(()=>{let t=n(g,``);return t?b(t,{preserveFunction:e}):e?A.activator:{kind:`off`}}),[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)([]),d=(0,E.useRef)(null),x=(0,E.useRef)(!1),S=(0,E.useMemo)(()=>e?[A,...k]:k,[e]),C=t.kind!==`off`,O=C&&!e,j=(0,E.useCallback)(e=>{i(e),r(g,m(e)),o(!1),c([])},[]),M=(0,E.useCallback)(()=>{o(!0),c([]),x.current=!1,requestAnimationFrame(()=>{d.current?.focus()})},[]),P=(0,E.useCallback)(()=>{o(!1),c([]),x.current=!1},[]),F=(0,E.useCallback)(t=>{let n=[];return e&&t.getModifierState(`Fn`)&&n.push(`function`),t.ctrlKey&&n.push(`control`),t.altKey&&n.push(`option`),t.shiftKey&&n.push(`shift`),t.metaKey&&n.push(`command`),n},[e]),I=(0,E.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){P();return}let t=F(e),n=e.key;if(n===`Control`||n===`Alt`||n===`Shift`||n===`Meta`||n===`Fn`){c(t.includes(`function`)?h.modifiers:y(t));return}if(t.includes(`function`)){j(h);return}x.current=!0,j({kind:`key`,label:n.length===1?n.toUpperCase():n,modifiers:t})},[P,F,j]),L=(0,E.useCallback)(e=>{if(!a)return;e.preventDefault(),e.stopPropagation();let t=e.key;if(t===`Control`||t===`Alt`||t===`Shift`||t===`Meta`||t===`Fn`){if(x.current){x.current=!1,c([]);return}F(e).length===0&&s.length>0&&j({kind:`modifierOnly`,modifiers:s})}},[F,a,s,j]);(0,E.useEffect)(()=>{if(!a)return;let e=e=>{d.current&&!d.current.contains(e.target)&&P()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[P,a]);let R=C&&!S.some(e=>w(e.activator,t));return(0,D.jsx)(T,{title:`Push to Talk`,subtitle:`Hold the activation key to dictate text or start a voice conversation.`,children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(l,{checked:C,onChange:n=>{n?t.kind===`off`&&j(e?A.activator:p):j({kind:`off`})},label:`Enable Push to Talk`}),C&&(0,D.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,D.jsx)(`span`,{className:N,children:`Activation Key:`}),(0,D.jsxs)(`div`,{ref:d,tabIndex:a?0:-1,onKeyDown:a?I:void 0,onKeyUp:a?L:void 0,className:`flex flex-wrap items-center gap-2 focus:outline-none`,children:[S.map(e=>{let n=w(e.activator,t);return(0,D.jsx)(z,{label:e.label,selected:n,onClick:()=>j(e.activator)},e.label)}),a?(0,D.jsx)(z,{label:s.length>0?f(s):`Press any key…`,selected:!0,recording:!0,onClick:P}):(0,D.jsx)(z,{label:R?v(t):`Custom`,selected:R,onClick:M})]}),O&&(0,D.jsxs)(`div`,{className:`flex items-start gap-1 pt-1 text-body-small-default text-[var(--content-quiet)]`,children:[(0,D.jsx)(u,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,D.jsx)(`span`,{children:`Push-to-Talk only works while this tab is focused, and browsers may intercept some shortcuts (e.g. Ctrl+T) before the page can see them. For always-on PTT, use the Vellum desktop app.`})]})]})]})})}function z({label:e,selected:t,recording:n=!1,onClick:r}){return(0,D.jsxs)(`button`,{type:`button`,onClick:r,className:[`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 text-body-medium-lighter transition-colors`,`border-[var(--border-subtle)]`,t?`bg-[var(--surface-active)]`:`bg-[var(--surface-lift)] hover:bg-[var(--surface-hover)]`,n?`animate-pulse`:``].filter(Boolean).join(` `),children:[(0,D.jsx)(`span`,{className:[`inline-block h-2.5 w-2.5 rounded-full border`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)]`].join(` `)}),(0,D.jsx)(`span`,{className:`text-[var(--content-default)]`,children:e})]})}function B(){let[e,t]=(0,E.useState)(()=>{let e=n(O,M);return j.find(t=>t.value===e)?.value??M});return(0,D.jsx)(T,{title:`Conversation Timeout`,subtitle:`How long the assistant waits for you to start speaking before ending a voice conversation turn.`,children:(0,D.jsx)(`div`,{className:`max-w-xs`,children:(0,D.jsx)(c,{options:j,value:e,onChange:(0,E.useCallback)(e=>{t(e),r(O,e)},[]),"aria-label":`Conversation timeout`})})})}export{P as VoicePage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,r as n,s as r}from"./local-settings-lVNyIOJ_.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-D-AX8Voo.js";import{t as o}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./dropdown-ChWAdhLG.js";import{t as l}from"./toggle-X_kQW5my.js";import{t as u}from"./info-ciQS_i3y.js";import{a as d}from"./routes-C6gxiCrz.js";import{Bn as f,Fn as p,Hn as m,In as h,Ln as g,Pn as _,Rn as v,Un as y,Vn as b,Xn as x,Zn as S,ja as C,zn as w}from"./index-B-S-gNKm.js";import{t as T}from"./detail-card-EsA9SOvZ.js";var E=e(i(),1),D=s(),O=`vellum:voice:conversationTimeoutSeconds`,k=[{label:`Ctrl`,activator:{kind:`modifierOnly`,modifiers:[`control`]}},{label:`Alt`,activator:{kind:`modifierOnly`,modifiers:[`option`]}},{label:`Ctrl+Shift`,activator:{kind:`modifierOnly`,modifiers:[`control`,`shift`]}}],A={label:`Fn`,activator:h},j=[{label:`5 seconds`,value:`5`},{label:`10 seconds`,value:`10`},{label:`15 seconds`,value:`15`},{label:`30 seconds`,value:`30`},{label:`60 seconds`,value:`60`}],M=`30`,N=`text-body-small-default text-[var(--content-tertiary)]`;function P(){return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,D.jsx)(F,{}),(0,D.jsx)(L,{}),(0,D.jsx)(R,{}),(0,D.jsx)(B,{})]})}function F(){return(0,D.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--field-bg)] px-3 py-2`,children:[(0,D.jsx)(u,{className:`h-3.5 w-3.5 shrink-0 text-[var(--primary-base)]`}),(0,D.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Looking to configure Speech-to-Text or Text-to-Speech models?`}),(0,D.jsxs)(o,{to:d.settings.ai,className:`inline-flex items-center gap-1 text-body-medium-lighter text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Go to Models & Services`,(0,D.jsx)(C,{className:`h-3 w-3`})]})]})}var I=``;function L(){let[e,n]=(0,E.useState)([]),[i,o]=(0,E.useState)(!1),[s,l]=(0,E.useState)(()=>S()),u=(0,E.useCallback)(async()=>{if(navigator.mediaDevices?.enumerateDevices)try{let e=(await navigator.mediaDevices.enumerateDevices()).filter(e=>e.kind===`audioinput`);o(e.length>0&&e.every(e=>!e.label)),n(e.filter(e=>e.deviceId!==``&&e.deviceId!==`default`&&e.deviceId!==`communications`))}catch{n([]),o(!1)}},[]),d=(0,E.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop()}catch{}u()},[u]);(0,E.useEffect)(()=>{u();let e=navigator.mediaDevices;if(!e?.addEventListener)return;let t=()=>void u();return e.addEventListener(`devicechange`,t),()=>e.removeEventListener(`devicechange`,t)},[u]);let f=(0,E.useMemo)(()=>[{value:I,label:`System Default`},...e.map((e,t)=>({value:e.deviceId,label:e.label||`Microphone ${t+1}`}))],[e]),p=(0,E.useCallback)(e=>{l(e),e===I?t(x):r(x,e)},[]);return(0,D.jsx)(T,{title:`Microphone`,subtitle:`Which input device is used for dictation and voice conversations.`,children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,D.jsx)(`div`,{className:`max-w-xs`,children:(0,D.jsx)(c,{options:f,value:f.some(e=>e.value===s)?s:I,onChange:p,"aria-label":`Microphone`})}),i&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(a,{variant:`outlined`,onClick:d,children:`Allow Microphone Access`}),(0,D.jsx)(`span`,{className:N,children:`Grant microphone access to list your available input devices.`})]})]})})}function R(){let e=_(),[t,i]=(0,E.useState)(()=>{let t=n(g,``);return t?b(t,{preserveFunction:e}):e?A.activator:{kind:`off`}}),[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)([]),d=(0,E.useRef)(null),x=(0,E.useRef)(!1),S=(0,E.useMemo)(()=>e?[A,...k]:k,[e]),C=t.kind!==`off`,O=C&&!e,j=(0,E.useCallback)(e=>{i(e),r(g,m(e)),o(!1),c([])},[]),M=(0,E.useCallback)(()=>{o(!0),c([]),x.current=!1,requestAnimationFrame(()=>{d.current?.focus()})},[]),P=(0,E.useCallback)(()=>{o(!1),c([]),x.current=!1},[]),F=(0,E.useCallback)(t=>{let n=[];return e&&t.getModifierState(`Fn`)&&n.push(`function`),t.ctrlKey&&n.push(`control`),t.altKey&&n.push(`option`),t.shiftKey&&n.push(`shift`),t.metaKey&&n.push(`command`),n},[e]),I=(0,E.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){P();return}let t=F(e),n=e.key;if(n===`Control`||n===`Alt`||n===`Shift`||n===`Meta`||n===`Fn`){c(t.includes(`function`)?h.modifiers:y(t));return}if(t.includes(`function`)){j(h);return}x.current=!0,j({kind:`key`,label:n.length===1?n.toUpperCase():n,modifiers:t})},[P,F,j]),L=(0,E.useCallback)(e=>{if(!a)return;e.preventDefault(),e.stopPropagation();let t=e.key;if(t===`Control`||t===`Alt`||t===`Shift`||t===`Meta`||t===`Fn`){if(x.current){x.current=!1,c([]);return}F(e).length===0&&s.length>0&&j({kind:`modifierOnly`,modifiers:s})}},[F,a,s,j]);(0,E.useEffect)(()=>{if(!a)return;let e=e=>{d.current&&!d.current.contains(e.target)&&P()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[P,a]);let R=C&&!S.some(e=>w(e.activator,t));return(0,D.jsx)(T,{title:`Push to Talk`,subtitle:`Hold the activation key to dictate text or start a voice conversation.`,children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(l,{checked:C,onChange:n=>{n?t.kind===`off`&&j(e?A.activator:p):j({kind:`off`})},label:`Enable Push to Talk`}),C&&(0,D.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,D.jsx)(`span`,{className:N,children:`Activation Key:`}),(0,D.jsxs)(`div`,{ref:d,tabIndex:a?0:-1,onKeyDown:a?I:void 0,onKeyUp:a?L:void 0,className:`flex flex-wrap items-center gap-2 focus:outline-none`,children:[S.map(e=>{let n=w(e.activator,t);return(0,D.jsx)(z,{label:e.label,selected:n,onClick:()=>j(e.activator)},e.label)}),a?(0,D.jsx)(z,{label:s.length>0?f(s):`Press any key…`,selected:!0,recording:!0,onClick:P}):(0,D.jsx)(z,{label:R?v(t):`Custom`,selected:R,onClick:M})]}),O&&(0,D.jsxs)(`div`,{className:`flex items-start gap-1 pt-1 text-body-small-default text-[var(--content-quiet)]`,children:[(0,D.jsx)(u,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,D.jsx)(`span`,{children:`Push-to-Talk only works while this tab is focused, and browsers may intercept some shortcuts (e.g. Ctrl+T) before the page can see them. For always-on PTT, use the Vellum desktop app.`})]})]})]})})}function z({label:e,selected:t,recording:n=!1,onClick:r}){return(0,D.jsxs)(`button`,{type:`button`,onClick:r,className:[`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 text-body-medium-lighter transition-colors`,`border-[var(--border-subtle)]`,t?`bg-[var(--surface-active)]`:`bg-[var(--surface-lift)] hover:bg-[var(--surface-hover)]`,n?`animate-pulse`:``].filter(Boolean).join(` `),children:[(0,D.jsx)(`span`,{className:[`inline-block h-2.5 w-2.5 rounded-full border`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)]`].join(` `)}),(0,D.jsx)(`span`,{className:`text-[var(--content-default)]`,children:e})]})}function B(){let[e,t]=(0,E.useState)(()=>{let e=n(O,M);return j.find(t=>t.value===e)?.value??M});return(0,D.jsx)(T,{title:`Conversation Timeout`,subtitle:`How long the assistant waits for you to start speaking before ending a voice conversation turn.`,children:(0,D.jsx)(`div`,{className:`max-w-xs`,children:(0,D.jsx)(c,{options:j,value:e,onChange:(0,E.useCallback)(e=>{t(e),r(O,e)},[]),"aria-label":`Conversation timeout`})})})}export{P as VoicePage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./moon-CKINz50a.js";import{t as i}from"./misc-CFzLzLPH.js";import{G as a,K as o,U as s,W as c,_a as l,ai as u,fi as d,ga as f,ha as p,hi as m,la as h,ma as g,pa as _,va as v}from"./index-CZ2UBc_U.js";var y=e(t(),1),b={"sun.max.fill":{icon:d,className:`text-orange-500`},"cloud.sun.fill":{icon:g,className:`text-amber-400`},"moon.fill":{icon:r,className:`text-blue-400`},"cloud.moon.fill":{icon:f,className:`text-blue-400`},"cloud.fill":{icon:_,className:`text-stone-400`},"cloud.rain.fill":{icon:p,className:`text-blue-400`},snowflake:{icon:m,className:`text-blue-300`},"cloud.bolt.fill":{icon:l,className:`text-orange-500`},"cloud.fog.fill":{icon:v,className:`text-stone-400`}},x={sunny:{icon:d,className:`text-orange-500`},clear:{icon:d,className:`text-orange-500`},"partly cloudy":{icon:g,className:`text-amber-400`},"mostly sunny":{icon:g,className:`text-amber-400`},cloudy:{icon:_,className:`text-stone-400`},overcast:{icon:_,className:`text-stone-400`},rainy:{icon:p,className:`text-blue-400`},rain:{icon:p,className:`text-blue-400`},drizzle:{icon:p,className:`text-blue-400`},snow:{icon:m,className:`text-blue-300`},snowy:{icon:m,className:`text-blue-300`},thunderstorm:{icon:l,className:`text-orange-500`},thunder:{icon:l,className:`text-orange-500`},foggy:{icon:v,className:`text-stone-400`},fog:{icon:v,className:`text-stone-400`},mist:{icon:v,className:`text-stone-400`},hazy:{icon:v,className:`text-stone-400`},night:{icon:r,className:`text-blue-400`},"mainly clear":{icon:d,className:`text-orange-500`},"mostly cloudy":{icon:_,className:`text-stone-400`},breezy:{icon:u,className:`text-stone-400`},windy:{icon:u,className:`text-stone-400`},cool:{icon:_,className:`text-stone-400`},warm:{icon:d,className:`text-orange-500`},hot:{icon:d,className:`text-orange-500`},cold:{icon:m,className:`text-blue-300`},"cold snap":{icon:m,className:`text-blue-300`},"warm, mostly sunny":{icon:g,className:`text-amber-400`},"cooler, breezy":{icon:u,className:`text-stone-400`}},S={icon:_,className:`text-stone-400`};function C(e){let t=b[e];if(t)return t;let n=e.toLowerCase(),r=x[n];if(r)return r;for(let[e,t]of Object.entries(x))if(n.includes(e))return t;return S}function w(e){if(typeof e==`string`){let t=e.match(/^(\d+)\s*mph\s*(.*)/i);if(t)return{speed:Number(t[1]),direction:t[2]?.trim()||void 0}}return{}}function T(e){let t;if(typeof e.location==`string`)t=e.location;else{let n=a(e.location);n&&typeof n.name==`string`&&(t=n.name)}if(!t)return null;let n=a(e.current),r=c(n?.temp)??c(e.currentTemp)??c(e.temperature)??c(e.temp),i=c(n?.feelsLike)??c(n?.feels_like)??c(n?.apparentTemperature)??c(e.feelsLike)??c(e.feels_like)??c(e.apparentTemperature),l=o(n?.condition)??o(e.condition),u=c(n?.humidity)??c(e.humidity),d=w(n?.wind??e.wind),f=c(n?.windSpeed)??c(n?.wind_speed)??c(e.windSpeed)??c(e.wind_speed)??d.speed,p=o(n?.windDirection)??o(n?.wind_direction)??o(e.windDirection)??o(e.wind_direction)??d.direction,m=a(e.units),h=o(m?.temperature)??o(n?.unit)??o(e.unit)??`F`,g=o(m?.speed)??o(e.windUnit)??o(e.wind_unit),_=s(e.hourly).map((e,t)=>({id:o(e.id)??String(t),time:o(e.time)??``,icon:o(e.icon)??o(e.condition)??`cloud.fill`,temp:c(e.tempC)??c(e.temp)??c(e.temperature),tempC:c(e.tempC)})),v=s([e.forecast,e.daily,e.days].find(Array.isArray)).map((e,t)=>({id:o(e.id)??String(t),day:o(e.day)??o(e.date),dayLabel:o(e.dayLabel)??o(e.date),icon:o(e.icon)??o(e.condition)??`cloud.fill`,low:c(e.low),high:c(e.high),lowC:c(e.lowC),highC:c(e.highC),precip:c(e.precip)??c(e.precipitation)??c(e.precipitationProbability),condition:o(e.condition)}));return{location:t,currentTemp:r,feelsLike:i,condition:l,humidity:u,windSpeed:f,windDirection:p,windUnit:g,unit:h,hourly:_.length>0?_:void 0,forecast:v.length>0?v:void 0}}function E(e){return e*9/5+32}function D(e){return(e-32)*5/9}function O(e,t,n){if(e===void 0)return null;let r=e;return t&&!n&&(r=D(e)),!t&&n&&(r=E(e)),`${Math.round(r)}`}function k(e,t,n){return e.tempC===void 0?e.temp===void 0?null:O(e.temp,t,n):O(e.tempC,!1,n)}function A(e,t,n){return e.lowC===void 0?O(e.low,t,n):O(e.lowC,!1,n)}function j(e,t,n){return e.highC===void 0?O(e.high,t,n):O(e.highC,!1,n)}var M=n();function N({icon:e,size:t=20}){let{icon:n,className:r}=C(e);return(0,M.jsx)(n,{width:t,height:t,className:r})}function P({useFahrenheit:e,onToggle:t}){return(0,M.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-[var(--border-element)]`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:i(`px-2 py-0.5 text-body-small-default transition-colors`,e?`bg-[var(--primary-base)] text-[var(--content-inset)]`:`bg-transparent text-[var(--content-quiet)]`),children:`°F`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:i(`px-2 py-0.5 text-body-small-default transition-colors`,e?`bg-transparent text-[var(--content-quiet)]`:`bg-[var(--primary-base)] text-[var(--content-inset)]`),children:`°C`})]})}function F({data:e,sourceIsFahrenheit:t,useFahrenheit:n,onToggle:r}){let i=e.location,a=O(e.currentTemp,t,n),o=O(e.feelsLike,t,n),s=n?`F`:`C`,c=e.forecast?.[0],l=c?j(c,t,n):null,d=c?A(c,t,n):null,f=null;return e.windSpeed!==void 0&&(f=`${Math.round(e.windSpeed)} ${e.windUnit??`mph`}`,e.windDirection&&(f=`${e.windDirection} ${f}`)),(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i}),a!==null&&(0,M.jsxs)(`div`,{className:`mt-1 text-4xl font-light text-[var(--content-default)]`,children:[a,`°`,s]}),e.condition&&(0,M.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-quiet)]`,children:e.condition})]}),(0,M.jsx)(P,{useFahrenheit:n,onToggle:r})]}),(0,M.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3`,children:[o!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:[`Feels like `,o,`°`]}),l!==null&&d!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:[`H:`,l,`° L:`,d,`°`]}),f&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2 py-0.5 text-label-medium-default text-[var(--content-tertiary)]`,children:[(0,M.jsx)(u,{width:12,height:12}),f]}),e.humidity!==void 0&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2 py-0.5 text-label-medium-default text-[var(--content-tertiary)]`,children:[(0,M.jsx)(h,{width:12,height:12}),e.humidity,`%`]})]})]})}function I({hourly:e,sourceIsFahrenheit:t,useFahrenheit:n}){return(0,M.jsx)(`div`,{className:`mt-3 border-t border-[var(--border-element)] pt-3`,children:(0,M.jsx)(`div`,{className:`flex gap-3 overflow-x-auto`,children:e.map((e,r)=>{let i=e.time.toLowerCase()===`now`,a=k(e,t,n);return(0,M.jsxs)(`div`,{className:`flex min-w-[3rem] shrink-0 flex-col items-center gap-1`,children:[(0,M.jsx)(`span`,{className:i?`text-body-small-emphasised text-[var(--content-default)]`:`text-label-medium-default text-[var(--content-quiet)]`,children:i?`Now`:e.time}),(0,M.jsx)(N,{icon:e.icon,size:18}),a!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-default)]`,children:[a,`°`]})]},e.id??r)})})})}function L({forecast:e,currentTemp:t,sourceIsFahrenheit:n,useFahrenheit:r}){let{globalMin:a,globalMax:o}=(0,y.useMemo)(()=>{let t=1/0,n=-1/0;for(let r of e){let e=r.lowC??r.low,i=r.highC??r.high;e!==void 0&&e<t&&(t=e),i!==void 0&&i>n&&(n=i)}return{globalMin:t===1/0?0:t,globalMax:n===-1/0?100:n}},[e]),s=o-a||1;return(0,M.jsx)(`div`,{className:`mt-3 border-t border-[var(--border-element)] pt-3`,children:(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map((e,c)=>{let l=e.dayLabel??e.day??`Day ${c+1}`,u=l.toLowerCase()===`today`,d=A(e,n,r),f=j(e,n,r),p=e.precip,m=e.lowC??e.low??a,h=e.highC??e.high??o,g=(m-a)/s*100,_=(h-a)/s*100,v=Math.max(_-g,2),y=null;if(u&&t!==void 0){let r=(e.lowC!==void 0||e.highC!==void 0)&&n?(t-32)*5/9:t;y=h===m?50:(Math.max(m,Math.min(h,r))-m)/(h-m)*100}return(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`span`,{className:i(`w-12 shrink-0 truncate text-body-small-default`,u?`text-[var(--content-default)]`:`text-[var(--content-quiet)]`),children:l}),(0,M.jsxs)(`div`,{className:`flex w-10 shrink-0 items-center justify-center gap-0.5`,children:[(0,M.jsx)(N,{icon:e.icon,size:16}),p!==void 0&&p>0&&(0,M.jsxs)(`span`,{className:`text-label-small-default text-blue-400`,children:[Math.round(p),`%`]})]}),(0,M.jsx)(`span`,{className:`w-7 shrink-0 text-right text-body-small-default text-[var(--content-faint)]`,children:d===null?`--`:`${d}°`}),(0,M.jsxs)(`div`,{className:`relative h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--border-subtle)]`,children:[(0,M.jsx)(`div`,{className:`absolute top-0 h-full rounded-full bg-[var(--primary-base)]`,style:{left:`${g}%`,width:`${v}%`}}),y!==null&&(0,M.jsx)(`div`,{className:`absolute top-1/2 h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-[var(--aux-white)] bg-[var(--aux-white)] shadow-sm`,style:{left:`${g+y/100*v}%`}})]}),(0,M.jsx)(`span`,{className:`w-7 shrink-0 text-right text-body-small-default text-[var(--content-default)]`,children:f===null?`--`:`${f}°`})]},e.id??c)})})})}function R({templateData:e,fallback:t}){let n=(0,y.useMemo)(()=>T(e),[e]),r=n?.unit?.toUpperCase()===`F`||n?.unit?.toLowerCase()===`fahrenheit`,[i,a]=(0,y.useState)(null),o=i??r;return!n||n.currentTemp===void 0&&!n.forecast?.length?t??null:(0,M.jsxs)(`div`,{className:`mt-3`,children:[(0,M.jsx)(F,{data:n,sourceIsFahrenheit:r,useFahrenheit:o,onToggle:a}),n.hourly&&n.hourly.length>0&&(0,M.jsx)(I,{hourly:n.hourly,sourceIsFahrenheit:r,useFahrenheit:o}),n.forecast&&n.forecast.length>0&&(0,M.jsx)(L,{forecast:n.forecast,currentTemp:n.currentTemp,sourceIsFahrenheit:r,useFahrenheit:o})]})}export{R as WeatherForecastDisplay};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./moon-CKINz50a.js";import{t as i}from"./misc-CFzLzLPH.js";import{G as a,K as o,U as s,W as c,_a as l,ai as u,fi as d,ga as f,ha as p,hi as m,la as h,ma as g,pa as _,va as v}from"./index-B-S-gNKm.js";var y=e(t(),1),b={"sun.max.fill":{icon:d,className:`text-orange-500`},"cloud.sun.fill":{icon:g,className:`text-amber-400`},"moon.fill":{icon:r,className:`text-blue-400`},"cloud.moon.fill":{icon:f,className:`text-blue-400`},"cloud.fill":{icon:_,className:`text-stone-400`},"cloud.rain.fill":{icon:p,className:`text-blue-400`},snowflake:{icon:m,className:`text-blue-300`},"cloud.bolt.fill":{icon:l,className:`text-orange-500`},"cloud.fog.fill":{icon:v,className:`text-stone-400`}},x={sunny:{icon:d,className:`text-orange-500`},clear:{icon:d,className:`text-orange-500`},"partly cloudy":{icon:g,className:`text-amber-400`},"mostly sunny":{icon:g,className:`text-amber-400`},cloudy:{icon:_,className:`text-stone-400`},overcast:{icon:_,className:`text-stone-400`},rainy:{icon:p,className:`text-blue-400`},rain:{icon:p,className:`text-blue-400`},drizzle:{icon:p,className:`text-blue-400`},snow:{icon:m,className:`text-blue-300`},snowy:{icon:m,className:`text-blue-300`},thunderstorm:{icon:l,className:`text-orange-500`},thunder:{icon:l,className:`text-orange-500`},foggy:{icon:v,className:`text-stone-400`},fog:{icon:v,className:`text-stone-400`},mist:{icon:v,className:`text-stone-400`},hazy:{icon:v,className:`text-stone-400`},night:{icon:r,className:`text-blue-400`},"mainly clear":{icon:d,className:`text-orange-500`},"mostly cloudy":{icon:_,className:`text-stone-400`},breezy:{icon:u,className:`text-stone-400`},windy:{icon:u,className:`text-stone-400`},cool:{icon:_,className:`text-stone-400`},warm:{icon:d,className:`text-orange-500`},hot:{icon:d,className:`text-orange-500`},cold:{icon:m,className:`text-blue-300`},"cold snap":{icon:m,className:`text-blue-300`},"warm, mostly sunny":{icon:g,className:`text-amber-400`},"cooler, breezy":{icon:u,className:`text-stone-400`}},S={icon:_,className:`text-stone-400`};function C(e){let t=b[e];if(t)return t;let n=e.toLowerCase(),r=x[n];if(r)return r;for(let[e,t]of Object.entries(x))if(n.includes(e))return t;return S}function w(e){if(typeof e==`string`){let t=e.match(/^(\d+)\s*mph\s*(.*)/i);if(t)return{speed:Number(t[1]),direction:t[2]?.trim()||void 0}}return{}}function T(e){let t;if(typeof e.location==`string`)t=e.location;else{let n=a(e.location);n&&typeof n.name==`string`&&(t=n.name)}if(!t)return null;let n=a(e.current),r=c(n?.temp)??c(e.currentTemp)??c(e.temperature)??c(e.temp),i=c(n?.feelsLike)??c(n?.feels_like)??c(n?.apparentTemperature)??c(e.feelsLike)??c(e.feels_like)??c(e.apparentTemperature),l=o(n?.condition)??o(e.condition),u=c(n?.humidity)??c(e.humidity),d=w(n?.wind??e.wind),f=c(n?.windSpeed)??c(n?.wind_speed)??c(e.windSpeed)??c(e.wind_speed)??d.speed,p=o(n?.windDirection)??o(n?.wind_direction)??o(e.windDirection)??o(e.wind_direction)??d.direction,m=a(e.units),h=o(m?.temperature)??o(n?.unit)??o(e.unit)??`F`,g=o(m?.speed)??o(e.windUnit)??o(e.wind_unit),_=s(e.hourly).map((e,t)=>({id:o(e.id)??String(t),time:o(e.time)??``,icon:o(e.icon)??o(e.condition)??`cloud.fill`,temp:c(e.tempC)??c(e.temp)??c(e.temperature),tempC:c(e.tempC)})),v=s([e.forecast,e.daily,e.days].find(Array.isArray)).map((e,t)=>({id:o(e.id)??String(t),day:o(e.day)??o(e.date),dayLabel:o(e.dayLabel)??o(e.date),icon:o(e.icon)??o(e.condition)??`cloud.fill`,low:c(e.low),high:c(e.high),lowC:c(e.lowC),highC:c(e.highC),precip:c(e.precip)??c(e.precipitation)??c(e.precipitationProbability),condition:o(e.condition)}));return{location:t,currentTemp:r,feelsLike:i,condition:l,humidity:u,windSpeed:f,windDirection:p,windUnit:g,unit:h,hourly:_.length>0?_:void 0,forecast:v.length>0?v:void 0}}function E(e){return e*9/5+32}function D(e){return(e-32)*5/9}function O(e,t,n){if(e===void 0)return null;let r=e;return t&&!n&&(r=D(e)),!t&&n&&(r=E(e)),`${Math.round(r)}`}function k(e,t,n){return e.tempC===void 0?e.temp===void 0?null:O(e.temp,t,n):O(e.tempC,!1,n)}function A(e,t,n){return e.lowC===void 0?O(e.low,t,n):O(e.lowC,!1,n)}function j(e,t,n){return e.highC===void 0?O(e.high,t,n):O(e.highC,!1,n)}var M=n();function N({icon:e,size:t=20}){let{icon:n,className:r}=C(e);return(0,M.jsx)(n,{width:t,height:t,className:r})}function P({useFahrenheit:e,onToggle:t}){return(0,M.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-[var(--border-element)]`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:i(`px-2 py-0.5 text-body-small-default transition-colors`,e?`bg-[var(--primary-base)] text-[var(--content-inset)]`:`bg-transparent text-[var(--content-quiet)]`),children:`°F`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:i(`px-2 py-0.5 text-body-small-default transition-colors`,e?`bg-transparent text-[var(--content-quiet)]`:`bg-[var(--primary-base)] text-[var(--content-inset)]`),children:`°C`})]})}function F({data:e,sourceIsFahrenheit:t,useFahrenheit:n,onToggle:r}){let i=e.location,a=O(e.currentTemp,t,n),o=O(e.feelsLike,t,n),s=n?`F`:`C`,c=e.forecast?.[0],l=c?j(c,t,n):null,d=c?A(c,t,n):null,f=null;return e.windSpeed!==void 0&&(f=`${Math.round(e.windSpeed)} ${e.windUnit??`mph`}`,e.windDirection&&(f=`${e.windDirection} ${f}`)),(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i}),a!==null&&(0,M.jsxs)(`div`,{className:`mt-1 text-4xl font-light text-[var(--content-default)]`,children:[a,`°`,s]}),e.condition&&(0,M.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-quiet)]`,children:e.condition})]}),(0,M.jsx)(P,{useFahrenheit:n,onToggle:r})]}),(0,M.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3`,children:[o!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:[`Feels like `,o,`°`]}),l!==null&&d!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:[`H:`,l,`° L:`,d,`°`]}),f&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2 py-0.5 text-label-medium-default text-[var(--content-tertiary)]`,children:[(0,M.jsx)(u,{width:12,height:12}),f]}),e.humidity!==void 0&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2 py-0.5 text-label-medium-default text-[var(--content-tertiary)]`,children:[(0,M.jsx)(h,{width:12,height:12}),e.humidity,`%`]})]})]})}function I({hourly:e,sourceIsFahrenheit:t,useFahrenheit:n}){return(0,M.jsx)(`div`,{className:`mt-3 border-t border-[var(--border-element)] pt-3`,children:(0,M.jsx)(`div`,{className:`flex gap-3 overflow-x-auto`,children:e.map((e,r)=>{let i=e.time.toLowerCase()===`now`,a=k(e,t,n);return(0,M.jsxs)(`div`,{className:`flex min-w-[3rem] shrink-0 flex-col items-center gap-1`,children:[(0,M.jsx)(`span`,{className:i?`text-body-small-emphasised text-[var(--content-default)]`:`text-label-medium-default text-[var(--content-quiet)]`,children:i?`Now`:e.time}),(0,M.jsx)(N,{icon:e.icon,size:18}),a!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-default)]`,children:[a,`°`]})]},e.id??r)})})})}function L({forecast:e,currentTemp:t,sourceIsFahrenheit:n,useFahrenheit:r}){let{globalMin:a,globalMax:o}=(0,y.useMemo)(()=>{let t=1/0,n=-1/0;for(let r of e){let e=r.lowC??r.low,i=r.highC??r.high;e!==void 0&&e<t&&(t=e),i!==void 0&&i>n&&(n=i)}return{globalMin:t===1/0?0:t,globalMax:n===-1/0?100:n}},[e]),s=o-a||1;return(0,M.jsx)(`div`,{className:`mt-3 border-t border-[var(--border-element)] pt-3`,children:(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map((e,c)=>{let l=e.dayLabel??e.day??`Day ${c+1}`,u=l.toLowerCase()===`today`,d=A(e,n,r),f=j(e,n,r),p=e.precip,m=e.lowC??e.low??a,h=e.highC??e.high??o,g=(m-a)/s*100,_=(h-a)/s*100,v=Math.max(_-g,2),y=null;if(u&&t!==void 0){let r=(e.lowC!==void 0||e.highC!==void 0)&&n?(t-32)*5/9:t;y=h===m?50:(Math.max(m,Math.min(h,r))-m)/(h-m)*100}return(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`span`,{className:i(`w-12 shrink-0 truncate text-body-small-default`,u?`text-[var(--content-default)]`:`text-[var(--content-quiet)]`),children:l}),(0,M.jsxs)(`div`,{className:`flex w-10 shrink-0 items-center justify-center gap-0.5`,children:[(0,M.jsx)(N,{icon:e.icon,size:16}),p!==void 0&&p>0&&(0,M.jsxs)(`span`,{className:`text-label-small-default text-blue-400`,children:[Math.round(p),`%`]})]}),(0,M.jsx)(`span`,{className:`w-7 shrink-0 text-right text-body-small-default text-[var(--content-faint)]`,children:d===null?`--`:`${d}°`}),(0,M.jsxs)(`div`,{className:`relative h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--border-subtle)]`,children:[(0,M.jsx)(`div`,{className:`absolute top-0 h-full rounded-full bg-[var(--primary-base)]`,style:{left:`${g}%`,width:`${v}%`}}),y!==null&&(0,M.jsx)(`div`,{className:`absolute top-1/2 h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-[var(--aux-white)] bg-[var(--aux-white)] shadow-sm`,style:{left:`${g+y/100*v}%`}})]}),(0,M.jsx)(`span`,{className:`w-7 shrink-0 text-right text-body-small-default text-[var(--content-default)]`,children:f===null?`--`:`${f}°`})]},e.id??c)})})})}function R({templateData:e,fallback:t}){let n=(0,y.useMemo)(()=>T(e),[e]),r=n?.unit?.toUpperCase()===`F`||n?.unit?.toLowerCase()===`fahrenheit`,[i,a]=(0,y.useState)(null),o=i??r;return!n||n.currentTemp===void 0&&!n.forecast?.length?t??null:(0,M.jsxs)(`div`,{className:`mt-3`,children:[(0,M.jsx)(F,{data:n,sourceIsFahrenheit:r,useFahrenheit:o,onToggle:a}),n.hourly&&n.hourly.length>0&&(0,M.jsx)(I,{hourly:n.hourly,sourceIsFahrenheit:r,useFahrenheit:o}),n.forecast&&n.forecast.length>0&&(0,M.jsx)(L,{forecast:n.forecast,currentTemp:n.currentTemp,sourceIsFahrenheit:r,useFahrenheit:o})]})}export{R as WeatherForecastDisplay};
@@ -1 +1 @@
1
- import{t as e}from"./button-D-AX8Voo.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{l as r}from"./local-mode-CgrENuVf.js";import{a as i}from"./routes-C6gxiCrz.js";import{t as a}from"./use-onboarding-login-Da1r3M06.js";import{rn as o}from"./index-CZ2UBc_U.js";var s=n();function c(){let n=t(),{loading:c,error:l,login:u,cancel:d}=a();return(0,s.jsx)(o,{children:(0,s.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center px-6 pb-40 text-[var(--content-default)]`,children:(0,s.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center`,children:[(0,s.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Welcome to Vellum`}),(0,s.jsx)(`p`,{className:`mt-3 text-body-medium-lighter text-[var(--content-tertiary)]`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Your own personal intelligence is just a step away.`}),l&&(0,s.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:l}),(0,s.jsxs)(`div`,{className:`mt-10 flex w-full max-w-sm flex-col gap-3`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,s.jsx)(e,{variant:`primary`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:c?d:()=>void u(),children:c?`Cancel`:`Log In`}),(0,s.jsx)(e,{variant:`ghost`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:()=>{c&&d(),r()?n(i.selectAssistant):n(i.onboarding.hosting)},children:`Continue without account`})]})]})})})}export{c as WelcomeScreen};
1
+ import{t as e}from"./button-D-AX8Voo.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{l as r}from"./local-mode-CgrENuVf.js";import{a as i}from"./routes-C6gxiCrz.js";import{t as a}from"./use-onboarding-login-Da1r3M06.js";import{rn as o}from"./index-B-S-gNKm.js";var s=n();function c(){let n=t(),{loading:c,error:l,login:u,cancel:d}=a();return(0,s.jsx)(o,{children:(0,s.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center px-6 pb-40 text-[var(--content-default)]`,children:(0,s.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center`,children:[(0,s.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Welcome to Vellum`}),(0,s.jsx)(`p`,{className:`mt-3 text-body-medium-lighter text-[var(--content-tertiary)]`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Your own personal intelligence is just a step away.`}),l&&(0,s.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:l}),(0,s.jsxs)(`div`,{className:`mt-10 flex w-full max-w-sm flex-col gap-3`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,s.jsx)(e,{variant:`primary`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:c?d:()=>void u(),children:c?`Cancel`:`Log In`}),(0,s.jsx)(e,{variant:`ghost`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:()=>{c&&d(),r()?n(i.selectAssistant):n(i.onboarding.hosting)},children:`Continue without account`})]})]})})})}export{c as WelcomeScreen};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-BscuIPxA.js";import"./src-SCpl1O1B.js";import{t as a}from"./arrow-left-CP-EhDNF.js";import{n as o,r as s,t as c}from"./metric-card-UcIagS0r.js";import{t as l}from"./ban-BpBuRCKI.js";import{t as u}from"./chevron-right-B6vEpVY0.js";import{t as d}from"./circle-check-DzlJxj_M.js";import{t as f}from"./triangle-alert-C3aHZq1F.js";import{t as p}from"./x-DxL-bCuT.js";import{n as m,r as h,t as g}from"./workflow-status-ByHycBJ_.js";import{t as _}from"./proxy-BgtfAoJj.js";import{t as v}from"./AnimatePresence-uY0BR2n2.js";import{t as y}from"./use-reduced-motion-BG6r0Z46.js";import{Pa as b,at as x,dt as S,ii as C,it as w,mi as T,nt as E,si as D}from"./index-CZ2UBc_U.js";import{t as O}from"./status-badge-pill-j3ke1d9o.js";var k=e(t(),1),A=r();function j({onClick:e,ariaLabel:t}){return(0,A.jsxs)(`button`,{type:`button`,"aria-label":t,onClick:e,className:`flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border border-[var(--system-negative-strong)] bg-transparent px-2.5 py-1.5 text-[var(--system-negative-strong)] transition-colors hover:bg-[var(--system-negative-weak)]`,children:[(0,A.jsx)(T,{className:`h-3 w-3`,fill:`currentColor`}),(0,A.jsx)(i,{variant:`label-small-default`,children:`Stop`})]})}function M({title:e,body:t,emptyText:n}){return(0,A.jsxs)(`div`,{className:`mb-5`,children:[(0,A.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`mb-2 text-[var(--content-emphasised)]`,children:e}),t?(0,A.jsx)(i,{variant:`body-medium-lighter`,as:`p`,className:`whitespace-pre-wrap break-words leading-relaxed text-[var(--content-default)]`,children:t}):(0,A.jsx)(i,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-tertiary)]`,children:n})]})}function N({leaf:e}){let t=e.status===`running`?`Running…`:`No result summary`;return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`mb-5 grid grid-cols-2 gap-3`,children:[(0,A.jsx)(c,{icon:(0,A.jsx)(b,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.inputTokens??0,format:e=>o(Math.round(e)),label:`Input`}),(0,A.jsx)(c,{icon:(0,A.jsx)(s,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.outputTokens??0,format:e=>o(Math.round(e)),label:`Output`})]}),(0,A.jsx)(M,{title:`Prompt`,body:e.promptSummary,emptyText:`No prompt summary`}),(0,A.jsx)(M,{title:`Result`,body:e.resultSummary,emptyText:t})]})}function P({status:e}){return(0,A.jsx)(O,{color:m(e),label:h(e)})}function F(e){switch(e){case`completed`:return`var(--system-positive-strong)`;case`failed`:return`var(--system-negative-strong)`;case`cancelled`:return`var(--content-secondary)`;default:return`var(--primary-base)`}}function I(e){switch(e){case`completed`:return`Completed`;case`failed`:return`Failed`;case`cancelled`:return`Cancelled`;default:return`Running`}}function L({status:e}){return(0,A.jsx)(O,{color:F(e),label:I(e)})}function R({status:e}){let t=y(),n=`h-3.5 w-3.5 shrink-0`,r;return r=e===`running`?(0,A.jsx)(S,{className:`shrink-0`,dotSize:4,gap:2}):e===`completed`?(0,A.jsx)(d,{className:n,style:{color:`var(--system-positive-strong)`}}):e===`failed`?(0,A.jsx)(f,{className:n,style:{color:`var(--system-negative-strong)`}}):(0,A.jsx)(l,{className:n,style:{color:`var(--content-secondary)`},role:`img`,"aria-label":`Cancelled`}),(0,A.jsx)(v,{mode:`wait`,initial:!1,children:(0,A.jsx)(_.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t?{duration:0}:{duration:.15,ease:[.16,1,.3,1]},className:`flex shrink-0 items-center`,children:r},e)})}function z({runId:e,leaf:t,components:n,onSelect:r}){let a=t.label??`Subagent ${t.seq}`,o=t.promptSummary,s=E(`${e}:${t.seq}`);return(0,A.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Open ${a} details`,className:`flex w-full cursor-pointer items-center justify-between gap-2 rounded-[6px] px-2 py-1.5 text-left transition-colors hover:bg-[var(--surface-overlay)]`,children:(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,A.jsx)(R,{status:t.status}),n?(0,A.jsx)(x,{components:n,bodyShapeId:s.bodyShape,eyeStyleId:s.eyeStyle,colorId:s.color,size:16}):(0,A.jsx)(`div`,{style:{width:16,height:16,flexShrink:0},"aria-hidden":!0}),(0,A.jsx)(i,{variant:`body-medium-default`,title:a,className:`max-w-[60%] shrink-0 truncate text-[var(--content-default)]`,children:a}),o&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-[var(--content-tertiary)] opacity-10`,children:`|`}),(0,A.jsx)(i,{variant:`body-medium-lighter`,title:o,className:`min-w-0 truncate text-[var(--content-tertiary)]`,children:o})]})]})})}function B({entry:e,onClose:t,onStop:r,onRequestJournal:l}){let d=g(e.status),f=y(),m=e.label??e.runId,h=e.agentsSpawned||e.leaves.size,v=w(),S=[...e.leaves.values()].sort((e,t)=>e.seq-t.seq),[T,O]=(0,k.useState)(null),[M,F]=(0,k.useState)(e.runId);M!==e.runId&&(F(e.runId),O(null));let I=T==null?void 0:e.leaves.get(T),R=I?E(`${e.runId}:${I.seq}`):void 0,B=(0,k.useCallback)(()=>O(null),[]),V=I?I.label??`Subagent ${I.seq}`:``,H=I?V:m,U=d?`live`:`final`;return(0,k.useEffect)(()=>{l?.(e.runId)},[e.runId,U,l]),(0,A.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden rounded-xl bg-[var(--surface-lift)]`,children:[I&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-hover)] px-5 py-3`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:B,title:m,className:`min-w-0 shrink cursor-pointer truncate text-left text-[var(--content-default)] hover:underline`,children:(0,A.jsx)(i,{variant:`body-small-default`,as:`span`,children:m})}),(0,A.jsx)(u,{className:`h-2.5 w-2.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,A.jsx)(i,{variant:`body-small-default`,as:`span`,title:V,className:`min-w-0 shrink truncate text-[var(--content-secondary)]`,children:V})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-hover)] px-5 py-4`,children:[I&&(0,A.jsx)(n,{variant:`outlined`,iconOnly:(0,A.jsx)(a,{}),onClick:B,"aria-label":`Back to subagents`,tooltip:`Back`,className:`shrink-0 rounded-lg`}),I?v&&R?(0,A.jsx)(x,{components:v,bodyShapeId:R.bodyShape,eyeStyleId:R.eyeStyle,colorId:R.color,size:32}):(0,A.jsx)(`div`,{style:{width:32,height:32,flexShrink:0},"aria-hidden":!0}):(0,A.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-[6px] bg-[var(--surface-overlay)]`,children:(0,A.jsx)(C,{className:`h-4 w-4`,style:{color:`var(--content-secondary)`}})}),(0,A.jsx)(i,{variant:`title-medium`,title:H,className:`min-w-0 shrink truncate text-[var(--content-default)]`,children:H}),I?(0,A.jsx)(L,{status:I.status}):(0,A.jsx)(P,{status:e.status}),(0,A.jsx)(`span`,{className:`flex-1`}),d&&r&&(0,A.jsx)(j,{onClick:()=>r(e.runId),ariaLabel:`Stop workflow`}),(0,A.jsx)(n,{variant:`outlined`,iconOnly:(0,A.jsx)(p,{}),onClick:t,"aria-label":`Close workflow detail`,tooltip:`Close`,className:`shrink-0 rounded-lg`})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-5`,children:(0,A.jsx)(_.div,{initial:{opacity:0},animate:{opacity:1},transition:f?{duration:0}:{duration:.18,ease:[.16,1,.3,1]},children:I?(0,A.jsx)(N,{leaf:I}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`mb-5 grid grid-cols-3 gap-3`,children:[(0,A.jsx)(c,{icon:(0,A.jsx)(b,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.inputTokens,format:e=>o(Math.round(e)),label:`Input`}),(0,A.jsx)(c,{icon:(0,A.jsx)(s,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.outputTokens,format:e=>o(Math.round(e)),label:`Output`}),(0,A.jsx)(c,{icon:(0,A.jsx)(D,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:h,format:e=>o(Math.round(e)),label:`Agents`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`mb-4 text-[var(--content-emphasised)]`,children:`Subagents`}),S.length===0?(0,A.jsx)(i,{variant:`body-small-default`,className:`py-4 text-center text-[var(--content-tertiary)]`,children:`No subagents yet`}):(0,A.jsx)(`div`,{className:`flex flex-col gap-1`,children:S.map(t=>(0,A.jsx)(z,{runId:e.runId,leaf:t,components:v,onSelect:()=>O(t.seq)},t.seq))})]})]})},I?String(I.seq):`list`)})]})}export{B as WorkflowDetailPanel};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-BscuIPxA.js";import"./src-SCpl1O1B.js";import{t as a}from"./arrow-left-CP-EhDNF.js";import{n as o,r as s,t as c}from"./metric-card-UcIagS0r.js";import{t as l}from"./ban-BpBuRCKI.js";import{t as u}from"./chevron-right-B6vEpVY0.js";import{t as d}from"./circle-check-DzlJxj_M.js";import{t as f}from"./triangle-alert-C3aHZq1F.js";import{t as p}from"./x-DxL-bCuT.js";import{n as m,r as h,t as g}from"./workflow-status-ByHycBJ_.js";import{t as _}from"./proxy-BgtfAoJj.js";import{t as v}from"./AnimatePresence-uY0BR2n2.js";import{t as y}from"./use-reduced-motion-BG6r0Z46.js";import{Pa as b,at as x,dt as S,ii as C,it as w,mi as T,nt as E,si as D}from"./index-B-S-gNKm.js";import{t as O}from"./status-badge-pill-j3ke1d9o.js";var k=e(t(),1),A=r();function j({onClick:e,ariaLabel:t}){return(0,A.jsxs)(`button`,{type:`button`,"aria-label":t,onClick:e,className:`flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border border-[var(--system-negative-strong)] bg-transparent px-2.5 py-1.5 text-[var(--system-negative-strong)] transition-colors hover:bg-[var(--system-negative-weak)]`,children:[(0,A.jsx)(T,{className:`h-3 w-3`,fill:`currentColor`}),(0,A.jsx)(i,{variant:`label-small-default`,children:`Stop`})]})}function M({title:e,body:t,emptyText:n}){return(0,A.jsxs)(`div`,{className:`mb-5`,children:[(0,A.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`mb-2 text-[var(--content-emphasised)]`,children:e}),t?(0,A.jsx)(i,{variant:`body-medium-lighter`,as:`p`,className:`whitespace-pre-wrap break-words leading-relaxed text-[var(--content-default)]`,children:t}):(0,A.jsx)(i,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-tertiary)]`,children:n})]})}function N({leaf:e}){let t=e.status===`running`?`Running…`:`No result summary`;return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`mb-5 grid grid-cols-2 gap-3`,children:[(0,A.jsx)(c,{icon:(0,A.jsx)(b,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.inputTokens??0,format:e=>o(Math.round(e)),label:`Input`}),(0,A.jsx)(c,{icon:(0,A.jsx)(s,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.outputTokens??0,format:e=>o(Math.round(e)),label:`Output`})]}),(0,A.jsx)(M,{title:`Prompt`,body:e.promptSummary,emptyText:`No prompt summary`}),(0,A.jsx)(M,{title:`Result`,body:e.resultSummary,emptyText:t})]})}function P({status:e}){return(0,A.jsx)(O,{color:m(e),label:h(e)})}function F(e){switch(e){case`completed`:return`var(--system-positive-strong)`;case`failed`:return`var(--system-negative-strong)`;case`cancelled`:return`var(--content-secondary)`;default:return`var(--primary-base)`}}function I(e){switch(e){case`completed`:return`Completed`;case`failed`:return`Failed`;case`cancelled`:return`Cancelled`;default:return`Running`}}function L({status:e}){return(0,A.jsx)(O,{color:F(e),label:I(e)})}function R({status:e}){let t=y(),n=`h-3.5 w-3.5 shrink-0`,r;return r=e===`running`?(0,A.jsx)(S,{className:`shrink-0`,dotSize:4,gap:2}):e===`completed`?(0,A.jsx)(d,{className:n,style:{color:`var(--system-positive-strong)`}}):e===`failed`?(0,A.jsx)(f,{className:n,style:{color:`var(--system-negative-strong)`}}):(0,A.jsx)(l,{className:n,style:{color:`var(--content-secondary)`},role:`img`,"aria-label":`Cancelled`}),(0,A.jsx)(v,{mode:`wait`,initial:!1,children:(0,A.jsx)(_.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t?{duration:0}:{duration:.15,ease:[.16,1,.3,1]},className:`flex shrink-0 items-center`,children:r},e)})}function z({runId:e,leaf:t,components:n,onSelect:r}){let a=t.label??`Subagent ${t.seq}`,o=t.promptSummary,s=E(`${e}:${t.seq}`);return(0,A.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Open ${a} details`,className:`flex w-full cursor-pointer items-center justify-between gap-2 rounded-[6px] px-2 py-1.5 text-left transition-colors hover:bg-[var(--surface-overlay)]`,children:(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,A.jsx)(R,{status:t.status}),n?(0,A.jsx)(x,{components:n,bodyShapeId:s.bodyShape,eyeStyleId:s.eyeStyle,colorId:s.color,size:16}):(0,A.jsx)(`div`,{style:{width:16,height:16,flexShrink:0},"aria-hidden":!0}),(0,A.jsx)(i,{variant:`body-medium-default`,title:a,className:`max-w-[60%] shrink-0 truncate text-[var(--content-default)]`,children:a}),o&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-[var(--content-tertiary)] opacity-10`,children:`|`}),(0,A.jsx)(i,{variant:`body-medium-lighter`,title:o,className:`min-w-0 truncate text-[var(--content-tertiary)]`,children:o})]})]})})}function B({entry:e,onClose:t,onStop:r,onRequestJournal:l}){let d=g(e.status),f=y(),m=e.label??e.runId,h=e.agentsSpawned||e.leaves.size,v=w(),S=[...e.leaves.values()].sort((e,t)=>e.seq-t.seq),[T,O]=(0,k.useState)(null),[M,F]=(0,k.useState)(e.runId);M!==e.runId&&(F(e.runId),O(null));let I=T==null?void 0:e.leaves.get(T),R=I?E(`${e.runId}:${I.seq}`):void 0,B=(0,k.useCallback)(()=>O(null),[]),V=I?I.label??`Subagent ${I.seq}`:``,H=I?V:m,U=d?`live`:`final`;return(0,k.useEffect)(()=>{l?.(e.runId)},[e.runId,U,l]),(0,A.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden rounded-xl bg-[var(--surface-lift)]`,children:[I&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-hover)] px-5 py-3`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:B,title:m,className:`min-w-0 shrink cursor-pointer truncate text-left text-[var(--content-default)] hover:underline`,children:(0,A.jsx)(i,{variant:`body-small-default`,as:`span`,children:m})}),(0,A.jsx)(u,{className:`h-2.5 w-2.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,A.jsx)(i,{variant:`body-small-default`,as:`span`,title:V,className:`min-w-0 shrink truncate text-[var(--content-secondary)]`,children:V})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-hover)] px-5 py-4`,children:[I&&(0,A.jsx)(n,{variant:`outlined`,iconOnly:(0,A.jsx)(a,{}),onClick:B,"aria-label":`Back to subagents`,tooltip:`Back`,className:`shrink-0 rounded-lg`}),I?v&&R?(0,A.jsx)(x,{components:v,bodyShapeId:R.bodyShape,eyeStyleId:R.eyeStyle,colorId:R.color,size:32}):(0,A.jsx)(`div`,{style:{width:32,height:32,flexShrink:0},"aria-hidden":!0}):(0,A.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-[6px] bg-[var(--surface-overlay)]`,children:(0,A.jsx)(C,{className:`h-4 w-4`,style:{color:`var(--content-secondary)`}})}),(0,A.jsx)(i,{variant:`title-medium`,title:H,className:`min-w-0 shrink truncate text-[var(--content-default)]`,children:H}),I?(0,A.jsx)(L,{status:I.status}):(0,A.jsx)(P,{status:e.status}),(0,A.jsx)(`span`,{className:`flex-1`}),d&&r&&(0,A.jsx)(j,{onClick:()=>r(e.runId),ariaLabel:`Stop workflow`}),(0,A.jsx)(n,{variant:`outlined`,iconOnly:(0,A.jsx)(p,{}),onClick:t,"aria-label":`Close workflow detail`,tooltip:`Close`,className:`shrink-0 rounded-lg`})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-5`,children:(0,A.jsx)(_.div,{initial:{opacity:0},animate:{opacity:1},transition:f?{duration:0}:{duration:.18,ease:[.16,1,.3,1]},children:I?(0,A.jsx)(N,{leaf:I}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`mb-5 grid grid-cols-3 gap-3`,children:[(0,A.jsx)(c,{icon:(0,A.jsx)(b,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.inputTokens,format:e=>o(Math.round(e)),label:`Input`}),(0,A.jsx)(c,{icon:(0,A.jsx)(s,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.outputTokens,format:e=>o(Math.round(e)),label:`Output`}),(0,A.jsx)(c,{icon:(0,A.jsx)(D,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:h,format:e=>o(Math.round(e)),label:`Agents`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`mb-4 text-[var(--content-emphasised)]`,children:`Subagents`}),S.length===0?(0,A.jsx)(i,{variant:`body-small-default`,className:`py-4 text-center text-[var(--content-tertiary)]`,children:`No subagents yet`}):(0,A.jsx)(`div`,{className:`flex flex-col gap-1`,children:S.map(t=>(0,A.jsx)(z,{runId:e.runId,leaf:t,components:v,onSelect:()=>O(t.seq)},t.seq))})]})]})},I?String(I.seq):`list`)})]})}export{B as WorkflowDetailPanel};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{h as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./queryOptions-BtNi-_9H.js";import{n as l,t as u}from"./panel-item-Q1g7DFJw.js";import{t as d}from"./menu-BLJEjTFD.js";import{a as f}from"./src-SCpl1O1B.js";import{t as p}from"./confirm-dialog-bfBx6UYv.js";import{t as m}from"./input-D4W4p0pZ.js";import{t as h}from"./modal-BNAVT2FK.js";import{t as g}from"./createLucideIcon-BlMXrA59.js";import{t as _}from"./chevron-right-B6vEpVY0.js";import{t as v}from"./file-text-ClqzuFsu.js";import{t as y}from"./loader-circle-BFRVtR3K.js";import{t as b}from"./pencil-B90pDI55.js";import{t as x}from"./x-DxL-bCuT.js";import{Cr as S,Sr as C,_r as w,br as T,vr as E,xr as D,yr as O}from"./sdk.gen-zA5ns5LT.js";import{n as k}from"./use-is-mobile-jACt_z2d.js";import{n as A}from"./native-file-DIJL6af-.js";import{L as j,Oa as M,Qi as N,R as P,Si as F,ia as I,ki as L,na as R,oa as ee,oi as z,ra as B,sa as te,ua as V,ui as ne}from"./index-CZ2UBc_U.js";import{t as H}from"./use-active-assistant-id-BVzVN4_g.js";import{n as U,t as W}from"./mobile-sidebar-drawer-CzcwUqpn.js";import{i as G,n as re,r as K,t as q}from"./file-editor-sKfnpW-D.js";import{t as J}from"./format-file-size-BflZ4oxc.js";var ie=g(`arrow-down-a-z`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M20 8h-5`,key:`1vsyxs`}],[`path`,{d:`M15 10V6.5a2.5 2.5 0 0 1 5 0V10`,key:`ag13bf`}],[`path`,{d:`M15 14h5l-5 6h5`,key:`ur5jdg`}]]),ae=g(`arrow-down-wide-narrow`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h10`,key:`1w87gc`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}]]),oe=g(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Y=g(`folder-plus`,[[`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`}]]),X=e(t(),1);async function se(e){let{data:t,error:n}=await E({path:{assistant_id:e.assistantId},query:{path:e.path,...e.showHidden?{showHidden:`true`}:{}},parseAs:`blob`,throwOnError:!1});if(n||!(t instanceof Blob))throw Error(`Failed to download file`);await A(t,e.filename)}function ce(e){if(!e)return``;let t=e.indexOf(`;`);return(t===-1?e:e.slice(0,t)).trim()}function le(e,t){return ce(t)===`application/json`?!0:(e??``).toLowerCase().endsWith(`.json`)}function ue(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Z(e){return e.split(`/`).some(e=>e.startsWith(`.`))}var Q=s();function de(e){return c({queryFn:async()=>{let{data:t,error:n}=await O({path:e.path,query:{path:e.query.path,...e.query.showHidden?{showHidden:`true`}:{}}});if(n)throw n;return t},queryKey:[`assistantsWorkspaceFileRetrieve`,e]})}function fe({mimeType:e}){let t=e.indexOf(`;`),n=(t===-1?e:e.slice(0,t)).trim(),r=v;return n.startsWith(`image/`)?r=N:n.startsWith(`video/`)?r=z:!n.startsWith(`text/`)&&n!==`application/json`&&n!==`application/octet-stream`&&(r=B),(0,Q.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 10%, transparent)`},children:(0,Q.jsx)(r,{className:`h-3.5 w-3.5`,style:{color:`var(--content-default)`}})})}function pe({viewMode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`inline-flex rounded-md p-0.5`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`},children:[`preview`,`source`].map(r=>{let i=e===r;return(0,Q.jsx)(n,{variant:`ghost`,onClick:()=>t(r),className:`h-auto rounded border-0 px-2.5 py-1 text-body-small-default hover:bg-transparent`,style:{backgroundColor:i?`var(--surface-lift)`:`transparent`,color:i?`var(--content-default)`:`var(--content-tertiary)`,boxShadow:i?`0 1px 2px rgba(0,0,0,0.15)`:void 0},children:r===`preview`?`Preview`:`Source`},r)})})}function $({name:e,mimeType:t,size:n,rightContent:r}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(fe,{mimeType:t}),(0,Q.jsx)(`span`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),n!=null&&(0,Q.jsx)(`span`,{className:`shrink-0 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:J(n)})]}),r]})}function me({assistantId:e,path:t,mimeType:n,showHidden:r}){let{data:i,isLoading:o}=a({queryFn:async()=>{let n=await E({path:{assistant_id:e},query:{path:t,...r?{showHidden:`true`}:{}},parseAs:`blob`});if(n.error)throw n.error;return n.data},queryKey:[`assistantsWorkspaceFileContentRetrieve`,{assistantId:e,path:t,showHidden:r}],enabled:!!t}),[s,c]=(0,X.useState)(null);return(0,X.useEffect)(()=>{if(!i)return;let e=URL.createObjectURL(i);return c(e),()=>{URL.revokeObjectURL(e),c(null)}},[i]),o?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(y,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):s?n.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Q.jsx)(`img`,{src:s,alt:t.split(`/`).pop()??`image`,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n.startsWith(`video/`)?(0,Q.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Q.jsx)(`video`,{src:s,controls:!0,className:`max-h-[70vh] max-w-full rounded`})}):null:null}function he({assistantId:e,path:t,name:r,mimeType:i,size:a,modifiedAt:o,showHidden:s}){let[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),f=(0,X.useCallback)(async()=>{d(!1),l(!0);try{await se({assistantId:e,path:t,filename:r,showHidden:s})}catch{d(!0)}finally{l(!1)}},[e,t,r,s]);return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:r,mimeType:i,size:a}),(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,Q.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border p-6 text-center`,style:{borderColor:`var(--border-base)`,backgroundColor:`var(--surface-lift)`},children:[(0,Q.jsx)(B,{className:`mx-auto h-10 w-10`,style:{color:`var(--content-tertiary)`}}),(0,Q.jsx)(`p`,{className:`mt-3 text-body-medium-default`,style:{color:`var(--content-default)`},children:r}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:i}),(0,Q.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:J(a,`Unknown size`)}),o&&(0,Q.jsxs)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:[`Modified: `,new Date(o).toLocaleString()]})]}),(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:c?(0,Q.jsx)(y,{className:`animate-spin`,"aria-hidden":!0}):(0,Q.jsx)(V,{"aria-hidden":!0}),onClick:f,disabled:c,"aria-label":`Download ${r}`,className:`mt-4`,children:c?`Downloading…`:`Download`}),u&&(0,Q.jsx)(`p`,{className:`mt-2 text-body-small-default`,style:{color:`var(--system-error)`},children:`Download failed. Try again.`})]})})]})}function ge({assistantId:e,selectedPath:t,showHidden:r,viewMode:s,onChangeViewMode:c,onBrowse:l,pathRename:u,pathDelete:d}){let f=i(),{data:p,isLoading:m}=a({...de({path:{assistant_id:e},query:{path:t??``,showHidden:r}}),enabled:!!t}),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null);(0,X.useEffect)(()=>{if(!u)return;let{from:e,to:t}=u,n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;g(e=>e==null?e:n(e)),v(e=>e==null?e:{...e,path:n(e.path)})},[u]),(0,X.useEffect)(()=>{if(!d)return;let{path:e}=d,t=t=>t===e||t.startsWith(`${e}/`);g(e=>e!=null&&t(e)?null:e),v(e=>e!=null&&t(e.path)?null:e)},[d]);let b=h!=null&&h===t,x=p?.content??``,C=_?.path===t?_.content:x,w=()=>{g(null),v(null)},T=o({mutationFn:async({path:t,content:n})=>{let{error:r,response:i}=await S({path:{assistant_id:e},body:{path:t,content:n,encoding:`utf8`},throwOnError:!1});if(!i?.ok||r)throw Error(`Failed to save file`)},onSuccess:(e,t)=>{g(e=>e===t.path?null:e),v(e=>e?.path===t.path?null:e),f.invalidateQueries({queryKey:[`assistantsWorkspaceFileRetrieve`]})}}),E=C!==x,D=(0,X.useCallback)(()=>{t&&E&&!T.isPending&&T.mutate({path:t,content:C})},[t,E,T,C]);if(!t)return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view`}),l&&(0,Q.jsx)(n,{type:`button`,onClick:l,leftIcon:(0,Q.jsx)(oe,{"aria-hidden":!0}),className:`sm:hidden`,children:`Browse files`})]});if(m)return(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(y,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})});if(!p)return(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`File not found`})});let O=p.mimeType??`application/octet-stream`,k=p.name??t.split(`/`).pop()??t,A=P(k,O),M=le(k,O),N=p.content!=null&&!A&&!M,F=t?Z(t):!0,I=b&&(0,Q.jsx)(re,{isDirty:E,isSaving:T.isPending,error:T.isError?`Save failed`:null,onSave:D,onDiscard:w});if(A&&p.content!=null){let e=b?C:p.content;return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:k,mimeType:O,rightContent:(0,Q.jsx)(pe,{viewMode:s,onChange:e=>{b&&w(),c(e)}})}),(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Q.jsx)(q,{content:e,fileName:k,mimeType:O,showEdit:!F&&s===`source`,isEditing:b,onToggleEdit:()=>b?w():g(t)}),s===`preview`?(0,Q.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Q.jsx)(j,{content:e})}):b?(0,Q.jsx)(K,{value:C,onChange:e=>v({path:t,content:e}),onSave:D}):(0,Q.jsx)(G,{content:p.content,readOnly:F,onStartEdit:()=>g(t)})]}),I]})}if(M&&p.content!=null){let e=b?C:p.content,n=ue(e);return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:k,mimeType:O,rightContent:(0,Q.jsx)(pe,{viewMode:s,onChange:e=>{b&&w(),c(e)}})}),(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Q.jsx)(q,{content:s===`preview`?n:e,downloadContent:e,fileName:k,mimeType:O,showEdit:!F&&s===`source`,isEditing:b,onToggleEdit:()=>b?w():g(t)}),s===`preview`?(0,Q.jsx)(G,{content:n,readOnly:!0,whiteSpace:`pre`}):b?(0,Q.jsx)(K,{value:C,onChange:e=>v({path:t,content:e}),onSave:D}):(0,Q.jsx)(G,{content:p.content,readOnly:F,onStartEdit:()=>g(t)})]}),I]})}return N?(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:k,mimeType:O,size:p.size}),(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Q.jsx)(q,{content:b?C:p.content??``,fileName:k,mimeType:O,showEdit:!F,isEditing:b,onToggleEdit:()=>b?w():g(t)}),b?(0,Q.jsx)(K,{value:C,onChange:e=>v({path:t,content:e}),onSave:D}):(0,Q.jsx)(G,{content:p.content??``,readOnly:F,onStartEdit:()=>g(t)})]}),I]}):O.startsWith(`image/`)||O.startsWith(`video/`)?(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:k,mimeType:O,size:p.size}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Q.jsx)(me,{assistantId:e,path:t,mimeType:O,showHidden:r})})]}):(0,Q.jsx)(he,{assistantId:e,path:t,name:k,mimeType:O,size:p.size,modifiedAt:p.modifiedAt,showHidden:r})}function _e(e,t){if(t===`name`)return e;let n=e.slice();return n.sort((e,t)=>{let n=e.size??null,r=t.size??null;return n===null&&r===null?(e.name??``).localeCompare(t.name??``):n===null?1:r===null?-1:n===r?(e.name??``).localeCompare(t.name??``):r-n}),n}function ve(e){return c({queryFn:async()=>{let t={};e.query?.path&&(t.path=e.query.path),e.query?.showHidden&&(t.showHidden=`true`),e.query?.includeDirSizes&&(t.includeDirSizes=`true`);let{data:n,error:r}=await C({path:e.path,query:t});if(r)throw r;if(!n)throw Error(`Failed to load workspace tree`);return n},queryKey:[`assistantsWorkspaceTreeRetrieve`,e]})}async function ye(e,t,n,r){let i=n.toLowerCase(),a=r?.toLowerCase(),{data:o}=await C({path:{assistant_id:e},query:t?{path:t}:{}});if(o?.entries?.some(e=>{let t=(e.name??``).toLowerCase();return t===i&&t!==a}))throw Error(`"${n}" already exists here.`)}function be({entry:e}){return e.type===`directory`?(0,Q.jsx)(R,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`image/`)?(0,Q.jsx)(N,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`video/`)?(0,Q.jsx)(z,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Q.jsx)(v,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}})}function xe({entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:u,onRequestRename:d,onRequestCreate:p,depth:m}){let h=e.path??``,g=e.name??``,v=e.type===`directory`,y=n.has(h),x=r===h,S=g.startsWith(`.`),C=!Z(h),w=v&&(y||s.length>0),{data:T}=a({...ve({path:{assistant_id:t},query:{path:h,showHidden:i,includeDirSizes:o===`size`}}),enabled:v&&w}),E=(0,X.useMemo)(()=>_e(T?.entries??[],o),[T?.entries,o]),D=s===``||g.toLowerCase().includes(s);if(s!==``&&!v&&!D)return null;let O=(0,Q.jsxs)(`button`,{onClick:()=>{v?c(h):l(h)},className:`flex w-full items-center gap-1.5 px-2 py-1 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{paddingLeft:`${m*14+8}px`,paddingRight:`8px`,color:x?`var(--content-default)`:S?`var(--content-tertiary)`:`var(--content-default)`,backgroundColor:x?`color-mix(in oklab, var(--primary-base) 12%, transparent)`:void 0,opacity:S&&!x?.7:1},children:[v?w?(0,Q.jsx)(M,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Q.jsx)(_,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Q.jsx)(`span`,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(be,{entry:e}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g}),e.size!=null&&(0,Q.jsx)(`span`,{className:`shrink-0 text-label-medium-default tabular-nums`,style:{color:`var(--content-tertiary)`},children:J(e.size)})]});return(0,Q.jsxs)(`div`,{children:[C?(0,Q.jsxs)(f.Root,{children:[(0,Q.jsx)(f.Trigger,{children:O}),(0,Q.jsxs)(f.Content,{children:[v&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(f.Item,{leftIcon:(0,Q.jsx)(I,{className:`h-3.5 w-3.5`}),onSelect:()=>p({kind:`file`,parentPath:h}),children:`New File`}),(0,Q.jsx)(f.Item,{leftIcon:(0,Q.jsx)(Y,{className:`h-3.5 w-3.5`}),onSelect:()=>p({kind:`folder`,parentPath:h}),children:`New Folder`}),(0,Q.jsx)(f.Separator,{})]}),(0,Q.jsx)(f.Item,{leftIcon:(0,Q.jsx)(ne,{className:`h-3.5 w-3.5`}),onSelect:()=>u({path:h,name:g,isDirectory:v}),children:`Delete`}),(0,Q.jsx)(f.Item,{leftIcon:(0,Q.jsx)(b,{className:`h-3.5 w-3.5`}),onSelect:()=>d({path:h,name:g,isDirectory:v}),children:`Rename`})]})]}):O,v&&w&&E.length>0&&(0,Q.jsx)(`div`,{children:E.map(e=>(0,Q.jsx)(xe,{entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:u,onRequestRename:d,onRequestCreate:p,depth:m+1},e.path))})]})}function Se({title:e,placeholder:t,confirmLabel:r,pendingLabel:i,initialName:a,onCancel:o,onConfirm:s,pending:c,error:l}){let u=(0,X.useRef)(null),[d,f]=(0,X.useState)(a??``),p=d.trim(),g=p.length>0&&(/[/\\]/.test(p)||p===`.`||p===`..`),_=p.length>0&&!g&&!c;return(0,Q.jsx)(h.Root,{open:!0,onOpenChange:e=>{!e&&!c&&o()},children:(0,Q.jsx)(h.Content,{size:`sm`,hideCloseButton:!0,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault();let t=u.current;t&&(t.focus(),requestAnimationFrame(()=>{t.setSelectionRange(0,t.value.length)}))},onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),c||o()},children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_&&s(p)},children:[(0,Q.jsx)(h.Header,{children:(0,Q.jsx)(h.Title,{children:e})}),(0,Q.jsx)(h.Body,{children:(0,Q.jsx)(m,{ref:u,label:`Name`,value:d,onChange:e=>f(e.target.value),placeholder:t,errorText:l??(g?`Enter a single file or folder name without slashes.`:void 0),autoComplete:`off`,spellCheck:!1,fullWidth:!0})}),(0,Q.jsxs)(h.Footer,{children:[(0,Q.jsx)(n,{type:`button`,variant:`outlined`,onClick:o,disabled:c,children:`Cancel`}),(0,Q.jsx)(n,{type:`submit`,variant:`primary`,disabled:!_,children:c?i:r})]})]})})})}function Ce({assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,onToggleExpand:l,onExpandPath:u,onSelectPath:d,onToggleShowHidden:f,onChangeSortMode:h,onPathDeleted:g,onPathRenamed:_}){let v=i(),[y,b]=(0,X.useState)(``),C=y.trim().toLowerCase(),[E,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),N=(0,X.useCallback)(()=>{A(null),M(null)},[]),{data:P,isLoading:I}=a(ve({path:{assistant_id:e},query:{showHidden:s,includeDirSizes:c===`size`}})),L=(0,X.useMemo)(()=>_e(P?.entries??[],c),[P?.entries,c]),R=(0,X.useCallback)(()=>{for(let e of[`assistantsWorkspaceTreeRetrieve`,`assistantsWorkspaceFileRetrieve`,`assistantsWorkspaceFileContentRetrieve`])v.invalidateQueries({queryKey:[e]})},[v]),z=o({mutationFn:async t=>{let n=t.parentPath?`${t.parentPath}/${t.name}`:t.name;await ye(e,t.parentPath,t.name);let{error:r,response:i}=t.kind===`file`?await S({path:{assistant_id:e},body:{path:n,content:``,encoding:`utf8`},throwOnError:!1}):await T({path:{assistant_id:e},body:{path:n},throwOnError:!1});if(r||!i?.ok)throw Error(typeof r==`string`?r:`Failed to create — check the name and try again.`);return{...t,path:n}},onSuccess:e=>{N(),R(),e.parentPath&&u(e.parentPath),e.kind===`file`?d(e.path):u(e.path)},onError:e=>{M(e instanceof Error?e.message:`Failed to create.`)}}),B=o({mutationFn:async t=>{let n=t.oldPath.lastIndexOf(`/`),r=n===-1?``:t.oldPath.slice(0,n),i=t.oldPath.slice(n+1),a=r?`${r}/${t.newName}`:t.newName;await ye(e,r,t.newName,i);let{error:o,response:s}=await D({path:{assistant_id:e},body:{oldPath:t.oldPath,newPath:a},throwOnError:!1});if(o||!s?.ok)throw Error(typeof o==`string`?o:`Failed to rename — check the name and try again.`);return{oldPath:t.oldPath,newPath:a}},onSuccess:({oldPath:e,newPath:t})=>{N(),R(),_(e,t)},onError:e=>{M(e instanceof Error?e.message:`Failed to rename.`)}}),V=(0,X.useCallback)(e=>{M(null),A({type:`create`,...e})},[]),ne=(0,X.useCallback)(e=>{M(null),A({type:`rename`,path:e.path,name:e.name})},[]),[H,U]=(0,X.useState)(null),W=o({mutationFn:async t=>{let{error:n,response:r}=await w({path:{assistant_id:e},body:{path:t.path},throwOnError:!1});if(n||!r?.ok)throw Error(typeof n==`string`?n:`Failed to delete — try again.`);return t},onSuccess:e=>{U(null),R(),g(e.path)}}),G=(0,X.useCallback)(e=>{W.reset(),U(e)},[W]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:`Files`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:c===`size`?(0,Q.jsx)(ae,{"aria-hidden":!0}):(0,Q.jsx)(ie,{"aria-hidden":!0}),onClick:()=>h(c===`size`?`name`:`size`),"aria-label":c===`size`?`Sort by name`:`Sort by size`,title:c===`size`?`Sorted by size — switch to name`:`Sorted by name — switch to size`,tintColor:c===`size`?`var(--content-default)`:`var(--content-tertiary)`}),(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:s?(0,Q.jsx)(ee,{"aria-hidden":!0}):(0,Q.jsx)(te,{"aria-hidden":!0}),onClick:f,"aria-label":s?`Hide hidden files`:`Show hidden files`,title:s?`Hide hidden files`:`Show hidden files`,tintColor:s?`var(--content-default)`:`var(--content-tertiary)`}),(0,Q.jsx)(we,{open:E,onOpenChange:O,onSelectKind:e=>{O(!1),V({kind:e,parentPath:``})}})]})]}),(0,Q.jsx)(`div`,{className:`px-3 py-2`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(m,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Search files`,leftIcon:(0,Q.jsx)(F,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0,spellCheck:!1,autoComplete:`off`}),y&&(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(x,{"aria-hidden":!0}),onClick:()=>b(``),"aria-label":`Clear search`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,tintColor:`var(--content-tertiary)`})]})}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:I?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`,style:{color:`var(--content-tertiary)`}})}):L.length?L.map(n=>(0,Q.jsx)(xe,{entry:n,assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,searchLower:C,onToggleExpand:l,onSelectPath:d,onRequestDelete:G,onRequestRename:ne,onRequestCreate:V,depth:0},n.path)):(0,Q.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files found`})}),k?.type===`create`&&(0,Q.jsx)(Se,{title:k.kind===`file`?`New File`:`New Folder`,placeholder:k.kind===`file`?`filename.md`:`folder-name`,confirmLabel:`Create`,pendingLabel:`Creating…`,onCancel:N,onConfirm:e=>{M(null),z.mutate({kind:k.kind,parentPath:k.parentPath,name:e})},pending:z.isPending,error:j},`create-${k.kind}-${k.parentPath}`),k?.type===`rename`&&(0,Q.jsx)(Se,{title:`Rename`,placeholder:k.name,confirmLabel:`Rename`,pendingLabel:`Renaming…`,initialName:k.name,onCancel:N,onConfirm:e=>{if(e===k.name){N();return}M(null),B.mutate({oldPath:k.path,newName:e})},pending:B.isPending,error:j},`rename-${k.path}`),(0,Q.jsx)(p,{open:H!==null,title:H?.isDirectory?`Delete Folder`:`Delete File`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to delete`,` `,(0,Q.jsx)(`span`,{style:{color:`var(--content-default)`},children:H?.name}),H?.isDirectory?` and all of its contents`:``,`? This cannot be undone.`,W.error&&(0,Q.jsx)(`span`,{className:`mt-2 block`,style:{color:`var(--system-negative-strong)`},children:W.error.message})]}),confirmLabel:W.isPending?`Deleting…`:`Delete`,destructive:!0,isPending:W.isPending,onConfirm:()=>{H&&W.mutate(H)},onCancel:()=>U(null)})]})}function we({open:e,onOpenChange:t,onSelectKind:r}){return k()?(0,Q.jsxs)(l.Root,{open:e,onOpenChange:t,children:[(0,Q.jsx)(l.Trigger,{asChild:!0,children:(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(L,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Q.jsxs)(l.Content,{children:[(0,Q.jsx)(l.Header,{className:`sr-only`,children:(0,Q.jsx)(l.Title,{children:`Create new`})}),(0,Q.jsxs)(l.Body,{className:`pt-0`,children:[(0,Q.jsx)(u,{icon:I,label:`New File`,onSelect:()=>r(`file`)}),(0,Q.jsx)(u,{icon:Y,label:`New Folder`,onSelect:()=>r(`folder`)})]})]})]}):(0,Q.jsxs)(d.Root,{open:e,onOpenChange:t,children:[(0,Q.jsx)(d.Trigger,{asChild:!0,children:(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(L,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Q.jsxs)(d.Content,{align:`end`,sideOffset:4,children:[(0,Q.jsx)(d.Item,{leftIcon:(0,Q.jsx)(I,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`file`),children:`New File`}),(0,Q.jsx)(d.Item,{leftIcon:(0,Q.jsx)(Y,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`folder`),children:`New Folder`})]})]})}function Te(e){let t=e.split(`/`),n=new Set;for(let e=1;e<t.length;e++)n.add(t.slice(0,e).join(`/`));return n}function Ee({assistantId:e}){let[t,n]=r(),[i,a]=(0,X.useState)(()=>{let e=t.get(`file`);return e?Te(e):new Set}),[o,s]=(0,X.useState)(()=>t.get(`file`)),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(()=>t.get(`sort`)===`size`?`size`:`name`),[f,p]=(0,X.useState)(`preview`);(0,X.useEffect)(()=>{t.get(`file`)&&n(e=>{let t=new URLSearchParams(e);return t.delete(`file`),t},{replace:!0})},[]);let m=(0,X.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),h=(0,X.useCallback)(e=>{a(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),[g,_]=(0,X.useState)(!1),v=(0,X.useCallback)(e=>{s(e),_(!1)},[]),[y,b]=(0,X.useState)(null),x=(0,X.useCallback)(e=>{let t=t=>t===e||t.startsWith(`${e}/`);s(e=>e!==null&&t(e)?null:e),a(e=>{let n=new Set([...e].filter(e=>!t(e)));return n.size===e.size?e:n}),b({path:e})},[]),[S,C]=(0,X.useState)(null),w={assistantId:e,expandedPaths:i,selectedPath:o,showHidden:c,sortMode:u,onToggleExpand:m,onExpandPath:h,onSelectPath:v,onToggleShowHidden:()=>l(e=>!e),onChangeSortMode:d,onPathDeleted:x,onPathRenamed:(0,X.useCallback)((e,t)=>{let n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;s(e=>e===null?e:n(e)),a(e=>{let t=!1,r=new Set;for(let i of e){let e=n(i);e!==i&&(t=!0),r.add(e)}return t?r:e}),C({from:e,to:t})},[])};return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,Q.jsx)(U,{onClick:()=>_(!0)})}),(0,Q.jsx)(W,{open:g,onClose:()=>_(!1),title:`Files`,children:(0,Q.jsx)(Ce,{...w})}),(0,Q.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-4 sm:grid-cols-[320px_1fr]`,children:[(0,Q.jsx)(`div`,{className:`hidden min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border sm:flex`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Q.jsx)(Ce,{...w})}),(0,Q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Q.jsx)(ge,{assistantId:e,selectedPath:o,showHidden:c,viewMode:f,onChangeViewMode:p,onBrowse:()=>_(!0),pathRename:S,pathDelete:y})})]})]})}function De(){return(0,Q.jsx)(Ee,{assistantId:H()})}export{De as WorkspacePage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{h as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./queryOptions-BtNi-_9H.js";import{n as l,t as u}from"./panel-item-Q1g7DFJw.js";import{t as d}from"./menu-BLJEjTFD.js";import{a as f}from"./src-SCpl1O1B.js";import{t as p}from"./confirm-dialog-bfBx6UYv.js";import{t as m}from"./input-D4W4p0pZ.js";import{t as h}from"./modal-BNAVT2FK.js";import{t as g}from"./createLucideIcon-BlMXrA59.js";import{t as _}from"./chevron-right-B6vEpVY0.js";import{t as v}from"./file-text-ClqzuFsu.js";import{t as y}from"./loader-circle-BFRVtR3K.js";import{t as b}from"./pencil-B90pDI55.js";import{t as x}from"./x-DxL-bCuT.js";import{Cr as S,Sr as C,_r as w,br as T,vr as E,xr as D,yr as O}from"./sdk.gen-zA5ns5LT.js";import{n as k}from"./use-is-mobile-jACt_z2d.js";import{n as A}from"./native-file-DIJL6af-.js";import{L as j,Oa as M,Qi as N,R as P,Si as F,ia as I,ki as L,na as R,oa as ee,oi as z,ra as B,sa as te,ua as V,ui as ne}from"./index-B-S-gNKm.js";import{t as H}from"./use-active-assistant-id-BVzVN4_g.js";import{n as U,t as W}from"./mobile-sidebar-drawer-BA9ERuJ7.js";import{i as G,n as re,r as K,t as q}from"./file-editor-Bm5LJXwA.js";import{t as J}from"./format-file-size-BflZ4oxc.js";var ie=g(`arrow-down-a-z`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M20 8h-5`,key:`1vsyxs`}],[`path`,{d:`M15 10V6.5a2.5 2.5 0 0 1 5 0V10`,key:`ag13bf`}],[`path`,{d:`M15 14h5l-5 6h5`,key:`ur5jdg`}]]),ae=g(`arrow-down-wide-narrow`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h10`,key:`1w87gc`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}]]),oe=g(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Y=g(`folder-plus`,[[`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`}]]),X=e(t(),1);async function se(e){let{data:t,error:n}=await E({path:{assistant_id:e.assistantId},query:{path:e.path,...e.showHidden?{showHidden:`true`}:{}},parseAs:`blob`,throwOnError:!1});if(n||!(t instanceof Blob))throw Error(`Failed to download file`);await A(t,e.filename)}function ce(e){if(!e)return``;let t=e.indexOf(`;`);return(t===-1?e:e.slice(0,t)).trim()}function le(e,t){return ce(t)===`application/json`?!0:(e??``).toLowerCase().endsWith(`.json`)}function ue(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Z(e){return e.split(`/`).some(e=>e.startsWith(`.`))}var Q=s();function de(e){return c({queryFn:async()=>{let{data:t,error:n}=await O({path:e.path,query:{path:e.query.path,...e.query.showHidden?{showHidden:`true`}:{}}});if(n)throw n;return t},queryKey:[`assistantsWorkspaceFileRetrieve`,e]})}function fe({mimeType:e}){let t=e.indexOf(`;`),n=(t===-1?e:e.slice(0,t)).trim(),r=v;return n.startsWith(`image/`)?r=N:n.startsWith(`video/`)?r=z:!n.startsWith(`text/`)&&n!==`application/json`&&n!==`application/octet-stream`&&(r=B),(0,Q.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 10%, transparent)`},children:(0,Q.jsx)(r,{className:`h-3.5 w-3.5`,style:{color:`var(--content-default)`}})})}function pe({viewMode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`inline-flex rounded-md p-0.5`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`},children:[`preview`,`source`].map(r=>{let i=e===r;return(0,Q.jsx)(n,{variant:`ghost`,onClick:()=>t(r),className:`h-auto rounded border-0 px-2.5 py-1 text-body-small-default hover:bg-transparent`,style:{backgroundColor:i?`var(--surface-lift)`:`transparent`,color:i?`var(--content-default)`:`var(--content-tertiary)`,boxShadow:i?`0 1px 2px rgba(0,0,0,0.15)`:void 0},children:r===`preview`?`Preview`:`Source`},r)})})}function $({name:e,mimeType:t,size:n,rightContent:r}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(fe,{mimeType:t}),(0,Q.jsx)(`span`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),n!=null&&(0,Q.jsx)(`span`,{className:`shrink-0 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:J(n)})]}),r]})}function me({assistantId:e,path:t,mimeType:n,showHidden:r}){let{data:i,isLoading:o}=a({queryFn:async()=>{let n=await E({path:{assistant_id:e},query:{path:t,...r?{showHidden:`true`}:{}},parseAs:`blob`});if(n.error)throw n.error;return n.data},queryKey:[`assistantsWorkspaceFileContentRetrieve`,{assistantId:e,path:t,showHidden:r}],enabled:!!t}),[s,c]=(0,X.useState)(null);return(0,X.useEffect)(()=>{if(!i)return;let e=URL.createObjectURL(i);return c(e),()=>{URL.revokeObjectURL(e),c(null)}},[i]),o?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(y,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):s?n.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Q.jsx)(`img`,{src:s,alt:t.split(`/`).pop()??`image`,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n.startsWith(`video/`)?(0,Q.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Q.jsx)(`video`,{src:s,controls:!0,className:`max-h-[70vh] max-w-full rounded`})}):null:null}function he({assistantId:e,path:t,name:r,mimeType:i,size:a,modifiedAt:o,showHidden:s}){let[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),f=(0,X.useCallback)(async()=>{d(!1),l(!0);try{await se({assistantId:e,path:t,filename:r,showHidden:s})}catch{d(!0)}finally{l(!1)}},[e,t,r,s]);return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:r,mimeType:i,size:a}),(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,Q.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border p-6 text-center`,style:{borderColor:`var(--border-base)`,backgroundColor:`var(--surface-lift)`},children:[(0,Q.jsx)(B,{className:`mx-auto h-10 w-10`,style:{color:`var(--content-tertiary)`}}),(0,Q.jsx)(`p`,{className:`mt-3 text-body-medium-default`,style:{color:`var(--content-default)`},children:r}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:i}),(0,Q.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:J(a,`Unknown size`)}),o&&(0,Q.jsxs)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:[`Modified: `,new Date(o).toLocaleString()]})]}),(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:c?(0,Q.jsx)(y,{className:`animate-spin`,"aria-hidden":!0}):(0,Q.jsx)(V,{"aria-hidden":!0}),onClick:f,disabled:c,"aria-label":`Download ${r}`,className:`mt-4`,children:c?`Downloading…`:`Download`}),u&&(0,Q.jsx)(`p`,{className:`mt-2 text-body-small-default`,style:{color:`var(--system-error)`},children:`Download failed. Try again.`})]})})]})}function ge({assistantId:e,selectedPath:t,showHidden:r,viewMode:s,onChangeViewMode:c,onBrowse:l,pathRename:u,pathDelete:d}){let f=i(),{data:p,isLoading:m}=a({...de({path:{assistant_id:e},query:{path:t??``,showHidden:r}}),enabled:!!t}),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null);(0,X.useEffect)(()=>{if(!u)return;let{from:e,to:t}=u,n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;g(e=>e==null?e:n(e)),v(e=>e==null?e:{...e,path:n(e.path)})},[u]),(0,X.useEffect)(()=>{if(!d)return;let{path:e}=d,t=t=>t===e||t.startsWith(`${e}/`);g(e=>e!=null&&t(e)?null:e),v(e=>e!=null&&t(e.path)?null:e)},[d]);let b=h!=null&&h===t,x=p?.content??``,C=_?.path===t?_.content:x,w=()=>{g(null),v(null)},T=o({mutationFn:async({path:t,content:n})=>{let{error:r,response:i}=await S({path:{assistant_id:e},body:{path:t,content:n,encoding:`utf8`},throwOnError:!1});if(!i?.ok||r)throw Error(`Failed to save file`)},onSuccess:(e,t)=>{g(e=>e===t.path?null:e),v(e=>e?.path===t.path?null:e),f.invalidateQueries({queryKey:[`assistantsWorkspaceFileRetrieve`]})}}),E=C!==x,D=(0,X.useCallback)(()=>{t&&E&&!T.isPending&&T.mutate({path:t,content:C})},[t,E,T,C]);if(!t)return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view`}),l&&(0,Q.jsx)(n,{type:`button`,onClick:l,leftIcon:(0,Q.jsx)(oe,{"aria-hidden":!0}),className:`sm:hidden`,children:`Browse files`})]});if(m)return(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(y,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})});if(!p)return(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`File not found`})});let O=p.mimeType??`application/octet-stream`,k=p.name??t.split(`/`).pop()??t,A=P(k,O),M=le(k,O),N=p.content!=null&&!A&&!M,F=t?Z(t):!0,I=b&&(0,Q.jsx)(re,{isDirty:E,isSaving:T.isPending,error:T.isError?`Save failed`:null,onSave:D,onDiscard:w});if(A&&p.content!=null){let e=b?C:p.content;return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:k,mimeType:O,rightContent:(0,Q.jsx)(pe,{viewMode:s,onChange:e=>{b&&w(),c(e)}})}),(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Q.jsx)(q,{content:e,fileName:k,mimeType:O,showEdit:!F&&s===`source`,isEditing:b,onToggleEdit:()=>b?w():g(t)}),s===`preview`?(0,Q.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Q.jsx)(j,{content:e})}):b?(0,Q.jsx)(K,{value:C,onChange:e=>v({path:t,content:e}),onSave:D}):(0,Q.jsx)(G,{content:p.content,readOnly:F,onStartEdit:()=>g(t)})]}),I]})}if(M&&p.content!=null){let e=b?C:p.content,n=ue(e);return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:k,mimeType:O,rightContent:(0,Q.jsx)(pe,{viewMode:s,onChange:e=>{b&&w(),c(e)}})}),(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Q.jsx)(q,{content:s===`preview`?n:e,downloadContent:e,fileName:k,mimeType:O,showEdit:!F&&s===`source`,isEditing:b,onToggleEdit:()=>b?w():g(t)}),s===`preview`?(0,Q.jsx)(G,{content:n,readOnly:!0,whiteSpace:`pre`}):b?(0,Q.jsx)(K,{value:C,onChange:e=>v({path:t,content:e}),onSave:D}):(0,Q.jsx)(G,{content:p.content,readOnly:F,onStartEdit:()=>g(t)})]}),I]})}return N?(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:k,mimeType:O,size:p.size}),(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Q.jsx)(q,{content:b?C:p.content??``,fileName:k,mimeType:O,showEdit:!F,isEditing:b,onToggleEdit:()=>b?w():g(t)}),b?(0,Q.jsx)(K,{value:C,onChange:e=>v({path:t,content:e}),onSave:D}):(0,Q.jsx)(G,{content:p.content??``,readOnly:F,onStartEdit:()=>g(t)})]}),I]}):O.startsWith(`image/`)||O.startsWith(`video/`)?(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)($,{name:k,mimeType:O,size:p.size}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Q.jsx)(me,{assistantId:e,path:t,mimeType:O,showHidden:r})})]}):(0,Q.jsx)(he,{assistantId:e,path:t,name:k,mimeType:O,size:p.size,modifiedAt:p.modifiedAt,showHidden:r})}function _e(e,t){if(t===`name`)return e;let n=e.slice();return n.sort((e,t)=>{let n=e.size??null,r=t.size??null;return n===null&&r===null?(e.name??``).localeCompare(t.name??``):n===null?1:r===null?-1:n===r?(e.name??``).localeCompare(t.name??``):r-n}),n}function ve(e){return c({queryFn:async()=>{let t={};e.query?.path&&(t.path=e.query.path),e.query?.showHidden&&(t.showHidden=`true`),e.query?.includeDirSizes&&(t.includeDirSizes=`true`);let{data:n,error:r}=await C({path:e.path,query:t});if(r)throw r;if(!n)throw Error(`Failed to load workspace tree`);return n},queryKey:[`assistantsWorkspaceTreeRetrieve`,e]})}async function ye(e,t,n,r){let i=n.toLowerCase(),a=r?.toLowerCase(),{data:o}=await C({path:{assistant_id:e},query:t?{path:t}:{}});if(o?.entries?.some(e=>{let t=(e.name??``).toLowerCase();return t===i&&t!==a}))throw Error(`"${n}" already exists here.`)}function be({entry:e}){return e.type===`directory`?(0,Q.jsx)(R,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`image/`)?(0,Q.jsx)(N,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`video/`)?(0,Q.jsx)(z,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Q.jsx)(v,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}})}function xe({entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:u,onRequestRename:d,onRequestCreate:p,depth:m}){let h=e.path??``,g=e.name??``,v=e.type===`directory`,y=n.has(h),x=r===h,S=g.startsWith(`.`),C=!Z(h),w=v&&(y||s.length>0),{data:T}=a({...ve({path:{assistant_id:t},query:{path:h,showHidden:i,includeDirSizes:o===`size`}}),enabled:v&&w}),E=(0,X.useMemo)(()=>_e(T?.entries??[],o),[T?.entries,o]),D=s===``||g.toLowerCase().includes(s);if(s!==``&&!v&&!D)return null;let O=(0,Q.jsxs)(`button`,{onClick:()=>{v?c(h):l(h)},className:`flex w-full items-center gap-1.5 px-2 py-1 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{paddingLeft:`${m*14+8}px`,paddingRight:`8px`,color:x?`var(--content-default)`:S?`var(--content-tertiary)`:`var(--content-default)`,backgroundColor:x?`color-mix(in oklab, var(--primary-base) 12%, transparent)`:void 0,opacity:S&&!x?.7:1},children:[v?w?(0,Q.jsx)(M,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Q.jsx)(_,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Q.jsx)(`span`,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(be,{entry:e}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g}),e.size!=null&&(0,Q.jsx)(`span`,{className:`shrink-0 text-label-medium-default tabular-nums`,style:{color:`var(--content-tertiary)`},children:J(e.size)})]});return(0,Q.jsxs)(`div`,{children:[C?(0,Q.jsxs)(f.Root,{children:[(0,Q.jsx)(f.Trigger,{children:O}),(0,Q.jsxs)(f.Content,{children:[v&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(f.Item,{leftIcon:(0,Q.jsx)(I,{className:`h-3.5 w-3.5`}),onSelect:()=>p({kind:`file`,parentPath:h}),children:`New File`}),(0,Q.jsx)(f.Item,{leftIcon:(0,Q.jsx)(Y,{className:`h-3.5 w-3.5`}),onSelect:()=>p({kind:`folder`,parentPath:h}),children:`New Folder`}),(0,Q.jsx)(f.Separator,{})]}),(0,Q.jsx)(f.Item,{leftIcon:(0,Q.jsx)(ne,{className:`h-3.5 w-3.5`}),onSelect:()=>u({path:h,name:g,isDirectory:v}),children:`Delete`}),(0,Q.jsx)(f.Item,{leftIcon:(0,Q.jsx)(b,{className:`h-3.5 w-3.5`}),onSelect:()=>d({path:h,name:g,isDirectory:v}),children:`Rename`})]})]}):O,v&&w&&E.length>0&&(0,Q.jsx)(`div`,{children:E.map(e=>(0,Q.jsx)(xe,{entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:u,onRequestRename:d,onRequestCreate:p,depth:m+1},e.path))})]})}function Se({title:e,placeholder:t,confirmLabel:r,pendingLabel:i,initialName:a,onCancel:o,onConfirm:s,pending:c,error:l}){let u=(0,X.useRef)(null),[d,f]=(0,X.useState)(a??``),p=d.trim(),g=p.length>0&&(/[/\\]/.test(p)||p===`.`||p===`..`),_=p.length>0&&!g&&!c;return(0,Q.jsx)(h.Root,{open:!0,onOpenChange:e=>{!e&&!c&&o()},children:(0,Q.jsx)(h.Content,{size:`sm`,hideCloseButton:!0,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault();let t=u.current;t&&(t.focus(),requestAnimationFrame(()=>{t.setSelectionRange(0,t.value.length)}))},onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),c||o()},children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_&&s(p)},children:[(0,Q.jsx)(h.Header,{children:(0,Q.jsx)(h.Title,{children:e})}),(0,Q.jsx)(h.Body,{children:(0,Q.jsx)(m,{ref:u,label:`Name`,value:d,onChange:e=>f(e.target.value),placeholder:t,errorText:l??(g?`Enter a single file or folder name without slashes.`:void 0),autoComplete:`off`,spellCheck:!1,fullWidth:!0})}),(0,Q.jsxs)(h.Footer,{children:[(0,Q.jsx)(n,{type:`button`,variant:`outlined`,onClick:o,disabled:c,children:`Cancel`}),(0,Q.jsx)(n,{type:`submit`,variant:`primary`,disabled:!_,children:c?i:r})]})]})})})}function Ce({assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,onToggleExpand:l,onExpandPath:u,onSelectPath:d,onToggleShowHidden:f,onChangeSortMode:h,onPathDeleted:g,onPathRenamed:_}){let v=i(),[y,b]=(0,X.useState)(``),C=y.trim().toLowerCase(),[E,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),N=(0,X.useCallback)(()=>{A(null),M(null)},[]),{data:P,isLoading:I}=a(ve({path:{assistant_id:e},query:{showHidden:s,includeDirSizes:c===`size`}})),L=(0,X.useMemo)(()=>_e(P?.entries??[],c),[P?.entries,c]),R=(0,X.useCallback)(()=>{for(let e of[`assistantsWorkspaceTreeRetrieve`,`assistantsWorkspaceFileRetrieve`,`assistantsWorkspaceFileContentRetrieve`])v.invalidateQueries({queryKey:[e]})},[v]),z=o({mutationFn:async t=>{let n=t.parentPath?`${t.parentPath}/${t.name}`:t.name;await ye(e,t.parentPath,t.name);let{error:r,response:i}=t.kind===`file`?await S({path:{assistant_id:e},body:{path:n,content:``,encoding:`utf8`},throwOnError:!1}):await T({path:{assistant_id:e},body:{path:n},throwOnError:!1});if(r||!i?.ok)throw Error(typeof r==`string`?r:`Failed to create — check the name and try again.`);return{...t,path:n}},onSuccess:e=>{N(),R(),e.parentPath&&u(e.parentPath),e.kind===`file`?d(e.path):u(e.path)},onError:e=>{M(e instanceof Error?e.message:`Failed to create.`)}}),B=o({mutationFn:async t=>{let n=t.oldPath.lastIndexOf(`/`),r=n===-1?``:t.oldPath.slice(0,n),i=t.oldPath.slice(n+1),a=r?`${r}/${t.newName}`:t.newName;await ye(e,r,t.newName,i);let{error:o,response:s}=await D({path:{assistant_id:e},body:{oldPath:t.oldPath,newPath:a},throwOnError:!1});if(o||!s?.ok)throw Error(typeof o==`string`?o:`Failed to rename — check the name and try again.`);return{oldPath:t.oldPath,newPath:a}},onSuccess:({oldPath:e,newPath:t})=>{N(),R(),_(e,t)},onError:e=>{M(e instanceof Error?e.message:`Failed to rename.`)}}),V=(0,X.useCallback)(e=>{M(null),A({type:`create`,...e})},[]),ne=(0,X.useCallback)(e=>{M(null),A({type:`rename`,path:e.path,name:e.name})},[]),[H,U]=(0,X.useState)(null),W=o({mutationFn:async t=>{let{error:n,response:r}=await w({path:{assistant_id:e},body:{path:t.path},throwOnError:!1});if(n||!r?.ok)throw Error(typeof n==`string`?n:`Failed to delete — try again.`);return t},onSuccess:e=>{U(null),R(),g(e.path)}}),G=(0,X.useCallback)(e=>{W.reset(),U(e)},[W]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:`Files`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:c===`size`?(0,Q.jsx)(ae,{"aria-hidden":!0}):(0,Q.jsx)(ie,{"aria-hidden":!0}),onClick:()=>h(c===`size`?`name`:`size`),"aria-label":c===`size`?`Sort by name`:`Sort by size`,title:c===`size`?`Sorted by size — switch to name`:`Sorted by name — switch to size`,tintColor:c===`size`?`var(--content-default)`:`var(--content-tertiary)`}),(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:s?(0,Q.jsx)(ee,{"aria-hidden":!0}):(0,Q.jsx)(te,{"aria-hidden":!0}),onClick:f,"aria-label":s?`Hide hidden files`:`Show hidden files`,title:s?`Hide hidden files`:`Show hidden files`,tintColor:s?`var(--content-default)`:`var(--content-tertiary)`}),(0,Q.jsx)(we,{open:E,onOpenChange:O,onSelectKind:e=>{O(!1),V({kind:e,parentPath:``})}})]})]}),(0,Q.jsx)(`div`,{className:`px-3 py-2`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(m,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Search files`,leftIcon:(0,Q.jsx)(F,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0,spellCheck:!1,autoComplete:`off`}),y&&(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(x,{"aria-hidden":!0}),onClick:()=>b(``),"aria-label":`Clear search`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,tintColor:`var(--content-tertiary)`})]})}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:I?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`,style:{color:`var(--content-tertiary)`}})}):L.length?L.map(n=>(0,Q.jsx)(xe,{entry:n,assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,searchLower:C,onToggleExpand:l,onSelectPath:d,onRequestDelete:G,onRequestRename:ne,onRequestCreate:V,depth:0},n.path)):(0,Q.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files found`})}),k?.type===`create`&&(0,Q.jsx)(Se,{title:k.kind===`file`?`New File`:`New Folder`,placeholder:k.kind===`file`?`filename.md`:`folder-name`,confirmLabel:`Create`,pendingLabel:`Creating…`,onCancel:N,onConfirm:e=>{M(null),z.mutate({kind:k.kind,parentPath:k.parentPath,name:e})},pending:z.isPending,error:j},`create-${k.kind}-${k.parentPath}`),k?.type===`rename`&&(0,Q.jsx)(Se,{title:`Rename`,placeholder:k.name,confirmLabel:`Rename`,pendingLabel:`Renaming…`,initialName:k.name,onCancel:N,onConfirm:e=>{if(e===k.name){N();return}M(null),B.mutate({oldPath:k.path,newName:e})},pending:B.isPending,error:j},`rename-${k.path}`),(0,Q.jsx)(p,{open:H!==null,title:H?.isDirectory?`Delete Folder`:`Delete File`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to delete`,` `,(0,Q.jsx)(`span`,{style:{color:`var(--content-default)`},children:H?.name}),H?.isDirectory?` and all of its contents`:``,`? This cannot be undone.`,W.error&&(0,Q.jsx)(`span`,{className:`mt-2 block`,style:{color:`var(--system-negative-strong)`},children:W.error.message})]}),confirmLabel:W.isPending?`Deleting…`:`Delete`,destructive:!0,isPending:W.isPending,onConfirm:()=>{H&&W.mutate(H)},onCancel:()=>U(null)})]})}function we({open:e,onOpenChange:t,onSelectKind:r}){return k()?(0,Q.jsxs)(l.Root,{open:e,onOpenChange:t,children:[(0,Q.jsx)(l.Trigger,{asChild:!0,children:(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(L,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Q.jsxs)(l.Content,{children:[(0,Q.jsx)(l.Header,{className:`sr-only`,children:(0,Q.jsx)(l.Title,{children:`Create new`})}),(0,Q.jsxs)(l.Body,{className:`pt-0`,children:[(0,Q.jsx)(u,{icon:I,label:`New File`,onSelect:()=>r(`file`)}),(0,Q.jsx)(u,{icon:Y,label:`New Folder`,onSelect:()=>r(`folder`)})]})]})]}):(0,Q.jsxs)(d.Root,{open:e,onOpenChange:t,children:[(0,Q.jsx)(d.Trigger,{asChild:!0,children:(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(L,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Q.jsxs)(d.Content,{align:`end`,sideOffset:4,children:[(0,Q.jsx)(d.Item,{leftIcon:(0,Q.jsx)(I,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`file`),children:`New File`}),(0,Q.jsx)(d.Item,{leftIcon:(0,Q.jsx)(Y,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`folder`),children:`New Folder`})]})]})}function Te(e){let t=e.split(`/`),n=new Set;for(let e=1;e<t.length;e++)n.add(t.slice(0,e).join(`/`));return n}function Ee({assistantId:e}){let[t,n]=r(),[i,a]=(0,X.useState)(()=>{let e=t.get(`file`);return e?Te(e):new Set}),[o,s]=(0,X.useState)(()=>t.get(`file`)),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(()=>t.get(`sort`)===`size`?`size`:`name`),[f,p]=(0,X.useState)(`preview`);(0,X.useEffect)(()=>{t.get(`file`)&&n(e=>{let t=new URLSearchParams(e);return t.delete(`file`),t},{replace:!0})},[]);let m=(0,X.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),h=(0,X.useCallback)(e=>{a(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),[g,_]=(0,X.useState)(!1),v=(0,X.useCallback)(e=>{s(e),_(!1)},[]),[y,b]=(0,X.useState)(null),x=(0,X.useCallback)(e=>{let t=t=>t===e||t.startsWith(`${e}/`);s(e=>e!==null&&t(e)?null:e),a(e=>{let n=new Set([...e].filter(e=>!t(e)));return n.size===e.size?e:n}),b({path:e})},[]),[S,C]=(0,X.useState)(null),w={assistantId:e,expandedPaths:i,selectedPath:o,showHidden:c,sortMode:u,onToggleExpand:m,onExpandPath:h,onSelectPath:v,onToggleShowHidden:()=>l(e=>!e),onChangeSortMode:d,onPathDeleted:x,onPathRenamed:(0,X.useCallback)((e,t)=>{let n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;s(e=>e===null?e:n(e)),a(e=>{let t=!1,r=new Set;for(let i of e){let e=n(i);e!==i&&(t=!0),r.add(e)}return t?r:e}),C({from:e,to:t})},[])};return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,Q.jsx)(U,{onClick:()=>_(!0)})}),(0,Q.jsx)(W,{open:g,onClose:()=>_(!1),title:`Files`,children:(0,Q.jsx)(Ce,{...w})}),(0,Q.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-4 sm:grid-cols-[320px_1fr]`,children:[(0,Q.jsx)(`div`,{className:`hidden min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border sm:flex`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Q.jsx)(Ce,{...w})}),(0,Q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Q.jsx)(ge,{assistantId:e,selectedPath:o,showHidden:c,viewMode:f,onChangeViewMode:p,onBrowse:()=>_(!0),pathRename:S,pathDelete:y})})]})]})}function De(){return(0,Q.jsx)(Ee,{assistantId:H()})}export{De as WorkspacePage};
package/dist/index.html CHANGED
@@ -10,7 +10,7 @@
10
10
  <link rel="apple-touch-icon" href="/assistant/favicon.svg" />
11
11
  <title>Vellum Assistant</title>
12
12
  <script src="/assistant/theme-init.js"></script>
13
- <script type="module" crossorigin src="/assistant/assets/index-CZ2UBc_U.js"></script>
13
+ <script type="module" crossorigin src="/assistant/assets/index-B-S-gNKm.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assistant/assets/chunk-jRWAZmH_.js">
15
15
  <link rel="modulepreload" crossorigin href="/assistant/assets/preload-helper-BewR0kVT.js">
16
16
  <link rel="modulepreload" crossorigin href="/assistant/assets/dist-Ztj3rqLK.js">
@@ -85,7 +85,7 @@
85
85
  <link rel="modulepreload" crossorigin href="/assistant/assets/diagnostics-BAjanSbk.js">
86
86
  <link rel="modulepreload" crossorigin href="/assistant/assets/conversation-store-B8D6wE18.js">
87
87
  <link rel="modulepreload" crossorigin href="/assistant/assets/typed-storage-DjORmu8t.js">
88
- <link rel="modulepreload" crossorigin href="/assistant/assets/detail-shell-CyXDiAEa.js">
88
+ <link rel="modulepreload" crossorigin href="/assistant/assets/detail-shell-CPp3KhI8.js">
89
89
  <link rel="modulepreload" crossorigin href="/assistant/assets/bookmark-C3S-p0MQ.js">
90
90
  <link rel="modulepreload" crossorigin href="/assistant/assets/brain-Bs6LnfHO.js">
91
91
  <link rel="modulepreload" crossorigin href="/assistant/assets/bug-DDcuQ3au.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/web",
3
- "version": "0.10.5-staging.2",
3
+ "version": "0.10.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Pre-built web SPA for the Vellum Assistant",
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/native-file-DIJL6af-.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-BewR0kVT.js","assets/dist-Ztj3rqLK.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./chunk-jRWAZmH_.js";import{r as t,s as n}from"./local-settings-lVNyIOJ_.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-D-AX8Voo.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./typography-BscuIPxA.js";import"./src-SCpl1O1B.js";import{n as c,t as l}from"./create-selectors-BE0_e_Ed.js";import{t as u}from"./createLucideIcon-BlMXrA59.js";import{t as d}from"./x-DxL-bCuT.js";import{l as f}from"./sdk.gen-zA5ns5LT.js";import{n as ee}from"./typed-storage-DjORmu8t.js";import{a as te}from"./diagnostics-BAjanSbk.js";import{c as ne}from"./messages-ChEiS3wF.js";import{t as re}from"./conversation-store-B8D6wE18.js";import{b as ie,n as ae,t as oe,v as se,w as p,x as ce}from"./chat-rA5AbKPD.js";import{t as le}from"./misc-CFzLzLPH.js";var ue=u(`bolt`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]),de=u(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),fe=u(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),pe=u(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),me=e(r(),1),he=1e3,ge=15,_e=0,m=new Map,h=[];function ve(e){let t=`sse-${++_e}`,n={id:t,abortSignal:e,initiatedAt:Date.now(),establishedAt:null,lastTrafficAt:null,lastDataAt:null,dataFrames:0,keepalives:0,endedAt:null,endReason:null};m.set(t,n),Ee();let r=()=>{Te(t,`aborted`)};return e.aborted?r():e.addEventListener(`abort`,r,{once:!0}),t}function ye(e){let t=m.get(e);t&&t.establishedAt===null&&(t.establishedAt=Date.now())}function be(e,t){let n=m.get(e);if(!n)return;let r=Date.now();n.lastTrafficAt=r,t?(n.lastDataAt=r,n.dataFrames++):n.keepalives++}function xe(e,t){h.push({clientId:e,receivedAt:new Date().toISOString(),...t}),h.length>he&&h.shift()}function Se(){return Array.from(m.values())}function Ce(e=he){let t=Math.max(0,h.length-e);return h.slice(t)}function we(e,t){if(t===null)return null;let n=1/0;for(let e of h)typeof e.seq==`number`&&(n=Math.min(n,e.seq));return n!==1/0&&n>t+1?null:h.filter(n=>n.conversationId===e&&typeof n.seq==`number`&&n.seq>t).sort((e,t)=>e.seq-t.seq)}function Te(e,t){let n=m.get(e);n&&(n.endedAt===null?(n.endedAt=Date.now(),n.endReason=t):n.endReason===`aborted`&&t!==`aborted`&&(n.endReason=t),Ee())}function Ee(){let e=0;for(let t of m.values())t.endedAt!==null&&e++;if(!(e<=ge))for(let[t,n]of m){if(e<=ge)break;n.endedAt!==null&&(m.delete(t),e--)}}var De={phase:`idle`,pendingQueuedCount:0,activeToolCallCount:0,activeTurnId:null,lastTerminalReason:null,statusText:null,liveWebActivity:{}};function Oe(e){return e===`queued`||e===`thinking`||e===`streaming`||e===`awaiting_user_input`}function ke(e){return e===`thinking`}function g(e){return(e.phase===`idle`||e.phase===`errored`)&&!e.activeTurnId}var Ae=l(c()((e,t)=>({...De,requestSend:t=>e(e=>({phase:`thinking`,activeTurnId:t??e.activeTurnId,lastTerminalReason:null,activeToolCallCount:0,statusText:null})),acceptSend:t=>e(e=>({activeTurnId:t,...e.phase===`idle`||e.phase===`errored`?{phase:`thinking`,lastTerminalReason:null}:null})),onTextDelta:()=>{let n=t();if(n.phase===`idle`||n.phase===`errored`){if(!n.activeTurnId)return;e({phase:`streaming`});return}(n.phase===`thinking`||n.phase===`queued`)&&e({phase:`streaming`})},onToolUseStart:()=>{let n=t();g(n)||e({phase:n.phase===`idle`||n.phase===`errored`||n.phase===`queued`?`thinking`:n.phase,activeToolCallCount:n.activeToolCallCount+1})},onToolResult:()=>e(e=>({activeToolCallCount:Math.max(0,e.activeToolCallCount-1)})),onToolActivityMetadata:(n,r)=>{let i=t();g(i)||e({liveWebActivity:{...i.liveWebActivity,[n]:r}})},onActivityThinking:n=>{let r=t();g(r)||r.phase!==`awaiting_user_input`&&e({phase:`thinking`,statusText:n??null})},showSurface:n=>{g(t())||n&&e({phase:`awaiting_user_input`})},updateSurface:()=>{},dismissSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},completeSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},onSecretRequest:()=>{g(t())||e({phase:`awaiting_user_input`})},onConfirmationRequest:()=>{g(t())||e({phase:`awaiting_user_input`})},onQuestionRequest:()=>{g(t())||e({phase:`awaiting_user_input`})},onContactRequest:()=>{g(t())||e({phase:`awaiting_user_input`})},completeTurn:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},handoffGeneration:()=>{g(t())||e({phase:`thinking`,activeToolCallCount:0,statusText:null})},cancelGeneration:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`cancelled`,statusText:null,liveWebActivity:{}})},onStreamError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`error`,statusText:null,liveWebActivity:{}}),onSessionError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`session_error`,statusText:null,liveWebActivity:{}}),onTurnTimeout:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`timeout`,statusText:null,liveWebActivity:{}}),onPollReconciled:n=>{let r=t();n&&n!==r.activeTurnId||Oe(r.phase)&&e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},resetTurn:()=>e({...De}),enqueueMessage:()=>e(e=>({pendingQueuedCount:e.pendingQueuedCount+1})),dequeueMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(g(n)){e({pendingQueuedCount:r});return}e({phase:`thinking`,pendingQueuedCount:r})},deleteQueuedMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(r===0&&n.phase===`queued`){e({phase:`idle`,pendingQueuedCount:0,activeTurnId:null,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}});return}e({pendingQueuedCount:r})}}))),je=3670016,Me=[.85,.75,.65,.5],Ne=2e7,Pe=new Set([`image/jpeg`,`image/jpg`,`image/png`,`image/webp`,`image/heic`,`image/heif`,`image/bmp`,`image/tiff`]),Fe=new Set([`jpg`,`jpeg`,`png`,`webp`,`heic`,`heif`,`bmp`,`tif`,`tiff`]);function _(e){let t=e.type.trim().toLowerCase();if(Pe.has(t))return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n?Fe.has(n):!1}function Ie(e){return _(e)&&e.size>3670016}function Le(e){let t=e.type.trim().toLowerCase();if(t===`image/heic`||t===`image/heif`)return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n===`heic`||n===`heif`}function Re(e){return Ie(e)||Le(e)}function ze(e){let t=`attachment`,n=e.trim()||t;return/\.(?:jpe?g)$/i.test(n)?n:`${n.replace(/\.[^./\\]+$/,``)||t}.jpg`}async function Be(e){if(!Re(e)||await He(e))return{status:`unchanged`,file:e};if(e.size>104857600)return{status:`failed`,error:`This image is too large to process safely. Please choose a smaller image.`};let t;try{t=await Ve(e)}catch{return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`}}try{let n;try{n=await We(t,e.size)}catch{n=null}return!n||!Le(e)&&n.size>=e.size?{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`}:{status:`resized`,file:new File([n],ze(e.name),{type:`image/jpeg`,lastModified:e.lastModified})}}finally{t.close()}}async function Ve(e){if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e,{imageOrientation:`from-image`});return{source:t,width:t.width,height:t.height,close:()=>t.close()}}catch{}if(typeof Image>`u`)throw Error(`No browser image decoder is available.`);let t=URL.createObjectURL(e);return await new Promise((e,n)=>{let r=new Image;r.onload=()=>{e({source:r,width:r.naturalWidth||r.width,height:r.naturalHeight||r.height,close:()=>URL.revokeObjectURL(t)})},r.onerror=()=>{URL.revokeObjectURL(t),n(Error(`Image decode failed.`))},r.src=t})}async function He(e){if(!Ue(e))return!1;let t;try{t=new Uint8Array(await e.slice(0,Math.min(e.size,1024*1024)).arrayBuffer())}catch{return!0}if(!y(t,0,`RIFF`)||!y(t,8,`WEBP`))return!1;let n=v(t,`VP8X`);return n>=0&&(t[n+8]??0)&2?!0:v(t,`ANIM`)>=0||v(t,`ANMF`)>=0}function Ue(e){return e.type.trim().toLowerCase()===`image/webp`||/\.webp$/i.test(e.name)}function v(e,t){for(let n=0;n<=e.length-t.length;n+=1)if(y(e,n,t))return n;return-1}function y(e,t,n){if(t+n.length>e.length)return!1;for(let r=0;r<n.length;r+=1)if(e[t+r]!==n.charCodeAt(r))return!1;return!0}async function We(e,t){let n=e.width*e.height,r=null;if(n<=Ne)for(let t of Me){let n=await Ge(e.source,e.width,e.height,t);if(r=b(r,n),n&&n.size<=3670016)return n}let i=r?.size??t,a=Math.min(Math.sqrt(je/i*.9),.95);for(let t=0;t<4;t+=1){let t=Math.max(Math.floor(e.width*a),1),n=Math.max(Math.floor(e.height*a),1),o=null;for(let i of Me){let a=await Ge(e.source,t,n,i);if(r=b(r,a),o=b(o,a),a&&a.size<=3670016)return a}i=o?.size??i,a*=Math.min(Math.sqrt(je/i*.9),.9)}return null}function b(e,t){return t&&(!e||t.size<e.size)?t:e}async function Ge(e,t,n,r){if(typeof document>`u`)return null;let i=document.createElement(`canvas`);i.width=t,i.height=n;let a=i.getContext(`2d`);if(!a||typeof i.toBlob!=`function`)return null;a.fillStyle=`#fff`,a.fillRect(0,0,t,n),a.drawImage(e,0,0,t,n);try{return await new Promise(e=>{i.toBlob(t=>e(t),`image/jpeg`,r)})}finally{i.width=0,i.height=0}}async function x(e,t){if(!t||t.startsWith(`rehydrated:`))return null;try{let{data:n,error:r}=await f({path:{assistant_id:e,id:t},parseAs:`blob`,throwOnError:!1});return!r&&n instanceof Blob?n:null}catch{return null}}async function Ke(e,t){let{saveFile:n}=await a(async()=>{let{saveFile:e}=await import(`./native-file-DIJL6af-.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));if(t){let r=await x(t,e.id);if(r){await n(r,e.filename);return}}e.previewUrl&&await n(e.previewUrl,e.filename)}var qe=`vellum:chatDrafts:`;function Je(e){return`${qe}${e}`}function Ye(e){let n=t(Je(e),``);if(!n)return new Map;try{let e=JSON.parse(n);return typeof e!=`object`||!e||Array.isArray(e)?new Map:new Map(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return new Map}}function S(e,t){n(Je(e),JSON.stringify(Object.fromEntries(t)))}function Xe(){return`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Ze(e){return _(e)?`100 MB`:`50 MB`}function Qe(e){return e.size<=52428800?!0:_(e)&&e.size<=104857600}var C=new Map,w=null,T=new Map,E=new Set,$e=c()((e,t)=>({input:``,restoredDraftConversationId:null,attachments:[],attachmentLastError:null,setInput:t=>{e(e=>({input:typeof t==`function`?t(e.input):t}))},saveDraft:(e,t)=>{t.trim()?C.set(e,t):C.delete(e),w&&S(w,C)},clearDraft:e=>{C.delete(e),w&&S(w,C)},handleConversationSwitch:({previousKey:n,nextKey:r})=>{if(!(n!==null&&n!==r)||!n)return;let i=t().input;i.trim()?C.set(n,i):C.delete(n);let a=(r&&C.get(r))??``;e({input:a,restoredDraftConversationId:a.length>0&&r?r:null}),w&&S(w,C)},loadAssistantDrafts:(n,r)=>{if(w&&w!==n){let n=t().input;r&&(n.trim()?C.set(r,n):C.delete(r)),S(w,C),e({input:``,restoredDraftConversationId:null})}C=Ye(n),w=n},clearRestoredDraftNotice:()=>{e({restoredDraftConversationId:null})},restoreDraftIfEmpty:n=>{let r=C.get(n);r&&r.trim()&&!t().input.trim()&&e({input:r,restoredDraftConversationId:n})},addFiles:(t,n)=>{let r=Array.from(t);if(r.length===0)return;if(!n){e({attachmentLastError:`No active assistant. Please try again.`});return}let i=[],a=[];for(let e of r)Qe(e)?a.push(e):i.push(e);let o=i[0];if(e(o?{attachmentLastError:i.length===1?`${o.name} is larger than ${Ze(o)} and can't be attached.`:`${i.length} files are too large and can't be attached.`}:{attachmentLastError:null}),a.length===0)return;let s=a.map(e=>({pending:{kind:`uploading`,localId:Xe(),filename:e.name||`attachment`,mimeType:e.type||`application/octet-stream`,sizeBytes:e.size},file:e}));e(e=>({attachments:[...e.attachments,...s.map(e=>e.pending)]}));for(let{pending:t,file:r}of s)(async()=>{try{let i=await Be(r);if(E.has(t.localId)){E.delete(t.localId);return}if(i.status===`failed`&&r.size>52428800){D(e,t.localId,i.error);return}let a=i.status===`failed`?r:i.file;if(a.size>52428800){D(e,t.localId,`This attachment is still larger than 50 MB after resizing. Try a smaller image.`);return}i.status===`resized`&&e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId&&e.kind===`uploading`?{...e,filename:a.name||`attachment`,mimeType:a.type||`application/octet-stream`,sizeBytes:a.size}:e)}));let o=await ne(n,a);if(E.has(t.localId)){E.delete(t.localId);return}if(!o.ok){D(e,t.localId,o.error.detail??`Upload failed`);return}let s=a.type||`application/octet-stream`,c=o.filename??(a.name||`attachment`),l=o.mimeType??s,u=o.sizeBytes??a.size,d=a;if(l.startsWith(`image/`)&&l!==s){let e=await x(n,o.id);if(E.has(t.localId)){E.delete(t.localId);return}e&&(d=e)}let f=null;try{f=URL.createObjectURL(d),T.set(t.localId,f)}catch{f=null}e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId?{kind:`uploaded`,localId:t.localId,id:o.id,filename:c,mimeType:l,sizeBytes:u,previewUrl:f}:e)}))}catch{if(E.has(t.localId)){E.delete(t.localId);return}D(e,t.localId,`Upload failed`)}})()},removeAttachment:t=>{e(e=>{let n=e.attachments.find(e=>e.localId===t);return n&&n.kind===`uploading`&&E.add(t),{attachments:e.attachments.filter(e=>e.localId!==t)}}),et(t)},resetAttachments:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&E.add(t.localId);return{attachments:[],attachmentLastError:null}})},fullReset:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&E.add(t.localId);return{attachments:[],attachmentLastError:null}}),T.forEach(e=>URL.revokeObjectURL(e)),T.clear()},dismissAttachmentError:()=>{e({attachmentLastError:null})}}));function D(e,t,n){e(e=>({attachments:e.attachments.map(e=>e.localId===t?{kind:`failed`,localId:t,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,error:n}:e)}))}function et(e){let t=T.get(e);t&&(URL.revokeObjectURL(t),T.delete(e))}function tt(e){return e.reduce((e,t)=>t.kind===`uploading`?e+1:e,0)}function nt(e){return e.filter(e=>e.kind===`uploaded`).map(e=>e.id)}var O=l($e);function rt(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function it(e){let t=JSON.parse(e);return rt(t)?t:null}function k(e,t){let n=[...e??[]],r=n.findIndex(e=>e.type===`surface`&&e.surface.surfaceId===t.surfaceId);return r===-1?n.push({type:`surface`,surface:t}):n[r]={type:`surface`,surface:t},n}function at(e,t){return e?.filter(e=>!(e.type===`surface`&&e.surface.surfaceId===t))}function ot(e,t){if(!e.surfaces?.length)return e;let n=!1,r=e.contentBlocks,i=e.surfaces.map(e=>{let i=t(e);return i!==e&&(n=!0,r=k(r,i)),i});return n?{...e,surfaces:i,contentBlocks:r}:e}function st(e,t){if(!e.surfaces?.length)return e;let n=e.surfaces.filter(t);if(n.length===e.surfaces.length)return e;let r=new Set(e.surfaces.filter(e=>!t(e)).map(e=>e.surfaceId));return{...e,surfaces:n,contentOrder:e.contentOrder?.filter(e=>!(e.type===`surface`&&r.has(e.id))),contentBlocks:e.contentBlocks?.filter(e=>!(e.type===`surface`&&r.has(e.surface.surfaceId)))}}var A=500,j=ee({keyFn:e=>`vellum:dismissed-surfaces:${e}`,scope:`user`,parseValue:e=>rt(e)?e:null,fallback:{},maxEntries:200});function ct(e,t){let n=j.get(e,t);return n?new Set(n):new Set}function lt(e,t,n){let r=Array.from(n);r.length>A&&(r=r.slice(r.length-A)),j.set(e,t,r)}var ut=[];function dt(e,t){if(!e)return ut;if(t.size===0)return e;let n=!1,r=e.map(e=>{let r=st(e,e=>!t.has(e.surfaceId));return r!==e&&(n=!0),r});return n?r:e}function ft(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.tokens!=`number`||!Number.isFinite(t.tokens)||t.maxTokens!==null&&(typeof t.maxTokens!=`number`||!Number.isFinite(t.maxTokens))||t.fillRatio!==null&&(typeof t.fillRatio!=`number`||!Number.isFinite(t.fillRatio)))}var pt=ee({keyFn:e=>`vellum:ctxwindow:${e}`,scope:`user`,parseValue:e=>ft(e)?e:null,fallback:{},maxEntries:200});function mt(e){return new Map(Object.entries(pt.load(e)))}function ht(e,t,n){pt.set(e,t,n)}var gt=`PROVIDER_BILLING`,_t=`PROVIDER_NOT_CONFIGURED`,vt=`MANAGED_KEY_INVALID`,yt=`credits_exhausted`,bt=`provider_billing`;function xt(e){return e?.errorCategory?e.errorCategory.endsWith(yt):e?.code===gt}function St(e){return e?.errorCategory?e.errorCategory.endsWith(bt):!1}function M(e){return xt(e)?`managed_credits`:St(e)?`provider_billing`:null}function N(e){return M(e)!==null||e?.code===_t||e?.displayAs===`modal`}function Ct(e){return!!e&&!N(e)}function wt(e){return e?.code===vt}var Tt={pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,pendingContactRequest:null,isSubmittingContactRequest:!1,contactRequestAccepted:!1,pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1,inlineConfirmationToolCallId:null,unknownNudgeToolCallIds:new Set},P=l(c()((e,t)=>({...Tt,showSecret:n=>{let{pendingSecret:r}=t();if(r&&r.requestId===n.requestId){let t={};for(let e of Object.keys(n))n[e]!==void 0&&(t[e]=n[e]);e({pendingSecret:{...r,...t}});return}e({pendingSecret:n,isSubmittingSecret:!1,secretSaved:!1})},submitSecretStart:()=>e({isSubmittingSecret:!0}),submitSecretEnd:t=>e({isSubmittingSecret:!1,secretSaved:t??!1}),dismissSecret:()=>e({pendingSecret:null,isSubmittingSecret:!1}),updateSecret:(n,r)=>{let{pendingSecret:i}=t();!i||i.requestId!==n||e({pendingSecret:{...i,...r}})},showConfirmation:t=>e({pendingConfirmation:t,isSubmittingConfirmation:!1}),submitConfirmationStart:()=>e({isSubmittingConfirmation:!0}),submitConfirmationEnd:()=>e({isSubmittingConfirmation:!1}),dismissConfirmation:()=>e({pendingConfirmation:null,isSubmittingConfirmation:!1}),dismissConfirmationIfMatches:n=>{let{pendingConfirmation:r}=t();!r||r.requestId!==n||e({pendingConfirmation:null,isSubmittingConfirmation:!1})},updateConfirmation:(n,r)=>{let{pendingConfirmation:i}=t();!i||i.requestId!==n||e({pendingConfirmation:{...i,...r}})},setInlineConfirmationToolCallId:t=>e({inlineConfirmationToolCallId:t}),showContactRequest:t=>e({pendingContactRequest:t,isSubmittingContactRequest:!1,contactRequestAccepted:!1}),submitContactRequestStart:()=>e({isSubmittingContactRequest:!0}),submitContactRequestEnd:()=>e({isSubmittingContactRequest:!1}),dismissContactRequest:()=>e({pendingContactRequest:null,isSubmittingContactRequest:!1}),acceptContactRequest:()=>e({contactRequestAccepted:!0}),showQuestion:t=>e({pendingQuestion:t,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),submitQuestionStart:()=>e({isSubmittingQuestion:!0}),submitQuestionEnd:()=>e({isSubmittingQuestion:!1}),dismissQuestion:()=>e({pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),dismissQuestionCard:()=>e({isQuestionCardDismissed:!0}),resetSecretAndConfirmation:()=>e({pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,inlineConfirmationToolCallId:null}),addUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;r.has(n)||e({unknownNudgeToolCallIds:new Set([...r,n])})},removeUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;if(!r.has(n))return;let i=new Set(r);i.delete(n),e({unknownNudgeToolCallIds:i})},resetAll:()=>e(Tt)})));function Et(e){if(e.length===0)return``;let t=e[0]??``;for(let n=1;n<e.length;n++){let r=t[t.length-1],i=e[n][0];r&&i&&r!==` `&&r!==`
3
- `&&r!==` `&&i!==` `&&i!==`
4
- `&&i!==` `&&(t+=` `),t+=e[n]}return t}function Dt(e){let t=[];for(let n of e?.contentBlocks??[])n.type===`text`&&t.push(n.text);return Et(t)}function Ot(e){if(!(!e||e.length===0))return e.map(e=>{let t=null;return e.data?t=`data:${e.mimeType};base64,${e.data}`:e.thumbnailData&&(t=`data:image/jpeg;base64,${e.thumbnailData}`),{id:e.id??e.filename,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes??(e.data?Math.floor(e.data.length*3/4):0),previewUrl:t}})}function F(e){let t=e[e.length-1];return!!t&&t.role===`assistant`}function kt(e,t){if(!t)return null;let n=e.length-1;for(;n>=0&&e[n].role===`user`&&e[n].queueStatus===`queued`;)n--;let r=e[n];return!r||r.role!==`assistant`?null:r.id}function I(e,t){return e.findIndex(e=>e.role===`assistant`&&(e.id===t||!!e.mergedMessageIds?.includes(t)))}function L(e,t){if(!t||e.id===t)return e;let n=e.mergedMessageIds??[];return n.includes(t)?e:{...e,mergedMessageIds:[...n,t]}}function R(e,t=Date.now()){if(!e.toolCalls?.some(e=>p(e)))return null;let n=t;return{toolCalls:e.toolCalls.map(e=>p(e)?{...e,completedAt:n}:e),contentBlocks:e.contentBlocks?.map(e=>e.type===`tool_use`&&p(e.toolCall)?{type:`tool_use`,toolCall:{...e.toolCall,completedAt:n}}:e)}}function At(e,t,n){return e.map(e=>e.id===t?{...e,queuePosition:n}:e)}function jt(e,t){return e.map(e=>e.id===t?{...e,queueStatus:void 0,queuePosition:void 0}:e)}function Mt(e,t){return e.filter(e=>e.id!==t)}function Nt(e,t,n,r=Date.now()){return[...e,{id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,textSegments:[t],contentOrder:[{type:`text`,id:`0`}],contentBlocks:[{type:`text`,text:t}],timestamp:r}]}function Pt(e,t,n){n&&e[e.length-1]?.type===t.type?e[e.length-1]=t:e.push(t)}function z(e,t,n,r){let i=L(e[t],r),a=[...i.textSegments??[]],o=[...i.contentOrder??[]],s=[...i.contentBlocks??[]],c=o[o.length-1]?.type===`text`&&a.length>0;c?a[a.length-1]=a[a.length-1]+n:(o.push({type:`text`,id:String(a.length)}),a.push(n)),Pt(s,{type:`text`,text:a[a.length-1]},c);let l=[...e];return l[t]={...i,textSegments:a,contentOrder:o,contentBlocks:s},l}function B(e,t,n,r){let i=L(e[t],r),a=[...i.thinkingSegments??[]],o=[...i.contentOrder??[]],s=[...i.contentBlocks??[]],c=o[o.length-1]?.type===`thinking`&&a.length>0;c?a[a.length-1]=a[a.length-1]+n:(o.push({type:`thinking`,id:String(a.length)}),a.push(n)),Pt(s,{type:`thinking`,thinking:a[a.length-1]},c);let l=[...e];return l[t]={...i,thinkingSegments:a,contentOrder:o,contentBlocks:s},l}function Ft(e,t,n,r,i=Date.now()){if(n){let a=I(e,n);if(a>=0)return z(e,a,t,n);if(F(e))return z(e,e.length-1,t,n);let o=r?.();return o?z([...e,o],e.length,t,n):Nt(e,t,n,i)}return F(e)?z(e,e.length-1,t,void 0):Nt(e,t,n,i)}function It(e,t,n,r=Date.now()){return[...e,{id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,thinkingSegments:[t],contentOrder:[{type:`thinking`,id:`0`}],contentBlocks:[{type:`thinking`,thinking:t}],timestamp:r}]}function Lt(e,t,n,r,i=Date.now()){if(n){let a=I(e,n);if(a>=0)return B(e,a,t,n);if(F(e))return B(e,e.length-1,t,n);let o=r?.();return o?B([...e,o],e.length,t,n):It(e,t,n,i)}return F(e)?B(e,e.length-1,t,void 0):It(e,t,n,i)}function Rt(e,t=Date.now()){let n=!1,r=e.map(e=>{if(e.role!==`assistant`)return e;let r=R(e,t);return r?(n=!0,{...e,...r}):e});return n?r:e}function zt(e,t,n=Date.now()){let r=e[e.length-1],i=Ot(t.attachments);if(r?.role!==`assistant`)return i?[...e,{id:t.messageId??crypto.randomUUID(),...t.messageId?{}:{isOptimistic:!0},role:`assistant`,timestamp:n,attachments:i}]:e;let a=R(r,n),o=r.isOptimistic===!0&&!!t.messageId;return[...e.slice(0,-1),{...r,...o?{id:t.messageId,isOptimistic:!1}:{},...i?{attachments:i}:{},...a??{}}]}function Bt(e,t){if(t!==void 0)return e.findIndex(e=>e.role===`user`&&e.clientMessageId===t);for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.role===`user`&&n.isOptimistic===!0)return t}return-1}function Vt(e,t,n=Date.now()){let r=t.messageId;if(r!==void 0&&e.some(e=>e.role===`user`&&(e.id===r||e.mergedMessageIds?.includes(r))))return e;let i=Bt(e,t.clientMessageId);if(i!==-1){if(r===void 0)return e;let t=[...e];return t[i]={...t[i],id:r,isOptimistic:!1,queueStatus:void 0,queuePosition:void 0},t}return[...e,{id:r??crypto.randomUUID(),...r===void 0?{isOptimistic:!0}:{},...t.clientMessageId?{clientMessageId:t.clientMessageId}:{},role:`user`,textSegments:[t.text],contentOrder:[{type:`text`,id:`0`}],contentBlocks:[{type:`text`,text:t.text}],timestamp:n}]}function Ht(e,t=Date.now()){let n=e.length-1,r=e[n];if(!r||r.role!==`assistant`)return e;let i=R(r,t);if(!(Dt(r).trim().length>0||r.thinkingSegments!=null&&r.thinkingSegments.length>0||r.toolCalls!=null&&r.toolCalls.length>0||r.surfaces!=null&&r.surfaces.length>0))return e.slice(0,-1);let a=[...e];return a[n]={...r,...i??{}},a}function V(e,t){let n=[...e??[]],r=n.findIndex(e=>e.type===`tool_use`&&e.toolCall.id===t.id);return r===-1?n.push({type:`tool_use`,toolCall:t}):n[r]={type:`tool_use`,toolCall:t},n}function H(e,t,n,r){let i=L(e[t],r),a=i.toolCalls?.findIndex(e=>e.id===n.id)??-1,o=[...e];if(a!==-1){let e=[...i.toolCalls??[]],r={...e[a],...n};return e[a]=r,o[t]={...i,toolCalls:e,contentBlocks:V(i.contentBlocks,r)},o}return o[t]={...i,toolCalls:[...i.toolCalls??[],n],contentOrder:[...i.contentOrder??[],{type:`toolCall`,id:n.id}],contentBlocks:V(i.contentBlocks,n)},o}function Ut(e,t,n,r=Date.now()){if(n){let r=I(e,n);if(r>=0)return H(e,r,t,n);if(F(e))return H(e,e.length-1,t,n)}else if(F(e))return H(e,e.length-1,t);return[...e,{id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,toolCalls:[t],contentOrder:[{type:`toolCall`,id:t.id}],contentBlocks:[{type:`tool_use`,toolCall:t}],timestamp:r}]}function Wt(e,t){let n=-1,r=-1;if(t.toolUseId)for(let i=e.length-1;i>=0;i--){let a=e[i];if(a?.role!==`assistant`||!a.toolCalls?.length)continue;let o=a.toolCalls.findIndex(e=>e.id===t.toolUseId);if(o!==-1){n=i,r=o;break}}if(n===-1){if(n=e.findLastIndex(e=>e.role===`assistant`&&e.toolCalls&&e.toolCalls.length>0),n===-1)return e;let t=e[n];if(!t?.toolCalls)return e;r=t.toolCalls.findLastIndex(e=>p(e))}if(r===-1)return e;let i=e[n],a=i.toolCalls[r];if(!a)return e;let o=t.imageDataList===void 0?t.imageData===void 0?void 0:[t.imageData]:t.imageDataList,s=t.imageData===void 0?o?.[0]:t.imageData,c=[...i.toolCalls],l={...a,result:t.result,isError:t.isError,riskLevel:t.riskLevel,riskReason:t.riskReason,matchedTrustRuleId:t.matchedTrustRuleId,approvalMode:t.approvalMode,approvalReason:t.approvalReason,riskThreshold:t.riskThreshold,riskAllowlistOptions:t.riskAllowlistOptions,riskScopeOptions:t.riskScopeOptions,riskDirectoryScopeOptions:t.riskDirectoryScopeOptions,...s===void 0?{}:{imageData:s},...o===void 0?{}:{imageDataList:o},...t.activityMetadata===void 0?{}:{activityMetadata:t.activityMetadata},completedAt:t.completedAt??Date.now(),streamedOutput:void 0};c[r]=l;let u=[...e];return u[n]={...i,toolCalls:c,contentBlocks:V(i.contentBlocks,l)},u}var Gt=16384;function Kt(e){return e.length<=16384?e:e.slice(e.length-Gt)}function qt(e,t){if(!t.chunk)return e;let n=-1,r=-1;if(t.toolUseId){if(t.messageId){let i=I(e,t.messageId);if(i>=0){let a=e[i].toolCalls?.findIndex(e=>e.id===t.toolUseId)??-1;a!==-1&&(n=i,r=a)}}if(n===-1)for(let i=e.length-1;i>=0;i--){let a=e[i];if(a?.role!==`assistant`||!a.toolCalls?.length)continue;let o=a.toolCalls.findIndex(e=>e.id===t.toolUseId);if(o!==-1){n=i,r=o;break}}}else{if(n=e.findLastIndex(e=>e.role===`assistant`&&e.toolCalls&&e.toolCalls.length>0),n===-1)return e;let t=e[n];if(!t?.toolCalls)return e;r=t.toolCalls.findLastIndex(e=>p(e))}if(n===-1||r===-1)return e;let i=e[n],a=i.toolCalls[r];if(!a)return e;let o={...a,streamedOutput:Kt((a.streamedOutput??``)+t.chunk)},s=[...i.toolCalls];s[r]=o;let c=[...e];return c[n]={...i,toolCalls:s,contentBlocks:V(i.contentBlocks,o)},c}function Jt(e,t,n,r=Date.now()){let i=-1;if(n&&(i=I(e,n)),i===-1){for(let t=e.length-1;t>=0;t--)if(e[t]?.role===`assistant`){i=t;break}}let a=[...e];if(i===-1)a.push({id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,surfaces:[t],contentOrder:[{type:`surface`,id:t.surfaceId}],contentBlocks:[{type:`surface`,surface:t}],timestamp:r});else{let r=L(e[i],n);if(r.contentOrder?.some(e=>e.type===`surface`&&e.id===t.surfaceId)||r.surfaces?.some(e=>e.surfaceId===t.surfaceId))return e;a[i]={...r,surfaces:[...r.surfaces??[],t],contentOrder:[...r.contentOrder??[],{type:`surface`,id:t.surfaceId}],contentBlocks:k(r.contentBlocks,t)}}return a}function Yt(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r],a=i.surfaces?.findIndex(e=>e.surfaceId===t)??-1;if(a===-1)continue;let o=i.surfaces[a],s={...o.data,...n};o.data.templateData&&n.templateData&&typeof o.data.templateData==`object`&&typeof n.templateData==`object`&&(s.templateData={...o.data.templateData,...n.templateData});let c={...o,data:s},l=[...e],u=[...i.surfaces];return u[a]=c,l[r]={...i,surfaces:u,contentBlocks:k(i.contentBlocks,c)},l}return e}function Xt(e,t){for(let n=e.length-1;n>=0;n--){if(!e[n].surfaces?.some(e=>e.surfaceId===t))continue;let r=[...e];return r[n]={...e[n],surfaces:e[n].surfaces?.filter(e=>e.surfaceId!==t),contentOrder:e[n].contentOrder?.filter(e=>!(e.type===`surface`&&e.id===t)),contentBlocks:at(e[n].contentBlocks,t)},r}return e}function Zt(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r].surfaces?.find(e=>e.surfaceId===t);if(!i)continue;let a={...i,completed:!0,completionSummary:n},o=[...e];return o[r]={...e[r],surfaces:e[r].surfaces?.map(e=>e.surfaceId===t?a:e),contentBlocks:k(e[r].contentBlocks,a)},o}return e}var Qt=[`choice`,`oauth_connect`,`form`,`confirmation`,`file_upload`,`card`,`list`,`table`,`browser_view`,`task_preferences`];function $t(e){return e==null||e.hasPendingConfirmation||e.hasUncompletedVisibleSurface}function en(e,t){let n=!1,r=e.map(e=>{let r=se(e,e=>e.pendingConfirmation?.requestId===t?{...e,pendingConfirmation:void 0}:e);return r!==e&&(n=!0),r});return n?r:e}function tn(e){let t=!1,n=e.map(e=>{let n=se(e,e=>e.pendingConfirmation?{...e,pendingConfirmation:void 0}:e);return n!==e&&(t=!0),n});return t?n:e}function nn(e,t){let n=new Set;for(let e of t)if(e.surfaces)for(let t of e.surfaces)ce(t)&&n.add(t.surfaceId);return n.size===0?{updatedMessages:e,dismissedIds:n}:{updatedMessages:e.map(e=>st(e,e=>!n.has(e.surfaceId))),dismissedIds:n}}function rn(e,t,n,r){for(let i=e.length-1;i>=0;i--){let a=e[i].surfaces?.find(e=>e.surfaceId===t);if(!a)continue;if(!Qt.includes(a.surfaceType))return e;let o=a.actions?.find(e=>e.id===n),s=n===`cancel`||n===`dismiss`||o?.style===`secondary`,c=[...e];return c[i]=ot(e[i],e=>e.surfaceId===t?{...e,completed:!0,completionSummary:s?`Cancelled`:r??o?.label??void 0}:e),c}return e}function an(e,t,n){return e&&oe[e]||t||n}function U(e){return typeof e==`string`?e:void 0}function on(e){return typeof e==`boolean`?e:void 0}function sn(e){return Array.isArray(e)?e:void 0}function cn(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function W(e){return Array.isArray(e)?e:void 0}function ln(e){return{requestId:typeof e.requestId==`string`?e.requestId:``,label:U(e.label),service:U(e.service),field:U(e.field),description:U(e.description),placeholder:U(e.placeholder),allowOneTimeSend:on(e.allowOneTimeSend),allowedTools:sn(e.allowedTools),allowedDomains:sn(e.allowedDomains),purpose:U(e.purpose)}}function un(e){let t={requestId:typeof e.requestId==`string`?e.requestId:``,title:U(e.title),description:U(e.description),toolName:U(e.toolName),riskLevel:U(e.riskLevel),riskReason:U(e.riskReason),allowlistOptions:W(e.allowlistOptions),scopeOptions:W(e.scopeOptions),directoryScopeOptions:W(e.directoryScopeOptions),persistentDecisionsAllowed:on(e.persistentDecisionsAllowed),input:cn(e.input),toolUseId:U(e.toolUseId)};return{confData:t,state:{...t,confirmLabel:U(e.confirmLabel),denyLabel:U(e.denyLabel)}}}function dn(){return`turn-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function fn(e,t){let n=Date.parse(e);return Number.isFinite(n)?n:typeof t==`number`?t:0}function pn(e,t,n){switch(t.type){case`assistant_text_delta`:return Ft(e,t.text,t.messageId,void 0,n);case`assistant_thinking_delta`:return Lt(e,t.thinking,t.messageId,void 0,n);case`message_complete`:return zt(e,t,n);case`user_message_echo`:return Vt(e,{text:t.text,messageId:t.messageId,clientMessageId:t.clientMessageId},n);case`assistant_activity_state`:return t.phase===`idle`?Rt(e,n):e;case`conversation_error`:return Ht(e,n);case`tool_use_preview_start`:return Ut(e,{id:t.toolUseId,name:t.toolName,input:{},previewStartedAt:typeof t.previewStartedAt==`number`?t.previewStartedAt:n},t.messageId,n);case`tool_use_start`:return Ut(e,{id:t.toolUseId??`tool-${n}`,name:t.toolName,input:t.input,startedAt:`startedAt`in t&&typeof t.startedAt==`number`?t.startedAt:n,...`previewStartedAt`in t&&typeof t.previewStartedAt==`number`?{previewStartedAt:t.previewStartedAt}:{}},t.messageId,n);case`tool_result`:return Wt(e,{toolUseId:t.toolUseId,result:t.result,isError:t.isError,riskLevel:t.riskLevel,riskReason:t.riskReason,matchedTrustRuleId:t.matchedTrustRuleId,approvalMode:t.approvalMode,approvalReason:t.approvalReason,riskThreshold:t.riskThreshold,riskAllowlistOptions:t.riskAllowlistOptions,riskScopeOptions:t.riskScopeOptions,riskDirectoryScopeOptions:t.riskDirectoryScopeOptions,imageData:t.imageData,imageDataList:t.imageDataList,activityMetadata:t.activityMetadata,completedAt:`completedAt`in t&&typeof t.completedAt==`number`?t.completedAt:n});case`tool_output_chunk`:return t.chunk?qt(e,{chunk:t.chunk,toolUseId:t.toolUseId,messageId:t.messageId}):e;case`ui_surface_show`:{let r={surfaceId:t.surfaceId,surfaceType:t.surfaceType,title:t.title,data:t.data,actions:t.actions,display:t.display};return r.display=ie(r),Jt(e,r,t.messageId,n)}case`ui_surface_update`:return Yt(e,t.surfaceId,t.data);case`ui_surface_dismiss`:return Xt(e,t.surfaceId);case`ui_surface_complete`:return Zt(e,t.surfaceId,t.summary);case`confirmation_request`:return ae(e,{requestId:t.requestId,toolName:t.toolName,riskLevel:t.riskLevel,riskReason:t.riskReason,allowlistOptions:t.allowlistOptions,scopeOptions:t.scopeOptions,directoryScopeOptions:t.directoryScopeOptions,persistentDecisionsAllowed:t.persistentDecisionsAllowed,input:t.input,toolUseId:t.toolUseId}).updatedMessages;case`interaction_resolved`:return t.kind===`confirmation`||t.kind===`acp_confirmation`?en(e,t.requestId):e;default:return e}}function mn(e,t,n){if(e!==void 0){if(typeof n!=`number`)return e;switch(t.type){case`assistant_turn_start`:case`assistant_text_delta`:case`assistant_thinking_delta`:return!0;case`assistant_activity_state`:return t.phase!==`idle`;case`message_complete`:return!1;default:return e}}}function hn(e,t){let{seq:n}=t;if(typeof n==`number`&&typeof e.seq==`number`&&n<=e.seq)return e;let r=fn(t.emittedAt,n),i=pn(e.messages,t.message,r),a=typeof n==`number`?Math.max(e.seq??-1,n):e.seq??null,o=mn(e.processing,t.message,n);return{...e,messages:i,seq:a,processing:o}}function gn(e,t){return t.reduce(hn,e)}function _n(e,t){return t===null?e:gn(e,t)}function vn(e){return[...new Set([e.id,...e.mergedMessageIds??[]].filter(e=>typeof e==`string`&&e.length>0))]}function G(e){let t=vn(e);return e.clientMessageId&&!t.includes(e.clientMessageId)?[...t,e.clientMessageId]:t}var yn={hasMore:!1,oldestTimestamp:null,isLoadingOlder:!1};function bn(){return{snapshot:null,optimisticSends:[],error:null,notice:null,isLoadingHistory:!0,transcriptPagination:{...yn},contextWindowUsage:null,ephemeralMetaResults:[],compactionCircuitOpenUntil:null,dismissedSurfaceIds:new Set,streamingMessageIds:new Set,pendingQueuedMessageIds:[],requestIdToMessageId:new Map,pendingLocalDeletions:new Set,confirmationToolCallMap:new Map,expandedToolCallIds:new Set,expandedCardIds:new Map,contextWindowUsageByConversation:new Map,previousConversationId:null,previousAssistantId:null,draftConversationIdResolution:!1}}function K(e,t){return typeof t==`function`?t(e):t}function xn(e,t){if(e.length===0)return e;let n=new Map;for(let e of t)for(let t of G(e))n.has(t)||n.set(t,e);let r=e.filter(e=>{let t;for(let r of G(e))if(t=n.get(r),t)break;return t?!!e.attachments?.length&&!t.attachments?.length:!0});return r.length===e.length?e:r}var q=l(c()((e,t)=>({...bn(),seedSnapshot:(t,n)=>{let r=_n(n,we(t,n.seq??null));e(e=>({snapshot:r,optimisticSends:xn(e.optimisticSends,r.messages)}))},applyEnvelopeToSnapshot:t=>e(e=>e.snapshot?{snapshot:hn(e.snapshot,t)}:{}),addOptimisticSend:t=>e(e=>({optimisticSends:[...e.optimisticSends,t]})),setOptimisticSends:t=>e(e=>({optimisticSends:K(e.optimisticSends,t)})),patchSnapshotMessages:t=>e(e=>e.snapshot?{snapshot:{...e.snapshot,messages:t(e.snapshot.messages)}}:{}),setError:t=>e(e=>({error:K(e.error,t)})),setNotice:t=>e(e=>({notice:K(e.notice,t)})),setIsLoadingHistory:t=>e({isLoadingHistory:t}),setTranscriptPagination:t=>e(e=>({transcriptPagination:K(e.transcriptPagination,t)})),setContextWindowUsage:t=>e(e=>({contextWindowUsage:K(e.contextWindowUsage,t)})),setCompactionCircuitOpenUntil:t=>e(e=>({compactionCircuitOpenUntil:K(e.compactionCircuitOpenUntil,t)})),switchToConversation:({assistantId:n,activeConversationId:r})=>{let i=t();if(i.draftConversationIdResolution){e({draftConversationIdResolution:!1});return}let a=i.previousConversationId;if(a&&a!==r&&a){let e=P.getState();(e.pendingSecret||e.pendingConfirmation)&&re.getState().addAttentionConversationId(a)}let o=i.previousAssistantId!==null&&i.previousAssistantId!==n,s=o||i.previousAssistantId===null;te(`conversation_switch_reset`,{assistantId:n,conversationId:r,outgoingConversationId:a??null}),O.getState().handleConversationSwitch({previousKey:a??null,nextKey:r}),Ae.getState().resetTurn(),P.getState().resetAll(),o?O.getState().fullReset():O.getState().resetAttachments();let c=s?mt(n):i.contextWindowUsageByConversation;e({snapshot:null,optimisticSends:[],ephemeralMetaResults:[],error:N(i.error)?i.error:null,notice:null,isLoadingHistory:!0,transcriptPagination:{...yn},contextWindowUsage:c.get(r)??null,compactionCircuitOpenUntil:null,dismissedSurfaceIds:ct(n,r),streamingMessageIds:new Set,pendingQueuedMessageIds:[],requestIdToMessageId:new Map,pendingLocalDeletions:new Set,confirmationToolCallMap:new Map,expandedToolCallIds:new Set,expandedCardIds:new Map,contextWindowUsageByConversation:c,previousConversationId:r,previousAssistantId:n,draftConversationIdResolution:!1})},markDraftResolution:()=>e({draftConversationIdResolution:!0}),setConfirmationToolCall:(t,n)=>e(e=>{let r=new Map(e.confirmationToolCallMap);return r.set(t,n),{confirmationToolCallMap:r}}),deleteConfirmationToolCall:t=>e(e=>{let n=new Map(e.confirmationToolCallMap);return n.delete(t),{confirmationToolCallMap:n}}),clearConfirmationToolCallMap:()=>e({confirmationToolCallMap:new Map}),addDismissedSurfaceId:t=>e(e=>{let n=new Set(e.dismissedSurfaceIds);return n.add(t),{dismissedSurfaceIds:n}}),addDismissedSurfaceIds:t=>e(e=>{let n=new Set(e.dismissedSurfaceIds);for(let e of t)n.add(e);return{dismissedSurfaceIds:n}}),batchUpdateStreamingMessageIds:(t,n)=>e(e=>{let r=new Set(e.streamingMessageIds);for(let e of t)r.add(e);for(let e of n)r.delete(e);return{streamingMessageIds:r}}),pushPendingQueuedMessageId:t=>e(e=>({pendingQueuedMessageIds:[...e.pendingQueuedMessageIds,t]})),shiftPendingQueuedMessageId:()=>{let n=t().pendingQueuedMessageIds;if(n.length===0)return;let[r,...i]=n;return e({pendingQueuedMessageIds:i}),r},setRequestIdMapping:(t,n)=>e(e=>{let r=new Map(e.requestIdToMessageId);return r.set(t,n),{requestIdToMessageId:r}}),popRequestIdMapping:n=>{let r=t().requestIdToMessageId,i=r.get(n);if(i!==void 0){let t=new Map(r);t.delete(n),e({requestIdToMessageId:t})}return i},addPendingLocalDeletion:t=>e(e=>{let n=new Set(e.pendingLocalDeletions);return n.add(t),{pendingLocalDeletions:n}}),consumePendingLocalDeletion:n=>{let r=t().pendingLocalDeletions;if(!r.has(n))return!1;let i=new Set(r);return i.delete(n),e({pendingLocalDeletions:i}),!0},setExpandedToolCallId:(t,n)=>e(e=>{let r=new Set(e.expandedToolCallIds);return n?r.add(t):r.delete(t),{expandedToolCallIds:r}}),setExpandedCardId:(t,n)=>e(e=>{let r=new Map(e.expandedCardIds);return r.set(t,n),{expandedCardIds:r}}),setContextWindowUsageForConversation:(t,n)=>e(e=>{let r=new Map(e.contextWindowUsageByConversation);return r.set(t,n),{contextWindowUsageByConversation:r}}),addEphemeralMetaResult:t=>e(e=>({ephemeralMetaResults:[...e.ephemeralMetaResults,t]})),clearEphemeralMetaResults:()=>e(e=>e.ephemeralMetaResults.length===0?e:{ephemeralMetaResults:[]})})));function Sn(e,t){if(t.length===0)return e;let n=new Map;for(let e of t)for(let t of G(e))n.has(t)||n.set(t,e);let r=[],i=new Set;for(let t of e){let e;for(let r of G(t)){let t=n.get(r);if(t){e=t;break}}if(e){i.has(e)||(r.push(e),i.add(e));continue}r.push(t)}for(let e of t)i.has(e)||r.push(e);return r}function Cn(){let e=q.use.snapshot(),t=q.use.optimisticSends(),n=q.use.dismissedSurfaceIds();return(0,me.useMemo)(()=>Sn(dt(e?.messages,n),t),[e,t,n])}function J(e,t,n=`…`){return e.length<=t?e:e.slice(0,t-n.length)+n}function wn(e){if(!e)return null;let t=e.split(`/`),n=t[t.length-1];return!n||n===`.`?null:n}function Y(e,t){return J(e,t,`...`)}function Tn(e){if(!e)return null;let t=e.replace(/\s+/g,` `).trim().match(/(?:^|&&\s*|\|\|\s*|;\s*)(?:\S*\/)?assistant\s+browser\s+([^\s;&|]+)/i);if(!t)return null;let n=t[1].toLowerCase();return new Set([`navigate`,`click`,`type`,`screenshot`,`snapshot`,`scroll`,`hover`,`select`,`drag`,`wait`,`back`,`forward`,`refresh`,`close`,`tab`,`press_key`,`wait_for`,`extract`,`fill_credential`]).has(n)?n:`unknown`}function X(e,t){let n=e.toLowerCase();return n!==`bash`&&n!==`host_bash`?null:Tn(t)}function En(e){switch(e){case`navigate`:return`Opened a page`;case`click`:return`Clicked on the page`;case`type`:return`Typed on the page`;case`screenshot`:return`Took a screenshot`;case`snapshot`:return`Captured page snapshot`;case`scroll`:return`Scrolled the page`;case`hover`:return`Hovered on the page`;case`select`:return`Selected on the page`;case`drag`:return`Dragged on the page`;case`wait`:return`Waited for the page`;case`back`:return`Went back`;case`forward`:return`Went forward`;case`refresh`:return`Refreshed the page`;case`close`:return`Closed the tab`;case`tab`:return`Switched tabs`;case`press_key`:return`Pressed a key`;case`wait_for`:return`Waited for a condition`;case`extract`:return`Extracted page content`;case`fill_credential`:return`Filled a credential`;case`unknown`:return`Used the browser`}}function Dn(e){switch(e){case`navigate`:return`Opening a page`;case`click`:return`Clicking on the page`;case`type`:return`Typing on the page`;case`screenshot`:return`Taking a screenshot`;case`snapshot`:return`Capturing page snapshot`;case`scroll`:return`Scrolling the page`;case`hover`:return`Hovering on the page`;case`select`:return`Selecting on the page`;case`drag`:return`Dragging on the page`;case`wait`:return`Waiting for the page`;case`back`:return`Going back`;case`forward`:return`Going forward`;case`refresh`:return`Refreshing the page`;case`close`:return`Closing the tab`;case`tab`:return`Switching tabs`;case`press_key`:return`Pressing a key`;case`wait_for`:return`Waiting for a condition`;case`extract`:return`Extracting page content`;case`fill_credential`:return`Filling a credential`;case`unknown`:return`Using the browser`}}function On(e){switch(e){case`navigate`:case`back`:case`forward`:case`tab`:return`compass`;case`click`:case`hover`:case`select`:case`drag`:case`scroll`:return`compass`;case`screenshot`:case`snapshot`:return`camera`;case`type`:case`press_key`:case`fill_credential`:return`compass`;case`wait`:case`wait_for`:case`refresh`:case`close`:return`compass`;case`extract`:return`compass`;case`unknown`:return`compass`}}function kn(e,t){let n=e.toLowerCase();if(n===`bash`||n===`host_bash`){let e=t.command??t.cmd;if(typeof e==`string`)return e.replace(/\s+/g,` `).trim()}if(n===`file_read`||n===`host_file_read`||n===`file_write`||n===`host_file_write`||n===`file_edit`||n===`host_file_edit`){let e=t.file_path??t.path??t.filePath;if(typeof e==`string`)return e}if(n===`grep`||n===`glob`){let e=t.pattern??t.query;if(typeof e==`string`)return e}if(n===`web_search`){let e=t.query??t.search;if(typeof e==`string`)return e}return``}function An(e,t=``){let n=e.toLowerCase(),r=t.replace(/\s+/g,` `).trim(),i=wn(r),a=X(e,r);if(a)return En(a);switch(n){case`bash`:case`host_bash`:return r?`Ran \`${Y(r,30)}\``:`Ran a command`;case`file_read`:case`host_file_read`:return i?`Read ${i}`:`Read a file`;case`file_write`:case`host_file_write`:return i?`Wrote ${i}`:`Wrote a file`;case`file_edit`:case`host_file_edit`:return i?`Edited ${i}`:`Edited a file`;case`grep`:return r?`Searched for '${Y(r,25)}'`:`Searched files`;case`glob`:return r?`Searched for ${Y(r,25)}`:`Found files`;case`web_search`:return r?`Searched '${Y(r,25)}'`:`Searched the web`;case`web_fetch`:return`Fetched a webpage`;default:return`Used ${e.replace(/_/g,` `)}`}}function jn(e,t=``,n){let r=X(e,t);if(r)return Dn(r);if(n){let t=e.toLowerCase();if(t===`app_create`||t===`app_refresh`||t===`app_update`)return n}switch(e.toLowerCase()){case`bash`:case`host_bash`:return`Running a command`;case`file_read`:case`host_file_read`:return`Reading a file`;case`file_write`:case`host_file_write`:return`Writing a file`;case`file_edit`:case`host_file_edit`:return`Editing a file`;case`grep`:return`Searching files`;case`glob`:return`Finding files`;case`web_search`:return`Searching the web`;case`web_fetch`:return`Fetching a webpage`;case`app_create`:return`Building your app`;case`app_refresh`:case`app_update`:return`Refreshing your app`;default:return`Running ${e.replace(/_/g,` `)}`}}function Mn(e){return e.split(/[_-]+/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function Nn(e,t=``){let n=X(e,t);if(n)return On(n);switch(e.toLowerCase()){case`bash`:case`host_bash`:return`terminal`;case`file_read`:case`host_file_read`:return`file-text`;case`file_write`:case`host_file_write`:return`file-plus`;case`file_edit`:case`host_file_edit`:return`pencil`;case`grep`:case`glob`:case`web_search`:return`search`;case`web_fetch`:return`globe`;default:return`wrench`}}var Pn=80;function Z(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim().length>0)return t}return``}function Fn(e){if(!e)return``;let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n===-1?t:t.slice(n+1)}function In(e){if(!e.startsWith(`mcp__`))return null;let t=e.slice(5),n=t.indexOf(`__`);if(n===-1)return null;let r=t.slice(0,n),i=t.slice(n+2);return!r||!i?null:{serverName:r,toolMethod:i}}function Q(e,t){let n=t&&typeof t==`object`?t:{},r=e.toLowerCase(),i=Z(n,`activity`,`reason`),a=In(e);if(a)return{title:`Using ${a.serverName}`,info:a.toolMethod,activity:i,iconName:`plug`};switch(r){case`bash`:case`host_bash`:return{title:`Working`,info:J(Z(n,`command`,`cmd`).replace(/\s+/g,` `).trim(),Pn),activity:i,iconName:`terminal`};case`str_replace_editor`:case`text_editor`:{let e=Z(n,`command`).toLowerCase(),t=Fn(Z(n,`path`,`file_path`,`filePath`));return e===`view`?{title:`Reading`,info:t,activity:i,iconName:`file`}:{title:`Editing`,info:t,activity:i,iconName:`pen`}}case`computer`:return{title:`Using computer`,info:Z(n,`action`),activity:i,iconName:`monitor`};case`skill_execute`:{let e=Z(n,`tool`);if(e){let t=n.input,r=Q(e,t);return{...r,activity:i||r.activity}}return{title:`Using a skill`,info:Z(n,`skill`,`name`,`skillName`),activity:i,iconName:`sparkle`}}case`skill`:case`skill_invoke`:case`skill_load`:return{title:`Using a skill`,info:Z(n,`skill`,`name`,`skillName`),activity:i,iconName:`sparkle`};case`subagent_spawn`:return{title:`Spawning subagent`,info:Z(n,`label`,`objective`,`task`),activity:i,iconName:`user-plus`};default:return{title:e?`Running ${Mn(e)}`:`Running tool`,info:``,activity:i,iconName:`bolt`}}}function Ln(e){return Q(e.name,e.input)}var Rn=[{open:`<thinking>`,close:`</thinking>`},{open:`<think>`,close:`</think>`}];function zn(e){return Rn.some(t=>e.includes(t.open))}function Bn(e){if(!zn(e))return null;let t=[],n=e=>{e.trim()&&t.push({type:`text`,text:e})},r=e=>{let n=e.trim();n&&t.push({type:`thinking`,thinking:n})},i=0;for(;;){let a=-1,o;for(let t of Rn){let n=e.indexOf(t.open,i);n!==-1&&(a===-1||n<a)&&(a=n,o=t)}if(!o)break;n(e.slice(i,a));let s=a+o.open.length,c=e.indexOf(o.close,s);if(c===-1)return r(e.slice(s)),t;r(e.slice(s,c)),i=c+o.close.length}return n(e.slice(i)),t}function Vn(e){return typeof e.id==`string`&&e.id.length>0}function Hn(e){return e.some(e=>e.type===`text`&&zn(e.text))?e.flatMap(e=>{let t=e.type===`text`?Bn(e.text):null;return t?t.map(e=>e.type===`thinking`?{type:`thinking`,thinking:e.thinking}:{type:`text`,text:e.text}):[e]}):e}function Un(e,t){let n=t?.splitInlineThinking?Hn(e):e,r=[],i=null,a=()=>(i||(i={type:`activity`,items:[]},r.push(i)),i);for(let e of n)if(e.type===`thinking`){let t=a(),n=t.items[t.items.length-1];n?.type===`thinking`?(n.thinking=n.thinking?`${n.thinking}\n${e.thinking}`:e.thinking,e.startedAt!=null&&(n.startedAt=n.startedAt==null?e.startedAt:Math.min(n.startedAt,e.startedAt)),e.completedAt!=null&&(n.completedAt=n.completedAt==null?e.completedAt:Math.max(n.completedAt,e.completedAt))):t.items.push({type:`thinking`,thinking:e.thinking,startedAt:e.startedAt,completedAt:e.completedAt})}else if(e.type===`tool_use`){if(!Vn(e.toolCall))continue;a().items.push({type:`tool_use`,toolCall:e.toolCall})}else (e.type===`text`||e.type===`surface`)&&(i=null,r.push(e));return r}function Wn(e){return!e.pendingConfirmation&&(e.name===`ui_show`||e.name===`ui_update`||e.name===`ui_dismiss`)}function Gn(e){if(e.name===`subagent_spawn`)return!0;if(e.name!==`skill_execute`)return!1;let t=e.input;return typeof t!=`object`||!t?!1:t.tool===`subagent_spawn`}function Kn(e){if(e.name===`run_workflow`)return!0;if(e.name!==`skill_execute`)return!1;let t=e.input;return typeof t!=`object`||!t?!1:t.tool===`run_workflow`}function qn(e){if(e.name===`acp_spawn`)return!0;if(e.name!==`skill_execute`)return!1;let t=e.input;return typeof t!=`object`||!t?!1:t.tool===`acp_spawn`}function Jn(e){if(e.name!==`bash`&&e.name!==`host_bash`)return!1;let t=e.input;return typeof t!=`object`||!t?!1:t.background===!0}var Yn=new Set([`low`,`medium`,`high`]);function Xn(e){let t=e?.toLowerCase();return t&&Yn.has(t)?t:`medium`}function Zn(e){switch(e?.toLowerCase()){case`low`:return{bg:`bg-[var(--system-positive-strong)]`,text:`text-white`,label:`Low`};case`medium`:return{bg:`bg-[var(--system-mid-strong)]`,text:`text-black`,label:`Medium`};case`high`:return{bg:`bg-[var(--system-negative-strong)]`,text:`text-white`,label:`High`};case`workspace`:return{bg:`bg-[var(--surface-lift)]`,text:`text-[var(--content-secondary)]`,border:`border border-[var(--border-element)]`,label:`Workspace`};default:return{bg:`bg-[var(--content-secondary)]`,text:`text-white`,label:e??`Unknown`}}}function Qn(e){switch(e?.toLowerCase()){case`low`:return{bg:`bg-[var(--system-positive-weak)]`,text:`text-[var(--system-positive-strong)]`,label:`Low`};case`medium`:return{bg:`bg-[var(--system-mid-weak)]`,text:`text-[var(--system-mid-strong)]`,label:`Medium`};case`high`:return{bg:`bg-[var(--system-negative-weak)]`,text:`text-[var(--system-negative-strong)]`,label:`High`};case`workspace`:return{bg:`bg-[var(--surface-lift)]`,text:`text-[var(--content-secondary)]`,label:`Workspace`};default:return{bg:`bg-[var(--surface-lift)]`,text:`text-[var(--content-secondary)]`,label:e?e.charAt(0).toUpperCase()+e.slice(1):`Unknown`}}}var $n={unknown:2,low:0,medium:1,high:2},er={none:-1,low:0,medium:1,high:2};function tr(e,t,n){return e?.toLowerCase()!==`auto`||!n?!0:($n[(t??``).toLowerCase()]??-1)<=(er[n.toLowerCase()]??-1)}function nr(e){switch(e){case`trust_rule_allowed`:return`· Auto-approved · Trust rule matched`;case`sandbox_auto_approve`:return null;case`platform_auto_approve`:return`· Auto-approved · Platform session`;default:return null}}function rr(e,t){return e===`sandbox_auto_approve`?{displayLevel:`workspace`,inherentRisk:t}:{displayLevel:t??`unknown`}}var $=o();function ir({level:e,className:t,onClick:n}){if(!e)return null;let{bg:r,text:i,label:a}=Qn(e),o=le(`inline-flex items-center justify-center rounded-[100px] px-[6px] pt-[2px] pb-[3px]`,r,t);return n?(0,$.jsx)(`button`,{type:`button`,"data-testid":`risk-badge`,"data-risk-level":e,className:le(o,`cursor-pointer hover:opacity-80`),onClick:e=>{e.stopPropagation(),n()},children:(0,$.jsx)(s,{variant:`label-medium-default`,className:i,children:a})}):(0,$.jsx)(`span`,{"data-testid":`risk-badge`,"data-risk-level":e,className:o,children:(0,$.jsx)(s,{variant:`label-medium-default`,className:i,children:a})})}function ar({Glyph:e,icon:t,title:n,headerTrailing:r,headerActions:a,closeLabel:o=`Close panel`,closeVariant:c=`ghost`,onClose:l,children:u}){return(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden rounded-xl bg-[var(--surface-lift)]`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] px-5 py-4`,children:[t??(e?(0,$.jsx)(e,{className:`h-5 w-5 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}):null),(0,$.jsx)(s,{variant:`title-medium`,className:`min-w-0 shrink truncate py-0.5 leading-snug text-[var(--content-default)]`,children:n}),r,(0,$.jsx)(`span`,{className:`flex-1`}),a,(0,$.jsx)(i,{variant:c===`outlined`?`outlined`:`ghost`,iconOnly:(0,$.jsx)(d,{}),onClick:l,"aria-label":o,tooltip:`Close`,className:`shrink-0${c===`outlined`?` rounded-lg`:``}`})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-5`,children:u})]})}export{O as $,nn as A,F as B,Sn as C,en as D,G as E,$t as F,Ct as G,P as H,jt as I,lt as J,N as K,kt as L,un as M,ln as N,tn as O,an as P,tt as Q,Mt as R,Cn as S,vn as T,M as U,Dt as V,wt as W,it as X,ot as Y,nt as Z,jn as _,Zn as a,Te as at,Mn as b,Un as c,ye as ct,Kn as d,ve as dt,Ke as et,Gn as f,pe as ft,kn as g,Q as h,ue as ht,nr as i,Ae as it,dn as j,rn as k,qn as l,xe as lt,Ln as m,de as mt,ir as n,Oe as nt,Xn as o,Se as ot,Wn as p,fe as pt,ht as q,rr as r,ke as rt,tr as s,Ce as st,ar as t,x as tt,Jn as u,be as ut,Nn as v,q as w,J as x,An as y,At as z};