1import{s as j,j as e,L as g,aP as v,B as w}from"./index-Daj28piR.js";import{u as C,r as c}from"./vendor-react-BahdI5Xr.js";import{C as z}from"./card-BzzLmOtf.js";import"./vendor-pdf-D46ffnHm.js";import"./vendor-charts-CFTq_AuP.js";const m=()=>j.auth.oauth;function B(){var f;const[N]=C(),r=N.get("authorization_id")??"",[n,y]=c.useState(null),[d,i]=c.useState(null),[l,u]=c.useState(!1);c.useEffect(()=>{let o=!0;return(async()=>{if(!r){i("Missing authorization_id");return}const{data:s}=await j.auth.getSession();if(!s.session){const b=window.location.pathname+window.location.search;window.location.href="/auth?next="+encodeURIComponent(b);return}const{data:t,error:a}=await m().getAuthorizationDetails(r);if(!o)return;if(a){i(a.message);return}const p=(t==null?void 0:t.redirect_url)??(t==null?void 0:t.redirect_to);if(p&&!(t!=null&&t.client)){window.location.href=p;return}y(t)})(),()=>{o=!1}},[r]);async function h(o){u(!0);const{data:s,error:t}=o?await m().approveAuthorization(r):await m().denyAuthorization(r);if(t){u(!1),i(t.message);return}const a=(s==null?void 0:s.redirect_url)??(s==null?void 0:s.redirect_to);if(!a){u(!1),i("No redirect returned by the authorization server.");return}window.location.href=a}const x=((f=n==null?void 0:n.client)==null?void 0:f.name)??"this app";return e.jsx("main",{className:"min-h-screen flex items-center justify-center p-6 bg-background",children:e.jsx(z,{className:"w-full max-w-md p-6 space-y-4",children:d?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Could not load this request"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d})]}):n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(v,{className:"h-5 w-5"}),e.jsx("span",{className:"text-sm font-medium",children:"Connect to The Marketing Vault"})]}),e.jsxs("h1",{className:"text-xl font-semibold",children:["Allow ",x," to use your account?"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[x," will be able to read your businesses, customer profiles and saved outputs, and run marketing tools as you. Runs count against your plan. You can revoke access at any time."]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx(w,{disabled:l,onClick:()=>h(!0),className:"flex-1",children:l?e.jsx(g,{className:"h-4 w-4 animate-spin"}):"Approve"}),e.jsx(w,{disabled:l,variant:"outline",onClick:()=>h(!1),className:"flex-1",children:"Deny"})]})]}):e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(g,{className:"h-4 w-4 animate-spin"})," Loading authorization request..."]})})})}export{B 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.