@vellumai/web 0.10.11-staging.1 → 0.10.11

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 (84) hide show
  1. package/dist/assets/{account-page-CGxN4FMB.js → account-page-baxQRPzp.js} +1 -1
  2. package/dist/assets/{acp-run-detail-panel-zoCY9fdY.js → acp-run-detail-panel-CrZYAG8F.js} +1 -1
  3. package/dist/assets/{activity-steps-panel-CmBQQebr.js → activity-steps-panel-CNHBFP0M.js} +1 -1
  4. package/dist/assets/{add-credits-modal-UyqhEjtA.js → add-credits-modal-C6ACa7dJ.js} +1 -1
  5. package/dist/assets/{ai-page-CiXDPar3.js → ai-page-DWwijgkF.js} +1 -1
  6. package/dist/assets/{api-key-screen-Bj2ar1dh.js → api-key-screen-BEJ0jwQj.js} +1 -1
  7. package/dist/assets/{background-task-detail-panel-Ceccab-p.js → background-task-detail-panel-be-t1c4C.js} +1 -1
  8. package/dist/assets/{billing-page-ChU757Bq.js → billing-page-BcRCl8ly.js} +1 -1
  9. package/dist/assets/{bookmarks-page-CVao8uzP.js → bookmarks-page-Dit38fI8.js} +1 -1
  10. package/dist/assets/{channels-page-route-ThCDtS-m.js → channels-page-route-BlSQtnuj.js} +1 -1
  11. package/dist/assets/{command-palette-fZ-DYpTl.js → command-palette-BCipBcvn.js} +1 -1
  12. package/dist/assets/{command-palette-window-page-jACRTws1.js → command-palette-window-page-BqYv7VcH.js} +1 -1
  13. package/dist/assets/{community-page-BKMT2nGi.js → community-page-Dv-ySbbM.js} +1 -1
  14. package/dist/assets/{contacts-page-route-429brUkX.js → contacts-page-route-DgNLQnBu.js} +1 -1
  15. package/dist/assets/{credentials-page-BRYdZPLW.js → credentials-page-Cc4tHUkB.js} +1 -1
  16. package/dist/assets/{debug-page-dgwTiWS_.js → debug-page-BFWROcsz.js} +1 -1
  17. package/dist/assets/{deploy-dialogs-CzNMZxp5.js → deploy-dialogs-Cj-Aq_TC.js} +1 -1
  18. package/dist/assets/{detail-panel-stop-button-BDxTkocG.js → detail-panel-stop-button-39zLlSig.js} +1 -1
  19. package/dist/assets/{developer-page-CiMYzKyb.js → developer-page-DuvYjoYj.js} +1 -1
  20. package/dist/assets/{dictation-overlay-page-q89WquJV.js → dictation-overlay-page-DXgz4AQ6.js} +1 -1
  21. package/dist/assets/{document-viewer-page-BTdqnb-W.js → document-viewer-page-CZwiaFH_.js} +1 -1
  22. package/dist/assets/{emails-page-DnChFgts.js → emails-page-B-d8kujE.js} +1 -1
  23. package/dist/assets/{general-page-8T5d4hdF.js → general-page-CmA6p9An.js} +1 -1
  24. package/dist/assets/{hatching-screen-CKXaloYL.js → hatching-screen-XNHr8o2G.js} +1 -1
  25. package/dist/assets/{home-page-route-CUHZxuiS.js → home-page-route-CuxIigyf.js} +1 -1
  26. package/dist/assets/{hosting-screen-DvbjTPb9.js → hosting-screen-DefYV0ge.js} +1 -1
  27. package/dist/assets/identity-page-route-CiL_Zphi.js +7 -0
  28. package/dist/assets/{index-D7_9Qy0L.js → index-2np2R8qP.js} +26 -26
  29. package/dist/assets/{index-C0vMCzOO.css → index-B92kvb9E.css} +1 -1
  30. package/dist/assets/{inspect-page-CjOJXOkP.js → inspect-page-kRK_xs6g.js} +1 -1
  31. package/dist/assets/{integrations-page-33TSVQvc.js → integrations-page-CISSOSzb.js} +1 -1
  32. package/dist/assets/{intelligence-layout-DXqwl75M.js → intelligence-layout-DpgeQgJY.js} +1 -1
  33. package/dist/assets/{library-detail-page-CbtWUL71.js → library-detail-page-Bt9gp3QI.js} +1 -1
  34. package/dist/assets/{library-page-B0se5Aoa.js → library-page-BlNKrPkk.js} +1 -1
  35. package/dist/assets/{logout-page-l46o01fc.js → logout-page-Iz2ybEnD.js} +1 -1
  36. package/dist/assets/{logs-layout-BKW_V70e.js → logs-layout-CxOA-Wc5.js} +1 -1
  37. package/dist/assets/{memory-page-route-w5t6GZVV.js → memory-page-route-CPsBSRih.js} +1 -1
  38. package/dist/assets/{memory-router-playground-page-B9lQcT7J.js → memory-router-playground-page-B12rXqZf.js} +1 -1
  39. package/dist/assets/{mobile-sidebar-drawer-BNR5lCRm.js → mobile-sidebar-drawer-ZUf-00kg.js} +1 -1
  40. package/dist/assets/{notifications-page-BkxAhZI8.js → notifications-page-CjYIVpTH.js} +1 -1
  41. package/dist/assets/{oauth-complete-page-CVO0cJkk.js → oauth-complete-page-B2ewGhNS.js} +1 -1
  42. package/dist/assets/{oauth-popup-complete-page-w7j77OYp.js → oauth-popup-complete-page-DzBQF52z.js} +1 -1
  43. package/dist/assets/{pairing-page-DCLePIes.js → pairing-page-Cts5oIbb.js} +1 -1
  44. package/dist/assets/{personality-page-BLTetblf.js → personality-page-BIqqAa7v.js} +1 -1
  45. package/dist/assets/{plan-tier-meta-sbANEgqF.js → plan-tier-meta-BIKAm_Ai.js} +1 -1
  46. package/dist/assets/{plans-page-DDi3uCIA.js → plans-page-SfiDHZ-V.js} +1 -1
  47. package/dist/assets/{plugin-detail-page-Bx6MHYum.js → plugin-detail-page-CldUqueG.js} +1 -1
  48. package/dist/assets/{privacy-page-DEN2g4bg.js → privacy-page-C0yyDdog.js} +1 -1
  49. package/dist/assets/{privacy-screen-CcR6K8KB.js → privacy-screen-Dy-ZmDGc.js} +1 -1
  50. package/dist/assets/{provider-callback-page-DnCyuaIz.js → provider-callback-page-Dl7F__Qu.js} +1 -1
  51. package/dist/assets/{quick-input-page-DL6C5pNV.js → quick-input-page-CBLwsr9x.js} +1 -1
  52. package/dist/assets/{research-mock-page-JkFx_erV.js → research-mock-page-B6haRdv5.js} +1 -1
  53. package/dist/assets/{research-onboarding-route-CiYOCoIf.js → research-onboarding-route-ByXRk6ey.js} +1 -1
  54. package/dist/assets/{review-terms-screen-DeGMhBmb.js → review-terms-screen-CKDlmyVS.js} +1 -1
  55. package/dist/assets/{schedules-page-BCG9NNr8.js → schedules-page-BHCnNRj0.js} +1 -1
  56. package/dist/assets/{select-assistant-screen-DnHvJdOC.js → select-assistant-screen-dLgg2FG5.js} +1 -1
  57. package/dist/assets/{settings-layout-D4XyzZ10.js → settings-layout-DwJxTai2.js} +1 -1
  58. package/dist/assets/{share-feedback-modal-BTL9J1ZG.js → share-feedback-modal-Di8E9iA6.js} +1 -1
  59. package/dist/assets/{sidebar-tree-B3cns8Q3.js → sidebar-tree-CpqsN0in.js} +1 -1
  60. package/dist/assets/{signup-page-D0UmJvWq.js → signup-page-C0ErIgF3.js} +1 -1
  61. package/dist/assets/{skill-detail-page-DCX3jpg5.js → skill-detail-page-DF53ks-N.js} +1 -1
  62. package/dist/assets/{skill-detail-panel-DYJgMNy6.js → skill-detail-panel-D_eE-IN4.js} +1 -1
  63. package/dist/assets/{start-screen-5j8Dwj88.js → start-screen-DKTECs_x.js} +1 -1
  64. package/dist/assets/{subagent-detail-panel-Bh11Bk4f.js → subagent-detail-panel-PimZMDhD.js} +1 -1
  65. package/dist/assets/{superpowers-page-TClXVwUH.js → superpowers-page-z-OIImRF.js} +1 -1
  66. package/dist/assets/{system-events-page-BLI3KA9e.js → system-events-page-69I8yECA.js} +1 -1
  67. package/dist/assets/{theme-stage-page-C8IC55us.js → theme-stage-page-DbSjHaq5.js} +1 -1
  68. package/dist/assets/{tiptap-document-editor-CW_Ejipp.js → tiptap-document-editor-Drkf4aZR.js} +1 -1
  69. package/dist/assets/{tool-detail-panel-EOB9LtOS.js → tool-detail-panel-B7WGaI0e.js} +1 -1
  70. package/dist/assets/{upgrade-cancel-page-Rz-Zr9uN.js → upgrade-cancel-page-ouMju_xq.js} +1 -1
  71. package/dist/assets/{upgrade-success-page-VUmOBid-.js → upgrade-success-page-tGHxARrq.js} +1 -1
  72. package/dist/assets/{use-assistant-identity-details-DyyBK8Em.js → use-assistant-identity-details-CT-IVkCa.js} +1 -1
  73. package/dist/assets/{use-edge-swipe-back-DGdE69fG.js → use-edge-swipe-back-BYWXReAH.js} +1 -1
  74. package/dist/assets/{use-invite-link-dialog-BL_ylpSj.js → use-invite-link-dialog-BsdPKDQ_.js} +1 -1
  75. package/dist/assets/{use-skill-actions-BssxVwhK.js → use-skill-actions-7ZROdMpd.js} +1 -1
  76. package/dist/assets/{use-skill-detail-files-BVoaelHO.js → use-skill-detail-files-8L8VWCDM.js} +1 -1
  77. package/dist/assets/{voice-page-baOGcJ5W.js → voice-page-XqnVdjxN.js} +1 -1
  78. package/dist/assets/{weather-forecast-display-KeNyTAKb.js → weather-forecast-display-Bb6e1yNM.js} +1 -1
  79. package/dist/assets/{welcome-screen-C78xMG9C.js → welcome-screen-9POAvbd3.js} +1 -1
  80. package/dist/assets/{workflow-detail-panel-COrOekoP.js → workflow-detail-panel-xU_g1_Ed.js} +1 -1
  81. package/dist/assets/{workspace-page-9Rb-xofV.js → workspace-page-BuAzqfnV.js} +1 -1
  82. package/dist/index.html +2 -2
  83. package/package.json +1 -1
  84. package/dist/assets/identity-page-route-Cdj6Wr6j.js +0 -7
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{P as r,t as i}from"./button-BQVYX8n_.js";import{f as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./typography-Cqi8q9o7.js";import{n as d,t as f}from"./settings-wSv59mkN.js";import{t as p}from"./chart-column-L6Nldm8M.js";import{t as m}from"./chevron-down-DpYf9Gwq.js";import{r as h,t as g}from"./panel-item-An-BBeyL.js";import{t as _}from"./clock-LiCGqvyn.js";import{t as v}from"./loader-circle-Ck8fq3yv.js";import{t as y}from"./repeat-BhXOPeQU.js";import{t as b}from"./x-CswtfvgS.js";import{t as x}from"./notice-DkAWz47A.js";import{i as S,j as C}from"./src-CheJrlfT.js";import{t as w}from"./tag-B6WeUtBW.js";import{n as T,t as E}from"./input-ZpyYt_a0.js";import{t as D}from"./toggle-QSEiPr3k.js";import{t as O}from"./modal-BtcwNEBj.js";import{n as k}from"./toast-Be8FEQ-I.js";import{t as A}from"./dropdown-BxYrCXBS.js";import{F as j,M,N,P,Vt as F,Xt as ee,Yt as te,_ as ne,c as I,d as L,dt as re,ft as ie,g as R,j as ae,mt as oe,pt as se,ut as ce,v as le,y as ue}from"./react-query.gen-C0S0EYHV.js";import{c as z}from"./routes-Cwb-U9H-.js";import{t as de}from"./effective-timezone-Ct3PoWNH.js";import{t as B}from"./assistant-feature-flag-store-aNAjw1qx.js";import{Ao as fe,Da as pe,Ea as me,Oa as he,Wo as ge,ir as V,ys as _e,zs as ve,zt as ye}from"./index-D7_9Qy0L.js";import{t as be}from"./use-active-assistant-id-DwLFgABu.js";import{t as xe}from"./detail-card-CIh4dCKt.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae,u as je}from"./page-empty-state-DZYd2PGe.js";import{r as Me,t as Ne}from"./profile-metadata-CMym5q9r.js";var H=e(n(),1),Pe={frequency:`daily`,minute:0,hour24:9,weekdays:[1],dayOfMonth:1},U=[{value:0,letter:`S`,short:`Sun`,full:`Sunday`},{value:1,letter:`M`,short:`Mon`,full:`Monday`},{value:2,letter:`T`,short:`Tue`,full:`Tuesday`},{value:3,letter:`W`,short:`Wed`,full:`Wednesday`},{value:4,letter:`T`,short:`Thu`,full:`Thursday`},{value:5,letter:`F`,short:`Fri`,full:`Friday`},{value:6,letter:`S`,short:`Sat`,full:`Saturday`}],Fe=[1,2,3,4,5];function W(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Ie(e){let t=Array.from(new Set(e.map(e=>W(e,0,6)).filter(e=>Number.isInteger(e)))).sort((e,t)=>e-t);return t.length>0?t:[1]}function Le(e){let t=W(e.minute,0,59),n=W(e.hour24,0,23);switch(e.frequency){case`hourly`:return`${t} * * * *`;case`daily`:return`${t} ${n} * * *`;case`weekly`:return`${t} ${n} * * ${Ie(e.weekdays).join(`,`)}`;case`monthly`:return e.dayOfMonth===`last`?`${t} ${n} L * *`:`${t} ${n} ${W(e.dayOfMonth,1,28)} * *`}}function Re(e,t){let n=W(e,0,23),r=W(t,0,59),i=n<12?`AM`:`PM`;return`${n%12==0?12:n%12}:${String(r).padStart(2,`0`)} ${i}`}function ze(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return`${e}${t[(n-20)%10]??t[n]??t[0]}`}function Be(e){let t=Ie(e),n=new Set(t);if(t.length===7)return`every day`;if(t.length===5&&Fe.every(e=>n.has(e)))return`every weekday`;if(t.length===2&&n.has(0)&&n.has(6))return`every weekend`;if(t.length===1)return`every ${U[t[0]]?.full??`day`}`;let r=t.map(e=>U[e]?.short??``),i=r.pop();return`every ${r.join(`, `)} & ${i}`}function Ve(e){let t=Re(e.hour24,e.minute);switch(e.frequency){case`hourly`:{let t=W(e.minute,0,59);return`Runs every hour at :${String(t).padStart(2,`0`)}`}case`daily`:return`Runs every day at ${t}`;case`weekly`:return`Runs ${Be(e.weekdays)} at ${t}`;case`monthly`:return e.dayOfMonth===`last`?`Runs on the last day of every month at ${t}`:`Runs on the ${ze(W(e.dayOfMonth,1,28))} of every month at ${t}`}}var G=l(),He=[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}],Ue=Array.from({length:12},(e,t)=>{let n=t+1;return{value:String(n),label:String(n)}}),We=Array.from({length:12},(e,t)=>{let n=t*5,r=String(n).padStart(2,`0`);return{value:r,label:r}}),Ge=[...Array.from({length:28},(e,t)=>{let n=t+1;return{value:String(n),label:ze(n)}}),{value:`last`,label:`Last day`}],Ke=[{value:`AM`,label:`AM`},{value:`PM`,label:`PM`}];function qe(e,t){let n=e%12;return t===`PM`?n+12:n}function Je(e){try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;return t&&t!==e?`${e} · ${t}`:e}catch{return e}}function Ye({isOpen:e,assistantId:t,onClose:n,onCreated:r}){return(0,G.jsx)(O.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,G.jsx)(Xe,{assistantId:t,onClose:n,onCreated:r}):null})}function Xe({assistantId:e,onClose:t,onCreated:n}){let r=V(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(`simple`),[p,m]=(0,H.useState)(Pe),[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(null),x=a.trim(),S=s.trim(),C=l.trim(),w=h.trim(),D=(0,H.useMemo)(()=>d===`simple`?Le(p):w,[d,p,w]),k=(0,H.useMemo)(()=>d===`simple`?Ve(p):w||`Enter a cron expression to continue.`,[d,p,w]),A=(0,H.useMemo)(()=>Je(r),[r]),j=x.length>0&&S.length>0&&C.length>0&&D.length>0&&!_;return(0,G.jsxs)(O.Content,{size:`md`,children:[(0,G.jsxs)(O.Header,{children:[(0,G.jsx)(O.Title,{children:`Create schedule`}),(0,G.jsx)(O.Description,{children:`Schedule a recurring instruction for your assistant. Runs in execute mode — the message is delivered to the assistant on each fire.`})]}),(0,G.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),j){v(!0),b(null);try{await Ee(e,{name:x,description:S,expression:D,message:C,timezone:r}),v(!1),n()}catch(e){b(e instanceof Error?e.message:`Failed to create schedule.`),v(!1)}}},children:[(0,G.jsx)(O.Body,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,G.jsx)(E,{label:`Name`,placeholder:`Morning briefing`,value:a,onChange:e=>o(e.target.value),required:!0,autoFocus:!0,fullWidth:!0}),(0,G.jsx)(T,{label:`Description`,placeholder:`What is this schedule for?`,value:s,onChange:e=>c(e.target.value),required:!0,fullWidth:!0,rows:2}),(0,G.jsx)(tt,{label:`Repeat`,children:d===`simple`?(0,G.jsx)(Ze,{cadence:p,onChange:m}):(0,G.jsx)(et,{value:h,onChange:g,onUseSimple:()=>f(`simple`)})}),(0,G.jsx)(nt,{summary:k,mono:d===`advanced`&&w.length>0,timezoneLabel:A}),d===`simple`?(0,G.jsx)(`button`,{type:`button`,onClick:()=>{g(e=>e||Le(p)),f(`advanced`)},className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`Advanced — write a cron expression`}):null,(0,G.jsx)(T,{label:`Message`,placeholder:`What should the assistant do on each fire?`,value:l,onChange:e=>u(e.target.value),required:!0,fullWidth:!0,rows:4}),y?(0,G.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:y}):null]})}),(0,G.jsxs)(O.Footer,{children:[(0,G.jsx)(i,{variant:`outlined`,onClick:t,type:`button`,children:`Cancel`}),(0,G.jsx)(i,{variant:`primary`,type:`submit`,disabled:!j,children:_?`Creating…`:`Create schedule`})]})]})]})}function Ze({cadence:e,onChange:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(C,{items:He,value:e.frequency,onChange:n=>t({...e,frequency:n}),ariaLabel:`How often the schedule runs`}),e.frequency===`hourly`?(0,G.jsx)(K,{label:`At minute`,children:(0,G.jsx)(A,{options:We,value:String(e.minute).padStart(2,`0`),onChange:n=>t({...e,minute:Number(n)}),"aria-label":`Minute`,className:`w-24`})}):null,e.frequency===`weekly`?(0,G.jsx)(K,{label:`On these days`,children:(0,G.jsx)($e,{value:e.weekdays,onChange:n=>t({...e,weekdays:n})})}):null,e.frequency===`monthly`?(0,G.jsx)(K,{label:`On day`,children:(0,G.jsx)(A,{options:Ge,value:e.dayOfMonth===`last`?`last`:String(e.dayOfMonth),onChange:n=>t({...e,dayOfMonth:n===`last`?`last`:Number(n)}),"aria-label":`Day of month`,className:`w-32`})}):null,e.frequency===`hourly`?null:(0,G.jsx)(K,{label:`At time`,children:(0,G.jsx)(Qe,{hour24:e.hour24,minute:e.minute,onChange:(n,r)=>t({...e,hour24:n,minute:r})})})]})}function Qe({hour24:e,minute:t,onChange:n}){let r=e<12?`AM`:`PM`,i=e%12==0?12:e%12;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(A,{options:Ue,value:String(i),onChange:e=>n(qe(Number(e),r),t),"aria-label":`Hour`,className:`w-[72px]`}),(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`:`}),(0,G.jsx)(A,{options:We,value:String(t).padStart(2,`0`),onChange:t=>n(e,Number(t)),"aria-label":`Minute`,className:`w-[72px]`}),(0,G.jsx)(`div`,{className:`w-[112px]`,children:(0,G.jsx)(C,{items:Ke,value:r,onChange:e=>n(qe(i,e),t),ariaLabel:`AM or PM`})})]})}function $e({value:e,onChange:t}){let n=new Set(e),i=e=>{let r=new Set(n);r.has(e)?r.size>1&&r.delete(e):r.add(e),t([...r].sort((e,t)=>e-t))};return(0,G.jsx)(`div`,{className:`flex gap-1.5`,children:U.map(e=>{let t=n.has(e.value);return(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),"aria-pressed":t,"aria-label":e.full,title:e.full,className:r(`flex h-9 w-9 items-center justify-center rounded-md border text-body-medium-default transition-colors`,t?`border-[var(--border-active)] bg-[var(--surface-active)] text-[var(--content-emphasised)]`:`border-[var(--field-border)] text-[var(--content-tertiary)] hover:border-[var(--border-active)] hover:text-[var(--content-default)]`),children:e.letter},e.value)})})}function et({value:e,onChange:t,onUseSimple:n}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(E,{placeholder:`0 9 * * *`,value:e,onChange:e=>t(e.target.value),fullWidth:!0,className:`font-mono`,"aria-label":`Cron expression`,helperText:`Standard 5-field cron (minute hour day month weekday). RRULE expressions are also accepted.`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`← Back to the simple builder`})]})}function tt({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:e}),t]})}function K({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-[88px] text-body-small-default text-[var(--content-tertiary)]`,children:e}),t]})}function nt({summary:e,mono:t,timezoneLabel:n}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-3.5 py-3`,children:[(0,G.jsx)(_,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:r(`text-body-medium-default text-[var(--content-default)]`,t&&`break-all font-mono`),children:e}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Times use your timezone — `,n,`.`]})]})]})}function rt(e=de(),t=Date.now()){return Me(`7d`,e,t)}function q(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0}):`—`}function it(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}var at=new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2});function J(e){return e==null||!Number.isFinite(e)?`—`:at.format(e)}function Y(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}function ot(e){let t=Math.round(e/6e4);return t>=60&&t%60==0?`Every ${t/60} hr`:`Every ${t} min`}function st(e){if(!e)return;let t=new Set,n=[];for(let r of e)for(let e of r.runs)t.has(e.id)||(t.add(e.id),n.push(e));return n}function ct(e){return!!e.conversationId&&e.conversationExists===!0&&e.conversationArchivedAt==null}function lt(e){return ct(e)?e.conversationId??null:null}function X(e){return typeof e==`string`&&e.length>0}var ut={heartbeat:`system-heartbeat`,consolidation:`system-consolidation`,retrospective:`system-memory-retrospective`};function dt(e){if(e.cronExpression)return e.timezone?`Cron: ${e.cronExpression} (${e.timezone})`:`Cron: ${e.cronExpression}`;let t=ot(e.intervalMs);return e.activeHoursStart!=null&&e.activeHoursEnd!=null&&(t+=` (${e.activeHoursStart}:00–${e.activeHoursEnd}:00)`),t}function ft(e){return ot(e.intervalMs)}var pt=`After conversation activity`;function mt(e,t){return e.status===`fired`||e.status===`cancelled`?!0:e.status===`firing`?!1:e.nextRunAt==null||!e.enabled&&e.nextRunAt<=t}function ht(e,t){let n=[],r=[],i=[];for(let a of e)a.isOneShot?mt(a,t)?i.push(a):r.push(a):n.push(a);return n.sort((e,t)=>e.enabled===t.enabled?(e.nextRunAt??1/0)-(t.nextRunAt??1/0):e.enabled?-1:1),r.sort((e,t)=>(e.nextRunAt??1/0)-(t.nextRunAt??1/0)),i.sort((e,t)=>{let n=e.lastRunAt??e.nextRunAt??0;return(t.lastRunAt??t.nextRunAt??0)-n}),{recurring:n,upcomingOneTime:r,pastOneTime:i}}function gt(e,t,n=!0){return{queryKey:[{_id:`schedulesUsagesummaryGet`,path:{assistant_id:e??``},_tz:t}],queryFn:()=>e?Se(e,rt(t)):Promise.resolve([]),enabled:n,staleTime:1e4}}function _t(e){return{scheduleId:e,runCount:0,totalEstimatedCostUsd:0,eventCount:0}}function vt(e,t,n){let r=(t??[]).filter(e=>{let t=e.startedAt??e.createdAt;return t>=n.from&&t<=n.to});return{scheduleId:e,runCount:r.length,totalEstimatedCostUsd:r.reduce((e,t)=>{let n=t.estimatedCostUsd;return typeof n==`number`&&Number.isFinite(n)?e+n:e},0),eventCount:0}}function yt({status:e}){return(0,G.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:e===`ok`||e===`completed`?`var(--system-positive-strong)`:e===`error`||e===`failed`?`var(--system-negative-strong)`:`var(--content-tertiary)`},"aria-label":e??`unknown`})}function bt({scheduleName:e,usage:t,onOpenUsage:n}){if(t.status===`loading`)return(0,G.jsxs)(`div`,{"aria-label":`Loading schedule usage`,className:`flex w-[156px] shrink-0 items-center justify-end gap-3`,children:[(0,G.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,G.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`})]});let r=t.status===`error`,i=r?`--`:J(t.summary.totalEstimatedCostUsd),a=r?`--`:Y(t.summary.runCount),o=t.status===`ready`&&!(t.summary.totalEstimatedCostUsd>0),s=t.status===`ready`&&t.summary.runCount===0,c=o?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`,l=s?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`;return(0,G.jsxs)(`div`,{className:`flex w-[156px] shrink-0 items-center justify-end gap-3 text-right text-body-small-default`,children:[n?(0,G.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`View usage for ${e}`,className:`min-w-[64px] cursor-pointer rounded px-1 py-0.5 text-right transition-colors hover:bg-[var(--surface-hover)] ${c}`,children:i}):(0,G.jsx)(`span`,{"aria-label":`Cost for ${e} in the last 7 days: ${i}`,className:`block min-w-[64px] px-1 py-0.5 ${c}`,children:i}),(0,G.jsx)(`span`,{"aria-label":`Runs for ${e} in the last 7 days: ${a}`,className:`block min-w-[64px] px-1 py-0.5 ${l}`,children:a})]})}function xt({name:e,subtitle:t,enabled:n,nextRunAt:r,lastRunAt:i,usage:a,helperText:o,statusLabel:s,statusTone:c=`neutral`,onClick:l}){return(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md px-2 py-3 transition-colors hover:bg-[var(--surface-hover)] [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:l,"aria-label":`Open ${e}`,className:`flex min-w-0 flex-1 cursor-pointer flex-wrap items-center gap-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e})}),(0,G.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t}),o?(0,G.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-secondary)]`,children:o}):null,(0,G.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-body-small-default text-[var(--content-tertiary)]`,children:[r?(0,G.jsxs)(`span`,{children:[`Next: `,q(r)]}):null,i?(0,G.jsxs)(`span`,{children:[`Last: `,q(i)]}):null]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-3`,children:[(0,G.jsx)(bt,{scheduleName:e,usage:a}),s?(0,G.jsx)(w,{tone:c,children:s}):(0,G.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:n?`var(--system-positive-strong)`:`var(--content-disabled)`},"aria-label":n?`enabled`:`disabled`}),(0,G.jsx)(h,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})})}function St({heartbeatConfig:e,consolidationConfig:t,retrospectiveConfig:n,heartbeatUsage:r,consolidationUsage:i,retrospectiveUsage:a,isLoading:o,hasError:s,onRetry:c,onSelectHeartbeat:l,onSelectConsolidation:u,onSelectRetrospective:d}){let f=e!=null,p=t?.available===!0,h=n?.available===!0,g=f||p||h;if(!o&&!s&&!g)return null;let _=[...f?[r]:[],...p?[i]:[],...h?[a]:[]].filter(e=>e.status===`ready`),y=_.reduce((e,t)=>e+(t.summary.totalEstimatedCostUsd??0),0),b=o?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):s&&!g?(0,G.jsxs)(x,{tone:`error`,children:[`Failed to load system jobs.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):(0,G.jsxs)(`div`,{children:[f?(0,G.jsx)(xt,{name:`Heartbeat`,subtitle:dt(e),enabled:e.enabled,nextRunAt:e.nextRunAt,lastRunAt:e.lastRunAt,usage:r,onClick:l}):null,p?(0,G.jsx)(xt,{name:`Consolidation`,subtitle:ft(t),enabled:t.enabled,helperText:t.enabled?void 0:`Memory is off, so consolidation is paused.`,nextRunAt:t.nextRunAt,lastRunAt:t.lastRunAt,usage:i,statusLabel:t.enabled?void 0:`Paused`,statusTone:`warning`,onClick:u}):null,h?(0,G.jsx)(xt,{name:`Memory retrospective`,subtitle:pt,enabled:n.enabled,helperText:n.enabled?void 0:`Memory is off, so retrospectives are paused.`,nextRunAt:n.nextRunAt,lastRunAt:n.lastRunAt,usage:a,statusLabel:n.enabled?void 0:`Paused`,statusTone:`warning`,onClick:d}):null,s?(0,G.jsx)(`div`,{className:`pt-3 first:pt-0`,children:(0,G.jsxs)(x,{tone:`error`,children:[`Some system jobs failed to load.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})}):null]});return(0,G.jsx)(xe,{children:(0,G.jsx)(S.Root,{type:`multiple`,children:(0,G.jsxs)(S.Item,{value:`system-jobs`,children:[(0,G.jsxs)(S.Trigger,{className:`group justify-between gap-3`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1 text-left`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`System`}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Built-in jobs managed by the assistant runtime`})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[_.length>0?(0,G.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[J(y),` (7d)`]}):null,(0,G.jsx)(m,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]})]}),(0,G.jsx)(S.Content,{children:(0,G.jsx)(`div`,{className:`mt-3`,children:b})})]})})})}function Z(e,t){return{id:e.id,jobId:t,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:`skipReason`in e&&e.skipReason?`Skipped: ${e.skipReason}`:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt,...`title`in e?{title:e.title}:{}}}function Ct(e){return e.runs.map(e=>Z(e,`heartbeat`))}function wt(e){return e.runs.map(e=>Z(e,`consolidation`))}function Tt(e){return e.runs.map(e=>Z(e,`retrospective`))}var Q=1e4;function Et(e,t,n,r,i){return e?{status:`loading`}:t?{status:`error`}:{status:`ready`,summary:vt(n,r,i)}}function Dt(e,n){let r=s(),i={path:{assistant_id:e??``}},{data:a,isLoading:o,isError:l,refetch:u}=c({...ae(i),enabled:!!e,staleTime:Q}),{data:d,isLoading:f,isError:p,refetch:m}=c({...R(i),enabled:!!e,staleTime:Q}),{data:h,isLoading:g,isError:_,refetch:v}=c({...ce(i),enabled:!!e,staleTime:Q}),y={path:{assistant_id:e??``},query:{limit:100}},{data:b,isLoading:x,isError:S,refetch:C}=c({...j(y),select:Ct,enabled:!!e&&a!=null,staleTime:Q}),{data:w,isLoading:T,isError:E,refetch:D}=c({...ue(y),select:wt,enabled:!!e&&d?.available===!0,staleTime:Q}),{data:O,isLoading:A,isError:N,refetch:ne}=c({...se(y),select:Tt,enabled:!!e&&h?.available===!0,staleTime:Q}),I=(0,H.useMemo)(()=>rt(n),[n]),L=(0,H.useMemo)(()=>Et(x,S,ut.heartbeat,b,I),[b,S,x,I]),re=(0,H.useMemo)(()=>Et(T,E,ut.consolidation,w,I),[w,E,T,I]),oe=(0,H.useMemo)(()=>Et(A,N,ut.retrospective,O,I),[O,N,A,I]),z=t=>{if(!e)return;let n={heartbeat:{config:ae(i).queryKey,runs:j(y).queryKey,infinite:P(i)},consolidation:{config:R(i).queryKey,runs:ue(y).queryKey,infinite:le(i)},retrospective:{config:ce(i).queryKey,runs:se(y).queryKey,infinite:ie(i)}}[t];r.invalidateQueries({queryKey:n.config}),r.invalidateQueries({queryKey:n.runs}),r.invalidateQueries({queryKey:n.infinite})},de=ee({onSuccess:e=>{e.ran?k.success(`Heartbeat started.`):k.info(`Heartbeat skipped.`)},onError:e=>{t(e,{context:`heartbeat_run_now`}),k.error(`Failed to run heartbeat.`)},onSettled:()=>z(`heartbeat`)}),B=F({onSuccess:e=>{e.ran?k.success(`Consolidation queued.`):k.info(`Consolidation already queued or running.`)},onError:e=>{t(e,{context:`consolidation_run_now`}),k.error(`Failed to run consolidation.`)},onSettled:()=>z(`consolidation`)}),fe=te({onSuccess:e=>{M(r,i,e),k.success(e.enabled?`Heartbeat enabled.`:`Heartbeat disabled.`)},onError:e=>{t(e,{context:`heartbeat_toggle`}),k.error(`Failed to toggle heartbeat.`)}});return{heartbeatConfig:a,consolidationConfig:d,retrospectiveConfig:h,heartbeatUsage:L,consolidationUsage:re,retrospectiveUsage:oe,isLoading:o||f||g,hasError:l||p||_,isHeartbeatRunning:de.isPending,isConsolidationRunning:B.isPending,isHeartbeatLoading:o,isHeartbeatError:l,isConsolidationLoading:f,isConsolidationError:p,isRetrospectiveLoading:g,isRetrospectiveError:_,refetchHeartbeat:u,refetchConsolidation:m,refetchRetrospective:v,runHeartbeatNow:()=>{e&&de.mutate({path:{assistant_id:e}})},runConsolidationNow:()=>{e&&B.mutate({path:{assistant_id:e}})},toggleHeartbeat:t=>{e&&fe.mutate({body:{enabled:t},path:{assistant_id:e}})},refetchAll:()=>{u(),m(),v(),C(),D(),ne()}}}function Ot({children:e}){return(0,G.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function $({label:e,value:t}){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-1`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e}),(0,G.jsx)(`span`,{className:`min-w-0 text-right text-body-medium-lighter text-[var(--content-default)]`,children:t})]})}function kt({icon:e,value:t,label:n}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] p-3`,children:[(0,G.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--surface-sunken)] text-[var(--content-secondary)]`,children:e}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-body-large-default text-[var(--content-default)]`,children:t}),(0,G.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n})]})]})}function At({usage:e}){return e.status===`loading`?(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:Array.from({length:2},(e,t)=>(0,G.jsx)(`div`,{className:`h-[60px] animate-pulse rounded-lg bg-[var(--surface-muted)]`},t))}):e.status===`error`?null:(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:[(0,G.jsx)(kt,{icon:(0,G.jsx)(_e,{className:`h-4 w-4`}),value:J(e.summary.totalEstimatedCostUsd),label:`7 Day Cost`}),(0,G.jsx)(kt,{icon:(0,G.jsx)(y,{className:`h-4 w-4`}),value:Y(e.summary.runCount),label:`7 Day Runs`})]})}function jt(e){return e.exists&&e.archivedAt==null}function Mt({run:e,index:t,isExpanded:n,disableDirectOpen:i,onOpenConversation:a,onToggleDetails:o}){let s=lt(e),c=e.conversations??(s?[{id:s,title:null,exists:!0,archivedAt:null}]:[]),l=X(e.output),u=X(e.error),d=!i&&c.length===1&&jt(c[0])?c[0].id:null,f=!d&&(c.length>0||l||u),p=`schedule-run-details-${t}`,m=!!d||f,g=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yt,{status:e.status}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:q(e.startedAt)}),(0,G.jsxs)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[it(e.durationMs),` ·`,` `,J(e.estimatedCostUsd)]}),e.status===`error`&&e.error?(0,G.jsxs)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--system-negative-strong)]`,children:[e.error.slice(0,120),e.error.length>120?`…`:``]}):null]}),m?(0,G.jsx)(h,{className:r(`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform`,f&&n?`rotate-90`:``)}):null]}),_=f&&n?(0,G.jsx)(`div`,{id:p,className:`px-2 pb-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[c.length>0?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Conversations`}),(0,G.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>jt(e)?(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full truncate text-left text-body-small-default text-[var(--content-default)] hover:underline`,children:X(e.title)?e.title:`Conversation`},e.id):(0,G.jsxs)(`span`,{className:`block truncate text-body-small-default text-[var(--content-tertiary)] italic`,children:[X(e.title)?e.title:`Conversation`,` `,e.exists?`(archived)`:`(unavailable)`]},e.id))})]}):null,l?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,u?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null;return d?(0,G.jsx)(`div`,{children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(d),"aria-label":`Open conversation for run at ${q(e.startedAt)}`,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g})}):f?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-label":`Toggle details for run at ${q(e.startedAt)}`,"aria-expanded":n,"aria-controls":p,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g}),_]}):(0,G.jsx)(`div`,{className:`flex items-center gap-3 px-2 py-3`,children:g})}function Nt({runs:e,isLoading:t,disableDirectOpen:n,onOpenConversation:r}){let[i,a]=(0,H.useState)(null);return t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,G.jsx)(`p`,{className:`py-2 text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:`No runs yet.`}):(0,G.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.map((e,t)=>(0,G.jsx)(Mt,{run:e,index:t,isExpanded:i===e.id,disableDirectOpen:n,onOpenConversation:r,onToggleDetails:e=>a(t=>t===e?null:e)},e.id))})}function Pt({schedule:e,assistantId:n,usage:a,isMobile:s,onClose:l,onDeleted:d}){let f=o(),{data:m,isLoading:h}=c({queryKey:oe({path:{assistant_id:n,id:e.id}}),queryFn:()=>we(n,e.id),staleTime:1e4}),[g,_]=(0,H.useState)(!1),[y,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(!1),w=async()=>{_(!0);try{await De(n,e.id)}catch(e){t(e,{context:`schedule_run_now`}),k.error(`Failed to run schedule.`)}finally{_(!1)}},T=async()=>{C(!0);try{await Oe(n,e.id),d()}catch(e){t(e,{context:`schedule_delete`}),k.error(`Failed to delete schedule.`),C(!1),x(!1)}};return(0,G.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:e.name})}),(0,G.jsx)(i,{variant:`ghost`,iconOnly:(0,G.jsx)(b,{}),onClick:l,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[e.description?(0,G.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e.description}):null,(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Ot,{children:`Details`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-2`,children:[e.cadenceDescription?(0,G.jsx)($,{label:`Cadence`,value:e.cadenceDescription}):null,(0,G.jsx)($,{label:`Mode`,value:e.mode}),(0,G.jsx)($,{label:`Status`,value:e.enabled?`Enabled`:`Disabled`}),(0,G.jsx)($,{label:`Next run`,value:q(e.nextRunAt)}),e.lastRunAt?(0,G.jsx)($,{label:`Last run`,value:(0,G.jsxs)(`span`,{className:`flex items-center justify-end gap-2`,children:[(0,G.jsx)(yt,{status:e.lastStatus}),q(e.lastRunAt)]})}):null]})]}),(0,G.jsx)(At,{usage:a}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Ot,{children:`Recent runs`}),(0,G.jsx)(Nt,{runs:m?.runs,isLoading:h,disableDirectOpen:e.mode===`script`,onOpenConversation:e=>pe(f,e)})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[y?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),disabled:S,children:`Cancel`}),(0,G.jsx)(i,{variant:`danger`,onClick:()=>void T(),disabled:S,children:S?`Deleting…`:`Yes, delete`})]}):(0,G.jsx)(i,{variant:`dangerOutline`,leftIcon:(0,G.jsx)(fe,{className:`h-3.5 w-3.5`}),onClick:()=>x(!0),children:`Delete`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(i,{variant:`outlined`,leftIcon:(0,G.jsx)(p,{className:`h-3.5 w-3.5`}),onClick:()=>f(z.settings.usageForSchedule(e.id)),children:`View usage`}),e.mode===`script`?(0,G.jsx)(i,{variant:`primary`,leftIcon:g?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):void 0,onClick:()=>void w(),disabled:g,children:g?`Running…`:`Run now`}):null]})]})]})}function Ft(e){if(e.status===`loading`)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`h-4 w-12 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,G.jsx)(`span`,{className:`h-4 w-10 animate-pulse rounded bg-[var(--surface-muted)]`})]});if(e.status===`error`)return(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`—`});let{summary:t}=e;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:J(t.totalEstimatedCostUsd)}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:Y(t.runCount)})]})}function It({name:e,metaParts:t,usage:n,enabled:r,selected:i,onClick:a,onToggle:o,toggleAriaLabel:s}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md px-2 py-3 transition-colors [&+&]:border-t [&+&]:border-[var(--border-base)] ${i?`bg-[var(--surface-active)]`:`hover:bg-[var(--surface-hover)]`}`,children:[o?(0,G.jsx)(D,{checked:r,onChange:o,"aria-label":s}):null,(0,G.jsxs)(`button`,{type:`button`,onClick:a,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-4 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e}),t.length>0?(0,G.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 text-label-small-default text-[var(--content-tertiary)]`,children:t.map((e,t)=>(0,G.jsxs)(H.Fragment,{children:[t>0?(0,G.jsx)(`span`,{className:`h-[3px] w-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}):null,(0,G.jsx)(`span`,{className:`truncate`,children:e})]},t))}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4`,children:[Ft(n),(0,G.jsx)(h,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})]})}function Lt({schedule:e,usage:t,selected:n,onClick:r,onToggle:i}){let a=e.isOneShot?``:e.cadenceDescription.trim(),o=e.lastRunAt??e.nextRunAt,s=[a,o?q(o):``].filter(Boolean);return(0,G.jsx)(It,{name:e.name,metaParts:s,usage:t,enabled:e.enabled,selected:n,onClick:r,onToggle:i,toggleAriaLabel:i?`Toggle ${e.name}`:void 0})}function Rt({recurring:e,oneTime:t,pastOneTime:n,usageForSchedule:r,isLoading:a,isError:o,refetch:s,onToggle:c,onSelectSchedule:l,selectedScheduleId:u,onStartNewChat:f,onCreateSchedule:p,pastOpen:m,onPastOpenChange:g,systemTasksSlot:_}){let v=e=>(0,G.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id),onToggle:t=>c(e.id,t)},e.id),y=e=>(0,G.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id)},e.id),b=n.length>0?(0,G.jsx)(S.Root,{type:`single`,collapsible:!0,className:`mt-3`,value:m?`past`:``,onValueChange:e=>g(e===`past`),children:(0,G.jsxs)(S.Item,{value:`past`,children:[(0,G.jsxs)(S.Trigger,{className:`group gap-[var(--app-spacing-xs)] px-2 text-label-small-default text-[var(--content-tertiary)]`,children:[(0,G.jsx)(h,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,G.jsxs)(`span`,{children:[`Past (`,n.length,`)`]})]}),(0,G.jsx)(S.Content,{children:(0,G.jsx)(`div`,{className:`pt-1`,children:n.map(y)})})]})}):null;return(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[a?(0,G.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2},(e,t)=>(0,G.jsx)(`div`,{className:`h-12 animate-pulse rounded-md bg-[var(--surface-muted)]`},t))}):o&&e.length===0?(0,G.jsx)(x,{tone:`error`,actions:(0,G.jsx)(`button`,{type:`button`,onClick:s,className:`cursor-pointer underline hover:no-underline`,children:`Retry`}),children:`Failed to load schedules.`}):e.length===0&&t.length===0&&n.length===0?(0,G.jsx)(Ae,{icon:d,title:`No schedules yet`,description:`Ask your assistant to set one up, or create one yourself.`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(i,{variant:`primary`,size:`regular`,onClick:f,children:`New Conversation`}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`or`}),(0,G.jsx)(i,{variant:`outlined`,size:`regular`,onClick:p,children:`Create schedule`})]})}):(0,G.jsxs)(`div`,{children:[e.map(v),t.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mt-3 px-2 text-label-small-default text-[var(--content-tertiary)]`,children:`One-time`}),t.map(y)]}):null,b]}),_?(0,G.jsx)(`div`,{className:`mt-[var(--app-spacing-lg)]`,children:_}):null]})}var zt=`Default (assistant's main model)`,Bt=`Custom call-site model`;function Vt(e,t){return t?.[e]?.displayName??e}function Ht(e,t){if(e==null)return;if(e.provider!=null||e.model!=null)return Bt;let n=e.profile?.trim();return n?`Override (${Vt(n,t)})`:void 0}function Ut({assistantId:e,pinnedProfile:t,defaultCallSite:n=`mainAgent`,fallbackLabel:r=zt,respectCallSiteOverride:i=!1}){let a=t==null,{data:o}=c({...I({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4}),s=(0,H.useMemo)(()=>o?Ne(o):{},[o]),{data:l}=c({...L({path:{assistant_id:e}}),enabled:!!e&&a,staleTime:6e4}),u=a&&i?Ht(o?.llm?.callSites?.[n],s):void 0,d=a?l?.callSites.find(e=>e.id===n)?.defaultProfile:void 0,f=t==null?u??(d==null?r:`Default (${Vt(d,s)})`):Vt(t,s);return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Model profile`}),(0,G.jsx)(`span`,{className:`min-w-0 text-right`,children:f})]})}function Wt({runs:e,isLoading:t,emptyMessage:n=`No runs yet.`,hasMore:r=!1,isLoadingMore:a=!1,onLoadMore:s}){let c=o(),[l,u]=(0,H.useState)(null);return(0,G.jsx)(xe,{title:`Recent runs`,children:t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,G.jsx)(`p`,{className:`py-4 text-center text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:n}):(0,G.jsxs)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:[e.map((e,t)=>{let n=lt(e),r=X(e.output),i=X(e.error),a=!n&&(r||i),o=l===e.id,s=`schedule-run-details-${t}`;return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(g,{label:(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,G.jsx)(yt,{status:e.status}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-body-medium-lighter text-[var(--content-default)]`,children:X(e.title)?e.title:q(e.startedAt)}),(0,G.jsxs)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[X(e.title)?`${q(e.startedAt)} · `:``,it(e.durationMs),` ·`,` `,J(e.estimatedCostUsd),e.status===`error`&&e.error&&(0,G.jsxs)(`span`,{className:`ml-2 text-[var(--system-negative-strong)]`,children:[e.error.slice(0,80),e.error.length>80?`…`:``]})]})]}),n||a?(0,G.jsx)(h,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform ${o?`rotate-90`:``}`}):null]}),onSelect:n?()=>pe(c,n):a?()=>u(o?null:e.id):void 0,"aria-label":`Run at ${q(e.startedAt)}`,"aria-expanded":a?o:void 0,"aria-controls":a?s:void 0,className:`h-auto py-2.5 gap-3 -mx-2 px-2`}),a&&o?(0,G.jsx)(`div`,{id:s,className:`px-2 pb-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[r?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,i?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null]},e.id)}),r&&s?(0,G.jsx)(`div`,{className:`flex justify-center pt-3`,children:(0,G.jsx)(i,{variant:`outlined`,size:`compact`,onClick:s,disabled:a,leftIcon:a?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):void 0,children:a?`Loading…`:`Load more`})}):null]})})}var Gt={heartbeat:`heartbeatAgent`,consolidation:`memoryV2Consolidation`,retrospective:`memoryRetrospective`};function Kt({children:e}){return(0,G.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function qt({kind:e,assistantId:t,systemTasks:n,canOpenMemorySettings:a,isMobile:s,onClose:c}){let l=o(),{heartbeatConfig:d,consolidationConfig:p,retrospectiveConfig:m}=n,h,g,_,y,S,C,w;e===`heartbeat`?(h=`Heartbeat`,g=d?dt(d):``,_=d?.enabled??!1,y=d?.nextRunAt??null,S=d?.lastRunAt??null,C=n.isHeartbeatRunning,w=n.runHeartbeatNow):e===`consolidation`?(h=`Consolidation`,g=p?ft(p):``,_=p?.enabled??!1,y=p?.nextRunAt??null,S=p?.lastRunAt??null,C=n.isConsolidationRunning,w=n.runConsolidationNow):(h=`Memory retrospective`,g=pt,_=m?.enabled??!1,y=m?.nextRunAt??null,S=m?.lastRunAt??null,C=!1,w=void 0);let T=e!==`heartbeat`,E=e===`retrospective`,O=T&&!_,k=C||O,A=T?_?`On · Managed by Memory`:`Paused`:_?`Enabled`:`Disabled`,j=E?`Memory is off, so retrospectives are paused. Turn Memory back on to resume them.`:`Memory is off, so consolidation is paused. Turn Memory back on to resume consolidation.`,M=T&&_&&a,P={path:{assistant_id:t},query:{limit:25}},F=e===`heartbeat`?N(P):e===`consolidation`?ne(P):re(P),{data:ee,isLoading:te,fetchNextPage:I,hasNextPage:L,isFetchingNextPage:ie}=ve({queryKey:F.queryKey,queryFn:F.queryFn,initialPageParam:{path:P.path,query:{}},getNextPageParam:e=>e.nextCursor??void 0,staleTime:1e4}),R=st(ee?.pages.map(t=>({runs:t.runs.map(t=>Z(t,e))})));return(0,G.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:h}),g?(0,G.jsx)(u,{variant:`body-small-default`,as:`p`,className:`truncate text-[var(--content-tertiary)]`,children:g}):null]}),(0,G.jsx)(i,{variant:`ghost`,iconOnly:(0,G.jsx)(b,{}),onClick:c,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Kt,{children:`Details`}),(0,G.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-3 text-body-medium-lighter`,children:[(0,G.jsx)(Ut,{assistantId:t,defaultCallSite:Gt[e],fallbackLabel:`Default (system task model)`,respectCallSiteOverride:!0}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--content-default)]`,children:[(0,G.jsx)(`span`,{children:A}),T?null:(0,G.jsx)(D,{checked:_,onChange:n.toggleHeartbeat,"aria-label":`Toggle ${h}`})]})]}),E?null:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,G.jsx)(`span`,{className:`text-[var(--content-default)]`,children:q(y)})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,G.jsx)(`span`,{className:`text-[var(--content-default)]`,children:q(S)})]})]}),O?(0,G.jsx)(x,{tone:`warning`,className:`mt-4`,actions:a?(0,G.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Turn on Memory`}):void 0,children:j}):null]}),(0,G.jsx)(Wt,{runs:R,isLoading:te,hasMore:L,isLoadingMore:ie,onLoadMore:()=>void I()})]}),M||w?(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[M?(0,G.jsx)(i,{variant:`outlined`,leftIcon:(0,G.jsx)(f,{className:`h-3.5 w-3.5`}),onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Memory settings`}):null,w?(0,G.jsx)(i,{variant:`primary`,leftIcon:C?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(ge,{className:`h-3.5 w-3.5`}),onClick:w,disabled:k,children:C?`Running…`:`Run now`}):null]}):null]})}function Jt(e){let n=V(),[r]=(0,H.useState)(()=>Date.now()),{data:i,isLoading:a,isError:o,refetch:s}=c(ke(e)),{data:l,isLoading:u,isError:d}=c(gt(e,n,!0)),{recurring:f,oneTime:p,pastOneTime:m}=(0,H.useMemo)(()=>{let e=ht(i??[],r);return{recurring:e.recurring,oneTime:e.upcomingOneTime,pastOneTime:e.pastOneTime}},[r,i]),h=(0,H.useMemo)(()=>new Map((l??[]).map(e=>[e.scheduleId,e])),[l]);return{recurring:f,oneTime:p,pastOneTime:m,usageForSchedule:(0,H.useCallback)(e=>u?{status:`loading`}:d?{status:`error`}:{status:`ready`,summary:h.get(e)??_t(e)},[d,u,h]),handleToggle:(0,H.useCallback)(async(n,r)=>{if(e)try{await Ce(e,n,r),s()}catch(e){t(e,{context:`schedule_toggle`}),k.error(`Failed to toggle schedule.`)}},[e,s]),isLoading:a,isError:o,refetch:(0,H.useCallback)(()=>{s()},[s])}}function Yt(){let e=o(),{scheduleId:t}=a(),n=be(),r=me(),i=V(),s=Jt(n),c=Dt(n,i),l=ye(`memoryOptOut`),u=B.use.settingsDeveloperNav(),d=l&&u===!0,[f,p]=(0,H.useState)(!1),m=t??null,[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(!1),y=(0,H.useCallback)(t=>{e(t?z.schedules.detail(t):z.schedules.root)},[e]),b=m?s.recurring.find(e=>e.id===m)??s.oneTime.find(e=>e.id===m)??s.pastOneTime.find(e=>e.id===m)??null:null;(0,H.useEffect)(()=>{m&&!s.isLoading&&!s.isError&&!b&&y(null)},[m,b,s.isLoading,s.isError,y]);let x=h===`heartbeat`?c.heartbeatConfig!=null:h===`consolidation`?c.consolidationConfig?.available===!0:h===`retrospective`?c.retrospectiveConfig?.available===!0:!1;(0,H.useEffect)(()=>{h&&!c.isLoading&&!x&&g(null)},[h,x,c.isLoading]);let S=(0,H.useCallback)(e=>{g(null),y(e)},[y]),C=(0,H.useCallback)(e=>{m&&y(null),g(e)},[y,m]),w=(0,H.useCallback)(()=>{he(e)},[e]),T=(b?(0,G.jsx)(Pt,{schedule:b,assistantId:n,usage:s.usageForSchedule(b.id),isMobile:r,onClose:()=>y(null),onDeleted:()=>{y(null),s.refetch()}}):null)??(h&&x?(0,G.jsx)(qt,{kind:h,assistantId:n,systemTasks:c,canOpenMemorySettings:d,isMobile:r,onClose:()=>g(null)}):null),E=(0,G.jsx)(Rt,{recurring:s.recurring,oneTime:s.oneTime,pastOneTime:s.pastOneTime,usageForSchedule:s.usageForSchedule,isLoading:s.isLoading,isError:s.isError,refetch:s.refetch,onToggle:s.handleToggle,onSelectSchedule:S,selectedScheduleId:m,onStartNewChat:w,onCreateSchedule:()=>p(!0),pastOpen:_,onPastOpenChange:v,systemTasksSlot:(0,G.jsx)(St,{heartbeatConfig:c.heartbeatConfig,consolidationConfig:c.consolidationConfig,retrospectiveConfig:c.retrospectiveConfig,heartbeatUsage:c.heartbeatUsage,consolidationUsage:c.consolidationUsage,retrospectiveUsage:c.retrospectiveUsage,isLoading:c.isLoading,hasError:c.hasError,onRetry:c.refetchAll,onSelectHeartbeat:()=>C(`heartbeat`),onSelectConsolidation:()=>C(`consolidation`),onSelectRetrospective:()=>C(`retrospective`)})});return T&&r?(0,G.jsx)(je,{children:T}):(0,G.jsxs)(G.Fragment,{children:[T&&!r?(0,G.jsx)(Te,{storageKey:`schedulesDetailDrawerWidth`,detailKey:m??h??void 0,section:E,detail:T}):E,(0,G.jsx)(Ye,{isOpen:f,assistantId:n,onClose:()=>p(!1),onCreated:()=>{p(!1),s.refetch()}})]})}export{Yt as SchedulesPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{P as r,t as i}from"./button-BQVYX8n_.js";import{f as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./typography-Cqi8q9o7.js";import{n as d,t as f}from"./settings-wSv59mkN.js";import{t as p}from"./chart-column-L6Nldm8M.js";import{t as m}from"./chevron-down-DpYf9Gwq.js";import{r as h,t as g}from"./panel-item-An-BBeyL.js";import{t as _}from"./clock-LiCGqvyn.js";import{t as v}from"./loader-circle-Ck8fq3yv.js";import{t as y}from"./repeat-BhXOPeQU.js";import{t as b}from"./x-CswtfvgS.js";import{t as x}from"./notice-DkAWz47A.js";import{i as S,j as C}from"./src-CheJrlfT.js";import{t as w}from"./tag-B6WeUtBW.js";import{n as T,t as E}from"./input-ZpyYt_a0.js";import{t as D}from"./toggle-QSEiPr3k.js";import{t as O}from"./modal-BtcwNEBj.js";import{n as k}from"./toast-Be8FEQ-I.js";import{t as A}from"./dropdown-BxYrCXBS.js";import{F as j,M,N,P,Vt as F,Xt as ee,Yt as te,_ as ne,c as I,d as L,dt as re,ft as ie,g as R,j as ae,mt as oe,pt as se,ut as ce,v as le,y as ue}from"./react-query.gen-C0S0EYHV.js";import{c as z}from"./routes-Cwb-U9H-.js";import{t as de}from"./effective-timezone-Ct3PoWNH.js";import{t as B}from"./assistant-feature-flag-store-aNAjw1qx.js";import{Ao as fe,Da as pe,Ea as me,Oa as he,Wo as ge,ir as V,ys as _e,zs as ve,zt as ye}from"./index-2np2R8qP.js";import{t as be}from"./use-active-assistant-id-DwLFgABu.js";import{t as xe}from"./detail-card-CIh4dCKt.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae,u as je}from"./page-empty-state-DZYd2PGe.js";import{r as Me,t as Ne}from"./profile-metadata-CMym5q9r.js";var H=e(n(),1),Pe={frequency:`daily`,minute:0,hour24:9,weekdays:[1],dayOfMonth:1},U=[{value:0,letter:`S`,short:`Sun`,full:`Sunday`},{value:1,letter:`M`,short:`Mon`,full:`Monday`},{value:2,letter:`T`,short:`Tue`,full:`Tuesday`},{value:3,letter:`W`,short:`Wed`,full:`Wednesday`},{value:4,letter:`T`,short:`Thu`,full:`Thursday`},{value:5,letter:`F`,short:`Fri`,full:`Friday`},{value:6,letter:`S`,short:`Sat`,full:`Saturday`}],Fe=[1,2,3,4,5];function W(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Ie(e){let t=Array.from(new Set(e.map(e=>W(e,0,6)).filter(e=>Number.isInteger(e)))).sort((e,t)=>e-t);return t.length>0?t:[1]}function Le(e){let t=W(e.minute,0,59),n=W(e.hour24,0,23);switch(e.frequency){case`hourly`:return`${t} * * * *`;case`daily`:return`${t} ${n} * * *`;case`weekly`:return`${t} ${n} * * ${Ie(e.weekdays).join(`,`)}`;case`monthly`:return e.dayOfMonth===`last`?`${t} ${n} L * *`:`${t} ${n} ${W(e.dayOfMonth,1,28)} * *`}}function Re(e,t){let n=W(e,0,23),r=W(t,0,59),i=n<12?`AM`:`PM`;return`${n%12==0?12:n%12}:${String(r).padStart(2,`0`)} ${i}`}function ze(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return`${e}${t[(n-20)%10]??t[n]??t[0]}`}function Be(e){let t=Ie(e),n=new Set(t);if(t.length===7)return`every day`;if(t.length===5&&Fe.every(e=>n.has(e)))return`every weekday`;if(t.length===2&&n.has(0)&&n.has(6))return`every weekend`;if(t.length===1)return`every ${U[t[0]]?.full??`day`}`;let r=t.map(e=>U[e]?.short??``),i=r.pop();return`every ${r.join(`, `)} & ${i}`}function Ve(e){let t=Re(e.hour24,e.minute);switch(e.frequency){case`hourly`:{let t=W(e.minute,0,59);return`Runs every hour at :${String(t).padStart(2,`0`)}`}case`daily`:return`Runs every day at ${t}`;case`weekly`:return`Runs ${Be(e.weekdays)} at ${t}`;case`monthly`:return e.dayOfMonth===`last`?`Runs on the last day of every month at ${t}`:`Runs on the ${ze(W(e.dayOfMonth,1,28))} of every month at ${t}`}}var G=l(),He=[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}],Ue=Array.from({length:12},(e,t)=>{let n=t+1;return{value:String(n),label:String(n)}}),We=Array.from({length:12},(e,t)=>{let n=t*5,r=String(n).padStart(2,`0`);return{value:r,label:r}}),Ge=[...Array.from({length:28},(e,t)=>{let n=t+1;return{value:String(n),label:ze(n)}}),{value:`last`,label:`Last day`}],Ke=[{value:`AM`,label:`AM`},{value:`PM`,label:`PM`}];function qe(e,t){let n=e%12;return t===`PM`?n+12:n}function Je(e){try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;return t&&t!==e?`${e} · ${t}`:e}catch{return e}}function Ye({isOpen:e,assistantId:t,onClose:n,onCreated:r}){return(0,G.jsx)(O.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,G.jsx)(Xe,{assistantId:t,onClose:n,onCreated:r}):null})}function Xe({assistantId:e,onClose:t,onCreated:n}){let r=V(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(`simple`),[p,m]=(0,H.useState)(Pe),[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(null),x=a.trim(),S=s.trim(),C=l.trim(),w=h.trim(),D=(0,H.useMemo)(()=>d===`simple`?Le(p):w,[d,p,w]),k=(0,H.useMemo)(()=>d===`simple`?Ve(p):w||`Enter a cron expression to continue.`,[d,p,w]),A=(0,H.useMemo)(()=>Je(r),[r]),j=x.length>0&&S.length>0&&C.length>0&&D.length>0&&!_;return(0,G.jsxs)(O.Content,{size:`md`,children:[(0,G.jsxs)(O.Header,{children:[(0,G.jsx)(O.Title,{children:`Create schedule`}),(0,G.jsx)(O.Description,{children:`Schedule a recurring instruction for your assistant. Runs in execute mode — the message is delivered to the assistant on each fire.`})]}),(0,G.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),j){v(!0),b(null);try{await Ee(e,{name:x,description:S,expression:D,message:C,timezone:r}),v(!1),n()}catch(e){b(e instanceof Error?e.message:`Failed to create schedule.`),v(!1)}}},children:[(0,G.jsx)(O.Body,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,G.jsx)(E,{label:`Name`,placeholder:`Morning briefing`,value:a,onChange:e=>o(e.target.value),required:!0,autoFocus:!0,fullWidth:!0}),(0,G.jsx)(T,{label:`Description`,placeholder:`What is this schedule for?`,value:s,onChange:e=>c(e.target.value),required:!0,fullWidth:!0,rows:2}),(0,G.jsx)(tt,{label:`Repeat`,children:d===`simple`?(0,G.jsx)(Ze,{cadence:p,onChange:m}):(0,G.jsx)(et,{value:h,onChange:g,onUseSimple:()=>f(`simple`)})}),(0,G.jsx)(nt,{summary:k,mono:d===`advanced`&&w.length>0,timezoneLabel:A}),d===`simple`?(0,G.jsx)(`button`,{type:`button`,onClick:()=>{g(e=>e||Le(p)),f(`advanced`)},className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`Advanced — write a cron expression`}):null,(0,G.jsx)(T,{label:`Message`,placeholder:`What should the assistant do on each fire?`,value:l,onChange:e=>u(e.target.value),required:!0,fullWidth:!0,rows:4}),y?(0,G.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:y}):null]})}),(0,G.jsxs)(O.Footer,{children:[(0,G.jsx)(i,{variant:`outlined`,onClick:t,type:`button`,children:`Cancel`}),(0,G.jsx)(i,{variant:`primary`,type:`submit`,disabled:!j,children:_?`Creating…`:`Create schedule`})]})]})]})}function Ze({cadence:e,onChange:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(C,{items:He,value:e.frequency,onChange:n=>t({...e,frequency:n}),ariaLabel:`How often the schedule runs`}),e.frequency===`hourly`?(0,G.jsx)(K,{label:`At minute`,children:(0,G.jsx)(A,{options:We,value:String(e.minute).padStart(2,`0`),onChange:n=>t({...e,minute:Number(n)}),"aria-label":`Minute`,className:`w-24`})}):null,e.frequency===`weekly`?(0,G.jsx)(K,{label:`On these days`,children:(0,G.jsx)($e,{value:e.weekdays,onChange:n=>t({...e,weekdays:n})})}):null,e.frequency===`monthly`?(0,G.jsx)(K,{label:`On day`,children:(0,G.jsx)(A,{options:Ge,value:e.dayOfMonth===`last`?`last`:String(e.dayOfMonth),onChange:n=>t({...e,dayOfMonth:n===`last`?`last`:Number(n)}),"aria-label":`Day of month`,className:`w-32`})}):null,e.frequency===`hourly`?null:(0,G.jsx)(K,{label:`At time`,children:(0,G.jsx)(Qe,{hour24:e.hour24,minute:e.minute,onChange:(n,r)=>t({...e,hour24:n,minute:r})})})]})}function Qe({hour24:e,minute:t,onChange:n}){let r=e<12?`AM`:`PM`,i=e%12==0?12:e%12;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(A,{options:Ue,value:String(i),onChange:e=>n(qe(Number(e),r),t),"aria-label":`Hour`,className:`w-[72px]`}),(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`:`}),(0,G.jsx)(A,{options:We,value:String(t).padStart(2,`0`),onChange:t=>n(e,Number(t)),"aria-label":`Minute`,className:`w-[72px]`}),(0,G.jsx)(`div`,{className:`w-[112px]`,children:(0,G.jsx)(C,{items:Ke,value:r,onChange:e=>n(qe(i,e),t),ariaLabel:`AM or PM`})})]})}function $e({value:e,onChange:t}){let n=new Set(e),i=e=>{let r=new Set(n);r.has(e)?r.size>1&&r.delete(e):r.add(e),t([...r].sort((e,t)=>e-t))};return(0,G.jsx)(`div`,{className:`flex gap-1.5`,children:U.map(e=>{let t=n.has(e.value);return(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),"aria-pressed":t,"aria-label":e.full,title:e.full,className:r(`flex h-9 w-9 items-center justify-center rounded-md border text-body-medium-default transition-colors`,t?`border-[var(--border-active)] bg-[var(--surface-active)] text-[var(--content-emphasised)]`:`border-[var(--field-border)] text-[var(--content-tertiary)] hover:border-[var(--border-active)] hover:text-[var(--content-default)]`),children:e.letter},e.value)})})}function et({value:e,onChange:t,onUseSimple:n}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(E,{placeholder:`0 9 * * *`,value:e,onChange:e=>t(e.target.value),fullWidth:!0,className:`font-mono`,"aria-label":`Cron expression`,helperText:`Standard 5-field cron (minute hour day month weekday). RRULE expressions are also accepted.`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`← Back to the simple builder`})]})}function tt({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:e}),t]})}function K({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-[88px] text-body-small-default text-[var(--content-tertiary)]`,children:e}),t]})}function nt({summary:e,mono:t,timezoneLabel:n}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-3.5 py-3`,children:[(0,G.jsx)(_,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:r(`text-body-medium-default text-[var(--content-default)]`,t&&`break-all font-mono`),children:e}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Times use your timezone — `,n,`.`]})]})]})}function rt(e=de(),t=Date.now()){return Me(`7d`,e,t)}function q(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0}):`—`}function it(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}var at=new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2});function J(e){return e==null||!Number.isFinite(e)?`—`:at.format(e)}function Y(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}function ot(e){let t=Math.round(e/6e4);return t>=60&&t%60==0?`Every ${t/60} hr`:`Every ${t} min`}function st(e){if(!e)return;let t=new Set,n=[];for(let r of e)for(let e of r.runs)t.has(e.id)||(t.add(e.id),n.push(e));return n}function ct(e){return!!e.conversationId&&e.conversationExists===!0&&e.conversationArchivedAt==null}function lt(e){return ct(e)?e.conversationId??null:null}function X(e){return typeof e==`string`&&e.length>0}var ut={heartbeat:`system-heartbeat`,consolidation:`system-consolidation`,retrospective:`system-memory-retrospective`};function dt(e){if(e.cronExpression)return e.timezone?`Cron: ${e.cronExpression} (${e.timezone})`:`Cron: ${e.cronExpression}`;let t=ot(e.intervalMs);return e.activeHoursStart!=null&&e.activeHoursEnd!=null&&(t+=` (${e.activeHoursStart}:00–${e.activeHoursEnd}:00)`),t}function ft(e){return ot(e.intervalMs)}var pt=`After conversation activity`;function mt(e,t){return e.status===`fired`||e.status===`cancelled`?!0:e.status===`firing`?!1:e.nextRunAt==null||!e.enabled&&e.nextRunAt<=t}function ht(e,t){let n=[],r=[],i=[];for(let a of e)a.isOneShot?mt(a,t)?i.push(a):r.push(a):n.push(a);return n.sort((e,t)=>e.enabled===t.enabled?(e.nextRunAt??1/0)-(t.nextRunAt??1/0):e.enabled?-1:1),r.sort((e,t)=>(e.nextRunAt??1/0)-(t.nextRunAt??1/0)),i.sort((e,t)=>{let n=e.lastRunAt??e.nextRunAt??0;return(t.lastRunAt??t.nextRunAt??0)-n}),{recurring:n,upcomingOneTime:r,pastOneTime:i}}function gt(e,t,n=!0){return{queryKey:[{_id:`schedulesUsagesummaryGet`,path:{assistant_id:e??``},_tz:t}],queryFn:()=>e?Se(e,rt(t)):Promise.resolve([]),enabled:n,staleTime:1e4}}function _t(e){return{scheduleId:e,runCount:0,totalEstimatedCostUsd:0,eventCount:0}}function vt(e,t,n){let r=(t??[]).filter(e=>{let t=e.startedAt??e.createdAt;return t>=n.from&&t<=n.to});return{scheduleId:e,runCount:r.length,totalEstimatedCostUsd:r.reduce((e,t)=>{let n=t.estimatedCostUsd;return typeof n==`number`&&Number.isFinite(n)?e+n:e},0),eventCount:0}}function yt({status:e}){return(0,G.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:e===`ok`||e===`completed`?`var(--system-positive-strong)`:e===`error`||e===`failed`?`var(--system-negative-strong)`:`var(--content-tertiary)`},"aria-label":e??`unknown`})}function bt({scheduleName:e,usage:t,onOpenUsage:n}){if(t.status===`loading`)return(0,G.jsxs)(`div`,{"aria-label":`Loading schedule usage`,className:`flex w-[156px] shrink-0 items-center justify-end gap-3`,children:[(0,G.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,G.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`})]});let r=t.status===`error`,i=r?`--`:J(t.summary.totalEstimatedCostUsd),a=r?`--`:Y(t.summary.runCount),o=t.status===`ready`&&!(t.summary.totalEstimatedCostUsd>0),s=t.status===`ready`&&t.summary.runCount===0,c=o?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`,l=s?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`;return(0,G.jsxs)(`div`,{className:`flex w-[156px] shrink-0 items-center justify-end gap-3 text-right text-body-small-default`,children:[n?(0,G.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`View usage for ${e}`,className:`min-w-[64px] cursor-pointer rounded px-1 py-0.5 text-right transition-colors hover:bg-[var(--surface-hover)] ${c}`,children:i}):(0,G.jsx)(`span`,{"aria-label":`Cost for ${e} in the last 7 days: ${i}`,className:`block min-w-[64px] px-1 py-0.5 ${c}`,children:i}),(0,G.jsx)(`span`,{"aria-label":`Runs for ${e} in the last 7 days: ${a}`,className:`block min-w-[64px] px-1 py-0.5 ${l}`,children:a})]})}function xt({name:e,subtitle:t,enabled:n,nextRunAt:r,lastRunAt:i,usage:a,helperText:o,statusLabel:s,statusTone:c=`neutral`,onClick:l}){return(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md px-2 py-3 transition-colors hover:bg-[var(--surface-hover)] [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:l,"aria-label":`Open ${e}`,className:`flex min-w-0 flex-1 cursor-pointer flex-wrap items-center gap-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e})}),(0,G.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t}),o?(0,G.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-secondary)]`,children:o}):null,(0,G.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-body-small-default text-[var(--content-tertiary)]`,children:[r?(0,G.jsxs)(`span`,{children:[`Next: `,q(r)]}):null,i?(0,G.jsxs)(`span`,{children:[`Last: `,q(i)]}):null]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-3`,children:[(0,G.jsx)(bt,{scheduleName:e,usage:a}),s?(0,G.jsx)(w,{tone:c,children:s}):(0,G.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:n?`var(--system-positive-strong)`:`var(--content-disabled)`},"aria-label":n?`enabled`:`disabled`}),(0,G.jsx)(h,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})})}function St({heartbeatConfig:e,consolidationConfig:t,retrospectiveConfig:n,heartbeatUsage:r,consolidationUsage:i,retrospectiveUsage:a,isLoading:o,hasError:s,onRetry:c,onSelectHeartbeat:l,onSelectConsolidation:u,onSelectRetrospective:d}){let f=e!=null,p=t?.available===!0,h=n?.available===!0,g=f||p||h;if(!o&&!s&&!g)return null;let _=[...f?[r]:[],...p?[i]:[],...h?[a]:[]].filter(e=>e.status===`ready`),y=_.reduce((e,t)=>e+(t.summary.totalEstimatedCostUsd??0),0),b=o?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):s&&!g?(0,G.jsxs)(x,{tone:`error`,children:[`Failed to load system jobs.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):(0,G.jsxs)(`div`,{children:[f?(0,G.jsx)(xt,{name:`Heartbeat`,subtitle:dt(e),enabled:e.enabled,nextRunAt:e.nextRunAt,lastRunAt:e.lastRunAt,usage:r,onClick:l}):null,p?(0,G.jsx)(xt,{name:`Consolidation`,subtitle:ft(t),enabled:t.enabled,helperText:t.enabled?void 0:`Memory is off, so consolidation is paused.`,nextRunAt:t.nextRunAt,lastRunAt:t.lastRunAt,usage:i,statusLabel:t.enabled?void 0:`Paused`,statusTone:`warning`,onClick:u}):null,h?(0,G.jsx)(xt,{name:`Memory retrospective`,subtitle:pt,enabled:n.enabled,helperText:n.enabled?void 0:`Memory is off, so retrospectives are paused.`,nextRunAt:n.nextRunAt,lastRunAt:n.lastRunAt,usage:a,statusLabel:n.enabled?void 0:`Paused`,statusTone:`warning`,onClick:d}):null,s?(0,G.jsx)(`div`,{className:`pt-3 first:pt-0`,children:(0,G.jsxs)(x,{tone:`error`,children:[`Some system jobs failed to load.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})}):null]});return(0,G.jsx)(xe,{children:(0,G.jsx)(S.Root,{type:`multiple`,children:(0,G.jsxs)(S.Item,{value:`system-jobs`,children:[(0,G.jsxs)(S.Trigger,{className:`group justify-between gap-3`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1 text-left`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`System`}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Built-in jobs managed by the assistant runtime`})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[_.length>0?(0,G.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[J(y),` (7d)`]}):null,(0,G.jsx)(m,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]})]}),(0,G.jsx)(S.Content,{children:(0,G.jsx)(`div`,{className:`mt-3`,children:b})})]})})})}function Z(e,t){return{id:e.id,jobId:t,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:`skipReason`in e&&e.skipReason?`Skipped: ${e.skipReason}`:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt,...`title`in e?{title:e.title}:{}}}function Ct(e){return e.runs.map(e=>Z(e,`heartbeat`))}function wt(e){return e.runs.map(e=>Z(e,`consolidation`))}function Tt(e){return e.runs.map(e=>Z(e,`retrospective`))}var Q=1e4;function Et(e,t,n,r,i){return e?{status:`loading`}:t?{status:`error`}:{status:`ready`,summary:vt(n,r,i)}}function Dt(e,n){let r=s(),i={path:{assistant_id:e??``}},{data:a,isLoading:o,isError:l,refetch:u}=c({...ae(i),enabled:!!e,staleTime:Q}),{data:d,isLoading:f,isError:p,refetch:m}=c({...R(i),enabled:!!e,staleTime:Q}),{data:h,isLoading:g,isError:_,refetch:v}=c({...ce(i),enabled:!!e,staleTime:Q}),y={path:{assistant_id:e??``},query:{limit:100}},{data:b,isLoading:x,isError:S,refetch:C}=c({...j(y),select:Ct,enabled:!!e&&a!=null,staleTime:Q}),{data:w,isLoading:T,isError:E,refetch:D}=c({...ue(y),select:wt,enabled:!!e&&d?.available===!0,staleTime:Q}),{data:O,isLoading:A,isError:N,refetch:ne}=c({...se(y),select:Tt,enabled:!!e&&h?.available===!0,staleTime:Q}),I=(0,H.useMemo)(()=>rt(n),[n]),L=(0,H.useMemo)(()=>Et(x,S,ut.heartbeat,b,I),[b,S,x,I]),re=(0,H.useMemo)(()=>Et(T,E,ut.consolidation,w,I),[w,E,T,I]),oe=(0,H.useMemo)(()=>Et(A,N,ut.retrospective,O,I),[O,N,A,I]),z=t=>{if(!e)return;let n={heartbeat:{config:ae(i).queryKey,runs:j(y).queryKey,infinite:P(i)},consolidation:{config:R(i).queryKey,runs:ue(y).queryKey,infinite:le(i)},retrospective:{config:ce(i).queryKey,runs:se(y).queryKey,infinite:ie(i)}}[t];r.invalidateQueries({queryKey:n.config}),r.invalidateQueries({queryKey:n.runs}),r.invalidateQueries({queryKey:n.infinite})},de=ee({onSuccess:e=>{e.ran?k.success(`Heartbeat started.`):k.info(`Heartbeat skipped.`)},onError:e=>{t(e,{context:`heartbeat_run_now`}),k.error(`Failed to run heartbeat.`)},onSettled:()=>z(`heartbeat`)}),B=F({onSuccess:e=>{e.ran?k.success(`Consolidation queued.`):k.info(`Consolidation already queued or running.`)},onError:e=>{t(e,{context:`consolidation_run_now`}),k.error(`Failed to run consolidation.`)},onSettled:()=>z(`consolidation`)}),fe=te({onSuccess:e=>{M(r,i,e),k.success(e.enabled?`Heartbeat enabled.`:`Heartbeat disabled.`)},onError:e=>{t(e,{context:`heartbeat_toggle`}),k.error(`Failed to toggle heartbeat.`)}});return{heartbeatConfig:a,consolidationConfig:d,retrospectiveConfig:h,heartbeatUsage:L,consolidationUsage:re,retrospectiveUsage:oe,isLoading:o||f||g,hasError:l||p||_,isHeartbeatRunning:de.isPending,isConsolidationRunning:B.isPending,isHeartbeatLoading:o,isHeartbeatError:l,isConsolidationLoading:f,isConsolidationError:p,isRetrospectiveLoading:g,isRetrospectiveError:_,refetchHeartbeat:u,refetchConsolidation:m,refetchRetrospective:v,runHeartbeatNow:()=>{e&&de.mutate({path:{assistant_id:e}})},runConsolidationNow:()=>{e&&B.mutate({path:{assistant_id:e}})},toggleHeartbeat:t=>{e&&fe.mutate({body:{enabled:t},path:{assistant_id:e}})},refetchAll:()=>{u(),m(),v(),C(),D(),ne()}}}function Ot({children:e}){return(0,G.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function $({label:e,value:t}){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-1`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e}),(0,G.jsx)(`span`,{className:`min-w-0 text-right text-body-medium-lighter text-[var(--content-default)]`,children:t})]})}function kt({icon:e,value:t,label:n}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] p-3`,children:[(0,G.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--surface-sunken)] text-[var(--content-secondary)]`,children:e}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-body-large-default text-[var(--content-default)]`,children:t}),(0,G.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n})]})]})}function At({usage:e}){return e.status===`loading`?(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:Array.from({length:2},(e,t)=>(0,G.jsx)(`div`,{className:`h-[60px] animate-pulse rounded-lg bg-[var(--surface-muted)]`},t))}):e.status===`error`?null:(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:[(0,G.jsx)(kt,{icon:(0,G.jsx)(_e,{className:`h-4 w-4`}),value:J(e.summary.totalEstimatedCostUsd),label:`7 Day Cost`}),(0,G.jsx)(kt,{icon:(0,G.jsx)(y,{className:`h-4 w-4`}),value:Y(e.summary.runCount),label:`7 Day Runs`})]})}function jt(e){return e.exists&&e.archivedAt==null}function Mt({run:e,index:t,isExpanded:n,disableDirectOpen:i,onOpenConversation:a,onToggleDetails:o}){let s=lt(e),c=e.conversations??(s?[{id:s,title:null,exists:!0,archivedAt:null}]:[]),l=X(e.output),u=X(e.error),d=!i&&c.length===1&&jt(c[0])?c[0].id:null,f=!d&&(c.length>0||l||u),p=`schedule-run-details-${t}`,m=!!d||f,g=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yt,{status:e.status}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:q(e.startedAt)}),(0,G.jsxs)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[it(e.durationMs),` ·`,` `,J(e.estimatedCostUsd)]}),e.status===`error`&&e.error?(0,G.jsxs)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--system-negative-strong)]`,children:[e.error.slice(0,120),e.error.length>120?`…`:``]}):null]}),m?(0,G.jsx)(h,{className:r(`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform`,f&&n?`rotate-90`:``)}):null]}),_=f&&n?(0,G.jsx)(`div`,{id:p,className:`px-2 pb-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[c.length>0?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Conversations`}),(0,G.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>jt(e)?(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full truncate text-left text-body-small-default text-[var(--content-default)] hover:underline`,children:X(e.title)?e.title:`Conversation`},e.id):(0,G.jsxs)(`span`,{className:`block truncate text-body-small-default text-[var(--content-tertiary)] italic`,children:[X(e.title)?e.title:`Conversation`,` `,e.exists?`(archived)`:`(unavailable)`]},e.id))})]}):null,l?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,u?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null;return d?(0,G.jsx)(`div`,{children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(d),"aria-label":`Open conversation for run at ${q(e.startedAt)}`,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g})}):f?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-label":`Toggle details for run at ${q(e.startedAt)}`,"aria-expanded":n,"aria-controls":p,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g}),_]}):(0,G.jsx)(`div`,{className:`flex items-center gap-3 px-2 py-3`,children:g})}function Nt({runs:e,isLoading:t,disableDirectOpen:n,onOpenConversation:r}){let[i,a]=(0,H.useState)(null);return t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,G.jsx)(`p`,{className:`py-2 text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:`No runs yet.`}):(0,G.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.map((e,t)=>(0,G.jsx)(Mt,{run:e,index:t,isExpanded:i===e.id,disableDirectOpen:n,onOpenConversation:r,onToggleDetails:e=>a(t=>t===e?null:e)},e.id))})}function Pt({schedule:e,assistantId:n,usage:a,isMobile:s,onClose:l,onDeleted:d}){let f=o(),{data:m,isLoading:h}=c({queryKey:oe({path:{assistant_id:n,id:e.id}}),queryFn:()=>we(n,e.id),staleTime:1e4}),[g,_]=(0,H.useState)(!1),[y,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(!1),w=async()=>{_(!0);try{await De(n,e.id)}catch(e){t(e,{context:`schedule_run_now`}),k.error(`Failed to run schedule.`)}finally{_(!1)}},T=async()=>{C(!0);try{await Oe(n,e.id),d()}catch(e){t(e,{context:`schedule_delete`}),k.error(`Failed to delete schedule.`),C(!1),x(!1)}};return(0,G.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:e.name})}),(0,G.jsx)(i,{variant:`ghost`,iconOnly:(0,G.jsx)(b,{}),onClick:l,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[e.description?(0,G.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e.description}):null,(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Ot,{children:`Details`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-2`,children:[e.cadenceDescription?(0,G.jsx)($,{label:`Cadence`,value:e.cadenceDescription}):null,(0,G.jsx)($,{label:`Mode`,value:e.mode}),(0,G.jsx)($,{label:`Status`,value:e.enabled?`Enabled`:`Disabled`}),(0,G.jsx)($,{label:`Next run`,value:q(e.nextRunAt)}),e.lastRunAt?(0,G.jsx)($,{label:`Last run`,value:(0,G.jsxs)(`span`,{className:`flex items-center justify-end gap-2`,children:[(0,G.jsx)(yt,{status:e.lastStatus}),q(e.lastRunAt)]})}):null]})]}),(0,G.jsx)(At,{usage:a}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Ot,{children:`Recent runs`}),(0,G.jsx)(Nt,{runs:m?.runs,isLoading:h,disableDirectOpen:e.mode===`script`,onOpenConversation:e=>pe(f,e)})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[y?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),disabled:S,children:`Cancel`}),(0,G.jsx)(i,{variant:`danger`,onClick:()=>void T(),disabled:S,children:S?`Deleting…`:`Yes, delete`})]}):(0,G.jsx)(i,{variant:`dangerOutline`,leftIcon:(0,G.jsx)(fe,{className:`h-3.5 w-3.5`}),onClick:()=>x(!0),children:`Delete`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(i,{variant:`outlined`,leftIcon:(0,G.jsx)(p,{className:`h-3.5 w-3.5`}),onClick:()=>f(z.settings.usageForSchedule(e.id)),children:`View usage`}),e.mode===`script`?(0,G.jsx)(i,{variant:`primary`,leftIcon:g?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):void 0,onClick:()=>void w(),disabled:g,children:g?`Running…`:`Run now`}):null]})]})]})}function Ft(e){if(e.status===`loading`)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`h-4 w-12 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,G.jsx)(`span`,{className:`h-4 w-10 animate-pulse rounded bg-[var(--surface-muted)]`})]});if(e.status===`error`)return(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`—`});let{summary:t}=e;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:J(t.totalEstimatedCostUsd)}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:Y(t.runCount)})]})}function It({name:e,metaParts:t,usage:n,enabled:r,selected:i,onClick:a,onToggle:o,toggleAriaLabel:s}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md px-2 py-3 transition-colors [&+&]:border-t [&+&]:border-[var(--border-base)] ${i?`bg-[var(--surface-active)]`:`hover:bg-[var(--surface-hover)]`}`,children:[o?(0,G.jsx)(D,{checked:r,onChange:o,"aria-label":s}):null,(0,G.jsxs)(`button`,{type:`button`,onClick:a,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-4 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e}),t.length>0?(0,G.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 text-label-small-default text-[var(--content-tertiary)]`,children:t.map((e,t)=>(0,G.jsxs)(H.Fragment,{children:[t>0?(0,G.jsx)(`span`,{className:`h-[3px] w-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}):null,(0,G.jsx)(`span`,{className:`truncate`,children:e})]},t))}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4`,children:[Ft(n),(0,G.jsx)(h,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})]})}function Lt({schedule:e,usage:t,selected:n,onClick:r,onToggle:i}){let a=e.isOneShot?``:e.cadenceDescription.trim(),o=e.lastRunAt??e.nextRunAt,s=[a,o?q(o):``].filter(Boolean);return(0,G.jsx)(It,{name:e.name,metaParts:s,usage:t,enabled:e.enabled,selected:n,onClick:r,onToggle:i,toggleAriaLabel:i?`Toggle ${e.name}`:void 0})}function Rt({recurring:e,oneTime:t,pastOneTime:n,usageForSchedule:r,isLoading:a,isError:o,refetch:s,onToggle:c,onSelectSchedule:l,selectedScheduleId:u,onStartNewChat:f,onCreateSchedule:p,pastOpen:m,onPastOpenChange:g,systemTasksSlot:_}){let v=e=>(0,G.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id),onToggle:t=>c(e.id,t)},e.id),y=e=>(0,G.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id)},e.id),b=n.length>0?(0,G.jsx)(S.Root,{type:`single`,collapsible:!0,className:`mt-3`,value:m?`past`:``,onValueChange:e=>g(e===`past`),children:(0,G.jsxs)(S.Item,{value:`past`,children:[(0,G.jsxs)(S.Trigger,{className:`group gap-[var(--app-spacing-xs)] px-2 text-label-small-default text-[var(--content-tertiary)]`,children:[(0,G.jsx)(h,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,G.jsxs)(`span`,{children:[`Past (`,n.length,`)`]})]}),(0,G.jsx)(S.Content,{children:(0,G.jsx)(`div`,{className:`pt-1`,children:n.map(y)})})]})}):null;return(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[a?(0,G.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2},(e,t)=>(0,G.jsx)(`div`,{className:`h-12 animate-pulse rounded-md bg-[var(--surface-muted)]`},t))}):o&&e.length===0?(0,G.jsx)(x,{tone:`error`,actions:(0,G.jsx)(`button`,{type:`button`,onClick:s,className:`cursor-pointer underline hover:no-underline`,children:`Retry`}),children:`Failed to load schedules.`}):e.length===0&&t.length===0&&n.length===0?(0,G.jsx)(Ae,{icon:d,title:`No schedules yet`,description:`Ask your assistant to set one up, or create one yourself.`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(i,{variant:`primary`,size:`regular`,onClick:f,children:`New Conversation`}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`or`}),(0,G.jsx)(i,{variant:`outlined`,size:`regular`,onClick:p,children:`Create schedule`})]})}):(0,G.jsxs)(`div`,{children:[e.map(v),t.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mt-3 px-2 text-label-small-default text-[var(--content-tertiary)]`,children:`One-time`}),t.map(y)]}):null,b]}),_?(0,G.jsx)(`div`,{className:`mt-[var(--app-spacing-lg)]`,children:_}):null]})}var zt=`Default (assistant's main model)`,Bt=`Custom call-site model`;function Vt(e,t){return t?.[e]?.displayName??e}function Ht(e,t){if(e==null)return;if(e.provider!=null||e.model!=null)return Bt;let n=e.profile?.trim();return n?`Override (${Vt(n,t)})`:void 0}function Ut({assistantId:e,pinnedProfile:t,defaultCallSite:n=`mainAgent`,fallbackLabel:r=zt,respectCallSiteOverride:i=!1}){let a=t==null,{data:o}=c({...I({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4}),s=(0,H.useMemo)(()=>o?Ne(o):{},[o]),{data:l}=c({...L({path:{assistant_id:e}}),enabled:!!e&&a,staleTime:6e4}),u=a&&i?Ht(o?.llm?.callSites?.[n],s):void 0,d=a?l?.callSites.find(e=>e.id===n)?.defaultProfile:void 0,f=t==null?u??(d==null?r:`Default (${Vt(d,s)})`):Vt(t,s);return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Model profile`}),(0,G.jsx)(`span`,{className:`min-w-0 text-right`,children:f})]})}function Wt({runs:e,isLoading:t,emptyMessage:n=`No runs yet.`,hasMore:r=!1,isLoadingMore:a=!1,onLoadMore:s}){let c=o(),[l,u]=(0,H.useState)(null);return(0,G.jsx)(xe,{title:`Recent runs`,children:t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,G.jsx)(`p`,{className:`py-4 text-center text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:n}):(0,G.jsxs)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:[e.map((e,t)=>{let n=lt(e),r=X(e.output),i=X(e.error),a=!n&&(r||i),o=l===e.id,s=`schedule-run-details-${t}`;return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(g,{label:(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,G.jsx)(yt,{status:e.status}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-body-medium-lighter text-[var(--content-default)]`,children:X(e.title)?e.title:q(e.startedAt)}),(0,G.jsxs)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[X(e.title)?`${q(e.startedAt)} · `:``,it(e.durationMs),` ·`,` `,J(e.estimatedCostUsd),e.status===`error`&&e.error&&(0,G.jsxs)(`span`,{className:`ml-2 text-[var(--system-negative-strong)]`,children:[e.error.slice(0,80),e.error.length>80?`…`:``]})]})]}),n||a?(0,G.jsx)(h,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform ${o?`rotate-90`:``}`}):null]}),onSelect:n?()=>pe(c,n):a?()=>u(o?null:e.id):void 0,"aria-label":`Run at ${q(e.startedAt)}`,"aria-expanded":a?o:void 0,"aria-controls":a?s:void 0,className:`h-auto py-2.5 gap-3 -mx-2 px-2`}),a&&o?(0,G.jsx)(`div`,{id:s,className:`px-2 pb-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[r?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,i?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null]},e.id)}),r&&s?(0,G.jsx)(`div`,{className:`flex justify-center pt-3`,children:(0,G.jsx)(i,{variant:`outlined`,size:`compact`,onClick:s,disabled:a,leftIcon:a?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):void 0,children:a?`Loading…`:`Load more`})}):null]})})}var Gt={heartbeat:`heartbeatAgent`,consolidation:`memoryV2Consolidation`,retrospective:`memoryRetrospective`};function Kt({children:e}){return(0,G.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function qt({kind:e,assistantId:t,systemTasks:n,canOpenMemorySettings:a,isMobile:s,onClose:c}){let l=o(),{heartbeatConfig:d,consolidationConfig:p,retrospectiveConfig:m}=n,h,g,_,y,S,C,w;e===`heartbeat`?(h=`Heartbeat`,g=d?dt(d):``,_=d?.enabled??!1,y=d?.nextRunAt??null,S=d?.lastRunAt??null,C=n.isHeartbeatRunning,w=n.runHeartbeatNow):e===`consolidation`?(h=`Consolidation`,g=p?ft(p):``,_=p?.enabled??!1,y=p?.nextRunAt??null,S=p?.lastRunAt??null,C=n.isConsolidationRunning,w=n.runConsolidationNow):(h=`Memory retrospective`,g=pt,_=m?.enabled??!1,y=m?.nextRunAt??null,S=m?.lastRunAt??null,C=!1,w=void 0);let T=e!==`heartbeat`,E=e===`retrospective`,O=T&&!_,k=C||O,A=T?_?`On · Managed by Memory`:`Paused`:_?`Enabled`:`Disabled`,j=E?`Memory is off, so retrospectives are paused. Turn Memory back on to resume them.`:`Memory is off, so consolidation is paused. Turn Memory back on to resume consolidation.`,M=T&&_&&a,P={path:{assistant_id:t},query:{limit:25}},F=e===`heartbeat`?N(P):e===`consolidation`?ne(P):re(P),{data:ee,isLoading:te,fetchNextPage:I,hasNextPage:L,isFetchingNextPage:ie}=ve({queryKey:F.queryKey,queryFn:F.queryFn,initialPageParam:{path:P.path,query:{}},getNextPageParam:e=>e.nextCursor??void 0,staleTime:1e4}),R=st(ee?.pages.map(t=>({runs:t.runs.map(t=>Z(t,e))})));return(0,G.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:h}),g?(0,G.jsx)(u,{variant:`body-small-default`,as:`p`,className:`truncate text-[var(--content-tertiary)]`,children:g}):null]}),(0,G.jsx)(i,{variant:`ghost`,iconOnly:(0,G.jsx)(b,{}),onClick:c,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Kt,{children:`Details`}),(0,G.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-3 text-body-medium-lighter`,children:[(0,G.jsx)(Ut,{assistantId:t,defaultCallSite:Gt[e],fallbackLabel:`Default (system task model)`,respectCallSiteOverride:!0}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--content-default)]`,children:[(0,G.jsx)(`span`,{children:A}),T?null:(0,G.jsx)(D,{checked:_,onChange:n.toggleHeartbeat,"aria-label":`Toggle ${h}`})]})]}),E?null:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,G.jsx)(`span`,{className:`text-[var(--content-default)]`,children:q(y)})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,G.jsx)(`span`,{className:`text-[var(--content-default)]`,children:q(S)})]})]}),O?(0,G.jsx)(x,{tone:`warning`,className:`mt-4`,actions:a?(0,G.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Turn on Memory`}):void 0,children:j}):null]}),(0,G.jsx)(Wt,{runs:R,isLoading:te,hasMore:L,isLoadingMore:ie,onLoadMore:()=>void I()})]}),M||w?(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[M?(0,G.jsx)(i,{variant:`outlined`,leftIcon:(0,G.jsx)(f,{className:`h-3.5 w-3.5`}),onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Memory settings`}):null,w?(0,G.jsx)(i,{variant:`primary`,leftIcon:C?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(ge,{className:`h-3.5 w-3.5`}),onClick:w,disabled:k,children:C?`Running…`:`Run now`}):null]}):null]})}function Jt(e){let n=V(),[r]=(0,H.useState)(()=>Date.now()),{data:i,isLoading:a,isError:o,refetch:s}=c(ke(e)),{data:l,isLoading:u,isError:d}=c(gt(e,n,!0)),{recurring:f,oneTime:p,pastOneTime:m}=(0,H.useMemo)(()=>{let e=ht(i??[],r);return{recurring:e.recurring,oneTime:e.upcomingOneTime,pastOneTime:e.pastOneTime}},[r,i]),h=(0,H.useMemo)(()=>new Map((l??[]).map(e=>[e.scheduleId,e])),[l]);return{recurring:f,oneTime:p,pastOneTime:m,usageForSchedule:(0,H.useCallback)(e=>u?{status:`loading`}:d?{status:`error`}:{status:`ready`,summary:h.get(e)??_t(e)},[d,u,h]),handleToggle:(0,H.useCallback)(async(n,r)=>{if(e)try{await Ce(e,n,r),s()}catch(e){t(e,{context:`schedule_toggle`}),k.error(`Failed to toggle schedule.`)}},[e,s]),isLoading:a,isError:o,refetch:(0,H.useCallback)(()=>{s()},[s])}}function Yt(){let e=o(),{scheduleId:t}=a(),n=be(),r=me(),i=V(),s=Jt(n),c=Dt(n,i),l=ye(`memoryOptOut`),u=B.use.settingsDeveloperNav(),d=l&&u===!0,[f,p]=(0,H.useState)(!1),m=t??null,[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(!1),y=(0,H.useCallback)(t=>{e(t?z.schedules.detail(t):z.schedules.root)},[e]),b=m?s.recurring.find(e=>e.id===m)??s.oneTime.find(e=>e.id===m)??s.pastOneTime.find(e=>e.id===m)??null:null;(0,H.useEffect)(()=>{m&&!s.isLoading&&!s.isError&&!b&&y(null)},[m,b,s.isLoading,s.isError,y]);let x=h===`heartbeat`?c.heartbeatConfig!=null:h===`consolidation`?c.consolidationConfig?.available===!0:h===`retrospective`?c.retrospectiveConfig?.available===!0:!1;(0,H.useEffect)(()=>{h&&!c.isLoading&&!x&&g(null)},[h,x,c.isLoading]);let S=(0,H.useCallback)(e=>{g(null),y(e)},[y]),C=(0,H.useCallback)(e=>{m&&y(null),g(e)},[y,m]),w=(0,H.useCallback)(()=>{he(e)},[e]),T=(b?(0,G.jsx)(Pt,{schedule:b,assistantId:n,usage:s.usageForSchedule(b.id),isMobile:r,onClose:()=>y(null),onDeleted:()=>{y(null),s.refetch()}}):null)??(h&&x?(0,G.jsx)(qt,{kind:h,assistantId:n,systemTasks:c,canOpenMemorySettings:d,isMobile:r,onClose:()=>g(null)}):null),E=(0,G.jsx)(Rt,{recurring:s.recurring,oneTime:s.oneTime,pastOneTime:s.pastOneTime,usageForSchedule:s.usageForSchedule,isLoading:s.isLoading,isError:s.isError,refetch:s.refetch,onToggle:s.handleToggle,onSelectSchedule:S,selectedScheduleId:m,onStartNewChat:w,onCreateSchedule:()=>p(!0),pastOpen:_,onPastOpenChange:v,systemTasksSlot:(0,G.jsx)(St,{heartbeatConfig:c.heartbeatConfig,consolidationConfig:c.consolidationConfig,retrospectiveConfig:c.retrospectiveConfig,heartbeatUsage:c.heartbeatUsage,consolidationUsage:c.consolidationUsage,retrospectiveUsage:c.retrospectiveUsage,isLoading:c.isLoading,hasError:c.hasError,onRetry:c.refetchAll,onSelectHeartbeat:()=>C(`heartbeat`),onSelectConsolidation:()=>C(`consolidation`),onSelectRetrospective:()=>C(`retrospective`)})});return T&&r?(0,G.jsx)(je,{children:T}):(0,G.jsxs)(G.Fragment,{children:[T&&!r?(0,G.jsx)(Te,{storageKey:`schedulesDetailDrawerWidth`,detailKey:m??h??void 0,section:E,detail:T}):E,(0,G.jsx)(Ye,{isOpen:f,assistantId:n,onClose:()=>p(!1),onCreated:()=>{p(!1),s.refetch()}})]})}export{Yt as SchedulesPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./check-wF3S-AV4.js";import{t as s}from"./modal-BtcwNEBj.js";import{t as c}from"./confirm-dialog-Zyfei9GV.js";import{P as l,j as u,k as d,lt as f,rt as p,t as ee,u as m}from"./local-mode-Dydd46cS.js";import{t as h}from"./is-electron-y5bNUVyG.js";import{n as g}from"./resolved-assistants-store-DdHm-7v4.js";import{D as _,O as v,i as te,n as y}from"./auth-store-B8Es53B9.js";import{c as b}from"./routes-Cwb-U9H-.js";import{t as x}from"./use-onboarding-login-Db_0_ZZI.js";import{bs as S,g as C,nr as w,pn as T,ss as E,tr as D}from"./index-D7_9Qy0L.js";var O=e(t(),1),k=a();function A({open:e,assistantName:t,isPending:r,errorMessage:i,onCancel:a,onRepair:o,onRetire:l}){let[u,d]=(0,O.useState)(`menu`);(0,O.useEffect)(()=>{e&&d(`menu`)},[e]);let f=i?(0,k.jsx)(`span`,{className:`mt-3 block text-body-small-default text-[var(--system-negative-strong)]`,children:i}):null;return u===`confirm-repair`?(0,k.jsx)(c,{open:e,title:`Repair Assistant?`,message:(0,k.jsxs)(k.Fragment,{children:[`Repairing re-provisions this assistant’s authentication token. Any other devices or browser sessions connected to it will be signed out and need to reconnect.`,f]}),confirmLabel:`Repair`,isPending:r,onConfirm:o,onCancel:()=>d(`menu`)}):u===`confirm-retire`?(0,k.jsx)(D,{open:e,isPending:r,extraMessage:f,onConfirm:l,onCancel:()=>d(`menu`)}):(0,k.jsx)(s.Root,{open:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,k.jsxs)(s.Content,{size:`sm`,hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),r||a()},children:[(0,k.jsx)(s.Header,{children:(0,k.jsx)(s.Title,{children:`Can’t Authenticate Assistant`})}),(0,k.jsxs)(s.Body,{children:[(0,k.jsxs)(s.Description,{children:[`The authentication token for `,t,` is missing or can no longer be refreshed, so this assistant can’t be connected. You can repair it, retire it, or pick a different assistant.`]}),f,(0,k.jsxs)(`div`,{className:`mt-5 flex w-full flex-col gap-2`,children:[(0,k.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-repair`),children:`Wake & Repair`}),(0,k.jsx)(n,{variant:`dangerOutline`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-retire`),children:`Retire Assistant`}),(0,k.jsx)(n,{variant:`outlined`,fullWidth:!0,disabled:r,onClick:a,children:`Cancel`})]})]})]})})}function j(e){return e.name?e.name:e.isLocal?`Local Assistant`:`Cloud Assistant`}function M(e){if(e.hatchedAt)return`Created ${C(e.hatchedAt)}`}function N(){let e=i(),[t]=r(),a=t.get(`fromLogin`)===`1`,o=t.get(`noAutoSkip`)===`1`,s=h(),c=te(),S=g.use.assistants(),C=_.use.currentOrganizationId(),{loading:E,error:D,login:M,cancel:N}=x(),F=e=>e.isLocal||c,I=S.filter(F),L=S.some(e=>e.isPlatformHosted)&&!c,[R,z]=(0,O.useState)(null),[B,V]=(0,O.useState)(!1),[H,U]=(0,O.useState)(!1),[W,G]=(0,O.useState)(null),[K,q]=(0,O.useState)(null),[J,Y]=(0,O.useState)(!1),[ne,X]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(R!=null||I.length===0)return;let e=v(C);z(I.find(t=>t.id===e)?.id??I[0].id)},[R,I,C]);let Z=async t=>{V(!0),G(null);try{t.isLocal?await y.getState().connectLocalAssistant(t.id):await y.getState().connectPlatformAssistant(t.id),e(b.assistant,{replace:!0})}catch(e){console.error(`selectAssistant.handleConnect failed`,e),t.isLocal&&d()&&(u(e)||f(e)||e instanceof ee)&&m(t.id)?q(t):G(`Failed to connect. Please try again.`),V(!1)}},Q=()=>{q(null),Y(!1),X(null),U(!1)},re=async()=>{if(!(!K||J)){Y(!0),X(null);try{let e=await l(K.id,{repairGuardian:!0});if(e.ok){p(),Q(),Z(K);return}X(e.error||`Repair failed. Please try again.`)}catch(e){console.error(`selectAssistant.recoveryRepair failed`,e),X(`Repair failed. Please try again.`)}Y(!1)}},ie=async()=>{if(!(!K||J)){Y(!0),X(null);try{let t=await w(K.id);if(t.ok){Q(),e(t.nextRoute,{replace:!0});return}X(t.error)}catch(e){console.error(`selectAssistant.recoveryRetire failed`,e),X(`Failed to retire assistant. Please try again.`)}Y(!1)}};(0,O.useEffect)(()=>{a||o||B||H||S.length!==0&&S.length===1&&I.length===1&&(U(!0),Z(I[0]))},[S.length,I.length]);let ae=()=>{let e=S.find(e=>e.id===R);e&&Z(e)},oe=()=>{e(b.welcome)},$=D??W;return H&&!$&&!K?(0,k.jsx)(T,{children:(0,k.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center justify-center px-6 text-[var(--content-default)]`,children:(0,k.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Connecting to your assistant…`})})}):(0,k.jsxs)(T,{children:[(0,k.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${s?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`min-h-screen px-6 pb-40 pt-16`} text-[var(--content-default)]`,children:[(0,k.jsx)(`h1`,{className:s?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Choose an Assistant`}),(0,k.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${s?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Select which assistant you’d like to use.`}),$&&(0,k.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:$}),(0,k.jsx)(`div`,{className:`flex w-full flex-col ${s?`mt-8 gap-2`:`mt-10 gap-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:S.map(e=>{let t=F(e);return(0,k.jsx)(P,{assistant:e,selected:R===e.id,disabled:!t,badge:!t&&e.isPlatformHosted?`Requires Account`:void 0,onSelect:()=>{t&&z(e.id)}},e.id)})}),(0,k.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${s?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[I.length>0&&(0,k.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:ae,disabled:!R||B,children:B?`Connecting…`:`Continue`}),(0,k.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:()=>void e(`${b.onboarding.hosting}?from=select-assistant`),disabled:B||E,children:`Create New Assistant`}),L&&(0,k.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:E?N:()=>void M(),disabled:B,children:E?`Cancel`:`Log In`}),(0,k.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:oe,disabled:B||E,children:`Back`})]})]}),(0,k.jsx)(A,{open:K!=null,assistantName:K?j(K):``,isPending:J,errorMessage:ne??void 0,onCancel:Q,onRepair:()=>void re(),onRetire:()=>void ie()})]})}function P({assistant:e,selected:t,disabled:n,badge:r,onSelect:i}){let a=M(e),s=h();return(0,k.jsxs)(`button`,{type:`button`,onClick:i,disabled:n,className:[`group flex w-full items-center border text-left`,s?`gap-3 rounded-lg p-3`:`gap-4 rounded-2xl px-5 py-4`,`transition-all duration-200 ease-out`,n?`cursor-not-allowed opacity-50`:`cursor-pointer hover:bg-[var(--surface-secondary)]`,t&&!n?`border-[var(--primary-base)] bg-[var(--primary-base)]/[0.08] shadow-[inset_0_0_0_1px_var(--primary-base)]`:`border-[var(--border-element)] bg-transparent`].join(` `),children:[(0,k.jsx)(`div`,{className:[`flex shrink-0 items-center justify-center transition-colors duration-200`,s?`h-8 w-8 rounded-lg`:`h-10 w-10 rounded-xl`,t&&!n?`bg-[var(--primary-base)]/15 text-[var(--primary-base)]`:`bg-[var(--surface-tertiary)] text-[var(--content-secondary)]`].join(` `),children:e.isLocal?(0,k.jsx)(E,{className:`h-5 w-5`}):(0,k.jsx)(S,{className:`h-5 w-5`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:j(e)}),r&&(0,k.jsx)(`span`,{className:`rounded-full bg-[var(--surface-tertiary)] px-2 py-0.5 text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:r})]}),a&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:a})]}),!n&&(0,k.jsx)(`div`,{className:[`flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 transition-all duration-200`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)] group-hover:border-[var(--content-tertiary)]`].join(` `),children:t&&(0,k.jsx)(o,{className:`h-3 w-3 text-[var(--surface-base)]`,strokeWidth:3})})]})}export{N as SelectAssistantScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./check-wF3S-AV4.js";import{t as s}from"./modal-BtcwNEBj.js";import{t as c}from"./confirm-dialog-Zyfei9GV.js";import{P as l,j as u,k as d,lt as f,rt as p,t as ee,u as m}from"./local-mode-Dydd46cS.js";import{t as h}from"./is-electron-y5bNUVyG.js";import{n as g}from"./resolved-assistants-store-DdHm-7v4.js";import{D as _,O as v,i as te,n as y}from"./auth-store-B8Es53B9.js";import{c as b}from"./routes-Cwb-U9H-.js";import{t as x}from"./use-onboarding-login-Db_0_ZZI.js";import{bs as S,g as C,nr as w,pn as T,ss as E,tr as D}from"./index-2np2R8qP.js";var O=e(t(),1),k=a();function A({open:e,assistantName:t,isPending:r,errorMessage:i,onCancel:a,onRepair:o,onRetire:l}){let[u,d]=(0,O.useState)(`menu`);(0,O.useEffect)(()=>{e&&d(`menu`)},[e]);let f=i?(0,k.jsx)(`span`,{className:`mt-3 block text-body-small-default text-[var(--system-negative-strong)]`,children:i}):null;return u===`confirm-repair`?(0,k.jsx)(c,{open:e,title:`Repair Assistant?`,message:(0,k.jsxs)(k.Fragment,{children:[`Repairing re-provisions this assistant’s authentication token. Any other devices or browser sessions connected to it will be signed out and need to reconnect.`,f]}),confirmLabel:`Repair`,isPending:r,onConfirm:o,onCancel:()=>d(`menu`)}):u===`confirm-retire`?(0,k.jsx)(D,{open:e,isPending:r,extraMessage:f,onConfirm:l,onCancel:()=>d(`menu`)}):(0,k.jsx)(s.Root,{open:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,k.jsxs)(s.Content,{size:`sm`,hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),r||a()},children:[(0,k.jsx)(s.Header,{children:(0,k.jsx)(s.Title,{children:`Can’t Authenticate Assistant`})}),(0,k.jsxs)(s.Body,{children:[(0,k.jsxs)(s.Description,{children:[`The authentication token for `,t,` is missing or can no longer be refreshed, so this assistant can’t be connected. You can repair it, retire it, or pick a different assistant.`]}),f,(0,k.jsxs)(`div`,{className:`mt-5 flex w-full flex-col gap-2`,children:[(0,k.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-repair`),children:`Wake & Repair`}),(0,k.jsx)(n,{variant:`dangerOutline`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-retire`),children:`Retire Assistant`}),(0,k.jsx)(n,{variant:`outlined`,fullWidth:!0,disabled:r,onClick:a,children:`Cancel`})]})]})]})})}function j(e){return e.name?e.name:e.isLocal?`Local Assistant`:`Cloud Assistant`}function M(e){if(e.hatchedAt)return`Created ${C(e.hatchedAt)}`}function N(){let e=i(),[t]=r(),a=t.get(`fromLogin`)===`1`,o=t.get(`noAutoSkip`)===`1`,s=h(),c=te(),S=g.use.assistants(),C=_.use.currentOrganizationId(),{loading:E,error:D,login:M,cancel:N}=x(),F=e=>e.isLocal||c,I=S.filter(F),L=S.some(e=>e.isPlatformHosted)&&!c,[R,z]=(0,O.useState)(null),[B,V]=(0,O.useState)(!1),[H,U]=(0,O.useState)(!1),[W,G]=(0,O.useState)(null),[K,q]=(0,O.useState)(null),[J,Y]=(0,O.useState)(!1),[ne,X]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(R!=null||I.length===0)return;let e=v(C);z(I.find(t=>t.id===e)?.id??I[0].id)},[R,I,C]);let Z=async t=>{V(!0),G(null);try{t.isLocal?await y.getState().connectLocalAssistant(t.id):await y.getState().connectPlatformAssistant(t.id),e(b.assistant,{replace:!0})}catch(e){console.error(`selectAssistant.handleConnect failed`,e),t.isLocal&&d()&&(u(e)||f(e)||e instanceof ee)&&m(t.id)?q(t):G(`Failed to connect. Please try again.`),V(!1)}},Q=()=>{q(null),Y(!1),X(null),U(!1)},re=async()=>{if(!(!K||J)){Y(!0),X(null);try{let e=await l(K.id,{repairGuardian:!0});if(e.ok){p(),Q(),Z(K);return}X(e.error||`Repair failed. Please try again.`)}catch(e){console.error(`selectAssistant.recoveryRepair failed`,e),X(`Repair failed. Please try again.`)}Y(!1)}},ie=async()=>{if(!(!K||J)){Y(!0),X(null);try{let t=await w(K.id);if(t.ok){Q(),e(t.nextRoute,{replace:!0});return}X(t.error)}catch(e){console.error(`selectAssistant.recoveryRetire failed`,e),X(`Failed to retire assistant. Please try again.`)}Y(!1)}};(0,O.useEffect)(()=>{a||o||B||H||S.length!==0&&S.length===1&&I.length===1&&(U(!0),Z(I[0]))},[S.length,I.length]);let ae=()=>{let e=S.find(e=>e.id===R);e&&Z(e)},oe=()=>{e(b.welcome)},$=D??W;return H&&!$&&!K?(0,k.jsx)(T,{children:(0,k.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center justify-center px-6 text-[var(--content-default)]`,children:(0,k.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Connecting to your assistant…`})})}):(0,k.jsxs)(T,{children:[(0,k.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${s?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`min-h-screen px-6 pb-40 pt-16`} text-[var(--content-default)]`,children:[(0,k.jsx)(`h1`,{className:s?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Choose an Assistant`}),(0,k.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${s?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Select which assistant you’d like to use.`}),$&&(0,k.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:$}),(0,k.jsx)(`div`,{className:`flex w-full flex-col ${s?`mt-8 gap-2`:`mt-10 gap-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:S.map(e=>{let t=F(e);return(0,k.jsx)(P,{assistant:e,selected:R===e.id,disabled:!t,badge:!t&&e.isPlatformHosted?`Requires Account`:void 0,onSelect:()=>{t&&z(e.id)}},e.id)})}),(0,k.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${s?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[I.length>0&&(0,k.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:ae,disabled:!R||B,children:B?`Connecting…`:`Continue`}),(0,k.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:()=>void e(`${b.onboarding.hosting}?from=select-assistant`),disabled:B||E,children:`Create New Assistant`}),L&&(0,k.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:E?N:()=>void M(),disabled:B,children:E?`Cancel`:`Log In`}),(0,k.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:oe,disabled:B||E,children:`Back`})]})]}),(0,k.jsx)(A,{open:K!=null,assistantName:K?j(K):``,isPending:J,errorMessage:ne??void 0,onCancel:Q,onRepair:()=>void re(),onRetire:()=>void ie()})]})}function P({assistant:e,selected:t,disabled:n,badge:r,onSelect:i}){let a=M(e),s=h();return(0,k.jsxs)(`button`,{type:`button`,onClick:i,disabled:n,className:[`group flex w-full items-center border text-left`,s?`gap-3 rounded-lg p-3`:`gap-4 rounded-2xl px-5 py-4`,`transition-all duration-200 ease-out`,n?`cursor-not-allowed opacity-50`:`cursor-pointer hover:bg-[var(--surface-secondary)]`,t&&!n?`border-[var(--primary-base)] bg-[var(--primary-base)]/[0.08] shadow-[inset_0_0_0_1px_var(--primary-base)]`:`border-[var(--border-element)] bg-transparent`].join(` `),children:[(0,k.jsx)(`div`,{className:[`flex shrink-0 items-center justify-center transition-colors duration-200`,s?`h-8 w-8 rounded-lg`:`h-10 w-10 rounded-xl`,t&&!n?`bg-[var(--primary-base)]/15 text-[var(--primary-base)]`:`bg-[var(--surface-tertiary)] text-[var(--content-secondary)]`].join(` `),children:e.isLocal?(0,k.jsx)(E,{className:`h-5 w-5`}):(0,k.jsx)(S,{className:`h-5 w-5`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:j(e)}),r&&(0,k.jsx)(`span`,{className:`rounded-full bg-[var(--surface-tertiary)] px-2 py-0.5 text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:r})]}),a&&(0,k.jsx)(`span`,{className:`mt-0.5 block text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:a})]}),!n&&(0,k.jsx)(`div`,{className:[`flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 transition-all duration-200`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)] group-hover:border-[var(--content-tertiary)]`].join(` `),children:t&&(0,k.jsx)(o,{className:`h-3 w-3 text-[var(--surface-base)]`,strokeWidth:3})})]})}export{N as SelectAssistantScreen};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{l as n,r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./log-in-khREn0DP.js";import{i as s}from"./auth-store-B8Es53B9.js";import{c}from"./routes-Cwb-U9H-.js";import{t as l}from"./client-feature-flag-store-D85jf9vW.js";import{t as u}from"./use-onboarding-login-Db_0_ZZI.js";import{t as d}from"./assistant-feature-flag-store-aNAjw1qx.js";import{Ca as f,It as p,to as m,ts as h}from"./index-D7_9Qy0L.js";import{n as g,t as _}from"./sidebar-tree-B3cns8Q3.js";var v=e(t(),1),y=a();function b(){let e=d.use.settingsDeveloperNav(),t=d.use.credentialsSettings(),a=l.use.platformNotifications(),b=l.use.bookmarks(),x=m({platformHostedOnly:!0}),S=m()===`full`?`Billing & Usage`:`Usage`,{pathname:C}=n(),w=i(),T=s(),{login:E}=u(),D=(0,v.useMemo)(()=>p.filter(e=>!(e.id===`notifications`&&(!a||x===`gated`)||e.id===`bookmarks`&&!b||e.id===`credentials`&&!t||e.id===`developer`)).map(e=>e.id===`billing`?{...e,label:S}:e),[a,x,b,t,S]),O=(0,v.useMemo)(()=>{let t=[];return e&&t.push(...p.filter(e=>e.id===`developer`)),t.push(T?{id:`logout`,label:`Log Out`,icon:h,onSelect:()=>void f(w)}:{id:`login`,label:`Log In`,icon:o,onSelect:()=>void E()}),t},[e,T,w,E]),k=(0,v.useMemo)(()=>{if(C===c.settings.root)return`Settings`;let e=p.find(e=>C===e.href||C.startsWith(e.href+`/`));return e?e.id===`billing`?S:e.label:`Settings`},[C,S]);return(0,y.jsx)(g,{backHref:c.assistant,sidebar:(0,y.jsx)(_,{items:D,bottomItems:O,indexPath:c.settings.root}),title:k,children:(0,y.jsx)(r,{})})}export{b as SettingsLayout};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{l as n,r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./log-in-khREn0DP.js";import{i as s}from"./auth-store-B8Es53B9.js";import{c}from"./routes-Cwb-U9H-.js";import{t as l}from"./client-feature-flag-store-D85jf9vW.js";import{t as u}from"./use-onboarding-login-Db_0_ZZI.js";import{t as d}from"./assistant-feature-flag-store-aNAjw1qx.js";import{Ca as f,It as p,to as m,ts as h}from"./index-2np2R8qP.js";import{n as g,t as _}from"./sidebar-tree-CpqsN0in.js";var v=e(t(),1),y=a();function b(){let e=d.use.settingsDeveloperNav(),t=d.use.credentialsSettings(),a=l.use.platformNotifications(),b=l.use.bookmarks(),x=m({platformHostedOnly:!0}),S=m()===`full`?`Billing & Usage`:`Usage`,{pathname:C}=n(),w=i(),T=s(),{login:E}=u(),D=(0,v.useMemo)(()=>p.filter(e=>!(e.id===`notifications`&&(!a||x===`gated`)||e.id===`bookmarks`&&!b||e.id===`credentials`&&!t||e.id===`developer`)).map(e=>e.id===`billing`?{...e,label:S}:e),[a,x,b,t,S]),O=(0,v.useMemo)(()=>{let t=[];return e&&t.push(...p.filter(e=>e.id===`developer`)),t.push(T?{id:`logout`,label:`Log Out`,icon:h,onSelect:()=>void f(w)}:{id:`login`,label:`Log In`,icon:o,onSelect:()=>void E()}),t},[e,T,w,E]),k=(0,v.useMemo)(()=>{if(C===c.settings.root)return`Settings`;let e=p.find(e=>C===e.href||C.startsWith(e.href+`/`));return e?e.id===`billing`?S:e.label:`Settings`},[C,S]);return(0,y.jsx)(g,{backHref:c.assistant,sidebar:(0,y.jsx)(_,{items:D,bottomItems:O,indexPath:c.settings.root}),title:k,children:(0,y.jsx)(r,{})})}export{b as SettingsLayout};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./chunk-jRWAZmH_.js";import{t as n}from"./react-DJZBPgpf.js";import{n as r,t as i,z as a}from"./button-BQVYX8n_.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./bug-BMI_6ziD.js";import{t as l}from"./download-B6XjnEzx.js";import{t as u}from"./info-CqgkBvyS.js";import{t as ee}from"./loader-circle-Ck8fq3yv.js";import{t as d}from"./x-CswtfvgS.js";import{t as f}from"./notice-DkAWz47A.js";import{n as p,t as m}from"./input-ZpyYt_a0.js";import{t as h}from"./toggle-QSEiPr3k.js";import{t as g}from"./dropdown-BxYrCXBS.js";import{t as _}from"./is-electron-y5bNUVyG.js";import{on as v}from"./sdk.gen-zsiNChRm.js";import{t as y}from"./impersonate-version-flag-DRJTfKcP.js";import{n as te}from"./auth-store-B8Es53B9.js";import{t as b}from"./dist-DyRKd0bN2.js";import{n as x}from"./diagnostics-gOI79YBb.js";import{$o as S,Jo as C,Zo as w,as as T,ci as ne,zo as re}from"./index-D7_9Qy0L.js";var E=e(n(),1),ie=e(a(),1),D=`vellum:debug:`;function ae(){let e={};if(typeof window>`u`)return e;try{for(let t=0;t<window.localStorage.length;t++){let n=window.localStorage.key(t);if(n===null||!n.startsWith(D))continue;let r=window.localStorage.getItem(n);r!==null&&(e[n]=r)}}catch{}return e}function O(){return{collectedAt:new Date().toISOString(),resolved:{impersonateAssistantVersion:y()},overrides:ae()}}var k=t({ShareFeedbackModal:()=>z}),A=s(),j=[{value:`bug_report`,label:`Bug Report`,icon:c,includesLogsByDefault:!0},{value:`feature_request`,label:`Feature Request`,icon:T,includesLogsByDefault:!1},{value:`other`,label:`Other`,icon:w,includesLogsByDefault:!1}],M=[{value:`past_hour`,label:`Past hour`,cutoffMs:3600*1e3},{value:`past_24_hours`,label:`Past 24 hours`,cutoffMs:1440*60*1e3},{value:`all_time`,label:`All time`,cutoffMs:null}],oe=M.map(e=>({value:e.value,label:e.label})),N=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`video/mp4`,`video/quicktime`,`video/webm`]),P=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`mp4`,`mov`,`webm`]),F=10,I=50*1024*1024,se={bug_report:`bug_report`,feature_request:`feature_request`,other:`other`};function ce(){return _()?`electron`:b.getPlatform()===`ios`?`ios`:`web`}function le(e){if(e.size>I)return!1;if(e.type&&N.has(e.type))return!0;if(!e.type){let t=e.name.split(`.`).pop()?.toLowerCase();return t?P.has(t):!1}return!1}function L(e,t){let n=Math.ceil(t.length/512),r=new Uint8Array(512+n*512),i=new TextEncoder,a=(e,t,n)=>{let a=i.encode(e);r.set(a.slice(0,n),t)},o=(e,t,n)=>{a(e.toString(8).padStart(n-1,`0`)+`\0`,t,n)};a(e,0,100),o(420,100,8),o(0,108,8),o(0,116,8),o(t.length,124,12),o(Math.floor(Date.now()/1e3),136,12);for(let e=148;e<156;e++)r[e]=32;r[156]=48,a(`ustar\0`,257,6),a(`00`,263,2);let s=0;for(let e=0;e<512;e++)s+=r[e];return o(s,148,7),r[155]=32,r.set(t,512),r}async function R(e,t){try{let n={};t.window.startTime!=null&&(n.startTime=t.window.startTime,n.endTime=t.window.endTime),t.activeConversationId&&(n.conversationId=t.activeConversationId);let{data:r,error:i}=await v({path:{assistant_id:e},body:n,parseAs:`blob`,throwOnError:!1});if(i||!(r instanceof Blob))return null;let a=await r.arrayBuffer();return new Uint8Array(a)}catch{return null}}async function ue(e,t,n,r={}){if(typeof CompressionStream>`u`)return null;let{diagnosticsProvider:i,doctorSessionId:a,extraLogFiles:o=[]}=r,s=new Date,c=M.find(t=>t.value===e),l=s.getTime(),u=c?.cutoffMs==null?null:l-c.cutoffMs,ee=u==null?null:new Date(u).toISOString(),d=null;try{d=i?.()??null}catch{d=null}let f=x(d),p={collected_at:s.toISOString(),time_range:e,cutoff:ee,log_window:{start_time_ms:u,end_time_ms:l},assistant_id:t,active_conversation_id:n,doctor_session_id:a??null,user_agent:typeof navigator<`u`?navigator.userAgent:``,language:typeof navigator<`u`?navigator.language:``,platform:typeof navigator<`u`?navigator.platform:``,url:typeof window<`u`?window.location.href:``,viewport:typeof window<`u`?{width:window.innerWidth,height:window.innerHeight}:null,screen:typeof screen<`u`?{width:screen.width,height:screen.height}:null,connection:typeof navigator<`u`&&`connection`in navigator?{effectiveType:navigator.connection.effectiveType,downlink:navigator.connection.downlink,rtt:navigator.connection.rtt}:null,deviceMemory:typeof navigator<`u`&&`deviceMemory`in navigator?navigator.deviceMemory:null,hardwareConcurrency:typeof navigator<`u`?navigator.hardwareConcurrency:null},m=new TextEncoder,h=m.encode(JSON.stringify(p,null,2)),g=m.encode(JSON.stringify(f,null,2)),v=[L(`web-client-context.json`,h),L(`web-chat-diagnostics.json`,g)],y=new TextEncoder().encode(JSON.stringify(O(),null,2));v.push(L(`web-debug-flags.json`,y));for(let e of o){let t=e.contents.trim();t&&v.push(L(e.filename,m.encode(t)))}try{let e=typeof window<`u`?window._vellumDebug?.chat:null;if(e){let t={clientMessages:e.getClientMessages?.()??null,transcriptItems:e.getTranscriptItems?.()??null,pendingInteractions:e.listPendingInteractions?.()??null,thinkingIndicator:e.thinkingIndicator?.()??null,streamingRing:e.streamingRing?.()??null,reconciliationDiagnostics:e.getReconciliationDiagnostics?.()??null},n=new TextEncoder().encode(JSON.stringify(t,null,2));v.push(L(`web-chat-debug-api-triage.json`,n))}}catch{}try{let e=typeof window<`u`?window._vellumDebug?.events:null;if(e){let t={focus:typeof document<`u`?{hasFocus:typeof document.hasFocus==`function`?document.hasFocus():null,visibilityState:document.visibilityState}:null,clients:e.getClients().map(({abortSignal:e,...t})=>({...t,aborted:e.aborted})),events:e.getEvents()},n=new TextEncoder().encode(JSON.stringify(t,null,2));v.push(L(`web-sse-liveness-triage.json`,n))}}catch{}if(_()&&window.vellum?.feedback){try{let e=await window.vellum.feedback.diagnostics(),t=new TextEncoder().encode(JSON.stringify(e,null,2));v.push(L(`electron-diagnostics.json`,t))}catch{}try{let e=await window.vellum.feedback.logs();if(e){let t=new TextEncoder().encode(e);v.push(L(`electron-main-logs.txt`,t))}}catch{}}if(t){let e=await R(t,{window:{startTime:u,endTime:l},activeConversationId:n});e&&v.push(L(`platform-logs.tar.gz`,e))}v.push(new Uint8Array(1024));let te=v.reduce((e,t)=>e+t.length,0),b=new Uint8Array(te),S=0;for(let e of v)b.set(e,S),S+=e.length;let C=new Blob([b.buffer]),w=await new Response(C.stream().pipeThrough(new CompressionStream(`gzip`))).blob();return new File([w],`web-client-logs-${s.getTime()}.tar.gz`,{type:`application/gzip`})}function z({open:e,onClose:t,initialReason:n,initialMessage:a,onSubmitted:s,assistantId:c,assistantVersion:v,activeConversationId:y,doctorSessionId:b,doctorSessionLog:x,getDiagnosticsSnapshot:w}){let T=te.use.user(),D=T?.email,ae=T?.isStaff??!1,O=(0,E.useId)(),k=(0,E.useRef)(null),M=(0,E.useRef)(null),N=(0,E.useRef)(null),P=(0,E.useRef)(null),[I,L]=(0,E.useState)(n??`bug_report`),[R,z]=(0,E.useState)(``),[B,pe]=(0,E.useState)(``),[V,H]=(0,E.useState)(j.find(e=>e.value===(n??`bug_report`))?.includesLogsByDefault??!0),[me,he]=(0,E.useState)(!1),[U,W]=(0,E.useState)(`past_hour`),[G,K]=(0,E.useState)([]),[ge,q]=(0,E.useState)(null),[_e,J]=(0,E.useState)(!1),[Y,ve]=(0,E.useState)(!1),[X,ye]=(0,E.useState)(!1),Z=o(ne()),[be,Q]=(0,E.useState)(!1),$=Z.isPending||be,xe=!D,Se=(0,E.useMemo)(()=>R.trim().length>0&&B.trim().length>0,[R,B]);(0,E.useEffect)(()=>{if(!e)return;let t=n??`bug_report`;L(t),z(a??``),pe(D??``),H(j.find(e=>e.value===t)?.includesLogsByDefault??!0),he(!1),W(`past_hour`),K([]),ve(!1),ye(!1),q(null),Q(!1),Z.reset();let r=setTimeout(()=>{D?N.current?.focus():P.current?.focus()},50);return()=>clearTimeout(r)},[e]),(0,E.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e]);let Ce=e=>{L(e),me||H(j.find(t=>t.value===e)?.includesLogsByDefault??!1)},we=()=>{H(e=>!e),he(!0)},Te=x?.trim()?[{filename:`doctor-session.txt`,contents:x}]:[],Ee=(0,E.useCallback)(e=>{e.key===`Escape`&&!$&&t()},[t,$]),De=(0,E.useCallback)(e=>{e.target===k.current&&!$&&t()},[t,$]),Oe=(0,E.useCallback)(e=>{K(t=>{let n=F-t.length;if(n<=0)return t;let r=new Set(t.map(e=>`${e.name}:${e.size}`)),i=[];for(let t of e){if(i.length>=n)break;if(!le(t))continue;let e=`${t.name}:${t.size}`;r.has(e)||(r.add(e),i.push(t))}return i.length>0?[...t,...i]:t})},[]),ke=e=>{e.target.files&&Oe(Array.from(e.target.files)),e.target.value=``},Ae=e=>{e.preventDefault(),J(!1),e.dataTransfer.files?.length&&Oe(Array.from(e.dataTransfer.files))},je=e=>{e.preventDefault(),J(!0)},Me=e=>{e.preventDefault(),e.currentTarget===e.target&&J(!1)},Ne=e=>{K(t=>t.filter((t,n)=>n!==e))};return e?(0,ie.createPortal)((0,A.jsx)(`div`,{ref:k,role:`dialog`,"aria-modal":`true`,"aria-labelledby":O,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onKeyDown:Ee,onClick:De,onDrop:Ae,onDragOver:je,onDragLeave:Me,children:(0,A.jsxs)(`div`,{className:`mx-4 flex w-full max-w-lg flex-col rounded-xl border p-6 shadow-xl`,style:{backgroundColor:`var(--surface-lift)`,borderColor:`var(--border-base)`,maxHeight:`calc(100vh - 2rem)`},children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-4`,style:{borderColor:`var(--border-subtle)`},children:[(0,A.jsx)(`h2`,{id:O,className:`!m-0 text-title-small text-[var(--content-default)]`,children:`Share Feedback`}),(0,A.jsx)(i,{variant:`ghost`,iconOnly:(0,A.jsx)(d,{}),onClick:t,disabled:$,"aria-label":`Close`,tintColor:`var(--content-secondary)`})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-3.5 overflow-y-auto pt-4 ${$?`pointer-events-none opacity-60`:``}`,children:[ae&&(0,A.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,A.jsx)(h,{checked:X,onChange:()=>ye(e=>!e),"aria-label":`Download diagnostics directly`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Download diagnostics directly`})]}),(0,A.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Admin only — builds the diagnostics archive locally and downloads it instead of submitting feedback or notifying Slack.`})]}),X?(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Time range`}),(0,A.jsx)(g,{options:oe,value:U,onChange:W,"aria-label":`Diagnostics time range`})]}):(0,A.jsxs)(A.Fragment,{children:[xe&&(0,A.jsx)(m,{id:`${O}-email`,ref:P,label:`Email`,type:`email`,placeholder:`you@example.com`,value:B,onChange:e=>pe(e.target.value),leftIcon:(0,A.jsx)(S,{className:`h-4 w-4`,"aria-hidden":!0}),fullWidth:!0}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Category`}),(0,A.jsx)(`div`,{className:`flex gap-2`,children:j.map(e=>(0,A.jsx)(de,{option:e,isSelected:I===e.value,onSelect:()=>Ce(e.value)},e.value))})]}),(0,A.jsx)(`hr`,{className:`border-[var(--border-subtle)]`}),I===`bug_report`&&(0,A.jsxs)(f,{tone:`info`,children:[`Tip: Get faster support by posting in our`,` `,(0,A.jsx)(`a`,{href:`https://vellum.ai/community`,target:`_blank`,rel:`noopener noreferrer`,className:`underline text-[var(--content-default)]`,children:`Discord community`})]}),I===`feature_request`&&(0,A.jsxs)(f,{tone:`info`,children:[`Tip: Vote on features on our`,` `,(0,A.jsx)(`a`,{href:`https://vellum.ai/roadmap`,target:`_blank`,rel:`noopener noreferrer`,className:`underline text-[var(--content-default)]`,children:`public roadmap`})]}),(0,A.jsx)(p,{id:`${O}-message`,ref:N,label:I===`bug_report`?`What went wrong?`:I===`feature_request`?`Describe your idea`:`What's on your mind?`,rows:3,placeholder:I===`bug_report`?`What did you expect to happen, and what happened instead?`:I===`feature_request`?`What problem would this solve for you?`:`Share your thoughts...`,value:R,onChange:e=>z(e.target.value),fullWidth:!0}),I!==`feature_request`&&(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[(0,A.jsx)(h,{checked:V,onChange:we,"aria-label":`Include browser diagnostics`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter leading-6 text-[var(--content-default)]`,children:`Include diagnostics`})]}),(0,A.jsx)(r,{content:`Diagnostics include browser context, assistant logs, and timestamps — never passwords or credentials.`,children:(0,A.jsx)(`button`,{type:`button`,"aria-label":`About diagnostics`,className:`inline-flex items-center justify-center text-[var(--content-tertiary)]`,children:(0,A.jsx)(u,{className:`h-3.5 w-3.5`})})})]}),V&&(0,A.jsx)(g,{options:oe,value:U,onChange:W,"aria-label":`Diagnostics time range`})]}),_()&&y&&I!==`feature_request`&&(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[(0,A.jsx)(h,{checked:Y,onChange:()=>ve(e=>!e),"aria-label":`Include the most recent conversation`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter leading-6 text-[var(--content-default)]`,children:`Include the most recent conversation`})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:[`Attachments`,G.length>0&&(0,A.jsxs)(`span`,{className:`text-[var(--content-tertiary)]`,children:[` · `,G.length,`/`,F]})]}),(0,A.jsx)(i,{variant:`outlined`,size:`compact`,leftIcon:(0,A.jsx)(C,{}),onClick:()=>M.current?.click(),disabled:G.length>=F,children:`Add files`}),(0,A.jsx)(`input`,{ref:M,type:`file`,multiple:!0,accept:`image/png,image/jpeg,image/gif,image/webp,video/mp4,video/quicktime,video/webm`,onChange:ke,className:`hidden`})]}),G.length>0&&(0,A.jsx)(`div`,{className:`flex gap-2 overflow-x-auto`,children:G.map((e,t)=>(0,A.jsx)(fe,{file:e,onRemove:()=>Ne(t)},`${e.name}-${t}`))}),_e&&(0,A.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Drop files to attach…`})]})]}),ge&&(0,A.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:ge})]}),(0,A.jsx)(`div`,{className:`mt-4 flex items-center justify-end gap-2 border-t pt-4`,style:{borderColor:`var(--border-subtle)`},children:$?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,A.jsx)(ee,{className:`h-4 w-4 animate-spin`}),X?`Preparing diagnostics…`:`Sending feedback…`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(i,{variant:`ghost`,onClick:t,children:`Cancel`}),X?(0,A.jsx)(i,{variant:`primary`,leftIcon:(0,A.jsx)(l,{}),onClick:async()=>{if(!$){q(null),Q(!0);try{let e=await ue(U,c??null,_()?Y?y??null:null:y??null,{diagnosticsProvider:w,doctorSessionId:b,extraLogFiles:Te});if(!e){q(`Diagnostics export isn't supported in this browser.`);return}let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=e.name,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0),t()}catch(e){q(e instanceof Error?e.message:`Failed to build diagnostics. Please try again.`)}finally{Q(!1)}}},children:`Download diagnostics`}):(0,A.jsx)(i,{variant:`primary`,leftIcon:(0,A.jsx)(re,{}),onClick:async()=>{if(!(!Se||$)){q(null),Q(!0);try{let e=V&&I!==`feature_request`?await ue(U,c??null,_()?Y?y??null:null:y??null,{diagnosticsProvider:w,doctorSessionId:b,extraLogFiles:Te}):null;await Z.mutateAsync({headers:{"Content-Type":null},body:{message:R.trim(),classification:se[I],email:B.trim(),client:ce(),client_version:void 0,...c?{assistant_id:c}:{},...v?{assistant_version:v}:{},...b?{doctor_session_id:b}:{},...e?{logs_file:e}:{},...G.length?{attachments:G}:{}},bodySerializer:e=>{let t=new FormData;for(let[n,r]of Object.entries(e))if(r!=null){if(n===`attachments`&&Array.isArray(r)){for(let e of r)t.append(`attachments`,e);continue}r instanceof Blob?t.append(n,r):t.append(n,String(r))}return t}}),s?.(),t()}catch(e){q(e instanceof Error?e.message:`Failed to submit feedback. Please try again.`)}finally{Q(!1)}}},disabled:!Se,children:`Submit`})]})})]})}),document.body):null}function de({option:e,isSelected:t,onSelect:n}){let r=e.icon;return(0,A.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:`flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-left transition-colors`,style:{borderColor:t?`var(--primary-base)`:`var(--border-base)`,backgroundColor:t?`color-mix(in oklab, var(--primary-base) 10%, transparent)`:`transparent`},children:[(0,A.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`,style:{color:t?`var(--primary-base)`:`var(--content-secondary)`}}),(0,A.jsx)(`span`,{className:`text-body-small-default`,style:{color:t?`var(--primary-base)`:`var(--content-default)`},children:e.label})]})}function fe({file:e,onRemove:t}){let n=e.type.startsWith(`image/`),r=(0,E.useMemo)(()=>n?URL.createObjectURL(e):null,[e,n]);return(0,E.useEffect)(()=>{if(r)return()=>URL.revokeObjectURL(r)},[r]),(0,A.jsxs)(`div`,{className:`relative flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)]`,title:e.name,children:[n&&r?(0,A.jsx)(`img`,{src:r,alt:e.name,className:`h-full w-full object-cover`}):(0,A.jsx)(C,{className:`h-5 w-5 text-[var(--content-secondary)]`}),(0,A.jsx)(i,{variant:`ghost`,size:`compact`,iconOnly:(0,A.jsx)(d,{}),onClick:t,"aria-label":`Remove ${e.name}`,className:`absolute top-0.5 right-0.5 h-4 w-4 rounded-full bg-black/60 text-white hover:bg-black/70`,tintColor:`#fff`})]})}export{k as n,z as t};
1
+ import{o as e,r as t}from"./chunk-jRWAZmH_.js";import{t as n}from"./react-DJZBPgpf.js";import{n as r,t as i,z as a}from"./button-BQVYX8n_.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./bug-BMI_6ziD.js";import{t as l}from"./download-B6XjnEzx.js";import{t as u}from"./info-CqgkBvyS.js";import{t as ee}from"./loader-circle-Ck8fq3yv.js";import{t as d}from"./x-CswtfvgS.js";import{t as f}from"./notice-DkAWz47A.js";import{n as p,t as m}from"./input-ZpyYt_a0.js";import{t as h}from"./toggle-QSEiPr3k.js";import{t as g}from"./dropdown-BxYrCXBS.js";import{t as _}from"./is-electron-y5bNUVyG.js";import{on as v}from"./sdk.gen-zsiNChRm.js";import{t as y}from"./impersonate-version-flag-DRJTfKcP.js";import{n as te}from"./auth-store-B8Es53B9.js";import{t as b}from"./dist-DyRKd0bN2.js";import{n as x}from"./diagnostics-gOI79YBb.js";import{$o as S,Jo as C,Zo as w,as as T,ci as ne,zo as re}from"./index-2np2R8qP.js";var E=e(n(),1),ie=e(a(),1),D=`vellum:debug:`;function ae(){let e={};if(typeof window>`u`)return e;try{for(let t=0;t<window.localStorage.length;t++){let n=window.localStorage.key(t);if(n===null||!n.startsWith(D))continue;let r=window.localStorage.getItem(n);r!==null&&(e[n]=r)}}catch{}return e}function O(){return{collectedAt:new Date().toISOString(),resolved:{impersonateAssistantVersion:y()},overrides:ae()}}var k=t({ShareFeedbackModal:()=>z}),A=s(),j=[{value:`bug_report`,label:`Bug Report`,icon:c,includesLogsByDefault:!0},{value:`feature_request`,label:`Feature Request`,icon:T,includesLogsByDefault:!1},{value:`other`,label:`Other`,icon:w,includesLogsByDefault:!1}],M=[{value:`past_hour`,label:`Past hour`,cutoffMs:3600*1e3},{value:`past_24_hours`,label:`Past 24 hours`,cutoffMs:1440*60*1e3},{value:`all_time`,label:`All time`,cutoffMs:null}],oe=M.map(e=>({value:e.value,label:e.label})),N=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`video/mp4`,`video/quicktime`,`video/webm`]),P=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`mp4`,`mov`,`webm`]),F=10,I=50*1024*1024,se={bug_report:`bug_report`,feature_request:`feature_request`,other:`other`};function ce(){return _()?`electron`:b.getPlatform()===`ios`?`ios`:`web`}function le(e){if(e.size>I)return!1;if(e.type&&N.has(e.type))return!0;if(!e.type){let t=e.name.split(`.`).pop()?.toLowerCase();return t?P.has(t):!1}return!1}function L(e,t){let n=Math.ceil(t.length/512),r=new Uint8Array(512+n*512),i=new TextEncoder,a=(e,t,n)=>{let a=i.encode(e);r.set(a.slice(0,n),t)},o=(e,t,n)=>{a(e.toString(8).padStart(n-1,`0`)+`\0`,t,n)};a(e,0,100),o(420,100,8),o(0,108,8),o(0,116,8),o(t.length,124,12),o(Math.floor(Date.now()/1e3),136,12);for(let e=148;e<156;e++)r[e]=32;r[156]=48,a(`ustar\0`,257,6),a(`00`,263,2);let s=0;for(let e=0;e<512;e++)s+=r[e];return o(s,148,7),r[155]=32,r.set(t,512),r}async function R(e,t){try{let n={};t.window.startTime!=null&&(n.startTime=t.window.startTime,n.endTime=t.window.endTime),t.activeConversationId&&(n.conversationId=t.activeConversationId);let{data:r,error:i}=await v({path:{assistant_id:e},body:n,parseAs:`blob`,throwOnError:!1});if(i||!(r instanceof Blob))return null;let a=await r.arrayBuffer();return new Uint8Array(a)}catch{return null}}async function ue(e,t,n,r={}){if(typeof CompressionStream>`u`)return null;let{diagnosticsProvider:i,doctorSessionId:a,extraLogFiles:o=[]}=r,s=new Date,c=M.find(t=>t.value===e),l=s.getTime(),u=c?.cutoffMs==null?null:l-c.cutoffMs,ee=u==null?null:new Date(u).toISOString(),d=null;try{d=i?.()??null}catch{d=null}let f=x(d),p={collected_at:s.toISOString(),time_range:e,cutoff:ee,log_window:{start_time_ms:u,end_time_ms:l},assistant_id:t,active_conversation_id:n,doctor_session_id:a??null,user_agent:typeof navigator<`u`?navigator.userAgent:``,language:typeof navigator<`u`?navigator.language:``,platform:typeof navigator<`u`?navigator.platform:``,url:typeof window<`u`?window.location.href:``,viewport:typeof window<`u`?{width:window.innerWidth,height:window.innerHeight}:null,screen:typeof screen<`u`?{width:screen.width,height:screen.height}:null,connection:typeof navigator<`u`&&`connection`in navigator?{effectiveType:navigator.connection.effectiveType,downlink:navigator.connection.downlink,rtt:navigator.connection.rtt}:null,deviceMemory:typeof navigator<`u`&&`deviceMemory`in navigator?navigator.deviceMemory:null,hardwareConcurrency:typeof navigator<`u`?navigator.hardwareConcurrency:null},m=new TextEncoder,h=m.encode(JSON.stringify(p,null,2)),g=m.encode(JSON.stringify(f,null,2)),v=[L(`web-client-context.json`,h),L(`web-chat-diagnostics.json`,g)],y=new TextEncoder().encode(JSON.stringify(O(),null,2));v.push(L(`web-debug-flags.json`,y));for(let e of o){let t=e.contents.trim();t&&v.push(L(e.filename,m.encode(t)))}try{let e=typeof window<`u`?window._vellumDebug?.chat:null;if(e){let t={clientMessages:e.getClientMessages?.()??null,transcriptItems:e.getTranscriptItems?.()??null,pendingInteractions:e.listPendingInteractions?.()??null,thinkingIndicator:e.thinkingIndicator?.()??null,streamingRing:e.streamingRing?.()??null,reconciliationDiagnostics:e.getReconciliationDiagnostics?.()??null},n=new TextEncoder().encode(JSON.stringify(t,null,2));v.push(L(`web-chat-debug-api-triage.json`,n))}}catch{}try{let e=typeof window<`u`?window._vellumDebug?.events:null;if(e){let t={focus:typeof document<`u`?{hasFocus:typeof document.hasFocus==`function`?document.hasFocus():null,visibilityState:document.visibilityState}:null,clients:e.getClients().map(({abortSignal:e,...t})=>({...t,aborted:e.aborted})),events:e.getEvents()},n=new TextEncoder().encode(JSON.stringify(t,null,2));v.push(L(`web-sse-liveness-triage.json`,n))}}catch{}if(_()&&window.vellum?.feedback){try{let e=await window.vellum.feedback.diagnostics(),t=new TextEncoder().encode(JSON.stringify(e,null,2));v.push(L(`electron-diagnostics.json`,t))}catch{}try{let e=await window.vellum.feedback.logs();if(e){let t=new TextEncoder().encode(e);v.push(L(`electron-main-logs.txt`,t))}}catch{}}if(t){let e=await R(t,{window:{startTime:u,endTime:l},activeConversationId:n});e&&v.push(L(`platform-logs.tar.gz`,e))}v.push(new Uint8Array(1024));let te=v.reduce((e,t)=>e+t.length,0),b=new Uint8Array(te),S=0;for(let e of v)b.set(e,S),S+=e.length;let C=new Blob([b.buffer]),w=await new Response(C.stream().pipeThrough(new CompressionStream(`gzip`))).blob();return new File([w],`web-client-logs-${s.getTime()}.tar.gz`,{type:`application/gzip`})}function z({open:e,onClose:t,initialReason:n,initialMessage:a,onSubmitted:s,assistantId:c,assistantVersion:v,activeConversationId:y,doctorSessionId:b,doctorSessionLog:x,getDiagnosticsSnapshot:w}){let T=te.use.user(),D=T?.email,ae=T?.isStaff??!1,O=(0,E.useId)(),k=(0,E.useRef)(null),M=(0,E.useRef)(null),N=(0,E.useRef)(null),P=(0,E.useRef)(null),[I,L]=(0,E.useState)(n??`bug_report`),[R,z]=(0,E.useState)(``),[B,pe]=(0,E.useState)(``),[V,H]=(0,E.useState)(j.find(e=>e.value===(n??`bug_report`))?.includesLogsByDefault??!0),[me,he]=(0,E.useState)(!1),[U,W]=(0,E.useState)(`past_hour`),[G,K]=(0,E.useState)([]),[ge,q]=(0,E.useState)(null),[_e,J]=(0,E.useState)(!1),[Y,ve]=(0,E.useState)(!1),[X,ye]=(0,E.useState)(!1),Z=o(ne()),[be,Q]=(0,E.useState)(!1),$=Z.isPending||be,xe=!D,Se=(0,E.useMemo)(()=>R.trim().length>0&&B.trim().length>0,[R,B]);(0,E.useEffect)(()=>{if(!e)return;let t=n??`bug_report`;L(t),z(a??``),pe(D??``),H(j.find(e=>e.value===t)?.includesLogsByDefault??!0),he(!1),W(`past_hour`),K([]),ve(!1),ye(!1),q(null),Q(!1),Z.reset();let r=setTimeout(()=>{D?N.current?.focus():P.current?.focus()},50);return()=>clearTimeout(r)},[e]),(0,E.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e]);let Ce=e=>{L(e),me||H(j.find(t=>t.value===e)?.includesLogsByDefault??!1)},we=()=>{H(e=>!e),he(!0)},Te=x?.trim()?[{filename:`doctor-session.txt`,contents:x}]:[],Ee=(0,E.useCallback)(e=>{e.key===`Escape`&&!$&&t()},[t,$]),De=(0,E.useCallback)(e=>{e.target===k.current&&!$&&t()},[t,$]),Oe=(0,E.useCallback)(e=>{K(t=>{let n=F-t.length;if(n<=0)return t;let r=new Set(t.map(e=>`${e.name}:${e.size}`)),i=[];for(let t of e){if(i.length>=n)break;if(!le(t))continue;let e=`${t.name}:${t.size}`;r.has(e)||(r.add(e),i.push(t))}return i.length>0?[...t,...i]:t})},[]),ke=e=>{e.target.files&&Oe(Array.from(e.target.files)),e.target.value=``},Ae=e=>{e.preventDefault(),J(!1),e.dataTransfer.files?.length&&Oe(Array.from(e.dataTransfer.files))},je=e=>{e.preventDefault(),J(!0)},Me=e=>{e.preventDefault(),e.currentTarget===e.target&&J(!1)},Ne=e=>{K(t=>t.filter((t,n)=>n!==e))};return e?(0,ie.createPortal)((0,A.jsx)(`div`,{ref:k,role:`dialog`,"aria-modal":`true`,"aria-labelledby":O,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onKeyDown:Ee,onClick:De,onDrop:Ae,onDragOver:je,onDragLeave:Me,children:(0,A.jsxs)(`div`,{className:`mx-4 flex w-full max-w-lg flex-col rounded-xl border p-6 shadow-xl`,style:{backgroundColor:`var(--surface-lift)`,borderColor:`var(--border-base)`,maxHeight:`calc(100vh - 2rem)`},children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-4`,style:{borderColor:`var(--border-subtle)`},children:[(0,A.jsx)(`h2`,{id:O,className:`!m-0 text-title-small text-[var(--content-default)]`,children:`Share Feedback`}),(0,A.jsx)(i,{variant:`ghost`,iconOnly:(0,A.jsx)(d,{}),onClick:t,disabled:$,"aria-label":`Close`,tintColor:`var(--content-secondary)`})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-3.5 overflow-y-auto pt-4 ${$?`pointer-events-none opacity-60`:``}`,children:[ae&&(0,A.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,A.jsx)(h,{checked:X,onChange:()=>ye(e=>!e),"aria-label":`Download diagnostics directly`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Download diagnostics directly`})]}),(0,A.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Admin only — builds the diagnostics archive locally and downloads it instead of submitting feedback or notifying Slack.`})]}),X?(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Time range`}),(0,A.jsx)(g,{options:oe,value:U,onChange:W,"aria-label":`Diagnostics time range`})]}):(0,A.jsxs)(A.Fragment,{children:[xe&&(0,A.jsx)(m,{id:`${O}-email`,ref:P,label:`Email`,type:`email`,placeholder:`you@example.com`,value:B,onChange:e=>pe(e.target.value),leftIcon:(0,A.jsx)(S,{className:`h-4 w-4`,"aria-hidden":!0}),fullWidth:!0}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Category`}),(0,A.jsx)(`div`,{className:`flex gap-2`,children:j.map(e=>(0,A.jsx)(de,{option:e,isSelected:I===e.value,onSelect:()=>Ce(e.value)},e.value))})]}),(0,A.jsx)(`hr`,{className:`border-[var(--border-subtle)]`}),I===`bug_report`&&(0,A.jsxs)(f,{tone:`info`,children:[`Tip: Get faster support by posting in our`,` `,(0,A.jsx)(`a`,{href:`https://vellum.ai/community`,target:`_blank`,rel:`noopener noreferrer`,className:`underline text-[var(--content-default)]`,children:`Discord community`})]}),I===`feature_request`&&(0,A.jsxs)(f,{tone:`info`,children:[`Tip: Vote on features on our`,` `,(0,A.jsx)(`a`,{href:`https://vellum.ai/roadmap`,target:`_blank`,rel:`noopener noreferrer`,className:`underline text-[var(--content-default)]`,children:`public roadmap`})]}),(0,A.jsx)(p,{id:`${O}-message`,ref:N,label:I===`bug_report`?`What went wrong?`:I===`feature_request`?`Describe your idea`:`What's on your mind?`,rows:3,placeholder:I===`bug_report`?`What did you expect to happen, and what happened instead?`:I===`feature_request`?`What problem would this solve for you?`:`Share your thoughts...`,value:R,onChange:e=>z(e.target.value),fullWidth:!0}),I!==`feature_request`&&(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[(0,A.jsx)(h,{checked:V,onChange:we,"aria-label":`Include browser diagnostics`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter leading-6 text-[var(--content-default)]`,children:`Include diagnostics`})]}),(0,A.jsx)(r,{content:`Diagnostics include browser context, assistant logs, and timestamps — never passwords or credentials.`,children:(0,A.jsx)(`button`,{type:`button`,"aria-label":`About diagnostics`,className:`inline-flex items-center justify-center text-[var(--content-tertiary)]`,children:(0,A.jsx)(u,{className:`h-3.5 w-3.5`})})})]}),V&&(0,A.jsx)(g,{options:oe,value:U,onChange:W,"aria-label":`Diagnostics time range`})]}),_()&&y&&I!==`feature_request`&&(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[(0,A.jsx)(h,{checked:Y,onChange:()=>ve(e=>!e),"aria-label":`Include the most recent conversation`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter leading-6 text-[var(--content-default)]`,children:`Include the most recent conversation`})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:[`Attachments`,G.length>0&&(0,A.jsxs)(`span`,{className:`text-[var(--content-tertiary)]`,children:[` · `,G.length,`/`,F]})]}),(0,A.jsx)(i,{variant:`outlined`,size:`compact`,leftIcon:(0,A.jsx)(C,{}),onClick:()=>M.current?.click(),disabled:G.length>=F,children:`Add files`}),(0,A.jsx)(`input`,{ref:M,type:`file`,multiple:!0,accept:`image/png,image/jpeg,image/gif,image/webp,video/mp4,video/quicktime,video/webm`,onChange:ke,className:`hidden`})]}),G.length>0&&(0,A.jsx)(`div`,{className:`flex gap-2 overflow-x-auto`,children:G.map((e,t)=>(0,A.jsx)(fe,{file:e,onRemove:()=>Ne(t)},`${e.name}-${t}`))}),_e&&(0,A.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Drop files to attach…`})]})]}),ge&&(0,A.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:ge})]}),(0,A.jsx)(`div`,{className:`mt-4 flex items-center justify-end gap-2 border-t pt-4`,style:{borderColor:`var(--border-subtle)`},children:$?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,A.jsx)(ee,{className:`h-4 w-4 animate-spin`}),X?`Preparing diagnostics…`:`Sending feedback…`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(i,{variant:`ghost`,onClick:t,children:`Cancel`}),X?(0,A.jsx)(i,{variant:`primary`,leftIcon:(0,A.jsx)(l,{}),onClick:async()=>{if(!$){q(null),Q(!0);try{let e=await ue(U,c??null,_()?Y?y??null:null:y??null,{diagnosticsProvider:w,doctorSessionId:b,extraLogFiles:Te});if(!e){q(`Diagnostics export isn't supported in this browser.`);return}let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=e.name,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0),t()}catch(e){q(e instanceof Error?e.message:`Failed to build diagnostics. Please try again.`)}finally{Q(!1)}}},children:`Download diagnostics`}):(0,A.jsx)(i,{variant:`primary`,leftIcon:(0,A.jsx)(re,{}),onClick:async()=>{if(!(!Se||$)){q(null),Q(!0);try{let e=V&&I!==`feature_request`?await ue(U,c??null,_()?Y?y??null:null:y??null,{diagnosticsProvider:w,doctorSessionId:b,extraLogFiles:Te}):null;await Z.mutateAsync({headers:{"Content-Type":null},body:{message:R.trim(),classification:se[I],email:B.trim(),client:ce(),client_version:void 0,...c?{assistant_id:c}:{},...v?{assistant_version:v}:{},...b?{doctor_session_id:b}:{},...e?{logs_file:e}:{},...G.length?{attachments:G}:{}},bodySerializer:e=>{let t=new FormData;for(let[n,r]of Object.entries(e))if(r!=null){if(n===`attachments`&&Array.isArray(r)){for(let e of r)t.append(`attachments`,e);continue}r instanceof Blob?t.append(n,r):t.append(n,String(r))}return t}}),s?.(),t()}catch(e){q(e instanceof Error?e.message:`Failed to submit feedback. Please try again.`)}finally{Q(!1)}}},disabled:!Se,children:`Submit`})]})})]})}),document.body):null}function de({option:e,isSelected:t,onSelect:n}){let r=e.icon;return(0,A.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:`flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-left transition-colors`,style:{borderColor:t?`var(--primary-base)`:`var(--border-base)`,backgroundColor:t?`color-mix(in oklab, var(--primary-base) 10%, transparent)`:`transparent`},children:[(0,A.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`,style:{color:t?`var(--primary-base)`:`var(--content-secondary)`}}),(0,A.jsx)(`span`,{className:`text-body-small-default`,style:{color:t?`var(--primary-base)`:`var(--content-default)`},children:e.label})]})}function fe({file:e,onRemove:t}){let n=e.type.startsWith(`image/`),r=(0,E.useMemo)(()=>n?URL.createObjectURL(e):null,[e,n]);return(0,E.useEffect)(()=>{if(r)return()=>URL.revokeObjectURL(r)},[r]),(0,A.jsxs)(`div`,{className:`relative flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)]`,title:e.name,children:[n&&r?(0,A.jsx)(`img`,{src:r,alt:e.name,className:`h-full w-full object-cover`}):(0,A.jsx)(C,{className:`h-5 w-5 text-[var(--content-secondary)]`}),(0,A.jsx)(i,{variant:`ghost`,size:`compact`,iconOnly:(0,A.jsx)(d,{}),onClick:t,"aria-label":`Remove ${e.name}`,className:`absolute top-0.5 right-0.5 h-4 w-4 rounded-full bg-black/60 text-white hover:bg-black/70`,tintColor:`#fff`})]})}export{k as n,z as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{l as r,t as i,u as a}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./typography-Cqi8q9o7.js";import{t as c}from"./arrow-left-C2re-gYj.js";import{r as l}from"./panel-item-An-BBeyL.js";import{o as u}from"./src-CheJrlfT.js";import{t as d}from"./is-electron-y5bNUVyG.js";import{c as f}from"./routes-Cwb-U9H-.js";import{Ea as p,Rn as m,rr as h}from"./index-D7_9Qy0L.js";import{t as g}from"./use-edge-swipe-back-DGdE69fG.js";import{t as _}from"./link-click-Cw5JZikw.js";var v=e(t(),1),y=o();function b({sidebar:e,children:t,actions:o,backHref:l,title:u=`Settings`,menuRoute:_=f.settings.root}){let{pathname:b}=r(),x=a(),S=b===_,C=p(),w=(0,v.useRef)(null),T=(0,v.useRef)(null);(0,v.useLayoutEffect)(()=>{T.current?.scrollTo(0,0)},[b]);let E=S?l:_;g({containerRef:w,onBack:(0,v.useCallback)(()=>{x(E)},[x,E]),enabled:C,navKey:b});let D=d(),O=S?`Back from ${u}`:`Back to ${u} menu`,k=(0,y.jsx)(n,{variant:`ghost`,iconOnly:(0,y.jsx)(c,{}),"aria-label":O,tintColor:`var(--content-secondary)`,onClick:()=>x(E)}),A=(0,y.jsx)(n,{asChild:!0,variant:`outlined`,"aria-label":`Back from ${u}`,className:`h-8 w-8 px-0`,tintColor:`var(--content-secondary)`,children:(0,y.jsx)(i,{to:l,className:`flex items-center justify-center no-underline`,children:(0,y.jsx)(c,{size:16,"aria-hidden":`true`})})});return(0,y.jsxs)(`div`,{ref:w,className:`flex h-full min-h-0 w-full flex-1 flex-col gap-4 p-4 sm:p-6 md:gap-0`,style:{paddingTop:D?`3.75rem`:`1rem`},children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 md:hidden`,children:[k,(0,y.jsx)(s,{as:`h1`,variant:`body-large-default`,className:`flex-1 truncate text-center`,style:{color:`var(--content-tertiary)`,lineHeight:1.4},children:u}),(0,y.jsx)(`div`,{className:`h-10 w-10 shrink-0`,"aria-hidden":`true`})]}),D?(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 pb-4 empty:hidden`,children:[(0,y.jsx)(h,{placement:`electron`,className:`px-0 pt-0`}),(0,y.jsx)(m,{placement:`electron`,className:`px-0 pt-0`})]}):null,(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:rounded-[12px] md:border md:border-[var(--border-base)] md:bg-[var(--surface-overlay)]`,children:[(0,y.jsxs)(`div`,{className:`hidden shrink-0 items-center justify-between gap-4 px-6 py-5 md:flex`,children:[(0,y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[A,(0,y.jsx)(`h1`,{className:`text-title-large truncate`,style:{color:`var(--content-emphasised)`,lineHeight:1.2},children:u})]}),(0,y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:o})]}),(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,y.jsx)(`aside`,{className:`hidden w-64 shrink-0 overflow-y-auto md:block`,"aria-label":`${u} navigation`,children:e}),S?(0,y.jsx)(`div`,{className:`flex min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overflow-x-hidden pb-6 md:hidden`,children:e}):null,(0,y.jsx)(`main`,{ref:T,className:`min-w-0 min-h-0 flex-1 flex-col gap-4 overflow-y-auto overflow-x-hidden pb-6 md:flex md:px-6 md:pt-0 ${S?`hidden`:`flex`}`,children:t})]})]})]})}function x({items:e,bottomItems:t,indexPath:n}){let{pathname:i}=r(),o=a(),s=p(),c=(e,t,r)=>{let{href:a,onSelect:c}=e,d=a!=null&&(i===a||i.startsWith(a+`/`)||!s&&r&&n!=null&&i===n);return(0,y.jsxs)(v.Fragment,{children:[(0,y.jsx)(u.Item,{icon:e.icon,label:e.label,active:d,trailingIcon:a==null?void 0:l,trailingIconClassName:a==null?void 0:`md:hidden`,href:a,onSelect:c,onClick:a==null?void 0:e=>{_(e)||(e.preventDefault(),o(a))}}),!t&&(0,y.jsx)(`div`,{role:`presentation`,"aria-hidden":!0,className:`my-2 h-px w-full bg-[var(--border-base)] md:hidden`})]},e.id)};return(0,y.jsxs)(`nav`,{"aria-label":`Sidebar navigation`,className:`flex min-h-full flex-col md:gap-2 md:px-6 md:pb-4`,children:[e.map((n,r)=>c(n,r===e.length-1&&!t?.length,r===0)),t&&t.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`flex-1`}),(0,y.jsx)(`div`,{role:`presentation`,"aria-hidden":!0,className:`mx-0 my-2 h-px w-full bg-[var(--border-base)] md:mx-0`}),t.map((e,n)=>c(e,n===t.length-1,!1))]})]})}export{b as n,x as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{l as r,t as i,u as a}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./typography-Cqi8q9o7.js";import{t as c}from"./arrow-left-C2re-gYj.js";import{r as l}from"./panel-item-An-BBeyL.js";import{o as u}from"./src-CheJrlfT.js";import{t as d}from"./is-electron-y5bNUVyG.js";import{c as f}from"./routes-Cwb-U9H-.js";import{Ea as p,Rn as m,rr as h}from"./index-2np2R8qP.js";import{t as g}from"./use-edge-swipe-back-BYWXReAH.js";import{t as _}from"./link-click-Cw5JZikw.js";var v=e(t(),1),y=o();function b({sidebar:e,children:t,actions:o,backHref:l,title:u=`Settings`,menuRoute:_=f.settings.root}){let{pathname:b}=r(),x=a(),S=b===_,C=p(),w=(0,v.useRef)(null),T=(0,v.useRef)(null);(0,v.useLayoutEffect)(()=>{T.current?.scrollTo(0,0)},[b]);let E=S?l:_;g({containerRef:w,onBack:(0,v.useCallback)(()=>{x(E)},[x,E]),enabled:C,navKey:b});let D=d(),O=S?`Back from ${u}`:`Back to ${u} menu`,k=(0,y.jsx)(n,{variant:`ghost`,iconOnly:(0,y.jsx)(c,{}),"aria-label":O,tintColor:`var(--content-secondary)`,onClick:()=>x(E)}),A=(0,y.jsx)(n,{asChild:!0,variant:`outlined`,"aria-label":`Back from ${u}`,className:`h-8 w-8 px-0`,tintColor:`var(--content-secondary)`,children:(0,y.jsx)(i,{to:l,className:`flex items-center justify-center no-underline`,children:(0,y.jsx)(c,{size:16,"aria-hidden":`true`})})});return(0,y.jsxs)(`div`,{ref:w,className:`flex h-full min-h-0 w-full flex-1 flex-col gap-4 p-4 sm:p-6 md:gap-0`,style:{paddingTop:D?`3.75rem`:`1rem`},children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 md:hidden`,children:[k,(0,y.jsx)(s,{as:`h1`,variant:`body-large-default`,className:`flex-1 truncate text-center`,style:{color:`var(--content-tertiary)`,lineHeight:1.4},children:u}),(0,y.jsx)(`div`,{className:`h-10 w-10 shrink-0`,"aria-hidden":`true`})]}),D?(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 pb-4 empty:hidden`,children:[(0,y.jsx)(h,{placement:`electron`,className:`px-0 pt-0`}),(0,y.jsx)(m,{placement:`electron`,className:`px-0 pt-0`})]}):null,(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:rounded-[12px] md:border md:border-[var(--border-base)] md:bg-[var(--surface-overlay)]`,children:[(0,y.jsxs)(`div`,{className:`hidden shrink-0 items-center justify-between gap-4 px-6 py-5 md:flex`,children:[(0,y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[A,(0,y.jsx)(`h1`,{className:`text-title-large truncate`,style:{color:`var(--content-emphasised)`,lineHeight:1.2},children:u})]}),(0,y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:o})]}),(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,y.jsx)(`aside`,{className:`hidden w-64 shrink-0 overflow-y-auto md:block`,"aria-label":`${u} navigation`,children:e}),S?(0,y.jsx)(`div`,{className:`flex min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overflow-x-hidden pb-6 md:hidden`,children:e}):null,(0,y.jsx)(`main`,{ref:T,className:`min-w-0 min-h-0 flex-1 flex-col gap-4 overflow-y-auto overflow-x-hidden pb-6 md:flex md:px-6 md:pt-0 ${S?`hidden`:`flex`}`,children:t})]})]})]})}function x({items:e,bottomItems:t,indexPath:n}){let{pathname:i}=r(),o=a(),s=p(),c=(e,t,r)=>{let{href:a,onSelect:c}=e,d=a!=null&&(i===a||i.startsWith(a+`/`)||!s&&r&&n!=null&&i===n);return(0,y.jsxs)(v.Fragment,{children:[(0,y.jsx)(u.Item,{icon:e.icon,label:e.label,active:d,trailingIcon:a==null?void 0:l,trailingIconClassName:a==null?void 0:`md:hidden`,href:a,onSelect:c,onClick:a==null?void 0:e=>{_(e)||(e.preventDefault(),o(a))}}),!t&&(0,y.jsx)(`div`,{role:`presentation`,"aria-hidden":!0,className:`my-2 h-px w-full bg-[var(--border-base)] md:hidden`})]},e.id)};return(0,y.jsxs)(`nav`,{"aria-label":`Sidebar navigation`,className:`flex min-h-full flex-col md:gap-2 md:px-6 md:pb-4`,children:[e.map((n,r)=>c(n,r===e.length-1&&!t?.length,r===0)),t&&t.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`flex-1`}),(0,y.jsx)(`div`,{role:`presentation`,"aria-hidden":!0,className:`mx-0 my-2 h-px w-full bg-[var(--border-base)] md:mx-0`}),t.map((e,n)=>c(e,n===t.length-1,!1))]})]})}export{b as n,x as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{m as n}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{f as i}from"./native-biometric-Bp5eYpXj.js";import{n as a,r as o}from"./login-flow-DXwwcT6M.js";import{t as s}from"./proxy-BzlH_XAe.js";import{t as c}from"./AnimatePresence-C8APSgIu.js";import{yt as l}from"./index-D7_9Qy0L.js";import{t as u}from"./signup-shell-C--ZjbjA.js";var d=e(t(),1),f=r();function p({words:e}){let[t,n]=(0,d.useState)(0),r=(0,d.useMemo)(()=>e.reduce((e,t)=>e.length>=t.length?e:t),[e]);return(0,d.useEffect)(()=>{let t=setInterval(()=>{n(t=>(t+1)%e.length)},2400);return()=>clearInterval(t)},[e.length]),(0,f.jsxs)(`span`,{className:`signup__rotating`,children:[(0,f.jsxs)(`span`,{className:`signup__rotating-sizer`,"aria-hidden":!0,children:[r,`.`]}),(0,f.jsx)(c,{mode:`wait`,children:(0,f.jsxs)(s.em,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.3,ease:`easeInOut`},children:[e[t],`.`]},e[t])})]})}var m=[`Personal Intelligence`,`Software Engineer`,`Finance Ops`,`Household Manager`,`GTM Engineer`,`Product Lead`];function h({returnTo:e}){let[t,n]=(0,d.useState)(null),r=o(e,{authIntent:`signup`});return(0,f.jsxs)(u,{children:[(0,f.jsxs)(`h1`,{className:`signup__title`,children:[`Meet your new`,(0,f.jsx)(`br`,{}),(0,f.jsx)(p,{words:m})]}),(0,f.jsx)(`p`,{className:`signup__subtitle`,children:`The most powerful assistant that can handle your work and life admin tasks.`}),(0,f.jsx)(`div`,{className:`signup__buttons`,children:(0,f.jsx)(`button`,{type:`button`,className:`signup__btn`,onClick:()=>{n(null),i(a,r,{returnTo:e,intent:`signup`}).catch(e=>{console.error(`[signup] auth flow failed:`,e),n(`Something went wrong. Please try again.`)})},children:`Continue`})}),t&&(0,f.jsx)(`p`,{className:`signup__error`,children:t}),(0,f.jsxs)(`p`,{className:`signup__footer`,children:[`Already have an account?`,` `,(0,f.jsx)(`button`,{type:`button`,className:`signup__link`,onClick:()=>{n(null),i(a,o(e),{returnTo:e}).catch(e=>{console.error(`[signup] sign-in flow failed:`,e),n(`Something went wrong. Please try again.`)})},children:`Sign in`})]}),(0,f.jsxs)(`a`,{className:`signup__download`,href:`/downloads`,children:[(0,f.jsx)(l,{size:16}),`Download for macOS`]})]})}function g(){let[e]=n();return(0,f.jsx)(h,{returnTo:e.get(`returnTo`)})}export{g as SignupPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{m as n}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{f as i}from"./native-biometric-Bp5eYpXj.js";import{n as a,r as o}from"./login-flow-DXwwcT6M.js";import{t as s}from"./proxy-BzlH_XAe.js";import{t as c}from"./AnimatePresence-C8APSgIu.js";import{yt as l}from"./index-2np2R8qP.js";import{t as u}from"./signup-shell-C--ZjbjA.js";var d=e(t(),1),f=r();function p({words:e}){let[t,n]=(0,d.useState)(0),r=(0,d.useMemo)(()=>e.reduce((e,t)=>e.length>=t.length?e:t),[e]);return(0,d.useEffect)(()=>{let t=setInterval(()=>{n(t=>(t+1)%e.length)},2400);return()=>clearInterval(t)},[e.length]),(0,f.jsxs)(`span`,{className:`signup__rotating`,children:[(0,f.jsxs)(`span`,{className:`signup__rotating-sizer`,"aria-hidden":!0,children:[r,`.`]}),(0,f.jsx)(c,{mode:`wait`,children:(0,f.jsxs)(s.em,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.3,ease:`easeInOut`},children:[e[t],`.`]},e[t])})]})}var m=[`Personal Intelligence`,`Software Engineer`,`Finance Ops`,`Household Manager`,`GTM Engineer`,`Product Lead`];function h({returnTo:e}){let[t,n]=(0,d.useState)(null),r=o(e,{authIntent:`signup`});return(0,f.jsxs)(u,{children:[(0,f.jsxs)(`h1`,{className:`signup__title`,children:[`Meet your new`,(0,f.jsx)(`br`,{}),(0,f.jsx)(p,{words:m})]}),(0,f.jsx)(`p`,{className:`signup__subtitle`,children:`The most powerful assistant that can handle your work and life admin tasks.`}),(0,f.jsx)(`div`,{className:`signup__buttons`,children:(0,f.jsx)(`button`,{type:`button`,className:`signup__btn`,onClick:()=>{n(null),i(a,r,{returnTo:e,intent:`signup`}).catch(e=>{console.error(`[signup] auth flow failed:`,e),n(`Something went wrong. Please try again.`)})},children:`Continue`})}),t&&(0,f.jsx)(`p`,{className:`signup__error`,children:t}),(0,f.jsxs)(`p`,{className:`signup__footer`,children:[`Already have an account?`,` `,(0,f.jsx)(`button`,{type:`button`,className:`signup__link`,onClick:()=>{n(null),i(a,o(e),{returnTo:e}).catch(e=>{console.error(`[signup] sign-in flow failed:`,e),n(`Something went wrong. Please try again.`)})},children:`Sign in`})]}),(0,f.jsxs)(`a`,{className:`signup__download`,href:`/downloads`,children:[(0,f.jsx)(l,{size:16}),`Download for macOS`]})]})}function g(){let[e]=n();return(0,f.jsx)(h,{returnTo:e.get(`returnTo`)})}export{g as SignupPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r,z as i}from"./button-BQVYX8n_.js";import{f as a,l as o,n as s,u as c}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./jsx-runtime-CVSDxk6A.js";import{t as f}from"./card-D8zyWtZh.js";import{t as p}from"./createLucideIcon-Bjb-Kuq7.js";import{t as m}from"./arrow-left-C2re-gYj.js";import{a as h,n as g,o as _,r as v,t as y}from"./use-skill-actions-BssxVwhK.js";import{t as b}from"./chevron-down-DpYf9Gwq.js";import{t as x}from"./menu-C9SOvGlk.js";import{t as S}from"./code-B_ruRFrX.js";import{t as C}from"./external-link-Cczz6xJ4.js";import{t as w}from"./eye-C2rSrbD-.js";import{t as T}from"./file-text-DA128T4K.js";import{t as E}from"./loader-circle-Ck8fq3yv.js";import{t as D}from"./triangle-alert-CnjNKhNx.js";import{j as O}from"./src-CheJrlfT.js";import{n as k,t as A}from"./file-markdown-BXDlM5ry.js";import{St as j,bt as M,sn as N}from"./react-query.gen-C0S0EYHV.js";import{c as P}from"./routes-Cwb-U9H-.js";import{Ao as F,Ea as I,Ls as L,fs as R}from"./index-D7_9Qy0L.js";import{t as z}from"./use-active-assistant-id-DwLFgABu.js";import{n as B,t as V}from"./use-skill-detail-files-BVoaelHO.js";import{n as H,r as U,t as W}from"./skills-CqbxZ62G.js";import{t as G}from"./use-edge-swipe-back-DGdE69fG.js";import{i as K,n as q,r as J,t as Y}from"./file-editor-CmUOlTjl.js";var ee=p(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),X=e(n(),1),Z=d();function te({assistantId:e,skill:t,onBack:n,onInstall:i,onRemove:a,isInstalling:o=!1,isRemoving:s=!1,sourceConversationId:c}){let l=v(t),u=H(t),{fileEntries:d,setSelectedPath:p,activePath:g,activeFile:y,isFilesLoading:b,fileContent:x,isBinary:S,isContentLoading:C}=V(e,t.id);return(0,Z.jsxs)(`div`,{className:`flex h-[calc(100vh-14rem)] flex-col`,children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,Z.jsx)(r,{type:`button`,variant:`ghost`,iconOnly:(0,Z.jsx)(m,{"aria-hidden":!0}),"aria-label":`Back to skills`,onClick:n}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,Z.jsx)(_,{skill:t,className:`h-8 w-8 text-3xl`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:t.name}),(0,Z.jsx)(h,{origin:t.origin})]}),(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:t.description}),(0,Z.jsx)(B,{skill:{origin:t.origin,sourceConversationId:c},className:`mt-1`})]})]}),l?o?(0,Z.jsx)(`div`,{className:`flex h-9 items-center px-3`,children:(0,Z.jsx)(E,{className:`h-4 w-4 animate-spin`,style:{color:`var(--content-tertiary)`}})}):(0,Z.jsx)(r,{type:`button`,onClick:i,disabled:!i,leftIcon:(0,Z.jsx)(L,{"aria-hidden":!0}),children:`Install`}):(0,Z.jsx)(r,{type:`button`,variant:u?`dangerOutline`:`outlined`,onClick:a,disabled:!u||s||!a,leftIcon:s?(0,Z.jsx)(E,{className:`animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(F,{"aria-hidden":!0}),children:`Remove`})]})]}),(0,Z.jsx)(f.Root,{asChild:!0,noPadding:!0,children:(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden sm:grid`,style:{gridTemplateColumns:`240px 1fr`},children:[(0,Z.jsx)(`div`,{className:`max-h-40 shrink-0 overflow-y-auto border-b p-2 sm:max-h-none sm:border-b-0 sm:border-r`,style:{borderColor:`var(--border-base)`},children:b?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(E,{className:`h-4 w-4 animate-spin`,style:{color:`var(--content-tertiary)`}})}):d.length===0?(0,Z.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files available.`}):d.map(e=>{let t=g===e.path,n=(e.mimeType??``).endsWith(`/directory`);return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{color:t?`var(--primary-base)`:`var(--content-default)`,backgroundColor:t?`color-mix(in oklab, var(--primary-base) 10%, transparent)`:void 0},children:[n?(0,Z.jsx)(R,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-mid-strong)`}}):(0,Z.jsx)(T,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)})}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:C?(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(E,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):y?(0,Z.jsx)(ne,{assistantId:e,skillId:t.id,fileName:y.name,filePath:y.path,content:x,isBinary:S,editable:t.kind===`installed`},`${t.id}/${y.path}`):(0,Z.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view its contents.`})})]})})]})}function ne({assistantId:e,skillId:n,fileName:i,filePath:a,content:o,isBinary:s,editable:u}){let d=c(),f=l(),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(``),_=`skills/${n}/${a}`,v=N({onSuccess:()=>{m(!1),g(``),f.invalidateQueries({queryKey:[{_id:`skillsByIdFilesContentGet`}]}),f.invalidateQueries({queryKey:[{_id:`skillsByIdFilesGet`}]}),a===`SKILL.md`&&W(f,e)},onError:e=>{t(e,{context:`skill-file-save`,bestEffort:!0})}}),y=p&&h!==(o??``),b=(0,X.useCallback)(()=>{!y||v.isPending||v.mutate({path:{assistant_id:e},body:{path:_,content:h,encoding:`utf8`}})},[y,v,e,_,h]),x=(0,X.useCallback)(()=>{m(!0),g(o??``),v.reset()},[o,v]),S=(0,X.useCallback)(()=>{m(!1),g(``),v.reset()},[v]);if(s)return(0,Z.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Binary file — no preview available.`});if(o===null)return(0,Z.jsxs)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[`No preview available for `,i,`.`]});let w=u?(0,Z.jsx)(r,{variant:`ghost`,size:`regular`,iconOnly:(0,Z.jsx)(C,{"aria-hidden":!0}),onClick:()=>d(`${P.workspace}?file=${encodeURIComponent(_)}`),"aria-label":`Open in Workspace`,className:`hover:bg-[var(--surface-base)]`}):void 0;return k(i,void 0)&&!p?(0,Z.jsx)(`div`,{className:`relative flex h-full flex-col`,children:(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:[(0,Z.jsx)(Y,{content:o,fileName:i,showEdit:u,isEditing:!1,onToggleEdit:x,extraActions:w}),(0,Z.jsx)(A,{content:o})]})}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(Y,{content:p?h:o,fileName:i,showEdit:u,isEditing:p,onToggleEdit:()=>p?S():x(),extraActions:w}),p?(0,Z.jsx)(J,{value:h,onChange:g,onSave:b}):(0,Z.jsx)(K,{content:o,readOnly:!u,onStartEdit:x})]}),p&&(0,Z.jsx)(q,{isDirty:y,isSaving:v.isPending,error:v.isError?`Save failed`:null,onSave:b,onDiscard:S})]})}var re=e(i(),1);function ie({fileName:e,content:t,isBinary:n,viewMode:r=`preview`}){return n?(0,Z.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Binary file — no preview available.`}):t===null?(0,Z.jsxs)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[`No preview available for `,e,`.`]}):k(e,void 0)&&r===`preview`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Z.jsx)(A,{content:t})}):(0,Z.jsx)(`pre`,{className:`h-full overflow-y-auto whitespace-pre-wrap break-words p-4 font-mono text-body-small-default`,style:{color:`var(--content-default)`},children:t})}function ae({assistantId:e,skill:t,onBack:n,onInstall:i,onRemove:a,isInstalling:o=!1,isRemoving:s=!1,swipeContainerRef:c,sourceConversationId:l}){let u=v(t),d=H(t),{fileEntries:p,setSelectedPath:g,activePath:y,activeFile:b,isFilesLoading:x,fileContent:C,isBinary:T,isContentLoading:D}=V(e,t.id),[A,j]=(0,X.useState)(`preview`);(0,X.useEffect)(()=>{j(`preview`)},[y]);let[M,N]=(0,X.useState)(null);(0,X.useEffect)(()=>{N(document.getElementById(`viewport-overlays`))},[]);let P=b?k(b.name,void 0):!1,F=P?A:`raw`,I=(0,Z.jsxs)(`div`,{ref:c,className:`fixed inset-0 z-40 flex flex-col overflow-hidden bg-[var(--surface-overlay)]`,style:{paddingTop:`calc(8px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,paddingBottom:`calc(8px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))`,paddingLeft:`calc(12px + var(--safe-area-inset-left, env(safe-area-inset-left, 0px)))`,paddingRight:`calc(12px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(r,{variant:`ghost`,iconOnly:(0,Z.jsx)(m,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Back to skills`,onClick:n,className:`max-md:bg-[var(--surface-active)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate px-2 text-center text-body-medium-default`,style:{color:`var(--content-secondary)`},children:t.name}),(0,Z.jsx)(oe,{available:u,removable:d,isInstalling:o,isRemoving:s,onInstall:i,onRemove:a})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(_,{skill:t,className:`h-6 w-6 shrink-0 text-[22px] leading-none`}),(0,Z.jsx)(`h2`,{className:`min-w-0 truncate text-title-medium`,style:{color:`var(--content-emphasised)`},children:t.name})]}),(0,Z.jsx)(h,{origin:t.origin})]}),(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:t.description}),(0,Z.jsx)(B,{skill:{origin:t.origin,sourceConversationId:l}})]}),(0,Z.jsx)(f.Root,{asChild:!0,noPadding:!0,children:(0,Z.jsxs)(`div`,{className:`mt-6 flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border bg-[var(--surface-lift)]`,style:{borderColor:`var(--border-hover)`},children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-3 py-2`,style:{borderColor:`var(--border-hover)`},children:[(0,Z.jsx)(ce,{fileEntries:p,activePath:y,activeName:b?.name??null,onSelect:g}),(0,Z.jsx)(O,{iconOnly:!0,ariaLabel:`File view mode`,value:F,onChange:j,items:[{value:`preview`,label:`Preview`,icon:(0,Z.jsx)(w,{"aria-hidden":!0}),disabled:!P},{value:`raw`,label:`Source`,icon:(0,Z.jsx)(S,{"aria-hidden":!0})}]})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:x||D?(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(E,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):b?(0,Z.jsx)(ie,{fileName:b.name,content:C,isBinary:T,viewMode:F}):(0,Z.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view its contents.`})})]})})]});return M?(0,re.createPortal)(I,M):I}function oe({available:e,removable:t,isInstalling:n,isRemoving:i,onInstall:a,onRemove:o}){return n||i?(0,Z.jsx)(r,{variant:`ghost`,iconOnly:(0,Z.jsx)(E,{className:`animate-spin`,"aria-hidden":!0}),expandOnMobile:!0,disabled:!0,"aria-label":`Pending`,className:`max-md:bg-[var(--surface-active)]`}):e?(0,Z.jsx)(r,{variant:`ghost`,iconOnly:(0,Z.jsx)(L,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Install skill`,onClick:a,disabled:!a,className:`max-md:bg-[var(--surface-active)]`}):t?(0,Z.jsx)(r,{variant:`dangerGhost`,iconOnly:(0,Z.jsx)(F,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Remove skill`,onClick:o,disabled:!o,className:`max-md:rounded-full max-md:bg-[var(--system-negative-weak)]`}):(0,Z.jsx)(r,{variant:`dangerGhost`,iconOnly:(0,Z.jsx)(F,{"aria-hidden":!0}),expandOnMobile:!0,disabled:!0,title:`Bundled skills cannot be removed`,"aria-label":`Bundled skill cannot be removed`,className:`max-md:rounded-full max-md:bg-[var(--system-negative-weak)]`})}function se(e){return(e??``).endsWith(`/directory`)}function ce({fileEntries:e,activePath:t,activeName:n,onSelect:r}){let i=n??`Select a file`;return e.length===0?(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{className:`truncate`,children:i})]}):(0,Z.jsxs)(x.Root,{children:[(0,Z.jsx)(x.Trigger,{children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-2 rounded-md text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{className:`truncate`,children:i}),(0,Z.jsx)(b,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`},"aria-hidden":!0})]})}),(0,Z.jsx)(x.Content,{align:`start`,children:e.map(e=>{let n=se(e.mimeType);return(0,Z.jsx)(x.Item,{onSelect:()=>r(e.path),leftIcon:n?(0,Z.jsx)(R,{}):(0,Z.jsx)(T,{}),"aria-current":e.path===t?`true`:void 0,children:e.name},e.path)})})]})}function Q(){return(0,Z.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)]`,"aria-hidden":!0,children:(0,Z.jsx)(T,{className:`h-4 w-4`,style:{color:`var(--content-secondary)`}})})}function le(){return(0,Z.jsx)(g,{icon:D,iconColor:`var(--system-danger)`,title:`Failed to load skills`,subtitle:`Something went wrong. Try refreshing the page.`})}function $(){return(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,Z.jsx)(E,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})})}function ue(){let e=z(),{skillId:t}=a(),n=c(),i=o(),{pathname:l}=i,d=I(),f=(0,X.useRef)(null),p=i.state,h=typeof p?.listSearch==`string`?p.listSearch:``,_=u({...j({path:{assistant_id:e},query:{include:`catalog`}}),select:e=>e.skills,refetchOnMount:`always`}),v=(0,X.useCallback)(()=>{n(`${P.superpowers}${h}`,{replace:!0})},[n,h]);G({containerRef:f,onBack:v,enabled:d,navKey:l});let{handleInstall:b,handleRemove:x,isInstallingSkill:S,isRemovingSkill:C,skillPendingRemoval:w,confirmRemove:T,cancelRemove:E}=y(e,{onRemoved:v}),D=_.data,O=(0,X.useMemo)(()=>D?.find(e=>e.id===t)??null,[D,t]),k=u({...M({path:{assistant_id:e,id:t??``}}),enabled:!!t&&O?.origin===`assistant-memory`,select:e=>e.skill.origin===`assistant-memory`?e.skill.sourceConversationId??null:null});if(!t)return(0,Z.jsx)(s,{to:P.superpowers,replace:!0});if(_.isLoading)return(0,Z.jsx)($,{});if(_.isError&&!O)return(0,Z.jsx)(le,{});if(!O&&_.isFetching)return(0,Z.jsx)($,{});if(!O)return(0,Z.jsx)(g,{icon:ee,title:`Skill not found`,subtitle:`This skill may have been removed, or the link is out of date.`,children:(0,Z.jsx)(r,{type:`button`,variant:`outlined`,className:`mt-4`,leftIcon:(0,Z.jsx)(m,{"aria-hidden":!0}),onClick:v,children:`Back to My Superpowers`})});let A={assistantId:e,skill:O,onBack:v,onInstall:()=>b(O),onRemove:()=>x(O),isInstalling:S(O),isRemoving:C(O),sourceConversationId:k.data??void 0};return(0,Z.jsxs)(Z.Fragment,{children:[d?(0,Z.jsx)(ae,{...A,swipeContainerRef:f}):(0,Z.jsx)(te,{...A}),(0,Z.jsx)(U,{skillName:w?.name??null,onConfirm:T,onCancel:E})]})}export{ue as SkillDetailPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r,z as i}from"./button-BQVYX8n_.js";import{f as a,l as o,n as s,u as c}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./jsx-runtime-CVSDxk6A.js";import{t as f}from"./card-D8zyWtZh.js";import{t as p}from"./createLucideIcon-Bjb-Kuq7.js";import{t as m}from"./arrow-left-C2re-gYj.js";import{a as h,n as g,o as _,r as v,t as y}from"./use-skill-actions-7ZROdMpd.js";import{t as b}from"./chevron-down-DpYf9Gwq.js";import{t as x}from"./menu-C9SOvGlk.js";import{t as S}from"./code-B_ruRFrX.js";import{t as C}from"./external-link-Cczz6xJ4.js";import{t as w}from"./eye-C2rSrbD-.js";import{t as T}from"./file-text-DA128T4K.js";import{t as E}from"./loader-circle-Ck8fq3yv.js";import{t as D}from"./triangle-alert-CnjNKhNx.js";import{j as O}from"./src-CheJrlfT.js";import{n as k,t as A}from"./file-markdown-BXDlM5ry.js";import{St as j,bt as M,sn as N}from"./react-query.gen-C0S0EYHV.js";import{c as P}from"./routes-Cwb-U9H-.js";import{Ao as F,Ea as I,Ls as L,fs as R}from"./index-2np2R8qP.js";import{t as z}from"./use-active-assistant-id-DwLFgABu.js";import{n as B,t as V}from"./use-skill-detail-files-8L8VWCDM.js";import{n as H,r as U,t as W}from"./skills-CqbxZ62G.js";import{t as G}from"./use-edge-swipe-back-BYWXReAH.js";import{i as K,n as q,r as J,t as Y}from"./file-editor-CmUOlTjl.js";var ee=p(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),X=e(n(),1),Z=d();function te({assistantId:e,skill:t,onBack:n,onInstall:i,onRemove:a,isInstalling:o=!1,isRemoving:s=!1,sourceConversationId:c}){let l=v(t),u=H(t),{fileEntries:d,setSelectedPath:p,activePath:g,activeFile:y,isFilesLoading:b,fileContent:x,isBinary:S,isContentLoading:C}=V(e,t.id);return(0,Z.jsxs)(`div`,{className:`flex h-[calc(100vh-14rem)] flex-col`,children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,Z.jsx)(r,{type:`button`,variant:`ghost`,iconOnly:(0,Z.jsx)(m,{"aria-hidden":!0}),"aria-label":`Back to skills`,onClick:n}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,Z.jsx)(_,{skill:t,className:`h-8 w-8 text-3xl`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:t.name}),(0,Z.jsx)(h,{origin:t.origin})]}),(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:t.description}),(0,Z.jsx)(B,{skill:{origin:t.origin,sourceConversationId:c},className:`mt-1`})]})]}),l?o?(0,Z.jsx)(`div`,{className:`flex h-9 items-center px-3`,children:(0,Z.jsx)(E,{className:`h-4 w-4 animate-spin`,style:{color:`var(--content-tertiary)`}})}):(0,Z.jsx)(r,{type:`button`,onClick:i,disabled:!i,leftIcon:(0,Z.jsx)(L,{"aria-hidden":!0}),children:`Install`}):(0,Z.jsx)(r,{type:`button`,variant:u?`dangerOutline`:`outlined`,onClick:a,disabled:!u||s||!a,leftIcon:s?(0,Z.jsx)(E,{className:`animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(F,{"aria-hidden":!0}),children:`Remove`})]})]}),(0,Z.jsx)(f.Root,{asChild:!0,noPadding:!0,children:(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden sm:grid`,style:{gridTemplateColumns:`240px 1fr`},children:[(0,Z.jsx)(`div`,{className:`max-h-40 shrink-0 overflow-y-auto border-b p-2 sm:max-h-none sm:border-b-0 sm:border-r`,style:{borderColor:`var(--border-base)`},children:b?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(E,{className:`h-4 w-4 animate-spin`,style:{color:`var(--content-tertiary)`}})}):d.length===0?(0,Z.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files available.`}):d.map(e=>{let t=g===e.path,n=(e.mimeType??``).endsWith(`/directory`);return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{color:t?`var(--primary-base)`:`var(--content-default)`,backgroundColor:t?`color-mix(in oklab, var(--primary-base) 10%, transparent)`:void 0},children:[n?(0,Z.jsx)(R,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-mid-strong)`}}):(0,Z.jsx)(T,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)})}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:C?(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(E,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):y?(0,Z.jsx)(ne,{assistantId:e,skillId:t.id,fileName:y.name,filePath:y.path,content:x,isBinary:S,editable:t.kind===`installed`},`${t.id}/${y.path}`):(0,Z.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view its contents.`})})]})})]})}function ne({assistantId:e,skillId:n,fileName:i,filePath:a,content:o,isBinary:s,editable:u}){let d=c(),f=l(),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(``),_=`skills/${n}/${a}`,v=N({onSuccess:()=>{m(!1),g(``),f.invalidateQueries({queryKey:[{_id:`skillsByIdFilesContentGet`}]}),f.invalidateQueries({queryKey:[{_id:`skillsByIdFilesGet`}]}),a===`SKILL.md`&&W(f,e)},onError:e=>{t(e,{context:`skill-file-save`,bestEffort:!0})}}),y=p&&h!==(o??``),b=(0,X.useCallback)(()=>{!y||v.isPending||v.mutate({path:{assistant_id:e},body:{path:_,content:h,encoding:`utf8`}})},[y,v,e,_,h]),x=(0,X.useCallback)(()=>{m(!0),g(o??``),v.reset()},[o,v]),S=(0,X.useCallback)(()=>{m(!1),g(``),v.reset()},[v]);if(s)return(0,Z.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Binary file — no preview available.`});if(o===null)return(0,Z.jsxs)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[`No preview available for `,i,`.`]});let w=u?(0,Z.jsx)(r,{variant:`ghost`,size:`regular`,iconOnly:(0,Z.jsx)(C,{"aria-hidden":!0}),onClick:()=>d(`${P.workspace}?file=${encodeURIComponent(_)}`),"aria-label":`Open in Workspace`,className:`hover:bg-[var(--surface-base)]`}):void 0;return k(i,void 0)&&!p?(0,Z.jsx)(`div`,{className:`relative flex h-full flex-col`,children:(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:[(0,Z.jsx)(Y,{content:o,fileName:i,showEdit:u,isEditing:!1,onToggleEdit:x,extraActions:w}),(0,Z.jsx)(A,{content:o})]})}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(Y,{content:p?h:o,fileName:i,showEdit:u,isEditing:p,onToggleEdit:()=>p?S():x(),extraActions:w}),p?(0,Z.jsx)(J,{value:h,onChange:g,onSave:b}):(0,Z.jsx)(K,{content:o,readOnly:!u,onStartEdit:x})]}),p&&(0,Z.jsx)(q,{isDirty:y,isSaving:v.isPending,error:v.isError?`Save failed`:null,onSave:b,onDiscard:S})]})}var re=e(i(),1);function ie({fileName:e,content:t,isBinary:n,viewMode:r=`preview`}){return n?(0,Z.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Binary file — no preview available.`}):t===null?(0,Z.jsxs)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[`No preview available for `,e,`.`]}):k(e,void 0)&&r===`preview`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Z.jsx)(A,{content:t})}):(0,Z.jsx)(`pre`,{className:`h-full overflow-y-auto whitespace-pre-wrap break-words p-4 font-mono text-body-small-default`,style:{color:`var(--content-default)`},children:t})}function ae({assistantId:e,skill:t,onBack:n,onInstall:i,onRemove:a,isInstalling:o=!1,isRemoving:s=!1,swipeContainerRef:c,sourceConversationId:l}){let u=v(t),d=H(t),{fileEntries:p,setSelectedPath:g,activePath:y,activeFile:b,isFilesLoading:x,fileContent:C,isBinary:T,isContentLoading:D}=V(e,t.id),[A,j]=(0,X.useState)(`preview`);(0,X.useEffect)(()=>{j(`preview`)},[y]);let[M,N]=(0,X.useState)(null);(0,X.useEffect)(()=>{N(document.getElementById(`viewport-overlays`))},[]);let P=b?k(b.name,void 0):!1,F=P?A:`raw`,I=(0,Z.jsxs)(`div`,{ref:c,className:`fixed inset-0 z-40 flex flex-col overflow-hidden bg-[var(--surface-overlay)]`,style:{paddingTop:`calc(8px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,paddingBottom:`calc(8px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))`,paddingLeft:`calc(12px + var(--safe-area-inset-left, env(safe-area-inset-left, 0px)))`,paddingRight:`calc(12px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(r,{variant:`ghost`,iconOnly:(0,Z.jsx)(m,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Back to skills`,onClick:n,className:`max-md:bg-[var(--surface-active)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate px-2 text-center text-body-medium-default`,style:{color:`var(--content-secondary)`},children:t.name}),(0,Z.jsx)(oe,{available:u,removable:d,isInstalling:o,isRemoving:s,onInstall:i,onRemove:a})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(_,{skill:t,className:`h-6 w-6 shrink-0 text-[22px] leading-none`}),(0,Z.jsx)(`h2`,{className:`min-w-0 truncate text-title-medium`,style:{color:`var(--content-emphasised)`},children:t.name})]}),(0,Z.jsx)(h,{origin:t.origin})]}),(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:t.description}),(0,Z.jsx)(B,{skill:{origin:t.origin,sourceConversationId:l}})]}),(0,Z.jsx)(f.Root,{asChild:!0,noPadding:!0,children:(0,Z.jsxs)(`div`,{className:`mt-6 flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border bg-[var(--surface-lift)]`,style:{borderColor:`var(--border-hover)`},children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-3 py-2`,style:{borderColor:`var(--border-hover)`},children:[(0,Z.jsx)(ce,{fileEntries:p,activePath:y,activeName:b?.name??null,onSelect:g}),(0,Z.jsx)(O,{iconOnly:!0,ariaLabel:`File view mode`,value:F,onChange:j,items:[{value:`preview`,label:`Preview`,icon:(0,Z.jsx)(w,{"aria-hidden":!0}),disabled:!P},{value:`raw`,label:`Source`,icon:(0,Z.jsx)(S,{"aria-hidden":!0})}]})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:x||D?(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(E,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):b?(0,Z.jsx)(ie,{fileName:b.name,content:C,isBinary:T,viewMode:F}):(0,Z.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view its contents.`})})]})})]});return M?(0,re.createPortal)(I,M):I}function oe({available:e,removable:t,isInstalling:n,isRemoving:i,onInstall:a,onRemove:o}){return n||i?(0,Z.jsx)(r,{variant:`ghost`,iconOnly:(0,Z.jsx)(E,{className:`animate-spin`,"aria-hidden":!0}),expandOnMobile:!0,disabled:!0,"aria-label":`Pending`,className:`max-md:bg-[var(--surface-active)]`}):e?(0,Z.jsx)(r,{variant:`ghost`,iconOnly:(0,Z.jsx)(L,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Install skill`,onClick:a,disabled:!a,className:`max-md:bg-[var(--surface-active)]`}):t?(0,Z.jsx)(r,{variant:`dangerGhost`,iconOnly:(0,Z.jsx)(F,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Remove skill`,onClick:o,disabled:!o,className:`max-md:rounded-full max-md:bg-[var(--system-negative-weak)]`}):(0,Z.jsx)(r,{variant:`dangerGhost`,iconOnly:(0,Z.jsx)(F,{"aria-hidden":!0}),expandOnMobile:!0,disabled:!0,title:`Bundled skills cannot be removed`,"aria-label":`Bundled skill cannot be removed`,className:`max-md:rounded-full max-md:bg-[var(--system-negative-weak)]`})}function se(e){return(e??``).endsWith(`/directory`)}function ce({fileEntries:e,activePath:t,activeName:n,onSelect:r}){let i=n??`Select a file`;return e.length===0?(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{className:`truncate`,children:i})]}):(0,Z.jsxs)(x.Root,{children:[(0,Z.jsx)(x.Trigger,{children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-2 rounded-md text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{className:`truncate`,children:i}),(0,Z.jsx)(b,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`},"aria-hidden":!0})]})}),(0,Z.jsx)(x.Content,{align:`start`,children:e.map(e=>{let n=se(e.mimeType);return(0,Z.jsx)(x.Item,{onSelect:()=>r(e.path),leftIcon:n?(0,Z.jsx)(R,{}):(0,Z.jsx)(T,{}),"aria-current":e.path===t?`true`:void 0,children:e.name},e.path)})})]})}function Q(){return(0,Z.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)]`,"aria-hidden":!0,children:(0,Z.jsx)(T,{className:`h-4 w-4`,style:{color:`var(--content-secondary)`}})})}function le(){return(0,Z.jsx)(g,{icon:D,iconColor:`var(--system-danger)`,title:`Failed to load skills`,subtitle:`Something went wrong. Try refreshing the page.`})}function $(){return(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,Z.jsx)(E,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})})}function ue(){let e=z(),{skillId:t}=a(),n=c(),i=o(),{pathname:l}=i,d=I(),f=(0,X.useRef)(null),p=i.state,h=typeof p?.listSearch==`string`?p.listSearch:``,_=u({...j({path:{assistant_id:e},query:{include:`catalog`}}),select:e=>e.skills,refetchOnMount:`always`}),v=(0,X.useCallback)(()=>{n(`${P.superpowers}${h}`,{replace:!0})},[n,h]);G({containerRef:f,onBack:v,enabled:d,navKey:l});let{handleInstall:b,handleRemove:x,isInstallingSkill:S,isRemovingSkill:C,skillPendingRemoval:w,confirmRemove:T,cancelRemove:E}=y(e,{onRemoved:v}),D=_.data,O=(0,X.useMemo)(()=>D?.find(e=>e.id===t)??null,[D,t]),k=u({...M({path:{assistant_id:e,id:t??``}}),enabled:!!t&&O?.origin===`assistant-memory`,select:e=>e.skill.origin===`assistant-memory`?e.skill.sourceConversationId??null:null});if(!t)return(0,Z.jsx)(s,{to:P.superpowers,replace:!0});if(_.isLoading)return(0,Z.jsx)($,{});if(_.isError&&!O)return(0,Z.jsx)(le,{});if(!O&&_.isFetching)return(0,Z.jsx)($,{});if(!O)return(0,Z.jsx)(g,{icon:ee,title:`Skill not found`,subtitle:`This skill may have been removed, or the link is out of date.`,children:(0,Z.jsx)(r,{type:`button`,variant:`outlined`,className:`mt-4`,leftIcon:(0,Z.jsx)(m,{"aria-hidden":!0}),onClick:v,children:`Back to My Superpowers`})});let A={assistantId:e,skill:O,onBack:v,onInstall:()=>b(O),onRemove:()=>x(O),isInstalling:S(O),isRemoving:C(O),sourceConversationId:k.data??void 0};return(0,Z.jsxs)(Z.Fragment,{children:[d?(0,Z.jsx)(ae,{...A,swipeContainerRef:f}):(0,Z.jsx)(te,{...A}),(0,Z.jsx)(U,{skillName:w?.name??null,onConfirm:T,onCancel:E})]})}export{ue as SkillDetailPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-BQVYX8n_.js";import{u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as a}from"./QueryClientProvider-DKhXIxGb.js";import{t as o}from"./useQuery-B45lW1Kk.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./typography-Cqi8q9o7.js";import{t as l}from"./brain-Ci5ws6Wl.js";import{t as u}from"./menu-C9SOvGlk.js";import{t as d}from"./loader-circle-Ck8fq3yv.js";import"./src-CheJrlfT.js";import{t as f}from"./file-markdown-BXDlM5ry.js";import{n as p}from"./resolved-assistants-store-DdHm-7v4.js";import{bt as m,on as h}from"./react-query.gen-C0S0EYHV.js";import{c as g}from"./routes-Cwb-U9H-.js";import{Ao as _,E as v,hs as y}from"./index-D7_9Qy0L.js";import{n as b,t as x}from"./use-skill-detail-files-BVoaelHO.js";import{n as S,r as C,t as w}from"./skills-CqbxZ62G.js";var T=e(n(),1),E=s();function D({skillId:e,onClose:n}){let s=i(),D=a(),O=p.use.activeAssistantId(),[k,A]=(0,T.useState)(!1),j=o({...m({path:{assistant_id:O??``,id:e}}),select:e=>e.skill,enabled:!!O}),M=j.data,{skillMd:N,fileContent:P,isFilesPending:F,isContentPending:I}=x(O,e),L=h({onSuccess:()=>{O&&w(D,O),n()},onError:e=>{t(e,{context:`skill-detail-panel-remove`})}}),R=()=>{O&&(L.mutate({path:{assistant_id:O,id:e}}),A(!1))},z=j.isPending||F||N!=null&&I,B=M!=null&&S(M);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v,{icon:M?.emoji?(0,E.jsx)(`span`,{className:`text-xl leading-none`,"aria-hidden":!0,children:M.emoji}):void 0,Glyph:l,title:M?.name??`Skill`,closeLabel:`Close skill details`,onClose:n,headerActions:B?(0,E.jsxs)(u.Root,{children:[(0,E.jsx)(u.Trigger,{asChild:!0,children:(0,E.jsx)(r,{variant:`ghost`,iconOnly:(0,E.jsx)(y,{}),"aria-label":`Skill actions`,className:`shrink-0`})}),(0,E.jsx)(u.Content,{side:`bottom`,align:`end`,children:(0,E.jsx)(u.Item,{leftIcon:(0,E.jsx)(_,{size:14}),onSelect:()=>A(!0),children:`Remove skill`})})]}):void 0,footer:(0,E.jsx)(r,{fullWidth:!0,onClick:()=>s(g.skills.detail(e)),children:`Go to Skill`}),children:j.isError&&!M?(0,E.jsx)(c,{variant:`body-medium-lighter`,as:`p`,className:`py-8 text-center text-[var(--content-tertiary)]`,children:`This skill could not be loaded. It may have been removed.`}):z?(0,E.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,E.jsx)(d,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,E.jsxs)(E.Fragment,{children:[M?.description&&(0,E.jsx)(c,{variant:`body-medium-lighter`,as:`p`,className:`mb-4 text-[var(--content-secondary)]`,children:M.description}),M&&(0,E.jsx)(b,{skill:M,className:`mb-4`,onNavigate:n}),P&&(0,E.jsx)(f,{content:P})]})}),(0,E.jsx)(C,{skillName:k&&M?M.name:null,onConfirm:R,onCancel:()=>A(!1)})]})}export{D as SkillDetailPanel};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-BQVYX8n_.js";import{u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as a}from"./QueryClientProvider-DKhXIxGb.js";import{t as o}from"./useQuery-B45lW1Kk.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./typography-Cqi8q9o7.js";import{t as l}from"./brain-Ci5ws6Wl.js";import{t as u}from"./menu-C9SOvGlk.js";import{t as d}from"./loader-circle-Ck8fq3yv.js";import"./src-CheJrlfT.js";import{t as f}from"./file-markdown-BXDlM5ry.js";import{n as p}from"./resolved-assistants-store-DdHm-7v4.js";import{bt as m,on as h}from"./react-query.gen-C0S0EYHV.js";import{c as g}from"./routes-Cwb-U9H-.js";import{Ao as _,E as v,hs as y}from"./index-2np2R8qP.js";import{n as b,t as x}from"./use-skill-detail-files-8L8VWCDM.js";import{n as S,r as C,t as w}from"./skills-CqbxZ62G.js";var T=e(n(),1),E=s();function D({skillId:e,onClose:n}){let s=i(),D=a(),O=p.use.activeAssistantId(),[k,A]=(0,T.useState)(!1),j=o({...m({path:{assistant_id:O??``,id:e}}),select:e=>e.skill,enabled:!!O}),M=j.data,{skillMd:N,fileContent:P,isFilesPending:F,isContentPending:I}=x(O,e),L=h({onSuccess:()=>{O&&w(D,O),n()},onError:e=>{t(e,{context:`skill-detail-panel-remove`})}}),R=()=>{O&&(L.mutate({path:{assistant_id:O,id:e}}),A(!1))},z=j.isPending||F||N!=null&&I,B=M!=null&&S(M);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v,{icon:M?.emoji?(0,E.jsx)(`span`,{className:`text-xl leading-none`,"aria-hidden":!0,children:M.emoji}):void 0,Glyph:l,title:M?.name??`Skill`,closeLabel:`Close skill details`,onClose:n,headerActions:B?(0,E.jsxs)(u.Root,{children:[(0,E.jsx)(u.Trigger,{asChild:!0,children:(0,E.jsx)(r,{variant:`ghost`,iconOnly:(0,E.jsx)(y,{}),"aria-label":`Skill actions`,className:`shrink-0`})}),(0,E.jsx)(u.Content,{side:`bottom`,align:`end`,children:(0,E.jsx)(u.Item,{leftIcon:(0,E.jsx)(_,{size:14}),onSelect:()=>A(!0),children:`Remove skill`})})]}):void 0,footer:(0,E.jsx)(r,{fullWidth:!0,onClick:()=>s(g.skills.detail(e)),children:`Go to Skill`}),children:j.isError&&!M?(0,E.jsx)(c,{variant:`body-medium-lighter`,as:`p`,className:`py-8 text-center text-[var(--content-tertiary)]`,children:`This skill could not be loaded. It may have been removed.`}):z?(0,E.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,E.jsx)(d,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,E.jsxs)(E.Fragment,{children:[M?.description&&(0,E.jsx)(c,{variant:`body-medium-lighter`,as:`p`,className:`mb-4 text-[var(--content-secondary)]`,children:M.description}),M&&(0,E.jsx)(b,{skill:M,className:`mb-4`,onNavigate:n}),P&&(0,E.jsx)(f,{content:P})]})}),(0,E.jsx)(C,{skillName:k&&M?M.name:null,onConfirm:R,onCancel:()=>A(!1)})]})}export{D as SkillDetailPanel};
@@ -1 +1 @@
1
- import{t as e}from"./button-BQVYX8n_.js";import{u as t}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{c as r}from"./routes-Cwb-U9H-.js";import{pn as i}from"./index-D7_9Qy0L.js";var a=n();function o(){let n=t();return(0,a.jsx)(i,{children:(0,a.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,a.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center`,children:[(0,a.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Welcome to Vellum`}),(0,a.jsx)(`p`,{className:`mt-3 text-center 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.`}),(0,a.jsx)(`div`,{className:`mt-10 flex w-full max-w-sm flex-col`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:(0,a.jsx)(e,{variant:`primary`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:()=>void n(r.onboarding.privacy),children:`Create your assistant`})})]})})})}export{o as StartScreen};
1
+ import{t as e}from"./button-BQVYX8n_.js";import{u as t}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{c as r}from"./routes-Cwb-U9H-.js";import{pn as i}from"./index-2np2R8qP.js";var a=n();function o(){let n=t();return(0,a.jsx)(i,{children:(0,a.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,a.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center`,children:[(0,a.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Welcome to Vellum`}),(0,a.jsx)(`p`,{className:`mt-3 text-center 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.`}),(0,a.jsx)(`div`,{className:`mt-10 flex w-full max-w-sm flex-col`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:(0,a.jsx)(e,{variant:`primary`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:()=>void n(r.onboarding.privacy),children:`Create your assistant`})})]})})})}export{o as StartScreen};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-Cqi8q9o7.js";import{t as a}from"./arrow-left-C2re-gYj.js";import{n as o,r as s,t as c}from"./metric-card-Cywp_yEB.js";import{h as l,ht as u}from"./risk-CcEyZBGP.js";import{t as d}from"./brain-Ci5ws6Wl.js";import{t as f}from"./chevron-down-DpYf9Gwq.js";import{r as p}from"./panel-item-An-BBeyL.js";import{t as m}from"./globe-DgKSh933.js";import{t as h}from"./x-CswtfvgS.js";import"./src-CheJrlfT.js";import{t as g}from"./chat-markdown-message-CqG8Eq9L.js";import{a as _,i as v,r as y}from"./subagent-store-BsdZwCd6.js";import{t as b}from"./misc-D0u5tzSd.js";import{t as x}from"./proxy-BzlH_XAe.js";import{t as S}from"./AnimatePresence-C8APSgIu.js";import{t as C}from"./use-reduced-motion-CcGT6CHV.js";import{S as w,a as T,b as E,c as D,d as O,f as k,i as A,l as j,m as M,n as N,o as P,p as F,r as I,t as L,u as R}from"./site-favicon-DFbjMYfe.js";import{t as z}from"./three-dot-indicator-DNuHHwtA.js";import{Ls as B,ct as V,ft as H,lt as U,pt as ee,st as W,ut as G}from"./index-D7_9Qy0L.js";import{t as te}from"./status-badge-pill-0N6rTEBg.js";import{CodeBlock as K,ToolDetailBody as q}from"./tool-detail-panel-EOB9LtOS.js";import{t as J}from"./detail-panel-stop-button-BDxTkocG.js";var Y=e(t(),1),X=r();function Z({status:e}){return(0,X.jsx)(te,{color:v(e),label:_(e)})}function ne(e,t){let n=e.steps[0];return`${t}-${e.label}-${n?k(n,t):``}`}function re(e){for(let t=e.steps.length-1;t>=0;t--){let n=e.steps[t];if(n.kind===`tool`&&n.status===`running`||n.kind===`web_search`&&n.title===`Searching the web`)return n}}function ie(e,t){return e&&e.kind===`tool`&&(e.activity||e.info)||t}function ae(e){for(let t=e.steps.length-1;t>=0;t--){let n=e.steps[t];if(n.kind===`web_search`&&n.query)return n.query}}function oe(e){for(let t=e.steps.length-1;t>=0;t--){let n=e.steps[t];if(n.kind===`thinking`&&n.text)return n.text}}function Q(e){if(e.kind===`tool`)return e.toolCallId||void 0;if(e.kind===`thinking`||e.kind===`web_search`||e.kind===`web_search_error`)return e.detailKey}function se({steps:e,onStepDetailClick:t,expandedKeys:n,onExpandedKeysChange:r,isRunning:i=!1}){let[a,o]=(0,Y.useState)(new Set),s=n??a,c=(0,Y.useCallback)(e=>{let t=t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n};if(r){r(t);return}o(t)},[r]),l=(0,Y.useMemo)(()=>R(e),[e]);return l.length===0?null:(0,X.jsx)(`div`,{className:`flex w-full flex-col`,children:l.map((e,n)=>{let r=ne(e,n),a=n===l.length-1;return(0,X.jsx)(ce,{section:e,isLast:a,isActiveTail:a&&i,expanded:s.has(r),sectionKeyValue:r,onToggle:c,onStepDetailClick:t},r)})})}var ce=(0,Y.memo)(function({section:e,isLast:t,isActiveTail:n,expanded:r,sectionKeyValue:a,onToggle:o,onStepDetailClick:s}){let c=C(),l=O(e.steps),u=l===`running`&&!n?`completed`:l,f=u===`running`||n,p=e.steps[0]?.kind===`thinking`,h=e.steps.length,g=e.label===`Searching the web`,_=g?ae(e):void 0,v=h>=2,y=e.steps.some(e=>F(e)||!!s&&!!Q(e)),E=u===`running`?``:M(e.steps.map(e=>`durationLabel`in e?e.durationLabel:``)),P=u===`running`?re(e):void 0,L=u===`running`&&!g?ie(P,e.label):``,R=g&&(u===`running`||!!_),z=_??e.label,B=p&&f,V=B?oe(e)??e.label:void 0,H=u===`running`||R||B||!!E,U=`${h} step${h===1?``:`s`}`;return(0,X.jsxs)(`div`,{"data-testid":`subagent-phase-section`,"data-phase-label":e.label,className:b(`relative flex flex-col gap-2`,!t&&`pb-4`),children:[!t&&(0,X.jsx)(D,{className:`top-[17.5px] -bottom-[4.5px]`}),(0,X.jsxs)(`button`,{type:`button`,"data-testid":`subagent-phase-header`,disabled:!y,onClick:y?()=>o(a):void 0,className:b(`flex h-[22px] w-full items-center gap-2 text-left`,y&&`cursor-pointer`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex h-[14px] w-[14px] shrink-0 items-center justify-center`,children:(0,X.jsx)(`span`,{className:`h-[5px] w-[5px] rounded-full bg-[var(--content-disabled)]`})}),(0,X.jsx)(j,{status:f?`running`:u,isThinking:p&&!f}),(0,X.jsx)(i,{variant:`body-medium-default`,className:`shrink-0 text-[var(--content-default)]`,children:e.label}),H&&(0,X.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 leading-none text-[var(--content-tertiary)] opacity-10`,children:`|`}),R?(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,X.jsx)(m,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(w,{currentStepTitle:``,currentStepInfo:z})]}):B?(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,X.jsx)(d,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(w,{currentStepTitle:``,currentStepInfo:V??e.label})]}):u===`running`?(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,X.jsx)(d,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(w,{currentStepTitle:``,currentStepInfo:L})]}):E?(0,X.jsx)(i,{variant:`body-small-default`,className:`min-w-0 truncate text-[var(--content-tertiary)]`,children:`Worked for ${E}`}):null,y&&v&&(0,X.jsx)(`span`,{"data-testid":`subagent-phase-step-count`,className:`ml-auto inline-flex shrink-0 items-center self-stretch whitespace-nowrap rounded-full bg-[var(--surface-base)] px-2`,children:(0,X.jsx)(i,{variant:`body-small-default`,className:`whitespace-nowrap text-[var(--content-secondary)]`,children:U})})]}),(0,X.jsx)(S,{initial:!1,children:y&&r&&(0,X.jsx)(x.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:c?{duration:0}:{duration:.25,ease:[.16,1,.3,1]},className:`overflow-hidden`,children:(0,X.jsx)(`div`,{className:`flex flex-col items-start gap-1 pl-[22px]`,children:e.steps.map((e,t)=>{let n=s?Q(e):void 0;if(n&&s){if(e.kind===`tool`)return(0,X.jsx)(A,{variant:`tool`,iconName:e.iconName,label:e.activity||e.info||e.title,ariaLabel:`View tool details`,onClick:()=>s(n)},k(e,t));if(e.kind===`thinking`)return(0,X.jsx)(A,{variant:`tool`,iconName:`brain`,label:e.text,ariaLabel:`View reasoning`,onClick:()=>s(n)},k(e,t));if(e.kind===`web_search`)return(0,X.jsx)(A,{variant:`tool`,iconName:`globe`,label:e.query||e.title,ariaLabel:`View search details`,onClick:()=>s(n)},k(e,t));if(e.kind===`web_search_error`)return(0,X.jsx)(A,{variant:`tool`,iconName:`globe`,label:e.errorMessage,ariaLabel:`View search error`,onClick:()=>s(n)},k(e,t))}return e.kind===`web_search`?(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[e.query?(0,X.jsx)(i,{variant:`body-small-default`,className:`text-[var(--content-secondary)]`,children:`"${e.query}"`}):null,(0,X.jsx)(I,{step:e})]},k(e,t)):e.kind===`web_search_error`?(0,X.jsx)(N,{step:e},k(e,t)):(0,X.jsx)(T,{step:e},k(e,t))})})},`phase-steps`)})]})}),le=`
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-Cqi8q9o7.js";import{t as a}from"./arrow-left-C2re-gYj.js";import{n as o,r as s,t as c}from"./metric-card-Cywp_yEB.js";import{h as l,ht as u}from"./risk-CcEyZBGP.js";import{t as d}from"./brain-Ci5ws6Wl.js";import{t as f}from"./chevron-down-DpYf9Gwq.js";import{r as p}from"./panel-item-An-BBeyL.js";import{t as m}from"./globe-DgKSh933.js";import{t as h}from"./x-CswtfvgS.js";import"./src-CheJrlfT.js";import{t as g}from"./chat-markdown-message-CqG8Eq9L.js";import{a as _,i as v,r as y}from"./subagent-store-BsdZwCd6.js";import{t as b}from"./misc-D0u5tzSd.js";import{t as x}from"./proxy-BzlH_XAe.js";import{t as S}from"./AnimatePresence-C8APSgIu.js";import{t as C}from"./use-reduced-motion-CcGT6CHV.js";import{S as w,a as T,b as E,c as D,d as O,f as k,i as A,l as j,m as M,n as N,o as P,p as F,r as I,t as L,u as R}from"./site-favicon-DFbjMYfe.js";import{t as z}from"./three-dot-indicator-DNuHHwtA.js";import{Ls as B,ct as V,ft as H,lt as U,pt as ee,st as W,ut as G}from"./index-2np2R8qP.js";import{t as te}from"./status-badge-pill-0N6rTEBg.js";import{CodeBlock as K,ToolDetailBody as q}from"./tool-detail-panel-B7WGaI0e.js";import{t as J}from"./detail-panel-stop-button-39zLlSig.js";var Y=e(t(),1),X=r();function Z({status:e}){return(0,X.jsx)(te,{color:v(e),label:_(e)})}function ne(e,t){let n=e.steps[0];return`${t}-${e.label}-${n?k(n,t):``}`}function re(e){for(let t=e.steps.length-1;t>=0;t--){let n=e.steps[t];if(n.kind===`tool`&&n.status===`running`||n.kind===`web_search`&&n.title===`Searching the web`)return n}}function ie(e,t){return e&&e.kind===`tool`&&(e.activity||e.info)||t}function ae(e){for(let t=e.steps.length-1;t>=0;t--){let n=e.steps[t];if(n.kind===`web_search`&&n.query)return n.query}}function oe(e){for(let t=e.steps.length-1;t>=0;t--){let n=e.steps[t];if(n.kind===`thinking`&&n.text)return n.text}}function Q(e){if(e.kind===`tool`)return e.toolCallId||void 0;if(e.kind===`thinking`||e.kind===`web_search`||e.kind===`web_search_error`)return e.detailKey}function se({steps:e,onStepDetailClick:t,expandedKeys:n,onExpandedKeysChange:r,isRunning:i=!1}){let[a,o]=(0,Y.useState)(new Set),s=n??a,c=(0,Y.useCallback)(e=>{let t=t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n};if(r){r(t);return}o(t)},[r]),l=(0,Y.useMemo)(()=>R(e),[e]);return l.length===0?null:(0,X.jsx)(`div`,{className:`flex w-full flex-col`,children:l.map((e,n)=>{let r=ne(e,n),a=n===l.length-1;return(0,X.jsx)(ce,{section:e,isLast:a,isActiveTail:a&&i,expanded:s.has(r),sectionKeyValue:r,onToggle:c,onStepDetailClick:t},r)})})}var ce=(0,Y.memo)(function({section:e,isLast:t,isActiveTail:n,expanded:r,sectionKeyValue:a,onToggle:o,onStepDetailClick:s}){let c=C(),l=O(e.steps),u=l===`running`&&!n?`completed`:l,f=u===`running`||n,p=e.steps[0]?.kind===`thinking`,h=e.steps.length,g=e.label===`Searching the web`,_=g?ae(e):void 0,v=h>=2,y=e.steps.some(e=>F(e)||!!s&&!!Q(e)),E=u===`running`?``:M(e.steps.map(e=>`durationLabel`in e?e.durationLabel:``)),P=u===`running`?re(e):void 0,L=u===`running`&&!g?ie(P,e.label):``,R=g&&(u===`running`||!!_),z=_??e.label,B=p&&f,V=B?oe(e)??e.label:void 0,H=u===`running`||R||B||!!E,U=`${h} step${h===1?``:`s`}`;return(0,X.jsxs)(`div`,{"data-testid":`subagent-phase-section`,"data-phase-label":e.label,className:b(`relative flex flex-col gap-2`,!t&&`pb-4`),children:[!t&&(0,X.jsx)(D,{className:`top-[17.5px] -bottom-[4.5px]`}),(0,X.jsxs)(`button`,{type:`button`,"data-testid":`subagent-phase-header`,disabled:!y,onClick:y?()=>o(a):void 0,className:b(`flex h-[22px] w-full items-center gap-2 text-left`,y&&`cursor-pointer`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex h-[14px] w-[14px] shrink-0 items-center justify-center`,children:(0,X.jsx)(`span`,{className:`h-[5px] w-[5px] rounded-full bg-[var(--content-disabled)]`})}),(0,X.jsx)(j,{status:f?`running`:u,isThinking:p&&!f}),(0,X.jsx)(i,{variant:`body-medium-default`,className:`shrink-0 text-[var(--content-default)]`,children:e.label}),H&&(0,X.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 leading-none text-[var(--content-tertiary)] opacity-10`,children:`|`}),R?(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,X.jsx)(m,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(w,{currentStepTitle:``,currentStepInfo:z})]}):B?(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,X.jsx)(d,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(w,{currentStepTitle:``,currentStepInfo:V??e.label})]}):u===`running`?(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,X.jsx)(d,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(w,{currentStepTitle:``,currentStepInfo:L})]}):E?(0,X.jsx)(i,{variant:`body-small-default`,className:`min-w-0 truncate text-[var(--content-tertiary)]`,children:`Worked for ${E}`}):null,y&&v&&(0,X.jsx)(`span`,{"data-testid":`subagent-phase-step-count`,className:`ml-auto inline-flex shrink-0 items-center self-stretch whitespace-nowrap rounded-full bg-[var(--surface-base)] px-2`,children:(0,X.jsx)(i,{variant:`body-small-default`,className:`whitespace-nowrap text-[var(--content-secondary)]`,children:U})})]}),(0,X.jsx)(S,{initial:!1,children:y&&r&&(0,X.jsx)(x.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:c?{duration:0}:{duration:.25,ease:[.16,1,.3,1]},className:`overflow-hidden`,children:(0,X.jsx)(`div`,{className:`flex flex-col items-start gap-1 pl-[22px]`,children:e.steps.map((e,t)=>{let n=s?Q(e):void 0;if(n&&s){if(e.kind===`tool`)return(0,X.jsx)(A,{variant:`tool`,iconName:e.iconName,label:e.activity||e.info||e.title,ariaLabel:`View tool details`,onClick:()=>s(n)},k(e,t));if(e.kind===`thinking`)return(0,X.jsx)(A,{variant:`tool`,iconName:`brain`,label:e.text,ariaLabel:`View reasoning`,onClick:()=>s(n)},k(e,t));if(e.kind===`web_search`)return(0,X.jsx)(A,{variant:`tool`,iconName:`globe`,label:e.query||e.title,ariaLabel:`View search details`,onClick:()=>s(n)},k(e,t));if(e.kind===`web_search_error`)return(0,X.jsx)(A,{variant:`tool`,iconName:`globe`,label:e.errorMessage,ariaLabel:`View search error`,onClick:()=>s(n)},k(e,t))}return e.kind===`web_search`?(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[e.query?(0,X.jsx)(i,{variant:`body-small-default`,className:`text-[var(--content-secondary)]`,children:`"${e.query}"`}):null,(0,X.jsx)(I,{step:e})]},k(e,t)):e.kind===`web_search_error`?(0,X.jsx)(N,{step:e},k(e,t)):(0,X.jsx)(T,{step:e},k(e,t))})})},`phase-steps`)})]})}),le=`
2
2
  Content:
3
3
  `;function ue(e){return E(e)||e}function de(e,t){let n=e??``,r=n.indexOf(le),i=r>=0?n.slice(0,r):``,a=r>=0?n.slice(r+10):n,o=e=>{let t=i.match(RegExp(`^${e}:[ \\t]*(.+)$`,`m`));return t?t[1].trim():null},s=[],c=i.indexOf(`Notices:`);if(c>=0)for(let e of i.slice(c).split(`
4
4
  `)){let t=e.match(/^\s*-\s+(.*)$/);t&&t[1].trim()&&s.push(t[1].trim())}a=a.trim();let l=null,u=a.match(/^<external_content\b([^>]*)>\s*/);if(u){let e=u[1].match(/origin="([^"]+)"/);e&&(l=e[1]),a=a.slice(u[0].length).replace(/\s*<\/external_content>\s*$/,``)}return{url:o(`Final URL`)||o(`Requested URL`)||l||t||null,status:o(`Status`),notices:s,content:a.trim()}}function fe({url:e,status:t}){let n=ue(e),r=t?/^\s*2\d\d/.test(t):!1;return(0,X.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3 transition-colors hover:border-[var(--border-hover)]`,children:[(0,X.jsx)(L,{domain:n,title:n}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(i,{variant:`body-medium-default`,as:`span`,className:`truncate text-[var(--content-default)]`,children:n}),(0,X.jsx)(i,{variant:`body-small-default`,as:`span`,className:`truncate text-[var(--content-tertiary)]`,children:e})]}),t&&(0,X.jsx)(`span`,{className:`shrink-0 rounded-[6px] px-2 py-0.5 text-body-small-emphasised ${r?`text-[var(--system-positive-strong)]`:`text-[var(--content-tertiary)]`}`,children:t})]})}function pe({detail:e}){let[t,n]=(0,Y.useState)(!1),r=typeof e.input?.url==`string`?e.input.url:void 0,a=(0,Y.useMemo)(()=>de(e.result??``,r),[e.result,r]);return e.status===`error`?(0,X.jsx)(K,{text:e.result??`Fetch failed.`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[a.url&&(0,X.jsx)(fe,{url:a.url,status:a.status}),a.notices.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1 rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:a.notices.map((e,t)=>(0,X.jsx)(i,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:e},t))}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`text-[var(--content-emphasised)]`,children:t?`Raw result`:`Content`}),e.result&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`cursor-pointer text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:(0,X.jsx)(i,{variant:`label-small-default`,as:`span`,children:t?`View extracted`:`View raw`})})]}),t?(0,X.jsx)(K,{text:e.result??``}):a.content?(0,X.jsx)(g,{content:a.content}):(0,X.jsx)(i,{variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:e.status===`running`?`Fetching…`:`No content extracted.`})]})]})}function me({detail:e}){let t=e.searchQuery??``,n=e.searchResults??[];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[t?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`text-[var(--content-emphasised)]`,children:`Query`}),(0,X.jsx)(i,{variant:`body-medium-lighter`,as:`p`,className:`break-words leading-relaxed text-[var(--content-default)]`,children:`"${t}"`})]}):null,(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`text-[var(--content-emphasised)]`,children:n.length>0?`Sources (${n.length})`:`Sources`}),n.length>0?(0,X.jsx)(I,{step:{kind:`web_search`,title:`Searched the web`,durationLabel:``,linkCount:n.length,results:n}}):(0,X.jsx)(i,{variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:`No sources found.`})]})]})}function $(e){return new Map(e.map(e=>[e.toolCallId,e]))}function he(e=W){let t=null,n=[],r=[],i=new Map;function a(a){let o=[],s=[];for(let t of a)e(o,s,t);return t=a,n=o,r=s,i=$(n),i}function o(o){let s=U(t,o);switch(s.kind){case`identity`:return i;case`first`:return a(o);case`append`:{let a=o.length,c=n.slice(),l=r.slice();for(let t=s.from;t<a;t++)e(c,l,o[t]);return t=o,n=c,r=l,i=$(n),i}case`mutate-last`:{let a=o.length,s=n.slice(),c=r.slice(),l=s[s.length-1];return l&&l.kind===`thinking`&&l.toolCallId===o[a-1].id&&(s.pop(),c.pop()),e(s,c,o[a-1]),t=o,n=s,r=c,i=$(n),i}case`fallback`:return a(o)}}return{project:o}}function ge(e){let t=(0,Y.useRef)(null);return t.current??=he(),t.current.project(e)}function _e(e){return e.kind===`web_search`?`globe`:e.kind===`thinking`?`brain`:l(e.toolName,e.input).iconName}function ve({detail:e}){return e.status===`running`?(0,X.jsx)(z,{className:`shrink-0`,"data-testid":`nested-detail-running`}):(0,X.jsx)(P[_e(e)]??u,{"aria-hidden":!0,className:`h-5 w-5 shrink-0 text-[var(--content-secondary)]`})}function ye({entry:e,onClose:t,onStop:r,onRequestDetail:l}){let u=y(e.status),d=C(),m=H(),_=(0,Y.useMemo)(()=>G(e.subagentId),[e.subagentId]),{steps:v}=V(e.events),b=ge(e.events),[S,w]=(0,Y.useState)(null),T=(0,Y.useRef)(b);T.current=b;let E=(0,Y.useCallback)(e=>{T.current.has(e)&&w(e)},[]),[D,O]=(0,Y.useState)(new Set),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),N=(0,Y.useRef)(null),[P,F]=(0,Y.useState)(e.subagentId);P!==e.subagentId&&(F(e.subagentId),A(!1),M(!1),w(null),O(new Set)),(0,Y.useLayoutEffect)(()=>{if(k)return;let e=N.current;e&&M(e.scrollHeight>e.clientHeight)},[e.subagentId,e.objective,k]),(0,Y.useEffect)(()=>{l&&e.conversationId&&e.events.length===0&&l(e.subagentId)},[e.subagentId,e.conversationId,e.events.length,l]);let I=S?b.get(S):void 0,L=(0,Y.useCallback)(()=>w(null),[]),R=I?I.activity||I.title:``,z=I?R:e.label;return(0,X.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden rounded-xl bg-[var(--surface-lift)]`,children:[I&&(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-hover)] px-5 py-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:L,title:e.label,className:`min-w-0 shrink cursor-pointer truncate text-left text-[var(--content-default)] hover:underline`,children:(0,X.jsx)(i,{variant:`body-small-default`,as:`span`,children:e.label})}),(0,X.jsx)(p,{className:`h-2.5 w-2.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,X.jsx)(i,{variant:`body-small-default`,as:`span`,title:R,className:`min-w-0 shrink truncate text-[var(--content-secondary)]`,children:R})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-hover)] px-5 py-4`,children:[I&&(0,X.jsx)(n,{variant:`outlined`,iconOnly:(0,X.jsx)(a,{}),onClick:L,"aria-label":`Back to timeline`,tooltip:`Back`,className:`shrink-0 rounded-lg`}),I?(0,X.jsx)(ve,{detail:I}):m?(0,X.jsx)(ee,{components:m,bodyShapeId:_.bodyShape,eyeStyleId:_.eyeStyle,colorId:_.color,size:32}):(0,X.jsx)(`div`,{style:{width:32,height:32,flexShrink:0},"aria-hidden":!0}),(0,X.jsx)(i,{variant:`title-medium`,title:z,className:`min-w-0 shrink truncate leading-snug text-[var(--content-default)]`,children:z}),(0,X.jsx)(Z,{status:e.status}),(0,X.jsx)(`span`,{className:`flex-1`}),u&&r&&(0,X.jsx)(J,{onStop:()=>r(e.subagentId),ariaLabel:`Stop subagent`}),(0,X.jsx)(n,{variant:`outlined`,iconOnly:(0,X.jsx)(h,{}),onClick:t,"aria-label":`Close subagent detail`,tooltip:`Close`,className:`shrink-0 rounded-lg`})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-5`,children:(0,X.jsx)(x.div,{initial:{opacity:0},animate:{opacity:1},transition:d?{duration:0}:{duration:.18,ease:[.16,1,.3,1]},children:I?(0,X.jsx)(X.Fragment,{children:I.kind===`thinking`?(0,X.jsx)(g,{content:I.thinkingText??``,hardLineBreaks:!0}):I.kind===`web_search`&&I.status!==`error`?(0,X.jsx)(me,{detail:I}):I.toolName===`web_fetch`?(0,X.jsx)(pe,{detail:I}):(0,X.jsx)(q,{detail:I})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mb-5 grid grid-cols-2 gap-3`,children:[(0,X.jsx)(c,{icon:(0,X.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,X.jsx)(c,{icon:(0,X.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`})]}),e.objective&&(0,X.jsxs)(`div`,{className:`mb-5`,children:[(0,X.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`mb-2 text-[var(--content-emphasised)]`,children:`Objective`}),(0,X.jsx)(i,{ref:N,variant:`body-medium-lighter`,as:`p`,tabIndex:k?0:void 0,role:k?`region`:void 0,"aria-label":k?`Objective`:void 0,className:`whitespace-pre-wrap break-words leading-relaxed text-[var(--content-default)] ${k?`max-h-[280px] overflow-y-auto`:`line-clamp-5`}`,children:e.objective}),j&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>A(e=>!e),className:`mt-1.5 flex cursor-pointer items-center gap-1 text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:[(0,X.jsx)(i,{variant:`label-small-default`,children:k?`Show less`:`Show more`}),(0,X.jsx)(f,{className:`h-3.5 w-3.5 transition-transform ${k?`rotate-180`:``}`,"aria-hidden":!0})]}),(0,X.jsx)(`div`,{className:`mt-5 h-px w-full bg-[var(--border-hover)]`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(i,{variant:`title-medium`,as:`h3`,className:`mb-4 text-[var(--content-emphasised)]`,children:`Timeline`}),e.events.length>0?(0,X.jsx)(se,{steps:v,expandedKeys:D,onExpandedKeysChange:O,onStepDetailClick:E,isRunning:u},e.subagentId):(0,X.jsx)(i,{variant:`body-small-default`,className:`py-4 text-center text-[var(--content-tertiary)]`,children:`No events yet`})]})]})},I?`detail`:`list`)})]})}export{ye as SubagentDetailPanel};