import{b2 as b,r as s,ef as h,j as e,aG as S,e as N,E as y}from"./index-Ef5HIHwv.js";function x(){const[r]=b(),[t,n]=s.useState(null),[p,g]=s.useState("minting"),m=s.useRef(!1),o=r.get("account_id")||"",i=r.get("scope_id")||"",l=r.get("app_id")||"",c=r.get("app_code")||void 0,u=r.get("reason")||void 0,d=r.get("email")||"";return s.useEffect(()=>{if(!m.current){if(m.current=!0,!o||!i||!l){n("Missing required parameters (account_id, scope_id, app_id).");return}(async()=>{try{const a=await h({account_id:o,scope_id:i,app_id:l,app_code:c,reason:u});if(!a.redirect_url){n("Got an access token but no redirect URL — the b2b host could not be resolved for this app.");return}g("redirecting"),window.location.replace(a.redirect_url)}catch(a){n(a.message||"Impersonation failed.")}})()}},[o,i,l,c,u]),e.jsxDEV("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 p-6",children:e.jsxDEV("div",{className:"max-w-md w-full bg-white rounded-lg shadow border p-6 space-y-4",children:[!t&&e.jsxDEV("div",{className:"flex items-center gap-3",children:[e.jsxDEV(S,{className:"h-6 w-6 animate-spin text-orange-600"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:70,columnNumber:13},this),e.jsxDEV("div",{children:[e.jsxDEV("div",{className:"font-medium",children:p==="minting"?"Minting impersonation session…":"Redirecting to b2b…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:72,columnNumber:15},this),d&&e.jsxDEV("div",{className:"text-sm text-muted-foreground",children:["as ",d]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:75,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:71,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:69,columnNumber:11},this),t&&e.jsxDEV("div",{className:"space-y-3",children:[e.jsxDEV("div",{className:"flex items-center gap-2 text-red-700",children:[e.jsxDEV(N,{className:"h-5 w-5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:82,columnNumber:15},this),e.jsxDEV("div",{className:"font-medium",children:"Impersonation failed"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:83,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:81,columnNumber:13},this),e.jsxDEV("div",{className:"text-sm text-muted-foreground",children:t},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:85,columnNumber:13},this),e.jsxDEV("a",{href:"/",className:"inline-flex items-center gap-1.5 text-sm text-orange-600 hover:underline",children:[e.jsxDEV(y,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:90,columnNumber:15},this),"Back to ops console"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:86,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:80,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:67,columnNumber:7},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/pages/ImpersonateLauncherPage.tsx",lineNumber:66,columnNumber:5},this)}export{x as default};
