@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,4 +1,4 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{P as n,t as r}from"./button-BQVYX8n_.js";import{m as i,t 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"./useMutation-Lj4VunQV.js";import{t as u}from"./jsx-runtime-CVSDxk6A.js";import{t as d}from"./typography-Cqi8q9o7.js";import{t as f}from"./card-D8zyWtZh.js";import{t as p}from"./chevron-down-DpYf9Gwq.js";import{t as m}from"./panel-item-An-BBeyL.js";import{t as h}from"./list-row-CFyYr-FU.js";import{t as g}from"./notice-DkAWz47A.js";import{M as _,N as v,a as y,i as b,j as x}from"./src-CheJrlfT.js";import{t as S}from"./tag-B6WeUtBW.js";import{t as C}from"./input-ZpyYt_a0.js";import{t as w}from"./confirm-dialog-Zyfei9GV.js";import{t as T}from"./dropdown-BxYrCXBS.js";import{n as E,t as D}from"./create-selectors-8NePGNlX.js";import{t as O}from"./assistant-identity-store-CgJwLRMd.js";import{r as k}from"./utils-DvUW9GK8.js";import{c as A}from"./routes-Cwb-U9H-.js";import{i as j,o as M,r as N}from"./sdk.gen-BhtkuoSl.js";import{t as P}from"./assistant-feature-flag-store-aNAjw1qx.js";import{t as F}from"./public-asset-Cr86Gucv.js";import{Bo as I,D as ee,F as L,Ft as te,I as ne,Oa as re,P as ie,T as ae,bn as R,da as oe,ds as z,ks as B,ns as se,ua as ce,yn as V}from"./index-D7_9Qy0L.js";import{t as le}from"./use-active-assistant-id-DwLFgABu.js";import{a as ue,c as de,d as H,l as fe,n as pe,o as me,t as he,u as ge}from"./use-invite-link-dialog-BL_ylpSj.js";import{t as _e}from"./detail-card-CIh4dCKt.js";import{n as ve,t as ye}from"./mobile-sidebar-drawer-BNR5lCRm.js";import{t as U}from"./mutation-error-C9sr8Rue.js";var W=e(t(),1),G=u();function K({icon:e,title:t,description:r,action:i,className:a}){return(0,G.jsxs)(`div`,{className:n(`flex flex-col items-center justify-center gap-3 px-4 py-12 text-center`,a),children:[e?(0,G.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-xl bg-[var(--surface-sunken)] text-[var(--content-tertiary)]`,children:e}):null,(0,G.jsx)(`h3`,{className:`text-title-small text-[var(--content-default)]`,children:t}),r?(0,G.jsx)(`p`,{className:`max-w-md text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:r}):null,i?(0,G.jsx)(`div`,{className:`mt-1`,children:i}):null]})}var q=D(E()(e=>({selectedAdapter:`slack`,selectAdapter:t=>e({selectedAdapter:t})})));function J({channels:e,selectedKey:t,onSelect:n}){return(0,G.jsx)(f.Root,{className:`flex h-full flex-col overflow-hidden`,children:(0,G.jsxs)(f.Body,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,G.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:`Channels`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,G.jsx)(be,{channel:e,selected:e.key===t,onClick:()=>n(e.key)},e.key))})]})})}function be({channel:e,selected:t,onClick:n}){let r=e.status===`ready`,i=R(e.key),a=r?`Connected`:`Not connected`;return(0,G.jsx)(m,{asChild:!0,active:t,label:`${i}, ${a}`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-auto w-full items-center gap-2 rounded-[6px] px-[8px] py-2 text-left`,children:[(0,G.jsx)(V,{channelId:e.key,className:`h-4 w-4 shrink-0 text-[color:var(--content-secondary)]`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-default`,children:i}),(0,G.jsx)(`span`,{className:`flex shrink-0 items-center`,children:(0,G.jsx)(S,{tone:r?`positive`:`neutral`,children:a})})]})})}function xe({children:e}){return(0,G.jsxs)(f.Root,{children:[(0,G.jsx)(f.Header,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`img`,{src:F(`/images/integrations/slack.svg`),alt:``,className:`size-8 rounded-lg bg-[var(--surface-sunken)] p-1`}),(0,G.jsx)(d,{as:`span`,variant:`body-medium-default`,children:`Slack setup`})]})}),(0,G.jsx)(f.Body,{children:e})]})}var Y=ie.map(e=>e.riskThreshold),X={none:{label:L(`none`).label,sublabel:`ask before every action`,tone:`negative`},low:{label:L(`low`).label,sublabel:`low-risk actions, ask for the rest`,tone:`warning`},medium:{label:L(`medium`).label,sublabel:`beyond its workspace too`,tone:`info`},high:{label:L(`high`).label,sublabel:`acts freely`,tone:`positive`}},Z=[`trusted_contact`,`unverified_contact`,`unknown`];function Se(e,t){let n={};for(let r of e){if(r.selector.scope!==`channel`||r.selector.adapter!==t)continue;let e=r.selector.channelExternalId;e&&(r.contactType===`trusted_contact`||!(e in n))&&(n[e]=r.threshold)}return n}function Ce(e){return{tier:e??null,overridden:e!==void 0}}function we({channelName:e,settings:t,defaultTier:n,loading:i=!1,error:a=!1,onTierChange:o,onReset:s}){let c=i||a,l=Y.map(e=>({value:e,label:X[e].label,sublabel:X[e].sublabel,disabled:c}));return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 pt-1 pb-4`,children:[t.overridden?(0,G.jsx)(g,{tone:`warning`,title:`Custom access.`,className:`border-dashed`,actions:(0,G.jsx)(r,{type:`button`,variant:`outlined`,onClick:s,disabled:c,children:`Reset to default`}),children:`This channel isn’t following your global Assistant Access setting.`}):null,(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(d,{as:`span`,variant:`body-small-emphasised`,className:`text-[color:var(--content-secondary)]`,children:`Assistant Access`}),i?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:`Loading…`}):a?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-negative)]`,children:`Couldn’t load — try reopening this page`}):t.overridden?(0,G.jsx)(S,{tone:`warning`,children:`overridden`}):(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:`default`})]}),(0,G.jsx)(x,{items:l,value:t.tier??n,onChange:o,ariaLabel:`Assistant Access in ${e}`})]})}var Te={positive:`var(--system-positive-strong)`,negative:`var(--system-negative-strong)`,warning:`var(--system-mid-strong)`,info:`var(--system-info-strong)`,neutral:`var(--content-secondary)`};function Ee(e,t){switch(e){case`none`:return(0,G.jsxs)(G.Fragment,{children:[t,` replies in this channel, but asks you before taking any action.`]});case`low`:return(0,G.jsxs)(G.Fragment,{children:[t,` replies and runs safe, read-only actions on its own, like web searches and reading files in its workspace. Anything that writes, sends, or spends asks you first.`]});case`medium`:return(0,G.jsxs)(G.Fragment,{children:[t,` also handles medium-risk requests on its own, like network requests that use your connected accounts. Anything that writes, sends, or spends still asks you first.`]});case`high`:return(0,G.jsxs)(G.Fragment,{children:[t,` answers any request on its own without asking. Tools that take action — writing, sending, spending — still come to you first.`]})}}function De({assistantName:e}){return(0,G.jsxs)(f.Root,{children:[(0,G.jsx)(f.Header,{children:`Assistant Access levels`}),(0,G.jsx)(f.Body,{className:`grid gap-4 sm:grid-cols-2`,children:Y.map(t=>{let n=X[t];return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 rounded-full`,style:{backgroundColor:Te[n.tone]}}),(0,G.jsx)(d,{as:`span`,variant:`body-small-emphasised`,children:n.label})]}),(0,G.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:Ee(t,e)})]},t)})}),(0,G.jsx)(f.Footer,{children:(0,G.jsxs)(d,{as:`p`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:[`Your`,` `,(0,G.jsx)(a,{to:A.settings.privacy,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`Trust Rules`}),` `,`fine-tune these levels: a rule raises or lowers how risky a specific action is treated, which changes when it asks first.`]})})]})}function Q(e){return e.type===`dm`?`dm`:e.isPrivate?`private`:`public`}function Oe(e){return e.filter(e=>Q(e)!==`dm`)}function ke(e,t,n){let r=t.trim().toLowerCase();return e.filter(e=>(n===null||Q(e)===n)&&(r===``||e.name.toLowerCase().includes(r))).sort((e,t)=>e.name.localeCompare(t.name))}function Ae(e){let t={public:0,private:0,dm:0};for(let n of e)t[Q(n)]+=1;return t}function je(e){return e.memberCount==null?null:e.memberCount===1?`1 member`:`${e.memberCount} members`}var Me=[{value:null,label:`All`},{value:`public`,label:`Public`},{value:`private`,label:`Private`}],Ne={public:z,private:se},Pe=100,Fe=new Set;function Ie({assistantDisplayName:e,slackHandle:t,channels:i,loading:a=!1,error:o=!1,tierOverrides:s,defaultTier:c=null,accessControlsSupported:l=!0,tierOverridesLoading:u=!1,tierOverridesError:p=!1,pendingChannelIds:m=Fe,onTierChange:h,onTierReset:g}){let[_,v]=(0,W.useState)(``),[x,S]=(0,W.useState)(null),[w,T]=(0,W.useState)(new Set),[E,D]=(0,W.useState)(!1),O=e=>{T(t=>{if(E){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}return t.has(e)?new Set:new Set([e])})},k=()=>{E?(D(!1),T(new Set)):(D(!0),T(new Set(A.map(e=>e.id))))},A=(0,W.useMemo)(()=>Oe(i??[]),[i]),j=(0,W.useMemo)(()=>ke(A,_,x),[A,_,x]),M=(0,W.useMemo)(()=>Ae(A),[A]),N=t??`@${e}`,P=(0,G.jsxs)(G.Fragment,{children:[`To add `,e,` to a channel, type`,` `,(0,G.jsxs)(`code`,{className:`text-[color:var(--content-secondary)]`,children:[`/invite `,N]}),` `,`inside that Slack channel.`]});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(f.Root,{children:[(0,G.jsx)(f.Header,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[`Where `,e,` is present`,(0,G.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:P})]})}),(0,G.jsx)(f.Body,{className:`flex flex-col gap-3`,children:a?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:`Loading…`}):o?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-negative)]`,children:`Couldn’t load channels. Try reopening this page.`}):A.length===0?(0,G.jsx)(K,{icon:(0,G.jsx)(z,{className:`h-6 w-6`}),title:`No channels yet`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`min-w-56 flex-1`,children:(0,G.jsx)(C,{type:`search`,value:_,onChange:e=>v(e.target.value),placeholder:`Search channels`,"aria-label":`Search channels`,leftIcon:(0,G.jsx)(I,{className:`h-4 w-4`}),fullWidth:!0})}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,role:`group`,"aria-label":`Filter channels by type`,children:Me.map(({value:e,label:t})=>{let r=x===e,i=e===null?A.length:M[e];return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>S(e),className:n(`inline-flex h-6 items-center rounded-full px-2.5 text-body-small-emphasised leading-none transition-colors`,r?`bg-[var(--content-default)] text-[var(--surface-base)]`:`bg-[var(--tag-bg-neutral)] text-[color:var(--content-secondary)] hover:text-[color:var(--content-default)]`),children:[t,` `,i]},e??`all`)})}),(0,G.jsx)(r,{type:`button`,variant:`outlined`,onClick:k,children:E?`Collapse all`:`Expand all`})]}),j.length===0?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`py-4 text-center text-[color:var(--content-tertiary)]`,children:`No channels match.`}):(0,G.jsx)(b.Root,{type:`multiple`,value:[...w],children:j.length>Pe?(0,G.jsx)(`div`,{className:`h-96`,children:(0,G.jsx)(y,{items:j,computeItemKey:(e,t)=>t.id,itemContent:(e,t)=>(0,G.jsx)($,{channel:t,open:w.has(t.id),onToggle:()=>O(t.id),pending:m.has(t.id),overridesLoading:u,overridesError:p,defaultTier:c,accessControls:l,tierOverride:s?.[t.id],onTierChange:e=>h?.(t.id,e),onReset:()=>g?.(t.id)}),className:`h-full`})}):j.map(e=>(0,G.jsx)($,{channel:e,open:w.has(e.id),onToggle:()=>O(e.id),pending:m.has(e.id),overridesLoading:u,overridesError:p,defaultTier:c,accessControls:l,tierOverride:s?.[e.id],onTierChange:t=>h?.(e.id,t),onReset:()=>g?.(e.id)},e.id))})]})}),!a&&!o&&A.length>0?(0,G.jsx)(f.Footer,{children:(0,G.jsxs)(d,{as:`p`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:[`Only showing channels `,e,` is in. To remove`,` `,e,` from a channel, use`,` `,(0,G.jsxs)(`code`,{className:`text-[color:var(--content-secondary)]`,children:[`/remove `,N]}),` `,`in that Slack channel.`]})}):null]}),l&&!a&&!o&&A.length>0?(0,G.jsx)(De,{assistantName:e}):null]})}function $({channel:e,open:t,pending:r,overridesLoading:i,overridesError:a,defaultTier:o,accessControls:s,tierOverride:c,onToggle:l,onTierChange:u,onReset:d}){let f=Q(e);if(f===`dm`)return null;let m=Ne[f],g=je(e),_=Ce(c),v=_.tier===null?null:X[_.tier],y=o===null?null:X[o];return s?(0,G.jsxs)(b.Item,{value:e.id,className:`[&+&]:border-t [&+&]:border-[var(--border-base)]`,children:[(0,G.jsx)(h,{leading:(0,G.jsx)(m,{className:`h-4 w-4 text-[var(--content-tertiary)]`}),title:e.name,onClick:l,contentAriaLabel:`${e.name} — ${t?`collapse`:`expand`} channel settings`,showChevron:!1,selected:t,trailing:(0,G.jsxs)(G.Fragment,{children:[r?(0,G.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:`Saving…`}):g==null?null:(0,G.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:g}),v===null?(0,G.jsx)(S,{children:y===null?`Default`:`${y.label} • default`}):(0,G.jsxs)(S,{tone:v.tone,children:[v.label,` • custom`]}),(0,G.jsx)(p,{"aria-hidden":`true`,className:n(`h-4 w-4 text-[var(--content-tertiary)] transition-transform`,t&&`rotate-180`)})]})}),(0,G.jsx)(b.Content,{children:(0,G.jsx)(we,{channelName:e.name,settings:_,defaultTier:o,loading:i,error:a,onTierChange:u,onReset:d})})]}):(0,G.jsx)(h,{leading:(0,G.jsx)(m,{className:`h-4 w-4 text-[var(--content-tertiary)]`}),title:e.name,trailing:g==null?void 0:(0,G.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:g})})}var Le=`0.10.7`;function Re(){return k(Le)}function ze(e,t,n){return Z.map(r=>({selector:{scope:`channel`,adapter:e,channelExternalId:t},contactType:r,threshold:n}))}function Be(e,t,n){return e.selector.scope===`channel`&&e.selector.adapter===t&&e.selector.channelExternalId===n}function Ve({assistantId:e,adapter:t}){let n=s(),r=P.use.channelTrustFloors(),i=Re(),a=r&&i&&!!e,o=(0,W.useMemo)(()=>({path:{assistant_id:e}}),[e]),u=(0,W.useMemo)(()=>oe(o),[o]),d=c({...ce(o),enabled:a,select:e=>Se(e.cells,t)}),f=c({queryKey:[`channel-permission-resolve`,e,t],queryFn:async()=>{let{data:e}=await M({...o,body:{adapter:t,contactType:`trusted_contact`},throwOnError:!0});return e.resolved?.threshold??null},enabled:a,retry:!1,staleTime:3e4}),p=(e,r)=>{let i=n.getQueryData(u),a=Date.now();return n.setQueryData(u,n=>({cells:[...(n?.cells??[]).filter(n=>!Be(n,t,e)),...r.map(e=>({...e,updatedAt:a}))]})),{previous:i}},m=l({mutationFn:async({channelExternalId:e,tier:n})=>{await Promise.all(ze(t,e,n).map(e=>j({...o,body:e,throwOnError:!0})))},onMutate:({channelExternalId:e,tier:n})=>p(e,ze(t,e,n)),onError:(e,t,r)=>{n.setQueryData(u,r?.previous),U(`Failed to save channel settings`)(e)},onSettled:()=>n.invalidateQueries({queryKey:u})}),h=l({mutationFn:async({channelExternalId:e})=>{await Promise.all(Z.map(n=>N({...o,body:{selector:{scope:`channel`,adapter:t,channelExternalId:e},contactType:n},throwOnError:!0})))},onMutate:({channelExternalId:e})=>p(e,[]),onError:(e,t,r)=>{n.setQueryData(u,r?.previous),U(`Failed to reset channel settings`)(e)},onSettled:()=>n.invalidateQueries({queryKey:u})}),g=(0,W.useMemo)(()=>{let e=new Set;return m.isPending&&m.variables&&e.add(m.variables.channelExternalId),h.isPending&&h.variables&&e.add(h.variables.channelExternalId),e},[m.isPending,m.variables,h.isPending,h.variables]);return a?{supported:!0,tierOverrides:d.data,defaultCellTier:f.data,pendingChannelIds:g,isLoading:d.isPending,isError:d.isError,onTierChange:(e,t)=>m.mutate({channelExternalId:e,tier:t}),onTierReset:e=>{d.data?.[e]!==void 0&&h.mutate({channelExternalId:e})}}:{supported:!1,tierOverrides:void 0,defaultCellTier:void 0,pendingChannelIds:new Set,isLoading:!1,isError:!1,onTierChange:void 0,onTierReset:void 0}}function He({assistantId:e,assistantDisplayName:t,slackHandle:n}){let r=c({...ae(e),enabled:!!e,select:e=>e.channels}),i=Ve({assistantId:e,adapter:`slack`}),a=c({queryKey:[`thresholds`,e],queryFn:()=>ne(e),enabled:i.supported&&!!e,staleTime:3e4}).data?.interactive??null,o=i.defaultCellTier===void 0?null:i.defaultCellTier??a;return(0,G.jsx)(Ie,{assistantDisplayName:t,slackHandle:n,accessControlsSupported:i.supported,defaultTier:o,channels:r.data,loading:r.isPending,error:r.isError,tierOverrides:i.tierOverrides,tierOverridesLoading:i.isLoading,tierOverridesError:i.isError,pendingChannelIds:i.pendingChannelIds,onTierChange:i.onTierChange,onTierReset:i.onTierReset})}function Ue({slackHandle:e,disconnectPending:t=!1,onDisconnect:n,children:i}){return(0,G.jsxs)(f.Root,{children:[(0,G.jsx)(f.Header,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`img`,{src:F(`/images/integrations/slack.svg`),alt:``,className:`size-8 rounded-lg bg-[var(--surface-sunken)] p-1`}),e?(0,G.jsx)(d,{as:`span`,variant:`body-medium-default`,children:e}):null,(0,G.jsx)(S,{tone:`positive`,leftIcon:(0,G.jsx)(B,{}),children:`Connected`}),(0,G.jsx)(`div`,{className:`ml-auto`,children:(0,G.jsx)(r,{type:`button`,variant:`ghost`,onClick:n,disabled:!n||t,children:t?`Disconnecting…`:`Disconnect`})})]})}),(0,G.jsx)(f.Body,{children:i})]})}function We({threadMode:e,threadModePending:t=!1,onThreadModeChange:n}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(d,{as:`span`,variant:`body-small-emphasised`,className:`text-[color:var(--content-secondary)]`,children:`Thread Behavior`}),(0,G.jsxs)(v,{value:e??`mention_then_thread`,onValueChange:e=>n?.(e),disabled:t||!n,"aria-label":`Slack thread behavior`,children:[(0,G.jsx)(_,{value:`mention_only`,label:`Mentions only`,helperText:`Bot only responds when @mentioned.`}),(0,G.jsx)(_,{value:`mention_then_thread`,label:`Follow threads after first mention`,helperText:`After an @mention in a thread, bot listens to all subsequent replies.`})]})]})}var Ge={no_one:{title:`Block all messages?`,message:`Setting this channel to “No one” hard-denies every inbound message — including messages from you.
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{P as n,t as r}from"./button-BQVYX8n_.js";import{m as i,t 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"./useMutation-Lj4VunQV.js";import{t as u}from"./jsx-runtime-CVSDxk6A.js";import{t as d}from"./typography-Cqi8q9o7.js";import{t as f}from"./card-D8zyWtZh.js";import{t as p}from"./chevron-down-DpYf9Gwq.js";import{t as m}from"./panel-item-An-BBeyL.js";import{t as h}from"./list-row-CFyYr-FU.js";import{t as g}from"./notice-DkAWz47A.js";import{M as _,N as v,a as y,i as b,j as x}from"./src-CheJrlfT.js";import{t as S}from"./tag-B6WeUtBW.js";import{t as C}from"./input-ZpyYt_a0.js";import{t as w}from"./confirm-dialog-Zyfei9GV.js";import{t as T}from"./dropdown-BxYrCXBS.js";import{n as E,t as D}from"./create-selectors-8NePGNlX.js";import{t as O}from"./assistant-identity-store-CgJwLRMd.js";import{r as k}from"./utils-DvUW9GK8.js";import{c as A}from"./routes-Cwb-U9H-.js";import{i as j,o as M,r as N}from"./sdk.gen-BhtkuoSl.js";import{t as P}from"./assistant-feature-flag-store-aNAjw1qx.js";import{t as F}from"./public-asset-Cr86Gucv.js";import{Bo as I,D as ee,F as L,Ft as te,I as ne,Oa as re,P as ie,T as ae,bn as R,da as oe,ds as z,ks as B,ns as se,ua as ce,yn as V}from"./index-2np2R8qP.js";import{t as le}from"./use-active-assistant-id-DwLFgABu.js";import{a as ue,c as de,d as H,l as fe,n as pe,o as me,t as he,u as ge}from"./use-invite-link-dialog-BsdPKDQ_.js";import{t as _e}from"./detail-card-CIh4dCKt.js";import{n as ve,t as ye}from"./mobile-sidebar-drawer-ZUf-00kg.js";import{t as U}from"./mutation-error-C9sr8Rue.js";var W=e(t(),1),G=u();function K({icon:e,title:t,description:r,action:i,className:a}){return(0,G.jsxs)(`div`,{className:n(`flex flex-col items-center justify-center gap-3 px-4 py-12 text-center`,a),children:[e?(0,G.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-xl bg-[var(--surface-sunken)] text-[var(--content-tertiary)]`,children:e}):null,(0,G.jsx)(`h3`,{className:`text-title-small text-[var(--content-default)]`,children:t}),r?(0,G.jsx)(`p`,{className:`max-w-md text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:r}):null,i?(0,G.jsx)(`div`,{className:`mt-1`,children:i}):null]})}var q=D(E()(e=>({selectedAdapter:`slack`,selectAdapter:t=>e({selectedAdapter:t})})));function J({channels:e,selectedKey:t,onSelect:n}){return(0,G.jsx)(f.Root,{className:`flex h-full flex-col overflow-hidden`,children:(0,G.jsxs)(f.Body,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,G.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:`Channels`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,G.jsx)(be,{channel:e,selected:e.key===t,onClick:()=>n(e.key)},e.key))})]})})}function be({channel:e,selected:t,onClick:n}){let r=e.status===`ready`,i=R(e.key),a=r?`Connected`:`Not connected`;return(0,G.jsx)(m,{asChild:!0,active:t,label:`${i}, ${a}`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-auto w-full items-center gap-2 rounded-[6px] px-[8px] py-2 text-left`,children:[(0,G.jsx)(V,{channelId:e.key,className:`h-4 w-4 shrink-0 text-[color:var(--content-secondary)]`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-default`,children:i}),(0,G.jsx)(`span`,{className:`flex shrink-0 items-center`,children:(0,G.jsx)(S,{tone:r?`positive`:`neutral`,children:a})})]})})}function xe({children:e}){return(0,G.jsxs)(f.Root,{children:[(0,G.jsx)(f.Header,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`img`,{src:F(`/images/integrations/slack.svg`),alt:``,className:`size-8 rounded-lg bg-[var(--surface-sunken)] p-1`}),(0,G.jsx)(d,{as:`span`,variant:`body-medium-default`,children:`Slack setup`})]})}),(0,G.jsx)(f.Body,{children:e})]})}var Y=ie.map(e=>e.riskThreshold),X={none:{label:L(`none`).label,sublabel:`ask before every action`,tone:`negative`},low:{label:L(`low`).label,sublabel:`low-risk actions, ask for the rest`,tone:`warning`},medium:{label:L(`medium`).label,sublabel:`beyond its workspace too`,tone:`info`},high:{label:L(`high`).label,sublabel:`acts freely`,tone:`positive`}},Z=[`trusted_contact`,`unverified_contact`,`unknown`];function Se(e,t){let n={};for(let r of e){if(r.selector.scope!==`channel`||r.selector.adapter!==t)continue;let e=r.selector.channelExternalId;e&&(r.contactType===`trusted_contact`||!(e in n))&&(n[e]=r.threshold)}return n}function Ce(e){return{tier:e??null,overridden:e!==void 0}}function we({channelName:e,settings:t,defaultTier:n,loading:i=!1,error:a=!1,onTierChange:o,onReset:s}){let c=i||a,l=Y.map(e=>({value:e,label:X[e].label,sublabel:X[e].sublabel,disabled:c}));return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 pt-1 pb-4`,children:[t.overridden?(0,G.jsx)(g,{tone:`warning`,title:`Custom access.`,className:`border-dashed`,actions:(0,G.jsx)(r,{type:`button`,variant:`outlined`,onClick:s,disabled:c,children:`Reset to default`}),children:`This channel isn’t following your global Assistant Access setting.`}):null,(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(d,{as:`span`,variant:`body-small-emphasised`,className:`text-[color:var(--content-secondary)]`,children:`Assistant Access`}),i?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:`Loading…`}):a?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-negative)]`,children:`Couldn’t load — try reopening this page`}):t.overridden?(0,G.jsx)(S,{tone:`warning`,children:`overridden`}):(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:`default`})]}),(0,G.jsx)(x,{items:l,value:t.tier??n,onChange:o,ariaLabel:`Assistant Access in ${e}`})]})}var Te={positive:`var(--system-positive-strong)`,negative:`var(--system-negative-strong)`,warning:`var(--system-mid-strong)`,info:`var(--system-info-strong)`,neutral:`var(--content-secondary)`};function Ee(e,t){switch(e){case`none`:return(0,G.jsxs)(G.Fragment,{children:[t,` replies in this channel, but asks you before taking any action.`]});case`low`:return(0,G.jsxs)(G.Fragment,{children:[t,` replies and runs safe, read-only actions on its own, like web searches and reading files in its workspace. Anything that writes, sends, or spends asks you first.`]});case`medium`:return(0,G.jsxs)(G.Fragment,{children:[t,` also handles medium-risk requests on its own, like network requests that use your connected accounts. Anything that writes, sends, or spends still asks you first.`]});case`high`:return(0,G.jsxs)(G.Fragment,{children:[t,` answers any request on its own without asking. Tools that take action — writing, sending, spending — still come to you first.`]})}}function De({assistantName:e}){return(0,G.jsxs)(f.Root,{children:[(0,G.jsx)(f.Header,{children:`Assistant Access levels`}),(0,G.jsx)(f.Body,{className:`grid gap-4 sm:grid-cols-2`,children:Y.map(t=>{let n=X[t];return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 rounded-full`,style:{backgroundColor:Te[n.tone]}}),(0,G.jsx)(d,{as:`span`,variant:`body-small-emphasised`,children:n.label})]}),(0,G.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:Ee(t,e)})]},t)})}),(0,G.jsx)(f.Footer,{children:(0,G.jsxs)(d,{as:`p`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:[`Your`,` `,(0,G.jsx)(a,{to:A.settings.privacy,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`Trust Rules`}),` `,`fine-tune these levels: a rule raises or lowers how risky a specific action is treated, which changes when it asks first.`]})})]})}function Q(e){return e.type===`dm`?`dm`:e.isPrivate?`private`:`public`}function Oe(e){return e.filter(e=>Q(e)!==`dm`)}function ke(e,t,n){let r=t.trim().toLowerCase();return e.filter(e=>(n===null||Q(e)===n)&&(r===``||e.name.toLowerCase().includes(r))).sort((e,t)=>e.name.localeCompare(t.name))}function Ae(e){let t={public:0,private:0,dm:0};for(let n of e)t[Q(n)]+=1;return t}function je(e){return e.memberCount==null?null:e.memberCount===1?`1 member`:`${e.memberCount} members`}var Me=[{value:null,label:`All`},{value:`public`,label:`Public`},{value:`private`,label:`Private`}],Ne={public:z,private:se},Pe=100,Fe=new Set;function Ie({assistantDisplayName:e,slackHandle:t,channels:i,loading:a=!1,error:o=!1,tierOverrides:s,defaultTier:c=null,accessControlsSupported:l=!0,tierOverridesLoading:u=!1,tierOverridesError:p=!1,pendingChannelIds:m=Fe,onTierChange:h,onTierReset:g}){let[_,v]=(0,W.useState)(``),[x,S]=(0,W.useState)(null),[w,T]=(0,W.useState)(new Set),[E,D]=(0,W.useState)(!1),O=e=>{T(t=>{if(E){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}return t.has(e)?new Set:new Set([e])})},k=()=>{E?(D(!1),T(new Set)):(D(!0),T(new Set(A.map(e=>e.id))))},A=(0,W.useMemo)(()=>Oe(i??[]),[i]),j=(0,W.useMemo)(()=>ke(A,_,x),[A,_,x]),M=(0,W.useMemo)(()=>Ae(A),[A]),N=t??`@${e}`,P=(0,G.jsxs)(G.Fragment,{children:[`To add `,e,` to a channel, type`,` `,(0,G.jsxs)(`code`,{className:`text-[color:var(--content-secondary)]`,children:[`/invite `,N]}),` `,`inside that Slack channel.`]});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(f.Root,{children:[(0,G.jsx)(f.Header,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[`Where `,e,` is present`,(0,G.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:P})]})}),(0,G.jsx)(f.Body,{className:`flex flex-col gap-3`,children:a?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:`Loading…`}):o?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`text-[color:var(--content-negative)]`,children:`Couldn’t load channels. Try reopening this page.`}):A.length===0?(0,G.jsx)(K,{icon:(0,G.jsx)(z,{className:`h-6 w-6`}),title:`No channels yet`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`min-w-56 flex-1`,children:(0,G.jsx)(C,{type:`search`,value:_,onChange:e=>v(e.target.value),placeholder:`Search channels`,"aria-label":`Search channels`,leftIcon:(0,G.jsx)(I,{className:`h-4 w-4`}),fullWidth:!0})}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,role:`group`,"aria-label":`Filter channels by type`,children:Me.map(({value:e,label:t})=>{let r=x===e,i=e===null?A.length:M[e];return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>S(e),className:n(`inline-flex h-6 items-center rounded-full px-2.5 text-body-small-emphasised leading-none transition-colors`,r?`bg-[var(--content-default)] text-[var(--surface-base)]`:`bg-[var(--tag-bg-neutral)] text-[color:var(--content-secondary)] hover:text-[color:var(--content-default)]`),children:[t,` `,i]},e??`all`)})}),(0,G.jsx)(r,{type:`button`,variant:`outlined`,onClick:k,children:E?`Collapse all`:`Expand all`})]}),j.length===0?(0,G.jsx)(d,{as:`span`,variant:`body-small-default`,className:`py-4 text-center text-[color:var(--content-tertiary)]`,children:`No channels match.`}):(0,G.jsx)(b.Root,{type:`multiple`,value:[...w],children:j.length>Pe?(0,G.jsx)(`div`,{className:`h-96`,children:(0,G.jsx)(y,{items:j,computeItemKey:(e,t)=>t.id,itemContent:(e,t)=>(0,G.jsx)($,{channel:t,open:w.has(t.id),onToggle:()=>O(t.id),pending:m.has(t.id),overridesLoading:u,overridesError:p,defaultTier:c,accessControls:l,tierOverride:s?.[t.id],onTierChange:e=>h?.(t.id,e),onReset:()=>g?.(t.id)}),className:`h-full`})}):j.map(e=>(0,G.jsx)($,{channel:e,open:w.has(e.id),onToggle:()=>O(e.id),pending:m.has(e.id),overridesLoading:u,overridesError:p,defaultTier:c,accessControls:l,tierOverride:s?.[e.id],onTierChange:t=>h?.(e.id,t),onReset:()=>g?.(e.id)},e.id))})]})}),!a&&!o&&A.length>0?(0,G.jsx)(f.Footer,{children:(0,G.jsxs)(d,{as:`p`,variant:`body-small-default`,className:`text-[color:var(--content-tertiary)]`,children:[`Only showing channels `,e,` is in. To remove`,` `,e,` from a channel, use`,` `,(0,G.jsxs)(`code`,{className:`text-[color:var(--content-secondary)]`,children:[`/remove `,N]}),` `,`in that Slack channel.`]})}):null]}),l&&!a&&!o&&A.length>0?(0,G.jsx)(De,{assistantName:e}):null]})}function $({channel:e,open:t,pending:r,overridesLoading:i,overridesError:a,defaultTier:o,accessControls:s,tierOverride:c,onToggle:l,onTierChange:u,onReset:d}){let f=Q(e);if(f===`dm`)return null;let m=Ne[f],g=je(e),_=Ce(c),v=_.tier===null?null:X[_.tier],y=o===null?null:X[o];return s?(0,G.jsxs)(b.Item,{value:e.id,className:`[&+&]:border-t [&+&]:border-[var(--border-base)]`,children:[(0,G.jsx)(h,{leading:(0,G.jsx)(m,{className:`h-4 w-4 text-[var(--content-tertiary)]`}),title:e.name,onClick:l,contentAriaLabel:`${e.name} — ${t?`collapse`:`expand`} channel settings`,showChevron:!1,selected:t,trailing:(0,G.jsxs)(G.Fragment,{children:[r?(0,G.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:`Saving…`}):g==null?null:(0,G.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:g}),v===null?(0,G.jsx)(S,{children:y===null?`Default`:`${y.label} • default`}):(0,G.jsxs)(S,{tone:v.tone,children:[v.label,` • custom`]}),(0,G.jsx)(p,{"aria-hidden":`true`,className:n(`h-4 w-4 text-[var(--content-tertiary)] transition-transform`,t&&`rotate-180`)})]})}),(0,G.jsx)(b.Content,{children:(0,G.jsx)(we,{channelName:e.name,settings:_,defaultTier:o,loading:i,error:a,onTierChange:u,onReset:d})})]}):(0,G.jsx)(h,{leading:(0,G.jsx)(m,{className:`h-4 w-4 text-[var(--content-tertiary)]`}),title:e.name,trailing:g==null?void 0:(0,G.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:g})})}var Le=`0.10.7`;function Re(){return k(Le)}function ze(e,t,n){return Z.map(r=>({selector:{scope:`channel`,adapter:e,channelExternalId:t},contactType:r,threshold:n}))}function Be(e,t,n){return e.selector.scope===`channel`&&e.selector.adapter===t&&e.selector.channelExternalId===n}function Ve({assistantId:e,adapter:t}){let n=s(),r=P.use.channelTrustFloors(),i=Re(),a=r&&i&&!!e,o=(0,W.useMemo)(()=>({path:{assistant_id:e}}),[e]),u=(0,W.useMemo)(()=>oe(o),[o]),d=c({...ce(o),enabled:a,select:e=>Se(e.cells,t)}),f=c({queryKey:[`channel-permission-resolve`,e,t],queryFn:async()=>{let{data:e}=await M({...o,body:{adapter:t,contactType:`trusted_contact`},throwOnError:!0});return e.resolved?.threshold??null},enabled:a,retry:!1,staleTime:3e4}),p=(e,r)=>{let i=n.getQueryData(u),a=Date.now();return n.setQueryData(u,n=>({cells:[...(n?.cells??[]).filter(n=>!Be(n,t,e)),...r.map(e=>({...e,updatedAt:a}))]})),{previous:i}},m=l({mutationFn:async({channelExternalId:e,tier:n})=>{await Promise.all(ze(t,e,n).map(e=>j({...o,body:e,throwOnError:!0})))},onMutate:({channelExternalId:e,tier:n})=>p(e,ze(t,e,n)),onError:(e,t,r)=>{n.setQueryData(u,r?.previous),U(`Failed to save channel settings`)(e)},onSettled:()=>n.invalidateQueries({queryKey:u})}),h=l({mutationFn:async({channelExternalId:e})=>{await Promise.all(Z.map(n=>N({...o,body:{selector:{scope:`channel`,adapter:t,channelExternalId:e},contactType:n},throwOnError:!0})))},onMutate:({channelExternalId:e})=>p(e,[]),onError:(e,t,r)=>{n.setQueryData(u,r?.previous),U(`Failed to reset channel settings`)(e)},onSettled:()=>n.invalidateQueries({queryKey:u})}),g=(0,W.useMemo)(()=>{let e=new Set;return m.isPending&&m.variables&&e.add(m.variables.channelExternalId),h.isPending&&h.variables&&e.add(h.variables.channelExternalId),e},[m.isPending,m.variables,h.isPending,h.variables]);return a?{supported:!0,tierOverrides:d.data,defaultCellTier:f.data,pendingChannelIds:g,isLoading:d.isPending,isError:d.isError,onTierChange:(e,t)=>m.mutate({channelExternalId:e,tier:t}),onTierReset:e=>{d.data?.[e]!==void 0&&h.mutate({channelExternalId:e})}}:{supported:!1,tierOverrides:void 0,defaultCellTier:void 0,pendingChannelIds:new Set,isLoading:!1,isError:!1,onTierChange:void 0,onTierReset:void 0}}function He({assistantId:e,assistantDisplayName:t,slackHandle:n}){let r=c({...ae(e),enabled:!!e,select:e=>e.channels}),i=Ve({assistantId:e,adapter:`slack`}),a=c({queryKey:[`thresholds`,e],queryFn:()=>ne(e),enabled:i.supported&&!!e,staleTime:3e4}).data?.interactive??null,o=i.defaultCellTier===void 0?null:i.defaultCellTier??a;return(0,G.jsx)(Ie,{assistantDisplayName:t,slackHandle:n,accessControlsSupported:i.supported,defaultTier:o,channels:r.data,loading:r.isPending,error:r.isError,tierOverrides:i.tierOverrides,tierOverridesLoading:i.isLoading,tierOverridesError:i.isError,pendingChannelIds:i.pendingChannelIds,onTierChange:i.onTierChange,onTierReset:i.onTierReset})}function Ue({slackHandle:e,disconnectPending:t=!1,onDisconnect:n,children:i}){return(0,G.jsxs)(f.Root,{children:[(0,G.jsx)(f.Header,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`img`,{src:F(`/images/integrations/slack.svg`),alt:``,className:`size-8 rounded-lg bg-[var(--surface-sunken)] p-1`}),e?(0,G.jsx)(d,{as:`span`,variant:`body-medium-default`,children:e}):null,(0,G.jsx)(S,{tone:`positive`,leftIcon:(0,G.jsx)(B,{}),children:`Connected`}),(0,G.jsx)(`div`,{className:`ml-auto`,children:(0,G.jsx)(r,{type:`button`,variant:`ghost`,onClick:n,disabled:!n||t,children:t?`Disconnecting…`:`Disconnect`})})]})}),(0,G.jsx)(f.Body,{children:i})]})}function We({threadMode:e,threadModePending:t=!1,onThreadModeChange:n}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(d,{as:`span`,variant:`body-small-emphasised`,className:`text-[color:var(--content-secondary)]`,children:`Thread Behavior`}),(0,G.jsxs)(v,{value:e??`mention_then_thread`,onValueChange:e=>n?.(e),disabled:t||!n,"aria-label":`Slack thread behavior`,children:[(0,G.jsx)(_,{value:`mention_only`,label:`Mentions only`,helperText:`Bot only responds when @mentioned.`}),(0,G.jsx)(_,{value:`mention_then_thread`,label:`Follow threads after first mention`,helperText:`After an @mention in a thread, bot listens to all subsequent replies.`})]})]})}var Ge={no_one:{title:`Block all messages?`,message:`Setting this channel to “No one” hard-denies every inbound message — including messages from you.
2
2
 
3
3
  You can reverse this at any time.`,confirmLabel:`Block all`,destructive:!0},any_contact:{title:`Allow any contact?`,message:`“Any contact” admits every matched contact in this channel — including pending, unverified ones — not just your verified contacts.
4
4
 
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n,z as r}from"./button-BQVYX8n_.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-Cqi8q9o7.js";import{t as o}from"./panel-item-An-BBeyL.js";import{t as s}from"./loader-circle-Ck8fq3yv.js";import{t as c}from"./x-CswtfvgS.js";import"./src-CheJrlfT.js";import{Bo as l,Ea as u}from"./index-D7_9Qy0L.js";var d=e(t(),1),f=e(r(),1),p=i();function m({icon:e,title:t,subtitle:n,shortcutHint:r,isSelected:i,onClick:a,surface:s=`overlay`}){let c=e;return s===`window`?(0,p.jsxs)(`button`,{type:`button`,role:`option`,"aria-current":i?`page`:void 0,"aria-selected":i,onClick:a,className:[`flex h-10 w-full items-center gap-3 rounded-md px-3 text-left text-sm font-medium outline-none transition-colors`,i?`bg-[var(--surface-active)] text-[var(--content-default)]`:`text-[var(--content-secondary)] hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`].join(` `),children:[c?(0,p.jsx)(c,{size:16,"aria-hidden":!0,className:i?`shrink-0 text-[var(--content-default)]`:`shrink-0 text-[var(--content-tertiary)]`}):null,(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-xs text-[var(--content-tertiary)]`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-[var(--content-tertiary)]`,children:r}):null]})]}):(0,p.jsx)(o,{icon:e,label:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-[var(--content-tertiary)] text-body-small-default`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-[var(--content-tertiary)] text-body-small-default`,children:r}):null]}),active:i,onSelect:a,className:`px-3 py-2`})}var h=({isOpen:e,onClose:t,query:r,onQueryChange:i,selectedIndex:o,sections:h,isSearching:g=!1,onItemSelect:_,onKeyDown:v,surface:y=`overlay`})=>{let b=u(),x=(0,d.useRef)(null),S=(0,d.useRef)(null),C=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{S.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,d.useEffect)(()=>{if(!e||!C.current)return;let t=C.current.querySelector(`[aria-current='page']`);t&&t.scrollIntoView({block:`nearest`})},[e,o]);let w=(0,d.useCallback)(e=>{e.target===x.current&&t()},[t]);if(!e)return null;let T=0,E=y===`window`,D=b&&!E,O=(0,p.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-base)] px-4 py-3`,children:[g?(0,p.jsx)(s,{size:16,"aria-hidden":!0,className:`shrink-0 animate-spin text-[var(--content-tertiary)]`}):(0,p.jsx)(l,{size:16,"aria-hidden":!0,className:`shrink-0 text-[var(--content-tertiary)]`}),(0,p.jsx)(`input`,{ref:S,type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search conversations, memories…`,className:E?`min-w-0 flex-1 bg-transparent text-sm font-medium text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`:`min-w-0 flex-1 bg-transparent text-body-medium-lighter text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`,"aria-label":`Search`}),r?D?(0,p.jsx)(`button`,{type:`button`,className:`shrink-0 text-body-medium-lighter text-[var(--content-tertiary)]`,onClick:()=>i(``),"aria-label":`Clear search`,children:`Clear`}):E?(0,p.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`,"aria-label":`Clear search`,onClick:()=>i(``),children:(0,p.jsx)(c,{size:16,"aria-hidden":!0})}):(0,p.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),"aria-label":`Clear search`,onClick:()=>i(``),tintColor:`var(--content-tertiary)`}):D?null:(0,p.jsx)(`kbd`,{className:E?`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-xs font-medium text-[var(--content-secondary)]`:`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-label-small-default text-[var(--content-tertiary)]`,children:`⌘K`}),D?(0,p.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),expandOnMobile:!1,"aria-label":`Close search`,onClick:t,tintColor:`var(--content-tertiary)`}):null]}),k=(0,p.jsx)(`div`,{ref:C,className:D?`flex-1 overflow-y-auto overscroll-contain p-2`:`max-h-[360px] overflow-y-auto overscroll-contain p-2`,role:`listbox`,children:h.length===0?(0,p.jsx)(`div`,{className:`px-3 py-6 text-center`,children:(0,p.jsx)(a,{variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,children:g?`Searching…`:`No results`})}):h.map(e=>(0,p.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,p.jsx)(a,{variant:`label-small-default`,as:`div`,className:E?`px-3 pb-1 pt-2 text-xs font-semibold text-[var(--content-tertiary)]`:`px-3 pb-1 pt-2 text-[var(--content-tertiary)] max-md:text-body-small-default`,children:e.label}),e.items.map(e=>{let t=T++;return(0,p.jsx)(m,{icon:e.icon,title:e.title,subtitle:e.subtitle,shortcutHint:D?void 0:e.shortcutHint,isSelected:t===o,onClick:()=>_?.(e,t),surface:y},e.id)})]},e.id))});if(D)return(0,p.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-[var(--surface-lift)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Search`,onKeyDown:v,style:{paddingTop:`var(--safe-area-inset-top, env(safe-area-inset-top, 0px))`,paddingBottom:`var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))`,paddingLeft:`var(--safe-area-inset-left, env(safe-area-inset-left, 0px))`,paddingRight:`var(--safe-area-inset-right, env(safe-area-inset-right, 0px))`},children:[O,k]});let A=(0,p.jsx)(`div`,{ref:x,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:y===`window`?`flex h-full w-full items-start justify-center bg-transparent p-3`:`fixed inset-0 z-50 flex items-start justify-center bg-black/40 pt-[15vh]`,onClick:w,onKeyDown:v,children:(0,p.jsxs)(`div`,{className:`flex w-full max-w-[560px] flex-col overflow-hidden rounded-xl border border-[var(--border-base)] bg-[var(--surface-base)] shadow-xl`,children:[O,k]})});return y===`window`?A:(0,f.createPortal)(A,document.body)};export{h as CommandPalette};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n,z as r}from"./button-BQVYX8n_.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-Cqi8q9o7.js";import{t as o}from"./panel-item-An-BBeyL.js";import{t as s}from"./loader-circle-Ck8fq3yv.js";import{t as c}from"./x-CswtfvgS.js";import"./src-CheJrlfT.js";import{Bo as l,Ea as u}from"./index-2np2R8qP.js";var d=e(t(),1),f=e(r(),1),p=i();function m({icon:e,title:t,subtitle:n,shortcutHint:r,isSelected:i,onClick:a,surface:s=`overlay`}){let c=e;return s===`window`?(0,p.jsxs)(`button`,{type:`button`,role:`option`,"aria-current":i?`page`:void 0,"aria-selected":i,onClick:a,className:[`flex h-10 w-full items-center gap-3 rounded-md px-3 text-left text-sm font-medium outline-none transition-colors`,i?`bg-[var(--surface-active)] text-[var(--content-default)]`:`text-[var(--content-secondary)] hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`].join(` `),children:[c?(0,p.jsx)(c,{size:16,"aria-hidden":!0,className:i?`shrink-0 text-[var(--content-default)]`:`shrink-0 text-[var(--content-tertiary)]`}):null,(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-xs text-[var(--content-tertiary)]`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-[var(--content-tertiary)]`,children:r}):null]})]}):(0,p.jsx)(o,{icon:e,label:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-[var(--content-tertiary)] text-body-small-default`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-[var(--content-tertiary)] text-body-small-default`,children:r}):null]}),active:i,onSelect:a,className:`px-3 py-2`})}var h=({isOpen:e,onClose:t,query:r,onQueryChange:i,selectedIndex:o,sections:h,isSearching:g=!1,onItemSelect:_,onKeyDown:v,surface:y=`overlay`})=>{let b=u(),x=(0,d.useRef)(null),S=(0,d.useRef)(null),C=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{S.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,d.useEffect)(()=>{if(!e||!C.current)return;let t=C.current.querySelector(`[aria-current='page']`);t&&t.scrollIntoView({block:`nearest`})},[e,o]);let w=(0,d.useCallback)(e=>{e.target===x.current&&t()},[t]);if(!e)return null;let T=0,E=y===`window`,D=b&&!E,O=(0,p.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-base)] px-4 py-3`,children:[g?(0,p.jsx)(s,{size:16,"aria-hidden":!0,className:`shrink-0 animate-spin text-[var(--content-tertiary)]`}):(0,p.jsx)(l,{size:16,"aria-hidden":!0,className:`shrink-0 text-[var(--content-tertiary)]`}),(0,p.jsx)(`input`,{ref:S,type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search conversations, memories…`,className:E?`min-w-0 flex-1 bg-transparent text-sm font-medium text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`:`min-w-0 flex-1 bg-transparent text-body-medium-lighter text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`,"aria-label":`Search`}),r?D?(0,p.jsx)(`button`,{type:`button`,className:`shrink-0 text-body-medium-lighter text-[var(--content-tertiary)]`,onClick:()=>i(``),"aria-label":`Clear search`,children:`Clear`}):E?(0,p.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`,"aria-label":`Clear search`,onClick:()=>i(``),children:(0,p.jsx)(c,{size:16,"aria-hidden":!0})}):(0,p.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),"aria-label":`Clear search`,onClick:()=>i(``),tintColor:`var(--content-tertiary)`}):D?null:(0,p.jsx)(`kbd`,{className:E?`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-xs font-medium text-[var(--content-secondary)]`:`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-label-small-default text-[var(--content-tertiary)]`,children:`⌘K`}),D?(0,p.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),expandOnMobile:!1,"aria-label":`Close search`,onClick:t,tintColor:`var(--content-tertiary)`}):null]}),k=(0,p.jsx)(`div`,{ref:C,className:D?`flex-1 overflow-y-auto overscroll-contain p-2`:`max-h-[360px] overflow-y-auto overscroll-contain p-2`,role:`listbox`,children:h.length===0?(0,p.jsx)(`div`,{className:`px-3 py-6 text-center`,children:(0,p.jsx)(a,{variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,children:g?`Searching…`:`No results`})}):h.map(e=>(0,p.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,p.jsx)(a,{variant:`label-small-default`,as:`div`,className:E?`px-3 pb-1 pt-2 text-xs font-semibold text-[var(--content-tertiary)]`:`px-3 pb-1 pt-2 text-[var(--content-tertiary)] max-md:text-body-small-default`,children:e.label}),e.items.map(e=>{let t=T++;return(0,p.jsx)(m,{icon:e.icon,title:e.title,subtitle:e.subtitle,shortcutHint:D?void 0:e.shortcutHint,isSelected:t===o,onClick:()=>_?.(e,t),surface:y},e.id)})]},e.id))});if(D)return(0,p.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-[var(--surface-lift)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Search`,onKeyDown:v,style:{paddingTop:`var(--safe-area-inset-top, env(safe-area-inset-top, 0px))`,paddingBottom:`var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))`,paddingLeft:`var(--safe-area-inset-left, env(safe-area-inset-left, 0px))`,paddingRight:`var(--safe-area-inset-right, env(safe-area-inset-right, 0px))`},children:[O,k]});let A=(0,p.jsx)(`div`,{ref:x,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:y===`window`?`flex h-full w-full items-start justify-center bg-transparent p-3`:`fixed inset-0 z-50 flex items-start justify-center bg-black/40 pt-[15vh]`,onClick:w,onKeyDown:v,children:(0,p.jsxs)(`div`,{className:`flex w-full max-w-[560px] flex-col overflow-hidden rounded-xl border border-[var(--border-base)] bg-[var(--surface-base)] shadow-xl`,children:[O,k]})});return y===`window`?A:(0,f.createPortal)(A,document.body)};export{h as CommandPalette};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{ct as r}from"./local-mode-Dydd46cS.js";import{n as i}from"./resolved-assistants-store-DdHm-7v4.js";import{D as a,O as o,i as s,n as c,s as l}from"./auth-store-B8Es53B9.js";import{t as u}from"./client-feature-flag-store-D85jf9vW.js";import{Gn as d,Kn as f,Ta as p,Tr as m,Yn as h,_n as g,za as _}from"./index-D7_9Qy0L.js";import{CommandPalette as v}from"./command-palette-fZ-DYpTl.js";var y=e(t(),1),b=n(),x=()=>void 0,S=e=>void 0,C=e=>{switch(e.id){case`action-new-conversation`:return{kind:`newConversation`};case`action-current-conversation`:return{kind:`currentConversation`};case`action-settings`:return{kind:`openSettings`};case`action-library`:return{kind:`openLibrary`};case`action-intelligence`:return{kind:`openIdentity`};case`action-back`:return{kind:`navigateBack`};case`action-forward`:return{kind:`navigateForward`};case`action-zoom-in`:return{kind:`zoomIn`};case`action-zoom-out`:return{kind:`zoomOut`};case`action-actual-size`:return{kind:`actualSize`};default:return e.id.startsWith(`conv-`)?{kind:`openConversation`,conversationId:e.id.slice(5)}:e.id.startsWith(`search-conv-`)?{kind:`openConversation`,conversationId:e.id.slice(12)}:e.id.startsWith(`search-schedule-`)||e.id.startsWith(`search-contact-`)?{kind:`openIdentity`}:null}};function w(){let e=c.use.sessionStatus(),t=l(),n=s();_(),m(!t),p({sessionStatus:e,hasPlatformSession:n});let w=i.use.assistants(),T=i.use.activeAssistantId(),E=i.use.selectedAssistantId(),D=a.use.currentOrganizationId(),O=u.use.multiPlatformAssistant(),k=(0,y.useMemo)(()=>{let e=O&&!r()&&D?o(D):T;if(!e)return null;let t=w.find(t=>t.id===e);return t?{id:t.id,name:t.name}:null},[O,T,w,D,E]),A=k?.id??null,{conversations:j}=h(A,!0),M=(0,y.useCallback)(e=>{let t=C(e);t&&f(t)},[]),{commandPalette:N,mergedSections:P,handleItemSelect:F}=g({assistantId:A,assistantName:k?.name,conversations:j,activeConversationId:void 0,startNewConversation:x,switchConversation:x,navigate:S,navigateToSettings:x,isOpen:!0,onClose:()=>{d()},onItemSelect:M});return(0,b.jsx)(`div`,{className:`h-screen w-screen bg-transparent`,children:(0,b.jsx)(v,{isOpen:!0,surface:`window`,onClose:N.close,query:N.query,onQueryChange:N.setQuery,selectedIndex:N.selectedIndex,sections:P,isSearching:N.isSearching,onItemSelect:F,onKeyDown:N.handleKeyDown})})}export{w as CommandPaletteWindowPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{ct as r}from"./local-mode-Dydd46cS.js";import{n as i}from"./resolved-assistants-store-DdHm-7v4.js";import{D as a,O as o,i as s,n as c,s as l}from"./auth-store-B8Es53B9.js";import{t as u}from"./client-feature-flag-store-D85jf9vW.js";import{Gn as d,Kn as f,Ta as p,Tr as m,Yn as h,_n as g,za as _}from"./index-2np2R8qP.js";import{CommandPalette as v}from"./command-palette-BCipBcvn.js";var y=e(t(),1),b=n(),x=()=>void 0,S=e=>void 0,C=e=>{switch(e.id){case`action-new-conversation`:return{kind:`newConversation`};case`action-current-conversation`:return{kind:`currentConversation`};case`action-settings`:return{kind:`openSettings`};case`action-library`:return{kind:`openLibrary`};case`action-intelligence`:return{kind:`openIdentity`};case`action-back`:return{kind:`navigateBack`};case`action-forward`:return{kind:`navigateForward`};case`action-zoom-in`:return{kind:`zoomIn`};case`action-zoom-out`:return{kind:`zoomOut`};case`action-actual-size`:return{kind:`actualSize`};default:return e.id.startsWith(`conv-`)?{kind:`openConversation`,conversationId:e.id.slice(5)}:e.id.startsWith(`search-conv-`)?{kind:`openConversation`,conversationId:e.id.slice(12)}:e.id.startsWith(`search-schedule-`)||e.id.startsWith(`search-contact-`)?{kind:`openIdentity`}:null}};function w(){let e=c.use.sessionStatus(),t=l(),n=s();_(),m(!t),p({sessionStatus:e,hasPlatformSession:n});let w=i.use.assistants(),T=i.use.activeAssistantId(),E=i.use.selectedAssistantId(),D=a.use.currentOrganizationId(),O=u.use.multiPlatformAssistant(),k=(0,y.useMemo)(()=>{let e=O&&!r()&&D?o(D):T;if(!e)return null;let t=w.find(t=>t.id===e);return t?{id:t.id,name:t.name}:null},[O,T,w,D,E]),A=k?.id??null,{conversations:j}=h(A,!0),M=(0,y.useCallback)(e=>{let t=C(e);t&&f(t)},[]),{commandPalette:N,mergedSections:P,handleItemSelect:F}=g({assistantId:A,assistantName:k?.name,conversations:j,activeConversationId:void 0,startNewConversation:x,switchConversation:x,navigate:S,navigateToSettings:x,isOpen:!0,onClose:()=>{d()},onItemSelect:M});return(0,b.jsx)(`div`,{className:`h-screen w-screen bg-transparent`,children:(0,b.jsx)(v,{isOpen:!0,surface:`window`,onClose:N.close,query:N.query,onQueryChange:N.setQuery,selectedIndex:N.selectedIndex,sections:P,isSearching:N.isSearching,onItemSelect:F,onKeyDown:N.handleKeyDown})})}export{w as CommandPaletteWindowPage};
@@ -1 +1 @@
1
- import{t as e}from"./button-BQVYX8n_.js";import{t}from"./jsx-runtime-CVSDxk6A.js";import{t as n}from"./card-D8zyWtZh.js";import{t as r}from"./createLucideIcon-Bjb-Kuq7.js";import{t as i}from"./bug-BMI_6ziD.js";import{t as a}from"./external-link-Cczz6xJ4.js";import{t as o}from"./globe-DgKSh933.js";import{t as s}from"./sparkles-BK3KXCjl.js";import{t as c}from"./users--1gWeHEq.js";import{t as l}from"./tag-B6WeUtBW.js";import{A as u,No as d,O as f,Ps as p,Wo as m,bt as h,k as g,us as _,v}from"./index-D7_9Qy0L.js";var y=r(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),b=t();function x({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function S({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})})}function C({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814ZM9.545 15.568V8.432L15.818 12l-6.273 3.568Z`})})}function w(){return(0,b.jsx)(n,{padding:`lg`,className:`bg-[var(--surface-lift)]`,children:(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`div`,{className:`pointer-events-none absolute -right-16 -top-16 h-64 w-64 rounded-full opacity-30 blur-3xl`,style:{background:`radial-gradient(circle, var(--system-mid-weak) 0%, transparent 70%)`},"aria-hidden":!0}),(0,b.jsxs)(`div`,{className:`relative flex flex-col items-start gap-3`,children:[(0,b.jsxs)(l,{tone:`neutral`,children:[(0,b.jsx)(m,{className:`h-3.5 w-3.5`}),`Community`]}),(0,b.jsx)(`h1`,{className:`text-[28px] font-semibold leading-tight tracking-tight text-[var(--content-emphasised)]`,children:`Build with us, in the open.`}),(0,b.jsx)(`p`,{className:`max-w-xl text-body-medium-default text-[color:var(--content-tertiary)]`,children:`Vellum is built in the open with a growing community of developers, designers, and tinkerers. Here's how to get involved.`})]})]})})}function T({icon:e,text:t}){return(0,b.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)]`,children:(0,b.jsx)(e,{size:14,className:`text-[var(--content-secondary)]`,"aria-hidden":!0})}),(0,b.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]})}function E({accentColor:t,iconColor:r=`var(--aux-white)`,label:i,icon:a,title:o,subtitle:s,benefits:c,primaryAction:l,secondaryAction:u}){return(0,b.jsx)(n,{padding:`lg`,className:`flex-1`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:a}),(0,b.jsx)(`span`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:i})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`h2`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:o}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:s})]}),(0,b.jsx)(`ul`,{className:`flex flex-col gap-3`,children:c.map(({icon:e,text:t})=>(0,b.jsx)(T,{icon:e,text:t},t))}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(e,{onClick:l.onClick,children:[l.icon,l.label]}),u&&(0,b.jsxs)(e,{variant:`ghost`,onClick:()=>window.open(u.href,`_blank`,`noopener,noreferrer`),children:[u.label,(0,b.jsx)(p,{className:`h-3.5 w-3.5`})]})]})]})})}function D({icon:e,iconBg:t,iconColor:r=`white`,title:i,description:o,href:s}){return(0,b.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`flex flex-1 cursor-pointer`,children:(0,b.jsx)(n,{className:`flex-1 transition-shadow hover:shadow-md`,padding:`lg`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:e}),(0,b.jsx)(a,{size:14,className:`text-[var(--content-tertiary)]`,"aria-hidden":!0})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`span`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:i}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:o})]})]})})})}function O(){let{handleStar:e}=u();return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(w,{}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,b.jsx)(E,{accentColor:`var(--content-emphasised)`,iconColor:`var(--surface-base)`,label:`Open Source`,icon:(0,b.jsx)(x,{size:20}),title:`Vellum is open source`,subtitle:`Read the source, star the repo, and contribute fixes and features on GitHub.`,benefits:[{icon:d,text:`Star the repo to follow updates`},{icon:i,text:`Open issues and report bugs`},{icon:y,text:`Contribute fixes and new features`}],primaryAction:{label:`Star on GitHub`,icon:(0,b.jsx)(d,{size:16}),onClick:e},secondaryAction:{label:`View source`,href:g}}),(0,b.jsx)(E,{accentColor:`#5865F2`,label:`Discord`,icon:(0,b.jsx)(h,{size:20}),title:`Join our community`,subtitle:`Talk to the team, share feedback, request features, and get answers faster.`,benefits:[{icon:_,text:`Talk directly with the team`},{icon:s,text:`Share feedback and request features`},{icon:c,text:`Get answers faster from the community`}],primaryAction:{label:`Join Discord`,icon:(0,b.jsx)(h,{size:16,style:{color:`currentColor`}}),onClick:f}})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsx)(`h2`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:`More from Vellum`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,b.jsx)(D,{icon:(0,b.jsx)(o,{size:20}),iconBg:`#22c55e`,title:`Community Hub`,description:`Showcases, guides, and projects shared by the community.`,href:v}),(0,b.jsx)(D,{icon:(0,b.jsx)(S,{size:20}),iconBg:`var(--content-default)`,iconColor:`var(--surface-base)`,title:`Follow on X`,description:`Product updates, releases, and behind-the-scenes.`,href:`https://x.com/vellum_ai`}),(0,b.jsx)(D,{icon:(0,b.jsx)(C,{size:20}),iconBg:`#ef4444`,title:`YouTube channel`,description:`Walkthroughs, tutorials, and product deep-dives.`,href:`https://www.youtube.com/@Vellum_AI`})]})]})]})}export{O as CommunityPage};
1
+ import{t as e}from"./button-BQVYX8n_.js";import{t}from"./jsx-runtime-CVSDxk6A.js";import{t as n}from"./card-D8zyWtZh.js";import{t as r}from"./createLucideIcon-Bjb-Kuq7.js";import{t as i}from"./bug-BMI_6ziD.js";import{t as a}from"./external-link-Cczz6xJ4.js";import{t as o}from"./globe-DgKSh933.js";import{t as s}from"./sparkles-BK3KXCjl.js";import{t as c}from"./users--1gWeHEq.js";import{t as l}from"./tag-B6WeUtBW.js";import{A as u,No as d,O as f,Ps as p,Wo as m,bt as h,k as g,us as _,v}from"./index-2np2R8qP.js";var y=r(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),b=t();function x({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function S({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})})}function C({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814ZM9.545 15.568V8.432L15.818 12l-6.273 3.568Z`})})}function w(){return(0,b.jsx)(n,{padding:`lg`,className:`bg-[var(--surface-lift)]`,children:(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`div`,{className:`pointer-events-none absolute -right-16 -top-16 h-64 w-64 rounded-full opacity-30 blur-3xl`,style:{background:`radial-gradient(circle, var(--system-mid-weak) 0%, transparent 70%)`},"aria-hidden":!0}),(0,b.jsxs)(`div`,{className:`relative flex flex-col items-start gap-3`,children:[(0,b.jsxs)(l,{tone:`neutral`,children:[(0,b.jsx)(m,{className:`h-3.5 w-3.5`}),`Community`]}),(0,b.jsx)(`h1`,{className:`text-[28px] font-semibold leading-tight tracking-tight text-[var(--content-emphasised)]`,children:`Build with us, in the open.`}),(0,b.jsx)(`p`,{className:`max-w-xl text-body-medium-default text-[color:var(--content-tertiary)]`,children:`Vellum is built in the open with a growing community of developers, designers, and tinkerers. Here's how to get involved.`})]})]})})}function T({icon:e,text:t}){return(0,b.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)]`,children:(0,b.jsx)(e,{size:14,className:`text-[var(--content-secondary)]`,"aria-hidden":!0})}),(0,b.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]})}function E({accentColor:t,iconColor:r=`var(--aux-white)`,label:i,icon:a,title:o,subtitle:s,benefits:c,primaryAction:l,secondaryAction:u}){return(0,b.jsx)(n,{padding:`lg`,className:`flex-1`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:a}),(0,b.jsx)(`span`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:i})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`h2`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:o}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:s})]}),(0,b.jsx)(`ul`,{className:`flex flex-col gap-3`,children:c.map(({icon:e,text:t})=>(0,b.jsx)(T,{icon:e,text:t},t))}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(e,{onClick:l.onClick,children:[l.icon,l.label]}),u&&(0,b.jsxs)(e,{variant:`ghost`,onClick:()=>window.open(u.href,`_blank`,`noopener,noreferrer`),children:[u.label,(0,b.jsx)(p,{className:`h-3.5 w-3.5`})]})]})]})})}function D({icon:e,iconBg:t,iconColor:r=`white`,title:i,description:o,href:s}){return(0,b.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`flex flex-1 cursor-pointer`,children:(0,b.jsx)(n,{className:`flex-1 transition-shadow hover:shadow-md`,padding:`lg`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:e}),(0,b.jsx)(a,{size:14,className:`text-[var(--content-tertiary)]`,"aria-hidden":!0})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`span`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:i}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:o})]})]})})})}function O(){let{handleStar:e}=u();return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(w,{}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,b.jsx)(E,{accentColor:`var(--content-emphasised)`,iconColor:`var(--surface-base)`,label:`Open Source`,icon:(0,b.jsx)(x,{size:20}),title:`Vellum is open source`,subtitle:`Read the source, star the repo, and contribute fixes and features on GitHub.`,benefits:[{icon:d,text:`Star the repo to follow updates`},{icon:i,text:`Open issues and report bugs`},{icon:y,text:`Contribute fixes and new features`}],primaryAction:{label:`Star on GitHub`,icon:(0,b.jsx)(d,{size:16}),onClick:e},secondaryAction:{label:`View source`,href:g}}),(0,b.jsx)(E,{accentColor:`#5865F2`,label:`Discord`,icon:(0,b.jsx)(h,{size:20}),title:`Join our community`,subtitle:`Talk to the team, share feedback, request features, and get answers faster.`,benefits:[{icon:_,text:`Talk directly with the team`},{icon:s,text:`Share feedback and request features`},{icon:c,text:`Get answers faster from the community`}],primaryAction:{label:`Join Discord`,icon:(0,b.jsx)(h,{size:16,style:{color:`currentColor`}}),onClick:f}})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsx)(`h2`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:`More from Vellum`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,b.jsx)(D,{icon:(0,b.jsx)(o,{size:20}),iconBg:`#22c55e`,title:`Community Hub`,description:`Showcases, guides, and projects shared by the community.`,href:v}),(0,b.jsx)(D,{icon:(0,b.jsx)(S,{size:20}),iconBg:`var(--content-default)`,iconColor:`var(--surface-base)`,title:`Follow on X`,description:`Product updates, releases, and behind-the-scenes.`,href:`https://x.com/vellum_ai`}),(0,b.jsx)(D,{icon:(0,b.jsx)(C,{size:20}),iconBg:`#ef4444`,title:`YouTube channel`,description:`Walkthroughs, tutorials, and product deep-dives.`,href:`https://www.youtube.com/@Vellum_AI`})]})]})]})}export{O as CommunityPage};
@@ -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,n as i,t 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"./useMutation-Lj4VunQV.js";import{t as u}from"./jsx-runtime-CVSDxk6A.js";import{t as d}from"./typography-Cqi8q9o7.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{t as h}from"./panel-item-An-BBeyL.js";import{t as g}from"./link-2-B9c5ZsFq.js";import{t as _}from"./loader-circle-Ck8fq3yv.js";import{t as v}from"./pencil-CsnkG5VN.js";import{t as y}from"./plus-DZZypDUF.js";import{t as b}from"./user-plus-KuzSTM_D.js";import{t as x}from"./tag-B6WeUtBW.js";import{t as S}from"./input-ZpyYt_a0.js";import{t as C}from"./modal-BtcwNEBj.js";import{n as w}from"./toast-Be8FEQ-I.js";import{t as T}from"./confirm-dialog-Zyfei9GV.js";import{C as E}from"./sdk.gen-zsiNChRm.js";import{Ht as ee,S as D,Ut as te,a as O,b as ne,x as k}from"./react-query.gen-C0S0EYHV.js";import{t as re}from"./assistant-identity-store-CgJwLRMd.js";import{c as ie}from"./routes-Cwb-U9H-.js";import{t as ae}from"./assistant-feature-flag-store-aNAjw1qx.js";import{$o as oe,Bo as A,Fs as j,Ft as se,Ms as M,Oa as ce,Yo as N,bn as P,ca as F,ds as le,ks as I,qo as L,w as ue,yn as R,zo as z}from"./index-D7_9Qy0L.js";import{t as B}from"./use-active-assistant-id-DwLFgABu.js";import{a as de,d as fe,i as V,n as pe,o as me,r as he,t as ge}from"./use-invite-link-dialog-BL_ylpSj.js";import{t as H}from"./detail-card-CIh4dCKt.js";import{n as _e,t as ve}from"./mobile-sidebar-drawer-BNR5lCRm.js";import{t as U}from"./mutation-error-C9sr8Rue.js";import{a as ye,i as be,n as W,t as xe}from"./contacts-gateway-C1Oif2mf.js";var Se=p(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),G=p(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Ce=p(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),K=e(t(),1),q=new Set([`slack`]);function J(e){return e.status===`verified`||e.status===`active`&&e.verifiedAt!=null}var Y=u();function X({channels:e,pendingChannelKey:t=null,onConnect:n,onDisconnect:r}){let[i,a]=(0,K.useState)(null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,i)=>(0,Y.jsxs)(`div`,{children:[i>0?(0,Y.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}):null,(0,Y.jsx)(Z,{channel:e,pending:t===e.key,onConnect:n?()=>n(e.key):void 0,onDisconnect:r?()=>a(e.key):void 0})]},e.key))}),(0,Y.jsx)(T,{open:i!==null,title:`Disconnect ${i?P(i):``}?`,message:`This clears the stored credentials for this channel. You can reconnect later.`,confirmLabel:`Disconnect`,destructive:!0,onConfirm:()=>{i&&r&&r(i),a(null)},onCancel:()=>a(null)})]})}function Z({channel:e,pending:t,onConnect:r,onDisconnect:i}){let a=e.status===`ready`;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,Y.jsx)(R,{channelId:e.key,className:`h-4 w-4 shrink-0 text-[color:var(--content-secondary)]`}),(0,Y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:P(e.key)}),a&&e.address?(0,Y.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:e.address}):null,(0,Y.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-8 px-2.5 rounded-md whitespace-nowrap select-none text-body-small-emphasised leading-none bg-[var(--content-default)] text-[var(--surface-base)]`,children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),`Connected`]}),(0,Y.jsx)(n,{variant:`danger`,onClick:i,disabled:!i||t,children:t?`Disconnecting…`:`Disconnect`})]}):(0,Y.jsx)(n,{variant:`outlined`,onClick:r,disabled:!r||t,children:`Connect`})})]})}function Q({role:e,contactType:t}){let{label:n,tone:r}=we(e,t);return(0,Y.jsx)(x,{tone:r,children:n})}function we(e,t){switch(e){case`guardian`:return{label:`Guardian`,tone:`positive`};case`assistant`:return{label:`Assistant`,tone:`negative`};default:return t===`assistant`?{label:`Assistant`,tone:`negative`}:{label:`Human`,tone:`warning`}}}function Te({assistantName:e,...t}){let n=fe(e);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(H,{title:`${n} (Your Assistant)`,accessory:(0,Y.jsx)(Q,{role:`assistant`}),compactAccessory:!0}),(0,Y.jsx)(H,{title:`Channels`,subtitle:`Where ${n} can be reached.`,children:(0,Y.jsx)(X,{...t})})]})}function Ee({provenance:e}){return e.source===`global-default`?(0,Y.jsx)(x,{children:`Global default`}):(0,Y.jsxs)(x,{children:[`Default from`,(0,Y.jsx)(n,{asChild:!0,variant:`link`,size:`compact`,className:`h-auto px-0`,children:(0,Y.jsxs)(a,{to:`${ie.channels}?setup=${e.channel}`,children:[`Channels → `,P(e.channel)]})})]})}var $=new Set([`telegram`,`phone`,`vellum`,`whatsapp`,`slack`,`email`,`platform`,`a2a`]);function De(e){return $.has(e)}function Oe(e,t){return e.id===`a2a`?t&&t.status!==`revoked`?{kind:`connected`}:{kind:`setup`}:t!=null&&J(t)?{kind:`verified`}:t?.status===`blocked`?{kind:`none`}:t&&t.status!==`revoked`?{kind:`unverified`}:{kind:`setup`}}function ke(e,t,n){let r=[],i=new Set;if(e)for(let t of e)t.id===`a2a`&&!n||(r.push(t),i.add(t.id));for(let e of t)e.status===`revoked`||i.has(e.type)||e.type===`a2a`&&!n||De(e.type)&&(r.push({id:e.type,label:e.type.charAt(0).toUpperCase()+e.type.slice(1),subtitle:``,icon:`help-circle`,supportsVerification:!1,setupMessages:{guardian:``,contact:``}}),i.add(e.type));return r}function Ae({name:e,className:t,style:n}){switch(e){case`bot`:return(0,Y.jsx)(M,{className:t,style:n});case`hash`:return(0,Y.jsx)(le,{className:t,style:n});case`send`:return(0,Y.jsx)(z,{className:t,style:n});case`phone`:return(0,Y.jsx)(L,{className:t,style:n});case`mail`:return(0,Y.jsx)(oe,{className:t,style:n});case`message-square`:return(0,Y.jsx)(N,{className:t,style:n});default:return(0,Y.jsx)(Se,{className:t,style:n})}}function je({contactChannels:e,availableChannels:t,a2aEnabled:n,channelProvenance:r,setupLabel:i=`Invite`,verifyLoading:a,verifySubject:o=`self`,onSetupChannel:s,onVerifyChannel:c,onRevokeChannel:l,onLinkAccount:u}){let[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),h=new Map;for(let t of e)t.status!==`revoked`&&(h.has(t.type)||h.set(t.type,t));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`flex flex-col`,children:ke(t,e,n).map((e,t)=>{let n=h.get(e.id);return(0,Y.jsxs)(`div`,{children:[t>0&&(0,Y.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),(0,Y.jsx)(Me,{info:e,existing:n,provenance:n&&se(e.id)?r?.[e.id]:void 0,setupLabel:i,verifyLoading:a,onSetup:s?()=>s(e.id):void 0,onVerify:c&&e.supportsVerification?()=>f(e):void 0,onRevoke:l&&n?()=>m({channelId:n.id,channel:e}):void 0,onLinkAccount:u&&q.has(e.id)?()=>u(e.id):void 0})]},e.id)})}),d&&(0,Y.jsx)(T,{open:!0,title:`Verify ${d.label}`,message:o===`contact`?`This will mark this contact's ${d.label} channel as verified. Your assistant will recognize them when they reach out from it.`:`This will mark your ${d.label} channel as verified. Your assistant will recognize you when you reach out from it.`,confirmLabel:`Verify`,onConfirm:()=>{d&&(c?.(d.id),f(null))},onCancel:()=>f(null)}),p&&(0,Y.jsx)(T,{open:!0,title:`Revoke ${p.channel.label}`,message:`This will disconnect the verified channel. The contact will need to re-verify to use this channel again.`,confirmLabel:`Revoke`,destructive:!0,onConfirm:()=>{l?.(p.channelId,p.channel.id),m(null)},onCancel:()=>m(null)})]})}function Me({info:e,existing:t,provenance:r,setupLabel:i,verifyLoading:a,onSetup:o,onVerify:s,onRevoke:c,onLinkAccount:l}){let u=Oe(e,t);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,Y.jsx)(Ae,{name:e.icon,className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),(0,Y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e.label}),t?.address?(0,Y.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:t.address}):null,(0,Y.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[r?(0,Y.jsx)(Ee,{provenance:r}):null,u.kind===`connected`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-8 px-2.5 rounded-md whitespace-nowrap select-none text-body-small-emphasised leading-none bg-[var(--content-default)] text-[var(--surface-base)]`,children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),`Connected`]}),c?(0,Y.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`verified`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-8 px-2.5 rounded-md whitespace-nowrap select-none text-body-small-emphasised leading-none bg-[var(--content-default)] text-[var(--surface-base)]`,children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),`Verified`]}),c?(0,Y.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`unverified`?(0,Y.jsx)(n,{variant:`outlined`,onClick:s,disabled:!s||a,children:a?`Verifying…`:`Verify`}):u.kind===`setup`?e.id===`a2a`?null:(0,Y.jsxs)(Y.Fragment,{children:[l?(0,Y.jsxs)(n,{onClick:l,children:[(0,Y.jsx)(g,{className:`h-3.5 w-3.5`}),`Link account`]}):null,(0,Y.jsx)(n,{variant:`outlined`,onClick:o,disabled:!o,children:i})]}):null]})]})}function Ne(e){return(0,Y.jsx)(Pe,{...e},e.contact.id)}function Pe({contact:e,savePending:t,deletePending:r,verifyPending:i,mergePending:a=!1,canMerge:o=!1,availableChannels:s,a2aEnabled:c,channelProvenance:l,onSave:u,onDelete:d,onMerge:f,onSetupChannel:p,onVerifyChannel:m,onRevokeChannel:h,onLinkAccount:g}){let _=e.displayName===`New Contact`,[v,y]=(0,K.useState)(_?``:e.displayName),[b,x]=(0,K.useState)(e.notes??``),[C,w]=(0,K.useState)(!1),E=v.trim(),ee=b.trim(),D=_?``:e.displayName,te=e.notes??``,O=E!==D||ee!==te,ne=E.length>0&&O&&!t&&!r,k=_&&e.channels.length===0&&e.interactionCount===0,re=E||e.displayName,ie=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(H,{title:re,accessory:(0,Y.jsx)(Q,{role:e.role,contactType:e.contactType}),compactAccessory:!0,subtitle:ie,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(S,{label:`Name`,type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`Give this human a name`,autoFocus:_,disabled:t||r,fullWidth:!0}),(0,Y.jsx)(S,{label:`Notes`,type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Optional notes about the human which AI will take into account`,disabled:t||r,fullWidth:!0}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(n,{type:`button`,onClick:()=>u({displayName:E,notes:ee}),disabled:!ne,children:t?`Saving…`:`Save`}),f?(0,Y.jsx)(n,{type:`button`,variant:`outlined`,onClick:f,disabled:!o||k||O||a||t||r,title:o?k?`Save this contact before merging`:O?`Save your changes before merging`:void 0:`No other contacts available to merge`,children:a?`Merging…`:`Merge…`}):null,(0,Y.jsx)(n,{type:`button`,variant:`danger`,onClick:()=>{k?d():w(!0)},disabled:r,children:r?`Deleting…`:`Delete Contact`})]})]})}),(0,Y.jsx)(H,{title:`Linked accounts`,subtitle:`Where the assistant recognizes this contact. Link accounts you know, invite the ones you don't.`,children:(0,Y.jsx)(je,{contactChannels:e.channels,availableChannels:s,a2aEnabled:c,channelProvenance:l,verifyLoading:i,verifySubject:`contact`,onSetupChannel:p,onVerifyChannel:m,onRevokeChannel:h,onLinkAccount:g})}),(0,Y.jsx)(T,{open:C,title:`Delete ${e.displayName}?`,message:`This will permanently delete this contact and all their channels. This action cannot be undone.`,confirmLabel:`Delete`,destructive:!0,onConfirm:()=>{w(!1),d()},onCancel:()=>w(!1)})]})}function Fe(e){return(0,Y.jsx)(Ie,{...e},`${e.survivor.id}:${e.open?`open`:`closed`}`)}function Ie({open:e,survivor:t,candidates:r,pending:i,errorMessage:a,onMerge:o,onClose:s}){let[c,l]=(0,K.useState)(``),[u,f]=(0,K.useState)(null);(0,K.useEffect)(()=>{u&&!r.some(e=>e.id===u)&&f(null)},[r,u]);let p=(0,K.useMemo)(()=>{let e=c.trim().toLowerCase();return e?r.filter(t=>t.displayName.toLowerCase().includes(e)):r},[r,c]),h=u?r.find(e=>e.id===u)??null:null,g=Ve(t);return(0,Y.jsx)(C.Root,{open:e,onOpenChange:e=>{!e&&!i&&s()},children:(0,Y.jsxs)(C.Content,{size:`md`,children:[(0,Y.jsxs)(C.Header,{children:[(0,Y.jsx)(C.Title,{icon:Ce,children:h?`Merge "${h.displayName}" into ${g}?`:`Merge another contact into ${g}`}),(0,Y.jsx)(C.Description,{children:h?`Channels and notes from the merged contact will move over. The merged contact will be deleted.`:`The contact you pick will be deleted. Its channels and notes will be added to this one.`})]}),(0,Y.jsxs)(C.Body,{className:`flex flex-col gap-3`,children:[h?(0,Y.jsx)(ze,{survivor:t,donor:h}):r.length===0?(0,Y.jsx)(Be,{}):(0,Y.jsx)(Le,{search:c,onSearch:l,candidates:p,onPick:f}),a?(0,Y.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-(--system-negative-strong)`,role:`alert`,children:a}):null]}),(0,Y.jsx)(C.Footer,{children:h?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(n,{variant:`outlined`,onClick:()=>f(null),disabled:i,leftIcon:(0,Y.jsx)(m,{"aria-hidden":!0}),children:`Back`}),(0,Y.jsx)(n,{variant:`danger`,onClick:()=>o(h.id),disabled:i,children:i?`Merging…`:`Merge`})]}):(0,Y.jsx)(n,{variant:`outlined`,onClick:s,disabled:i,children:`Cancel`})})]})})}function Le({search:e,onSearch:t,candidates:n,onPick:r}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search contacts`,leftIcon:(0,Y.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}),(0,Y.jsx)(`div`,{className:`flex max-h-[320px] min-h-[120px] flex-col gap-1 overflow-y-auto`,role:`listbox`,"aria-label":`Select a contact to merge`,children:n.length===0?(0,Y.jsx)(d,{as:`p`,variant:`body-small-default`,className:`px-3 py-4 text-center text-(--content-tertiary)`,children:`No matching contacts`}):n.map(e=>(0,Y.jsx)(Re,{contact:e,onPick:()=>r(e.id)},e.id))})]})}function Re({contact:e,onPick:t}){let n=Ge(e).join(` | `)||void 0;return(0,Y.jsx)(h,{asChild:!0,label:``,children:(0,Y.jsx)(`button`,{type:`button`,onClick:t,role:`option`,"aria-selected":`false`,className:`flex h-auto w-full items-center gap-2 rounded-[6px] px-[8px] py-2 text-left`,children:(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e.displayName}),n?(0,Y.jsx)(`span`,{className:`truncate text-body-small-default text-(--content-tertiary)`,children:n}):null]})})})}function ze({survivor:e,donor:t}){let n=Ve(e),{moved:r,duplicates:i}=We(e,t);return(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-2 text-body-medium-lighter text-(--content-secondary)`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`span`,{className:`text-(--content-default)`,children:[`“`,t.displayName,`”`]}),` `,`will be deleted.`]}),(0,Y.jsx)(`li`,{children:r.length===0?`No new channels will move to ${n}.`:`${r.length} channel${r.length===1?``:`s`} will move to ${n}: ${r.map(e=>Ue(e.type)).join(`, `)}.`}),i.length>0?(0,Y.jsxs)(`li`,{className:`text-(--content-tertiary)`,children:[i.length,` duplicate channel`,i.length===1?``:`s`,` already on `,n,` `,`(skipped).`]}):null,t.notes?(0,Y.jsx)(`li`,{children:`Notes from the merged contact will be appended.`}):null,(0,Y.jsx)(`li`,{className:`text-(--content-tertiary)`,children:`This cannot be undone.`})]})}function Be(){return(0,Y.jsx)(d,{as:`p`,variant:`body-medium-lighter`,className:`px-3 py-6 text-center text-(--content-tertiary)`,children:`No other contacts available to merge.`})}function Ve(e){return e.role===`guardian`?!e.displayName||e.displayName.startsWith(`vellum-principal-`)?`you`:`${e.displayName} (you)`:e.displayName||`this contact`}var He={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`};function Ue(e){return He[e.toLowerCase()]??e}function We(e,t){let n=[],r=[];for(let i of t.channels)i.status!==`revoked`&&(e.channels.some(e=>e.type===i.type&&e.address.toLowerCase()===i.address.toLowerCase())?r.push(i):n.push(i));return{moved:n,duplicates:r}}function Ge(e){let t=new Set,n=[];for(let r of e.channels){if(r.status===`revoked`)continue;let e=r.type.toLowerCase();t.has(e)||(t.add(e),n.push(He[e]??r.type))}return n}function Ke({loading:e,guardian:t,assistantName:r,regularContacts:i,selection:a,onSelect:o,onAddContact:s,addingContact:c=!1}){let[l,u]=(0,K.useState)(``),d=l.trim()?i.filter(e=>e.displayName.toLowerCase().includes(l.trim().toLowerCase())):i;return(0,Y.jsx)(f.Root,{className:`flex h-full flex-col overflow-hidden`,children:(0,Y.jsxs)(f.Body,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:`Entries`}),(0,Y.jsx)(n,{type:`button`,variant:`ghost`,iconOnly:c?(0,Y.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(y,{"aria-hidden":!0}),onClick:s,disabled:c,"aria-label":`Add contact`,tintColor:`var(--content-secondary)`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t?(0,Y.jsx)(qe,{name:t.displayName?`${t.displayName} (You)`:`You`,role:t.role,channelTypes:t.channelTypes,selected:a?.kind===`contact`&&a.contactId===t.id,onClick:()=>o({kind:`contact`,contactId:t.id}),trailingIcon:`pencil`}):null,(0,Y.jsx)(qe,{name:r?.trim()||`Your Assistant`,role:`assistant`,selected:a?.kind===`assistant`,onClick:()=>o({kind:`assistant`}),trailingIcon:`more`})]}),(0,Y.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),i.length>0?(0,Y.jsx)(S,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search Contacts`,leftIcon:(0,Y.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}):null,i.length>0?(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto flex flex-col gap-1`,children:[d.map(e=>(0,Y.jsx)(qe,{name:e.displayName,role:e.role,contactType:e.contactType,channelTypes:e.channelTypes,verified:e.verified,selected:a?.kind===`contact`&&a.contactId===e.id,onClick:()=>o({kind:`contact`,contactId:e.id}),trailingIcon:`more`},e.id)),d.length===0?(0,Y.jsx)(`p`,{className:`px-3 py-4 text-center text-body-small-default`,style:{color:`var(--content-tertiary)`},children:`No matching contacts`}):null]}):e?null:(0,Y.jsx)(n,{type:`button`,variant:`ghost`,onClick:s,disabled:c,tintColor:`var(--primary-base)`,leftIcon:c?(0,Y.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(b,{"aria-hidden":!0}),children:`Add Contact`})]})})}function qe({name:e,role:t,contactType:n,channelTypes:r,selected:i,onClick:a,trailingIcon:o,verified:s}){let c=r&&r.length>0?r.join(` | `):void 0;return(0,Y.jsx)(h,{asChild:!0,active:i,label:``,trailingAction:o===`pencil`?(0,Y.jsx)(v,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):o===`more`?(0,Y.jsx)(G,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):void 0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:a,className:`flex h-auto w-full items-center gap-2 rounded-[6px] px-[8px] py-2 text-left`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e}),c?(0,Y.jsx)(`span`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:c}):null]}),(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[s===void 0?null:(0,Y.jsx)(x,{tone:s?`positive`:`neutral`,children:s?`Verified`:`Unverified`}),(0,Y.jsx)(Q,{role:t,contactType:n})]})]})})}function Je(e){return(0,Y.jsx)(Ye,{...e},e.contact.id)}function Ye({contact:e,savePending:t,verifyPending:r,mergePending:i=!1,canMerge:a=!1,availableChannels:o,a2aEnabled:s,onSave:c,onMerge:l,onSetupChannel:u,onVerifyChannel:d,onRevokeChannel:f,onGenerateInviteLink:p}){let m=e.displayName.startsWith(`vellum-principal-`),h=m?``:e.displayName,[g,_]=(0,K.useState)(h),[v,y]=(0,K.useState)(e.notes??``),b=g.trim(),x=v.trim(),C=b!==h.trim()||x!==(e.notes??``).trim(),w=C&&!t,T=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(H,{title:m?`You`:`${e.displayName} (You)`,accessory:(0,Y.jsx)(Q,{role:`guardian`}),compactAccessory:!0,subtitle:T,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(S,{label:`Name`,type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Your name`,disabled:t,fullWidth:!0}),(0,Y.jsx)(S,{label:`Notes`,type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`Notes about yourself which AI will take into account`,disabled:t,fullWidth:!0}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(n,{variant:`primary`,onClick:()=>c({displayName:b||e.displayName,notes:x}),disabled:!w,children:t?`Saving…`:`Save`}),l?(0,Y.jsx)(n,{variant:`outlined`,onClick:l,disabled:!a||C||i||t,title:a?C?`Save your changes before merging`:void 0:`No other contacts available to merge`,children:i?`Merging…`:`Merge…`}):null]})]})}),(0,Y.jsx)(H,{title:`Channels`,subtitle:`Once verified, your assistant will recognize you when you message from these channels.`,children:(0,Y.jsx)(je,{contactChannels:e.channels,availableChannels:o,a2aEnabled:s,setupLabel:`Verify me`,verifyLoading:r,onSetupChannel:u,onVerifyChannel:d,onRevokeChannel:f})}),p?(0,Y.jsx)(de,{onClick:p}):null]})}function Xe(e,t){let n=t.trim().toLowerCase().replace(/^@/,``);return n===``?e:e.filter(e=>e.displayName.toLowerCase().includes(n)||e.username.toLowerCase().includes(n))}function Ze(e){let t=e.trim().split(/\s+/).filter(Boolean);return`${t[0]?.[0]??`?`}${t.length>1?t[t.length-1]?.[0]??``:``}`.toUpperCase()}function Qe({open:e,channelLabel:t,contactName:r,accounts:i,loading:a,errorMessage:o,pendingAccountId:s,onPick:c,onClose:l,onInviteInstead:u}){let[d,f]=(0,K.useState)(``);(0,K.useEffect)(()=>{e&&f(``)},[e]);let p=(0,K.useMemo)(()=>Xe(i??[],d),[i,d]),m=s!=null;return(0,Y.jsx)(C.Root,{open:e,onOpenChange:e=>!e&&l(),children:(0,Y.jsxs)(C.Content,{size:`sm`,children:[(0,Y.jsxs)(C.Header,{children:[(0,Y.jsxs)(C.Title,{children:[`Link `,t,` account`]}),(0,Y.jsxs)(C.Description,{children:[`Search your `,t,` workspace and pick`,` `,(0,Y.jsx)(`span`,{className:`text-[color:var(--content-default)]`,children:r}),`’s account.`]})]}),(0,Y.jsxs)(C.Body,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(S,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search by name or @handle`,"aria-label":`Search ${t} workspace accounts`,leftIcon:(0,Y.jsx)(A,{className:`h-4 w-4`}),fullWidth:!0}),o?(0,Y.jsx)(`p`,{className:`text-body-small-default text-[color:var(--content-negative)]`,children:o}):null,(0,Y.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:a?(0,Y.jsx)(`p`,{className:`py-4 text-center text-body-small-default text-[color:var(--content-tertiary)]`,children:`Loading workspace members…`}):p.length===0?(0,Y.jsx)(`p`,{className:`py-4 text-center text-body-small-default text-[color:var(--content-tertiary)]`,children:(i?.length??0)===0?`No workspace members found.`:`No members match.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:p.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(e),disabled:m,className:`flex w-full cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-left transition-colors hover:bg-[var(--surface-overlay)] disabled:cursor-not-allowed disabled:opacity-60`,children:[e.imageUrl?(0,Y.jsx)(`img`,{src:e.imageUrl,alt:``,className:`h-8 w-8 shrink-0 rounded-full`}):(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[var(--tag-bg-neutral)] text-body-small-emphasised text-[color:var(--content-secondary)]`,children:Ze(e.displayName)}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-body-medium-default text-[color:var(--content-default)]`,children:e.displayName}),(0,Y.jsxs)(`span`,{className:`truncate text-body-small-default text-[color:var(--content-tertiary)]`,children:[`@`,e.username]})]}),s===e.id?(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:`Linking…`}):null]})},e.id))})})]}),(0,Y.jsxs)(C.Footer,{className:`items-center justify-between gap-3 border-t border-[var(--border-base)]`,children:[(0,Y.jsxs)(`p`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:[`Picking marks this account as`,` `,(0,Y.jsx)(`span`,{className:`text-[color:var(--content-secondary)]`,children:`guardian-linked`}),` `,`— you vouch for the identity, no handshake needed.`]}),u?(0,Y.jsxs)(n,{variant:`link`,className:`shrink-0`,onClick:u,disabled:m,children:[`Or send an invite instead`,(0,Y.jsx)(j,{className:`h-3.5 w-3.5`})]}):null]})]})})}function $e(e){let t={};for(let n of e)se(n.channelType)&&(t[n.channelType]=n.policy===`trusted_contacts`?{source:`global-default`}:{source:`channel-default`,channel:n.channelType});return t}function et(e){return $e(V(e))}function tt(e){let t=ae.use.channelTrustFloors(),n=he(),r=t&&n,i=c({...F({path:{assistant_id:e}}),enabled:r,select:et});return r?i.data:void 0}function nt({assistantId:e,channelType:t,contact:n,onLinked:r}){let[i,a]=(0,K.useState)(!1),o=l({mutationFn:n=>W(e,n.contact,{type:t,address:n.account.id}),onSuccess:(e,t)=>{a(!1),w.success(`Linked as @${t.account.username}`),r()}}),s=(0,K.useCallback)(()=>{o.reset(),a(!0)},[o]),c=(0,K.useCallback)(()=>{o.isPending||(o.reset(),a(!1))},[o]),u=(0,K.useCallback)(e=>{!n||o.isPending||o.mutate({contact:n,account:e})},[n,o]);return{channelType:t,dialogOpen:i,open:s,close:c,linkErrorMessage:o.error instanceof Error?o.error.message:o.error?`Failed to link account`:null,pendingAccountId:o.isPending?o.variables.account.id:null,pick:u}}var rt=[{id:`slack`,label:`Slack`,subtitle:`Message your assistant from Slack`,icon:`hash`,supportsVerification:!0,setupMessages:{guardian:`I'd like to verify my identity as your guardian on Slack. Can you help me set that up?`,contact:`I'd like to verify a contact's Slack identity. Can you walk me through it?`}},{id:`telegram`,label:`Telegram`,subtitle:`Message your assistant from Telegram`,icon:`send`,supportsVerification:!0,setupMessages:{guardian:`I'd like to verify my identity as your guardian on Telegram. Can you help me set that up?`,contact:`I'd like to verify a contact's Telegram identity. Can you walk me through it?`}},{id:`phone`,label:`Phone Calling`,subtitle:`Call or text your assistant via phone`,icon:`phone`,supportsVerification:!0,setupMessages:{guardian:`I'd like to verify my identity as your guardian for phone calls. Can you help me set that up?`,contact:`I'd like to verify a contact's phone number. Can you help me set that up?`}}],it=[];function at({assistantId:e,onStartSetupConversation:t}){let n=ae.use.a2aChannel(),a=re.use.name(),o=s(),[u]=r(),d=u.get(`setup`),f=d&&se(d)?d:null,[p,m]=(0,K.useState)({kind:`assistant`}),h=ge(e),[g,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(!1),b=fe(a),x=(0,K.useMemo)(()=>({path:{assistant_id:e}}),[e]),S=k(x),C=c({...ne(x),enabled:!!e,select:e=>e.contacts}),T=pe({assistantId:e,onStartSetupConversation:t}),oe=tt(e),A=c({...O({path:{assistant_id:e}}),enabled:!!e,queryFn:async({signal:t})=>{let{data:n,error:r,response:i}=await E({path:{assistant_id:e},signal:t,throwOnError:!1});if(!i||i.status===404)return{channels:rt};if(!i.ok)throw r??Error(`Failed to fetch channel availability`);return n},select:e=>e.channels}).data??it,j=C.data,M=(0,K.useMemo)(()=>j?.find(e=>e.role===`guardian`)??null,[j]),ce=(0,K.useMemo)(()=>j?.filter(e=>e.role!==`guardian`)??[],[j]),N=(0,K.useMemo)(()=>p.kind===`contact`?j?.find(e=>e.id===p.contactId)??null:null,[j,p]),P=(0,K.useMemo)(()=>!j||!N?[]:j.filter(e=>e.id!==N.id&&e.role!==`guardian`),[j,N]),F=P.length>0,le=(0,K.useRef)(!!f);(0,K.useEffect)(()=>{le.current||M&&(le.current=!0,m({kind:`contact`,contactId:M.id}))},[M]);let I=(0,K.useCallback)(()=>o.invalidateQueries({queryKey:S}),[o,S]),L=l({mutationFn:()=>be(e,{displayName:`New Contact`}),onMutate:async()=>{await o.cancelQueries({queryKey:S})},onSuccess:e=>{D(o,x,t=>t?{...t,contacts:[...t.contacts,e]}:void 0),m({kind:`contact`,contactId:e.id})},onError:U(`Failed to create contact`),onSettled:()=>I()}),R=l({mutationFn:t=>xe(e,t),onSuccess:(e,t)=>{D(o,x,e=>e?{...e,contacts:e.contacts.filter(e=>e.id!==t)}:void 0),m({kind:`assistant`})},onError:U(`Failed to delete contact`),onSettled:()=>I()}),z=l({mutationFn:({contactId:t,patch:n})=>be(e,{id:t,displayName:n.displayName,notes:n.notes}),onSuccess:e=>{D(o,x,t=>t?{...t,contacts:t.contacts.map(t=>t.id===e.id?e:t)}:void 0)},onError:U(`Failed to save contact`),onSettled:()=>I()}),B=te({onMutate:async()=>{await o.cancelQueries({queryKey:S})},onSuccess:(e,t)=>{let n=e.contact,r=t.body.mergeId;n&&(D(o,x,e=>e?{...e,contacts:e.contacts.filter(e=>e.id!==r).map(e=>e.id===n.id?n:e)}:void 0),m({kind:`contact`,contactId:n.id})),y(!1),w.success(`Contacts merged`)},onSettled:()=>I()}),de=(0,K.useCallback)(e=>{m(e),_(!1),y(!1),B.reset()},[B]),V=(0,K.useCallback)(()=>{B.reset(),y(!0)},[B]),he=(0,K.useCallback)(()=>{B.isPending||(y(!1),B.reset())},[B]),H=ee({onSuccess:()=>I()}),W=(0,K.useCallback)((t,n)=>{H.mutate({path:{assistant_id:e,contactChannelId:t},body:{status:`revoked`}})},[H,e]),Se=(0,K.useCallback)(()=>{L.isPending||L.mutate()},[L]),G=(0,K.useCallback)(e=>{if(!t)return;let n=A.find(t=>t.id===e)?.setupMessages.contact;n&&t(n)},[A,t]),Ce=(0,K.useCallback)(e=>{if(!t)return;let n=A.find(t=>t.id===e)?.setupMessages.guardian;n&&t(n)},[A,t]),q=l({mutationFn:t=>ye(e,t.channelId),onSuccess:()=>I(),onError:U(`Failed to verify channel`)}),J=(0,K.useCallback)(e=>{if(!N)return;let t=N.channels.find(t=>t.type===e&&t.status!==`revoked`);t&&q.mutate({channelId:t.id})},[N,q]),X=nt({assistantId:e,channelType:`slack`,contact:N?{id:N.id,displayName:N.displayName}:null,onLinked:I}),Z=c({...ue(e),enabled:!!e&&X.dialogOpen,select:e=>e.users}),Q=T.channels.some(e=>e.key===`slack`&&e.status===`ready`),we=(0,K.useCallback)(e=>{e===X.channelType&&X.open()},[X]),Ee=R.isPending?R.variables:null,$=(0,K.useMemo)(()=>N?z.isPending&&z.variables?.contactId===N.id?{...N,displayName:z.variables.patch.displayName,notes:z.variables.patch.notes}:N:null,[N,z.isPending,z.variables]);if(f)return(0,Y.jsx)(i,{to:`${ie.channels}?setup=${f}`,replace:!0});let De={loading:C.isLoading,assistantName:b,guardian:M?{id:M.id,displayName:M.displayName.startsWith(`vellum-principal-`)?``:M.displayName,role:M.role,channelTypes:lt(M.channels,n)}:null,regularContacts:ce.filter(e=>e.id!==Ee).map(e=>({id:e.id,displayName:e.displayName,role:e.role,contactType:e.contactType,channelTypes:lt(e.channels,n),verified:ct(e.channels)})),selection:p,onAddContact:Se,addingContact:L.isPending};return(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden sm:flex-row sm:gap-6`,children:[(0,Y.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,Y.jsx)(_e,{onClick:()=>_(!0)})}),(0,Y.jsx)(ve,{open:g,onClose:()=>_(!1),title:`Contacts`,children:(0,Y.jsx)(Ke,{...De,onSelect:de})}),(0,Y.jsx)(`aside`,{className:`hidden min-h-0 w-[320px] shrink-0 overflow-y-auto self-stretch sm:block`,children:(0,Y.jsx)(Ke,{...De,onSelect:de})}),(0,Y.jsx)(`section`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:p.kind===`assistant`||p.kind===`contact`&&p.contactId===Ee?(0,Y.jsx)(Te,{assistantName:b,channels:T.channels,pendingChannelKey:T.pendingChannelKey,onConnect:T.onSetup,onDisconnect:T.onDisconnect}):$?$.role===`guardian`?(0,Y.jsx)(Je,{contact:$,savePending:z.isPending,verifyPending:q.isPending,mergePending:B.isPending,canMerge:F,availableChannels:A,a2aEnabled:n,onSave:e=>{z.mutate({contactId:$.id,patch:e})},onMerge:V,onSetupChannel:t?Ce:void 0,onVerifyChannel:J,onRevokeChannel:W,onGenerateInviteLink:n?h.open:void 0}):(0,Y.jsx)(Ne,{contact:$,savePending:z.isPending,deletePending:R.isPending,verifyPending:q.isPending,mergePending:B.isPending,canMerge:F,availableChannels:A,a2aEnabled:n,channelProvenance:oe,onSave:e=>{z.mutate({contactId:$.id,patch:e})},onDelete:()=>{R.mutate($.id)},onMerge:V,onSetupChannel:t?G:void 0,onVerifyChannel:J,onRevokeChannel:W,onLinkAccount:Q?we:void 0}):(0,Y.jsx)(ot,{})}),N?(0,Y.jsx)(Fe,{open:v,survivor:N,candidates:P,pending:B.isPending,errorMessage:B.error instanceof Error?B.error.message:B.error?`Failed to merge contacts`:null,onMerge:t=>B.mutate({path:{assistant_id:e},body:{keepId:N.id,mergeId:t}}),onClose:he}):null,(0,Y.jsx)(Qe,{open:X.dialogOpen,channelLabel:`Slack`,contactName:N?.displayName??``,accounts:Z.data,loading:Z.isLoading,errorMessage:Z.isError?`Couldn’t load the workspace roster. Check the Slack connection and try again.`:X.linkErrorMessage,pendingAccountId:X.pendingAccountId,onPick:X.pick,onClose:X.close,onInviteInstead:t?()=>{X.close(),G(X.channelType)}:void 0}),(0,Y.jsx)(me,{open:h.isOpen,assistantId:e,onClose:h.close})]})}function ot(){return(0,Y.jsx)(`div`,{className:`flex h-full items-center justify-center py-16`,children:(0,Y.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a contact`})})}var st={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`,a2a:`A2A`};function ct(e){return e.some(e=>e.status!==`revoked`&&(e.type===`a2a`||J(e)))}function lt(e,t){let n=new Set,r=[];for(let i of e){if(i.status===`revoked`)continue;let e=i.type.toLowerCase();n.has(e)||e===`a2a`&&!t||(n.add(e),r.push(st[e]??i.type))}return r}function ut(){let e=o(),t=B();return(0,Y.jsx)(at,{assistantId:t,onStartSetupConversation:t=>{ce(e,{prompt:t})}},t)}export{ut as ContactsPageRoute};
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,n as i,t 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"./useMutation-Lj4VunQV.js";import{t as u}from"./jsx-runtime-CVSDxk6A.js";import{t as d}from"./typography-Cqi8q9o7.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{t as h}from"./panel-item-An-BBeyL.js";import{t as g}from"./link-2-B9c5ZsFq.js";import{t as _}from"./loader-circle-Ck8fq3yv.js";import{t as v}from"./pencil-CsnkG5VN.js";import{t as y}from"./plus-DZZypDUF.js";import{t as b}from"./user-plus-KuzSTM_D.js";import{t as x}from"./tag-B6WeUtBW.js";import{t as S}from"./input-ZpyYt_a0.js";import{t as C}from"./modal-BtcwNEBj.js";import{n as w}from"./toast-Be8FEQ-I.js";import{t as T}from"./confirm-dialog-Zyfei9GV.js";import{C as E}from"./sdk.gen-zsiNChRm.js";import{Ht as ee,S as D,Ut as te,a as O,b as ne,x as k}from"./react-query.gen-C0S0EYHV.js";import{t as re}from"./assistant-identity-store-CgJwLRMd.js";import{c as ie}from"./routes-Cwb-U9H-.js";import{t as ae}from"./assistant-feature-flag-store-aNAjw1qx.js";import{$o as oe,Bo as A,Fs as j,Ft as se,Ms as M,Oa as ce,Yo as N,bn as P,ca as F,ds as le,ks as I,qo as L,w as ue,yn as R,zo as z}from"./index-2np2R8qP.js";import{t as B}from"./use-active-assistant-id-DwLFgABu.js";import{a as de,d as fe,i as V,n as pe,o as me,r as he,t as ge}from"./use-invite-link-dialog-BsdPKDQ_.js";import{t as H}from"./detail-card-CIh4dCKt.js";import{n as _e,t as ve}from"./mobile-sidebar-drawer-ZUf-00kg.js";import{t as U}from"./mutation-error-C9sr8Rue.js";import{a as ye,i as be,n as W,t as xe}from"./contacts-gateway-C1Oif2mf.js";var Se=p(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),G=p(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Ce=p(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),K=e(t(),1),q=new Set([`slack`]);function J(e){return e.status===`verified`||e.status===`active`&&e.verifiedAt!=null}var Y=u();function X({channels:e,pendingChannelKey:t=null,onConnect:n,onDisconnect:r}){let[i,a]=(0,K.useState)(null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,i)=>(0,Y.jsxs)(`div`,{children:[i>0?(0,Y.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}):null,(0,Y.jsx)(Z,{channel:e,pending:t===e.key,onConnect:n?()=>n(e.key):void 0,onDisconnect:r?()=>a(e.key):void 0})]},e.key))}),(0,Y.jsx)(T,{open:i!==null,title:`Disconnect ${i?P(i):``}?`,message:`This clears the stored credentials for this channel. You can reconnect later.`,confirmLabel:`Disconnect`,destructive:!0,onConfirm:()=>{i&&r&&r(i),a(null)},onCancel:()=>a(null)})]})}function Z({channel:e,pending:t,onConnect:r,onDisconnect:i}){let a=e.status===`ready`;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,Y.jsx)(R,{channelId:e.key,className:`h-4 w-4 shrink-0 text-[color:var(--content-secondary)]`}),(0,Y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:P(e.key)}),a&&e.address?(0,Y.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:e.address}):null,(0,Y.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-8 px-2.5 rounded-md whitespace-nowrap select-none text-body-small-emphasised leading-none bg-[var(--content-default)] text-[var(--surface-base)]`,children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),`Connected`]}),(0,Y.jsx)(n,{variant:`danger`,onClick:i,disabled:!i||t,children:t?`Disconnecting…`:`Disconnect`})]}):(0,Y.jsx)(n,{variant:`outlined`,onClick:r,disabled:!r||t,children:`Connect`})})]})}function Q({role:e,contactType:t}){let{label:n,tone:r}=we(e,t);return(0,Y.jsx)(x,{tone:r,children:n})}function we(e,t){switch(e){case`guardian`:return{label:`Guardian`,tone:`positive`};case`assistant`:return{label:`Assistant`,tone:`negative`};default:return t===`assistant`?{label:`Assistant`,tone:`negative`}:{label:`Human`,tone:`warning`}}}function Te({assistantName:e,...t}){let n=fe(e);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(H,{title:`${n} (Your Assistant)`,accessory:(0,Y.jsx)(Q,{role:`assistant`}),compactAccessory:!0}),(0,Y.jsx)(H,{title:`Channels`,subtitle:`Where ${n} can be reached.`,children:(0,Y.jsx)(X,{...t})})]})}function Ee({provenance:e}){return e.source===`global-default`?(0,Y.jsx)(x,{children:`Global default`}):(0,Y.jsxs)(x,{children:[`Default from`,(0,Y.jsx)(n,{asChild:!0,variant:`link`,size:`compact`,className:`h-auto px-0`,children:(0,Y.jsxs)(a,{to:`${ie.channels}?setup=${e.channel}`,children:[`Channels → `,P(e.channel)]})})]})}var $=new Set([`telegram`,`phone`,`vellum`,`whatsapp`,`slack`,`email`,`platform`,`a2a`]);function De(e){return $.has(e)}function Oe(e,t){return e.id===`a2a`?t&&t.status!==`revoked`?{kind:`connected`}:{kind:`setup`}:t!=null&&J(t)?{kind:`verified`}:t?.status===`blocked`?{kind:`none`}:t&&t.status!==`revoked`?{kind:`unverified`}:{kind:`setup`}}function ke(e,t,n){let r=[],i=new Set;if(e)for(let t of e)t.id===`a2a`&&!n||(r.push(t),i.add(t.id));for(let e of t)e.status===`revoked`||i.has(e.type)||e.type===`a2a`&&!n||De(e.type)&&(r.push({id:e.type,label:e.type.charAt(0).toUpperCase()+e.type.slice(1),subtitle:``,icon:`help-circle`,supportsVerification:!1,setupMessages:{guardian:``,contact:``}}),i.add(e.type));return r}function Ae({name:e,className:t,style:n}){switch(e){case`bot`:return(0,Y.jsx)(M,{className:t,style:n});case`hash`:return(0,Y.jsx)(le,{className:t,style:n});case`send`:return(0,Y.jsx)(z,{className:t,style:n});case`phone`:return(0,Y.jsx)(L,{className:t,style:n});case`mail`:return(0,Y.jsx)(oe,{className:t,style:n});case`message-square`:return(0,Y.jsx)(N,{className:t,style:n});default:return(0,Y.jsx)(Se,{className:t,style:n})}}function je({contactChannels:e,availableChannels:t,a2aEnabled:n,channelProvenance:r,setupLabel:i=`Invite`,verifyLoading:a,verifySubject:o=`self`,onSetupChannel:s,onVerifyChannel:c,onRevokeChannel:l,onLinkAccount:u}){let[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),h=new Map;for(let t of e)t.status!==`revoked`&&(h.has(t.type)||h.set(t.type,t));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`flex flex-col`,children:ke(t,e,n).map((e,t)=>{let n=h.get(e.id);return(0,Y.jsxs)(`div`,{children:[t>0&&(0,Y.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),(0,Y.jsx)(Me,{info:e,existing:n,provenance:n&&se(e.id)?r?.[e.id]:void 0,setupLabel:i,verifyLoading:a,onSetup:s?()=>s(e.id):void 0,onVerify:c&&e.supportsVerification?()=>f(e):void 0,onRevoke:l&&n?()=>m({channelId:n.id,channel:e}):void 0,onLinkAccount:u&&q.has(e.id)?()=>u(e.id):void 0})]},e.id)})}),d&&(0,Y.jsx)(T,{open:!0,title:`Verify ${d.label}`,message:o===`contact`?`This will mark this contact's ${d.label} channel as verified. Your assistant will recognize them when they reach out from it.`:`This will mark your ${d.label} channel as verified. Your assistant will recognize you when you reach out from it.`,confirmLabel:`Verify`,onConfirm:()=>{d&&(c?.(d.id),f(null))},onCancel:()=>f(null)}),p&&(0,Y.jsx)(T,{open:!0,title:`Revoke ${p.channel.label}`,message:`This will disconnect the verified channel. The contact will need to re-verify to use this channel again.`,confirmLabel:`Revoke`,destructive:!0,onConfirm:()=>{l?.(p.channelId,p.channel.id),m(null)},onCancel:()=>m(null)})]})}function Me({info:e,existing:t,provenance:r,setupLabel:i,verifyLoading:a,onSetup:o,onVerify:s,onRevoke:c,onLinkAccount:l}){let u=Oe(e,t);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,Y.jsx)(Ae,{name:e.icon,className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),(0,Y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e.label}),t?.address?(0,Y.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:t.address}):null,(0,Y.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[r?(0,Y.jsx)(Ee,{provenance:r}):null,u.kind===`connected`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-8 px-2.5 rounded-md whitespace-nowrap select-none text-body-small-emphasised leading-none bg-[var(--content-default)] text-[var(--surface-base)]`,children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),`Connected`]}),c?(0,Y.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`verified`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-8 px-2.5 rounded-md whitespace-nowrap select-none text-body-small-emphasised leading-none bg-[var(--content-default)] text-[var(--surface-base)]`,children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),`Verified`]}),c?(0,Y.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`unverified`?(0,Y.jsx)(n,{variant:`outlined`,onClick:s,disabled:!s||a,children:a?`Verifying…`:`Verify`}):u.kind===`setup`?e.id===`a2a`?null:(0,Y.jsxs)(Y.Fragment,{children:[l?(0,Y.jsxs)(n,{onClick:l,children:[(0,Y.jsx)(g,{className:`h-3.5 w-3.5`}),`Link account`]}):null,(0,Y.jsx)(n,{variant:`outlined`,onClick:o,disabled:!o,children:i})]}):null]})]})}function Ne(e){return(0,Y.jsx)(Pe,{...e},e.contact.id)}function Pe({contact:e,savePending:t,deletePending:r,verifyPending:i,mergePending:a=!1,canMerge:o=!1,availableChannels:s,a2aEnabled:c,channelProvenance:l,onSave:u,onDelete:d,onMerge:f,onSetupChannel:p,onVerifyChannel:m,onRevokeChannel:h,onLinkAccount:g}){let _=e.displayName===`New Contact`,[v,y]=(0,K.useState)(_?``:e.displayName),[b,x]=(0,K.useState)(e.notes??``),[C,w]=(0,K.useState)(!1),E=v.trim(),ee=b.trim(),D=_?``:e.displayName,te=e.notes??``,O=E!==D||ee!==te,ne=E.length>0&&O&&!t&&!r,k=_&&e.channels.length===0&&e.interactionCount===0,re=E||e.displayName,ie=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(H,{title:re,accessory:(0,Y.jsx)(Q,{role:e.role,contactType:e.contactType}),compactAccessory:!0,subtitle:ie,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(S,{label:`Name`,type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`Give this human a name`,autoFocus:_,disabled:t||r,fullWidth:!0}),(0,Y.jsx)(S,{label:`Notes`,type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Optional notes about the human which AI will take into account`,disabled:t||r,fullWidth:!0}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(n,{type:`button`,onClick:()=>u({displayName:E,notes:ee}),disabled:!ne,children:t?`Saving…`:`Save`}),f?(0,Y.jsx)(n,{type:`button`,variant:`outlined`,onClick:f,disabled:!o||k||O||a||t||r,title:o?k?`Save this contact before merging`:O?`Save your changes before merging`:void 0:`No other contacts available to merge`,children:a?`Merging…`:`Merge…`}):null,(0,Y.jsx)(n,{type:`button`,variant:`danger`,onClick:()=>{k?d():w(!0)},disabled:r,children:r?`Deleting…`:`Delete Contact`})]})]})}),(0,Y.jsx)(H,{title:`Linked accounts`,subtitle:`Where the assistant recognizes this contact. Link accounts you know, invite the ones you don't.`,children:(0,Y.jsx)(je,{contactChannels:e.channels,availableChannels:s,a2aEnabled:c,channelProvenance:l,verifyLoading:i,verifySubject:`contact`,onSetupChannel:p,onVerifyChannel:m,onRevokeChannel:h,onLinkAccount:g})}),(0,Y.jsx)(T,{open:C,title:`Delete ${e.displayName}?`,message:`This will permanently delete this contact and all their channels. This action cannot be undone.`,confirmLabel:`Delete`,destructive:!0,onConfirm:()=>{w(!1),d()},onCancel:()=>w(!1)})]})}function Fe(e){return(0,Y.jsx)(Ie,{...e},`${e.survivor.id}:${e.open?`open`:`closed`}`)}function Ie({open:e,survivor:t,candidates:r,pending:i,errorMessage:a,onMerge:o,onClose:s}){let[c,l]=(0,K.useState)(``),[u,f]=(0,K.useState)(null);(0,K.useEffect)(()=>{u&&!r.some(e=>e.id===u)&&f(null)},[r,u]);let p=(0,K.useMemo)(()=>{let e=c.trim().toLowerCase();return e?r.filter(t=>t.displayName.toLowerCase().includes(e)):r},[r,c]),h=u?r.find(e=>e.id===u)??null:null,g=Ve(t);return(0,Y.jsx)(C.Root,{open:e,onOpenChange:e=>{!e&&!i&&s()},children:(0,Y.jsxs)(C.Content,{size:`md`,children:[(0,Y.jsxs)(C.Header,{children:[(0,Y.jsx)(C.Title,{icon:Ce,children:h?`Merge "${h.displayName}" into ${g}?`:`Merge another contact into ${g}`}),(0,Y.jsx)(C.Description,{children:h?`Channels and notes from the merged contact will move over. The merged contact will be deleted.`:`The contact you pick will be deleted. Its channels and notes will be added to this one.`})]}),(0,Y.jsxs)(C.Body,{className:`flex flex-col gap-3`,children:[h?(0,Y.jsx)(ze,{survivor:t,donor:h}):r.length===0?(0,Y.jsx)(Be,{}):(0,Y.jsx)(Le,{search:c,onSearch:l,candidates:p,onPick:f}),a?(0,Y.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-(--system-negative-strong)`,role:`alert`,children:a}):null]}),(0,Y.jsx)(C.Footer,{children:h?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(n,{variant:`outlined`,onClick:()=>f(null),disabled:i,leftIcon:(0,Y.jsx)(m,{"aria-hidden":!0}),children:`Back`}),(0,Y.jsx)(n,{variant:`danger`,onClick:()=>o(h.id),disabled:i,children:i?`Merging…`:`Merge`})]}):(0,Y.jsx)(n,{variant:`outlined`,onClick:s,disabled:i,children:`Cancel`})})]})})}function Le({search:e,onSearch:t,candidates:n,onPick:r}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search contacts`,leftIcon:(0,Y.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}),(0,Y.jsx)(`div`,{className:`flex max-h-[320px] min-h-[120px] flex-col gap-1 overflow-y-auto`,role:`listbox`,"aria-label":`Select a contact to merge`,children:n.length===0?(0,Y.jsx)(d,{as:`p`,variant:`body-small-default`,className:`px-3 py-4 text-center text-(--content-tertiary)`,children:`No matching contacts`}):n.map(e=>(0,Y.jsx)(Re,{contact:e,onPick:()=>r(e.id)},e.id))})]})}function Re({contact:e,onPick:t}){let n=Ge(e).join(` | `)||void 0;return(0,Y.jsx)(h,{asChild:!0,label:``,children:(0,Y.jsx)(`button`,{type:`button`,onClick:t,role:`option`,"aria-selected":`false`,className:`flex h-auto w-full items-center gap-2 rounded-[6px] px-[8px] py-2 text-left`,children:(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e.displayName}),n?(0,Y.jsx)(`span`,{className:`truncate text-body-small-default text-(--content-tertiary)`,children:n}):null]})})})}function ze({survivor:e,donor:t}){let n=Ve(e),{moved:r,duplicates:i}=We(e,t);return(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-2 text-body-medium-lighter text-(--content-secondary)`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`span`,{className:`text-(--content-default)`,children:[`“`,t.displayName,`”`]}),` `,`will be deleted.`]}),(0,Y.jsx)(`li`,{children:r.length===0?`No new channels will move to ${n}.`:`${r.length} channel${r.length===1?``:`s`} will move to ${n}: ${r.map(e=>Ue(e.type)).join(`, `)}.`}),i.length>0?(0,Y.jsxs)(`li`,{className:`text-(--content-tertiary)`,children:[i.length,` duplicate channel`,i.length===1?``:`s`,` already on `,n,` `,`(skipped).`]}):null,t.notes?(0,Y.jsx)(`li`,{children:`Notes from the merged contact will be appended.`}):null,(0,Y.jsx)(`li`,{className:`text-(--content-tertiary)`,children:`This cannot be undone.`})]})}function Be(){return(0,Y.jsx)(d,{as:`p`,variant:`body-medium-lighter`,className:`px-3 py-6 text-center text-(--content-tertiary)`,children:`No other contacts available to merge.`})}function Ve(e){return e.role===`guardian`?!e.displayName||e.displayName.startsWith(`vellum-principal-`)?`you`:`${e.displayName} (you)`:e.displayName||`this contact`}var He={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`};function Ue(e){return He[e.toLowerCase()]??e}function We(e,t){let n=[],r=[];for(let i of t.channels)i.status!==`revoked`&&(e.channels.some(e=>e.type===i.type&&e.address.toLowerCase()===i.address.toLowerCase())?r.push(i):n.push(i));return{moved:n,duplicates:r}}function Ge(e){let t=new Set,n=[];for(let r of e.channels){if(r.status===`revoked`)continue;let e=r.type.toLowerCase();t.has(e)||(t.add(e),n.push(He[e]??r.type))}return n}function Ke({loading:e,guardian:t,assistantName:r,regularContacts:i,selection:a,onSelect:o,onAddContact:s,addingContact:c=!1}){let[l,u]=(0,K.useState)(``),d=l.trim()?i.filter(e=>e.displayName.toLowerCase().includes(l.trim().toLowerCase())):i;return(0,Y.jsx)(f.Root,{className:`flex h-full flex-col overflow-hidden`,children:(0,Y.jsxs)(f.Body,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:`Entries`}),(0,Y.jsx)(n,{type:`button`,variant:`ghost`,iconOnly:c?(0,Y.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(y,{"aria-hidden":!0}),onClick:s,disabled:c,"aria-label":`Add contact`,tintColor:`var(--content-secondary)`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t?(0,Y.jsx)(qe,{name:t.displayName?`${t.displayName} (You)`:`You`,role:t.role,channelTypes:t.channelTypes,selected:a?.kind===`contact`&&a.contactId===t.id,onClick:()=>o({kind:`contact`,contactId:t.id}),trailingIcon:`pencil`}):null,(0,Y.jsx)(qe,{name:r?.trim()||`Your Assistant`,role:`assistant`,selected:a?.kind===`assistant`,onClick:()=>o({kind:`assistant`}),trailingIcon:`more`})]}),(0,Y.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),i.length>0?(0,Y.jsx)(S,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search Contacts`,leftIcon:(0,Y.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}):null,i.length>0?(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto flex flex-col gap-1`,children:[d.map(e=>(0,Y.jsx)(qe,{name:e.displayName,role:e.role,contactType:e.contactType,channelTypes:e.channelTypes,verified:e.verified,selected:a?.kind===`contact`&&a.contactId===e.id,onClick:()=>o({kind:`contact`,contactId:e.id}),trailingIcon:`more`},e.id)),d.length===0?(0,Y.jsx)(`p`,{className:`px-3 py-4 text-center text-body-small-default`,style:{color:`var(--content-tertiary)`},children:`No matching contacts`}):null]}):e?null:(0,Y.jsx)(n,{type:`button`,variant:`ghost`,onClick:s,disabled:c,tintColor:`var(--primary-base)`,leftIcon:c?(0,Y.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(b,{"aria-hidden":!0}),children:`Add Contact`})]})})}function qe({name:e,role:t,contactType:n,channelTypes:r,selected:i,onClick:a,trailingIcon:o,verified:s}){let c=r&&r.length>0?r.join(` | `):void 0;return(0,Y.jsx)(h,{asChild:!0,active:i,label:``,trailingAction:o===`pencil`?(0,Y.jsx)(v,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):o===`more`?(0,Y.jsx)(G,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):void 0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:a,className:`flex h-auto w-full items-center gap-2 rounded-[6px] px-[8px] py-2 text-left`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e}),c?(0,Y.jsx)(`span`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:c}):null]}),(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[s===void 0?null:(0,Y.jsx)(x,{tone:s?`positive`:`neutral`,children:s?`Verified`:`Unverified`}),(0,Y.jsx)(Q,{role:t,contactType:n})]})]})})}function Je(e){return(0,Y.jsx)(Ye,{...e},e.contact.id)}function Ye({contact:e,savePending:t,verifyPending:r,mergePending:i=!1,canMerge:a=!1,availableChannels:o,a2aEnabled:s,onSave:c,onMerge:l,onSetupChannel:u,onVerifyChannel:d,onRevokeChannel:f,onGenerateInviteLink:p}){let m=e.displayName.startsWith(`vellum-principal-`),h=m?``:e.displayName,[g,_]=(0,K.useState)(h),[v,y]=(0,K.useState)(e.notes??``),b=g.trim(),x=v.trim(),C=b!==h.trim()||x!==(e.notes??``).trim(),w=C&&!t,T=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(H,{title:m?`You`:`${e.displayName} (You)`,accessory:(0,Y.jsx)(Q,{role:`guardian`}),compactAccessory:!0,subtitle:T,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(S,{label:`Name`,type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Your name`,disabled:t,fullWidth:!0}),(0,Y.jsx)(S,{label:`Notes`,type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`Notes about yourself which AI will take into account`,disabled:t,fullWidth:!0}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(n,{variant:`primary`,onClick:()=>c({displayName:b||e.displayName,notes:x}),disabled:!w,children:t?`Saving…`:`Save`}),l?(0,Y.jsx)(n,{variant:`outlined`,onClick:l,disabled:!a||C||i||t,title:a?C?`Save your changes before merging`:void 0:`No other contacts available to merge`,children:i?`Merging…`:`Merge…`}):null]})]})}),(0,Y.jsx)(H,{title:`Channels`,subtitle:`Once verified, your assistant will recognize you when you message from these channels.`,children:(0,Y.jsx)(je,{contactChannels:e.channels,availableChannels:o,a2aEnabled:s,setupLabel:`Verify me`,verifyLoading:r,onSetupChannel:u,onVerifyChannel:d,onRevokeChannel:f})}),p?(0,Y.jsx)(de,{onClick:p}):null]})}function Xe(e,t){let n=t.trim().toLowerCase().replace(/^@/,``);return n===``?e:e.filter(e=>e.displayName.toLowerCase().includes(n)||e.username.toLowerCase().includes(n))}function Ze(e){let t=e.trim().split(/\s+/).filter(Boolean);return`${t[0]?.[0]??`?`}${t.length>1?t[t.length-1]?.[0]??``:``}`.toUpperCase()}function Qe({open:e,channelLabel:t,contactName:r,accounts:i,loading:a,errorMessage:o,pendingAccountId:s,onPick:c,onClose:l,onInviteInstead:u}){let[d,f]=(0,K.useState)(``);(0,K.useEffect)(()=>{e&&f(``)},[e]);let p=(0,K.useMemo)(()=>Xe(i??[],d),[i,d]),m=s!=null;return(0,Y.jsx)(C.Root,{open:e,onOpenChange:e=>!e&&l(),children:(0,Y.jsxs)(C.Content,{size:`sm`,children:[(0,Y.jsxs)(C.Header,{children:[(0,Y.jsxs)(C.Title,{children:[`Link `,t,` account`]}),(0,Y.jsxs)(C.Description,{children:[`Search your `,t,` workspace and pick`,` `,(0,Y.jsx)(`span`,{className:`text-[color:var(--content-default)]`,children:r}),`’s account.`]})]}),(0,Y.jsxs)(C.Body,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(S,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search by name or @handle`,"aria-label":`Search ${t} workspace accounts`,leftIcon:(0,Y.jsx)(A,{className:`h-4 w-4`}),fullWidth:!0}),o?(0,Y.jsx)(`p`,{className:`text-body-small-default text-[color:var(--content-negative)]`,children:o}):null,(0,Y.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:a?(0,Y.jsx)(`p`,{className:`py-4 text-center text-body-small-default text-[color:var(--content-tertiary)]`,children:`Loading workspace members…`}):p.length===0?(0,Y.jsx)(`p`,{className:`py-4 text-center text-body-small-default text-[color:var(--content-tertiary)]`,children:(i?.length??0)===0?`No workspace members found.`:`No members match.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:p.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(e),disabled:m,className:`flex w-full cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-left transition-colors hover:bg-[var(--surface-overlay)] disabled:cursor-not-allowed disabled:opacity-60`,children:[e.imageUrl?(0,Y.jsx)(`img`,{src:e.imageUrl,alt:``,className:`h-8 w-8 shrink-0 rounded-full`}):(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[var(--tag-bg-neutral)] text-body-small-emphasised text-[color:var(--content-secondary)]`,children:Ze(e.displayName)}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-body-medium-default text-[color:var(--content-default)]`,children:e.displayName}),(0,Y.jsxs)(`span`,{className:`truncate text-body-small-default text-[color:var(--content-tertiary)]`,children:[`@`,e.username]})]}),s===e.id?(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:`Linking…`}):null]})},e.id))})})]}),(0,Y.jsxs)(C.Footer,{className:`items-center justify-between gap-3 border-t border-[var(--border-base)]`,children:[(0,Y.jsxs)(`p`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:[`Picking marks this account as`,` `,(0,Y.jsx)(`span`,{className:`text-[color:var(--content-secondary)]`,children:`guardian-linked`}),` `,`— you vouch for the identity, no handshake needed.`]}),u?(0,Y.jsxs)(n,{variant:`link`,className:`shrink-0`,onClick:u,disabled:m,children:[`Or send an invite instead`,(0,Y.jsx)(j,{className:`h-3.5 w-3.5`})]}):null]})]})})}function $e(e){let t={};for(let n of e)se(n.channelType)&&(t[n.channelType]=n.policy===`trusted_contacts`?{source:`global-default`}:{source:`channel-default`,channel:n.channelType});return t}function et(e){return $e(V(e))}function tt(e){let t=ae.use.channelTrustFloors(),n=he(),r=t&&n,i=c({...F({path:{assistant_id:e}}),enabled:r,select:et});return r?i.data:void 0}function nt({assistantId:e,channelType:t,contact:n,onLinked:r}){let[i,a]=(0,K.useState)(!1),o=l({mutationFn:n=>W(e,n.contact,{type:t,address:n.account.id}),onSuccess:(e,t)=>{a(!1),w.success(`Linked as @${t.account.username}`),r()}}),s=(0,K.useCallback)(()=>{o.reset(),a(!0)},[o]),c=(0,K.useCallback)(()=>{o.isPending||(o.reset(),a(!1))},[o]),u=(0,K.useCallback)(e=>{!n||o.isPending||o.mutate({contact:n,account:e})},[n,o]);return{channelType:t,dialogOpen:i,open:s,close:c,linkErrorMessage:o.error instanceof Error?o.error.message:o.error?`Failed to link account`:null,pendingAccountId:o.isPending?o.variables.account.id:null,pick:u}}var rt=[{id:`slack`,label:`Slack`,subtitle:`Message your assistant from Slack`,icon:`hash`,supportsVerification:!0,setupMessages:{guardian:`I'd like to verify my identity as your guardian on Slack. Can you help me set that up?`,contact:`I'd like to verify a contact's Slack identity. Can you walk me through it?`}},{id:`telegram`,label:`Telegram`,subtitle:`Message your assistant from Telegram`,icon:`send`,supportsVerification:!0,setupMessages:{guardian:`I'd like to verify my identity as your guardian on Telegram. Can you help me set that up?`,contact:`I'd like to verify a contact's Telegram identity. Can you walk me through it?`}},{id:`phone`,label:`Phone Calling`,subtitle:`Call or text your assistant via phone`,icon:`phone`,supportsVerification:!0,setupMessages:{guardian:`I'd like to verify my identity as your guardian for phone calls. Can you help me set that up?`,contact:`I'd like to verify a contact's phone number. Can you help me set that up?`}}],it=[];function at({assistantId:e,onStartSetupConversation:t}){let n=ae.use.a2aChannel(),a=re.use.name(),o=s(),[u]=r(),d=u.get(`setup`),f=d&&se(d)?d:null,[p,m]=(0,K.useState)({kind:`assistant`}),h=ge(e),[g,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(!1),b=fe(a),x=(0,K.useMemo)(()=>({path:{assistant_id:e}}),[e]),S=k(x),C=c({...ne(x),enabled:!!e,select:e=>e.contacts}),T=pe({assistantId:e,onStartSetupConversation:t}),oe=tt(e),A=c({...O({path:{assistant_id:e}}),enabled:!!e,queryFn:async({signal:t})=>{let{data:n,error:r,response:i}=await E({path:{assistant_id:e},signal:t,throwOnError:!1});if(!i||i.status===404)return{channels:rt};if(!i.ok)throw r??Error(`Failed to fetch channel availability`);return n},select:e=>e.channels}).data??it,j=C.data,M=(0,K.useMemo)(()=>j?.find(e=>e.role===`guardian`)??null,[j]),ce=(0,K.useMemo)(()=>j?.filter(e=>e.role!==`guardian`)??[],[j]),N=(0,K.useMemo)(()=>p.kind===`contact`?j?.find(e=>e.id===p.contactId)??null:null,[j,p]),P=(0,K.useMemo)(()=>!j||!N?[]:j.filter(e=>e.id!==N.id&&e.role!==`guardian`),[j,N]),F=P.length>0,le=(0,K.useRef)(!!f);(0,K.useEffect)(()=>{le.current||M&&(le.current=!0,m({kind:`contact`,contactId:M.id}))},[M]);let I=(0,K.useCallback)(()=>o.invalidateQueries({queryKey:S}),[o,S]),L=l({mutationFn:()=>be(e,{displayName:`New Contact`}),onMutate:async()=>{await o.cancelQueries({queryKey:S})},onSuccess:e=>{D(o,x,t=>t?{...t,contacts:[...t.contacts,e]}:void 0),m({kind:`contact`,contactId:e.id})},onError:U(`Failed to create contact`),onSettled:()=>I()}),R=l({mutationFn:t=>xe(e,t),onSuccess:(e,t)=>{D(o,x,e=>e?{...e,contacts:e.contacts.filter(e=>e.id!==t)}:void 0),m({kind:`assistant`})},onError:U(`Failed to delete contact`),onSettled:()=>I()}),z=l({mutationFn:({contactId:t,patch:n})=>be(e,{id:t,displayName:n.displayName,notes:n.notes}),onSuccess:e=>{D(o,x,t=>t?{...t,contacts:t.contacts.map(t=>t.id===e.id?e:t)}:void 0)},onError:U(`Failed to save contact`),onSettled:()=>I()}),B=te({onMutate:async()=>{await o.cancelQueries({queryKey:S})},onSuccess:(e,t)=>{let n=e.contact,r=t.body.mergeId;n&&(D(o,x,e=>e?{...e,contacts:e.contacts.filter(e=>e.id!==r).map(e=>e.id===n.id?n:e)}:void 0),m({kind:`contact`,contactId:n.id})),y(!1),w.success(`Contacts merged`)},onSettled:()=>I()}),de=(0,K.useCallback)(e=>{m(e),_(!1),y(!1),B.reset()},[B]),V=(0,K.useCallback)(()=>{B.reset(),y(!0)},[B]),he=(0,K.useCallback)(()=>{B.isPending||(y(!1),B.reset())},[B]),H=ee({onSuccess:()=>I()}),W=(0,K.useCallback)((t,n)=>{H.mutate({path:{assistant_id:e,contactChannelId:t},body:{status:`revoked`}})},[H,e]),Se=(0,K.useCallback)(()=>{L.isPending||L.mutate()},[L]),G=(0,K.useCallback)(e=>{if(!t)return;let n=A.find(t=>t.id===e)?.setupMessages.contact;n&&t(n)},[A,t]),Ce=(0,K.useCallback)(e=>{if(!t)return;let n=A.find(t=>t.id===e)?.setupMessages.guardian;n&&t(n)},[A,t]),q=l({mutationFn:t=>ye(e,t.channelId),onSuccess:()=>I(),onError:U(`Failed to verify channel`)}),J=(0,K.useCallback)(e=>{if(!N)return;let t=N.channels.find(t=>t.type===e&&t.status!==`revoked`);t&&q.mutate({channelId:t.id})},[N,q]),X=nt({assistantId:e,channelType:`slack`,contact:N?{id:N.id,displayName:N.displayName}:null,onLinked:I}),Z=c({...ue(e),enabled:!!e&&X.dialogOpen,select:e=>e.users}),Q=T.channels.some(e=>e.key===`slack`&&e.status===`ready`),we=(0,K.useCallback)(e=>{e===X.channelType&&X.open()},[X]),Ee=R.isPending?R.variables:null,$=(0,K.useMemo)(()=>N?z.isPending&&z.variables?.contactId===N.id?{...N,displayName:z.variables.patch.displayName,notes:z.variables.patch.notes}:N:null,[N,z.isPending,z.variables]);if(f)return(0,Y.jsx)(i,{to:`${ie.channels}?setup=${f}`,replace:!0});let De={loading:C.isLoading,assistantName:b,guardian:M?{id:M.id,displayName:M.displayName.startsWith(`vellum-principal-`)?``:M.displayName,role:M.role,channelTypes:lt(M.channels,n)}:null,regularContacts:ce.filter(e=>e.id!==Ee).map(e=>({id:e.id,displayName:e.displayName,role:e.role,contactType:e.contactType,channelTypes:lt(e.channels,n),verified:ct(e.channels)})),selection:p,onAddContact:Se,addingContact:L.isPending};return(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden sm:flex-row sm:gap-6`,children:[(0,Y.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,Y.jsx)(_e,{onClick:()=>_(!0)})}),(0,Y.jsx)(ve,{open:g,onClose:()=>_(!1),title:`Contacts`,children:(0,Y.jsx)(Ke,{...De,onSelect:de})}),(0,Y.jsx)(`aside`,{className:`hidden min-h-0 w-[320px] shrink-0 overflow-y-auto self-stretch sm:block`,children:(0,Y.jsx)(Ke,{...De,onSelect:de})}),(0,Y.jsx)(`section`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:p.kind===`assistant`||p.kind===`contact`&&p.contactId===Ee?(0,Y.jsx)(Te,{assistantName:b,channels:T.channels,pendingChannelKey:T.pendingChannelKey,onConnect:T.onSetup,onDisconnect:T.onDisconnect}):$?$.role===`guardian`?(0,Y.jsx)(Je,{contact:$,savePending:z.isPending,verifyPending:q.isPending,mergePending:B.isPending,canMerge:F,availableChannels:A,a2aEnabled:n,onSave:e=>{z.mutate({contactId:$.id,patch:e})},onMerge:V,onSetupChannel:t?Ce:void 0,onVerifyChannel:J,onRevokeChannel:W,onGenerateInviteLink:n?h.open:void 0}):(0,Y.jsx)(Ne,{contact:$,savePending:z.isPending,deletePending:R.isPending,verifyPending:q.isPending,mergePending:B.isPending,canMerge:F,availableChannels:A,a2aEnabled:n,channelProvenance:oe,onSave:e=>{z.mutate({contactId:$.id,patch:e})},onDelete:()=>{R.mutate($.id)},onMerge:V,onSetupChannel:t?G:void 0,onVerifyChannel:J,onRevokeChannel:W,onLinkAccount:Q?we:void 0}):(0,Y.jsx)(ot,{})}),N?(0,Y.jsx)(Fe,{open:v,survivor:N,candidates:P,pending:B.isPending,errorMessage:B.error instanceof Error?B.error.message:B.error?`Failed to merge contacts`:null,onMerge:t=>B.mutate({path:{assistant_id:e},body:{keepId:N.id,mergeId:t}}),onClose:he}):null,(0,Y.jsx)(Qe,{open:X.dialogOpen,channelLabel:`Slack`,contactName:N?.displayName??``,accounts:Z.data,loading:Z.isLoading,errorMessage:Z.isError?`Couldn’t load the workspace roster. Check the Slack connection and try again.`:X.linkErrorMessage,pendingAccountId:X.pendingAccountId,onPick:X.pick,onClose:X.close,onInviteInstead:t?()=>{X.close(),G(X.channelType)}:void 0}),(0,Y.jsx)(me,{open:h.isOpen,assistantId:e,onClose:h.close})]})}function ot(){return(0,Y.jsx)(`div`,{className:`flex h-full items-center justify-center py-16`,children:(0,Y.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a contact`})})}var st={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`,a2a:`A2A`};function ct(e){return e.some(e=>e.status!==`revoked`&&(e.type===`a2a`||J(e)))}function lt(e,t){let n=new Set,r=[];for(let i of e){if(i.status===`revoked`)continue;let e=i.type.toLowerCase();n.has(e)||e===`a2a`&&!t||(n.add(e),r.push(st[e]??i.type))}return r}function ut(){let e=o(),t=B();return(0,Y.jsx)(at,{assistantId:t,onStartSetupConversation:t=>{ce(e,{prompt:t})}},t)}export{ut as ContactsPageRoute};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{r as t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-BQVYX8n_.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./card-D8zyWtZh.js";import{t as c}from"./check-wF3S-AV4.js";import{t as l}from"./chevron-down-DpYf9Gwq.js";import{n as u,t as d}from"./panel-item-An-BBeyL.js";import{o as f}from"./list-row-CFyYr-FU.js";import{t as p}from"./eye-off-BQ9J3pF2.js";import{t as m}from"./eye-C2rSrbD-.js";import{t as h}from"./key-round-CN4UKztQ.js";import{t as g}from"./link-2-B9c5ZsFq.js";import{t as _}from"./loader-circle-Ck8fq3yv.js";import{t as v}from"./plus-DZZypDUF.js";import{j as y}from"./src-CheJrlfT.js";import{t as ee}from"./tag-B6WeUtBW.js";import{t as b}from"./popover-Bl6742nZ.js";import{t as x}from"./input-ZpyYt_a0.js";import{t as S}from"./modal-BtcwNEBj.js";import{n as C}from"./toast-Be8FEQ-I.js";import{t as te}from"./confirm-dialog-Zyfei9GV.js";import{Ur as w,dt as T,ut as ne}from"./sdk.gen-zsiNChRm.js";import{Gt as re,Wt as ie}from"./react-query.gen-C0S0EYHV.js";import{t as ae}from"./use-is-org-ready-DKJvP9Ky.js";import{t as E}from"./assistant-feature-flag-store-aNAjw1qx.js";import{Ao as D,Bo as oe,Ea as O,t as k}from"./index-D7_9Qy0L.js";import{t as se}from"./use-active-assistant-id-DwLFgABu.js";import{t as ce}from"./detail-card-CIh4dCKt.js";var A=e(n(),1),j=o(),M=1500;function N(e){if(!e)return``;try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return``}}function le({credential:e,assistantId:t,canGenerateLink:n,generatingLink:r,deleting:i,onGenerateLink:a,onDelete:o}){let c=`${e.service}:${e.field}`,[l,u]=(0,A.useState)(!1),d=[e.alias?c:null,e.createdAt?`added ${N(e.createdAt)}`:null].filter(e=>!!e);return(0,j.jsx)(s.Root,{children:(0,j.jsxs)(s.Body,{padding:`sm`,className:`flex items-center gap-4 px-4`,children:[(0,j.jsx)(h,{className:`h-5 w-5 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`p`,{className:`truncate text-title-small text-[var(--content-default)]`,children:e.alias||c}),(0,j.jsx)(`div`,{className:`mt-0.5 flex min-w-0 items-center`,children:(0,j.jsx)(P,{assistantId:t,credential:e})}),d.length>0&&(0,j.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-body-medium-lighter text-[var(--content-tertiary)]`,children:d.join(` · `)})]}),(0,j.jsx)(`div`,{className:`shrink-0`,children:(0,j.jsx)(F,{name:c,open:l,onOpenChange:u,canGenerateLink:n,generatingLink:r,deleting:i,onGenerateLink:()=>{u(!1),a()},onDelete:()=>{u(!1),o()}})})]})})}function P({assistantId:e,credential:t}){let[n,r]=(0,A.useState)(null),[i,a]=(0,A.useState)(!1),[o,s]=(0,A.useState)(!1),l=(0,A.useRef)(null),u=(0,A.useRef)(0),d=`${t.service}:${t.field}`,h=(0,A.useCallback)(()=>{u.current++,r(null),a(!1),s(!1),l.current&&=(clearTimeout(l.current),null)},[]);(0,A.useEffect)(()=>{h()},[t.updatedAt,h]);let g=(0,A.useCallback)(async()=>{let n=++u.current;a(!0);try{let{data:i}=await T({path:{assistant_id:e},body:{service:t.service,field:t.field},throwOnError:!0});u.current===n&&r(i.value)}catch{u.current===n&&C.error(`Couldn't reveal ${d}.`)}finally{u.current===n&&a(!1)}},[e,t.service,t.field,d]),v=(0,A.useCallback)(()=>{n!=null&&navigator.clipboard.writeText(n).then(()=>{s(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>s(!1),M)},()=>C.error(`Couldn't copy — reveal and copy manually.`))},[n]),y=n!==null;return t.hasSecret?(0,j.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 align-middle font-mono text-body-medium-lighter`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>y?h():void g(),disabled:i,"aria-label":y?`Hide value for ${d}`:`Reveal value for ${d}`,title:y?`Hide value`:`Click to reveal`,"data-private":!0,className:`min-w-0 truncate rounded-sm text-left transition-[filter,color] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--border-focus)] ${y?`text-[var(--content-secondary)]`:`select-none text-[var(--content-tertiary)] blur-[3px] hover:blur-[2px]`}`,children:y?n:t.scrubbedValue}),i?(0,j.jsx)(_,{className:`h-3.5 w-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):y?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,onClick:v,"aria-label":`Copy value for ${d}`,title:`Copy value`,className:`shrink-0 rounded-sm p-0.5 text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--border-focus)]`,children:o?(0,j.jsx)(c,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):(0,j.jsx)(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,j.jsx)(`button`,{type:`button`,onClick:h,"aria-label":`Hide value for ${d}`,title:`Hide value`,className:`shrink-0 rounded-sm p-0.5 text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--border-focus)]`,children:(0,j.jsx)(p,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]}):(0,j.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":`Reveal value for ${d}`,title:`Click to reveal`,className:`shrink-0 rounded-sm p-0.5 text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--border-focus)]`,children:(0,j.jsx)(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]}):(0,j.jsx)(`span`,{className:`min-w-0 truncate font-mono text-body-medium-lighter text-[var(--content-tertiary)]`,children:t.scrubbedValue})}function F({name:e,open:t,onOpenChange:n,canGenerateLink:i,generatingLink:a,deleting:o,onGenerateLink:s,onDelete:c}){let f=O(),p=a||o,m=(0,j.jsx)(r,{variant:`outlined`,rightIcon:(0,j.jsx)(l,{}),"aria-haspopup":`menu`,"aria-expanded":t,"aria-label":`Configure ${e}`,leftIcon:p?(0,j.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):void 0,children:`Configure`});return f?(0,j.jsxs)(u.Root,{open:t,onOpenChange:n,children:[(0,j.jsx)(u.Trigger,{asChild:!0,children:m}),(0,j.jsxs)(u.Content,{children:[(0,j.jsx)(u.Header,{children:(0,j.jsx)(u.Title,{children:e})}),(0,j.jsxs)(u.Body,{children:[i&&(0,j.jsx)(d,{icon:a?_:g,label:`Generate link`,onSelect:()=>{p||s()}}),(0,j.jsx)(d,{icon:o?_:D,label:`Delete`,onSelect:()=>{p||c()}})]})]})]}):(0,j.jsxs)(b.Root,{open:t,onOpenChange:n,children:[(0,j.jsx)(b.Trigger,{asChild:!0,children:m}),(0,j.jsxs)(b.Content,{align:`end`,sideOffset:4,role:`menu`,className:`w-56 overflow-hidden p-0`,children:[i&&(0,j.jsx)(r,{type:`button`,role:`menuitem`,variant:`ghost`,onClick:s,disabled:p,className:`w-full justify-start rounded-none`,leftIcon:a?(0,j.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):(0,j.jsx)(g,{"aria-hidden":!0}),children:`Generate link`}),(0,j.jsx)(r,{type:`button`,role:`menuitem`,variant:`dangerGhost`,onClick:c,disabled:p,className:`w-full justify-start rounded-none`,leftIcon:o?(0,j.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):(0,j.jsx)(D,{"aria-hidden":!0}),children:`Delete`})]})]})}function ue(e){return e>0xe8d4a51000?e:e*1e3}async function de(e,t){let{data:n,response:r}=await w.post({url:`/v1/assistants/{assistant_id}/credential-requests`,path:{assistant_id:e},body:t});if(!r?.ok)throw Error(`Failed to create credential request: ${r?.status}`);return n}function fe(e){return[`credentials-list`,e]}var I=6;function L(){let e=E.use.credentialsSettings(),t=E.use.hasHydrated();return t&&!e?(0,j.jsx)(k,{}):t?(0,j.jsx)(R,{}):null}function R(){let e=se(),n=i(),o=ae(),c=E.use.credentialRequests(),l=fe(e),u=a({queryKey:l,queryFn:async()=>{let{data:t}=await ne({path:{assistant_id:e},body:{},throwOnError:!0});return{credentials:t.credentials,managedCredentials:t.managedCredentials}},enabled:o,retry:t}),d=(0,A.useMemo)(()=>u.data?.credentials??[],[u.data]),p=(0,A.useMemo)(()=>u.data?.managedCredentials??[],[u.data]),m=re({onSuccess:()=>{n.invalidateQueries({queryKey:l}),C.success(`Credential saved.`)},onError:e=>{C.error(e.message||`Failed to save credential`)}}),b=ie({onError:e=>{C.error(e.message||`Failed to delete credential`)}}),[w,T]=(0,A.useState)(!1),[D,O]=(0,A.useState)(`own`),[k,M]=(0,A.useState)(``),[N,P]=(0,A.useState)(``),[F,L]=(0,A.useState)(``),[R,z]=(0,A.useState)(``),[B,V]=(0,A.useState)(``),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(null),[pe,K]=(0,A.useState)(null),q=m.isPending,me=b.isPending?`${b.variables?.body?.service}:${b.variables?.body?.field}`:null,J=(0,A.useMemo)(()=>{let e=k.trim().toLowerCase();return e?d.filter(t=>[t.service,t.field,`${t.service}:${t.field}`,t.alias??``].join(` `).toLowerCase().includes(e)):d},[d,k]);(0,A.useEffect)(()=>{d.length<=I&&M(``)},[d.length]),(0,A.useEffect)(()=>{d.length===0&&p.length>0&&O(`managed`)},[d.length,p.length]);let Y=()=>{T(!1),P(``),L(``),z(``),V(``)},he=t=>{t?.preventDefault();let n=N.trim(),r=F.trim();!n||!r||!R.trim()||m.mutate({path:{assistant_id:e},body:{service:n,field:r,value:R,label:B.trim()||void 0}},{onSuccess:Y})},X=()=>{let t=H;U(null),t&&b.mutate({path:{assistant_id:e},body:{service:t.service,field:t.field}},{onSuccess:()=>{n.invalidateQueries({queryKey:l}),C.success(`Deleted ${t.service}:${t.field}.`)}})},ge=async t=>{let n=`${t.service}:${t.field}`;K(n);try{let r=await de(e,{service:t.service,field:t.field,label:t.alias??void 0});r.ok&&r.url?G({name:n,url:r.url,expiresAt:r.expiresAt??null}):C.error(r.error||`Failed to generate a one-time link`)}catch(e){C.error(e instanceof Error?e.message:`Failed to generate a one-time link`)}finally{K(null)}},_e=()=>{let e=W?.url;e&&navigator.clipboard.writeText(e).then(()=>C.success(`Link copied to clipboard.`),()=>C.error(`Couldn't copy the link — select it and copy manually.`))};if(u.isLoading)return(0,j.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,j.jsx)(_,{className:`h-5 w-5 animate-spin text-[var(--content-disabled)]`})});let Z=d.length>0,Q=p.length>0,ve=d.length>I,$=D===`managed`&&Q;return(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(ce,{title:`Credentials`,subtitle:$?`Provided through your Vellum-managed integrations. These are read-only here.`:`Stored encrypted in your assistant's credential vault. Reveal a value on demand, or replace or delete it at any time.`,accessory:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Q?(0,j.jsx)(y,{items:[{value:`own`,label:`Your own`},{value:`managed`,label:`Managed`}],value:D,onChange:O,ariaLabel:`Credential source`}):null,!$&&Z?(0,j.jsx)(r,{type:`button`,variant:`primary`,size:`regular`,onClick:()=>T(!0),leftIcon:(0,j.jsx)(v,{"aria-hidden":!0}),children:`Add`}):null]}),children:$?(0,j.jsx)(`div`,{className:`space-y-2`,children:p.map(e=>(0,j.jsx)(s.Root,{children:(0,j.jsxs)(s.Body,{padding:`sm`,className:`flex items-center gap-4 px-4`,children:[(0,j.jsx)(h,{className:`h-5 w-5 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`p`,{className:`truncate text-title-small text-[var(--content-default)]`,children:e.provider}),(0,j.jsxs)(`p`,{className:`truncate text-body-medium-lighter text-[var(--content-tertiary)]`,children:[e.accountInfo??e.handle,` · `,e.status]})]}),(0,j.jsx)(ee,{tone:`neutral`,children:`Managed`})]})},e.handle))}):(0,j.jsxs)(`div`,{className:`space-y-4`,children:[Z?(0,j.jsxs)(`div`,{className:`space-y-3`,children:[ve?(0,j.jsx)(x,{type:`text`,value:k,onChange:e=>M(e.target.value),placeholder:`Search credentials`,"aria-label":`Search credentials`,leftIcon:(0,j.jsx)(oe,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}):null,J.length===0?(0,j.jsxs)(`p`,{className:`px-1 py-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[`No credentials matched “`,k.trim(),`”.`]}):(0,j.jsx)(`div`,{className:`space-y-2`,children:J.map(t=>{let n=`${t.service}:${t.field}`;return(0,j.jsx)(le,{credential:t,assistantId:e,canGenerateLink:c,generatingLink:pe===n,deleting:me===n,onGenerateLink:()=>void ge(t),onDelete:()=>U(t)},t.credentialId??n)})})]}):(0,j.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-6 py-12 text-center`,children:[(0,j.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,j.jsx)(h,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`,"aria-hidden":!0})}),(0,j.jsx)(`h3`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No credentials yet`}),(0,j.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Add an API key or token to let tools and integrations use it.`})]}),Z?null:(0,j.jsx)(r,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>T(!0),className:`w-full border-dashed`,leftIcon:(0,j.jsx)(v,{"aria-hidden":!0}),children:`Add Credential`})]})}),(0,j.jsx)(te,{open:H!==null,title:`Delete credential`,message:H?`Delete ${H.service}:${H.field}? Tools and integrations using it will lose access.`:``,confirmLabel:`Delete`,destructive:!0,onConfirm:X,onCancel:()=>U(null)}),(0,j.jsx)(S.Root,{open:w,onOpenChange:e=>{!e&&!q&&Y()},children:(0,j.jsx)(S.Content,{size:`sm`,children:(0,j.jsxs)(`form`,{onSubmit:he,children:[(0,j.jsxs)(S.Header,{children:[(0,j.jsx)(S.Title,{icon:h,children:`Add credential`}),(0,j.jsx)(S.Description,{children:`Add an API key or token to let tools and integrations use it.`})]}),(0,j.jsxs)(S.Body,{className:`flex flex-col gap-3`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[(0,j.jsx)(x,{label:`Service`,type:`text`,value:N,onChange:e=>P(e.target.value),placeholder:`e.g. github`,autoFocus:!0,fullWidth:!0}),(0,j.jsx)(x,{label:`Field`,type:`text`,value:F,onChange:e=>L(e.target.value),placeholder:`e.g. api_token`,fullWidth:!0})]}),(0,j.jsx)(x,{label:`Value`,type:`password`,value:R,onChange:e=>z(e.target.value),placeholder:`Enter the secret value`,fullWidth:!0}),(0,j.jsx)(x,{label:`Label (optional)`,type:`text`,value:B,onChange:e=>V(e.target.value),placeholder:`e.g. GitHub personal access token`,fullWidth:!0})]}),(0,j.jsxs)(S.Footer,{children:[(0,j.jsx)(r,{type:`button`,variant:`outlined`,onClick:Y,disabled:q,children:`Cancel`}),(0,j.jsx)(r,{type:`submit`,variant:`primary`,disabled:q||!N.trim()||!F.trim()||!R.trim(),leftIcon:q?(0,j.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):void 0,children:`Save`})]})]})})}),(0,j.jsx)(S.Root,{open:W!==null,onOpenChange:e=>{e||G(null)},children:(0,j.jsxs)(S.Content,{size:`sm`,children:[(0,j.jsxs)(S.Header,{children:[(0,j.jsx)(S.Title,{icon:g,children:`One-time credential link`}),(0,j.jsx)(S.Description,{children:W?`Send this link to whoever should provide ${W.name}. It works exactly once${W.expiresAt===null?``:` and expires ${new Date(ue(W.expiresAt)).toLocaleString()}`}. Anyone with the link can set this credential, so share it over a trusted channel.`:``})]}),(0,j.jsx)(S.Body,{children:(0,j.jsx)(x,{label:`Link`,type:`text`,readOnly:!0,value:W?.url??``,onFocus:e=>e.currentTarget.select(),fullWidth:!0})}),(0,j.jsx)(S.Footer,{children:(0,j.jsx)(r,{type:`button`,size:`compact`,onClick:_e,leftIcon:(0,j.jsx)(f,{"aria-hidden":!0}),children:`Copy link`})})]})})]})}export{L as CredentialsPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{r as t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-BQVYX8n_.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./card-D8zyWtZh.js";import{t as c}from"./check-wF3S-AV4.js";import{t as l}from"./chevron-down-DpYf9Gwq.js";import{n as u,t as d}from"./panel-item-An-BBeyL.js";import{o as f}from"./list-row-CFyYr-FU.js";import{t as p}from"./eye-off-BQ9J3pF2.js";import{t as m}from"./eye-C2rSrbD-.js";import{t as h}from"./key-round-CN4UKztQ.js";import{t as g}from"./link-2-B9c5ZsFq.js";import{t as _}from"./loader-circle-Ck8fq3yv.js";import{t as v}from"./plus-DZZypDUF.js";import{j as y}from"./src-CheJrlfT.js";import{t as ee}from"./tag-B6WeUtBW.js";import{t as b}from"./popover-Bl6742nZ.js";import{t as x}from"./input-ZpyYt_a0.js";import{t as S}from"./modal-BtcwNEBj.js";import{n as C}from"./toast-Be8FEQ-I.js";import{t as te}from"./confirm-dialog-Zyfei9GV.js";import{Ur as w,dt as T,ut as ne}from"./sdk.gen-zsiNChRm.js";import{Gt as re,Wt as ie}from"./react-query.gen-C0S0EYHV.js";import{t as ae}from"./use-is-org-ready-DKJvP9Ky.js";import{t as E}from"./assistant-feature-flag-store-aNAjw1qx.js";import{Ao as D,Bo as oe,Ea as O,t as k}from"./index-2np2R8qP.js";import{t as se}from"./use-active-assistant-id-DwLFgABu.js";import{t as ce}from"./detail-card-CIh4dCKt.js";var A=e(n(),1),j=o(),M=1500;function N(e){if(!e)return``;try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return``}}function le({credential:e,assistantId:t,canGenerateLink:n,generatingLink:r,deleting:i,onGenerateLink:a,onDelete:o}){let c=`${e.service}:${e.field}`,[l,u]=(0,A.useState)(!1),d=[e.alias?c:null,e.createdAt?`added ${N(e.createdAt)}`:null].filter(e=>!!e);return(0,j.jsx)(s.Root,{children:(0,j.jsxs)(s.Body,{padding:`sm`,className:`flex items-center gap-4 px-4`,children:[(0,j.jsx)(h,{className:`h-5 w-5 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`p`,{className:`truncate text-title-small text-[var(--content-default)]`,children:e.alias||c}),(0,j.jsx)(`div`,{className:`mt-0.5 flex min-w-0 items-center`,children:(0,j.jsx)(P,{assistantId:t,credential:e})}),d.length>0&&(0,j.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-body-medium-lighter text-[var(--content-tertiary)]`,children:d.join(` · `)})]}),(0,j.jsx)(`div`,{className:`shrink-0`,children:(0,j.jsx)(F,{name:c,open:l,onOpenChange:u,canGenerateLink:n,generatingLink:r,deleting:i,onGenerateLink:()=>{u(!1),a()},onDelete:()=>{u(!1),o()}})})]})})}function P({assistantId:e,credential:t}){let[n,r]=(0,A.useState)(null),[i,a]=(0,A.useState)(!1),[o,s]=(0,A.useState)(!1),l=(0,A.useRef)(null),u=(0,A.useRef)(0),d=`${t.service}:${t.field}`,h=(0,A.useCallback)(()=>{u.current++,r(null),a(!1),s(!1),l.current&&=(clearTimeout(l.current),null)},[]);(0,A.useEffect)(()=>{h()},[t.updatedAt,h]);let g=(0,A.useCallback)(async()=>{let n=++u.current;a(!0);try{let{data:i}=await T({path:{assistant_id:e},body:{service:t.service,field:t.field},throwOnError:!0});u.current===n&&r(i.value)}catch{u.current===n&&C.error(`Couldn't reveal ${d}.`)}finally{u.current===n&&a(!1)}},[e,t.service,t.field,d]),v=(0,A.useCallback)(()=>{n!=null&&navigator.clipboard.writeText(n).then(()=>{s(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>s(!1),M)},()=>C.error(`Couldn't copy — reveal and copy manually.`))},[n]),y=n!==null;return t.hasSecret?(0,j.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 align-middle font-mono text-body-medium-lighter`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>y?h():void g(),disabled:i,"aria-label":y?`Hide value for ${d}`:`Reveal value for ${d}`,title:y?`Hide value`:`Click to reveal`,"data-private":!0,className:`min-w-0 truncate rounded-sm text-left transition-[filter,color] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--border-focus)] ${y?`text-[var(--content-secondary)]`:`select-none text-[var(--content-tertiary)] blur-[3px] hover:blur-[2px]`}`,children:y?n:t.scrubbedValue}),i?(0,j.jsx)(_,{className:`h-3.5 w-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):y?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,onClick:v,"aria-label":`Copy value for ${d}`,title:`Copy value`,className:`shrink-0 rounded-sm p-0.5 text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--border-focus)]`,children:o?(0,j.jsx)(c,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):(0,j.jsx)(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,j.jsx)(`button`,{type:`button`,onClick:h,"aria-label":`Hide value for ${d}`,title:`Hide value`,className:`shrink-0 rounded-sm p-0.5 text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--border-focus)]`,children:(0,j.jsx)(p,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]}):(0,j.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":`Reveal value for ${d}`,title:`Click to reveal`,className:`shrink-0 rounded-sm p-0.5 text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--border-focus)]`,children:(0,j.jsx)(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]}):(0,j.jsx)(`span`,{className:`min-w-0 truncate font-mono text-body-medium-lighter text-[var(--content-tertiary)]`,children:t.scrubbedValue})}function F({name:e,open:t,onOpenChange:n,canGenerateLink:i,generatingLink:a,deleting:o,onGenerateLink:s,onDelete:c}){let f=O(),p=a||o,m=(0,j.jsx)(r,{variant:`outlined`,rightIcon:(0,j.jsx)(l,{}),"aria-haspopup":`menu`,"aria-expanded":t,"aria-label":`Configure ${e}`,leftIcon:p?(0,j.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):void 0,children:`Configure`});return f?(0,j.jsxs)(u.Root,{open:t,onOpenChange:n,children:[(0,j.jsx)(u.Trigger,{asChild:!0,children:m}),(0,j.jsxs)(u.Content,{children:[(0,j.jsx)(u.Header,{children:(0,j.jsx)(u.Title,{children:e})}),(0,j.jsxs)(u.Body,{children:[i&&(0,j.jsx)(d,{icon:a?_:g,label:`Generate link`,onSelect:()=>{p||s()}}),(0,j.jsx)(d,{icon:o?_:D,label:`Delete`,onSelect:()=>{p||c()}})]})]})]}):(0,j.jsxs)(b.Root,{open:t,onOpenChange:n,children:[(0,j.jsx)(b.Trigger,{asChild:!0,children:m}),(0,j.jsxs)(b.Content,{align:`end`,sideOffset:4,role:`menu`,className:`w-56 overflow-hidden p-0`,children:[i&&(0,j.jsx)(r,{type:`button`,role:`menuitem`,variant:`ghost`,onClick:s,disabled:p,className:`w-full justify-start rounded-none`,leftIcon:a?(0,j.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):(0,j.jsx)(g,{"aria-hidden":!0}),children:`Generate link`}),(0,j.jsx)(r,{type:`button`,role:`menuitem`,variant:`dangerGhost`,onClick:c,disabled:p,className:`w-full justify-start rounded-none`,leftIcon:o?(0,j.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):(0,j.jsx)(D,{"aria-hidden":!0}),children:`Delete`})]})]})}function ue(e){return e>0xe8d4a51000?e:e*1e3}async function de(e,t){let{data:n,response:r}=await w.post({url:`/v1/assistants/{assistant_id}/credential-requests`,path:{assistant_id:e},body:t});if(!r?.ok)throw Error(`Failed to create credential request: ${r?.status}`);return n}function fe(e){return[`credentials-list`,e]}var I=6;function L(){let e=E.use.credentialsSettings(),t=E.use.hasHydrated();return t&&!e?(0,j.jsx)(k,{}):t?(0,j.jsx)(R,{}):null}function R(){let e=se(),n=i(),o=ae(),c=E.use.credentialRequests(),l=fe(e),u=a({queryKey:l,queryFn:async()=>{let{data:t}=await ne({path:{assistant_id:e},body:{},throwOnError:!0});return{credentials:t.credentials,managedCredentials:t.managedCredentials}},enabled:o,retry:t}),d=(0,A.useMemo)(()=>u.data?.credentials??[],[u.data]),p=(0,A.useMemo)(()=>u.data?.managedCredentials??[],[u.data]),m=re({onSuccess:()=>{n.invalidateQueries({queryKey:l}),C.success(`Credential saved.`)},onError:e=>{C.error(e.message||`Failed to save credential`)}}),b=ie({onError:e=>{C.error(e.message||`Failed to delete credential`)}}),[w,T]=(0,A.useState)(!1),[D,O]=(0,A.useState)(`own`),[k,M]=(0,A.useState)(``),[N,P]=(0,A.useState)(``),[F,L]=(0,A.useState)(``),[R,z]=(0,A.useState)(``),[B,V]=(0,A.useState)(``),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(null),[pe,K]=(0,A.useState)(null),q=m.isPending,me=b.isPending?`${b.variables?.body?.service}:${b.variables?.body?.field}`:null,J=(0,A.useMemo)(()=>{let e=k.trim().toLowerCase();return e?d.filter(t=>[t.service,t.field,`${t.service}:${t.field}`,t.alias??``].join(` `).toLowerCase().includes(e)):d},[d,k]);(0,A.useEffect)(()=>{d.length<=I&&M(``)},[d.length]),(0,A.useEffect)(()=>{d.length===0&&p.length>0&&O(`managed`)},[d.length,p.length]);let Y=()=>{T(!1),P(``),L(``),z(``),V(``)},he=t=>{t?.preventDefault();let n=N.trim(),r=F.trim();!n||!r||!R.trim()||m.mutate({path:{assistant_id:e},body:{service:n,field:r,value:R,label:B.trim()||void 0}},{onSuccess:Y})},X=()=>{let t=H;U(null),t&&b.mutate({path:{assistant_id:e},body:{service:t.service,field:t.field}},{onSuccess:()=>{n.invalidateQueries({queryKey:l}),C.success(`Deleted ${t.service}:${t.field}.`)}})},ge=async t=>{let n=`${t.service}:${t.field}`;K(n);try{let r=await de(e,{service:t.service,field:t.field,label:t.alias??void 0});r.ok&&r.url?G({name:n,url:r.url,expiresAt:r.expiresAt??null}):C.error(r.error||`Failed to generate a one-time link`)}catch(e){C.error(e instanceof Error?e.message:`Failed to generate a one-time link`)}finally{K(null)}},_e=()=>{let e=W?.url;e&&navigator.clipboard.writeText(e).then(()=>C.success(`Link copied to clipboard.`),()=>C.error(`Couldn't copy the link — select it and copy manually.`))};if(u.isLoading)return(0,j.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,j.jsx)(_,{className:`h-5 w-5 animate-spin text-[var(--content-disabled)]`})});let Z=d.length>0,Q=p.length>0,ve=d.length>I,$=D===`managed`&&Q;return(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(ce,{title:`Credentials`,subtitle:$?`Provided through your Vellum-managed integrations. These are read-only here.`:`Stored encrypted in your assistant's credential vault. Reveal a value on demand, or replace or delete it at any time.`,accessory:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Q?(0,j.jsx)(y,{items:[{value:`own`,label:`Your own`},{value:`managed`,label:`Managed`}],value:D,onChange:O,ariaLabel:`Credential source`}):null,!$&&Z?(0,j.jsx)(r,{type:`button`,variant:`primary`,size:`regular`,onClick:()=>T(!0),leftIcon:(0,j.jsx)(v,{"aria-hidden":!0}),children:`Add`}):null]}),children:$?(0,j.jsx)(`div`,{className:`space-y-2`,children:p.map(e=>(0,j.jsx)(s.Root,{children:(0,j.jsxs)(s.Body,{padding:`sm`,className:`flex items-center gap-4 px-4`,children:[(0,j.jsx)(h,{className:`h-5 w-5 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`p`,{className:`truncate text-title-small text-[var(--content-default)]`,children:e.provider}),(0,j.jsxs)(`p`,{className:`truncate text-body-medium-lighter text-[var(--content-tertiary)]`,children:[e.accountInfo??e.handle,` · `,e.status]})]}),(0,j.jsx)(ee,{tone:`neutral`,children:`Managed`})]})},e.handle))}):(0,j.jsxs)(`div`,{className:`space-y-4`,children:[Z?(0,j.jsxs)(`div`,{className:`space-y-3`,children:[ve?(0,j.jsx)(x,{type:`text`,value:k,onChange:e=>M(e.target.value),placeholder:`Search credentials`,"aria-label":`Search credentials`,leftIcon:(0,j.jsx)(oe,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}):null,J.length===0?(0,j.jsxs)(`p`,{className:`px-1 py-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[`No credentials matched “`,k.trim(),`”.`]}):(0,j.jsx)(`div`,{className:`space-y-2`,children:J.map(t=>{let n=`${t.service}:${t.field}`;return(0,j.jsx)(le,{credential:t,assistantId:e,canGenerateLink:c,generatingLink:pe===n,deleting:me===n,onGenerateLink:()=>void ge(t),onDelete:()=>U(t)},t.credentialId??n)})})]}):(0,j.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-6 py-12 text-center`,children:[(0,j.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,j.jsx)(h,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`,"aria-hidden":!0})}),(0,j.jsx)(`h3`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No credentials yet`}),(0,j.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Add an API key or token to let tools and integrations use it.`})]}),Z?null:(0,j.jsx)(r,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>T(!0),className:`w-full border-dashed`,leftIcon:(0,j.jsx)(v,{"aria-hidden":!0}),children:`Add Credential`})]})}),(0,j.jsx)(te,{open:H!==null,title:`Delete credential`,message:H?`Delete ${H.service}:${H.field}? Tools and integrations using it will lose access.`:``,confirmLabel:`Delete`,destructive:!0,onConfirm:X,onCancel:()=>U(null)}),(0,j.jsx)(S.Root,{open:w,onOpenChange:e=>{!e&&!q&&Y()},children:(0,j.jsx)(S.Content,{size:`sm`,children:(0,j.jsxs)(`form`,{onSubmit:he,children:[(0,j.jsxs)(S.Header,{children:[(0,j.jsx)(S.Title,{icon:h,children:`Add credential`}),(0,j.jsx)(S.Description,{children:`Add an API key or token to let tools and integrations use it.`})]}),(0,j.jsxs)(S.Body,{className:`flex flex-col gap-3`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[(0,j.jsx)(x,{label:`Service`,type:`text`,value:N,onChange:e=>P(e.target.value),placeholder:`e.g. github`,autoFocus:!0,fullWidth:!0}),(0,j.jsx)(x,{label:`Field`,type:`text`,value:F,onChange:e=>L(e.target.value),placeholder:`e.g. api_token`,fullWidth:!0})]}),(0,j.jsx)(x,{label:`Value`,type:`password`,value:R,onChange:e=>z(e.target.value),placeholder:`Enter the secret value`,fullWidth:!0}),(0,j.jsx)(x,{label:`Label (optional)`,type:`text`,value:B,onChange:e=>V(e.target.value),placeholder:`e.g. GitHub personal access token`,fullWidth:!0})]}),(0,j.jsxs)(S.Footer,{children:[(0,j.jsx)(r,{type:`button`,variant:`outlined`,onClick:Y,disabled:q,children:`Cancel`}),(0,j.jsx)(r,{type:`submit`,variant:`primary`,disabled:q||!N.trim()||!F.trim()||!R.trim(),leftIcon:q?(0,j.jsx)(_,{className:`animate-spin`,"aria-hidden":!0}):void 0,children:`Save`})]})]})})}),(0,j.jsx)(S.Root,{open:W!==null,onOpenChange:e=>{e||G(null)},children:(0,j.jsxs)(S.Content,{size:`sm`,children:[(0,j.jsxs)(S.Header,{children:[(0,j.jsx)(S.Title,{icon:g,children:`One-time credential link`}),(0,j.jsx)(S.Description,{children:W?`Send this link to whoever should provide ${W.name}. It works exactly once${W.expiresAt===null?``:` and expires ${new Date(ue(W.expiresAt)).toLocaleString()}`}. Anyone with the link can set this credential, so share it over a trusted channel.`:``})]}),(0,j.jsx)(S.Body,{children:(0,j.jsx)(x,{label:`Link`,type:`text`,readOnly:!0,value:W?.url??``,onFocus:e=>e.currentTarget.select(),fullWidth:!0})}),(0,j.jsx)(S.Footer,{children:(0,j.jsx)(r,{type:`button`,size:`compact`,onClick:_e,leftIcon:(0,j.jsx)(f,{"aria-hidden":!0}),children:`Copy link`})})]})})]})}export{L as CredentialsPage};