1var b=(u,p,a)=>new Promise((f,h)=>{var g=s=>{try{m(a.next(s))}catch(n){h(n)}},x=s=>{try{m(a.throw(s))}catch(n){h(n)}},m=s=>s.done?f(s.value):Promise.resolve(s.value).then(g,x);m((a=a.apply(u,p)).next())});import{j as e}from"./vendor-framer-D8dO-b0k.js";import"./InternationalPhoneField-Dx5PKh9n.js";import{r as o}from"./vendor-react-pZQaDvDc.js";import{S as A}from"./SEO-B5im8YTh.js";import{A as E}from"./AgentMemberSession-BZlaiZ8C.js";import"./index-CkemRdey.js";import"./vendor-firebase-p_iMPr39.js";import"./firebase-BsqF83MS.js";function I(){const[u,p]=o.useState(!1),[a,f]=o.useState(""),[h,g]=o.useState([]),[x,m]=o.useState(!1),[s,n]=o.useState(""),c=o.useRef(""),i=o.useRef(0),j=o.useCallback(t=>b(this,null,function*(){if(!t||t!==c.current)return;const r=++i.current;m(!0),n("");try{const d=yield fetch("/v1/me/connected-apps",{credentials:"include",cache:"no-store",headers:{"X-Mesh-Expected-Account-Uid":t}}),l=yield d.json();if(r!==i.current||c.current!==t)return;if(!d.ok)throw new Error(l.message||"Mesh could not load connected apps.");g(l.connectedApps||[])}catch(d){r===i.current&&c.current===t&&n(d instanceof Error?d.message:"Mesh could not load connected apps.")}finally{r===i.current&&c.current===t&&m(!1)}}),[]);o.useEffect(()=>{u&&a&&j(a)},[a,u,j]);function N(t){return b(this,null,function*(){if(!window.confirm(`Disconnect ${t.clientName} from your Mesh account?`))return;const r=c.current;if(!r)return;const d=i.current;n("");try{const l=yield fetch(`/v1/me/connected-apps/${encodeURIComponent(t.grantId)}`,{method:"DELETE",credentials:"include",headers:{"X-Mesh-Expected-Account-Uid":r}}),v=yield l.json().catch(()=>({}));if(d!==i.current||c.current!==r)return;if(!l.ok)throw new Error(v.message||"Mesh could not disconnect this app.");n(`${t.clientName} is disconnected.`),yield j(r)}catch(l){d===i.current&&c.current===r&&n(l instanceof Error?l.message:"Mesh could not disconnect this app.")}})}function w(t){c.current=t,f(t),p(!0)}function y(){i.current+=1,c.current="",f(""),p(!1),g([]),m(!1),n("")}return e.jsxs(e.Fragment,{children:[e.jsx(A,{title:"Connected apps",description:"Review or revoke AI agent access to your Mesh Local account.",noindex:!0}),e.jsx("div",{className:"mesh-connection min-h-screen bg-[#F7EFDF] px-4 py-8 text-[#041C4D] sm:py-14",children:e.jsxs("main",{className:"mx-auto max-w-3xl",children:[e.jsx("a",{href:"/developers",className:"mesh-connection-brand font-bold",children:"Mesh Local"}),e.jsxs("section",{className:"mesh-connection-panel mt-6 rounded-3xl border-4 border-[#041C4D] bg-white p-5 shadow-[8px_8px_0px_0px_rgba(4,28,77,0.2)] sm:p-9",children:[e.jsx("h1",{className:"mt-3 font-heading text-4xl font-medium leading-tight sm:text-5xl",children:"Connected apps"}),e.jsx("p",{className:"mt-4 max-w-2xl leading-7",children:"Review the AI clients that have Mesh access and disconnect any grant immediately."}),e.jsx("div",{className:"mt-6",children:e.jsx(E,{authenticated:u,onAuthenticated:w,onSignedOut:y})}),u&&e.jsxs("div",{className:"mt-6 space-y-4",children:[x&&e.jsx("p",{children:"Loading connected appsâ¦"}),!x&&h.length===0&&e.jsx("p",{className:"rounded-xl border-2 border-[#041C4D]/30 p-4",children:"No agent apps are connected to this Mesh account."}),h.map(t=>e.jsx("article",{className:"rounded-2xl border-2 border-[#041C4D] bg-[#D9F1FD] p-4 sm:p-5",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:t.clientName}),t.clientUri&&e.jsxs("p",{className:"mt-1 break-all text-xs",children:["Registered website: ",t.clientUri]}),e.jsxs("p",{className:"mt-3 text-sm",children:["Permissions: ",e.jsx("span",{className:"font-mono",children:t.scopes.join(", ")})]}),e.jsxs("p",{className:"mt-1 break-all text-xs",children:["Service: ",t.resource]}),e.jsxs("p",{className:"mt-1 text-xs",children:["Connected ",new Date(t.authorizedAt).toLocaleString()]})]}),e.jsx("button",{type:"button",disabled:x,onClick:()=>void N(t),className:"min-h-11 shrink-0 rounded-xl border-2 border-[#041C4D] bg-[#FFB4D5] px-4 py-2 font-bold disabled:opacity-60",children:"Disconnect"})]})},t.grantId))]}),s&&e.jsx("p",{role:"status",className:"mt-5 text-sm leading-6",children:s})]})]})})]})}export{I as ConnectedApps};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.