1import{r as o,j as e}from"./vendor-7EzcLXMk.js";import{u as E}from"./router-DpaPmXr1.js";import{B as f}from"./button-B5IEMXyn.js";import{C as S,c as h,a as k,d as P}from"./card-6rUXPQBx.js";import{S as T}from"./separator-B3FDoUSz.js";import{a as j,e as N}from"./index-BGbXa73q.js";import{L as q}from"./FavIcon-gVv5EhOM.js";import{L as u,T as w,p as z}from"./icons-Bl3RYITO.js";import"./radix-ui-DVhjBwIM.js";import"./tanstack-CREO3szZ.js";import"./pdf-utils-C2-73oHn.js";class l extends Error{constructor(r="Not signed in"){super(r),this.name="MCPConsentUnauthorizedError"}}function b(t){return(t==null?void 0:t.status)===401}const I=async t=>{try{return(await j("GET",`${N}/oauth/consent/pending?request_id=${encodeURIComponent(t)}`)).json()}catch(r){throw b(r)?new l:(console.error("Error loading pending MCP consent request:",r),new Error(r.message||"Failed to load the authorization request"))}},L=async t=>{try{return(await j("POST",`${N}/oauth/consent/decide`,{headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json()}catch(r){throw b(r)?new l:(console.error("Error recording MCP consent decision:",r),new Error(r.message||"Failed to record your decision"))}};function y(){const t=window.location.pathname+window.location.search;return`/signin?redirect=${encodeURIComponent(t)}`}
1function H(){const[,t]=E(),r=new URLSearchParams(window.location.search).get("request_id"),[c,d]=o.useState("loading"),[m,x]=o.useState(null),[s,C]=o.useState(null),[i,g]=o.useState(null),v=async()=>{if(!r){x("No request_id in the URL. Start the flow from your MCP client."),d("error");return}try{const a=await I(r);C(a),d("consent")}catch(a){if(a instanceof l){t(y());return}x(a instanceof Error?a.message:"This authorization request is no longer valid."),d("error")}};o.useEffect(()=>{v()},[]);const p=async a=>{if(r){g(a?"allow":"deny");try{const{redirectTo:n}=await L({requestId:r,approved:a});window.location.href=n}catch(n){if(g(null),n instanceof l){t(y());return}x(n instanceof Error?n.message:"Could not record the decision.")}}};return e.jsxs("div",{className:"relative min-h-screen w-full overflow-x-hidden flex items-center justify-center px-6 py-10",style:{background:"radial-gradient(circle at 12% 15%, rgba(62,142,247,0.16) 0%, transparent 45%), radial-gradient(circle at 88% 85%, rgba(62,142,247,0.10) 0%, transparent 42%), linear-gradient(165deg, #060B16 0%, #0A1830 45%, #0F2C52 100%)"},children:[e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute -right-32 -top-32 h-96 w-96 rounded-full opacity-30 blur-3xl",style:{background:"#3E8EF7"}}),e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute -left-24 top-1/2 h-72 w-72 rounded-full opacity-10 blur-3xl",style:{background:"#3E8EF7"}}),e.jsx("div",{className:"relative z-10 w-full max-w-md",children:e.jsxs(S,{className:"rounded-2xl border-0 shadow-2xl shadow-black/50 bg-white",children:[c==="loading"&&e.jsxs(h,{className:"py-16 flex flex-col items-center gap-3",children:[e.jsx(u,{className:"h-5 w-5 text-gray-400 animate-spin"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Loading authorization requestâ¦"})]}),c==="error"&&e.jsxs(h,{className:"py-12 flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(w,{className:"h-5 w-5 text-red-500"})}),e.jsx("p",{className:"text-sm text-gray-600",children:m})]}),c==="consent"&&s&&e.jsxs(e.Fragment,{children:[e.jsxs(k,{className:"flex flex-col items-center gap-3 pt-8",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-11 w-11 rounded-xl bg-gray-50 border border-gray-100 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:q,alt:"Optraflow logo",className:"w-8 h-8 rounded"})}),e.jsx("span",{className:"text-gray-300 text-lg",children:"+"}),e.jsx("div",{className:"h-11 w-11 rounded-xl bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-900 font-semibold",children:"C"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("h1",{className:"font-display text-lg font-medium text-gray-900",children:["Authorize ",s.clientName??s.clientId,"?"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"It will be able to run API tests through your Optraflow workspace."})]})]}),e.jsx(T,{className:"bg-gray-100"}),e.jsxs(h,{className:"pt-5 pb-2 space-y-4",children:[e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm",children:[e.jsx("dt",{className:"text-gray-400",children:"Application"}),e.jsx("dd",{className:"text-gray-800 break-all",children:s.clientName??s.clientId}),e.jsx("dt",{className:"text-gray-400",children:"Scope"}),e.jsx("dd",{className:"text-gray-800 break-all",children:s.scope??"mcp"})]}),!s.eligible&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-amber-50 border border-amber-100 px-3 py-2",children:[e.jsx(w,{className:"h-4 w-4 text-amber-500 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-xs text-amber-700",children:s.message??"This workspace is not entitled to use the connector."})]}),s.eligible&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-emerald-50 border border-emerald-100 px-3 py-2",children:[e.jsx(z,{className:"h-4 w-4 text-emerald-500 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-xs text-emerald-700",children:"Your workspace can use this connector."})]}),m&&e.jsx("p",{className:"text-xs text-red-500 text-center",children:m})]}),e.jsxs(P,{className:"flex flex-col gap-2 pt-4 pb-8",children:[e.jsxs(f,{className:"w-full",disabled:!s.eligible||i!==null,onClick:()=>p(!0),children:[i==="allow"&&e.jsx(u,{className:"h-4 w-4 mr-2 animate-spin"}),"Allow"]}),e.jsxs(f,{variant:"ghost",className:"w-full text-gray-500 hover:text-gray-900 hover:bg-gray-50",disabled:i!==null,onClick:()=>p(!1),children:[i==="deny"&&e.jsx(u,{className:"h-4 w-4 mr-2 animate-spin"}),"Deny"]})]})]})]})})]})}export{H as default};
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.