1import{af as z,r as c,s as j,j as e,A as d,b as g,B as y}from"./index-BemFr6U8.js";const r=j.auth.oauth;function C(){var p;const[b]=z(),n=b.get("authorization_id")??"",[h,N]=c.useState(null),[m,a]=c.useState(null),[l,u]=c.useState(!1);c.useEffect(()=>{let i=!0;return(async()=>{if(!n){a("Missing authorization_id");return}const{data:s}=await j.auth.getSession();if(!s.session){const v=window.location.pathname+window.location.search;window.location.href="/login?returnTo="+encodeURIComponent(v);return}if(!(r!=null&&r.getAuthorizationDetails)){a("OAuth is not available on this Waddyado instance yet.");return}const{data:t,error:o}=await r.getAuthorizationDetails(n);if(!i)return;if(o){a(o.message);return}const w=(t==null?void 0:t.redirect_url)??(t==null?void 0:t.redirect_to);if(w&&!(t!=null&&t.client)){window.location.href=w;return}N(t)})(),()=>{i=!1}},[n]);async function x(i){u(!0);const{data:s,error:t}=i?await r.approveAuthorization(n):await r.denyAuthorization(n);if(t){u(!1),a(t.message);return}const o=(s==null?void 0:s.redirect_url)??(s==null?void 0:s.redirect_to);if(!o){u(!1),a("No redirect returned by the authorization server.");return}window.location.href=o}if(m)return e.jsx(d,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Authorization error"}),e.jsx("p",{className:"text-muted-foreground",children:m})]})});if(!h)return e.jsx(d,{children:e.jsxs("div",{className:"text-center flex flex-col items-center gap-3",children:[e.jsx(g,{className:"w-6 h-6 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading authorizationâ¦"})]})});const f=((p=h.client)==null?void 0:p.name)??"an application";return e.jsxs(d,{children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground mb-2",children:["Connect ",f]}),e.jsxs("p",{className:"text-muted-foreground",children:[f," is asking to access your Waddyado account. It will act as you and can only see data your account is allowed to see."]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(y,{type:"button",disabled:l,onClick:()=>x(!0),className:"w-full btn-primary-gradient h-12 text-base",children:[l?e.jsx(g,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Approve"]}),e.jsx(y,{type:"button",variant:"outline",disabled:l,onClick:()=>x(!1),className:"w-full h-12 text-base",children:"Deny"})]})]})}export{C 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.