@vellumai/web 0.10.7-dev.202607100313.fffdfea → 0.10.7-dev.202607100720.fba456e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{account-page-Ce-pbLMJ.js → account-page-Li0uLmLs.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-T0GBDg-W.js → acp-run-detail-panel-C0yvGSks.js} +1 -1
- package/dist/assets/{activity-steps-panel-BXXeXc19.js → activity-steps-panel-OLcpKG_k.js} +1 -1
- package/dist/assets/{advanced-page-C8Ib_u5F.js → advanced-page-CVO_Q3kI.js} +1 -1
- package/dist/assets/{ai-page-BezzLmVq.js → ai-page-C1h5NlKw.js} +1 -1
- package/dist/assets/{animated-avatar-DDpjZzRx.js → animated-avatar-CrlodWQr.js} +1 -1
- package/dist/assets/{api-Zs5JMgKY.js → api-CYdUmFnA.js} +1 -1
- package/dist/assets/{api-key-screen-B_g5hH5v.js → api-key-screen-BIMt5wXC.js} +1 -1
- package/dist/assets/{archive-page-rl2uRUik.js → archive-page-QDAZt1bN.js} +1 -1
- package/dist/assets/{assistant-status-panel-DPwgE1TF.js → assistant-status-panel-DbbksK3-.js} +1 -1
- package/dist/assets/{auth-store-CKsDsnkp.js → auth-store-CVs0OdtO.js} +1 -1
- package/dist/assets/{background-task-detail-panel-3xiHMnCC.js → background-task-detail-panel-Dvg9X_dS.js} +1 -1
- package/dist/assets/{billing-page-D-gIsav0.js → billing-page-ojEsvt_X.js} +1 -1
- package/dist/assets/{bookmarks-page-giPayf1N.js → bookmarks-page-D7myoNlj.js} +1 -1
- package/dist/assets/{build-state-BLXpH8o6.js → build-state-BOU11GPr.js} +1 -1
- package/dist/assets/{channels-page-route-DAZ5e9vo.js → channels-page-route-DGd6PLjm.js} +1 -1
- package/dist/assets/{chat-markdown-message-BuypfAkx.js → chat-markdown-message-CItp7csw.js} +1 -1
- package/dist/assets/{command-palette-C0XZVlzp.js → command-palette-BvwNadPb.js} +1 -1
- package/dist/assets/{command-palette-window-page-CxIvQGwt.js → command-palette-window-page-DMnQ_aD6.js} +1 -1
- package/dist/assets/{community-page-CwSloAl0.js → community-page-CMyh79_4.js} +1 -1
- package/dist/assets/{contacts-page-route-CBqOhX8s.js → contacts-page-route-CxCzPa-M.js} +1 -1
- package/dist/assets/{conversation-list-fetchers-tE99dnUJ.js → conversation-list-fetchers-DS9vmqfD.js} +1 -1
- package/dist/assets/{credentials-page-Bd-E5j_2.js → credentials-page-Bay5GYZG.js} +1 -1
- package/dist/assets/{debug-page-CU0jo5tG.js → debug-page-DNYNb8g1.js} +1 -1
- package/dist/assets/{deploy-dialogs-8TBhlLXZ.js → deploy-dialogs-D9ogAwUI.js} +1 -1
- package/dist/assets/{detail-panel-stop-button-B0utUgSr.js → detail-panel-stop-button-CRcHovlo.js} +1 -1
- package/dist/assets/{developer-page-Da1bdSPK.js → developer-page-GiubU02W.js} +1 -1
- package/dist/assets/{devices-page-DC9det1s.js → devices-page-DSmfGWDc.js} +1 -1
- package/dist/assets/{dictation-overlay-page-6l-KJCrE.js → dictation-overlay-page-DJcRyCby.js} +1 -1
- package/dist/assets/{document-viewer-page-djjsg4WE.js → document-viewer-page-CNpSIR5q.js} +1 -1
- package/dist/assets/{earn-credits-modal-B4iirPUC.js → earn-credits-modal-B6EL9KHM.js} +1 -1
- package/dist/assets/{emails-page-RItjmMG5.js → emails-page-DAbdjEcM.js} +1 -1
- package/dist/assets/{general-page-BtAuGqFM.js → general-page-In-O5z14.js} +1 -1
- package/dist/assets/{hatching-screen-C71v2Kqp.js → hatching-screen-1Ib1UsQ8.js} +1 -1
- package/dist/assets/{home-page-route-DxKq7gEn.js → home-page-route-Bx4xkQr4.js} +1 -1
- package/dist/assets/{hosting-screen-DBN9hO0s.js → hosting-screen-Ce4JiQ9J.js} +1 -1
- package/dist/assets/{identity-page-route-Ck1TCmSd.js → identity-page-route-CDdf-0ZX.js} +1 -1
- package/dist/assets/index-BYfTlch9.js +113 -0
- package/dist/assets/index-BjtwYdrT.css +2 -0
- package/dist/assets/{inspect-page-BuriU_iU.js → inspect-page-Dmsojyx2.js} +1 -1
- package/dist/assets/{integrations-page-N-I7F_JQ.js → integrations-page-npAbqYD4.js} +1 -1
- package/dist/assets/{intelligence-layout-C_H2Uec7.js → intelligence-layout-B354MRxu.js} +1 -1
- package/dist/assets/{keyboard-shortcuts-page-B2ozF8zY.js → keyboard-shortcuts-page-BTszfF5y.js} +1 -1
- package/dist/assets/{library-detail-page-BKj7gWNL.js → library-detail-page-Be9DFLXt.js} +1 -1
- package/dist/assets/{library-page-BJljT3MY.js → library-page-JA-4LBMj.js} +1 -1
- package/dist/assets/{login-flow-C4Ehxg-g.js → login-flow-v02gDpa1.js} +1 -1
- package/dist/assets/{login-page-CZBdlVje.js → login-page-BgsuEo8T.js} +1 -1
- package/dist/assets/{logout-page-BryU7bK_.js → logout-page-DQGYrYot.js} +1 -1
- package/dist/assets/{logs-layout-nPLZjXX5.js → logs-layout-tD5gXnKs.js} +1 -1
- package/dist/assets/{memory-router-playground-page-qIG7U97D.js → memory-router-playground-page-CnQYMmVa.js} +1 -1
- package/dist/assets/{messages-DF7pzUR8.js → messages-Bl6a3LUN.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-DpvWGGSA.js → mobile-sidebar-drawer-dvuldt8a.js} +1 -1
- package/dist/assets/{notifications-page-DBlKmak1.js → notifications-page-D0DqTrSh.js} +1 -1
- package/dist/assets/{oauth-complete-page-D8aQ3tJ_.js → oauth-complete-page-DC4_JCQY.js} +1 -1
- package/dist/assets/{oauth-popup-complete-page-CXXZdxWJ.js → oauth-popup-complete-page-Bik6u419.js} +1 -1
- package/dist/assets/{pairing-page-b1uNitAm.js → pairing-page-gcO-QeQH.js} +1 -1
- package/dist/assets/{platform-loopback-page-hCZEK9-q.js → platform-loopback-page-BIC5R_2A.js} +1 -1
- package/dist/assets/{plugins-page-C0TtdwgQ.js → plugins-page-BHEtI3Gk.js} +1 -1
- package/dist/assets/{prechat-route-CnIcxqAR.js → prechat-route-DhtyT72h.js} +1 -1
- package/dist/assets/{prefs-hu4Ft3Gc.js → prefs-CTRDnnnS.js} +1 -1
- package/dist/assets/{privacy-page-PFWKww1A.js → privacy-page-DMURyayZ.js} +1 -1
- package/dist/assets/{privacy-screen-DSr2ddPX.js → privacy-screen-DuaVQ6IQ.js} +1 -1
- package/dist/assets/{provider-callback-page-CVVL9mxY.js → provider-callback-page-DgFANe_f.js} +1 -1
- package/dist/assets/{provider-key-B9HxajGj.js → provider-key-DBiHV_K5.js} +1 -1
- package/dist/assets/{provider-signup-page-BBqT_sHe.js → provider-signup-page-BDMHfIcI.js} +1 -1
- package/dist/assets/{quick-input-page-CLwquN93.js → quick-input-page-C0Rse0qs.js} +1 -1
- package/dist/assets/react-query.gen-C6wVk6Rw.js +1 -0
- package/dist/assets/{research-mock-page-DeBKxHSz.js → research-mock-page-D_m36Jy6.js} +1 -1
- package/dist/assets/{research-onboarding-route-2nc0yKsq.js → research-onboarding-route-CEC2x5kn.js} +1 -1
- package/dist/assets/{review-terms-screen-QliTExQL.js → review-terms-screen-DdZD1jqm.js} +1 -1
- package/dist/assets/{risk-jKF7qGwV.js → risk-Dsj4oM8c.js} +1 -1
- package/dist/assets/{schedules-CQO3UwTc.js → schedules-Dj3YQqG5.js} +1 -1
- package/dist/assets/{sdk.gen-jDeNbBv8.js → sdk.gen-BwnFjFcp.js} +1 -1
- package/dist/assets/{security-page-CQfQh2wW.js → security-page-CIC8qXj0.js} +1 -1
- package/dist/assets/{select-assistant-screen-BsGcZIsZ.js → select-assistant-screen-Cd8srvtb.js} +1 -1
- package/dist/assets/{settings-layout-hvCEbqwx.js → settings-layout-VEkpa1PW.js} +1 -1
- package/dist/assets/{share-feedback-modal-BFxBtlP7.js → share-feedback-modal-BEFlSqbK.js} +1 -1
- package/dist/assets/{sidebar-tree-BaU6dAAM.js → sidebar-tree-FcJ6pHEw.js} +1 -1
- package/dist/assets/{signup-page-COVsB50a.js → signup-page-CEqH6BRM.js} +1 -1
- package/dist/assets/{site-favicon-D9Rp1QPZ.js → site-favicon-DSzk4cg0.js} +1 -1
- package/dist/assets/{skill-detail-page-D5UAAUmZ.js → skill-detail-page-CSR6eBxk.js} +1 -1
- package/dist/assets/{skill-detail-panel-DIoN-AUc.js → skill-detail-panel-DedH9GLd.js} +1 -1
- package/dist/assets/{skills-C9wbjXsQ.js → skills-CSlvOB79.js} +1 -1
- package/dist/assets/{skills-page-DhUitBj9.js → skills-page-irwMop0O.js} +1 -1
- package/dist/assets/{sound-manager-CSAwT8Vm.js → sound-manager-6UbdgQrj.js} +1 -1
- package/dist/assets/{sounds-page-DeBeDlcY.js → sounds-page-b0kjLtBm.js} +1 -1
- package/dist/assets/{subagent-detail-panel-CF-VVQJA.js → subagent-detail-panel-CTulpbUd.js} +1 -1
- package/dist/assets/{subagent-store-C-pyGmFU.js → subagent-store-D-9RtoyJ.js} +1 -1
- package/dist/assets/{system-events-page-CYqUpGpC.js → system-events-page-DrQWpC2D.js} +1 -1
- package/dist/assets/{tiptap-document-editor-aGPkbqbr.js → tiptap-document-editor-Af0WPHxQ.js} +1 -1
- package/dist/assets/{tool-detail-panel-CzkNK-ue.js → tool-detail-panel-G01JjAPo.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-BytvxNqQ.js → upgrade-cancel-page-cJyqnC7O.js} +1 -1
- package/dist/assets/{upgrade-success-page-CeuBASa8.js → upgrade-success-page-C3__rlPJ.js} +1 -1
- package/dist/assets/{usage-page-CI7scN-b.js → usage-page-BIGDjU_J.js} +1 -1
- package/dist/assets/{use-edge-swipe-back-U9h8O8rp.js → use-edge-swipe-back-DcQxnpRK.js} +1 -1
- package/dist/assets/{use-invite-link-dialog-JL5Jevln.js → use-invite-link-dialog-C_z3cWhR.js} +1 -1
- package/dist/assets/use-is-org-ready-B7B3xHAy.js +1 -0
- package/dist/assets/{use-onboarding-login-CP7O8ZzB.js → use-onboarding-login-XjtnziWG.js} +1 -1
- package/dist/assets/{use-skill-actions-BKfLB9Oe.js → use-skill-actions-BFrx1e4G.js} +1 -1
- package/dist/assets/{use-skill-categories-8DmU61Hs.js → use-skill-categories-7ngHJrBv.js} +1 -1
- package/dist/assets/{use-skill-detail-files-DmLQiG5u.js → use-skill-detail-files-qblcXTbq.js} +1 -1
- package/dist/assets/{viewer-store-SsoxBypb.js → viewer-store-B8-Qnbx9.js} +1 -1
- package/dist/assets/{voice-page-DX8ma3dY.js → voice-page-BVGxL6rD.js} +1 -1
- package/dist/assets/{weather-forecast-display-hxrsJwFy.js → weather-forecast-display-Dd2Uyk7j.js} +1 -1
- package/dist/assets/{welcome-screen-Drx018g8.js → welcome-screen-Cyx9Mjus.js} +1 -1
- package/dist/assets/{workflow-detail-panel-n5adDCz2.js → workflow-detail-panel-xScksXY2.js} +1 -1
- package/dist/assets/{workflow-store-B_M196cU.js → workflow-store-BL2Hgm3R.js} +1 -1
- package/dist/assets/workspace-page-Bx3ihC2n.js +1 -0
- package/dist/index.html +21 -21
- package/package.json +1 -1
- package/dist/assets/index-DQjUULFO.js +0 -113
- package/dist/assets/index-z4S53sm1.css +0 -2
- package/dist/assets/react-query.gen-DOfazqkL.js +0 -1
- package/dist/assets/use-is-org-ready-BP6_0L-A.js +0 -1
- package/dist/assets/workspace-page-CYDMc7C-.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/native-file-Cn3RbQbT.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-BewR0kVT.js","assets/dist-DS5iJwBJ2.js","assets/pdf-CuY9CA7Q.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-Dhiismgm.js";import{t as n}from"./react-DJZBPgpf.js";import{F as r,t as i}from"./button-amTXFI-2.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{t as o}from"./useQuery-B45lW1Kk.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./typography-D5f7kt80.js";import{t as l}from"./chevron-left-BMF1xNfR.js";import{t as u}from"./chevron-right-DqqmezXC.js";import{t as d}from"./download-CAuK-nZ6.js";import{t as f}from"./file-DsyJLS2u.js";import{t as p}from"./loader-circle-Cz7opInR.js";import{t as m}from"./x-CkSVp1Ok.js";import{a as h,m as g}from"./src-B2IjVySQ.js";import{n as _,t as v}from"./file-markdown-BXUvAQ24.js";import{l as y}from"./sdk.gen-jDeNbBv8.js";import{t as b}from"./dist-DS5iJwBJ2.js";import{t as x}from"./browser-BPZAXjRE.js";var S=e(n(),1),ee=e(r(),1),C=s(),w=`width=500,height=600`;function T(e){if(!e)return null;let t;try{let n=typeof window>`u`?`http://localhost`:window.location.origin;t=new URL(e,n)}catch{return null}return t.protocol!==`https:`&&t.protocol!==`http:`?null:t}function E(e){let t=T(e);if(!t)return!1;let n=t.pathname.toLowerCase();return t.searchParams.get(`response_type`)===`code`&&t.searchParams.has(`client_id`)&&t.searchParams.has(`redirect_uri`)||t.searchParams.has(`client_id`)&&t.searchParams.has(`redirect_uri`)&&/oauth|authorize|auth/.test(n)}function D(e){if(typeof window>`u`)return null;let t=T(e);return!t||t.origin!==window.location.origin?null:`${t.pathname}${t.search}${t.hash}`}function O(e){return T(e)?.href??null}function k(e){if(!E(e))return!1;if(b.isNativePlatform()){let t=O(e);return t?(x(t),!0):!1}let t=window.open(e,`_blank`,w);return t===null?!1:(t.focus(),!0)}function A(e){return k(e)}function j(e){if(k(e))return!0;let t=window.open(e,`_blank`);return t===null?!1:(t.focus(),!0)}function M(e,t){let n=D(e);if(n)return t.push(n),{kind:`routed`};let r=O(e);return r?t.isNative?(x(r),{kind:`opened`}):j(r)?{kind:`opened`}:{kind:`blocked`,url:r}:{kind:`invalid`}}async function N(e,t){if(!t||t.startsWith(`rehydrated:`))return null;try{let{data:n,error:r}=await y({path:{assistant_id:e,id:t},parseAs:`blob`,throwOnError:!1});return!r&&n instanceof Blob?n:null}catch{return null}}async function P(e,t){let{saveFile:n}=await a(async()=>{let{saveFile:e}=await import(`./native-file-Cn3RbQbT.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));if(t){let r=await N(t,e.id);if(r){await n(r,e.filename);return}}e.previewUrl&&await n(e.previewUrl,e.filename)}function F(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||r===0?Math.round(n).toString():n.toFixed(1)} ${t[r]}`}function I(e,t){let n=(e||``).toLowerCase(),r=t.split(`.`).pop()?.toLowerCase()??``;return n.startsWith(`image/`)?`image`:n.startsWith(`video/`)?`video`:n.startsWith(`audio/`)?`audio`:n===`application/pdf`||r===`pdf`?`pdf`:n===`application/zip`||n===`application/x-tar`||n===`application/gzip`||[`zip`,`tar`,`gz`,`tgz`,`rar`,`7z`].includes(r)?`archive`:n===`text/csv`||n===`application/vnd.ms-excel`||n===`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`||[`csv`,`xlsx`,`xls`,`numbers`].includes(r)?`spreadsheet`:`ts.tsx.js.jsx.py.rb.go.rs.java.kt.swift.c.cc.cpp.h.hpp.sh.bash.zsh.html.css.scss.json.yaml.yml.toml.xml`.split(`.`).includes(r)?`code`:n===`application/msword`||n===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||[`doc`,`docx`,`pages`].includes(r)?`document`:n.startsWith(`text/`)||[`txt`,`md`,`rtf`].includes(r)?`text`:`file`}function L(e){let t=e.replace(/\s/g,``),n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return Math.max(0,Math.floor(t.length*3/4)-n)}function R(e){let t=e.match(/;base64,(.*)$/);if(!t?.[1])return null;let n=atob(t[1]),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function z(e,t=28){if(e.length<=t)return e;let n=Math.max(4,Math.floor((t-1)/2));return`${e.slice(0,n)}…${e.slice(e.length-n)}`}var B=1.5,V=20,H=!1;async function U(){let e=await a(()=>import(`./pdf-CuY9CA7Q.js`),__vite__mapDeps([4,2]));return H||=(e.GlobalWorkerOptions.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${e.version}/legacy/build/pdf.worker.min.mjs`,!0),e}function te({url:e,className:t}){let n=(0,S.useRef)(null),[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(0),[s,c]=(0,S.useState)(!0),[l,u]=(0,S.useState)(null),d=(0,S.useRef)(new Map),f=(0,S.useRef)(new Set);(0,S.useEffect)(()=>{let t=!1;async function n(){c(!0),u(null),i(null),o(0),f.current.clear();try{let n=await U(),r;if(e.startsWith(`data:`)){let t=R(e);r=t?{data:t}:e}else r=e;let a=await n.getDocument(r).promise;if(t){a.destroy();return}i(a),o(Math.min(a.numPages,V))}catch{t||u(`Failed to load PDF.`)}finally{t||c(!1)}}return n(),()=>{t=!0}},[e]),(0,S.useEffect)(()=>()=>{r&&r.destroy()},[r]);let m=(0,S.useCallback)(async e=>{if(!r||f.current.has(e))return;let t=d.current.get(e);if(t){f.current.add(e);try{let n=await r.getPage(e),i=n.getViewport({scale:B});t.width=i.width,t.height=i.height,await n.render({canvas:t,viewport:i}).promise}catch{f.current.delete(e)}}},[r]);(0,S.useEffect)(()=>{if(!r||a===0)return;let e=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=Number(t.target.dataset.page);e&&m(e)}},{root:n.current,rootMargin:`200px`});return d.current.forEach(t=>e.observe(t)),()=>e.disconnect()},[r,a,m]);let h=(0,S.useCallback)(e=>t=>{t?d.current.set(e,t):d.current.delete(e)},[]);return s?(0,C.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,C.jsx)(p,{className:`h-8 w-8 animate-spin text-white/70`})}):l?(0,C.jsx)(`div`,{className:`w-full max-w-sm rounded-lg border border-white/15 bg-white/[0.08] p-8 text-center`,children:(0,C.jsx)(`p`,{className:`text-body-medium-lighter text-white/80`,children:l})}):(0,C.jsx)(`div`,{ref:n,className:`flex max-h-[80vh] flex-col items-center gap-2 overflow-y-auto rounded ${t??``}`,children:Array.from({length:a},(e,t)=>(0,C.jsx)(`canvas`,{ref:h(t+1),"data-page":t+1,className:`w-[90vw] max-w-[800px]`,style:{height:`auto`}},t+1))})}function W({message:e,filename:t,onDownload:n,downloadDisabled:r=!1}){return(0,C.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border border-white/15 bg-white/[0.08] p-8 text-center`,children:[(0,C.jsx)(`p`,{className:`text-body-medium-lighter text-white/80`,children:e}),(0,C.jsx)(i,{variant:`ghost`,leftIcon:(0,C.jsx)(d,{}),onClick:n,disabled:r,"aria-label":`Download ${t}`,className:`mt-4 text-white/70 hover:bg-white/10 hover:text-white max-md:bg-transparent`,tintColor:`currentColor`,children:`Download`})]})}var G=class extends Error{};async function K(e,t,n){if(t>204800)throw new G;if(e.startsWith(`data:`)){let t=R(e);if(!t)throw Error(`Malformed data URI`);return new TextDecoder().decode(t)}let r=await fetch(e,{signal:n});if(!r.ok)throw Error(`Failed to load file: ${r.status}`);let i=await r.blob();if(i.size>204800)throw new G;return i.text()}function ne({url:e,filename:n,mimeType:r,sizeBytes:i}){let[o,s]=(0,S.useState)({status:`loading`});return(0,S.useEffect)(()=>{let n=new AbortController;return s({status:`loading`}),K(e,i,n.signal).then(e=>{n.signal.aborted||s({status:`ready`,text:e})}).catch(e=>{if(n.signal.aborted)return;let r=e instanceof G;r||t(e,{context:`attachment-text-preview`,bestEffort:!0}),s({status:`error`,tooLarge:r})}),()=>n.abort()},[e,i]),o.status===`loading`?(0,C.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,C.jsx)(p,{className:`h-8 w-8 animate-spin text-white/70`})}):o.status===`error`?(0,C.jsx)(W,{message:o.tooLarge?`File too large to preview inline.`:`Failed to load preview.`,filename:n,onDownload:async()=>{let{saveFile:t}=await a(async()=>{let{saveFile:e}=await import(`./native-file-Cn3RbQbT.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));await t(e,n)}}):(0,C.jsx)(`div`,{className:`max-h-[80vh] w-[min(90vw,800px)] overflow-auto rounded-lg p-6`,style:{backgroundColor:`var(--surface-overlay)`,color:`var(--content-default)`},children:(0,C.jsx)(re,{text:o.text,filename:n,mimeType:r})})}function re({text:e,filename:t,mimeType:n}){return _(t,n)?(0,C.jsx)(v,{content:e}):(0,C.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-body-small-default`,children:e})}var ie=new Set([`ts`,`tsx`,`js`,`jsx`,`py`,`json`,`md`,`sh`,`bash`,`html`,`css`,`yaml`,`yml`,`txt`]),ae=new Set([`application/json`,`application/javascript`,`application/xml`]),q=e=>{let t=e.lastIndexOf(`.`);return t===-1||t===e.length-1?``:e.slice(t+1).toLowerCase()},J=({open:e,onClose:t,attachment:n,assistantId:r,siblingAttachments:s,onNavigate:h})=>{let g=(0,S.useRef)(null),_=(0,S.useRef)(null);(0,S.useEffect)(()=>{e&&_.current?.focus()},[e]);let v=!n.previewUrl&&n.id.startsWith(`rehydrated:`),y=e&&!n.previewUrl&&!!r&&!!n.id&&!v,{data:b,isError:x}=o({queryKey:[`attachmentContent`,r,n.id],queryFn:async()=>{let e=await N(r,n.id);if(!e)throw Error(`Failed to load file`);return e},enabled:y,staleTime:1/0,retry:!1}),[w,T]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(!b){T(null);return}let e=URL.createObjectURL(b);return T(e),()=>{URL.revokeObjectURL(e),T(null)}},[b]);let E=n.previewUrl??w,[D,O]=(0,S.useState)(null),k=y&&!w&&!x,A=v?`Preview unavailable — file content was not preserved in chat history.`:x?`Failed to load preview.`:null,j=(0,S.useMemo)(()=>!s||s.length<=1?-1:s.findIndex(e=>e.id===n.id),[s,n.id]),M=j!==-1&&s!=null&&s.length>1,P=(0,S.useCallback)(()=>{!M||!s||!h||h(s[(j-1+s.length)%s.length])},[M,s,j,h]),I=(0,S.useCallback)(()=>{!M||!s||!h||h(s[(j+1)%s.length])},[M,s,j,h]),L=(0,S.useCallback)(e=>{e.key===`Escape`?(e.preventDefault(),t()):e.key===`ArrowLeft`&&M?(e.preventDefault(),P()):e.key===`ArrowRight`&&M&&(e.preventDefault(),I())},[t,P,I,M]),R=(0,S.useCallback)(e=>{e.target===g.current&&t()},[t]),z=(0,S.useCallback)(async()=>{if(!E)return;let{saveFile:e}=await a(async()=>{let{saveFile:e}=await import(`./native-file-Cn3RbQbT.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));await e(E,n.filename)},[E,n.filename]);if(!e)return null;let B=n.mimeType.toLowerCase(),V=B.startsWith(`image/`),H=B.startsWith(`video/`),U=B===`application/pdf`||B===`application/octet-stream`&&n.filename.toLowerCase().endsWith(`.pdf`),G=q(n.filename),K=B.startsWith(`text/`)||ae.has(B)||ie.has(G);return(0,ee.createPortal)((0,C.jsxs)(`div`,{ref:g,role:`dialog`,"aria-modal":`true`,"aria-label":`Preview of ${n.filename}`,className:`fixed inset-0 z-50 flex flex-col items-center justify-center bg-black/80 [-webkit-app-region:no-drag]`,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))`},onKeyDown:L,onClick:R,children:[(0,C.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-10 flex items-center gap-3 px-4`,style:{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1rem)`},children:[(0,C.jsx)(c,{variant:`body-small-default`,className:`w-11 shrink-0 truncate text-white/50`,children:F(n.sizeBytes)}),(0,C.jsx)(c,{as:`div`,variant:`body-medium-lighter`,className:`min-w-0 flex-1 truncate text-center text-white/90`,children:n.filename}),(0,C.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,C.jsx)(i,{variant:`ghost`,iconOnly:(0,C.jsx)(d,{}),expandOnMobile:!1,onClick:z,disabled:!E,"aria-label":`Download ${n.filename}`,className:`h-11 w-11 rounded-full bg-white/10 text-white/70 hover:bg-white/20 hover:text-white`,tintColor:`currentColor`}),(0,C.jsx)(i,{ref:_,variant:`ghost`,iconOnly:(0,C.jsx)(m,{}),expandOnMobile:!1,onClick:t,"aria-label":`Close preview`,className:`h-11 w-11 rounded-full bg-white/10 text-white/70 hover:bg-white/20 hover:text-white`,tintColor:`currentColor`})]})]}),M&&(0,C.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-1/2 z-10 flex -translate-y-1/2 items-center justify-between px-4`,children:[(0,C.jsx)(i,{variant:`ghost`,iconOnly:(0,C.jsx)(l,{}),expandOnMobile:!1,onClick:P,"aria-label":`Previous attachment`,className:`pointer-events-auto h-11 w-11 rounded-full bg-white/10 text-white/70 hover:bg-white/20 hover:text-white`,tintColor:`currentColor`}),(0,C.jsx)(i,{variant:`ghost`,iconOnly:(0,C.jsx)(u,{}),expandOnMobile:!1,onClick:I,"aria-label":`Next attachment`,className:`pointer-events-auto h-11 w-11 rounded-full bg-white/10 text-white/70 hover:bg-white/20 hover:text-white`,tintColor:`currentColor`})]}),(0,C.jsx)(`div`,{className:`flex items-center justify-center`,onClick:e=>e.stopPropagation(),children:k?(0,C.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,C.jsx)(p,{className:`h-8 w-8 animate-spin text-white/70`})}):A?(0,C.jsx)(W,{message:A,filename:n.filename,onDownload:z,downloadDisabled:!E}):U&&E?(0,C.jsx)(te,{url:E}):V&&E&&D!==E?(0,C.jsx)(`img`,{src:E,alt:n.filename,onError:()=>O(E),className:`max-h-[80vh] max-w-[90vw] rounded object-contain`}):H&&E?(0,C.jsx)(`video`,{"data-testid":`video-preview`,src:E,poster:n.thumbnailUrl??void 0,controls:!0,className:`max-h-[80vh] max-w-[90vw] rounded`}):K&&E?(0,C.jsx)(ne,{url:E,filename:n.filename,mimeType:n.mimeType,sizeBytes:n.sizeBytes}):(0,C.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col items-center rounded-lg border border-white/15 bg-white/[0.08] p-8 text-center`,children:[(0,C.jsx)(f,{className:`h-16 w-16 text-white/60`}),(0,C.jsx)(`p`,{className:`mt-4 text-body-medium-default text-white/90`,children:n.filename}),(0,C.jsx)(`p`,{className:`mt-1 text-body-small-default text-white/60`,children:F(n.sizeBytes)}),(0,C.jsx)(i,{variant:`ghost`,leftIcon:(0,C.jsx)(d,{}),onClick:z,disabled:!E,"aria-label":`Download ${n.filename}`,className:`mt-4 text-white/70 hover:bg-white/10 hover:text-white max-md:bg-transparent`,tintColor:`currentColor`,children:`Download`})]})}),M&&(0,C.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 z-10 flex justify-center`,style:{paddingBottom:`calc(var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + 2rem)`},onClick:e=>e.stopPropagation(),children:(0,C.jsxs)(c,{variant:`body-small-default`,className:`text-white/50`,children:[j+1,` / `,s.length]})})]}),document.body)};function Y(e,t){let[n,r]=(0,S.useState)(null),i=(0,S.useCallback)(e=>r(e),[]),a=(0,S.useCallback)(()=>r(null),[]),o=(0,S.useCallback)(e=>r(e),[]);return{openPreview:i,previewModal:n?(0,C.jsx)(J,{open:!0,onClose:a,attachment:n,assistantId:e,siblingAttachments:t,onNavigate:o}):null}}function X(e){return e!=null&&(e.startsWith(`vellum://workspace/`)||e.startsWith(`vellum://host/`))}function Z(e){return e.startsWith(`vellum://workspace/`)||e.startsWith(`vellum://host/`)?e:g(e)}function oe({href:e,children:t}){return(0,C.jsx)(`a`,{href:e,target:`_blank`,rel:E(e)?void 0:`noopener noreferrer`,onClick:t=>{A(e)&&t.preventDefault()},className:`text-[var(--system-positive-strong)] underline hover:opacity-80`,children:t})}var Q=`my-2 max-w-full max-h-[400px] rounded-lg border border-[var(--border-default)] object-contain`;function $({alt:e}){return(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-[var(--surface-sunken)] px-1.5 py-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Image failed to load`,e?` (${e})`:``]})}function se({src:e,alt:t}){let[n,r]=(0,S.useState)(!1);return n?(0,C.jsx)($,{alt:t}):(0,C.jsx)(`img`,{src:e,alt:t,onError:()=>r(!0),className:Q})}function ce(e){try{return decodeURIComponent(e)}catch{return e}}function le({src:e,alt:n,attachments:r,assistantId:i,onOpenPreview:a}){let[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),u=ce(e.split(`/`).pop()??``),d=r?.find(e=>e.filename===u);if((0,S.useEffect)(()=>{if(!d||!i||d.id.startsWith(`rehydrated:`))return;let e=!1;return(async()=>{try{let{data:t,error:n}=await y({path:{assistant_id:i,id:d.id},parseAs:`blob`,throwOnError:!1});if(e)return;if(n||!(t instanceof Blob)){l(!0);return}s(URL.createObjectURL(t))}catch(n){e||(l(!0),t(n,{context:`WorkspaceInlineImage`,bestEffort:!0}))}})(),()=>{e=!0,s(e=>(e&&URL.revokeObjectURL(e),null))}},[d,i]),c||!d&&!o)return(0,C.jsx)($,{alt:n||u});if(!o)return(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-[var(--surface-sunken)] px-1.5 py-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Loading image…`,n?` (${n})`:``]});let f=(0,C.jsx)(`img`,{src:o,alt:n,className:Q});return!d||!a?f:(0,C.jsx)(`button`,{type:`button`,onClick:()=>a(d),className:`cursor-zoom-in appearance-none border-0 bg-transparent p-0`,"aria-label":n?`Expand image: ${n}`:`Expand image`,children:f})}var ue=(0,S.memo)(function({content:e,className:t,hardLineBreaks:n,onVellumLinkClick:r,attachments:i,assistantId:a}){let{openPreview:o,previewModal:s}=Y(a,i);return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h,{content:e,className:t,hardLineBreaks:n,linkComponent:(0,S.useCallback)(({href:e,children:t})=>r&&X(e)?(0,C.jsx)(`a`,{href:e,onClick:t=>{t.preventDefault(),e&&r(e,t.currentTarget.textContent??``)},className:`text-[var(--system-positive-strong)] underline hover:opacity-80 cursor-pointer`,children:t}):(0,C.jsx)(oe,{href:e,children:t}),[r]),imageComponent:(0,S.useMemo)(()=>({src:e,alt:t})=>X(e)?(0,C.jsx)(le,{src:e,alt:t,attachments:i,assistantId:a,onOpenPreview:o}):(0,C.jsx)(se,{src:e,alt:t}),[i,a,o]),urlTransform:Z}),s]})});export{L as a,P as c,j as d,I as i,N as l,Y as n,F as o,J as r,z as s,ue as t,M as u};
|
|
2
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-Dhiismgm.js";import{t as n}from"./react-DJZBPgpf.js";import{F as r,t as i}from"./button-amTXFI-2.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{t as o}from"./useQuery-B45lW1Kk.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./typography-D5f7kt80.js";import{t as l}from"./chevron-left-BMF1xNfR.js";import{t as u}from"./chevron-right-DqqmezXC.js";import{t as d}from"./download-CAuK-nZ6.js";import{t as f}from"./file-DsyJLS2u.js";import{t as p}from"./loader-circle-Cz7opInR.js";import{t as m}from"./x-CkSVp1Ok.js";import{a as h,m as g}from"./src-B2IjVySQ.js";import{n as _,t as v}from"./file-markdown-BXUvAQ24.js";import{l as y}from"./sdk.gen-BwnFjFcp.js";import{t as b}from"./dist-DS5iJwBJ2.js";import{t as x}from"./browser-BPZAXjRE.js";var S=e(n(),1),ee=e(r(),1),C=s(),w=`width=500,height=600`;function T(e){if(!e)return null;let t;try{let n=typeof window>`u`?`http://localhost`:window.location.origin;t=new URL(e,n)}catch{return null}return t.protocol!==`https:`&&t.protocol!==`http:`?null:t}function E(e){let t=T(e);if(!t)return!1;let n=t.pathname.toLowerCase();return t.searchParams.get(`response_type`)===`code`&&t.searchParams.has(`client_id`)&&t.searchParams.has(`redirect_uri`)||t.searchParams.has(`client_id`)&&t.searchParams.has(`redirect_uri`)&&/oauth|authorize|auth/.test(n)}function D(e){if(typeof window>`u`)return null;let t=T(e);return!t||t.origin!==window.location.origin?null:`${t.pathname}${t.search}${t.hash}`}function O(e){return T(e)?.href??null}function k(e){if(!E(e))return!1;if(b.isNativePlatform()){let t=O(e);return t?(x(t),!0):!1}let t=window.open(e,`_blank`,w);return t===null?!1:(t.focus(),!0)}function A(e){return k(e)}function j(e){if(k(e))return!0;let t=window.open(e,`_blank`);return t===null?!1:(t.focus(),!0)}function M(e,t){let n=D(e);if(n)return t.push(n),{kind:`routed`};let r=O(e);return r?t.isNative?(x(r),{kind:`opened`}):j(r)?{kind:`opened`}:{kind:`blocked`,url:r}:{kind:`invalid`}}async function N(e,t){if(!t||t.startsWith(`rehydrated:`))return null;try{let{data:n,error:r}=await y({path:{assistant_id:e,id:t},parseAs:`blob`,throwOnError:!1});return!r&&n instanceof Blob?n:null}catch{return null}}async function P(e,t){let{saveFile:n}=await a(async()=>{let{saveFile:e}=await import(`./native-file-Cn3RbQbT.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));if(t){let r=await N(t,e.id);if(r){await n(r,e.filename);return}}e.previewUrl&&await n(e.previewUrl,e.filename)}function F(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||r===0?Math.round(n).toString():n.toFixed(1)} ${t[r]}`}function I(e,t){let n=(e||``).toLowerCase(),r=t.split(`.`).pop()?.toLowerCase()??``;return n.startsWith(`image/`)?`image`:n.startsWith(`video/`)?`video`:n.startsWith(`audio/`)?`audio`:n===`application/pdf`||r===`pdf`?`pdf`:n===`application/zip`||n===`application/x-tar`||n===`application/gzip`||[`zip`,`tar`,`gz`,`tgz`,`rar`,`7z`].includes(r)?`archive`:n===`text/csv`||n===`application/vnd.ms-excel`||n===`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`||[`csv`,`xlsx`,`xls`,`numbers`].includes(r)?`spreadsheet`:`ts.tsx.js.jsx.py.rb.go.rs.java.kt.swift.c.cc.cpp.h.hpp.sh.bash.zsh.html.css.scss.json.yaml.yml.toml.xml`.split(`.`).includes(r)?`code`:n===`application/msword`||n===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||[`doc`,`docx`,`pages`].includes(r)?`document`:n.startsWith(`text/`)||[`txt`,`md`,`rtf`].includes(r)?`text`:`file`}function L(e){let t=e.replace(/\s/g,``),n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return Math.max(0,Math.floor(t.length*3/4)-n)}function R(e){let t=e.match(/;base64,(.*)$/);if(!t?.[1])return null;let n=atob(t[1]),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function z(e,t=28){if(e.length<=t)return e;let n=Math.max(4,Math.floor((t-1)/2));return`${e.slice(0,n)}…${e.slice(e.length-n)}`}var B=1.5,V=20,H=!1;async function U(){let e=await a(()=>import(`./pdf-CuY9CA7Q.js`),__vite__mapDeps([4,2]));return H||=(e.GlobalWorkerOptions.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${e.version}/legacy/build/pdf.worker.min.mjs`,!0),e}function te({url:e,className:t}){let n=(0,S.useRef)(null),[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(0),[s,c]=(0,S.useState)(!0),[l,u]=(0,S.useState)(null),d=(0,S.useRef)(new Map),f=(0,S.useRef)(new Set);(0,S.useEffect)(()=>{let t=!1;async function n(){c(!0),u(null),i(null),o(0),f.current.clear();try{let n=await U(),r;if(e.startsWith(`data:`)){let t=R(e);r=t?{data:t}:e}else r=e;let a=await n.getDocument(r).promise;if(t){a.destroy();return}i(a),o(Math.min(a.numPages,V))}catch{t||u(`Failed to load PDF.`)}finally{t||c(!1)}}return n(),()=>{t=!0}},[e]),(0,S.useEffect)(()=>()=>{r&&r.destroy()},[r]);let m=(0,S.useCallback)(async e=>{if(!r||f.current.has(e))return;let t=d.current.get(e);if(t){f.current.add(e);try{let n=await r.getPage(e),i=n.getViewport({scale:B});t.width=i.width,t.height=i.height,await n.render({canvas:t,viewport:i}).promise}catch{f.current.delete(e)}}},[r]);(0,S.useEffect)(()=>{if(!r||a===0)return;let e=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=Number(t.target.dataset.page);e&&m(e)}},{root:n.current,rootMargin:`200px`});return d.current.forEach(t=>e.observe(t)),()=>e.disconnect()},[r,a,m]);let h=(0,S.useCallback)(e=>t=>{t?d.current.set(e,t):d.current.delete(e)},[]);return s?(0,C.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,C.jsx)(p,{className:`h-8 w-8 animate-spin text-white/70`})}):l?(0,C.jsx)(`div`,{className:`w-full max-w-sm rounded-lg border border-white/15 bg-white/[0.08] p-8 text-center`,children:(0,C.jsx)(`p`,{className:`text-body-medium-lighter text-white/80`,children:l})}):(0,C.jsx)(`div`,{ref:n,className:`flex max-h-[80vh] flex-col items-center gap-2 overflow-y-auto rounded ${t??``}`,children:Array.from({length:a},(e,t)=>(0,C.jsx)(`canvas`,{ref:h(t+1),"data-page":t+1,className:`w-[90vw] max-w-[800px]`,style:{height:`auto`}},t+1))})}function W({message:e,filename:t,onDownload:n,downloadDisabled:r=!1}){return(0,C.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border border-white/15 bg-white/[0.08] p-8 text-center`,children:[(0,C.jsx)(`p`,{className:`text-body-medium-lighter text-white/80`,children:e}),(0,C.jsx)(i,{variant:`ghost`,leftIcon:(0,C.jsx)(d,{}),onClick:n,disabled:r,"aria-label":`Download ${t}`,className:`mt-4 text-white/70 hover:bg-white/10 hover:text-white max-md:bg-transparent`,tintColor:`currentColor`,children:`Download`})]})}var G=class extends Error{};async function K(e,t,n){if(t>204800)throw new G;if(e.startsWith(`data:`)){let t=R(e);if(!t)throw Error(`Malformed data URI`);return new TextDecoder().decode(t)}let r=await fetch(e,{signal:n});if(!r.ok)throw Error(`Failed to load file: ${r.status}`);let i=await r.blob();if(i.size>204800)throw new G;return i.text()}function ne({url:e,filename:n,mimeType:r,sizeBytes:i}){let[o,s]=(0,S.useState)({status:`loading`});return(0,S.useEffect)(()=>{let n=new AbortController;return s({status:`loading`}),K(e,i,n.signal).then(e=>{n.signal.aborted||s({status:`ready`,text:e})}).catch(e=>{if(n.signal.aborted)return;let r=e instanceof G;r||t(e,{context:`attachment-text-preview`,bestEffort:!0}),s({status:`error`,tooLarge:r})}),()=>n.abort()},[e,i]),o.status===`loading`?(0,C.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,C.jsx)(p,{className:`h-8 w-8 animate-spin text-white/70`})}):o.status===`error`?(0,C.jsx)(W,{message:o.tooLarge?`File too large to preview inline.`:`Failed to load preview.`,filename:n,onDownload:async()=>{let{saveFile:t}=await a(async()=>{let{saveFile:e}=await import(`./native-file-Cn3RbQbT.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));await t(e,n)}}):(0,C.jsx)(`div`,{className:`max-h-[80vh] w-[min(90vw,800px)] overflow-auto rounded-lg p-6`,style:{backgroundColor:`var(--surface-overlay)`,color:`var(--content-default)`},children:(0,C.jsx)(re,{text:o.text,filename:n,mimeType:r})})}function re({text:e,filename:t,mimeType:n}){return _(t,n)?(0,C.jsx)(v,{content:e}):(0,C.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-body-small-default`,children:e})}var ie=new Set([`ts`,`tsx`,`js`,`jsx`,`py`,`json`,`md`,`sh`,`bash`,`html`,`css`,`yaml`,`yml`,`txt`]),ae=new Set([`application/json`,`application/javascript`,`application/xml`]),q=e=>{let t=e.lastIndexOf(`.`);return t===-1||t===e.length-1?``:e.slice(t+1).toLowerCase()},J=({open:e,onClose:t,attachment:n,assistantId:r,siblingAttachments:s,onNavigate:h})=>{let g=(0,S.useRef)(null),_=(0,S.useRef)(null);(0,S.useEffect)(()=>{e&&_.current?.focus()},[e]);let v=!n.previewUrl&&n.id.startsWith(`rehydrated:`),y=e&&!n.previewUrl&&!!r&&!!n.id&&!v,{data:b,isError:x}=o({queryKey:[`attachmentContent`,r,n.id],queryFn:async()=>{let e=await N(r,n.id);if(!e)throw Error(`Failed to load file`);return e},enabled:y,staleTime:1/0,retry:!1}),[w,T]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(!b){T(null);return}let e=URL.createObjectURL(b);return T(e),()=>{URL.revokeObjectURL(e),T(null)}},[b]);let E=n.previewUrl??w,[D,O]=(0,S.useState)(null),k=y&&!w&&!x,A=v?`Preview unavailable — file content was not preserved in chat history.`:x?`Failed to load preview.`:null,j=(0,S.useMemo)(()=>!s||s.length<=1?-1:s.findIndex(e=>e.id===n.id),[s,n.id]),M=j!==-1&&s!=null&&s.length>1,P=(0,S.useCallback)(()=>{!M||!s||!h||h(s[(j-1+s.length)%s.length])},[M,s,j,h]),I=(0,S.useCallback)(()=>{!M||!s||!h||h(s[(j+1)%s.length])},[M,s,j,h]),L=(0,S.useCallback)(e=>{e.key===`Escape`?(e.preventDefault(),t()):e.key===`ArrowLeft`&&M?(e.preventDefault(),P()):e.key===`ArrowRight`&&M&&(e.preventDefault(),I())},[t,P,I,M]),R=(0,S.useCallback)(e=>{e.target===g.current&&t()},[t]),z=(0,S.useCallback)(async()=>{if(!E)return;let{saveFile:e}=await a(async()=>{let{saveFile:e}=await import(`./native-file-Cn3RbQbT.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));await e(E,n.filename)},[E,n.filename]);if(!e)return null;let B=n.mimeType.toLowerCase(),V=B.startsWith(`image/`),H=B.startsWith(`video/`),U=B===`application/pdf`||B===`application/octet-stream`&&n.filename.toLowerCase().endsWith(`.pdf`),G=q(n.filename),K=B.startsWith(`text/`)||ae.has(B)||ie.has(G);return(0,ee.createPortal)((0,C.jsxs)(`div`,{ref:g,role:`dialog`,"aria-modal":`true`,"aria-label":`Preview of ${n.filename}`,className:`fixed inset-0 z-50 flex flex-col items-center justify-center bg-black/80 [-webkit-app-region:no-drag]`,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))`},onKeyDown:L,onClick:R,children:[(0,C.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-10 flex items-center gap-3 px-4`,style:{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1rem)`},children:[(0,C.jsx)(c,{variant:`body-small-default`,className:`w-11 shrink-0 truncate text-white/50`,children:F(n.sizeBytes)}),(0,C.jsx)(c,{as:`div`,variant:`body-medium-lighter`,className:`min-w-0 flex-1 truncate text-center text-white/90`,children:n.filename}),(0,C.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,C.jsx)(i,{variant:`ghost`,iconOnly:(0,C.jsx)(d,{}),expandOnMobile:!1,onClick:z,disabled:!E,"aria-label":`Download ${n.filename}`,className:`h-11 w-11 rounded-full bg-white/10 text-white/70 hover:bg-white/20 hover:text-white`,tintColor:`currentColor`}),(0,C.jsx)(i,{ref:_,variant:`ghost`,iconOnly:(0,C.jsx)(m,{}),expandOnMobile:!1,onClick:t,"aria-label":`Close preview`,className:`h-11 w-11 rounded-full bg-white/10 text-white/70 hover:bg-white/20 hover:text-white`,tintColor:`currentColor`})]})]}),M&&(0,C.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-1/2 z-10 flex -translate-y-1/2 items-center justify-between px-4`,children:[(0,C.jsx)(i,{variant:`ghost`,iconOnly:(0,C.jsx)(l,{}),expandOnMobile:!1,onClick:P,"aria-label":`Previous attachment`,className:`pointer-events-auto h-11 w-11 rounded-full bg-white/10 text-white/70 hover:bg-white/20 hover:text-white`,tintColor:`currentColor`}),(0,C.jsx)(i,{variant:`ghost`,iconOnly:(0,C.jsx)(u,{}),expandOnMobile:!1,onClick:I,"aria-label":`Next attachment`,className:`pointer-events-auto h-11 w-11 rounded-full bg-white/10 text-white/70 hover:bg-white/20 hover:text-white`,tintColor:`currentColor`})]}),(0,C.jsx)(`div`,{className:`flex items-center justify-center`,onClick:e=>e.stopPropagation(),children:k?(0,C.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,C.jsx)(p,{className:`h-8 w-8 animate-spin text-white/70`})}):A?(0,C.jsx)(W,{message:A,filename:n.filename,onDownload:z,downloadDisabled:!E}):U&&E?(0,C.jsx)(te,{url:E}):V&&E&&D!==E?(0,C.jsx)(`img`,{src:E,alt:n.filename,onError:()=>O(E),className:`max-h-[80vh] max-w-[90vw] rounded object-contain`}):H&&E?(0,C.jsx)(`video`,{"data-testid":`video-preview`,src:E,poster:n.thumbnailUrl??void 0,controls:!0,className:`max-h-[80vh] max-w-[90vw] rounded`}):K&&E?(0,C.jsx)(ne,{url:E,filename:n.filename,mimeType:n.mimeType,sizeBytes:n.sizeBytes}):(0,C.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col items-center rounded-lg border border-white/15 bg-white/[0.08] p-8 text-center`,children:[(0,C.jsx)(f,{className:`h-16 w-16 text-white/60`}),(0,C.jsx)(`p`,{className:`mt-4 text-body-medium-default text-white/90`,children:n.filename}),(0,C.jsx)(`p`,{className:`mt-1 text-body-small-default text-white/60`,children:F(n.sizeBytes)}),(0,C.jsx)(i,{variant:`ghost`,leftIcon:(0,C.jsx)(d,{}),onClick:z,disabled:!E,"aria-label":`Download ${n.filename}`,className:`mt-4 text-white/70 hover:bg-white/10 hover:text-white max-md:bg-transparent`,tintColor:`currentColor`,children:`Download`})]})}),M&&(0,C.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 z-10 flex justify-center`,style:{paddingBottom:`calc(var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + 2rem)`},onClick:e=>e.stopPropagation(),children:(0,C.jsxs)(c,{variant:`body-small-default`,className:`text-white/50`,children:[j+1,` / `,s.length]})})]}),document.body)};function Y(e,t){let[n,r]=(0,S.useState)(null),i=(0,S.useCallback)(e=>r(e),[]),a=(0,S.useCallback)(()=>r(null),[]),o=(0,S.useCallback)(e=>r(e),[]);return{openPreview:i,previewModal:n?(0,C.jsx)(J,{open:!0,onClose:a,attachment:n,assistantId:e,siblingAttachments:t,onNavigate:o}):null}}function X(e){return e!=null&&(e.startsWith(`vellum://workspace/`)||e.startsWith(`vellum://host/`))}function Z(e){return e.startsWith(`vellum://workspace/`)||e.startsWith(`vellum://host/`)?e:g(e)}function oe({href:e,children:t}){return(0,C.jsx)(`a`,{href:e,target:`_blank`,rel:E(e)?void 0:`noopener noreferrer`,onClick:t=>{A(e)&&t.preventDefault()},className:`text-[var(--system-positive-strong)] underline hover:opacity-80`,children:t})}var Q=`my-2 max-w-full max-h-[400px] rounded-lg border border-[var(--border-default)] object-contain`;function $({alt:e}){return(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-[var(--surface-sunken)] px-1.5 py-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Image failed to load`,e?` (${e})`:``]})}function se({src:e,alt:t}){let[n,r]=(0,S.useState)(!1);return n?(0,C.jsx)($,{alt:t}):(0,C.jsx)(`img`,{src:e,alt:t,onError:()=>r(!0),className:Q})}function ce(e){try{return decodeURIComponent(e)}catch{return e}}function le({src:e,alt:n,attachments:r,assistantId:i,onOpenPreview:a}){let[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),u=ce(e.split(`/`).pop()??``),d=r?.find(e=>e.filename===u);if((0,S.useEffect)(()=>{if(!d||!i||d.id.startsWith(`rehydrated:`))return;let e=!1;return(async()=>{try{let{data:t,error:n}=await y({path:{assistant_id:i,id:d.id},parseAs:`blob`,throwOnError:!1});if(e)return;if(n||!(t instanceof Blob)){l(!0);return}s(URL.createObjectURL(t))}catch(n){e||(l(!0),t(n,{context:`WorkspaceInlineImage`,bestEffort:!0}))}})(),()=>{e=!0,s(e=>(e&&URL.revokeObjectURL(e),null))}},[d,i]),c||!d&&!o)return(0,C.jsx)($,{alt:n||u});if(!o)return(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-[var(--surface-sunken)] px-1.5 py-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Loading image…`,n?` (${n})`:``]});let f=(0,C.jsx)(`img`,{src:o,alt:n,className:Q});return!d||!a?f:(0,C.jsx)(`button`,{type:`button`,onClick:()=>a(d),className:`cursor-zoom-in appearance-none border-0 bg-transparent p-0`,"aria-label":n?`Expand image: ${n}`:`Expand image`,children:f})}var ue=(0,S.memo)(function({content:e,className:t,hardLineBreaks:n,onVellumLinkClick:r,attachments:i,assistantId:a}){let{openPreview:o,previewModal:s}=Y(a,i);return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h,{content:e,className:t,hardLineBreaks:n,linkComponent:(0,S.useCallback)(({href:e,children:t})=>r&&X(e)?(0,C.jsx)(`a`,{href:e,onClick:t=>{t.preventDefault(),e&&r(e,t.currentTarget.textContent??``)},className:`text-[var(--system-positive-strong)] underline hover:opacity-80 cursor-pointer`,children:t}):(0,C.jsx)(oe,{href:e,children:t}),[r]),imageComponent:(0,S.useMemo)(()=>({src:e,alt:t})=>X(e)?(0,C.jsx)(le,{src:e,alt:t,attachments:i,assistantId:a,onOpenPreview:o}):(0,C.jsx)(se,{src:e,alt:t}),[i,a,o]),urlTransform:Z}),s]})});export{L as a,P as c,j as d,I as i,N as l,Y as n,F as o,J as r,z as s,ue as t,M as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{F as n,t as r}from"./button-amTXFI-2.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-D5f7kt80.js";import{t as o}from"./loader-circle-Cz7opInR.js";import{t as s}from"./x-CkSVp1Ok.js";import"./src-B2IjVySQ.js";import{t as c}from"./panel-item-CouW2A55.js";import{ji as l,vr as u}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{F as n,t as r}from"./button-amTXFI-2.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-D5f7kt80.js";import{t as o}from"./loader-circle-Cz7opInR.js";import{t as s}from"./x-CkSVp1Ok.js";import"./src-B2IjVySQ.js";import{t as c}from"./panel-item-CouW2A55.js";import{ji as l,vr as u}from"./index-BYfTlch9.js";var d=e(t(),1),f=e(n(),1),p=i();function m({icon:e,title:t,subtitle:n,shortcutHint:r,isSelected:i,onClick:a,surface:o=`overlay`}){let s=e;return o===`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:[s?(0,p.jsx)(s,{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)(c,{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:n,onQueryChange:i,selectedIndex:c,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,c]);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)(o,{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:n,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`}),n?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)(s,{size:16,"aria-hidden":!0})}):(0,p.jsx)(r,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(s,{}),"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)(r,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(s,{}),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===c,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-grqHUoNh.js";import{n as i}from"./resolved-assistants-store-BSZbT8Ju.js";import{D as a,O as o,i as s,n as c,o as l}from"./auth-store-
|
|
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-grqHUoNh.js";import{n as i}from"./resolved-assistants-store-BSZbT8Ju.js";import{D as a,O as o,i as s,n as c,o as l}from"./auth-store-CVs0OdtO.js";import{t as u}from"./client-feature-flag-store-C0g8zi1W.js";import{Cn as d,_r as f,bn as p,cn as m,tr as h,wr as g,yn as _}from"./index-BYfTlch9.js";import{CommandPalette as v}from"./command-palette-BvwNadPb.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();g(),h(!t),f({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}=d(A,!0),M=(0,y.useCallback)(e=>{let t=C(e);t&&p(t)},[]),{commandPalette:N,mergedSections:P,handleItemSelect:F}=m({assistantId:A,assistantName:k?.name,conversations:j,activeConversationId:void 0,startNewConversation:x,switchConversation:x,navigate:S,navigateToSettings:x,isOpen:!0,onClose:()=>{_()},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-amTXFI-2.js";import{t}from"./jsx-runtime-CVSDxk6A.js";import{t as n}from"./card-Bv5O5juh.js";import{t as r}from"./createLucideIcon-IRfcSUxS.js";import{r as i}from"./middleware-pbPQ0upo.js";import{t as a}from"./bug-BsuQ5ciQ.js";import{t as o}from"./external-link-Dqpx9nRm.js";import{t as s}from"./globe-4qSOWE2N.js";import{t as c}from"./sparkles-PGiR5v1g.js";import{t as l}from"./tag-CV4v7fRF.js";import{Li as u,Si as d,aa as f,f as p,gi as m,m as h,n as g,p as _,ut as v}from"./index-
|
|
1
|
+
import{t as e}from"./button-amTXFI-2.js";import{t}from"./jsx-runtime-CVSDxk6A.js";import{t as n}from"./card-Bv5O5juh.js";import{t as r}from"./createLucideIcon-IRfcSUxS.js";import{r as i}from"./middleware-pbPQ0upo.js";import{t as a}from"./bug-BsuQ5ciQ.js";import{t as o}from"./external-link-Dqpx9nRm.js";import{t as s}from"./globe-4qSOWE2N.js";import{t as c}from"./sparkles-PGiR5v1g.js";import{t as l}from"./tag-CV4v7fRF.js";import{Li as u,Si as d,aa as f,f as p,gi as m,m as h,n as g,p as _,ut as v}from"./index-BYfTlch9.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)(u,{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:a,icon:o,title:s,subtitle:c,benefits:l,primaryAction:u,secondaryAction:d}){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:o}),(0,b.jsx)(`span`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:a})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`h2`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:s}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:c})]}),(0,b.jsx)(`ul`,{className:`flex flex-col gap-3`,children:l.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:u.onClick,children:[u.icon,u.label]}),d&&(0,b.jsxs)(e,{variant:`ghost`,onClick:()=>window.open(d.href,`_blank`,`noopener,noreferrer`),children:[d.label,(0,b.jsx)(i,{className:`h-3.5 w-3.5`})]})]})]})})}function D({icon:e,iconBg:t,iconColor:r=`white`,title:i,description:a,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)(o,{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:a})]})]})})})}function O(){let{handleStar:e}=h();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:a,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:_}}),(0,b.jsx)(E,{accentColor:`#5865F2`,label:`Discord`,icon:(0,b.jsx)(v,{size:20}),title:`Join our community`,subtitle:`Talk to the team, share feedback, request features, and get answers faster.`,benefits:[{icon:f,text:`Talk directly with the team`},{icon:c,text:`Share feedback and request features`},{icon:m,text:`Get answers faster from the community`}],primaryAction:{label:`Join Discord`,icon:(0,b.jsx)(v,{size:16,style:{color:`currentColor`}}),onClick:p}})]}),(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)(s,{size:20}),iconBg:`#22c55e`,title:`Community Hub`,description:`Showcases, guides, and projects shared by the community.`,href:g}),(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-amTXFI-2.js";import{d as r,h as i,r as a,t as o}from"./chunk-5KNZJZUH-DdS6bb-3.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-D5f7kt80.js";import{t as f}from"./card-Bv5O5juh.js";import{t as p}from"./createLucideIcon-IRfcSUxS.js";import{t as m}from"./arrow-left-DI9551VI.js";import{t as h}from"./link-2-4bMylQ5v.js";import{t as g}from"./loader-circle-Cz7opInR.js";import{t as _}from"./pencil-CUIr0IFo.js";import{t as v}from"./plus-DItfr5ux.js";import{t as y}from"./user-plus-DMh4_UTz.js";import{t as b}from"./tag-CV4v7fRF.js";import{t as x}from"./input-CoUmPnRU.js";import{t as S}from"./modal-D5nLWNN9.js";import{t as C}from"./panel-item-CouW2A55.js";import{n as w}from"./toast-xTp-xwYL.js";import{t as T}from"./confirm-dialog-CSkhRFRk.js";import{C as E}from"./sdk.gen-jDeNbBv8.js";import{Ht as ee,S as D,Vt as te,a as O,b as ne,x as k}from"./react-query.gen-DOfazqkL.js";import{t as re}from"./assistant-identity-store-CX03CK8q.js";import{c as A}from"./routes-BbeIx_F9.js";import{t as ie}from"./assistant-feature-flag-store-CKUjJHuh.js";import{Ai as ae,Bi as j,Ea as M,Ji as N,Nt as P,Wi as oe,c as se,ja as F,ji as I,ka as L,ln as R,nr as z,oa as B,un as V,yr as H}from"./index-DQjUULFO.js";import{t as U}from"./use-active-assistant-id-BNRMo_Mi.js";import{a as ce,i as W,n as le,r as G,t as ue,u as de}from"./use-invite-link-dialog-JL5Jevln.js";import{t as K}from"./detail-card-RGTjHkZ8.js";import{n as fe,t as pe}from"./mobile-sidebar-drawer-DpvWGGSA.js";import{t as q}from"./mutation-error-CrhKyTkx.js";import{a as me,i as he,n as ge,t as _e}from"./contacts-gateway-CNqVHBQ3.js";var ve=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`}]]),ye=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`}]]),be=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`}]]),J=e(t(),1),xe=new Set([`slack`]);function Y(e){return e.status===`verified`||e.status===`active`&&e.verifiedAt!=null}var X=u();function Se({channels:e,pendingChannelKey:t=null,onConnect:n,onDisconnect:r}){let[i,a]=(0,J.useState)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,i)=>(0,X.jsxs)(`div`,{children:[i>0?(0,X.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}):null,(0,X.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,X.jsx)(T,{open:i!==null,title:`Disconnect ${i?V(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,X.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,X.jsx)(R,{channelId:e.key,className:`h-4 w-4 shrink-0 text-[color:var(--content-secondary)]`}),(0,X.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:V(e.key)}),a&&e.address?(0,X.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:e.address}):null,(0,X.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(M,{className:`h-3 w-3`}),`Connected`]}),(0,X.jsx)(n,{variant:`danger`,onClick:i,disabled:!i||t,children:t?`Disconnecting…`:`Disconnect`})]}):(0,X.jsx)(n,{variant:`outlined`,onClick:r,disabled:!r||t,children:`Connect`})})]})}function Q({role:e,contactType:t}){let{label:n,tone:r}=Ce(e,t);return(0,X.jsx)(b,{tone:r,children:n})}function Ce(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 we({assistantName:e,...t}){let n=de(e);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsx)(K,{title:`${n} (Your Assistant)`,accessory:(0,X.jsx)(Q,{role:`assistant`}),compactAccessory:!0}),(0,X.jsx)(K,{title:`Channels`,subtitle:`Where ${n} can be reached.`,children:(0,X.jsx)(Se,{...t})})]})}function Te({provenance:e}){return e.source===`global-default`?(0,X.jsx)(b,{children:`Global default`}):(0,X.jsxs)(b,{children:[`Default from`,(0,X.jsx)(n,{asChild:!0,variant:`link`,size:`compact`,className:`h-auto px-0`,children:(0,X.jsxs)(o,{to:`${A.channels}?setup=${e.channel}`,children:[`Channels → `,V(e.channel)]})})]})}var Ee=new Set([`telegram`,`phone`,`vellum`,`whatsapp`,`slack`,`email`,`platform`,`a2a`]);function $(e){return Ee.has(e)}function De(e,t){return e.id===`a2a`?t&&t.status!==`revoked`?{kind:`connected`}:{kind:`setup`}:t!=null&&Y(t)?{kind:`verified`}:t?.status===`blocked`?{kind:`none`}:t&&t.status!==`revoked`?{kind:`unverified`}:{kind:`setup`}}function Oe(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||$(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 ke({name:e,className:t,style:n}){switch(e){case`bot`:return(0,X.jsx)(L,{className:t,style:n});case`hash`:return(0,X.jsx)(B,{className:t,style:n});case`send`:return(0,X.jsx)(ae,{className:t,style:n});case`phone`:return(0,X.jsx)(j,{className:t,style:n});case`mail`:return(0,X.jsx)(N,{className:t,style:n});case`message-square`:return(0,X.jsx)(oe,{className:t,style:n});default:return(0,X.jsx)(ve,{className:t,style:n})}}function Ae({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,J.useState)(null),[p,m]=(0,J.useState)(null),h=new Map;for(let t of e)t.status!==`revoked`&&(h.has(t.type)||h.set(t.type,t));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex flex-col`,children:Oe(t,e,n).map((e,t)=>{let n=h.get(e.id);return(0,X.jsxs)(`div`,{children:[t>0&&(0,X.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),(0,X.jsx)(je,{info:e,existing:n,provenance:n&&P(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&&xe.has(e.id)?()=>u(e.id):void 0})]},e.id)})}),d&&(0,X.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,X.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 je({info:e,existing:t,provenance:r,setupLabel:i,verifyLoading:a,onSetup:o,onVerify:s,onRevoke:c,onLinkAccount:l}){let u=De(e,t);return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,X.jsx)(ke,{name:e.icon,className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),(0,X.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e.label}),t?.address?(0,X.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:t.address}):null,(0,X.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[r?(0,X.jsx)(Te,{provenance:r}):null,u.kind===`connected`?(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(M,{className:`h-3 w-3`}),`Connected`]}),c?(0,X.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`verified`?(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(M,{className:`h-3 w-3`}),`Verified`]}),c?(0,X.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`unverified`?(0,X.jsx)(n,{variant:`outlined`,onClick:s,disabled:!s||a,children:a?`Verifying…`:`Verify`}):u.kind===`setup`?e.id===`a2a`?null:(0,X.jsxs)(X.Fragment,{children:[l?(0,X.jsxs)(n,{onClick:l,children:[(0,X.jsx)(h,{className:`h-3.5 w-3.5`}),`Link account`]}):null,(0,X.jsx)(n,{variant:`outlined`,onClick:o,disabled:!o,children:i})]}):null]})]})}function Me(e){return(0,X.jsx)(Ne,{...e},e.contact.id)}function Ne({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,J.useState)(_?``:e.displayName),[b,S]=(0,J.useState)(e.notes??``),[C,w]=(0,J.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,A=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsx)(K,{title:re,accessory:(0,X.jsx)(Q,{role:e.role,contactType:e.contactType}),compactAccessory:!0,subtitle:A,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(x,{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,X.jsx)(x,{label:`Notes`,type:`text`,value:b,onChange:e=>S(e.target.value),placeholder:`Optional notes about the human which AI will take into account`,disabled:t||r,fullWidth:!0}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(n,{type:`button`,onClick:()=>u({displayName:E,notes:ee}),disabled:!ne,children:t?`Saving…`:`Save`}),f?(0,X.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,X.jsx)(n,{type:`button`,variant:`danger`,onClick:()=>{k?d():w(!0)},disabled:r,children:r?`Deleting…`:`Delete Contact`})]})]})}),(0,X.jsx)(K,{title:`Linked accounts`,subtitle:`Where the assistant recognizes this contact. Link accounts you know, invite the ones you don't.`,children:(0,X.jsx)(Ae,{contactChannels:e.channels,availableChannels:s,a2aEnabled:c,channelProvenance:l,verifyLoading:i,verifySubject:`contact`,onSetupChannel:p,onVerifyChannel:m,onRevokeChannel:h,onLinkAccount:g})}),(0,X.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 Pe(e){return(0,X.jsx)(Fe,{...e},`${e.survivor.id}:${e.open?`open`:`closed`}`)}function Fe({open:e,survivor:t,candidates:r,pending:i,errorMessage:a,onMerge:o,onClose:s}){let[c,l]=(0,J.useState)(``),[u,f]=(0,J.useState)(null);(0,J.useEffect)(()=>{u&&!r.some(e=>e.id===u)&&f(null)},[r,u]);let p=(0,J.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=Be(t);return(0,X.jsx)(S.Root,{open:e,onOpenChange:e=>{!e&&!i&&s()},children:(0,X.jsxs)(S.Content,{size:`md`,children:[(0,X.jsxs)(S.Header,{children:[(0,X.jsx)(S.Title,{icon:be,children:h?`Merge "${h.displayName}" into ${g}?`:`Merge another contact into ${g}`}),(0,X.jsx)(S.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,X.jsxs)(S.Body,{className:`flex flex-col gap-3`,children:[h?(0,X.jsx)(Re,{survivor:t,donor:h}):r.length===0?(0,X.jsx)(ze,{}):(0,X.jsx)(Ie,{search:c,onSearch:l,candidates:p,onPick:f}),a?(0,X.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-(--system-negative-strong)`,role:`alert`,children:a}):null]}),(0,X.jsx)(S.Footer,{children:h?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(n,{variant:`outlined`,onClick:()=>f(null),disabled:i,leftIcon:(0,X.jsx)(m,{"aria-hidden":!0}),children:`Back`}),(0,X.jsx)(n,{variant:`danger`,onClick:()=>o(h.id),disabled:i,children:i?`Merging…`:`Merge`})]}):(0,X.jsx)(n,{variant:`outlined`,onClick:s,disabled:i,children:`Cancel`})})]})})}function Ie({search:e,onSearch:t,candidates:n,onPick:r}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(x,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search contacts`,leftIcon:(0,X.jsx)(I,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}),(0,X.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,X.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,X.jsx)(Le,{contact:e,onPick:()=>r(e.id)},e.id))})]})}function Le({contact:e,onPick:t}){let n=We(e).join(` | `)||void 0;return(0,X.jsx)(C,{asChild:!0,label:``,children:(0,X.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,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e.displayName}),n?(0,X.jsx)(`span`,{className:`truncate text-body-small-default text-(--content-tertiary)`,children:n}):null]})})})}function Re({survivor:e,donor:t}){let n=Be(e),{moved:r,duplicates:i}=Ue(e,t);return(0,X.jsxs)(`ul`,{className:`flex flex-col gap-2 text-body-medium-lighter text-(--content-secondary)`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`span`,{className:`text-(--content-default)`,children:[`“`,t.displayName,`”`]}),` `,`will be deleted.`]}),(0,X.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=>He(e.type)).join(`, `)}.`}),i.length>0?(0,X.jsxs)(`li`,{className:`text-(--content-tertiary)`,children:[i.length,` duplicate channel`,i.length===1?``:`s`,` already on `,n,` `,`(skipped).`]}):null,t.notes?(0,X.jsx)(`li`,{children:`Notes from the merged contact will be appended.`}):null,(0,X.jsx)(`li`,{className:`text-(--content-tertiary)`,children:`This cannot be undone.`})]})}function ze(){return(0,X.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 Be(e){return e.role===`guardian`?!e.displayName||e.displayName.startsWith(`vellum-principal-`)?`you`:`${e.displayName} (you)`:e.displayName||`this contact`}var Ve={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`};function He(e){return Ve[e.toLowerCase()]??e}function Ue(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 We(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(Ve[e]??r.type))}return n}function Ge({loading:e,guardian:t,assistantName:r,regularContacts:i,selection:a,onSelect:o,onAddContact:s,addingContact:c=!1}){let[l,u]=(0,J.useState)(``),d=l.trim()?i.filter(e=>e.displayName.toLowerCase().includes(l.trim().toLowerCase())):i;return(0,X.jsx)(f.Root,{className:`flex h-full flex-col overflow-hidden`,children:(0,X.jsxs)(f.Body,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:`Entries`}),(0,X.jsx)(n,{type:`button`,variant:`ghost`,iconOnly:c?(0,X.jsx)(g,{className:`animate-spin`,"aria-hidden":!0}):(0,X.jsx)(v,{"aria-hidden":!0}),onClick:s,disabled:c,"aria-label":`Add contact`,tintColor:`var(--content-secondary)`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t?(0,X.jsx)(Ke,{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,X.jsx)(Ke,{name:r?.trim()||`Your Assistant`,role:`assistant`,selected:a?.kind===`assistant`,onClick:()=>o({kind:`assistant`}),trailingIcon:`more`})]}),(0,X.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),i.length>0?(0,X.jsx)(x,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search Contacts`,leftIcon:(0,X.jsx)(I,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}):null,i.length>0?(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto flex flex-col gap-1`,children:[d.map(e=>(0,X.jsx)(Ke,{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,X.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,X.jsx)(n,{type:`button`,variant:`ghost`,onClick:s,disabled:c,tintColor:`var(--primary-base)`,leftIcon:c?(0,X.jsx)(g,{className:`animate-spin`,"aria-hidden":!0}):(0,X.jsx)(y,{"aria-hidden":!0}),children:`Add Contact`})]})})}function Ke({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,X.jsx)(C,{asChild:!0,active:i,label:``,trailingAction:o===`pencil`?(0,X.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):o===`more`?(0,X.jsx)(ye,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):void 0,children:(0,X.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,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e}),c?(0,X.jsx)(`span`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:c}):null]}),(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[s===void 0?null:(0,X.jsx)(b,{tone:s?`positive`:`neutral`,children:s?`Verified`:`Unverified`}),(0,X.jsx)(Q,{role:t,contactType:n})]})]})})}function qe(e){return(0,X.jsx)(Je,{...e},e.contact.id)}function Je({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,J.useState)(h),[v,y]=(0,J.useState)(e.notes??``),b=g.trim(),S=v.trim(),C=b!==h.trim()||S!==(e.notes??``).trim(),w=C&&!t,T=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsx)(K,{title:m?`You`:`${e.displayName} (You)`,accessory:(0,X.jsx)(Q,{role:`guardian`}),compactAccessory:!0,subtitle:T,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(x,{label:`Name`,type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Your name`,disabled:t,fullWidth:!0}),(0,X.jsx)(x,{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,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(n,{variant:`primary`,onClick:()=>c({displayName:b||e.displayName,notes:S}),disabled:!w,children:t?`Saving…`:`Save`}),l?(0,X.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,X.jsx)(K,{title:`Channels`,subtitle:`Once verified, your assistant will recognize you when you message from these channels.`,children:(0,X.jsx)(Ae,{contactChannels:e.channels,availableChannels:o,a2aEnabled:s,setupLabel:`Verify me`,verifyLoading:r,onSetupChannel:u,onVerifyChannel:d,onRevokeChannel:f})}),p?(0,X.jsx)(W,{onClick:p}):null]})}function Ye(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 Xe(e){let t=e.trim().split(/\s+/).filter(Boolean);return`${t[0]?.[0]??`?`}${t.length>1?t[t.length-1]?.[0]??``:``}`.toUpperCase()}function Ze({open:e,channelLabel:t,contactName:r,accounts:i,loading:a,errorMessage:o,pendingAccountId:s,onPick:c,onClose:l,onInviteInstead:u}){let[d,f]=(0,J.useState)(``);(0,J.useEffect)(()=>{e&&f(``)},[e]);let p=(0,J.useMemo)(()=>Ye(i??[],d),[i,d]),m=s!=null;return(0,X.jsx)(S.Root,{open:e,onOpenChange:e=>!e&&l(),children:(0,X.jsxs)(S.Content,{size:`sm`,children:[(0,X.jsxs)(S.Header,{children:[(0,X.jsxs)(S.Title,{children:[`Link `,t,` account`]}),(0,X.jsxs)(S.Description,{children:[`Search your `,t,` workspace and pick`,` `,(0,X.jsx)(`span`,{className:`text-[color:var(--content-default)]`,children:r}),`’s account.`]})]}),(0,X.jsxs)(S.Body,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(x,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search by name or @handle`,"aria-label":`Search ${t} workspace accounts`,leftIcon:(0,X.jsx)(I,{className:`h-4 w-4`}),fullWidth:!0}),o?(0,X.jsx)(`p`,{className:`text-body-small-default text-[color:var(--content-negative)]`,children:o}):null,(0,X.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:a?(0,X.jsx)(`p`,{className:`py-4 text-center text-body-small-default text-[color:var(--content-tertiary)]`,children:`Loading workspace members…`}):p.length===0?(0,X.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,X.jsx)(`ul`,{className:`flex flex-col`,children:p.map(e=>(0,X.jsx)(`li`,{children:(0,X.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,X.jsx)(`img`,{src:e.imageUrl,alt:``,className:`h-8 w-8 shrink-0 rounded-full`}):(0,X.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:Xe(e.displayName)}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default text-[color:var(--content-default)]`,children:e.displayName}),(0,X.jsxs)(`span`,{className:`truncate text-body-small-default text-[color:var(--content-tertiary)]`,children:[`@`,e.username]})]}),s===e.id?(0,X.jsx)(`span`,{className:`ml-auto shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:`Linking…`}):null]})},e.id))})})]}),(0,X.jsxs)(S.Footer,{className:`items-center justify-between gap-3 border-t border-[var(--border-base)]`,children:[(0,X.jsxs)(`p`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:[`Picking marks this account as`,` `,(0,X.jsx)(`span`,{className:`text-[color:var(--content-secondary)]`,children:`guardian-linked`}),` `,`— you vouch for the identity, no handshake needed.`]}),u?(0,X.jsxs)(n,{variant:`link`,className:`shrink-0`,onClick:u,disabled:m,children:[`Or send an invite instead`,(0,X.jsx)(F,{className:`h-3.5 w-3.5`})]}):null]})]})})}function Qe(e){let t={};for(let n of e)P(n.channelType)&&(t[n.channelType]=n.policy===`trusted_contacts`?{source:`global-default`}:{source:`channel-default`,channel:n.channelType});return t}function $e(e){return Qe(G(e))}function et(e){let t=ie.use.channelTrustFloors(),n=c({...z({path:{assistant_id:e}}),enabled:t,select:$e});return t?n.data:void 0}function tt({assistantId:e,channelType:t,contact:n,onLinked:r}){let[i,a]=(0,J.useState)(!1),o=l({mutationFn:n=>ge(e,n.contact,{type:t,address:n.account.id}),onSuccess:(e,t)=>{a(!1),w.success(`Linked as @${t.account.username}`),r()}}),s=(0,J.useCallback)(()=>{o.reset(),a(!0)},[o]),c=(0,J.useCallback)(()=>{o.isPending||(o.reset(),a(!1))},[o]),u=(0,J.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 nt=[{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?`}}],rt=[];function it({assistantId:e,onStartSetupConversation:t}){let n=ie.use.a2aChannel(),r=re.use.name(),o=s(),[u]=i(),d=u.get(`setup`),f=d&&P(d)?d:null,[p,m]=(0,J.useState)({kind:`assistant`}),h=ue(e),[g,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(!1),b=de(r),x=(0,J.useMemo)(()=>({path:{assistant_id:e}}),[e]),S=k(x),C=c({...ne(x),enabled:!!e,select:e=>e.contacts}),T=le({assistantId:e,onStartSetupConversation:t}),ae=et(e),j=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:nt};if(!i.ok)throw r??Error(`Failed to fetch channel availability`);return n},select:e=>e.channels}).data??rt,M=C.data,N=(0,J.useMemo)(()=>M?.find(e=>e.role===`guardian`)??null,[M]),oe=(0,J.useMemo)(()=>M?.filter(e=>e.role!==`guardian`)??[],[M]),F=(0,J.useMemo)(()=>p.kind===`contact`?M?.find(e=>e.id===p.contactId)??null:null,[M,p]),I=(0,J.useMemo)(()=>!M||!F?[]:M.filter(e=>e.id!==F.id&&e.role!==`guardian`),[M,F]),L=I.length>0,R=(0,J.useRef)(!!f);(0,J.useEffect)(()=>{R.current||N&&(R.current=!0,m({kind:`contact`,contactId:N.id}))},[N]);let z=(0,J.useCallback)(()=>o.invalidateQueries({queryKey:S}),[o,S]),B=l({mutationFn:()=>he(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:q(`Failed to create contact`),onSettled:()=>z()}),V=l({mutationFn:t=>_e(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:q(`Failed to delete contact`),onSettled:()=>z()}),H=l({mutationFn:({contactId:t,patch:n})=>he(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:q(`Failed to save contact`),onSettled:()=>z()}),U=ee({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:()=>z()}),W=(0,J.useCallback)(e=>{m(e),_(!1),y(!1),U.reset()},[U]),G=(0,J.useCallback)(()=>{U.reset(),y(!0)},[U]),K=(0,J.useCallback)(()=>{U.isPending||(y(!1),U.reset())},[U]),ge=te({onSuccess:()=>z()}),ve=(0,J.useCallback)((t,n)=>{ge.mutate({path:{assistant_id:e,contactChannelId:t},body:{status:`revoked`}})},[ge,e]),ye=(0,J.useCallback)(()=>{B.isPending||B.mutate()},[B]),be=(0,J.useCallback)(e=>{if(!t)return;let n=j.find(t=>t.id===e)?.setupMessages.contact;n&&t(n)},[j,t]),xe=(0,J.useCallback)(e=>{if(!t)return;let n=j.find(t=>t.id===e)?.setupMessages.guardian;n&&t(n)},[j,t]),Y=l({mutationFn:t=>me(e,t.channelId),onSuccess:()=>z(),onError:q(`Failed to verify channel`)}),Se=(0,J.useCallback)(e=>{if(!F)return;let t=F.channels.find(t=>t.type===e&&t.status!==`revoked`);t&&Y.mutate({channelId:t.id})},[F,Y]),Z=tt({assistantId:e,channelType:`slack`,contact:F?{id:F.id,displayName:F.displayName}:null,onLinked:z}),Q=c({...se(e),enabled:!!e&&Z.dialogOpen,select:e=>e.users}),Ce=T.channels.some(e=>e.key===`slack`&&e.status===`ready`),Te=(0,J.useCallback)(e=>{e===Z.channelType&&Z.open()},[Z]),Ee=V.isPending?V.variables:null,$=(0,J.useMemo)(()=>F?H.isPending&&H.variables?.contactId===F.id?{...F,displayName:H.variables.patch.displayName,notes:H.variables.patch.notes}:F:null,[F,H.isPending,H.variables]);if(f)return(0,X.jsx)(a,{to:`${A.channels}?setup=${f}`,replace:!0});let De={loading:C.isLoading,assistantName:b,guardian:N?{id:N.id,displayName:N.displayName.startsWith(`vellum-principal-`)?``:N.displayName,role:N.role,channelTypes:ct(N.channels,n)}:null,regularContacts:oe.filter(e=>e.id!==Ee).map(e=>({id:e.id,displayName:e.displayName,role:e.role,contactType:e.contactType,channelTypes:ct(e.channels,n),verified:st(e.channels)})),selection:p,onAddContact:ye,addingContact:B.isPending};return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden sm:flex-row sm:gap-6`,children:[(0,X.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,X.jsx)(fe,{onClick:()=>_(!0)})}),(0,X.jsx)(pe,{open:g,onClose:()=>_(!1),title:`Contacts`,children:(0,X.jsx)(Ge,{...De,onSelect:W})}),(0,X.jsx)(`aside`,{className:`hidden min-h-0 w-[320px] shrink-0 overflow-y-auto self-stretch sm:block`,children:(0,X.jsx)(Ge,{...De,onSelect:W})}),(0,X.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,X.jsx)(we,{assistantName:b,channels:T.channels,pendingChannelKey:T.pendingChannelKey,onConnect:T.onSetup,onDisconnect:T.onDisconnect}):$?$.role===`guardian`?(0,X.jsx)(qe,{contact:$,savePending:H.isPending,verifyPending:Y.isPending,mergePending:U.isPending,canMerge:L,availableChannels:j,a2aEnabled:n,onSave:e=>{H.mutate({contactId:$.id,patch:e})},onMerge:G,onSetupChannel:t?xe:void 0,onVerifyChannel:Se,onRevokeChannel:ve,onGenerateInviteLink:n?h.open:void 0}):(0,X.jsx)(Me,{contact:$,savePending:H.isPending,deletePending:V.isPending,verifyPending:Y.isPending,mergePending:U.isPending,canMerge:L,availableChannels:j,a2aEnabled:n,channelProvenance:ae,onSave:e=>{H.mutate({contactId:$.id,patch:e})},onDelete:()=>{V.mutate($.id)},onMerge:G,onSetupChannel:t?be:void 0,onVerifyChannel:Se,onRevokeChannel:ve,onLinkAccount:Ce?Te:void 0}):(0,X.jsx)(at,{})}),F?(0,X.jsx)(Pe,{open:v,survivor:F,candidates:I,pending:U.isPending,errorMessage:U.error instanceof Error?U.error.message:U.error?`Failed to merge contacts`:null,onMerge:t=>U.mutate({path:{assistant_id:e},body:{keepId:F.id,mergeId:t}}),onClose:K}):null,(0,X.jsx)(Ze,{open:Z.dialogOpen,channelLabel:`Slack`,contactName:F?.displayName??``,accounts:Q.data,loading:Q.isLoading,errorMessage:Q.isError?`Couldn’t load the workspace roster. Check the Slack connection and try again.`:Z.linkErrorMessage,pendingAccountId:Z.pendingAccountId,onPick:Z.pick,onClose:Z.close,onInviteInstead:t?()=>{Z.close(),be(Z.channelType)}:void 0}),(0,X.jsx)(ce,{open:h.isOpen,assistantId:e,onClose:h.close})]})}function at(){return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center py-16`,children:(0,X.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a contact`})})}var ot={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`,a2a:`A2A`};function st(e){return e.some(e=>e.status!==`revoked`&&(e.type===`a2a`||Y(e)))}function ct(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(ot[e]??i.type))}return r}function lt(){let e=r(),t=U();return(0,X.jsx)(it,{assistantId:t,onStartSetupConversation:t=>{H(e,{prompt:t})}},t)}export{lt as ContactsPageRoute};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-amTXFI-2.js";import{d as r,h as i,r as a,t as o}from"./chunk-5KNZJZUH-DdS6bb-3.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-D5f7kt80.js";import{t as f}from"./card-Bv5O5juh.js";import{t as p}from"./createLucideIcon-IRfcSUxS.js";import{t as m}from"./arrow-left-DI9551VI.js";import{t as h}from"./link-2-4bMylQ5v.js";import{t as g}from"./loader-circle-Cz7opInR.js";import{t as _}from"./pencil-CUIr0IFo.js";import{t as v}from"./plus-DItfr5ux.js";import{t as y}from"./user-plus-DMh4_UTz.js";import{t as b}from"./tag-CV4v7fRF.js";import{t as x}from"./input-CoUmPnRU.js";import{t as S}from"./modal-D5nLWNN9.js";import{t as C}from"./panel-item-CouW2A55.js";import{n as w}from"./toast-xTp-xwYL.js";import{t as T}from"./confirm-dialog-CSkhRFRk.js";import{C as E}from"./sdk.gen-BwnFjFcp.js";import{Ht as ee,S as D,Vt as te,a as O,b as ne,x as k}from"./react-query.gen-C6wVk6Rw.js";import{t as re}from"./assistant-identity-store-CX03CK8q.js";import{c as A}from"./routes-BbeIx_F9.js";import{t as ie}from"./assistant-feature-flag-store-CKUjJHuh.js";import{Ai as ae,Bi as j,Ea as M,Ji as N,Nt as P,Wi as oe,c as se,ja as F,ji as I,ka as L,ln as R,nr as z,oa as B,un as V,yr as H}from"./index-BYfTlch9.js";import{t as U}from"./use-active-assistant-id-BNRMo_Mi.js";import{a as ce,i as W,n as le,r as G,t as ue,u as de}from"./use-invite-link-dialog-C_z3cWhR.js";import{t as K}from"./detail-card-RGTjHkZ8.js";import{n as fe,t as pe}from"./mobile-sidebar-drawer-dvuldt8a.js";import{t as q}from"./mutation-error-CrhKyTkx.js";import{a as me,i as he,n as ge,t as _e}from"./contacts-gateway-CNqVHBQ3.js";var ve=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`}]]),ye=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`}]]),be=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`}]]),J=e(t(),1),xe=new Set([`slack`]);function Y(e){return e.status===`verified`||e.status===`active`&&e.verifiedAt!=null}var X=u();function Se({channels:e,pendingChannelKey:t=null,onConnect:n,onDisconnect:r}){let[i,a]=(0,J.useState)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,i)=>(0,X.jsxs)(`div`,{children:[i>0?(0,X.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}):null,(0,X.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,X.jsx)(T,{open:i!==null,title:`Disconnect ${i?V(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,X.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,X.jsx)(R,{channelId:e.key,className:`h-4 w-4 shrink-0 text-[color:var(--content-secondary)]`}),(0,X.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:V(e.key)}),a&&e.address?(0,X.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:e.address}):null,(0,X.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(M,{className:`h-3 w-3`}),`Connected`]}),(0,X.jsx)(n,{variant:`danger`,onClick:i,disabled:!i||t,children:t?`Disconnecting…`:`Disconnect`})]}):(0,X.jsx)(n,{variant:`outlined`,onClick:r,disabled:!r||t,children:`Connect`})})]})}function Q({role:e,contactType:t}){let{label:n,tone:r}=Ce(e,t);return(0,X.jsx)(b,{tone:r,children:n})}function Ce(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 we({assistantName:e,...t}){let n=de(e);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsx)(K,{title:`${n} (Your Assistant)`,accessory:(0,X.jsx)(Q,{role:`assistant`}),compactAccessory:!0}),(0,X.jsx)(K,{title:`Channels`,subtitle:`Where ${n} can be reached.`,children:(0,X.jsx)(Se,{...t})})]})}function Te({provenance:e}){return e.source===`global-default`?(0,X.jsx)(b,{children:`Global default`}):(0,X.jsxs)(b,{children:[`Default from`,(0,X.jsx)(n,{asChild:!0,variant:`link`,size:`compact`,className:`h-auto px-0`,children:(0,X.jsxs)(o,{to:`${A.channels}?setup=${e.channel}`,children:[`Channels → `,V(e.channel)]})})]})}var Ee=new Set([`telegram`,`phone`,`vellum`,`whatsapp`,`slack`,`email`,`platform`,`a2a`]);function $(e){return Ee.has(e)}function De(e,t){return e.id===`a2a`?t&&t.status!==`revoked`?{kind:`connected`}:{kind:`setup`}:t!=null&&Y(t)?{kind:`verified`}:t?.status===`blocked`?{kind:`none`}:t&&t.status!==`revoked`?{kind:`unverified`}:{kind:`setup`}}function Oe(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||$(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 ke({name:e,className:t,style:n}){switch(e){case`bot`:return(0,X.jsx)(L,{className:t,style:n});case`hash`:return(0,X.jsx)(B,{className:t,style:n});case`send`:return(0,X.jsx)(ae,{className:t,style:n});case`phone`:return(0,X.jsx)(j,{className:t,style:n});case`mail`:return(0,X.jsx)(N,{className:t,style:n});case`message-square`:return(0,X.jsx)(oe,{className:t,style:n});default:return(0,X.jsx)(ve,{className:t,style:n})}}function Ae({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,J.useState)(null),[p,m]=(0,J.useState)(null),h=new Map;for(let t of e)t.status!==`revoked`&&(h.has(t.type)||h.set(t.type,t));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex flex-col`,children:Oe(t,e,n).map((e,t)=>{let n=h.get(e.id);return(0,X.jsxs)(`div`,{children:[t>0&&(0,X.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),(0,X.jsx)(je,{info:e,existing:n,provenance:n&&P(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&&xe.has(e.id)?()=>u(e.id):void 0})]},e.id)})}),d&&(0,X.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,X.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 je({info:e,existing:t,provenance:r,setupLabel:i,verifyLoading:a,onSetup:o,onVerify:s,onRevoke:c,onLinkAccount:l}){let u=De(e,t);return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,X.jsx)(ke,{name:e.icon,className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),(0,X.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e.label}),t?.address?(0,X.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:t.address}):null,(0,X.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[r?(0,X.jsx)(Te,{provenance:r}):null,u.kind===`connected`?(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(M,{className:`h-3 w-3`}),`Connected`]}),c?(0,X.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`verified`?(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(M,{className:`h-3 w-3`}),`Verified`]}),c?(0,X.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`unverified`?(0,X.jsx)(n,{variant:`outlined`,onClick:s,disabled:!s||a,children:a?`Verifying…`:`Verify`}):u.kind===`setup`?e.id===`a2a`?null:(0,X.jsxs)(X.Fragment,{children:[l?(0,X.jsxs)(n,{onClick:l,children:[(0,X.jsx)(h,{className:`h-3.5 w-3.5`}),`Link account`]}):null,(0,X.jsx)(n,{variant:`outlined`,onClick:o,disabled:!o,children:i})]}):null]})]})}function Me(e){return(0,X.jsx)(Ne,{...e},e.contact.id)}function Ne({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,J.useState)(_?``:e.displayName),[b,S]=(0,J.useState)(e.notes??``),[C,w]=(0,J.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,A=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsx)(K,{title:re,accessory:(0,X.jsx)(Q,{role:e.role,contactType:e.contactType}),compactAccessory:!0,subtitle:A,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(x,{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,X.jsx)(x,{label:`Notes`,type:`text`,value:b,onChange:e=>S(e.target.value),placeholder:`Optional notes about the human which AI will take into account`,disabled:t||r,fullWidth:!0}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(n,{type:`button`,onClick:()=>u({displayName:E,notes:ee}),disabled:!ne,children:t?`Saving…`:`Save`}),f?(0,X.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,X.jsx)(n,{type:`button`,variant:`danger`,onClick:()=>{k?d():w(!0)},disabled:r,children:r?`Deleting…`:`Delete Contact`})]})]})}),(0,X.jsx)(K,{title:`Linked accounts`,subtitle:`Where the assistant recognizes this contact. Link accounts you know, invite the ones you don't.`,children:(0,X.jsx)(Ae,{contactChannels:e.channels,availableChannels:s,a2aEnabled:c,channelProvenance:l,verifyLoading:i,verifySubject:`contact`,onSetupChannel:p,onVerifyChannel:m,onRevokeChannel:h,onLinkAccount:g})}),(0,X.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 Pe(e){return(0,X.jsx)(Fe,{...e},`${e.survivor.id}:${e.open?`open`:`closed`}`)}function Fe({open:e,survivor:t,candidates:r,pending:i,errorMessage:a,onMerge:o,onClose:s}){let[c,l]=(0,J.useState)(``),[u,f]=(0,J.useState)(null);(0,J.useEffect)(()=>{u&&!r.some(e=>e.id===u)&&f(null)},[r,u]);let p=(0,J.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=Be(t);return(0,X.jsx)(S.Root,{open:e,onOpenChange:e=>{!e&&!i&&s()},children:(0,X.jsxs)(S.Content,{size:`md`,children:[(0,X.jsxs)(S.Header,{children:[(0,X.jsx)(S.Title,{icon:be,children:h?`Merge "${h.displayName}" into ${g}?`:`Merge another contact into ${g}`}),(0,X.jsx)(S.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,X.jsxs)(S.Body,{className:`flex flex-col gap-3`,children:[h?(0,X.jsx)(Re,{survivor:t,donor:h}):r.length===0?(0,X.jsx)(ze,{}):(0,X.jsx)(Ie,{search:c,onSearch:l,candidates:p,onPick:f}),a?(0,X.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-(--system-negative-strong)`,role:`alert`,children:a}):null]}),(0,X.jsx)(S.Footer,{children:h?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(n,{variant:`outlined`,onClick:()=>f(null),disabled:i,leftIcon:(0,X.jsx)(m,{"aria-hidden":!0}),children:`Back`}),(0,X.jsx)(n,{variant:`danger`,onClick:()=>o(h.id),disabled:i,children:i?`Merging…`:`Merge`})]}):(0,X.jsx)(n,{variant:`outlined`,onClick:s,disabled:i,children:`Cancel`})})]})})}function Ie({search:e,onSearch:t,candidates:n,onPick:r}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(x,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search contacts`,leftIcon:(0,X.jsx)(I,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}),(0,X.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,X.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,X.jsx)(Le,{contact:e,onPick:()=>r(e.id)},e.id))})]})}function Le({contact:e,onPick:t}){let n=We(e).join(` | `)||void 0;return(0,X.jsx)(C,{asChild:!0,label:``,children:(0,X.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,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e.displayName}),n?(0,X.jsx)(`span`,{className:`truncate text-body-small-default text-(--content-tertiary)`,children:n}):null]})})})}function Re({survivor:e,donor:t}){let n=Be(e),{moved:r,duplicates:i}=Ue(e,t);return(0,X.jsxs)(`ul`,{className:`flex flex-col gap-2 text-body-medium-lighter text-(--content-secondary)`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`span`,{className:`text-(--content-default)`,children:[`“`,t.displayName,`”`]}),` `,`will be deleted.`]}),(0,X.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=>He(e.type)).join(`, `)}.`}),i.length>0?(0,X.jsxs)(`li`,{className:`text-(--content-tertiary)`,children:[i.length,` duplicate channel`,i.length===1?``:`s`,` already on `,n,` `,`(skipped).`]}):null,t.notes?(0,X.jsx)(`li`,{children:`Notes from the merged contact will be appended.`}):null,(0,X.jsx)(`li`,{className:`text-(--content-tertiary)`,children:`This cannot be undone.`})]})}function ze(){return(0,X.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 Be(e){return e.role===`guardian`?!e.displayName||e.displayName.startsWith(`vellum-principal-`)?`you`:`${e.displayName} (you)`:e.displayName||`this contact`}var Ve={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`};function He(e){return Ve[e.toLowerCase()]??e}function Ue(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 We(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(Ve[e]??r.type))}return n}function Ge({loading:e,guardian:t,assistantName:r,regularContacts:i,selection:a,onSelect:o,onAddContact:s,addingContact:c=!1}){let[l,u]=(0,J.useState)(``),d=l.trim()?i.filter(e=>e.displayName.toLowerCase().includes(l.trim().toLowerCase())):i;return(0,X.jsx)(f.Root,{className:`flex h-full flex-col overflow-hidden`,children:(0,X.jsxs)(f.Body,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:`Entries`}),(0,X.jsx)(n,{type:`button`,variant:`ghost`,iconOnly:c?(0,X.jsx)(g,{className:`animate-spin`,"aria-hidden":!0}):(0,X.jsx)(v,{"aria-hidden":!0}),onClick:s,disabled:c,"aria-label":`Add contact`,tintColor:`var(--content-secondary)`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t?(0,X.jsx)(Ke,{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,X.jsx)(Ke,{name:r?.trim()||`Your Assistant`,role:`assistant`,selected:a?.kind===`assistant`,onClick:()=>o({kind:`assistant`}),trailingIcon:`more`})]}),(0,X.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),i.length>0?(0,X.jsx)(x,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search Contacts`,leftIcon:(0,X.jsx)(I,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}):null,i.length>0?(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto flex flex-col gap-1`,children:[d.map(e=>(0,X.jsx)(Ke,{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,X.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,X.jsx)(n,{type:`button`,variant:`ghost`,onClick:s,disabled:c,tintColor:`var(--primary-base)`,leftIcon:c?(0,X.jsx)(g,{className:`animate-spin`,"aria-hidden":!0}):(0,X.jsx)(y,{"aria-hidden":!0}),children:`Add Contact`})]})})}function Ke({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,X.jsx)(C,{asChild:!0,active:i,label:``,trailingAction:o===`pencil`?(0,X.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):o===`more`?(0,X.jsx)(ye,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):void 0,children:(0,X.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,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e}),c?(0,X.jsx)(`span`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:c}):null]}),(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[s===void 0?null:(0,X.jsx)(b,{tone:s?`positive`:`neutral`,children:s?`Verified`:`Unverified`}),(0,X.jsx)(Q,{role:t,contactType:n})]})]})})}function qe(e){return(0,X.jsx)(Je,{...e},e.contact.id)}function Je({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,J.useState)(h),[v,y]=(0,J.useState)(e.notes??``),b=g.trim(),S=v.trim(),C=b!==h.trim()||S!==(e.notes??``).trim(),w=C&&!t,T=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsx)(K,{title:m?`You`:`${e.displayName} (You)`,accessory:(0,X.jsx)(Q,{role:`guardian`}),compactAccessory:!0,subtitle:T,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(x,{label:`Name`,type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Your name`,disabled:t,fullWidth:!0}),(0,X.jsx)(x,{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,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(n,{variant:`primary`,onClick:()=>c({displayName:b||e.displayName,notes:S}),disabled:!w,children:t?`Saving…`:`Save`}),l?(0,X.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,X.jsx)(K,{title:`Channels`,subtitle:`Once verified, your assistant will recognize you when you message from these channels.`,children:(0,X.jsx)(Ae,{contactChannels:e.channels,availableChannels:o,a2aEnabled:s,setupLabel:`Verify me`,verifyLoading:r,onSetupChannel:u,onVerifyChannel:d,onRevokeChannel:f})}),p?(0,X.jsx)(W,{onClick:p}):null]})}function Ye(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 Xe(e){let t=e.trim().split(/\s+/).filter(Boolean);return`${t[0]?.[0]??`?`}${t.length>1?t[t.length-1]?.[0]??``:``}`.toUpperCase()}function Ze({open:e,channelLabel:t,contactName:r,accounts:i,loading:a,errorMessage:o,pendingAccountId:s,onPick:c,onClose:l,onInviteInstead:u}){let[d,f]=(0,J.useState)(``);(0,J.useEffect)(()=>{e&&f(``)},[e]);let p=(0,J.useMemo)(()=>Ye(i??[],d),[i,d]),m=s!=null;return(0,X.jsx)(S.Root,{open:e,onOpenChange:e=>!e&&l(),children:(0,X.jsxs)(S.Content,{size:`sm`,children:[(0,X.jsxs)(S.Header,{children:[(0,X.jsxs)(S.Title,{children:[`Link `,t,` account`]}),(0,X.jsxs)(S.Description,{children:[`Search your `,t,` workspace and pick`,` `,(0,X.jsx)(`span`,{className:`text-[color:var(--content-default)]`,children:r}),`’s account.`]})]}),(0,X.jsxs)(S.Body,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(x,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search by name or @handle`,"aria-label":`Search ${t} workspace accounts`,leftIcon:(0,X.jsx)(I,{className:`h-4 w-4`}),fullWidth:!0}),o?(0,X.jsx)(`p`,{className:`text-body-small-default text-[color:var(--content-negative)]`,children:o}):null,(0,X.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:a?(0,X.jsx)(`p`,{className:`py-4 text-center text-body-small-default text-[color:var(--content-tertiary)]`,children:`Loading workspace members…`}):p.length===0?(0,X.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,X.jsx)(`ul`,{className:`flex flex-col`,children:p.map(e=>(0,X.jsx)(`li`,{children:(0,X.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,X.jsx)(`img`,{src:e.imageUrl,alt:``,className:`h-8 w-8 shrink-0 rounded-full`}):(0,X.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:Xe(e.displayName)}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default text-[color:var(--content-default)]`,children:e.displayName}),(0,X.jsxs)(`span`,{className:`truncate text-body-small-default text-[color:var(--content-tertiary)]`,children:[`@`,e.username]})]}),s===e.id?(0,X.jsx)(`span`,{className:`ml-auto shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:`Linking…`}):null]})},e.id))})})]}),(0,X.jsxs)(S.Footer,{className:`items-center justify-between gap-3 border-t border-[var(--border-base)]`,children:[(0,X.jsxs)(`p`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:[`Picking marks this account as`,` `,(0,X.jsx)(`span`,{className:`text-[color:var(--content-secondary)]`,children:`guardian-linked`}),` `,`— you vouch for the identity, no handshake needed.`]}),u?(0,X.jsxs)(n,{variant:`link`,className:`shrink-0`,onClick:u,disabled:m,children:[`Or send an invite instead`,(0,X.jsx)(F,{className:`h-3.5 w-3.5`})]}):null]})]})})}function Qe(e){let t={};for(let n of e)P(n.channelType)&&(t[n.channelType]=n.policy===`trusted_contacts`?{source:`global-default`}:{source:`channel-default`,channel:n.channelType});return t}function $e(e){return Qe(G(e))}function et(e){let t=ie.use.channelTrustFloors(),n=c({...z({path:{assistant_id:e}}),enabled:t,select:$e});return t?n.data:void 0}function tt({assistantId:e,channelType:t,contact:n,onLinked:r}){let[i,a]=(0,J.useState)(!1),o=l({mutationFn:n=>ge(e,n.contact,{type:t,address:n.account.id}),onSuccess:(e,t)=>{a(!1),w.success(`Linked as @${t.account.username}`),r()}}),s=(0,J.useCallback)(()=>{o.reset(),a(!0)},[o]),c=(0,J.useCallback)(()=>{o.isPending||(o.reset(),a(!1))},[o]),u=(0,J.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 nt=[{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?`}}],rt=[];function it({assistantId:e,onStartSetupConversation:t}){let n=ie.use.a2aChannel(),r=re.use.name(),o=s(),[u]=i(),d=u.get(`setup`),f=d&&P(d)?d:null,[p,m]=(0,J.useState)({kind:`assistant`}),h=ue(e),[g,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(!1),b=de(r),x=(0,J.useMemo)(()=>({path:{assistant_id:e}}),[e]),S=k(x),C=c({...ne(x),enabled:!!e,select:e=>e.contacts}),T=le({assistantId:e,onStartSetupConversation:t}),ae=et(e),j=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:nt};if(!i.ok)throw r??Error(`Failed to fetch channel availability`);return n},select:e=>e.channels}).data??rt,M=C.data,N=(0,J.useMemo)(()=>M?.find(e=>e.role===`guardian`)??null,[M]),oe=(0,J.useMemo)(()=>M?.filter(e=>e.role!==`guardian`)??[],[M]),F=(0,J.useMemo)(()=>p.kind===`contact`?M?.find(e=>e.id===p.contactId)??null:null,[M,p]),I=(0,J.useMemo)(()=>!M||!F?[]:M.filter(e=>e.id!==F.id&&e.role!==`guardian`),[M,F]),L=I.length>0,R=(0,J.useRef)(!!f);(0,J.useEffect)(()=>{R.current||N&&(R.current=!0,m({kind:`contact`,contactId:N.id}))},[N]);let z=(0,J.useCallback)(()=>o.invalidateQueries({queryKey:S}),[o,S]),B=l({mutationFn:()=>he(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:q(`Failed to create contact`),onSettled:()=>z()}),V=l({mutationFn:t=>_e(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:q(`Failed to delete contact`),onSettled:()=>z()}),H=l({mutationFn:({contactId:t,patch:n})=>he(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:q(`Failed to save contact`),onSettled:()=>z()}),U=ee({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:()=>z()}),W=(0,J.useCallback)(e=>{m(e),_(!1),y(!1),U.reset()},[U]),G=(0,J.useCallback)(()=>{U.reset(),y(!0)},[U]),K=(0,J.useCallback)(()=>{U.isPending||(y(!1),U.reset())},[U]),ge=te({onSuccess:()=>z()}),ve=(0,J.useCallback)((t,n)=>{ge.mutate({path:{assistant_id:e,contactChannelId:t},body:{status:`revoked`}})},[ge,e]),ye=(0,J.useCallback)(()=>{B.isPending||B.mutate()},[B]),be=(0,J.useCallback)(e=>{if(!t)return;let n=j.find(t=>t.id===e)?.setupMessages.contact;n&&t(n)},[j,t]),xe=(0,J.useCallback)(e=>{if(!t)return;let n=j.find(t=>t.id===e)?.setupMessages.guardian;n&&t(n)},[j,t]),Y=l({mutationFn:t=>me(e,t.channelId),onSuccess:()=>z(),onError:q(`Failed to verify channel`)}),Se=(0,J.useCallback)(e=>{if(!F)return;let t=F.channels.find(t=>t.type===e&&t.status!==`revoked`);t&&Y.mutate({channelId:t.id})},[F,Y]),Z=tt({assistantId:e,channelType:`slack`,contact:F?{id:F.id,displayName:F.displayName}:null,onLinked:z}),Q=c({...se(e),enabled:!!e&&Z.dialogOpen,select:e=>e.users}),Ce=T.channels.some(e=>e.key===`slack`&&e.status===`ready`),Te=(0,J.useCallback)(e=>{e===Z.channelType&&Z.open()},[Z]),Ee=V.isPending?V.variables:null,$=(0,J.useMemo)(()=>F?H.isPending&&H.variables?.contactId===F.id?{...F,displayName:H.variables.patch.displayName,notes:H.variables.patch.notes}:F:null,[F,H.isPending,H.variables]);if(f)return(0,X.jsx)(a,{to:`${A.channels}?setup=${f}`,replace:!0});let De={loading:C.isLoading,assistantName:b,guardian:N?{id:N.id,displayName:N.displayName.startsWith(`vellum-principal-`)?``:N.displayName,role:N.role,channelTypes:ct(N.channels,n)}:null,regularContacts:oe.filter(e=>e.id!==Ee).map(e=>({id:e.id,displayName:e.displayName,role:e.role,contactType:e.contactType,channelTypes:ct(e.channels,n),verified:st(e.channels)})),selection:p,onAddContact:ye,addingContact:B.isPending};return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden sm:flex-row sm:gap-6`,children:[(0,X.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,X.jsx)(fe,{onClick:()=>_(!0)})}),(0,X.jsx)(pe,{open:g,onClose:()=>_(!1),title:`Contacts`,children:(0,X.jsx)(Ge,{...De,onSelect:W})}),(0,X.jsx)(`aside`,{className:`hidden min-h-0 w-[320px] shrink-0 overflow-y-auto self-stretch sm:block`,children:(0,X.jsx)(Ge,{...De,onSelect:W})}),(0,X.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,X.jsx)(we,{assistantName:b,channels:T.channels,pendingChannelKey:T.pendingChannelKey,onConnect:T.onSetup,onDisconnect:T.onDisconnect}):$?$.role===`guardian`?(0,X.jsx)(qe,{contact:$,savePending:H.isPending,verifyPending:Y.isPending,mergePending:U.isPending,canMerge:L,availableChannels:j,a2aEnabled:n,onSave:e=>{H.mutate({contactId:$.id,patch:e})},onMerge:G,onSetupChannel:t?xe:void 0,onVerifyChannel:Se,onRevokeChannel:ve,onGenerateInviteLink:n?h.open:void 0}):(0,X.jsx)(Me,{contact:$,savePending:H.isPending,deletePending:V.isPending,verifyPending:Y.isPending,mergePending:U.isPending,canMerge:L,availableChannels:j,a2aEnabled:n,channelProvenance:ae,onSave:e=>{H.mutate({contactId:$.id,patch:e})},onDelete:()=>{V.mutate($.id)},onMerge:G,onSetupChannel:t?be:void 0,onVerifyChannel:Se,onRevokeChannel:ve,onLinkAccount:Ce?Te:void 0}):(0,X.jsx)(at,{})}),F?(0,X.jsx)(Pe,{open:v,survivor:F,candidates:I,pending:U.isPending,errorMessage:U.error instanceof Error?U.error.message:U.error?`Failed to merge contacts`:null,onMerge:t=>U.mutate({path:{assistant_id:e},body:{keepId:F.id,mergeId:t}}),onClose:K}):null,(0,X.jsx)(Ze,{open:Z.dialogOpen,channelLabel:`Slack`,contactName:F?.displayName??``,accounts:Q.data,loading:Q.isLoading,errorMessage:Q.isError?`Couldn’t load the workspace roster. Check the Slack connection and try again.`:Z.linkErrorMessage,pendingAccountId:Z.pendingAccountId,onPick:Z.pick,onClose:Z.close,onInviteInstead:t?()=>{Z.close(),be(Z.channelType)}:void 0}),(0,X.jsx)(ce,{open:h.isOpen,assistantId:e,onClose:h.close})]})}function at(){return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center py-16`,children:(0,X.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a contact`})})}var ot={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`,a2a:`A2A`};function st(e){return e.some(e=>e.status!==`revoked`&&(e.type===`a2a`||Y(e)))}function ct(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(ot[e]??i.type))}return r}function lt(){let e=r(),t=U();return(0,X.jsx)(it,{assistantId:t,onStartSetupConversation:t=>{H(e,{prompt:t})}},t)}export{lt as ContactsPageRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./capture-error-Dhiismgm.js";import{t}from"./queryOptions-BtNi-_9H.js";import{Q as n}from"./sdk.gen-
|
|
1
|
+
import{t as e}from"./capture-error-Dhiismgm.js";import{t}from"./queryOptions-BtNi-_9H.js";import{Q as n}from"./sdk.gen-BwnFjFcp.js";import{n as r,r as i,t as a}from"./api-errors-CrWDzVca.js";function o(e){return e.surfacedAt==null?e.conversationType===`background`||e.conversationType===`scheduled`||e.groupId===`system:background`||e.groupId===`system:scheduled`:!1}function s(e){return e.conversationType===`scheduled`||e.groupId===`system:scheduled`}function c(e){return!e.hasUnseenLatestAssistantMessage&&!o(e)&&e.conversationId!=null&&e.latestAssistantMessageAt!=null}function l(e){return e.hasUnseenLatestAssistantMessage===!0&&!o(e)&&e.conversationId!=null}function u(e){return e.hasUnseenLatestAssistantMessage===!0&&!o(e)&&e.archivedAt==null}function d(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function f(e){return typeof e==`string`?e:void 0}function p(e){if(e)return{sourceChannel:e.sourceChannel,externalChatId:e.externalChatId,externalThreadId:e.externalThreadId,externalChatName:e.externalChatName,externalUserId:f(e.externalUserId),displayName:f(e.displayName),username:f(e.username),slackChannel:e.slackChannel?{channelId:e.slackChannel.channelId,name:e.slackChannel.name,link:e.slackChannel.link?.webUrl?{webUrl:e.slackChannel.link.webUrl}:void 0}:void 0,slackThread:e.slackThread?{channelId:e.slackThread.channelId,threadTs:e.slackThread.threadTs,link:e.slackThread.link?.appUrl||e.slackThread.link?.webUrl?{appUrl:e.slackThread.link.appUrl,webUrl:e.slackThread.link.webUrl}:void 0}:void 0}}function m(e){let t=e.assistantAttention,n=e.channelBinding?.sourceChannel??f(e.conversationOriginChannel);return{conversationId:e.id,title:e.title,createdAt:d(e.createdAt),lastMessageAt:d(e.lastMessageAt??e.updatedAt),hasUnseenLatestAssistantMessage:t?.hasUnseenLatestAssistantMessage,latestAssistantMessageAt:d(t?.latestAssistantMessageAt),lastSeenAssistantMessageAt:d(t?.lastSeenAssistantMessageAt),archivedAt:e.archivedAt,surfacedAt:d(e.surfacedAt),groupId:f(e.groupId),source:e.source,isPinned:e.isPinned,conversationType:e.conversationType,scheduleJobId:e.scheduleJobId,displayOrder:d(e.displayOrder),channelBinding:p(e.channelBinding),originChannel:n,isProcessing:e.isProcessing}}function h(e){return m(e)}var g=`conversation-list`;function _(e){return[g,e??``]}function v(e){return[g,e??``,`foreground`]}function y(e){return[g,e??``,`archived`]}function b(e){return[g,e??``,`background`]}function x(e){return[g,e??``,`scheduled`]}function S(e){return[g,e??``,`channel`]}function C(e){return(t,n)=>(n[e]??0)-(t[e]??0)}var w=50,T=200;async function E(e,t,o={}){let{conversationType:s,archiveStatus:c,originChannel:l}=o,{data:u,error:d,response:f}=await n({path:{assistant_id:e},query:{limit:w,offset:t,...s?{conversationType:s}:{},...c?{archiveStatus:c}:{},...l?{originChannel:l}:{}},throwOnError:!1});if(r(f,d,`Failed to list conversations.`),!f.ok){let e=i(d,f,`Failed to list conversations.`);throw new a(f.status,e)}return{conversations:(u?.conversations??[]).map(m),hasMore:u?.hasMore??!1}}async function D(e,t={}){let n=[],r=new Set;for(let i=0;i<T;i++){let{conversations:a,hasMore:o}=await E(e,i*w,t);for(let e of a)r.has(e.conversationId)||(r.add(e.conversationId),n.push(e));if(!o||a.length===0)break}return n}async function O(t,n=`active`,r=`lastMessageAt`){let i=n===`active`?{}:{archiveStatus:n},a={...i,conversationType:`background`},[o,s]=await Promise.allSettled([D(t,i),D(t,a)]);if(o.status===`rejected`)throw o.reason;let c=o.value,l=[];s.status===`fulfilled`?l=s.value:e(s.reason,{context:`fetchMergedConversationList.background(${n})`,level:`warning`,extra:{assistantId:t}});let u=new Set,d=[];for(let e of[...c,...l])u.has(e.conversationId)||(u.add(e.conversationId),d.push(e));return d.sort(C(r)),d}async function k(e){return[...await D(e)].sort(C(`lastMessageAt`))}async function A(e){let{conversations:t}=await E(e,0);return t.length>0}async function j(e){return(await D(e,{conversationType:`background`})).filter(e=>!s(e)).sort(C(`lastMessageAt`))}async function M(e){return[...await D(e,{conversationType:`scheduled`})].sort(C(`lastMessageAt`))}async function N(e){return O(e,`archived`,`archivedAt`)}async function P(e){let t=await E(e,0);return{...t,conversations:[...t.conversations].sort(C(`lastMessageAt`))}}async function F(e){let t=await E(e,0,{conversationType:`background`});return{...t,conversations:t.conversations.filter(e=>!s(e)).sort(C(`lastMessageAt`))}}async function I(e){let t=await E(e,0,{conversationType:`scheduled`});return{...t,conversations:[...t.conversations].sort(C(`lastMessageAt`))}}var L=3e4;function R(e){return t({queryKey:v(e),queryFn:()=>k(e),staleTime:L})}function z(e){return t({queryKey:b(e),queryFn:()=>j(e),staleTime:L})}function B(e){return t({queryKey:x(e),queryFn:()=>M(e),staleTime:L})}function V(e){return t({queryKey:y(e),queryFn:()=>N(e),staleTime:L})}export{c as _,R as a,s as b,A as c,I as d,S as f,l as g,h,b as i,F as l,x as m,y as n,_ as o,B as p,z as r,v as s,V as t,P as u,u as v,o as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{r as t}from"./capture-error-Dhiismgm.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-amTXFI-2.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-Bv5O5juh.js";import{t as c}from"./copy-Cn1FKrEp.js";import{t as l}from"./key-round-CD3JWrs1.js";import{t as u}from"./link-2-4bMylQ5v.js";import{t as d}from"./loader-circle-Cz7opInR.js";import{t as f}from"./plus-DItfr5ux.js";import{t as p}from"./input-CoUmPnRU.js";import{t as m}from"./modal-D5nLWNN9.js";import{n as h}from"./toast-xTp-xwYL.js";import{t as g}from"./confirm-dialog-CSkhRFRk.js";import{
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{r as t}from"./capture-error-Dhiismgm.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-amTXFI-2.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-Bv5O5juh.js";import{t as c}from"./copy-Cn1FKrEp.js";import{t as l}from"./key-round-CD3JWrs1.js";import{t as u}from"./link-2-4bMylQ5v.js";import{t as d}from"./loader-circle-Cz7opInR.js";import{t as f}from"./plus-DItfr5ux.js";import{t as p}from"./input-CoUmPnRU.js";import{t as m}from"./modal-D5nLWNN9.js";import{n as h}from"./toast-xTp-xwYL.js";import{t as g}from"./confirm-dialog-CSkhRFRk.js";import{Ir as _,lt as ee}from"./sdk.gen-BwnFjFcp.js";import{Ut as v,Wt as y}from"./react-query.gen-C6wVk6Rw.js";import{t as b}from"./use-is-org-ready-B7B3xHAy.js";import{t as x}from"./assistant-feature-flag-store-CKUjJHuh.js";import{t as S,yi as C}from"./index-BYfTlch9.js";import{t as w}from"./use-active-assistant-id-BNRMo_Mi.js";var T=e(n(),1);function E(e){return e>0xe8d4a51000?e:e*1e3}async function D(e,t){let{data:n,response:r}=await _.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}var O=o();function k(e){return[`credentials-list`,e]}function te(e){if(!e)return``;try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return``}}function A(){let e=x.use.credentialsSettings(),t=x.use.hasHydrated();return t&&!e?(0,O.jsx)(S,{}):t?(0,O.jsx)(j,{}):null}function j(){let e=w(),n=i(),o=b(),_=x.use.credentialRequests(),S=k(e),A=a({queryKey:S,queryFn:async()=>{let{data:t}=await ee({path:{assistant_id:e},body:{},throwOnError:!0});return{credentials:t.credentials,managedCredentials:t.managedCredentials}},enabled:o,retry:t}),j=A.data?.credentials??[],M=A.data?.managedCredentials??[],N=y({onSuccess:()=>{n.invalidateQueries({queryKey:S}),h.success(`Credential saved.`)},onError:e=>{h.error(e.message||`Failed to save credential`)}}),P=v({onError:e=>{h.error(e.message||`Failed to delete credential`)}}),[F,I]=(0,T.useState)(!1),[L,R]=(0,T.useState)(``),[z,B]=(0,T.useState)(``),[V,H]=(0,T.useState)(``),[U,W]=(0,T.useState)(``),[G,K]=(0,T.useState)(null),[q,J]=(0,T.useState)(null),[Y,X]=(0,T.useState)(null),Z=N.isPending,Q=P.isPending?`${P.variables?.body?.service}:${P.variables?.body?.field}`:null,$=()=>{I(!1),R(``),B(``),H(``),W(``)},ne=()=>{let t=L.trim(),n=z.trim();!t||!n||!V.trim()||N.mutate({path:{assistant_id:e},body:{service:t,field:n,value:V,label:U.trim()||void 0}},{onSuccess:$})},re=()=>{let t=G;K(null),t&&P.mutate({path:{assistant_id:e},body:{service:t.service,field:t.field}},{onSuccess:()=>{n.invalidateQueries({queryKey:S}),h.success(`Deleted ${t.service}:${t.field}.`)}})},ie=async t=>{let n=`${t.service}:${t.field}`;X(n);try{let r=await D(e,{service:t.service,field:t.field,label:t.alias??void 0});r.ok&&r.url?J({name:n,url:r.url,expiresAt:r.expiresAt??null}):h.error(r.error||`Failed to generate a one-time link`)}catch(e){h.error(e instanceof Error?e.message:`Failed to generate a one-time link`)}finally{X(null)}},ae=()=>{let e=q?.url;e&&navigator.clipboard.writeText(e).then(()=>h.success(`Link copied to clipboard.`),()=>h.error(`Couldn't copy the link — select it and copy manually.`))};if(A.isLoading)return(0,O.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,O.jsx)(d,{className:`h-5 w-5 animate-spin text-[var(--content-disabled)]`})});let oe=F||j.length===0;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,O.jsx)(`p`,{className:`text-body-small-default leading-relaxed text-[var(--content-tertiary)]`,children:`Credentials are stored encrypted in your assistant's credential vault. Values are write-only — they can be replaced or deleted, but not viewed here.`}),j.length>0?(0,O.jsx)(s.Root,{children:(0,O.jsx)(s.Body,{className:`flex flex-col divide-y divide-[var(--border-default)]`,children:j.map(e=>{let t=`${e.service}:${e.field}`;return(0,O.jsxs)(`div`,{className:`flex items-center gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,O.jsx)(l,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e.alias||t}),(0,O.jsxs)(`p`,{className:`truncate font-mono text-body-small-default text-[var(--content-tertiary)]`,children:[e.alias?`${t} · `:``,e.scrubbedValue,e.createdAt?` · added ${te(e.createdAt)}`:``]})]}),_?(0,O.jsx)(r,{type:`button`,variant:`ghost`,size:`compact`,onClick:()=>void ie(e),disabled:Y===t,"aria-label":`Generate one-time link for ${t}`,title:`Generate one-time link`,iconOnly:Y===t?(0,O.jsx)(d,{className:`animate-spin`,"aria-hidden":!0}):(0,O.jsx)(u,{"aria-hidden":!0})}):null,(0,O.jsx)(r,{type:`button`,variant:`ghost`,size:`compact`,onClick:()=>K(e),disabled:Q===t,"aria-label":`Delete ${t}`,iconOnly:Q===t?(0,O.jsx)(d,{className:`animate-spin`,"aria-hidden":!0}):(0,O.jsx)(C,{"aria-hidden":!0})})]},e.credentialId??t)})})}):null,oe?(0,O.jsx)(s.Root,{children:(0,O.jsxs)(s.Body,{className:`flex flex-col gap-3`,children:[(0,O.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:j.length===0?`Add a credential`:`Add another credential`}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[(0,O.jsx)(p,{label:`Service`,type:`text`,value:L,onChange:e=>R(e.target.value),placeholder:`e.g. github`,fullWidth:!0}),(0,O.jsx)(p,{label:`Field`,type:`text`,value:z,onChange:e=>B(e.target.value),placeholder:`e.g. api_token`,fullWidth:!0})]}),(0,O.jsx)(p,{label:`Value`,type:`password`,value:V,onChange:e=>H(e.target.value),placeholder:`Enter the secret value`,fullWidth:!0}),(0,O.jsx)(p,{label:`Label (optional)`,type:`text`,value:U,onChange:e=>W(e.target.value),placeholder:`e.g. GitHub personal access token`,fullWidth:!0}),(0,O.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-1`,children:[j.length>0?(0,O.jsx)(r,{type:`button`,variant:`outlined`,size:`compact`,onClick:$,disabled:Z,children:`Cancel`}):null,(0,O.jsx)(r,{type:`button`,size:`compact`,onClick:ne,disabled:Z||!L.trim()||!z.trim()||!V.trim(),leftIcon:Z?(0,O.jsx)(d,{className:`animate-spin`,"aria-hidden":!0}):void 0,children:`Save Credential`})]})]})}):(0,O.jsx)(r,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>I(!0),className:`w-full border-dashed`,leftIcon:(0,O.jsx)(f,{"aria-hidden":!0}),children:`Add Credential`}),M.length>0?(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Managed by Vellum`}),(0,O.jsx)(s.Root,{children:(0,O.jsx)(s.Body,{className:`flex flex-col divide-y divide-[var(--border-default)]`,children:M.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,O.jsx)(l,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e.provider}),(0,O.jsxs)(`p`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[e.accountInfo??e.handle,` ·`,` `,e.status]})]})]},e.handle))})})]}):null,(0,O.jsx)(g,{open:G!==null,title:`Delete credential`,message:G?`Delete ${G.service}:${G.field}? Tools and integrations using it will lose access.`:``,confirmLabel:`Delete`,destructive:!0,onConfirm:re,onCancel:()=>K(null)}),(0,O.jsx)(m.Root,{open:q!==null,onOpenChange:e=>{e||J(null)},children:(0,O.jsxs)(m.Content,{size:`sm`,children:[(0,O.jsxs)(m.Header,{children:[(0,O.jsx)(m.Title,{icon:u,children:`One-time credential link`}),(0,O.jsx)(m.Description,{children:q?`Send this link to whoever should provide ${q.name}. It works exactly once${q.expiresAt===null?``:` and expires ${new Date(E(q.expiresAt)).toLocaleString()}`}. Anyone with the link can set this credential, so share it over a trusted channel.`:``})]}),(0,O.jsx)(m.Body,{children:(0,O.jsx)(p,{label:`Link`,type:`text`,readOnly:!0,value:q?.url??``,onFocus:e=>e.currentTarget.select(),fullWidth:!0})}),(0,O.jsx)(m.Footer,{children:(0,O.jsx)(r,{type:`button`,size:`compact`,onClick:ae,leftIcon:(0,O.jsx)(c,{"aria-hidden":!0}),children:`Copy link`})})]})})]})}export{A as CredentialsPage};
|