1import{aq as k,r as d,j as e,L as g}from"./vendor-CSdFbWfl.js";import{d as L,a9 as S,k as q}from"./index-BynWLX9U.js";import{E as p}from"./ErrorMessage-CFYKaoeN.js";import{a as P,i as R}from"./oauth-DuIimM3X.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"5fdab7154cbea903e2531547e54739370b469773"};var t=new s.Error().stack;t&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[t]="5ece6cbf-1e43-4f08-9765-543fe25dc6ad",s._sentryDebugIdIdentifier="sentry-dbid-5ece6cbf-1e43-4f08-9765-543fe25dc6ad")}catch{}})();const T=s=>{if(!s||!s.length)return null;const t=s.map(a=>a==null?void 0:a.mode).filter(a=>!!a);return t.includes("LIVE")?"LIVE":t.includes("SANDBOX")?"SANDBOX":null},D=({app:s,checked:t,onChange:a})=>e.jsxs("label",{"aria-label":`Select app ${s.name}`,className:"flex cursor-pointer items-center gap-3 rounded-lg border border-app-gray100 p-4 hover:border-app-blue400",children:[e.jsx("input",{type:"radio",className:"h-4 w-4",name:"selected_app_id",value:s.id,checked:t,onChange:a,required:!0}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-app-gray900",children:s.name}),e.jsxs("span",{className:"text-body-sm text-app-gray500",children:[s.slug?`Slug: ${s.slug}`:"No slug",s.mode?` · Mode: ${s.mode}`:"",s.role?` · Role: ${s.role}`:""]})]})]}),z=()=>{const{currentUser:s}=L(),[t]=k(),a=t.get("selection_token")??t.get("selectionToken")??"",m=t.get("oauthIssuer")??"",c=t.get("resource")??"",b=t.get("scope")??"",y=t.get("client_id")??"",I=t.get("selection_error"),u=(t.get("requested_app")??"").toLowerCase(),[i,j]=d.useState(""),[N,h]=d.useState(""),[v,E]=d.useState(!1),n=d.useMemo(()=>((s==null?void 0:s.appConnections)||[]).map(r=>{const o=r==null?void 0:r.app;return o?{id:o.id,name:o.name,slug:o.slug??null,role:(r==null?void 0:r.role)??null,mode:T((o.domains??[]).filter(A=>A!==null))}:null}).filter(r=>r!==null),[s==null?void 0:s.appConnections]);d.useEffect(()=>{if(!i&&n.length){const l=n.find(r=>{var o;return u?r.id.toLowerCase()===u||((o=r.slug)==null?void 0:o.toLowerCase())===u:!1});j((l??n[0]).id)}},[n,u,i]);const x=P(m??""),C=m?R(m):!1,_=l=>{if(!a||!x||!i){l.preventDefault(),h("The selection session is no longer valid. Please restart the authorization flow.");return}h(""),E(!0)},w=n.length>0,f=!a||!C||!x;return e.jsx("div",{className:"min-h-screen bg-gray-50 px-4 py-12",children:e.jsxs("div",{className:"mx-auto w-full max-w-2xl rounded-2xl bg-white p-8 shadow-lg",children:[e.jsx("h1",{className:"text-h3 font-semibold text-app-gray900",children:"Select an app to continue"}),e.jsx("p",{className:"mt-2 text-body-md text-app-gray600",children:y?`Client "${y}" is requesting access.`:"Choose which app should be used for this authorization."}),b&&e.jsxs("div",{className:"mt-4 rounded-lg border border-app-blue100 bg-app-blue50 p-4 text-body-sm text-app-gray700",children:[e.jsx("strong",{className:"block text-app-blue500",children:"Requested scopes"}),e.jsx("span",{children:b})]}),c&&e.jsxs("div",{className:"mt-4 text-body-sm text-app-gray600",children:[e.jsx("strong",{className:"text-app-gray800",children:"Resource:"})," ",c]}),I==="invalid_app"&&e.jsx("div",{className:"mt-4",children:e.jsx(p,{message:"You do not have access to the requested app. Please choose one from the list below.",showIcon:!1})}),f&&e.jsxs("div",{className:"mt-6",children:[e.jsx(p,{message:"This selection session has expired. Please restart the authorization process from your integration.",showIcon:!1}),e.jsx("div",{className:"mt-4 text-body-sm text-app-gray600",children:e.jsx(g,{className:"text-app-blue500",to:`/${S.apps}`,children:"Return to dashboard"})})]}),!f&&!w&&e.jsxs("div",{className:"mt-6",children:[e.jsx(p,{message:"Your account does not have any apps yet. Create an app to continue.",showIcon:!1}),e.jsx("div",{className:"mt-4",children:e.jsx(g,{className:"text-app-blue500",to:"/create-app",children:"Create a new app"})})]}),!f&&w&&e.jsxs("form",{className:"mt-6 flex flex-col gap-6",method:"POST",action:x??void 0,onSubmit:_,children:[e.jsx("input",{type:"hidden",name:"selection_token",value:a}),c?e.jsx("input",{type:"hidden",name:"resource",value:c}):null,e.jsx("fieldset",{className:"flex max-h-[32rem] flex-col gap-3 overflow-y-auto pr-2",children:n.map(l=>e.jsx(D,{app:l,checked:i===l.id,onChange:()=>{j(l.id),h("")}},l.id))}),N&&e.jsx(p,{message:N,showIcon:!1}),e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e.jsx(g,{className:"text-app-gray500 hover:text-app-gray700",to:`/${S.apps}`,children:"Cancel"}),e.jsx(q,{type:"submit",isLoading:v,disabled:!i||v,children:"Continue"})]})]})]})})};export{z 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.