1import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{J as t,M as n,N as r,P as i,j as a,q as o}from"./axiosClient-DUhX2EP0.js";import{n as s,r as c}from"./domainValidation-FMKryCR2.js";import{T as l,n as u,r as d,v as f}from"./backend-lAz2jGEC.js";import{d as p,l as m,p as h,r as g,u as _,v,x as y}from"./vendor-react-DpRoP2jP.js";import{_ as b,c as x,g as S,i as C,m as w,p as T,w as ee}from"./dist-MU4AWLxh.js";import{K as te,_ as ne,y as E}from"./vendor-data-cHhjBKlt.js";import{Bi as D,Ii as O,Wi as k,ar as re,as as A,ec as j,is as M,ma as ie}from"./vendor-ui-5dZ4Cido.js";import{a as ae,d as oe}from"./mixpanelUtils-CjAjqja8.js";import{t as se}from"./base-steoUX-Y.js";import{t as N}from"./text-kd9Epb70.js";import{t as P}from"./text-button-C1C7xOLG.js";import{r as F}from"./button-0-wIPlRQ.js";import{t as ce}from"./usePlatform-CeQ0MESx.js";import{t as I}from"./utils-Idi6bWLx.js";import{F as le,b as ue,y as de}from"./index-CoexMVMf.js";import{n as fe,r as pe}from"./useFetch-6XveWYoO.js";import{t as L}from"./DeadEndPage-Br0j-PKy.js";import{n as R,t as z}from"./card-DiFo4FYM.js";import{t as me}from"./separator-CjqgPVOl.js";import{t as B}from"./input-ExP5iLeX.js";import{t as V}from"./label-ojIxnzs8.js";import{n as he,r as ge,t as _e}from"./dist-DdcGSx_t.js";import{t as ve}from"./apiErrors-pkM_VAe0.js";import{t as ye}from"./AppAccessRequestAPI-CybAZ7U0.js";import{t as be}from"./authConfigUtils-DFq-jyxY.js";import{n as H,t as U}from"./alert-D9EeUEau.js";import{t as W}from"./webviewDetection-Cx1F3Qc3.js";import{t as xe}from"./code-input-64QHVy_e.js";import{n as Se}from"./types-Cd0VPYyP.js";var G=e(y()),K=v(),Ce=(0,G.createContext)(),we=new class extends se{getBaseURL(){return`/apps`}getCurrentUser(e){return this.axios.get(`/${e}/entities/User/me`)}},Te=({children:e,appId:t})=>{let[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!0),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(null);(0,G.useEffect)(()=>{let e=!1;i.ensureSessionReady().then(()=>{if(e)return;let t=a(!0);if(t)r(t),h(`platform`),y();else{let e=i.getSSOTokens();e&&e.access_token?(p(e),h(`sso`),i.setSSOTokens({access_token:e.access_token,token_type:e.token_type,expires_at:e.expires_at,scope:e.scope,provider:e.provider,id_token:e.id_token}),d(!1)):d(!1)}});let t=i.addListener((e,t)=>{if(e===`sso_tokens_updated`){let e=t.tokens;p(e),!a(!1)&&e&&e.access_token&&h(`sso`)}else e===`sso_tokens_cleared`&&(p(null),m===`sso`&&(h(null),l(!1),s(null)))});return()=>{e=!0,t()}},[]);let g=e=>{s(e)},_=()=>{n(),s(null),l(!1),d(!1),p(null),h(null),i.clearSSOTokens()},v=(e=!0)=>{if(_(),l(!1),s(null),e){let e=encodeURIComponent(window.location.href);window.location.href=`/login?from_url=`+e}},y=async()=>{try{d(!0);let e=await we.getCurrentUser(t);return window.FS&&window.FS(`setIdentity`,{uid:e.id,properties:{displayName:e.full_name||e.email,email:e.email}}),s(e),l(!0),d(!1),e}catch(e){d(!1),e?.response?.status===401?_():(s(null),l(!1))}};return(0,K.jsx)(Ce.Provider,{value:{user:o,isAuthenticated:c,logout:v,isLoadingAuth:u,updateUser:g,ssoTokens:f,authMethod:m,loginWithSSO:(e=!0)=>{let n=window.location.href,r=`/api/apps/${t}/auth/sso/login?from_url=${encodeURIComponent(n)}&include_external_tokens=${e}`;window.location.href=r},getSSOTokens:()=>f||i.getSSOTokens(),clearSSOTokens:()=>{i.clearSSOTokens(),p(null)}},children:e})},Ee=()=>(0,G.useContext)(Ce);function q({appName:e}){let{t}=w(`app-access`),n=f();return(0,K.jsx)(L,{headingTestId:`app-unavailable-heading`,heading:e?t(`appNotPublished.heading`,{appName:e}):t(`appNotPublished.headingNoName`),description:[...e?[t(`appNotPublished.notAvailable`)]:[],t(`appNotPublished.invited`)],action:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(N,{weight:`medium`,children:t(`appNotPublished.buildPrompt`)}),(0,K.jsx)(F,{variant:`premium`,href:n,"data-testid":`start-building-button`,children:t(`appNotPublished.startBuilding`)})]}),footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(N,{tone:`secondary`,children:t(`appNotPublished.adminHint`)}),(0,K.jsx)(P,{href:n,weight:`medium`,underline:`always`,"data-testid":`open-builder-link`,children:t(`appNotPublished.openBuilder`)})]})})}function De({appId:e}){let{data:t,isLoading:n}=ne({queryKey:[`login-info`,e],queryFn:()=>x.getLoginInfoById(e),...S.STATIC});return n?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100`,children:(0,K.jsx)(k,{className:`h-10 w-10 animate-spin text-slate-400`})}):(0,K.jsx)(q,{appName:t?.name})}var Oe=({...e})=>{let{theme:t=`system`}=de();return(0,K.jsx)(ue,{theme:t,className:`toaster group`,toastOptions:{classNames:{toast:`group toast font-base44 group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-muted-foreground`,actionButton:`group-[.toast]:bg-primary group-[.toast]:text-primary-foreground`,cancelButton:`group-[.toast]:bg-muted group-[.toast]:text-muted-foreground`,success:`[&_[data-icon]]:text-green-500`}},...e})},ke=G.forwardRef(({className:e,...t},n)=>(0,K.jsx)(ge,{ref:n,className:I(`relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full`,e),...t}));ke.displayName=ge.displayName;var Ae=G.forwardRef(({className:e,...t},n)=>(0,K.jsx)(he,{ref:n,className:I(`aspect-square h-full w-full`,e),...t}));Ae.displayName=he.displayName;var je=G.forwardRef(({className:e,...t},n)=>(0,K.jsx)(_e,{ref:n,className:I(`flex h-full w-full items-center justify-center rounded-full bg-muted`,e),...t}));
1je.displayName=_e.displayName;function Me(e,t,n){class r extends se{getBaseURL(){return`/apps/${e}`}inviteUser(e,t){return this.axios.post(`/users/invite-user`,{user_email:e,role:t})}getMyUserInfo(){return this.axios.get(`/entities/User/me`)}updateMyUserData(e){return this.axios.put(`/entities/User/me`,e)}logout(){n.logout(!1),window.location.reload()}async login(){let t=window.location.href,n=`${u()}/apps/auth/login?from_url=${t}&app_id=${e}`;W(n)}async loginWithRedirect(e){let t=window.location.href.substring(0,window.location.href.lastIndexOf(`/`)+1);window.location.href=`${t}login?from_url=${encodeURIComponent(e)}`}isUserAuthenticated(){return n.isUserAuthenticated()}register(e){return this.axios.post(`/auth/register`,e)}verifyOtp(e,t){return this.axios.post(`/auth/verify-otp`,{email:e,otp_code:t})}resendOtp(e){return this.axios.post(`/auth/resend-otp`,{email:e})}verifyAccessRequestOtp(e,t){return this.axios.post(`/access-requests/verify-otp`,{email:e,otp_code:t})}resendAccessRequestOtp(e){return this.axios.post(`/access-requests/resend-otp`,{email:e})}loginViaUsernamePassword(e,t){return this.axios.post(`/auth/login`,{email:e,password:t})}resetPasswordRequest(e){return this.axios.post(`/auth/reset-password-request`,{email:e})}resetPassword(e,t){return this.axios.post(`/auth/reset-password`,{reset_token:e,new_password:t})}changePassword(e,t,n){return this.axios.post(`/auth/change-password`,{user_id:e,current_password:t,new_password:n})}}return new r(t)}var Ne=!(typeof window>`u`)&&window.self!==window.top,J=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),Pe=class extends Error{constructor(e,t,n,r,i){super(e),this.name=`Base44Error`,this.status=t,this.code=n,this.data=r,this.originalError=i}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code,data:this.data}}};function Y({baseURL:e,headers:n={},token:r,interceptResponses:i=!0,onError:a}){let o=te.create({baseURL:e,headers:{"Content-Type":`application/json`,Accept:`application/json`,...n}});return r&&(o.defaults.headers.common.Authorization=`Bearer ${r}`),o.interceptors.request.use(n=>{typeof window<`u`&&n.headers.set(`X-Origin-URL`,window.location.href);let r=t();if(n.requestId=r,Ne)try{window.parent.postMessage({type:`api-request-start`,requestId:r,data:{url:e+n.url,method:n.method,body:n.data instanceof FormData?`[FormData object]`:n.data}},`*`)}catch{}return n}),i&&o.interceptors.response.use(e=>{let t=e.config?.requestId;try{Ne&&t&&window.parent.postMessage({type:`api-request-end`,requestId:t,data:{statusCode:e.status,response:e.data}},`*`)}catch{}return e.data},e=>{let t=new Pe(e.response?.data?.message||e.response?.data?.detail||e.message,e.response?.status,e.response?.data?.code,e.response?.data,e);return a?.(t),Promise.reject(t)}),o}function Fe(e){let{axios:t,appId:n,getSocket:r}=e;return new Proxy({},{get(e,i){if(!(typeof i!=`string`||i===`then`||i.startsWith(`_`)))return Le(t,n,i,r)}})}function Ie(e){try{let t=JSON.parse(e);return{type:t.type,data:t.data,id:t.id||t.data?.id,timestamp:t.timestamp||new Date().toISOString()}}catch{return null}}function Le(e,t,n,r){let i=`/apps/${t}/entities/${n}`;return{async list(t,n,r,a){let o={};return t&&(o.sort=t),n&&(o.limit=n),r&&(o.skip=r),a&&(o.fields=Array.isArray(a)?a.join(`,`):a),e.get(i,{params:o})},async filter(t,n,r,a,o){let s={q:JSON.stringify(t)};return n&&(s.sort=n),r&&(s.limit=r),a&&(s.skip=a),o&&(s.fields=Array.isArray(o)?o.join(`,`):o),e.get(i,{params:s})},async get(t){return e.get(`${i}/${t}`)},async create(t){return e.post(i,t)},async update(t,n){return e.put(`${i}/${t}`,n)},async delete(t){return e.delete(`${i}/${t}`)},async deleteMany(t){return e.delete(i,{data:t})},async bulkCreate(t){return e.post(`${i}/bulk`,t)},async updateMany(t,n){return e.patch(`${i}/update-many`,{query:t,data:n})},async bulkUpdate(t){return e.put(`${i}/bulk`,t)},async importEntities(t){let n=new FormData;return n.append(`file`,t,t.name),e.post(`${i}/import`,n,{headers:{"Content-Type":`multipart/form-data`}})},subscribe(e){let i=`entities:${t}:${n}`;return r().subscribeToRoom(i,{update_model:t=>{let n=Ie(t.data);if(n)try{e(n)}catch{}}})}}}function Re(e,t){return{async call(n,r,i){if(!n?.trim())throw Error(`Integration slug is required and cannot be empty`);if(!r?.trim())throw Error(`Operation ID is required and cannot be empty`);let{pathParams:a,queryParams:o,...s}=i??{},c={...s,...a&&{path_params:a},...o&&{query_params:o}};return await e.post(`/apps/${t}/integrations/custom/${n}/${r}`,c)}}}function ze(e,t){let n=Re(e,t);return new Proxy({},{get(r,i){if(!(typeof i!=`string`||i===`then`||i.startsWith(`_`)))return i===`custom`?n:new Proxy({},{get(n,r){if(!(typeof r!=`string`||r===`then`||r.startsWith(`_`)))return async n=>{if(typeof n==`string`)throw Error(`Integration ${r} must receive an object with named parameters, received: ${n}`);let a,o;return n instanceof FormData||n&&Object.values(n).some(e=>
1e instanceof File)?(a=new FormData,Object.keys(n).forEach(e=>{n[e]instanceof File?a.append(e,n[e],n[e].name):typeof n[e]==`object`&&n[e]!==null?a.append(e,JSON.stringify(n[e])):a.append(e,n[e])}),o=`multipart/form-data`):(a=n,o=`application/json`),i===`Core`?e.post(`/apps/${t}/integration-endpoints/Core/${r}`,a||n,{headers:{"Content-Type":o}}):e.post(`/apps/${t}/integration-endpoints/installable/${i}/integration-endpoints/${r}`,a||n,{headers:{"Content-Type":o}})}}})}})}function Be(e,t,n,r){return{async me(){return e.get(`/apps/${n}/entities/User/me`)},async updateMe(t){return e.put(`/apps/${n}/entities/User/me`,t)},redirectToLogin(e){if(typeof window>`u`)throw Error(`Login method can only be used in a browser environment`);let t=e?new URL(e,window.location.origin).toString():window.location.href,n=`${r.appBaseUrl}/login?from_url=${encodeURIComponent(t)}`;window.location.href=n},loginWithProvider(e,t=`/`){let i=new URL(t,window.location.origin).toString(),a=`app_id=${n}&from_url=${encodeURIComponent(i)}`,o;o=e===`sso`?`/apps/${n}/auth/sso/login`:`/apps/auth${e===`google`?``:`/${e}`}/login`;let s=`${r.appBaseUrl}/api${o}?${a}`;window.location.href=s},logout(t){if(delete e.defaults.headers.common.Authorization,typeof window<`u`){if(window.localStorage)try{window.localStorage.removeItem(`base44_access_token`),window.localStorage.removeItem(`token`)}catch{}let e=t||window.location.href,n=`${r.appBaseUrl}/api/apps/auth/logout?from_url=${encodeURIComponent(e)}`;window.location.href=n}},setToken(n,r=!0){if(n&&(e.defaults.headers.common.Authorization=`Bearer ${n}`,t.defaults.headers.common.Authorization=`Bearer ${n}`,r&&typeof window<`u`&&window.localStorage))try{window.localStorage.setItem(`base44_access_token`,n),window.localStorage.setItem(`token`,n)}catch{}},async loginViaEmailPassword(t,r,i){try{let{access_token:a,user:o}=await e.post(`/apps/${n}/auth/login`,{email:t,password:r,...i&&{turnstile_token:i}});return a&&this.setToken(a),{access_token:a,user:o}}catch(e){throw e.response?.status===401&&await this.logout(),e}},async isAuthenticated(){try{return await this.me(),!0}catch{return!1}},inviteUser(t,r){return e.post(`/apps/${n}/users/invite-user`,{user_email:t,role:r})},register(t){return e.post(`/apps/${n}/auth/register`,t)},verifyOtp({email:t,otpCode:r}){return e.post(`/apps/${n}/auth/verify-otp`,{email:t,otp_code:r})},resendOtp(t){return e.post(`/apps/${n}/auth/resend-otp`,{email:t})},resetPasswordRequest(t){return e.post(`/apps/${n}/auth/reset-password-request`,{email:t})},resetPassword({resetToken:t,newPassword:r}){return e.post(`/apps/${n}/auth/reset-password`,{reset_token:t,new_password:r})},changePassword({userId:t,currentPassword:r,newPassword:i}){return e.post(`/apps/${n}/auth/change-password`,{user_id:t,current_password:r,new_password:i})}}}function Ve(e,t,n){return{async getAccessToken(r){let i=`/apps/${t}/auth/sso/accesstoken/${r}`,a={};return n&&(a[`on-behalf-of`]=`Bearer ${n}`),e.get(i,{headers:a})}}}function He(e,t){return{async getAccessToken(n){if(!n||typeof n!=`string`)throw Error(`Integration type is required and must be a string`);return(await e.get(`/apps/${t}/external-auth/tokens/${n}`)).access_token},async getConnection(n){if(!n||typeof n!=`string`)throw Error(`Integration type is required and must be a string`);let r=await e.get(`/apps/${t}/external-auth/tokens/${n}`);return{accessToken:r.access_token,connectionConfig:r.connection_config??null}}}}function Ue(e,t){return{async getCurrentAppUserAccessToken(n){if(!n||typeof n!=`string`)throw Error(`Connector ID is required and must be a string`);return(await e.get(`/apps/${t}/app-user-auth/connectors/${n}/token`)).access_token},async connectAppUser(n){if(!n||typeof n!=`string`)throw Error(`Connector ID is required and must be a string`);return(await e.post(`/apps/${t}/app-user-auth/connectors/${n}/initiate`)).redirect_url},async disconnectAppUser(n){if(!n||typeof n!=`string`)throw Error(`Connector ID is required and must be a string`);await e.delete(`/apps/${t}/app-user-auth/connectors/${n}`)}}}function X(e={}){let{storageKey:t=`base44_access_token`,paramName:n=`access_token`,saveToStorage:r=!0,removeFromUrl:i=!0}=e,a=null;if(typeof window<`u`&&window.location)try{let e=new URLSearchParams(window.location.search);if(a=e.get(n),a){if(r&&We(a,{storageKey:t}),i){e.delete(n);let t=`${window.location.pathname}${e.toString()?`?${e.toString()}`:``}${window.location.hash}`;window.history.replaceState({},document.title,t)}return a}}catch{}if(typeof window<`u`&&window.localStorage)try{return a=window.localStorage.getItem(t),a}catch{}return null}function We(e,t){let{storageKey:n=`base44_access_token`}=t;if(typeof window>`u`||!window.localStorage||!e)return!1;try{return window.localStorage.setItem(n,e),window.localStorage.setItem(`token`,e),!0}catch{return!1}}function Ge(e,t,n){let r=(e,t)=>e?`${String(e).replace(/\/$/,``)}${t}`:t,i=e=>{let t=new Headers;if(n?.getAuthHeaders){let e=n.getAuthHeaders();Object.entries(e).forEach(([e,n])=>{n!=null&&t.set(e,String(n))})}return e&&new Headers(e).forEach((e,n)=>{t.set(n,e)}),t};return{async invoke(n,r){if(typeof r==`string`)throw Error(`Function ${n} must receive an object with named parameters, received: ${r}`);let i,a;return r instanceof FormData||r&&Object.values(r).some(e=>
1e instanceof File)?(i=new FormData,Object.keys(r).forEach(e=>{r[e]instanceof File?i.append(e,r[e],r[e].name):typeof r[e]==`object`&&r[e]!==null?i.append(e,JSON.stringify(r[e])):i.append(e,r[e])}),a=`multipart/form-data`):(i=r,a=`application/json`),e.post(`/apps/${t}/functions/${n}`,i||r,{headers:{"Content-Type":a}})},async fetch(e,t={}){let a=`/functions${e.startsWith(`/`)?e:`/${e}`}`,o=i(t.headers),s={...t,headers:o};return await fetch(r(n?.baseURL,a),s)}}}function Ke({axios:e,getSocket:t,appId:n,serverUrl:r,token:i}){let a=`/apps/${n}/agents`,o={},s=()=>e.get(`${a}/conversations`),c=t=>e.get(`${a}/conversations/${t}`);return{getConversations:s,getConversation:c,listConversations:t=>e.get(`${a}/conversations`,{params:t}),createConversation:t=>e.post(`${a}/conversations`,t),addMessage:async(t,n)=>e.post(`${a}/conversations/v2/${t.id}/messages`,n),subscribeToConversation:(e,n)=>{let r=`/agent-conversations/${e}`,i=t(),a=c(e).then(t=>(o[e]=t,t));return i.subscribeToRoom(r,{connect:()=>{},update_model:async({data:t})=>{let r=JSON.parse(t);if(r._message){await a;let t=r._message,i=o[e];if(i){let r=i.messages||[],a=r.findIndex(e=>e.id===t.id),s=a===-1?[...r,t]:r.map((e,n)=>n===a?t:e);o[e]={...i,messages:s},n?.(o[e])}}}})},getWhatsAppConnectURL:e=>{let t=`${r}/api/apps/${n}/agents/${encodeURIComponent(e)}/whatsapp`,a=i??X();return a?`${t}?token=${a}`:t}}}function qe(e,t){let n=`/app-logs/${t}`;return{async logUserInApp(t){await e.post(`${n}/log-user-in-app/${t}`)},async fetchLogs(t={}){return await e.get(n,{params:t})},async getStats(t={}){return await e.get(`${n}/stats`,{params:t})}}}function Je(e,t){return{async inviteUser(n,r){if(r!==`user`&&r!==`admin`)throw Error(`Invalid role: "${r}". Role must be either "user" or "admin".`);return await e.post(`/apps/${t}/runtime/users/invite-user`,{user_email:n,role:r})}}}function Ye(e,t){let n=o(e.serverUrl,{path:e.mountPath,transports:e.transports,query:{app_id:e.appId,token:e.token??X()}});return n.on(`connect`,async()=>t.connect?.call(t)),n.on(`update_model`,async e=>t.update_model?.call(t,e)),n.on(`error`,async e=>t.error?.call(t,e)),n.on(`connect_error`,async e=>t.error?.call(t,e)),n}function Xe({config:e}){let t={...e},n={},r={connect:async()=>{let e=[];Object.keys(n).forEach(t=>{c(t),d(t)?.forEach(({connect:t})=>{e.push((async()=>t?.())())})}),await Promise.all(e)},update_model:async e=>{let t=d(e.room).map(t=>t.update_model?.call(t,e));await Promise.all(t)},error:async e=>{let t=Object.values(n).flat().map(t=>t.error?.call(t,e));await Promise.all(t)}},i=Ye(e,r);function a(){o()}function o(){i&&i.disconnect()}function s(e){a(),t={...t,...e},i=Ye(t,r)}function c(e){i.emit(`join`,e)}function l(e){i.emit(`leave`,e)}async function u(e,t){let n=JSON.stringify(t);return r.update_model?.call(r,{room:e,data:n})}function d(e){return n[e]}return{socket:i,subscribeToRoom:(e,t)=>(n[e]||(c(e),n[e]=[]),n[e].push(t),()=>{n[e]=n[e]?.filter(e=>e!==t)??[],n[e].length===0&&l(e)}),updateConfig:s,updateModel:u,disconnect:o}}var Z=typeof window<`u`?window:{base44SharedInstances:{}};function Ze(e,t){return Z.base44SharedInstances||={},Z.base44SharedInstances[e]||(Z.base44SharedInstances[e]={instance:t()}),Z.base44SharedInstances[e].instance}var Qe=`__user_heartbeat_event__`,$e=`__initialization_event__`,et=`__session_duration_event__`,tt=`analytics-enable`,nt=`base44_analytics_session_id`,rt={enabled:!0,maxQueueSize:1e3,throttleTime:1e3,batchSize:30,heartBeatInterval:6e4},Q=Ze(`analytics`,()=>({requestsQueue:[],isProcessing:!1,isHeartBeatProcessing:!1,wasInitializationTracked:!1,sessionContext:null,sessionStartTime:null,config:{...rt,...mt()}})),it=({axiosClient:e,serverUrl:t,appId:n,userAuthModule:r})=>{let{maxQueueSize:i,throttleTime:a,batchSize:o}=Q.config;if(!Q.config?.enabled)return{track:()=>{},cleanup:()=>{}};let s,c=`${t}/api/apps/${n}/analytics/track/batch`,l=async t=>{await e.request({method:`POST`,url:`/apps/${n}/analytics/track/batch`,data:{events:t}})},u=e=>{try{let t=JSON.stringify({events:e}),n=new Blob([t],{type:`application/json`});return typeof navigator>`u`||t.length>6e4||!navigator.sendBeacon(c,n)}catch{return!1}},d=async(e,t={})=>
1{if(e.length===0)return;let n=await pt(r),i=e.map(ft(n));try{(!t.isBeacon||!u(i))&&await l(i)}catch{}},f=()=>{ot(d,{throttleTime:a,batchSize:o})},p=e=>{if(Q.requestsQueue.length>=i)return;let t=dt();Q.requestsQueue.push({...e,...t}),f()},m=()=>{ot(d,{throttleTime:a,batchSize:o}),s=st(p),lt()},h=()=>{at(),s?.(),ut(p);let e=Q.requestsQueue.splice(0);d(e,{isBeacon:!0})},g=()=>{typeof window>`u`||(document.visibilityState===`hidden`?h():document.visibilityState===`visible`&&m())};return f(),s=st(p),ct(p),typeof window<`u`&&window.addEventListener(`visibilitychange`,g),{track:p,cleanup:()=>{at(),s?.(),typeof window<`u`&&window.removeEventListener(`visibilitychange`,g)}}};function at(){Q.isProcessing=!1}async function ot(e,t){if(Q.isProcessing)return;Q.isProcessing=!0;let{throttleTime:n=1e3,batchSize:r=30}=t??{};for(;Q.isProcessing&&Q.requestsQueue.length>0;){let t=Q.requestsQueue.splice(0,r);t.length&&await e(t),await new Promise(e=>setTimeout(e,n))}Q.isProcessing=!1}function st(e){if(Q.isHeartBeatProcessing||(Q.config.heartBeatInterval??0)<10)return()=>{};Q.isHeartBeatProcessing=!0;let t=setInterval(()=>{e({eventName:Qe})},Q.config.heartBeatInterval);return()=>{clearInterval(t),Q.isHeartBeatProcessing=!1}}function ct(e){typeof window>`u`||Q.wasInitializationTracked||(Q.wasInitializationTracked=!0,e({eventName:$e,properties:{referrer:document==null?void 0:document.referrer}}))}function lt(){typeof window>`u`||Q.sessionStartTime!==null||(Q.sessionStartTime=new Date().toISOString())}function ut(e){if(typeof window>`u`||Q.sessionStartTime===null)return;let t=new Date().getTime()-new Date(Q.sessionStartTime).getTime();Q.sessionStartTime=null,e({eventName:et,properties:{sessionDuration:t}})}function dt(){return{timestamp:new Date().toISOString(),pageUrl:typeof window<`u`?window.location.pathname:null}}function ft(e){return t=>({event_name:t.eventName,properties:t.properties,timestamp:t.timestamp,page_url:t.pageUrl,...e})}var $=null;async function pt(e){if(!Q.sessionContext){if(!$){let t=ht();$=e.me().then(e=>({user_id:e.id,session_id:t})).catch(()=>({user_id:null,session_id:t}))}Q.sessionContext=await $}return Q.sessionContext}function mt(){if(typeof window>`u`)return;let e=new URLSearchParams(window.location.search).get(tt);if(e==null||!e.length)return;let t=new URLSearchParams(window.location.search);t.delete(tt);let n=window.location.pathname+(t.toString()?`?`+t.toString():``);return window.history.replaceState({},``,n),{enabled:e===`true`}}function ht(){if(typeof window>`u`)return J();try{let e=localStorage.getItem(nt);if(!e){let e=J();return localStorage.setItem(nt,e),e}return e}catch{return J()}}function gt(e){let{serverUrl:t=`https://base44.app`,appId:n,token:r,serviceToken:i,requiresAuth:a=!1,appBaseUrl:o,options:s,functionsVersion:c,headers:l}=e,u=typeof o==`string`?o:``,d={serverUrl:t,mountPath:`/ws-user-apps/socket.io/`,transports:[`websocket`],appId:n,token:r},f=null,p=()=>(f||=Xe({config:d}),f),m={...l,"X-App-Id":String(n)},h=c?{...m,"Base44-Functions-Version":c}:m,g=Y({baseURL:`${t}/api`,headers:m,token:r,onError:s?.onError}),_=Y({baseURL:`${t}/api`,headers:h,token:r,interceptResponses:!1,onError:s?.onError}),v=Y({baseURL:`${t}/api`,headers:m,token:i,onError:s?.onError}),y=Y({baseURL:`${t}/api`,headers:h,token:i,interceptResponses:!1}),b=Be(g,_,n,{appBaseUrl:u,serverUrl:t}),x={entities:Fe({axios:g,appId:n,getSocket:p}),integrations:ze(g,n),connectors:Ue(g,n),auth:b,functions:Ge(_,n,{getAuthHeaders:()=>{let e={},t=r||X();return t&&(e.Authorization=`Bearer ${t}`),e},baseURL:_.defaults?.baseURL}),agents:Ke({axios:g,getSocket:p,appId:n,serverUrl:t,token:r}),appLogs:qe(g,n),users:Je(g,n),analytics:it({axiosClient:g,serverUrl:t,appId:n,userAuthModule:b}),cleanup:()=>{x.analytics.cleanup(),f&&f.disconnect()}},S={entities:Fe({axios:v,appId:n,getSocket:p}),integrations:ze(v,n),sso:Ve(v,n,r),connectors:He(v,n),functions:Ge(y,n,{getAuthHeaders:()=>{let e={};return i&&(e.Authorization=`Bearer ${i}`),e},baseURL:y.defaults?.baseURL}),agents:Ke({axios:v,getSocket:p,appId:n,serverUrl:t,token:r}),appLogs:qe(v,n),cleanup:()=>{f&&f.disconnect()}};if(typeof window<`u`){let e=r||X();e&&x.auth.setToken(e)}return a&&typeof window<`u`&&setTimeout(async()=>{try{await x.auth.isAuthenticated()||x.auth.redirectToLogin(window.location.href)}catch{x.auth.redirectToLogin(window.location.href)}},0),{...x,setToken(e){x.auth.setToken(e),f&&f.updateConfig({token:e}),d.token=e},getConfig(){return{serverUrl:t,appId:n,requiresAuth:a}},get asServiceRole(){if(!i)throw Error(`Service token is required to use asServiceRole. Please provide a serviceToken when creating the client.`);return S}}}function _t({appId:e,appPlatformVersion:t,authSDK:n,onSuccess:i,onSwitchToRegister:a,onSwitchToResetPassword:o}){let[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(``),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(!1);return(0,K.jsxs)(`form`,{onSubmit:async a=>{a.preventDefault(),p(``),h(!0);try{if(t===3){let t=await gt({appId:e,serverUrl:d()}).auth.loginViaEmailPassword(s,l);t&&i(t.user)}else{let e=await n.loginViaUsernamePassword(s,l);e&&(r(e.access_token),i(e.user))}}catch(e){p(e.response?.data?.detail||`Invalid email or password`)}finally{h(!1)}}
1,className:`space-y-4 sm:space-y-5`,children:[(0,K.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(V,{htmlFor:`email`,className:`text-sm font-medium text-slate-700`,children:`Email`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(O,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-slate-500`}),(0,K.jsx)(B,{id:`email`,type:`email`,placeholder:`[email protected]`,value:s,onChange:e=>c(e.target.value),required:!0,disabled:m,className:`pl-10 h-11 sm:h-12 bg-slate-50/50 border-slate-200 focus:border-slate-400 focus:ring-slate-400 rounded-xl placeholder:text-slate-600`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(V,{htmlFor:`password`,className:`text-sm font-medium text-slate-700`,children:`Password`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(D,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-slate-500`}),(0,K.jsx)(B,{id:`password`,type:`password`,placeholder:`â¢â¢â¢â¢â¢â¢â¢â¢`,value:l,onChange:e=>u(e.target.value),required:!0,disabled:m,className:`pl-10 h-11 sm:h-12 bg-slate-50/50 border-slate-200 focus:border-slate-400 focus:ring-slate-400 rounded-xl placeholder:text-slate-600`})]})]})]}),f&&(0,K.jsx)(U,{className:`bg-red-50/70 border-red-200 rounded-xl`,children:(0,K.jsx)(H,{className:`text-red-700 text-sm`,children:f})}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(C,{type:`submit`,disabled:m,className:`w-full h-11 sm:h-12 bg-slate-900 hover:bg-slate-800 text-white font-medium shadow-sm rounded-xl transition-all duration-200`,children:m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(k,{className:`mr-2 h-4 w-4 animate-spin`}),`Signing in...`]}):`Sign in`}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center justify-between gap-2 sm:gap-0`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:o,className:`text-sm text-slate-500 hover:text-slate-700 font-medium transition-colors`,children:`Forgot password?`}),(0,K.jsxs)(`button`,{type:`button`,onClick:a,className:`text-sm text-slate-500 hover:text-slate-700 transition-colors`,children:[`Need an account? `,(0,K.jsx)(`span`,{className:`font-medium text-slate-700`,children:`Sign up`})]})]})]})]})}function vt({authSDK:e,onSuccess:t,onSwitchToLogin:n,onSwitchToOtpVerification:r,appId:i}){let a=h(),[o,s]=(0,G.useState)({email:``,password:``,confirmPassword:``}),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(!1),f=async t=>{if(t.preventDefault(),l(``),o.password!==o.confirmPassword){l(`Passwords do not match`);return}if(o.password.length<8){l(`Password must be at least 8 characters long`);return}d(!0);try{let t=await e.register({email:o.email,password:o.password});t&&r(o.email,t.access_request_created)}catch(e){let t=e.response?.data?.extra_data;t?.reason===`access_request_needed`&&t?.app_id?a(`/login?app_id=${t.app_id}&error=access_required`):l(e.response?.data?.detail||e.response?.data?.message||`Registration failed. Please try again.`)}finally{d(!1)}},p=(e,t)=>{s(n=>({...n,[e]:t}))};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 text-sm text-slate-500 hover:text-slate-700 font-medium transition-colors -mb-2`,children:[(0,K.jsx)(j,{className:`h-4 w-4`}),`Back to sign in`]}),(0,K.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-slate-900`,children:`Create your account`}),(0,K.jsxs)(`form`,{onSubmit:f,className:`space-y-3 sm:space-y-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(V,{htmlFor:`email`,className:`text-sm font-medium text-slate-700`,children:`Email`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(O,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-slate-400`}),(0,K.jsx)(B,{id:`email`,type:`email`,placeholder:`[email protected]`,value:o.email,onChange:e=>p(`email`,e.target.value),required:!0,disabled:u,className:`pl-10 h-10 sm:h-11 bg-slate-50/50 border-slate-200 focus:border-slate-400 focus:ring-slate-400 rounded-xl placeholder:text-slate-400 text-sm sm:text-base`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(V,{htmlFor:`password`,className:`text-sm font-medium text-slate-700`,children:`Password`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(D,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-slate-400`}),(0,K.jsx)(B,{id:`password`,type:`password`,placeholder:`Min. 8 characters`,value:o.password,onChange:e=>p(`password`,e.target.value),required:!0,disabled:u,className:`pl-10 h-10 sm:h-11 bg-slate-50/50 border-slate-200 focus:border-slate-400 focus:ring-slate-400 rounded-xl placeholder:text-slate-400 text-sm sm:text-base`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(V,{htmlFor:`confirmPassword`,className:`text-sm font-medium text-slate-700`,children:`Confirm Password`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(D,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-slate-400`}),(0,K.jsx)(B,{id:`confirmPassword`,type:`password`,placeholder:`Re-enter password`,value:o.confirmPassword,onChange:e=>p(`confirmPassword`,e.target.value),required:!0,disabled:u,className:`pl-10 h-10 sm:h-11 bg-slate-50/50 border-slate-200 focus:border-slate-400 focus:ring-slate-400 rounded-xl placeholder:text-slate-400 text-sm sm:text-base`})]})]})]}),c&&(0,K.jsx)(U,{className:`bg-red-50/70 border-red-200 rounded-xl`,children:(0,K.jsx)(H,{className:`text-red-700 text-sm`,children:c})}),(0,K.jsx)(C,{type:`submit`,disabled:u,className:`w-full h-10 sm:h-11 bg-slate-900 hover:bg-slate-800 text-white font-medium shadow-sm rounded-xl transition-all duration-200`,children:u?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(k,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating account...`]}):`Create account`})]})]})}function yt({authSDK:e,appId:t,email:n,isAccessRequest:i=!1,onSuccess:a,onSwitchToLogin:o}){let s=h(),[c,l]=(0,G.useState)([``,``,``,``,``,``]),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(``),[m,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1);
1return(0,K.jsxs)(`div`,{className:`space-y-4 sm:space-y-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:o,className:`flex items-center gap-2 text-sm text-slate-500 hover:text-slate-700 font-medium transition-colors -mb-2`,children:[(0,K.jsx)(j,{className:`h-4 w-4`}),`Back to sign in`]}),(0,K.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,K.jsx)(`div`,{className:`mx-auto w-14 h-14 sm:w-16 sm:h-16 bg-slate-100 rounded-full flex items-center justify-center mb-3 sm:mb-4`,children:(0,K.jsx)(re,{className:`h-7 w-7 sm:h-8 sm:w-8 text-slate-700`})}),(0,K.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-slate-900`,children:`Verify your email`}),(0,K.jsxs)(`p`,{className:`text-slate-600 text-sm sm:text-base`,children:[`We've sent a 6-digit code to`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`span`,{className:`font-medium text-slate-900`,children:n})]})]}),(0,K.jsxs)(`form`,{onSubmit:async l=>{l.preventDefault(),d(``),p(``);let u=c.join(``);if(u.length!==6){d(`Please enter all 6 digits`);return}g(!0);try{let c=i?await e.verifyAccessRequestOtp(n,u):await e.verifyOtp(n,u);c&&(i?(p(`Email verified! Waiting for admin approval...`),setTimeout(()=>{s(`/request-access?app_id=${t}`,{state:{email:n,confirmationToken:c.confirmation_token}})},1500)):c.access_token?(r(c.access_token),await new Promise(e=>setTimeout(e,500)),a()):(p(`Email verified successfully! Redirecting to login...`),setTimeout(()=>{o()},2e3)))}catch(e){d(e.response?.data?.detail||`Invalid verification code`)}finally{g(!1)}},className:`space-y-4 sm:space-y-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(xe,{value:c,onChange:l,autoFocus:!0,disabled:m||_,separator:!1}),(0,K.jsx)(`p`,{className:`text-xs text-slate-500 text-center mt-3`,children:`Enter the verification code sent to your email`})]}),u&&(0,K.jsx)(U,{className:`bg-red-50/70 border-red-200 rounded-xl`,children:(0,K.jsx)(H,{className:`text-red-700 text-sm`,children:u})}),f&&(0,K.jsx)(U,{className:`bg-green-50/70 border-green-200 rounded-xl`,children:(0,K.jsx)(H,{className:`text-green-700 text-sm`,children:f})}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(C,{type:`submit`,disabled:m||_||!!f,className:`w-full h-10 sm:h-11 bg-slate-900 hover:bg-slate-800 text-white font-medium shadow-sm rounded-xl transition-all duration-200`,children:m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(k,{className:`mr-2 h-4 w-4 animate-spin`}),`Verifying...`]}):`Verify email`}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsxs)(`p`,{className:`text-sm text-slate-600`,children:[`Didn't receive the code?`,` `,(0,K.jsx)(`button`,{type:`button`,onClick:async()=>{d(``),p(``),v(!0);try{i?await e.resendAccessRequestOtp(n):await e.resendOtp(n),p(`New verification code sent to your email`),l([``,``,``,``,``,``]),setTimeout(()=>p(``),3e3)}catch(e){d(e.response?.data?.detail||`Failed to resend code`)}finally{v(!1)}},disabled:_||m,className:`font-medium text-slate-700 hover:text-slate-900 disabled:opacity-50 transition-colors`,children:_?`Sending...`:`Resend`})]})})]})]})]})}function bt({authSDK:e,onSwitchToLogin:t}){let[n,r]=(0,G.useState)(``),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1);return o?(0,K.jsxs)(`div`,{className:`space-y-4 sm:space-y-6`,children:[(0,K.jsxs)(`div`,{className:`text-center space-y-3 sm:space-y-4`,children:[(0,K.jsx)(`div`,{className:`mx-auto w-14 h-14 sm:w-16 sm:h-16 bg-slate-100 rounded-full flex items-center justify-center`,children:(0,K.jsx)(O,{className:`h-7 w-7 sm:h-8 sm:w-8 text-slate-700`})}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-slate-900`,children:`Check your email`}),(0,K.jsxs)(`p`,{className:`text-slate-600 text-sm sm:text-base`,children:[`We've sent password reset instructions to`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`span`,{className:`font-medium text-slate-900`,children:n})]})]})]}),(0,K.jsx)(U,{className:`bg-green-50/70 border-green-200 rounded-xl`,children:(0,K.jsx)(H,{className:`text-green-700 text-sm`,children:`Please check your email for the password reset link. It may take a few minutes to arrive.`})}),(0,K.jsxs)(`button`,{onClick:t,className:`w-full flex items-center justify-center gap-2 text-sm text-slate-500 hover:text-slate-700 font-medium transition-colors`,children:[(0,K.jsx)(j,{className:`h-4 w-4`}),`Back to sign in`]})]}
1):(0,K.jsxs)(`div`,{className:`space-y-4 sm:space-y-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 text-sm text-slate-500 hover:text-slate-700 font-medium transition-colors -mb-2`,children:[(0,K.jsx)(j,{className:`h-4 w-4`}),`Back to sign in`]}),(0,K.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,K.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-slate-900`,children:`Reset your password`}),(0,K.jsx)(`p`,{className:`text-slate-600 text-sm sm:text-base`,children:`Enter your email and we'll send you a link to reset your password`})]}),(0,K.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),a(``),s(!1),l(!0);try{await e.resetPasswordRequest(n),s(!0)}catch(e){a(e.response?.data?.detail||`Failed to send reset email`)}finally{l(!1)}},className:`space-y-4 sm:space-y-5`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(V,{htmlFor:`email`,className:`text-sm font-medium text-slate-700`,children:`Email`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(O,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-slate-400`}),(0,K.jsx)(B,{id:`email`,type:`email`,placeholder:`[email protected]`,value:n,onChange:e=>r(e.target.value),required:!0,disabled:c,className:`pl-10 h-10 sm:h-11 bg-slate-50/50 border-slate-200 focus:border-slate-400 focus:ring-slate-400 rounded-xl placeholder:text-slate-400`})]})]}),i&&(0,K.jsx)(U,{className:`bg-red-50/70 border-red-200 rounded-xl`,children:(0,K.jsx)(H,{className:`text-red-700 text-sm`,children:i})}),(0,K.jsx)(C,{type:`submit`,disabled:c,className:`w-full h-10 sm:h-11 bg-slate-900 hover:bg-slate-800 text-white font-medium shadow-sm rounded-xl transition-all duration-200`,children:c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(k,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send reset link`})]})]})}var xt=()=>(0,K.jsxs)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`,fill:`#4285F4`}),(0,K.jsx)(`path`,{d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`,fill:`#34A853`}),(0,K.jsx)(`path`,{d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`,fill:`#FBBC05`}),(0,K.jsx)(`path`,{d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`,fill:`#EA4335`})]}),St=()=>(0,K.jsxs)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{fill:`#F25022`,d:`M1 1h10v10H1z`}),(0,K.jsx)(`path`,{fill:`#00A4EF`,d:`M13 1h10v10H13z`}),(0,K.jsx)(`path`,{fill:`#7FBA00`,d:`M1 13h10v10H1z`}),(0,K.jsx)(`path`,{fill:`#FFB900`,d:`M13 13h10v10H13z`})]}),Ct=()=>(0,K.jsx)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{fill:`#1877F2`,d:`M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z`})}),wt=()=>(0,K.jsx)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{fill:`#181717`,d:`M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z`})}),Tt=()=>(0,K.jsx)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{fill:`#007DC1`,d:`M12 0C5.383 0 0 5.383 0 12s5.383 12 12 12 12-5.383 12-12S18.617 0 12 0zm0 4.8c3.971 0 7.2 3.229 7.2 7.2s-3.229 7.2-7.2 7.2S4.8 15.971 4.8 12 8.029 4.8 12 4.8z`})}),Et=()=>(0,K.jsx)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{fill:`#000000`,d:`M18.71 19.5c-.83 1.24
1-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z`})}),Dt={google:{name:`Google`,icon:xt},microsoft:{name:`Microsoft`,icon:St},github:{name:`GitHub`,icon:wt},okta:{name:`Okta`,icon:Tt}};function Ot(e){let t=s(e,`/`);return`${window.location.origin}${t}`}function kt({appId:e}){let t=p(),n=Me(e,()=>{},{}),[r,i]=(0,G.useState)(!0),[a,o]=(0,G.useState)(null),[s,l]=(0,G.useState)(null),[d,f]=(0,G.useState)(`login`),[m,h]=(0,G.useState)(``),[g,_]=(0,G.useState)(!1),v=new URLSearchParams(t.search),y=v.get(`error`),[b,S]=(0,G.useState)(y===`access_required`),C=t=>{let n=Ot(v.get(`from_url`)),r=v.get(`app_id`)||e,i;i=t===`google`?`${u()}/apps/auth/login?from_url=${encodeURIComponent(n)}`:`${u()}/apps/auth/${t}/login?from_url=${encodeURIComponent(n)}`,r&&(i+=`&app_id=${r}`),W(i)},w=()=>C(`google`),T=()=>C(`microsoft`),ee=()=>C(`facebook`),te=()=>C(`apple`),ne=()=>{let t=Ot(v.get(`from_url`)),n=v.get(`app_id`)||e,r;O.use_workspace_sso&&s?.organization_id?r=`${u()}/apps/${s.organization_id}/${n}/auth/sso/login?from_url=${encodeURIComponent(t)}`:(r=`${u()}/apps/${n}/auth/sso/login?from_url=${encodeURIComponent(t)}`,n&&(r+=`&app_id=${n}`)),W(r)},E=e=>{let t=v.get(`from_url`),n=c(t,`/`);window.location.href=n},D=(e,t=!1)=>{h(e),_(t),f(`otp`)},O=be(s),re=[{id:`google`,name:`Google`,enabled:O.enable_google_login!==!1,handler:w,icon:xt},{id:`microsoft`,name:`Microsoft`,enabled:O.enable_microsoft_login,handler:T,icon:St},{id:`facebook`,name:`Facebook`,enabled:O.enable_facebook_login,handler:ee,icon:Ct},{id:`apple`,name:`Apple`,enabled:O.enable_apple_login,handler:te,icon:Et}],A=O.enable_sso_login||O.use_workspace_sso?[]:re.filter(e=>e.enabled),j=e=>{let t=e.icon;return(0,K.jsxs)(`button`,{onClick:e.handler,className:`w-full flex items-center justify-center gap-3 bg-white text-slate-700 px-5 py-3.5 rounded-xl border border-slate-200 hover:bg-slate-50 hover:border-slate-300 hover:shadow-sm transition-all duration-200 font-medium text-[16px] group`,children:[(0,K.jsx)(`div`,{className:` transition-transform duration-200 ${e.id===`google`?`-ml-4`:``}`,children:(0,K.jsx)(t,{})}),(0,K.jsxs)(`span`,{children:[`Continue with `,e.name]})]},e.id)},M=()=>{if(!O.sso_provider_name||O.enable_sso_login===!1)return null;let e=Dt[O.sso_provider_name],t=e?`Continue with ${e.name}`:`Continue with ${O.sso_provider_name} SSO`,n=e?.icon;return(0,K.jsxs)(`button`,{onClick:ne,className:`w-full flex items-center justify-center gap-3 bg-white text-slate-700 px-5 py-3.5 rounded-xl border border-slate-200 hover:bg-slate-50 hover:border-slate-300 hover:shadow-sm transition-all duration-200 font-medium text-[15px] group`,children:[n&&(0,K.jsx)(`div`,{className:`group-hover:scale-110 transition-transform duration-200`,children:(0,K.jsx)(n,{})}),(0,K.jsx)(`span`,{children:t})]})};return(0,G.useEffect)(()=>{(async()=>{try{let t=await x.getLoginInfoById(e);l(t),i(!1)}catch(e){o(e),i(!1)}})()},[e]),r?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100`,children:(0,K.jsx)(`div`,{className:`p-8`,children:(0,K.jsx)(k,{className:`h-10 w-10 animate-spin text-slate-400`})})}):s?.not_published?(0,K.jsx)(q,{appName:s.name}):a?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100`,children:(0,K.jsx)(`div`,{className:`p-8 text-base font-medium text-red-600 bg-white rounded-2xl shadow-sm border border-red-100`,children:`An error occurred while loading the app`})}):(0,K.jsx)(`main`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100 p-4`,children:(0,K.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,K.jsxs)(z,{className:`relative overflow-hidden border-0 shadow-2xl bg-white/95 backdrop-blur-sm rounded-2xl`,children:[(0,K.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-slate-200 via-slate-300 to-slate-200`}),(0,K.jsx)(R,{className:`p-8 sm:p-10 md:pt-12 md:pb-10 md:px-10`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-6 sm:space-y-8`,children:[s?.logo_url&&d===`login`&&(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br from-slate-200 to-slate-300 rounded-full blur-xl opacity-30 group-hover:opacity-40 transition-opacity duration-300`}),(0,K.jsxs)(ke,{className:`relative h-20 w-20 sm:h-24 sm:w-24 shadow-lg ring-4 ring-white/50 group-hover:shadow-xl transition-all duration-300`,children:[(0,K.jsx)(Ae,{src:s.logo_url,alt:`${s.name} logo`,className:`object-cover`}),(0,K.jsx)(je,{className:`bg-gradient-to-br from-slate-100 to-slate-200 text-xl sm:text-2xl font-bold text-slate-700`,children:s.name?.[0]})]})]}),d===`login`&&(0,K.jsxs)(`div`,{className:`space-y-2 sm:space-y-3`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl sm:text-3xl font-bold text-slate-900 tracking-tight`,children:[`Welcome to `,s?.name]}),(0,K.jsx)(`p`,{className:`text-slate-500 text-sm sm:text-base font-medium`,children:`Sign in to continue`})]}),b&&(0,K.jsxs)(`div`,{className:`w-full bg-amber-50 border border-amber-200 rounded-lg px-4 py-3 flex items-start gap-2.5 text-sm text-amber-800`,children:[(0,K.jsx)(ie,{className:`w-4 h-4 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:`This app requires access. Please sign in to request access.`})]}),(0,K.jsx)(`div`,{className:`w-full`,children:(()=>
1{if(O.enable_username_password)switch(d){case`register`:return(0,K.jsx)(vt,{authSDK:n,appId:e,onSuccess:E,onSwitchToLogin:()=>f(`login`),onSwitchToOtpVerification:D});case`otp`:return(0,K.jsx)(yt,{authSDK:n,appId:e,email:m,isAccessRequest:g,onSuccess:E,onSwitchToLogin:()=>f(`login`)});case`reset`:return(0,K.jsx)(bt,{authSDK:n,onSwitchToLogin:()=>f(`login`)});default:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[A.map(e=>j(e)),M()]}),(A.length>0||M())&&(0,K.jsxs)(`div`,{className:`relative my-6`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,K.jsx)(me,{className:`w-full bg-slate-200`})}),(0,K.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,K.jsx)(`span`,{className:`bg-white px-3 text-slate-500 font-medium tracking-wider`,children:`or`})})]}),(0,K.jsx)(_t,{appId:e,appPlatformVersion:s?.platform_version,authSDK:n,onSuccess:E,onSwitchToRegister:()=>f(`register`),onSwitchToResetPassword:()=>f(`reset`)})]})}return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[A.map(e=>j(e)),M()]})})()})]})})]}),(0,K.jsx)(`div`,{className:`mt-8 text-center text-xs text-slate-400 sm:hidden`,children:(0,K.jsx)(`p`,{children:`\xA0`})})]})})}function At({appId:e}){let t=p(),n=h(),r=Me(e,()=>{},{}),i=new URLSearchParams(t.search).get(`token`),[a,o]=(0,G.useState)({password:``,confirmPassword:``}),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),[m,g]=(0,G.useState)(null),[_,v]=(0,G.useState)(!0);(0,G.useEffect)(()=>{(async()=>{try{let t=await x.getLoginInfoById(e);g(t)}catch{}finally{v(!1)}})(),i||c(`Invalid reset link. Please request a new password reset.`)},[i,e]);let y=async e=>{if(e.preventDefault(),c(``),a.password!==a.confirmPassword){c(`Passwords do not match`);return}if(a.password.length<8){c(`Password must be at least 8 characters long`);return}u(!0);try{await r.resetPassword(i,a.password),f(!0),setTimeout(()=>{n(`/login`)},3e3)}catch(e){c(e.response?.data?.detail||`Failed to reset password. The link may have expired.`)}finally{u(!1)}},b=(e,t)=>{o(n=>({...n,[e]:t}))};return _?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50`,children:(0,K.jsx)(`div`,{className:`p-8`,children:(0,K.jsx)(k,{className:`h-10 w-10 animate-spin text-gray-600`})})}):m?.not_published?(0,K.jsx)(q,{appName:m.name}):d?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 p-4`,children:(0,K.jsx)(z,{className:`max-w-md w-full overflow-hidden border-0 shadow-lg bg-white`,children:(0,K.jsxs)(R,{className:`pt-12 pb-10 px-12 text-center space-y-6`,children:[(0,K.jsx)(`div`,{className:`mx-auto w-20 h-20 bg-gray-100 rounded-full flex items-center justify-center`,children:(0,K.jsx)(M,{className:`h-10 w-10 text-green-600`})}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h2`,{className:`text-2xl font-bold text-gray-900`,children:`Password reset successful!`}),(0,K.jsx)(`p`,{className:`text-gray-600`,children:`Your password has been reset. Redirecting to login...`})]}),m?.name&&(0,K.jsxs)(`p`,{className:`text-sm text-gray-500`,children:[`You can now sign in to `,m.name,` with your new password`]})]})})}):i?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 p-4`,children:(0,K.jsxs)(z,{className:`relative max-w-md w-full overflow-hidden border-0 shadow-lg bg-white`,children:[(0,K.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-0.5 bg-gray-900`}),(0,K.jsxs)(R,{className:`pt-12 pb-10 px-12 space-y-8`,children:[(0,K.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,K.jsx)(`h2`,{className:`text-2xl font-bold text-gray-900`,children:`Set new password`}),(0,K.jsx)(`p`,{className:`text-gray-600`,children:m?.name?`Enter your new password for ${m.name}`:`Please enter your new password below`})]}),(0,K.jsxs)(`form`,{onSubmit:y,className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(V,{htmlFor:`password`,className:`text-sm font-medium text-gray-700`,children:`New Password`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(D,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,K.jsx)(B,{id:`password`,type:`password`,placeholder:`â¢â¢â¢â¢â¢â¢â¢â¢`,value:a.password,onChange:e=>b(`password`,e.target.value),required:!0,disabled:l,className:`pl-10 h-11 bg-gray-50/50 border-gray-200 focus:border-gray-400 focus:ring-gray-400`})]}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500`,children:`Must be at least 8 characters`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(V,{htmlFor:`confirmPassword`,className:`text-sm font-medium text-gray-700`,children:`Confirm New Password`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(D,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,K.jsx)(B,{id:`confirmPassword`,type:`password`,placeholder:`â¢â¢â¢â¢â¢â¢â¢â¢`,value:a.confirmPassword,onChange:e=>b(`confirmPassword`,e.target.value),required:!0,disabled:l,className:`pl-10 h-11 bg-gray-50/50 border-gray-200 focus:border-gray-400 focus:ring-gray-400`})]})]})]}),s&&(0,K.jsx)(U,{className:`bg-red-50/50 border-red-200`,children:(0,K.jsx)(H,{className:`text-red-800 text-sm`,children:s})}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(C,{type:`submit`,disabled:l,className:`w-full h-11 bg-gray-900 hover:bg-gray-800 text-white font-medium shadow-sm`,children:l?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(k,{className:`mr-2 h-4 w-4 animate-spin`}),`Resetting password...`]}):`Reset password`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>n(`/login`),className:`w-full text-sm text-gray-600 hover:text-gray-700`,children:`Back to login`})]})]})]})]})}):(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 p-4`,children:(0,K.jsx)(z,{className:`max-w-md w-full overflow-hidden border-0 shadow-lg bg-white`,children:(0,K.jsxs)(R,{className:`pt-12 pb-10 px-12 text-center space-y-6`,children:[(0,K.jsx)(`div`,{className:`mx-auto w-20 h-20 bg-red-100 rounded-full flex items-center justify-center`,children:(0,K.jsx)(A,{className:`h-10 w-10 text-red-600`})}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h2`,{className:`text-2xl font-bold text-gray-900`,children:`Invalid Reset Link`}),(0,K.jsx)(`p`,{className:`text-gray-600`,children:`This password reset link is invali
1d or has expired.`})]}),(0,K.jsx)(C,{onClick:()=>n(`/login`),className:`w-full h-11 bg-gray-900 hover:bg-gray-800 text-white font-medium shadow-sm`,children:`Back to Login`})]})})})}function jt(e){try{let t=e.split(`.`);if(t.length!==3)return null;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`),r=atob(n);return JSON.parse(r)}catch{return null}}function Mt(e){let t=window.location.hash;return t?new URLSearchParams(t.slice(1)).get(e):null}var Nt=3;function Pt({appId:e}){return(0,K.jsx)(T,{ns:`app-access`,children:(0,K.jsx)(Ft,{appId:e})})}function Ft({appId:e}){let t=p().state,n=(0,G.useRef)(null);n.current===null&&(n.current=Mt(`confirmation_token`));let r=n.current;(0,G.useEffect)(()=>{r&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[r]);let i=t?.confirmationToken??r,a=t?.email,o=i?jt(i)?.email:void 0,s=a??o??void 0,{t:c}=w(),[l,u]=(0,G.useState)(0),d=l>=Nt,f=!i;(0,G.useEffect)(()=>{f&&(window.location.href=`/login?app_id=${e}`)},[f,e]);let{data:m}=fe({query:()=>x.getLoginInfoById(e),enabled:!!e},[e]),{mutate:h,data:g,isLoading:_,error:v}=pe({mutate:async()=>{if(!i)throw Error(`Confirmation token is required`);return ye.requestAccess(e,i)},toastError:void 0}),y=(0,G.useCallback)(()=>{d||(u(e=>e+1),h())},[d,h]),b=!!g?.success,S=m?.name??``,C=!!v&&!b,T=`/login?app_id=${e}`;return f||!m?null:Se(m)?(0,K.jsx)(q,{appName:m.name}):(0,K.jsx)(L,{hideLogo:m?.is_remixable===!1,headingTestId:`request-access-heading`,heading:c(`accessRequired.title`,{appName:S||`...`}),description:[c(b?`accessRequired.subtitleRequested`:`accessRequired.subtitleDefault`)],action:(0,K.jsxs)(ee,{preset:`column`,gap:3,className:`items-center`,children:[(0,K.jsx)(F,{variant:`premium`,onClick:y,disabled:b||d,loading:_,"data-testid":`request-access-button`,children:c(b?`accessRequired.requestSubmitted`:`accessRequired.requestAccess`)}),C&&(0,K.jsx)(N,{weight:`medium`,variant:`destructive`,children:c(d?`accessRequired.tooManyAttempts`:`accessRequired.errorMessage`)}),d&&(0,K.jsx)(P,{href:T,weight:`medium`,underline:`always`,children:c(`accessRequired.backToLogin`)})]}),footer:s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(N,{tone:`secondary`,children:c(`accessRequired.loggedInAs`,{email:s})}),(0,K.jsx)(P,{href:T,weight:`medium`,underline:`always`,"data-testid":`switch-account-link`,children:c(`accessRequired.switchAccount`)})]}):void 0})}function It({appId:e}){return(0,K.jsx)(T,{ns:`app-access`,children:(0,K.jsx)(Lt,{appId:e})})}function Lt({appId:e}){let{t}=w(),n=(0,G.useRef)(null);n.current===null&&(n.current=Mt(`email_token`));let r=n.current;(0,G.useEffect)(()=>{r&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[r]);let i=r?jt(r)?.email:void 0,a=!r;(0,G.useEffect)(()=>{a&&(window.location.href=`/login?app_id=${e}`)},[a,e]);let{data:o,error:s}=fe({query:()=>x.getLoginInfoById(e),enabled:!!e&&!a},[e,a]);if(a||!o&&!s)return null;if(Se(o))return(0,K.jsx)(q,{appName:o.name});let c=`/login?app_id=${e}`;return(0,K.jsx)(L,{hideLogo:o?.is_remixable===!1,headingTestId:`workspace-restricted-heading`,heading:t(`workspaceRestricted.title`),description:[t(`workspaceRestricted.subtitle`)],footer:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(N,{tone:`secondary`,children:t(`accessRequired.loggedInAs`,{email:i})}),(0,K.jsx)(P,{href:c,weight:`medium`,underline:`always`,"data-testid":`switch-account-link`,children:t(`accessRequired.switchAccount`)})]}):void 0})}function Rt(){let{user:e,isLoadingAuth:t}=Ee(),{platform:n}=ce();return(0,G.useEffect)(()=>{t||ae({platform:n,onLoaded:()=>{e&&oe(e.id,{platform:n})}})},[t,n,e]),null}function zt(){let{t:e}=w(`app-access`),t=f();return(0,K.jsx)(L,{label:e(`errorLoadingApp.notFoundLabel`),headingTestId:`app-not-found-heading`,heading:e(`errorLoadingApp.notFoundHeading`),description:[e(`errorLoadingApp.notFoundDescription`)],action:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(N,{weight:`medium`,children:e(`errorLoadingApp.notFoundLookingFor`)}),(0,K.jsx)(F,{variant:`premium`,href:t,"data-testid":`visit-home-button`,children:e(`errorLoadingApp.notFoundVisitHome`)})]})})}function Bt({appName:e}){let{t,Trans:n}=w(`app-access`),r=f();return(0,K.jsx)(L,{label:t(`errorLoadingApp.blockedLabel`),headingTestId:`app-blocked-heading`,heading:e?t(`errorLoadingApp.blockedHeadingWithName`,{appName:e}):t(`errorLoadingApp.blockedHeading`),description:[t(`errorLoadingApp.blockedNotAvailable`),t(`errorLoadingApp.blockedTryLater`)],action:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(N,{weight:`medium`,children:t(`appNotPublished.buildPrompt`)}),(0,K.jsx)(F,{variant:`premium`,href:r,"data-testid":`start-building-button`,children:t(`appNotPublished.startBuilding`)})]}),footer:(0,K.jsx)(N,{tone:`secondary`,className:`flex flex-wrap items-center justify-center gap-space-1-5`,children:(0,K.jsx)(n,{i18nKey:`errorLoadingApp.blockedAdminHint`,components:{account:(0,K.jsx)(P,{href:r,weight:`medium`,underline:`always`,"data-testid":`review-account-link`})}})})})}function Vt({}){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),[c,u]=(0,G.useState)(!0),d=l()??(window.location.host.includes(`localhost`)?window.location.host:window.location.hostname),[f]=(0,G.useState)(()=>new b);return(0,G.useEffect)(()=>{x.getDomainAppId(d).then(e=>
1{t(e),window.appId=e,u(!1)}).catch(e=>{e?.response?.status===403&&(a(!0),s(ve(e,`app_name`)??null)),r(!0),u(!1)})},[]),c?(0,K.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`w-12 h-12 border-4 border-gray-200 border-t-black rounded-full animate-spin`})}):i?(0,K.jsx)(Bt,{appName:o}):n?(0,K.jsx)(zt,{}):(0,K.jsxs)(g,{children:[(0,K.jsx)(`div`,{children:(0,K.jsx)(le,{})}),(0,K.jsx)(`div`,{children:(0,K.jsx)(Oe,{})}),(0,K.jsx)(`div`,{children:(0,K.jsx)(le,{})}),(0,K.jsx)(Te,{appId:e,children:(0,K.jsxs)(E,{client:f,children:[(0,K.jsx)(Rt,{}),(0,K.jsxs)(_,{children:[(0,K.jsx)(m,{path:`/login`,element:(0,K.jsx)(kt,{appId:e})}),(0,K.jsx)(m,{path:`/reset-password`,element:(0,K.jsx)(At,{appId:e})}),(0,K.jsx)(m,{path:`/request-access`,element:(0,K.jsx)(Pt,{appId:e})}),(0,K.jsx)(m,{path:`/workspace-restricted`,element:(0,K.jsx)(It,{appId:e})}),(0,K.jsx)(m,{path:`*`,element:(0,K.jsx)(De,{appId:e})})]})]})})]})}export{Vt 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.