heyio 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/daemon/cli.js
CHANGED
|
@@ -59905,6 +59905,12 @@ function createApiServer(config2) {
|
|
|
59905
59905
|
next();
|
|
59906
59906
|
});
|
|
59907
59907
|
app.use(import_express10.default.json({ limit: "1mb" }));
|
|
59908
|
+
app.get("/api/auth/config", (_req, res) => {
|
|
59909
|
+
res.json({
|
|
59910
|
+
supabaseUrl: config2.supabaseUrl ?? null,
|
|
59911
|
+
supabaseAnonKey: config2.supabaseAnonKey ?? null
|
|
59912
|
+
});
|
|
59913
|
+
});
|
|
59908
59914
|
app.use("/api", createAuthMiddleware(config2));
|
|
59909
59915
|
app.use(router2);
|
|
59910
59916
|
app.use(router7);
|
package/dist/daemon/index.js
CHANGED
|
@@ -78994,6 +78994,12 @@ function createApiServer(config2) {
|
|
|
78994
78994
|
next();
|
|
78995
78995
|
});
|
|
78996
78996
|
app.use(import_express10.default.json({ limit: "1mb" }));
|
|
78997
|
+
app.get("/api/auth/config", (_req, res) => {
|
|
78998
|
+
res.json({
|
|
78999
|
+
supabaseUrl: config2.supabaseUrl ?? null,
|
|
79000
|
+
supabaseAnonKey: config2.supabaseAnonKey ?? null
|
|
79001
|
+
});
|
|
79002
|
+
});
|
|
78997
79003
|
app.use("/api", createAuthMiddleware(config2));
|
|
78998
79004
|
app.use(router2);
|
|
78999
79005
|
app.use(router7);
|
|
@@ -443,7 +443,7 @@ Request ID: ${u}`),d){let S=`
|
|
|
443
443
|
Resources:`;for(const A of d){if(!A||typeof A!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${A}`);S+=`
|
|
444
444
|
- ${A}`}k+=S}return`${x}
|
|
445
445
|
${k}`}class Zt extends Error{constructor({message:e,code:r,cause:n,name:i}){var a;super(e,{cause:n}),this.__isWebAuthnError=!0,this.name=(a=i??(n instanceof Error?n.name:void 0))!==null&&a!==void 0?a:"Unknown Error",this.code=r}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class Zf extends Zt{constructor(e,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}),this.name="WebAuthnUnknownError",this.originalError=r}}function tU({error:t,options:e}){var r,n,i;const{publicKey:a}=e;if(!a)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Zt({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=a.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new Zt({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((n=a.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new Zt({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((i=a.authenticatorSelection)===null||i===void 0?void 0:i.userVerification)==="required")return new Zt({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Zt({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Zt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return a.pubKeyCredParams.filter(c=>c.type==="public-key").length===0?new Zt({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Zt({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const o=window.location.hostname;if(uR(o)){if(a.rp.id!==o)return new Zt({message:`The RP ID "${a.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Zt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(a.user.id.byteLength<1||a.user.id.byteLength>64)return new Zt({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Zt({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Zt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function rU({error:t,options:e}){const{publicKey:r}=e;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Zt({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Zt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(uR(n)){if(r.rpId!==n)return new Zt({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Zt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Zt({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Zt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class nU{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const fx=new nU;function PE(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:r,excludeCredentials:n}=t,i=dp(t,["challenge","user","excludeCredentials"]),a=Ds(e).buffer,o=Object.assign(Object.assign({},r),{id:Ds(r.id).buffer}),c=Object.assign(Object.assign({},i),{challenge:a,user:o});if(n&&n.length>0){c.excludeCredentials=new Array(n.length);for(let u=0;u<n.length;u++){const d=n[u];c.excludeCredentials[u]=Object.assign(Object.assign({},d),{id:Ds(d.id).buffer,type:d.type||"public-key",transports:d.transports})}}return c}function RE(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:r}=t,n=dp(t,["challenge","allowCredentials"]),i=Ds(e).buffer,a=Object.assign(Object.assign({},n),{challenge:i});if(r&&r.length>0){a.allowCredentials=new Array(r.length);for(let o=0;o<r.length;o++){const c=r[o];a.allowCredentials[o]=Object.assign(Object.assign({},c),{id:Ds(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return a}function IE(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t;return{id:t.id,rawId:t.id,response:{attestationObject:ko(new Uint8Array(t.response.attestationObject)),clientDataJSON:ko(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function $E(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t,n=t.getClientExtensionResults(),i=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:ko(new Uint8Array(i.authenticatorData)),clientDataJSON:ko(new Uint8Array(i.clientDataJSON)),signature:ko(new Uint8Array(i.signature)),userHandle:i.userHandle?ko(new Uint8Array(i.userHandle)):void 0},type:"public-key",clientExtensionResults:n,authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function uR(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function Qf(){var t,e;return!!(Tr()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.get)=="function")}async function dR(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Zf("Browser returned unexpected credential type",e)}:{data:null,error:new Zf("Empty credential response",e)}}catch(e){return{data:null,error:tU({error:e,options:t})}}}async function fR(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Zf("Browser returned unexpected credential type",e)}:{data:null,error:new Zf("Empty credential response",e)}}catch(e){return{data:null,error:rU({error:e,options:t})}}}const iU={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},aU={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function eh(...t){const e=i=>i!==null&&typeof i=="object"&&!Array.isArray(i),r=i=>i instanceof ArrayBuffer||ArrayBuffer.isView(i),n={};for(const i of t)if(i)for(const a in i){const o=i[a];if(o!==void 0)if(Array.isArray(o))n[a]=o;else if(r(o))n[a]=o;else if(e(o)){const c=n[a];e(c)?n[a]=eh(c,o):n[a]=eh(o)}else n[a]=o}return n}function oU(t,e){return eh(iU,t,e||{})}function sU(t,e){return eh(aU,t,e||{})}class lU{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:r,friendlyName:n,signal:i},a){var o;try{const{data:c,error:u}=await this.client.mfa.challenge({factorId:e,webauthn:r});if(!c)return{data:null,error:u};const d=i??fx.createNewAbortSignal();if(c.webauthn.type==="create"){const{user:p}=c.webauthn.credential_options.publicKey;if(!p.name){const f=n;if(f)p.name=`${p.id}:${f}`;else{const v=(await this.client.getUser()).data.user,b=((o=v==null?void 0:v.user_metadata)===null||o===void 0?void 0:o.name)||(v==null?void 0:v.email)||(v==null?void 0:v.id)||"User";p.name=`${p.id}:${b}`}}p.displayName||(p.displayName=p.name)}switch(c.webauthn.type){case"create":{const p=oU(c.webauthn.credential_options.publicKey,a==null?void 0:a.create),{data:f,error:m}=await dR({publicKey:p,signal:d});return f?{data:{factorId:e,challengeId:c.id,webauthn:{type:c.webauthn.type,credential_response:f}},error:null}:{data:null,error:m}}case"request":{const p=sU(c.webauthn.credential_options.publicKey,a==null?void 0:a.request),{data:f,error:m}=await fR(Object.assign(Object.assign({},c.webauthn.credential_options),{publicKey:p,signal:d}));return f?{data:{factorId:e,challengeId:c.id,webauthn:{type:c.webauthn.type,credential_response:f}},error:null}:{data:null,error:m}}}}catch(c){return be(c)?{data:null,error:c}:{data:null,error:new Xn("Unexpected error in challenge",c)}}}async _verify({challengeId:e,factorId:r,webauthn:n}){return this.client.mfa.verify({factorId:r,challengeId:e,webauthn:n})}async _authenticate({factorId:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:i}={}},a){if(!r)return{data:null,error:new Gc("rpId is required for WebAuthn authentication")};try{if(!Qf())return{data:null,error:new Xn("Browser does not support WebAuthn",null)};const{data:o,error:c}=await this.challenge({factorId:e,webauthn:{rpId:r,rpOrigins:n},signal:i},{request:a});if(!o)return{data:null,error:c};const{webauthn:u}=o;return this._verify({factorId:e,challengeId:o.challengeId,webauthn:{type:u.type,rpId:r,rpOrigins:n,credential_response:u.credential_response}})}catch(o){return be(o)?{data:null,error:o}:{data:null,error:new Xn("Unexpected error in authenticate",o)}}}async _register({friendlyName:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:i}={}},a){if(!r)return{data:null,error:new Gc("rpId is required for WebAuthn registration")};try{if(!Qf())return{data:null,error:new Xn("Browser does not support WebAuthn",null)};const{data:o,error:c}=await this._enroll({friendlyName:e});if(!o)return await this.client.mfa.listFactors().then(p=>{var f;return(f=p.data)===null||f===void 0?void 0:f.all.find(m=>m.factor_type==="webauthn"&&m.friendly_name===e&&m.status!=="unverified")}).then(p=>p?this.client.mfa.unenroll({factorId:p==null?void 0:p.id}):void 0),{data:null,error:c};const{data:u,error:d}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:r,rpOrigins:n},signal:i},{create:a});return u?this._verify({factorId:o.id,challengeId:u.challengeId,webauthn:{rpId:r,rpOrigins:n,type:u.webauthn.type,credential_response:u.webauthn.credential_response}}):{data:null,error:d}}catch(o){return be(o)?{data:null,error:o}:{data:null,error:new Xn("Unexpected error in register",o)}}}}J6();const cU={url:f6,storageKey:h6,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:p6,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}},Ss={};class Vc{get jwks(){var e,r;return(r=(e=Ss[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){Ss[this.storageKey]=Object.assign(Object.assign({},Ss[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=Ss[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Ss[this.storageKey]=Object.assign(Object.assign({},Ss[this.storageKey]),{cachedAt:e})}constructor(e){var r,n,i;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this._sessionRemovalEpoch=0,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lock=null,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const a=Object.assign(Object.assign({},cU),e);if(this.storageKey=a.storageKey,this.instanceID=(r=Vc.nextInstanceID[this.storageKey])!==null&&r!==void 0?r:0,Vc.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.instanceID>0&&Tr()){const o=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(o),this.logDebugMessages&&console.trace(o)}if(this.persistSession=a.persistSession,this.autoRefreshToken=a.autoRefreshToken,this.experimental=(n=a.experimental)!==null&&n!==void 0?n:{},this.admin=new X6({url:a.url,headers:a.headers,fetch:a.fetch,experimental:this.experimental}),this.url=a.url,this.headers=a.headers,this.fetch=lR(a.fetch),this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,this.throwOnError=a.throwOnError,this.lockAcquireTimeout=a.lockAcquireTimeout,a.lock!=null&&(this.lock=a.lock),this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new lU(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(a.storage?this.storage=a.storage:sR()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=NE(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=NE(this.memoryStorage)),Tr()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(i=this.broadcastChannel)===null||i===void 0||i.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o);try{await this._notifyAllSubscribers(o.data.event,o.data.session,!1)}catch(c){this._debug("#broadcastChannel","error",c)}})}a.skipAutoInitialize||this.initialize().catch(o=>{this._debug("#initialize()","error",o)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${iR}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()):await this._initialize())(),await this.initializePromise)}async _initialize(){var e;try{let r={},n="none";if(Tr()&&(r=C6(window.location.href),this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce")),Tr()&&this.detectSessionInUrl&&n!=="none"){const{data:i,error:a}=await this._getSessionFromURL(r,n);if(a){if(this._debug("#_initialize()","error detecting session from URL",a),b6(a)){const u=(e=a.details)===null||e===void 0?void 0:e.code;if(u==="identity_already_exists"||u==="identity_not_found"||u==="single_identity_not_deletable")return{error:a}}return{error:a}}const{session:o,redirectType:c}=i;return this._debug("#_initialize()","detected session in URL",o,"redirect type",c),await this._saveSession(o),setTimeout(async()=>{c==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return be(r)?this._returnResult({error:r}):this._returnResult({error:new Xn("Unexpected error during initialization",r)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,i;try{const a=await Ne(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(i=e==null?void 0:e.options)===null||i===void 0?void 0:i.captchaToken}},xform:An}),{data:o,error:c}=a;if(c||!o)return this._returnResult({data:{user:null,session:null},error:c});const u=o.session,d=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",u)),this._returnResult({data:{user:d,session:u},error:null})}catch(a){if(be(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async signUp(e){var r,n,i;try{let a;if("email"in e){const{email:p,password:f,options:m}=e;let v=null,b=null;this.flowType==="pkce"&&([v,b]=await _s(this.storage,this.storageKey)),a=await Ne(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:m==null?void 0:m.emailRedirectTo,body:{email:p,password:f,data:(r=m==null?void 0:m.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:m==null?void 0:m.captchaToken},code_challenge:v,code_challenge_method:b},xform:An})}else if("phone"in e){const{phone:p,password:f,options:m}=e;a=await Ne(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:f,data:(n=m==null?void 0:m.data)!==null&&n!==void 0?n:{},channel:(i=m==null?void 0:m.channel)!==null&&i!==void 0?i:"sms",gotrue_meta_security:{captcha_token:m==null?void 0:m.captchaToken}},xform:An})}else throw new df("You must provide either an email or phone number and a password");const{data:o,error:c}=a;if(c||!o)return await nr(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:c});const u=o.session,d=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",u)),this._returnResult({data:{user:d,session:u},error:null})}catch(a){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async signInWithPassword(e){try{let r;if("email"in e){const{email:a,password:o,options:c}=e;r=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:o,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},xform:CE})}else if("phone"in e){const{phone:a,password:o,options:c}=e;r=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:o,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},xform:CE})}else throw new df("You must provide either an email or phone number and a password");const{data:n,error:i}=r;if(i)return this._returnResult({data:{user:null,session:null},error:i});if(!n||!n.session||!n.user){const a=new ws;return this._returnResult({data:{user:null,session:null},error:a})}return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),this._returnResult({data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:i})}catch(r){if(be(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOAuth(e){var r,n,i,a;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(i=e.options)===null||i===void 0?void 0:i.queryParams,skipBrowserRedirect:(a=e.options)===null||a===void 0?void 0:a.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this.lock!=null?this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e)):this._exchangeCodeForSession(e)}async signInWithWeb3(e){const{chain:r}=e;switch(r){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(e){var r,n,i,a,o,c,u,d,p,f,m;let v,b;if("message"in e)v=e.message,b=e.signature;else{const{chain:w,wallet:x,statement:k,options:S}=e;let A;if(Tr())if(typeof x=="object")A=x;else{const $=window;if("ethereum"in $&&typeof $.ethereum=="object"&&"request"in $.ethereum&&typeof $.ethereum.request=="function")A=$.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof x!="object"||!(S!=null&&S.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=x}const C=new URL((r=S==null?void 0:S.url)!==null&&r!==void 0?r:window.location.href),T=await A.request({method:"eth_requestAccounts"}).then($=>$).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!T||T.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const O=cR(T[0]);let N=(n=S==null?void 0:S.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!N){const $=await A.request({method:"eth_chainId"});N=Z6($)}const R={domain:C.host,address:O,statement:k,uri:C.href,version:"1",chainId:N,nonce:(i=S==null?void 0:S.signInWithEthereum)===null||i===void 0?void 0:i.nonce,issuedAt:(o=(a=S==null?void 0:S.signInWithEthereum)===null||a===void 0?void 0:a.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(c=S==null?void 0:S.signInWithEthereum)===null||c===void 0?void 0:c.expirationTime,notBefore:(u=S==null?void 0:S.signInWithEthereum)===null||u===void 0?void 0:u.notBefore,requestId:(d=S==null?void 0:S.signInWithEthereum)===null||d===void 0?void 0:d.requestId,resources:(p=S==null?void 0:S.signInWithEthereum)===null||p===void 0?void 0:p.resources};v=eU(R),b=await A.request({method:"personal_sign",params:[Q6(v),O]})}try{const{data:w,error:x}=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:v,signature:b},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(m=e.options)===null||m===void 0?void 0:m.captchaToken}}:null),xform:An});if(x)throw x;if(!w||!w.session||!w.user){const k=new ws;return this._returnResult({data:{user:null,session:null},error:k})}return w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),this._returnResult({data:Object.assign({},w),error:x})}catch(w){if(be(w))return this._returnResult({data:{user:null,session:null},error:w});throw w}}async signInWithSolana(e){var r,n,i,a,o,c,u,d,p,f,m,v;let b,w;if("message"in e)b=e.message,w=e.signature;else{const{chain:x,wallet:k,statement:S,options:A}=e;let C;if(Tr())if(typeof k=="object")C=k;else{const O=window;if("solana"in O&&typeof O.solana=="object"&&("signIn"in O.solana&&typeof O.solana.signIn=="function"||"signMessage"in O.solana&&typeof O.solana.signMessage=="function"))C=O.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof k!="object"||!(A!=null&&A.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");C=k}const T=new URL((r=A==null?void 0:A.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in C&&C.signIn){const O=await C.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},A==null?void 0:A.signInWithSolana),{version:"1",domain:T.host,uri:T.href}),S?{statement:S}:null));let N;if(Array.isArray(O)&&O[0]&&typeof O[0]=="object")N=O[0];else if(O&&typeof O=="object"&&"signedMessage"in O&&"signature"in O)N=O;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in N&&"signature"in N&&(typeof N.signedMessage=="string"||N.signedMessage instanceof Uint8Array)&&N.signature instanceof Uint8Array)b=typeof N.signedMessage=="string"?N.signedMessage:new TextDecoder().decode(N.signedMessage),w=N.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in C)||typeof C.signMessage!="function"||!("publicKey"in C)||typeof C!="object"||!C.publicKey||!("toBase58"in C.publicKey)||typeof C.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");b=[`${T.host} wants you to sign in with your Solana account:`,C.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${T.href}`,`Issued At: ${(i=(n=A==null?void 0:A.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&i!==void 0?i:new Date().toISOString()}`,...!((a=A==null?void 0:A.signInWithSolana)===null||a===void 0)&&a.notBefore?[`Not Before: ${A.signInWithSolana.notBefore}`]:[],...!((o=A==null?void 0:A.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${A.signInWithSolana.expirationTime}`]:[],...!((c=A==null?void 0:A.signInWithSolana)===null||c===void 0)&&c.chainId?[`Chain ID: ${A.signInWithSolana.chainId}`]:[],...!((u=A==null?void 0:A.signInWithSolana)===null||u===void 0)&&u.nonce?[`Nonce: ${A.signInWithSolana.nonce}`]:[],...!((d=A==null?void 0:A.signInWithSolana)===null||d===void 0)&&d.requestId?[`Request ID: ${A.signInWithSolana.requestId}`]:[],...!((f=(p=A==null?void 0:A.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||f===void 0)&&f.length?["Resources",...A.signInWithSolana.resources.map(N=>`- ${N}`)]:[]].join(`
|
|
446
|
-
`);const O=await C.signMessage(new TextEncoder().encode(b),"utf8");if(!O||!(O instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=O}}try{const{data:x,error:k}=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:b,signature:ko(w)},!((m=e.options)===null||m===void 0)&&m.captchaToken?{gotrue_meta_security:{captcha_token:(v=e.options)===null||v===void 0?void 0:v.captchaToken}}:null),xform:An});if(k)throw k;if(!x||!x.session||!x.user){const S=new ws;return this._returnResult({data:{user:null,session:null},error:S})}return x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("SIGNED_IN",x.session)),this._returnResult({data:Object.assign({},x),error:k})}catch(x){if(be(x))return this._returnResult({data:{user:null,session:null},error:x});throw x}}async _exchangeCodeForSession(e){const r=await Di(this.storage,`${this.storageKey}-code-verifier`),[n,i]=(r??"").split("/");try{if(!n&&this.flowType==="pkce")throw new x6;const{data:a,error:o}=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:An});if(await nr(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!a||!a.session||!a.user){const c=new ws;return this._returnResult({data:{user:null,session:null,redirectType:null},error:c})}return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers(i==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",a.session)),this._returnResult({data:Object.assign(Object.assign({},a),{redirectType:i??null}),error:o})}catch(a){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(a))return this._returnResult({data:{user:null,session:null,redirectType:null},error:a});throw a}}async signInWithIdToken(e){try{const{options:r,provider:n,token:i,access_token:a,nonce:o}=e,c=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:i,access_token:a,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:An}),{data:u,error:d}=c;if(d)return this._returnResult({data:{user:null,session:null},error:d});if(!u||!u.session||!u.user){const p=new ws;return this._returnResult({data:{user:null,session:null},error:p})}return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),this._returnResult({data:u,error:d})}catch(r){if(be(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,n,i,a,o;try{if("email"in e){const{email:c,options:u}=e;let d=null,p=null;this.flowType==="pkce"&&([d,p]=await _s(this.storage,this.storageKey));const{error:f}=await Ne(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:c,data:(r=u==null?void 0:u.data)!==null&&r!==void 0?r:{},create_user:(n=u==null?void 0:u.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:u==null?void 0:u.captchaToken},code_challenge:d,code_challenge_method:p},redirectTo:u==null?void 0:u.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:f})}if("phone"in e){const{phone:c,options:u}=e,{data:d,error:p}=await Ne(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:c,data:(i=u==null?void 0:u.data)!==null&&i!==void 0?i:{},create_user:(a=u==null?void 0:u.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:u==null?void 0:u.captchaToken},channel:(o=u==null?void 0:u.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:d==null?void 0:d.message_id},error:p})}throw new df("You must provide either an email or phone number.")}catch(c){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(c))return this._returnResult({data:{user:null,session:null},error:c});throw c}}async verifyOtp(e){var r,n;try{let i,a;"options"in e&&(i=(r=e.options)===null||r===void 0?void 0:r.redirectTo,a=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:o,error:c}=await Ne(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:i,xform:An});if(c)throw c;if(!o)throw new Error("An error occurred on token verification.");const u=o.session,d=o.user;return u!=null&&u.access_token&&(await this._saveSession(u),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",u)),this._returnResult({data:{user:d,session:u},error:null})}catch(i){if(be(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithSSO(e){var r,n,i,a,o;try{let c=null,u=null;this.flowType==="pkce"&&([c,u]=await _s(this.storage,this.storageKey));const d=await Ne(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((i=e==null?void 0:e.options)===null||i===void 0)&&i.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:c,code_challenge_method:u}),headers:this.headers,xform:K6});return!((a=d.data)===null||a===void 0)&&a.url&&Tr()&&!(!((o=e.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(d.data.url),this._returnResult(d)}catch(c){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(c))return this._returnResult({data:null,error:c});throw c}}async reauthenticate(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate()):await this._reauthenticate()}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new mr;const{error:i}=await Ne(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:i})})}catch(e){if(be(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:n,type:i,options:a}=e,{error:o}=await Ne(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:i,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},redirectTo:a==null?void 0:a.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in e){const{phone:n,type:i,options:a}=e,{data:o,error:c}=await Ne(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:i,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:c})}throw new df("You must provide either an email or phone number and a type")}catch(r){if(be(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async getSession(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async e=>e)):await this._useSession(async e=>e)}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),i=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await i}catch{}})()),i}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const i=[...this.pendingInLock];await Promise.all(i),this.pendingInLock.splice(0,i.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lock!=null&&!this.lockAcquired&&this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await Di(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=e.expires_at?e.expires_at*1e3-Date.now()<Dg:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.userStorage){const o=await Di(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=zg()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};e.user=q6(e.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:i,error:a}=await this._callRefreshToken(e.refresh_token);return a?this._returnResult({data:{session:null},error:a}):this._returnResult({data:{session:i},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;let r;return this.lock!=null?r=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser()):r=await this._getUser(),r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await Ne(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Pa}):await this._useSession(async r=>{var n,i,a;const{data:o,error:c}=r;if(c)throw c;return!(!((n=o.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new mr}:await Ne(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(a=(i=o.session)===null||i===void 0?void 0:i.access_token)!==null&&a!==void 0?a:void 0,xform:Pa})})}catch(r){if(be(r))return uf(r)&&(await this._removeSession(),await nr(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:r});throw r}}async updateUser(e,r={}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,r)):await this._updateUser(e,r)}async _updateUser(e,r={}){try{return await this._useSession(async n=>{const{data:i,error:a}=n;if(a)throw a;if(!i.session)throw new mr;const o=i.session;let c=null,u=null;this.flowType==="pkce"&&e.email!=null&&([c,u]=await _s(this.storage,this.storageKey));const{data:d,error:p}=await Ne(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:c,code_challenge_method:u}),jwt:o.access_token,xform:Pa});if(p)throw p;return o.user=d.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(n){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(n))return this._returnResult({data:{user:null},error:n});throw n}}async setSession(e){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e)):await this._setSession(e)}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new mr;const r=Date.now()/1e3;let n=r,i=!0,a=null;const{payload:o}=hf(e.access_token);if(o.exp&&(n=o.exp,i=n<=r),i){const{data:c,error:u}=await this._callRefreshToken(e.refresh_token);if(u)return this._returnResult({data:{user:null,session:null},error:u});if(!c)return{data:{user:null,session:null},error:null};a=c}else{const{data:c,error:u}=await this._getUser(e.access_token);if(u)return this._returnResult({data:{user:null,session:null},error:u});a={access_token:e.access_token,refresh_token:e.refresh_token,user:c.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return this._returnResult({data:{user:a.user,session:a},error:null})}catch(r){if(be(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}}async refreshSession(e){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e)):await this._refreshSession(e)}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){const{data:o,error:c}=r;if(c)throw c;e=(n=o.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new mr;const{data:i,error:a}=await this._callRefreshToken(e.refresh_token);return a?this._returnResult({data:{user:null,session:null},error:a}):i?this._returnResult({data:{user:i.user,session:i},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(be(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){var n;try{if(!Tr())throw new ff("No browser detected.");if(e.error||e.error_description||e.error_code)throw new ff(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new wE("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new ff("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new wE("No code detected.");const{data:A,error:C}=await this._exchangeCodeForSession(e.code);if(C)throw C;const T=new URL(window.location.href);return T.searchParams.delete("code"),window.history.replaceState(window.history.state,"",T.toString()),{data:{session:A.session,redirectType:(n=A.redirectType)!==null&&n!==void 0?n:null},error:null}}const{provider_token:i,provider_refresh_token:a,access_token:o,refresh_token:c,expires_in:u,expires_at:d,token_type:p}=e;if(!o||!u||!c||!p)throw new ff("No session defined in URL");const f=Math.round(Date.now()/1e3),m=parseInt(u);let v=f+m;d&&(v=parseInt(d));const b=v-f;b*1e3<=Ca&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${b}s, should have been closer to ${m}s`);const w=v-m;f-w>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",w,v,f):f-w<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",w,v,f);const{data:x,error:k}=await this._getUser(o);if(k)throw k;const S={provider_token:i,provider_refresh_token:a,access_token:o,expires_in:m,expires_at:v,refresh_token:c,token_type:p,user:x.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:S,redirectType:e.type},error:null})}catch(i){if(be(i))return this._returnResult({data:{session:null,redirectType:null},error:i});throw i}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error||e.error_description||e.error_code)}async _isPKCECallback(e){const r=await Di(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e)):await this._signOut(e)}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:i,error:a}=r;if(a&&!uf(a))return this._returnResult({error:a});const o=(n=i.session)===null||n===void 0?void 0:n.access_token;if(o){const{error:c}=await this.admin.signOut(o,e);if(c&&!(v6(c)&&(c.status===404||c.status===401||c.status===403)||uf(c)))return this._returnResult({error:c})}return e!=="others"&&(await this._removeSession(),await nr(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const r=T6(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(r)}):await this._emitInitialSession(r)))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,i;try{const{data:{session:a},error:o}=r;if(o)throw o;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",a),uf(a)?console.warn(a):console.error(a)}})}async resetPasswordForEmail(e,r={}){let n=null,i=null;this.flowType==="pkce"&&([n,i]=await _s(this.storage,this.storageKey,!0));try{return await Ne(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:i,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(a){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(a))return this._returnResult({data:null,error:a});throw a}}async getUserIdentities(){var e;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var r;try{const{data:n,error:i}=await this._useSession(async a=>{var o,c,u,d,p;const{data:f,error:m}=a;if(m)throw m;const v=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(c=e.options)===null||c===void 0?void 0:c.scopes,queryParams:(u=e.options)===null||u===void 0?void 0:u.queryParams,skipBrowserRedirect:!0});return await Ne(this.fetch,"GET",v,{headers:this.headers,jwt:(p=(d=f.session)===null||d===void 0?void 0:d.access_token)!==null&&p!==void 0?p:void 0})});if(i)throw i;return Tr()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),this._returnResult({data:{provider:e.provider,url:n==null?void 0:n.url},error:null})}catch(n){if(be(n))return this._returnResult({data:{provider:e.provider,url:null},error:n});throw n}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var n;try{const{error:i,data:{session:a}}=r;if(i)throw i;const{options:o,provider:c,token:u,access_token:d,nonce:p}=e,f=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=a==null?void 0:a.access_token)!==null&&n!==void 0?n:void 0,body:{provider:c,id_token:u,access_token:d,nonce:p,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:An}),{data:m,error:v}=f;return v?this._returnResult({data:{user:null,session:null},error:v}):!m||!m.session||!m.user?this._returnResult({data:{user:null,session:null},error:new ws}):(m.session&&(await this._saveSession(m.session),await this._notifyAllSubscribers("USER_UPDATED",m.session)),this._returnResult({data:m,error:v}))}catch(i){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,i;const{data:a,error:o}=r;if(o)throw o;return await Ne(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(i=(n=a.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _refreshAccessToken(e){const r="#_refreshAccessToken()";this._debug(r,"begin");try{const n=Date.now();return await P6(async i=>(i>0&&await N6(200*Math.pow(2,i-1)),this._debug(r,"refreshing attempt",i),await Ne(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:An})),(i,a)=>{const o=200*Math.pow(2,i);return a&&Lg(a)&&Date.now()+o-n<Ca})}catch(n){if(this._debug(r,"error",n),be(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const n=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",n),Tr()&&!r.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e,r;const n="#_recoverAndRefresh()";this._debug(n,"begin");try{const i=await Di(this.storage,this.storageKey);if(i&&this.userStorage){let o=await Di(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:i.user},await Ns(this.userStorage,this.storageKey+"-user",o)),i.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:zg()}else if(i&&!i.user&&!i.user){const o=await Di(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(i.user=o.user,await nr(this.storage,this.storageKey+"-user"),await Ns(this.storage,this.storageKey,i)):i.user=zg()}if(this._debug(n,"session from storage",i),!this._isValidSession(i)){this._debug(n,"session is not valid"),i!==null&&await this._removeSession();return}const a=((r=i.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<Dg;if(this._debug(n,`session has${a?"":" not"} expired with margin of ${Dg}s`),a){if(this.autoRefreshToken&&i.refresh_token){const{error:o}=await this._callRefreshToken(i.refresh_token);o&&(w6(o)?this._debug(n,"refresh discarded by commit guard",o):(console.error(o),Lg(o)||(this._debug(n,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession())))}}else if(i.user&&i.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:c}=await this._getUser(i.access_token);!c&&(o!=null&&o.user)?(i.user=o.user,await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)):this._debug(n,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(n,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",i)}catch(i){this._debug(n,"error",i),console.error(i);return}finally{this._debug(n,"end")}}async _callRefreshToken(e){var r,n;if(!e)throw new mr;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const i="#_callRefreshToken()";this._debug(i,"begin");try{this.refreshingDeferred=new pp;const a=await Di(this.storage,this.storageKey),{data:o,error:c}=await this._refreshAccessToken(e);if(c)throw c;if(!o.session)throw new mr;const u=await Di(this.storage,this.storageKey);if(a!==null&&(u===null||u.refresh_token!==a.refresh_token)){this._debug(i,"commit guard: storage changed since refresh started, discarding rotated tokens",{startedWith:"present",nowHolds:u?"replaced":"cleared"});const m={data:null,error:new _E};return this.refreshingDeferred.resolve(m),m}const p=this._sessionRemovalEpoch;if(await this._saveSession(o.session),this._sessionRemovalEpoch!==p){this._debug(i,"commit guard (post-save): _removeSession ran during _saveSession, undoing write"),await nr(this.storage,this.storageKey),this.userStorage&&await nr(this.userStorage,this.storageKey+"-user");const m={data:null,error:new _E};return this.refreshingDeferred.resolve(m),m}await this._notifyAllSubscribers("TOKEN_REFRESHED",o.session);const f={data:o.session,error:null};return this.refreshingDeferred.resolve(f),f}catch(a){if(this._debug(i,"error",a),be(a)){const o={data:null,error:a};return Lg(a)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(o),o}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(a),a}finally{this.refreshingDeferred=null,this._debug(i,"end")}}async _notifyAllSubscribers(e,r,n=!0){const i=`#_notifyAllSubscribers(${e})`;this._debug(i,"begin",r,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:r});const a=[],o=Array.from(this.stateChangeEmitters.values()).map(async c=>{try{await c.callback(e,r)}catch(u){a.push(u)}});if(await Promise.all(o),a.length>0){for(let c=0;c<a.length;c+=1)console.error(a[c]);throw a[0]}}finally{this._debug(i,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await nr(this.storage,`${this.storageKey}-code-verifier`);const r=Object.assign({},e),n=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!n&&r.user&&await Ns(this.userStorage,this.storageKey+"-user",{user:r.user});const i=Object.assign({},r);delete i.user;const a=OE(i);await Ns(this.storage,this.storageKey,a)}else{const i=OE(r);await Ns(this.storage,this.storageKey,i)}}async _removeSession(){this._sessionRemovalEpoch+=1,this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await nr(this.storage,this.storageKey),await nr(this.storage,this.storageKey+"-code-verifier"),await nr(this.storage,this.storageKey+"-user"),this.userStorage&&await nr(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Tr()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Ca);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const r=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=r,r&&typeof r=="object"&&typeof r.unref=="function"?r.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(r)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const r=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,r&&clearTimeout(r)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async dispose(){var e;this._removeVisibilityChangedCallback(),await this._stopAutoRefresh(),(e=this.broadcastChannel)===null||e===void 0||e.close(),this.broadcastChannel=null,this.stateChangeEmitters.clear()}async _autoRefreshTokenTick(){if(this._debug("#_autoRefreshTokenTick()","begin"),this.lock!=null){try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const i=Math.floor((n.expires_at*1e3-e)/Ca);this._debug("#_autoRefreshTokenTick()",`access token expires in ${i} ticks, a tick lasts ${Ca}ms, refresh threshold is ${Oc} ticks`),i<=Oc&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof Y6)this._debug("auto refresh token tick lock not available");else throw e}return}if(this.refreshingDeferred!==null){this._debug("#_autoRefreshTokenTick()","refresh already in flight, skipping");return}try{const e=Date.now();try{await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const i=Math.floor((n.expires_at*1e3-e)/Ca);this._debug("#_autoRefreshTokenTick()",`access token expires in ${i} ticks, a tick lasts ${Ca}ms, refresh threshold is ${Oc} ticks`),i<=Oc&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Tr()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;if(this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"){if(this.autoRefreshToken&&this._startAutoRefresh(),!e)if(await this.initializePromise,this.lock!=null)await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()});else{if(document.visibilityState!=="visible"){this._debug(r,"visibilityState is no longer visible, skipping recovery");return}await this._recoverAndRefresh()}}else document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){const i=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&i.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&i.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[a,o]=await _s(this.storage,this.storageKey),c=new URLSearchParams({code_challenge:`${encodeURIComponent(a)}`,code_challenge_method:`${encodeURIComponent(o)}`});i.push(c.toString())}if(n!=null&&n.queryParams){const a=new URLSearchParams(n.queryParams);i.push(a.toString())}return n!=null&&n.skipBrowserRedirect&&i.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${i.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;const{data:i,error:a}=r;return a?this._returnResult({data:null,error:a}):await Ne(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=i==null?void 0:i.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,i;const{data:a,error:o}=r;if(o)return this._returnResult({data:null,error:o});const c=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:u,error:d}=await Ne(this.fetch,"POST",`${this.url}/factors`,{body:c,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return d?this._returnResult({data:null,error:d}):(e.factorType==="totp"&&u.type==="totp"&&(!((i=u==null?void 0:u.totp)===null||i===void 0)&&i.qr_code)&&(u.totp.qr_code=`data:image/svg+xml;utf-8,${u.totp.qr_code}`),this._returnResult({data:u,error:null}))})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _verify(e){const r=async()=>{try{return await this._useSession(async n=>{var i;const{data:a,error:o}=n;if(o)return this._returnResult({data:null,error:o});const c=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?IE(e.webauthn.credential_response):$E(e.webauthn.credential_response)})}:{code:e.code}),{data:u,error:d}=await Ne(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:c,headers:this.headers,jwt:(i=a==null?void 0:a.session)===null||i===void 0?void 0:i.access_token});return d?this._returnResult({data:null,error:d}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+u.expires_in},u)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",u),this._returnResult({data:u,error:d}))})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,r):r()}async _challenge(e){const r=async()=>{try{return await this._useSession(async n=>{var i;const{data:a,error:o}=n;if(o)return this._returnResult({data:null,error:o});const c=await Ne(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(i=a==null?void 0:a.session)===null||i===void 0?void 0:i.access_token});if(c.error)return c;const{data:u}=c;if(u.type!=="webauthn")return{data:u,error:null};switch(u.webauthn.type){case"create":return{data:Object.assign(Object.assign({},u),{webauthn:Object.assign(Object.assign({},u.webauthn),{credential_options:Object.assign(Object.assign({},u.webauthn.credential_options),{publicKey:PE(u.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},u),{webauthn:Object.assign(Object.assign({},u.webauthn),{credential_options:Object.assign(Object.assign({},u.webauthn.credential_options),{publicKey:RE(u.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,r):r()}async _challengeAndVerify(e){const{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?this._returnResult({data:null,error:n}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:n}=await this.getUser();if(n)return{data:null,error:n};const i={all:[],phone:[],totp:[],webauthn:[]};for(const a of(e=r==null?void 0:r.factors)!==null&&e!==void 0?e:[])i.all.push(a),a.status==="verified"&&i[a.factor_type].push(a);return{data:i,error:null}}async _getAuthenticatorAssuranceLevel(e){var r,n,i,a;if(e)try{const{payload:v}=hf(e);let b=null;v.aal&&(b=v.aal);let w=b;const{data:{user:x},error:k}=await this.getUser(e);if(k)return this._returnResult({data:null,error:k});((n=(r=x==null?void 0:x.factors)===null||r===void 0?void 0:r.filter(C=>C.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(w="aal2");const A=v.amr||[];return{data:{currentLevel:b,nextLevel:w,currentAuthenticationMethods:A},error:null}}catch(v){if(be(v))return this._returnResult({data:null,error:v});throw v}const{data:{session:o},error:c}=await this.getSession();if(c)return this._returnResult({data:null,error:c});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:u}=hf(o.access_token);let d=null;u.aal&&(d=u.aal);let p=d;((a=(i=o.user.factors)===null||i===void 0?void 0:i.filter(v=>v.status==="verified"))!==null&&a!==void 0?a:[]).length>0&&(p="aal2");const m=u.amr||[];return{data:{currentLevel:d,nextLevel:p,currentAuthenticationMethods:m},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;return i?this._returnResult({data:null,error:i}):n?await Ne(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:n.access_token,xform:a=>({data:a,error:null})}):this._returnResult({data:null,error:new mr})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:i},error:a}=n;if(a)return this._returnResult({data:null,error:a});if(!i)return this._returnResult({data:null,error:new mr});const o=await Ne(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:i.access_token,body:{action:"approve"},xform:c=>({data:c,error:null})});return o.data&&o.data.redirect_url&&Tr()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}}async _denyAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:i},error:a}=n;if(a)return this._returnResult({data:null,error:a});if(!i)return this._returnResult({data:null,error:new mr});const o=await Ne(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:i.access_token,body:{action:"deny"},xform:c=>({data:c,error:null})});return o.data&&o.data.redirect_url&&Tr()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;return n?this._returnResult({data:null,error:n}):r?await Ne(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new mr})})}catch(e){if(be(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;return i?this._returnResult({data:null,error:i}):n?(await Ne(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new mr})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(c=>c.kid===e);if(n)return n;const i=Date.now();if(n=this.jwks.keys.find(c=>c.kid===e),n&&this.jwks_cached_at+g6>i)return n;const{data:a,error:o}=await Ne(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!a.keys||a.keys.length===0||(this.jwks=a,this.jwks_cached_at=i,n=a.keys.find(c=>c.kid===e),!n)?null:n}async getClaims(e,r={}){try{let n=e;if(!n){const{data:v,error:b}=await this.getSession();if(b||!v.session)return this._returnResult({data:null,error:b});n=v.session.access_token}const{header:i,payload:a,signature:o,raw:{header:c,payload:u}}=hf(n);if(!(r!=null&&r.allowExpired))try{z6(a.exp)}catch(v){throw new Yf(v instanceof Error?v.message:"JWT validation failed")}const d=!i.alg||i.alg.startsWith("HS")||!i.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(i.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!d){const{error:v}=await this.getUser(n);if(v)throw v;return{data:{claims:a,header:i,signature:o},error:null}}const p=B6(i.alg),f=await crypto.subtle.importKey("jwk",d,p,!0,["verify"]);if(!await crypto.subtle.verify(p,f,o,A6(`${c}.${u}`)))throw new Yf("Invalid JWT signature");return{data:{claims:a,header:i,signature:o},error:null}}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}}async signInWithPasskey(e){var r,n,i;qn(this.experimental);try{if(!Qf())return this._returnResult({data:null,error:new Xn("Browser does not support WebAuthn",null)});const{data:a,error:o}=await this._startPasskeyAuthentication({options:{captchaToken:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}});if(o||!a)return this._returnResult({data:null,error:o});const c=RE(a.options),u=(i=(n=e==null?void 0:e.options)===null||n===void 0?void 0:n.signal)!==null&&i!==void 0?i:fx.createNewAbortSignal(),{data:d,error:p}=await fR({publicKey:c,signal:u});if(p||!d)return this._returnResult({data:null,error:p??new Xn("WebAuthn ceremony failed",null)});const f=$E(d);return this._verifyPasskeyAuthentication({challengeId:a.challenge_id,credential:f})}catch(a){if(be(a))return this._returnResult({data:null,error:a});throw a}}async registerPasskey(e){var r,n;qn(this.experimental);try{if(!Qf())return this._returnResult({data:null,error:new Xn("Browser does not support WebAuthn",null)});const{data:i,error:a}=await this._startPasskeyRegistration();if(a||!i)return this._returnResult({data:null,error:a});const o=PE(i.options),c=(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.signal)!==null&&n!==void 0?n:fx.createNewAbortSignal(),{data:u,error:d}=await dR({publicKey:o,signal:c});if(d||!u)return this._returnResult({data:null,error:d??new Xn("WebAuthn ceremony failed",null)});const p=IE(u);return this._verifyPasskeyRegistration({challengeId:i.challenge_id,credential:p})}catch(i){if(be(i))return this._returnResult({data:null,error:i});throw i}}async _startPasskeyRegistration(){qn(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new mr});const{data:i,error:a}=await Ne(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:r.access_token,body:{}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:i,error:null})})}catch(e){if(be(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){qn(this.experimental);try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new mr});const{data:a,error:o}=await Ne(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:n.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:a,error:null})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _startPasskeyAuthentication(e){var r;qn(this.experimental);try{const{data:n,error:i}=await Ne(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}}async _verifyPasskeyAuthentication(e){qn(this.experimental);try{const{data:r,error:n}=await Ne(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:An});return n?this._returnResult({data:null,error:n}):(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:r,error:null}))}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _listPasskeys(){qn(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new mr});const{data:i,error:a}=await Ne(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:r.access_token,xform:o=>({data:o,error:null})});return a?this._returnResult({data:null,error:a}):this._returnResult({data:i,error:null})})}catch(e){if(be(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){qn(this.experimental);try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new mr});const{data:a,error:o}=await Ne(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:n.access_token,body:{friendly_name:e.friendlyName}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:a,error:null})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _deletePasskey(e){qn(this.experimental);try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new mr});const{error:a}=await Ne(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:n.access_token,noResolveJson:!0});return a?this._returnResult({data:null,error:a}):this._returnResult({data:null,error:null})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}}Vc.nextInstanceID={};const uU=Vc,dU="2.107.0";let Tc="",th;if(typeof Deno<"u"){var Ug;Tc="deno",th=(Ug=Deno.version)===null||Ug===void 0?void 0:Ug.deno}else if(typeof document<"u")Tc="web";else if(typeof navigator<"u"&&navigator.product==="ReactNative")Tc="react-native";else{var qg;Tc="node",th=typeof process<"u"?(qg=process.version)===null||qg===void 0?void 0:qg.replace(/^v/,""):void 0}const hR=[`runtime=${Tc}`];th&&hR.push(`runtime-version=${th}`);const fU={"X-Client-Info":`supabase-js/${dU}; ${hR.join("; ")}`},hU={headers:fU},pU={schema:"public"},mU={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},gU={},yU={enabled:!1,respectSamplingDecision:!0};function vU(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(p){try{d(n.next(p))}catch(f){o(f)}}function u(p){try{d(n.throw(p))}catch(f){o(f)}}function d(p){p.done?a(p.value):i(p.value).then(c,u)}d((n=n.apply(t,[])).next())})}let Fg=null;const bU="@opentelemetry/api";function xU(){return Fg===null&&(Fg=import(bU).catch(()=>null)),Fg}function wU(){return vU(this,void 0,void 0,function*(){try{const t=yield xU();if(!t||!t.propagation||!t.context)return null;const e={};t.propagation.inject(t.context.active(),e);const r=e.traceparent;return r?{traceparent:r,tracestate:e.tracestate,baggage:e.baggage}:null}catch{return null}})}function _U(t){if(!t||typeof t!="string")return null;const e=t.split("-");if(e.length!==4)return null;const[r,n,i,a]=e;if(r.length!==2||n.length!==32||i.length!==16||a.length!==2)return null;const o=/^[0-9a-f]+$/i;return!o.test(r)||!o.test(n)||!o.test(i)||!o.test(a)||n==="00000000000000000000000000000000"||i==="0000000000000000"?null:{version:r,traceId:n,parentId:i,traceFlags:a,isSampled:(parseInt(a,16)&1)===1}}function SU(t,e){if(!t||!e||e.length===0)return!1;let r;if(t instanceof URL)r=t;else try{r=new URL(t)}catch{return!1}for(const n of e)try{if(typeof n=="string"){if(kU(r.hostname,n))return!0}else if(n instanceof RegExp){if(n.test(r.hostname))return!0}else if(typeof n=="function"&&n(r))return!0}catch{continue}return!1}function kU(t,e){if(e===t)return!0;if(e.startsWith("*.")){const r=e.slice(2);if(t.endsWith(r)&&(t===r||t.endsWith("."+r)))return!0}return!1}function EU(t){const e=[];try{const r=new URL(t);e.push(r.hostname)}catch{}return e.push("*.supabase.co","*.supabase.in"),e.push("localhost","127.0.0.1","[::1]"),e}function Xc(t){"@babel/helpers - typeof";return Xc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xc(t)}function AU(t,e){if(Xc(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(Xc(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function OU(t){var e=AU(t,"string");return Xc(e)=="symbol"?e:e+""}function TU(t,e,r){return(e=OU(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ME(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function Ht(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ME(Object(r),!0).forEach(function(n){TU(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ME(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const CU=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),jU=()=>Headers,NU=(t,e,r,n,i)=>{const a=CU(n),o=jU(),c=(i==null?void 0:i.enabled)===!0,u=(i==null?void 0:i.respectSamplingDecision)!==!1,d=c?EU(e):null;return async(p,f)=>{var m;const v=(m=await r())!==null&&m!==void 0?m:t;let b=new o(f==null?void 0:f.headers);if(b.has("apikey")||b.set("apikey",t),b.has("Authorization")||b.set("Authorization",`Bearer ${v}`),d){const w=await PU(p,d,u);w&&(w.traceparent&&!b.has("traceparent")&&b.set("traceparent",w.traceparent),w.tracestate&&!b.has("tracestate")&&b.set("tracestate",w.tracestate),w.baggage&&!b.has("baggage")&&b.set("baggage",w.baggage))}return a(p,Ht(Ht({},f),{},{headers:b}))}};async function PU(t,e,r){if(!SU(typeof t=="string"||t instanceof URL?t:t.url,e))return null;const n=await wU();if(!n||!n.traceparent)return null;if(r){const i=_U(n.traceparent);if(i&&!i.isSampled)return null}return n}function DE(t){return typeof t=="boolean"?{enabled:t}:t}function RU(t){return t.endsWith("/")?t:t+"/"}function IU(t,e){var r,n,i,a,o,c;const{db:u,auth:d,realtime:p,global:f}=t,{db:m,auth:v,realtime:b,global:w}=e,x=DE(t.tracePropagation),k=DE(e.tracePropagation),S={db:Ht(Ht({},m),u),auth:Ht(Ht({},v),d),realtime:Ht(Ht({},b),p),storage:{},global:Ht(Ht(Ht({},w),f),{},{headers:Ht(Ht({},(r=w==null?void 0:w.headers)!==null&&r!==void 0?r:{}),(n=f==null?void 0:f.headers)!==null&&n!==void 0?n:{})}),tracePropagation:{enabled:(i=(a=x==null?void 0:x.enabled)!==null&&a!==void 0?a:k==null?void 0:k.enabled)!==null&&i!==void 0?i:!1,respectSamplingDecision:(o=(c=x==null?void 0:x.respectSamplingDecision)!==null&&c!==void 0?c:k==null?void 0:k.respectSamplingDecision)!==null&&o!==void 0?o:!0},accessToken:async()=>""};return t.accessToken?S.accessToken=t.accessToken:delete S.accessToken,S}function $U(t){const e=t==null?void 0:t.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(RU(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var MU=class extends uU{constructor(t){super(t)}},DU=class{constructor(t,e,r){var n,i;this.supabaseUrl=t,this.supabaseKey=e;const a=$U(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",a),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",a),this.storageUrl=new URL("storage/v1",a),this.functionsUrl=new URL("functions/v1",a);const o=`sb-${a.hostname.split(".")[0]}-auth-token`,c={db:pU,realtime:gU,auth:Ht(Ht({},mU),{},{storageKey:o}),global:hU,tracePropagation:yU},u=IU(r??{},c);if(this.settings=u,this.storageKey=(n=u.auth.storageKey)!==null&&n!==void 0?n:"",this.headers=(i=u.global.headers)!==null&&i!==void 0?i:{},u.accessToken)this.accessToken=u.accessToken,this.auth=new Proxy({},{get:(p,f)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(f)} is not possible`)}});else{var d;this.auth=this._initSupabaseAuthClient((d=u.auth)!==null&&d!==void 0?d:{},this.headers,u.global.fetch)}this.fetch=NU(e,t,this._getAccessToken.bind(this),u.global.fetch,u.tracePropagation),this.realtime=this._initRealtimeClient(Ht({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},u.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(p=>this.realtime.setAuth(p)).catch(p=>console.warn("Failed to set initial Realtime auth token:",p)),this.rest=new ZB(new URL("rest/v1",a).href,{headers:this.headers,schema:u.db.schema,fetch:this.fetch,timeout:u.db.timeout,urlLengthLimit:u.db.urlLengthLimit}),this.storage=new d6(this.storageUrl.href,this.headers,this.fetch,r==null?void 0:r.storage),u.accessToken||this._listenForAuthEvents()}get functions(){return new FB(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,r)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,r;if(t.accessToken)return await t.accessToken();const{data:n}=await t.auth.getSession();return(e=(r=n.session)===null||r===void 0?void 0:r.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:n,userStorage:i,storageKey:a,flowType:o,lock:c,debug:u,throwOnError:d,experimental:p,lockAcquireTimeout:f,skipAutoInitialize:m},v,b){const w={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new MU({url:this.authUrl.href,headers:Ht(Ht({},w),v),storageKey:a,autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:n,userStorage:i,flowType:o,lock:c,debug:u,throwOnError:d,experimental:p,fetch:b,lockAcquireTimeout:f,skipAutoInitialize:m,hasCustomAuthorizationHeader:Object.keys(this.headers).some(x=>x.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new I8(this.realtimeUrl.href,Ht(Ht({},t),{},{params:Ht(Ht({},{apikey:this.supabaseKey}),t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e==null?void 0:e.access_token)})}_handleTokenChanged(t,e,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const LU=(t,e,r)=>new DU(t,e,r);function zU(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const r=e.match(/^v(\d+)\./);return r?parseInt(r[1],10)<=18:!1}zU()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const pR=j.createContext({session:null,supabase:null,loading:!0,signIn:async()=>({error:"Not initialized"}),signOut:async()=>{}});function mp(){return j.useContext(pR)}function BU({children:t}){const[e,r]=j.useState(null),[n,i]=j.useState(null),[a,o]=j.useState(!0),c=j.useRef(null);j.useEffect(()=>{W4(()=>{var f;return((f=c.current)==null?void 0:f.access_token)??null})},[]);const u=j.useRef(null);j.useEffect(()=>{K4(async()=>{const f=u.current;if(!f)return null;const{data:m,error:v}=await f.auth.refreshSession();return v||!m.session?null:(c.current=m.session,i(m.session),m.session.access_token)})},[]),j.useEffect(()=>{Ge.get("/config").then(({config:f})=>{if(f.supabase.projectUrl&&f.supabase.anonKey){const m=LU(f.supabase.projectUrl,f.supabase.anonKey);r(m),u.current=m,m.auth.getSession().then(({data:b})=>{c.current=b.session,i(b.session),o(!1)});const{data:{subscription:v}}=m.auth.onAuthStateChange((b,w)=>{c.current=w,i(w)});return()=>v.unsubscribe()}o(!1)}).catch(()=>{o(!1)})},[]);async function d(f,m){if(!e)return{error:"Supabase not configured"};const{error:v}=await e.auth.signInWithPassword({email:f,password:m});return{error:(v==null?void 0:v.message)??null}}async function p(){e&&(await e.auth.signOut(),c.current=null,i(null))}return y.jsx(pR.Provider,{value:{session:n,supabase:e,loading:a,signIn:d,signOut:p},children:t})}function mR(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(r=mR(t[e]))&&(n&&(n+=" "),n+=r)}else for(r in t)t[r]&&(n&&(n+=" "),n+=r);return n}function ot(){for(var t,e,r=0,n="",i=arguments.length;r<i;r++)(t=arguments[r])&&(e=mR(t))&&(n&&(n+=" "),n+=e);return n}const UU=(t,e)=>{const r=new Array(t.length+e.length);for(let n=0;n<t.length;n++)r[n]=t[n];for(let n=0;n<e.length;n++)r[t.length+n]=e[n];return r},qU=(t,e)=>({classGroupId:t,validator:e}),gR=(t=new Map,e=null,r)=>({nextPart:t,validators:e,classGroupId:r}),rh="-",LE=[],FU="arbitrary..",HU=t=>{const e=KU(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return WU(o);const c=o.split(rh),u=c[0]===""&&c.length>1?1:0;return yR(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=n[o],d=r[o];return u?d?UU(d,u):u:d||LE}return r[o]||LE}}},yR=(t,e,r)=>{if(t.length-e===0)return r.classGroupId;const i=t[e],a=r.nextPart.get(i);if(a){const d=yR(t,e+1,a);if(d)return d}const o=r.validators;if(o===null)return;const c=e===0?t.join(rh):t.slice(e).join(rh),u=o.length;for(let d=0;d<u;d++){const p=o[d];if(p.validator(c))return p.classGroupId}},WU=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),r=e.indexOf(":"),n=e.slice(0,r);return n?FU+n:void 0})(),KU=t=>{const{theme:e,classGroups:r}=t;return GU(r,e)},GU=(t,e)=>{const r=gR();for(const n in t){const i=t[n];l1(i,r,n,e)}return r},l1=(t,e,r,n)=>{const i=t.length;for(let a=0;a<i;a++){const o=t[a];VU(o,e,r,n)}},VU=(t,e,r,n)=>{if(typeof t=="string"){XU(t,e,r);return}if(typeof t=="function"){YU(t,e,r,n);return}JU(t,e,r,n)},XU=(t,e,r)=>{const n=t===""?e:vR(e,t);n.classGroupId=r},YU=(t,e,r,n)=>{if(ZU(t)){l1(t(n),e,r,n);return}e.validators===null&&(e.validators=[]),e.validators.push(qU(r,t))},JU=(t,e,r,n)=>{const i=Object.entries(t),a=i.length;for(let o=0;o<a;o++){const[c,u]=i[o];l1(u,vR(e,c),r,n)}},vR=(t,e)=>{let r=t;const n=e.split(rh),i=n.length;for(let a=0;a<i;a++){const o=n[a];let c=r.nextPart.get(o);c||(c=gR(),r.nextPart.set(o,c)),r=c}return r},ZU=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,QU=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=Object.create(null),n=Object.create(null);const i=(a,o)=>{r[a]=o,e++,e>t&&(e=0,n=r,r=Object.create(null))};return{get(a){let o=r[a];if(o!==void 0)return o;if((o=n[a])!==void 0)return i(a,o),o},set(a,o){a in r?r[a]=o:i(a,o)}}},hx="!",zE=":",eq=[],BE=(t,e,r,n,i)=>({modifiers:t,hasImportantModifier:e,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),tq=t=>{const{prefix:e,experimentalParseClassName:r}=t;let n=i=>{const a=[];let o=0,c=0,u=0,d;const p=i.length;for(let w=0;w<p;w++){const x=i[w];if(o===0&&c===0){if(x===zE){a.push(i.slice(u,w)),u=w+1;continue}if(x==="/"){d=w;continue}}x==="["?o++:x==="]"?o--:x==="("?c++:x===")"&&c--}const f=a.length===0?i:i.slice(u);let m=f,v=!1;f.endsWith(hx)?(m=f.slice(0,-1),v=!0):f.startsWith(hx)&&(m=f.slice(1),v=!0);const b=d&&d>u?d-u:void 0;return BE(a,v,m,b)};if(e){const i=e+zE,a=n;n=o=>o.startsWith(i)?a(o.slice(i.length)):BE(eq,!1,o,void 0,!0)}if(r){const i=n;n=a=>r({className:a,parseClassName:i})}return n},rq=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((r,n)=>{e.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let a=0;a<r.length;a++){const o=r[a],c=o[0]==="[",u=e.has(o);c||u?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(o)):i.push(o)}return i.length>0&&(i.sort(),n.push(...i)),n}},nq=t=>({cache:QU(t.cacheSize),parseClassName:tq(t),sortModifiers:rq(t),postfixLookupClassGroupIds:iq(t),...HU(t)}),iq=t=>{const e=Object.create(null),r=t.postfixLookupClassGroups;if(r)for(let n=0;n<r.length;n++)e[r[n]]=!0;return e},aq=/\s+/,oq=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=e,c=[],u=t.trim().split(aq);let d="";for(let p=u.length-1;p>=0;p-=1){const f=u[p],{isExternal:m,modifiers:v,hasImportantModifier:b,baseClassName:w,maybePostfixModifierPosition:x}=r(f);if(m){d=f+(d.length>0?" "+d:d);continue}let k=!!x,S;if(k){const N=w.substring(0,x);S=n(N);const R=S&&o[S]?n(w):void 0;R&&R!==S&&(S=R,k=!1)}else S=n(w);if(!S){if(!k){d=f+(d.length>0?" "+d:d);continue}if(S=n(w),!S){d=f+(d.length>0?" "+d:d);continue}k=!1}const A=v.length===0?"":v.length===1?v[0]:a(v).join(":"),C=b?A+hx:A,T=C+S;if(c.indexOf(T)>-1)continue;c.push(T);const O=i(S,k);for(let N=0;N<O.length;++N){const R=O[N];c.push(C+R)}d=f+(d.length>0?" "+d:d)}return d},sq=(...t)=>{let e=0,r,n,i="";for(;e<t.length;)(r=t[e++])&&(n=bR(r))&&(i&&(i+=" "),i+=n);return i},bR=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=bR(t[n]))&&(r&&(r+=" "),r+=e);return r},lq=(t,...e)=>{let r,n,i,a;const o=u=>{const d=e.reduce((p,f)=>f(p),t());return r=nq(d),n=r.cache.get,i=r.cache.set,a=c,c(u)},c=u=>{const d=n(u);if(d)return d;const p=oq(u,r);return i(u,p),p};return a=o,(...u)=>a(sq(...u))},cq=[],ir=t=>{const e=r=>r[t]||cq;return e.isThemeGetter=!0,e},xR=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,wR=/^\((?:(\w[\w-]*):)?(.+)\)$/i,uq=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,dq=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,fq=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,hq=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,pq=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mq=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ta=t=>uq.test(t),Ye=t=>!!t&&!Number.isNaN(Number(t)),gi=t=>!!t&&Number.isInteger(Number(t)),Hg=t=>t.endsWith("%")&&Ye(t.slice(0,-1)),zi=t=>dq.test(t),_R=()=>!0,gq=t=>fq.test(t)&&!hq.test(t),c1=()=>!1,yq=t=>pq.test(t),vq=t=>mq.test(t),bq=t=>!ke(t)&&!Oe(t),xq=t=>t.startsWith("@container")&&(t[10]==="/"&&t[11]!==void 0||t[11]==="s"&&t[16]!==void 0&&t.startsWith("-size/",10)||t[11]==="n"&&t[18]!==void 0&&t.startsWith("-normal/",10)),wq=t=>Ha(t,ER,c1),ke=t=>xR.test(t),vo=t=>Ha(t,AR,gq),UE=t=>Ha(t,Cq,Ye),_q=t=>Ha(t,TR,_R),Sq=t=>Ha(t,OR,c1),qE=t=>Ha(t,SR,c1),kq=t=>Ha(t,kR,vq),pf=t=>Ha(t,CR,yq),Oe=t=>wR.test(t),pc=t=>zo(t,AR),Eq=t=>zo(t,OR),FE=t=>zo(t,SR),Aq=t=>zo(t,ER),Oq=t=>zo(t,kR),mf=t=>zo(t,CR,!0),Tq=t=>zo(t,TR,!0),Ha=(t,e,r)=>{const n=xR.exec(t);return n?n[1]?e(n[1]):r(n[2]):!1},zo=(t,e,r=!1)=>{const n=wR.exec(t);return n?n[1]?e(n[1]):r:!1},SR=t=>t==="position"||t==="percentage",kR=t=>t==="image"||t==="url",ER=t=>t==="length"||t==="size"||t==="bg-size",AR=t=>t==="length",Cq=t=>t==="number",OR=t=>t==="family-name",TR=t=>t==="number"||t==="weight",CR=t=>t==="shadow",jq=()=>{const t=ir("color"),e=ir("font"),r=ir("text"),n=ir("font-weight"),i=ir("tracking"),a=ir("leading"),o=ir("breakpoint"),c=ir("container"),u=ir("spacing"),d=ir("radius"),p=ir("shadow"),f=ir("inset-shadow"),m=ir("text-shadow"),v=ir("drop-shadow"),b=ir("blur"),w=ir("perspective"),x=ir("aspect"),k=ir("ease"),S=ir("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],T=()=>[...C(),Oe,ke],O=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],R=()=>[Oe,ke,u],$=()=>[Ta,"full","auto",...R()],K=()=>[gi,"none","subgrid",Oe,ke],L=()=>["auto",{span:["full",gi,Oe,ke]},gi,Oe,ke],U=()=>[gi,"auto",Oe,ke],F=()=>["auto","min","max","fr",Oe,ke],X=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Y=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",...R()],Q=()=>[Ta,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],W=()=>[Ta,"screen","full","dvw","lvw","svw","min","max","fit",...R()],ee=()=>[Ta,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],q=()=>[t,Oe,ke],I=()=>[...C(),FE,qE,{position:[Oe,ke]}],B=()=>["no-repeat",{repeat:["","x","y","space","round"]}],J=()=>["auto","cover","contain",Aq,wq,{size:[Oe,ke]}],oe=()=>[Hg,pc,vo],ue=()=>["","none","full",d,Oe,ke],ve=()=>["",Ye,pc,vo],qe=()=>["solid","dashed","dotted","double"],xe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ae=()=>[Ye,Hg,FE,qE],Se=()=>["","none",b,Oe,ke],Me=()=>["none",Ye,Oe,ke],se=()=>["none",Ye,Oe,ke],rt=()=>[Ye,Oe,ke],Fe=()=>[Ta,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[zi],breakpoint:[zi],color:[_R],container:[zi],"drop-shadow":[zi],ease:["in","out","in-out"],font:[bq],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[zi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[zi],shadow:[zi],spacing:["px",Ye],text:[zi],"text-shadow":[zi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ta,ke,Oe,x]}],container:["container"],"container-type":[{"@container":["","normal","size",Oe,ke]}],"container-named":[xq],columns:[{columns:[Ye,ke,Oe,c]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:T()}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:$()}],"inset-x":[{"inset-x":$()}],"inset-y":[{"inset-y":$()}],start:[{"inset-s":$(),start:$()}],end:[{"inset-e":$(),end:$()}],"inset-bs":[{"inset-bs":$()}],"inset-be":[{"inset-be":$()}],top:[{top:$()}],right:[{right:$()}],bottom:[{bottom:$()}],left:[{left:$()}],visibility:["visible","invisible","collapse"],z:[{z:[gi,"auto",Oe,ke]}],basis:[{basis:[Ta,"full","auto",c,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ye,Ta,"auto","initial","none",ke]}],grow:[{grow:["",Ye,Oe,ke]}],shrink:[{shrink:["",Ye,Oe,ke]}],order:[{order:[gi,"first","last","none",Oe,ke]}],"grid-cols":[{"grid-cols":K()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":K()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":F()}],"auto-rows":[{"auto-rows":F()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...X(),"normal"]}],"justify-items":[{"justify-items":[...Y(),"normal"]}],"justify-self":[{"justify-self":["auto",...Y()]}],"align-content":[{content:["normal",...X()]}],"align-items":[{items:[...Y(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Y(),{baseline:["","last"]}]}],"place-content":[{"place-content":X()}],"place-items":[{"place-items":[...Y(),"baseline"]}],"place-self":[{"place-self":["auto",...Y()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mbs:[{mbs:G()}],mbe:[{mbe:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...W()]}],"min-inline-size":[{"min-inline":["auto",...W()]}],"max-inline-size":[{"max-inline":["none",...W()]}],"block-size":[{block:["auto",...ee()]}],"min-block-size":[{"min-block":["auto",...ee()]}],"max-block-size":[{"max-block":["none",...ee()]}],w:[{w:[c,"screen",...Q()]}],"min-w":[{"min-w":[c,"screen","none",...Q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",r,pc,vo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Tq,_q]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Hg,ke]}],"font-family":[{font:[Eq,Sq,e]}],"font-features":[{"font-features":[ke]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Oe,ke]}],"line-clamp":[{"line-clamp":[Ye,"none",Oe,UE]}],leading:[{leading:[a,...R()]}],"list-image":[{"list-image":["none",Oe,ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Oe,ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...qe(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ye,"from-font","auto",Oe,vo]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Ye,"auto",Oe,ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[gi,Oe,ke]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Oe,ke]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Oe,ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:I()}],"bg-repeat":[{bg:B()}],"bg-size":[{bg:J()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},gi,Oe,ke],radial:["",Oe,ke],conic:[gi,Oe,ke]},Oq,kq]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:oe()}],"gradient-via-pos":[{via:oe()}],"gradient-to-pos":[{to:oe()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:ue()}],"rounded-s":[{"rounded-s":ue()}],"rounded-e":[{"rounded-e":ue()}],"rounded-t":[{"rounded-t":ue()}],"rounded-r":[{"rounded-r":ue()}],"rounded-b":[{"rounded-b":ue()}],"rounded-l":[{"rounded-l":ue()}],"rounded-ss":[{"rounded-ss":ue()}],"rounded-se":[{"rounded-se":ue()}],"rounded-ee":[{"rounded-ee":ue()}],"rounded-es":[{"rounded-es":ue()}],"rounded-tl":[{"rounded-tl":ue()}],"rounded-tr":[{"rounded-tr":ue()}],"rounded-br":[{"rounded-br":ue()}],"rounded-bl":[{"rounded-bl":ue()}],"border-w":[{border:ve()}],"border-w-x":[{"border-x":ve()}],"border-w-y":[{"border-y":ve()}],"border-w-s":[{"border-s":ve()}],"border-w-e":[{"border-e":ve()}],"border-w-bs":[{"border-bs":ve()}],"border-w-be":[{"border-be":ve()}],"border-w-t":[{"border-t":ve()}],"border-w-r":[{"border-r":ve()}],"border-w-b":[{"border-b":ve()}],"border-w-l":[{"border-l":ve()}],"divide-x":[{"divide-x":ve()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ve()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...qe(),"hidden","none"]}],"divide-style":[{divide:[...qe(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...qe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ye,Oe,ke]}],"outline-w":[{outline:["",Ye,pc,vo]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",p,mf,pf]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",f,mf,pf]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:ve()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Ye,vo]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":ve()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",m,mf,pf]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Ye,Oe,ke]}],"mix-blend":[{"mix-blend":[...xe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":xe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ye]}],"mask-image-linear-from-pos":[{"mask-linear-from":ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":ae()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":ae()}],"mask-image-t-to-pos":[{"mask-t-to":ae()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":ae()}],"mask-image-r-to-pos":[{"mask-r-to":ae()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":ae()}],"mask-image-b-to-pos":[{"mask-b-to":ae()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":ae()}],"mask-image-l-to-pos":[{"mask-l-to":ae()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":ae()}],"mask-image-x-to-pos":[{"mask-x-to":ae()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":ae()}],"mask-image-y-to-pos":[{"mask-y-to":ae()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[Oe,ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":ae()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":C()}],"mask-image-conic-pos":[{"mask-conic":[Ye]}],"mask-image-conic-from-pos":[{"mask-conic-from":ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":ae()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:I()}],"mask-repeat":[{mask:B()}],"mask-size":[{mask:J()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Oe,ke]}],filter:[{filter:["","none",Oe,ke]}],blur:[{blur:Se()}],brightness:[{brightness:[Ye,Oe,ke]}],contrast:[{contrast:[Ye,Oe,ke]}],"drop-shadow":[{"drop-shadow":["","none",v,mf,pf]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Ye,Oe,ke]}],"hue-rotate":[{"hue-rotate":[Ye,Oe,ke]}],invert:[{invert:["",Ye,Oe,ke]}],saturate:[{saturate:[Ye,Oe,ke]}],sepia:[{sepia:["",Ye,Oe,ke]}],"backdrop-filter":[{"backdrop-filter":["","none",Oe,ke]}],"backdrop-blur":[{"backdrop-blur":Se()}],"backdrop-brightness":[{"backdrop-brightness":[Ye,Oe,ke]}],"backdrop-contrast":[{"backdrop-contrast":[Ye,Oe,ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ye,Oe,ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ye,Oe,ke]}],"backdrop-invert":[{"backdrop-invert":["",Ye,Oe,ke]}],"backdrop-opacity":[{"backdrop-opacity":[Ye,Oe,ke]}],"backdrop-saturate":[{"backdrop-saturate":[Ye,Oe,ke]}],"backdrop-sepia":[{"backdrop-sepia":["",Ye,Oe,ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Oe,ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ye,"initial",Oe,ke]}],ease:[{ease:["linear","initial",k,Oe,ke]}],delay:[{delay:[Ye,Oe,ke]}],animate:[{animate:["none",S,Oe,ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,Oe,ke]}],"perspective-origin":[{"perspective-origin":T()}],rotate:[{rotate:Me()}],"rotate-x":[{"rotate-x":Me()}],"rotate-y":[{"rotate-y":Me()}],"rotate-z":[{"rotate-z":Me()}],scale:[{scale:se()}],"scale-x":[{"scale-x":se()}],"scale-y":[{"scale-y":se()}],"scale-z":[{"scale-z":se()}],"scale-3d":["scale-3d"],skew:[{skew:rt()}],"skew-x":[{"skew-x":rt()}],"skew-y":[{"skew-y":rt()}],transform:[{transform:[Oe,ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:T()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Fe()}],"translate-x":[{"translate-x":Fe()}],"translate-y":[{"translate-y":Fe()}],"translate-z":[{"translate-z":Fe()}],"translate-none":["translate-none"],zoom:[{zoom:[gi,Oe,ke]}],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Oe,ke]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":q()}],"scrollbar-track-color":[{"scrollbar-track":q()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Oe,ke]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Ye,pc,vo,UE]}],stroke:[{stroke:["none",...q()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Nq=lq(jq);function Cc(...t){return Nq(ot(t))}const Pq=[{to:"/squads",icon:a1,label:"Squads"},{to:"/skills",icon:tx,label:"Skills"},{to:"/schedules",icon:yz,label:"Schedules"},{to:"/wiki",icon:PP,label:"Wiki"},{to:"/usage",icon:bz,label:"Usage"}],Rq=[{to:"/",icon:n1,label:"Chat"},{to:"/feed",icon:ex,label:"Inbox"},{to:"/settings",icon:pB,label:"Settings"}];function HE({to:t,icon:e,label:r,collapsed:n,badge:i}){return y.jsxs(tP,{to:t,end:t==="/",title:n?r:void 0,className:({isActive:a})=>Cc("w-full flex items-center gap-2.5 px-2 py-2 rounded-xl text-[11px] font-mono transition-colors cursor-pointer relative",n?"justify-center":"",a?"text-[#E43A9C]":"text-zinc-600 hover:text-zinc-300 hover:bg-white/[0.04]"),style:({isActive:a})=>a?{background:"rgba(228,58,156,0.1)"}:void 0,children:[y.jsx(e,{className:"w-3.5 h-3.5 flex-shrink-0"}),!n&&r,i!=null&&i>0&&y.jsx("span",{className:"absolute top-1 right-1 min-w-[14px] h-[14px] flex items-center justify-center rounded-full bg-[#E43A9C] text-[9px] text-white font-mono px-1",children:i>99?"99+":i})]})}function Iq(){const[t,e]=j.useState(!1),[r]=j.useState(CB),[n,i]=j.useState(0),{supabase:a}=mp();return j.useEffect(()=>{let o=!0;const c=()=>{Ge.get("/inbox?limit=200").then(d=>{if(!o)return;const p=d.entries??[];i(p.filter(f=>f.status==="pending").length)}).catch(()=>{})};c();const u=setInterval(c,3e4);return()=>{o=!1,clearInterval(u)}},[]),y.jsxs("div",{className:"flex h-screen overflow-hidden bg-background relative",children:[y.jsxs("div",{className:Cc("flex-shrink-0 flex flex-col border-r border-white/[0.06] bg-[#181818] transition-all duration-200",t?"w-[52px]":"w-[210px]"),children:[y.jsx("div",{className:Cc("h-[52px] flex items-center border-b border-white/[0.06] flex-shrink-0",t?"justify-center px-3":"justify-between pl-4 pr-3"),children:t?y.jsx(Ia,{height:26}):y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx(Ia,{height:26}),y.jsx("span",{className:"text-2xl text-white tracking-wider leading-none",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"IO"})]})}),y.jsx("nav",{className:"flex-1 py-2 px-1.5 space-y-0.5 overflow-y-auto",children:Pq.map(o=>y.jsx(HE,{collapsed:t,...o},o.to))}),y.jsxs("div",{className:"flex-shrink-0 border-t border-white/[0.06]",children:[y.jsx("div",{className:"py-1.5 px-1.5 space-y-0.5",children:Rq.map(o=>y.jsx(HE,{collapsed:t,badge:o.to==="/feed"?n:void 0,...o},o.to))}),y.jsxs("div",{className:"border-t border-white/[0.05] py-1.5 px-1.5 space-y-0.5",children:[y.jsxs("a",{href:`https://github.com/michaeljolley/io/releases/tag/v${r}`,target:"_blank",rel:"noreferrer",title:"GitHub",className:Cc("flex items-center gap-2.5 px-2 py-2 rounded-xl text-[11px] font-mono text-zinc-600 hover:text-zinc-300 hover:bg-white/[0.04] transition-colors cursor-pointer",t&&"justify-center"),children:[y.jsx(r1,{className:"w-3.5 h-3.5 flex-shrink-0"}),!t&&y.jsxs("span",{className:"text-zinc-700",children:["v",r]})]}),y.jsx("button",{type:"button",onClick:()=>e(!t),title:t?"Expand sidebar":"Collapse sidebar",className:Cc("w-full flex items-center gap-2.5 px-2 py-2 rounded-xl text-[11px] font-mono text-zinc-600 hover:text-zinc-300 hover:bg-white/[0.04] transition-colors cursor-pointer",t&&"justify-center"),children:t?y.jsx(Qw,{className:"w-3.5 h-3.5 flex-shrink-0"}):y.jsx(vl,{className:"w-3.5 h-3.5 flex-shrink-0"})})]})]})]}),y.jsxs("div",{className:"flex flex-col flex-1 min-w-0 overflow-hidden",children:[y.jsxs("div",{className:"h-[52px] flex-shrink-0 flex items-center justify-between px-4 border-b border-white/[0.06] bg-[#181818]",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(DB,{status:"connected"}),y.jsx("span",{className:"text-[11px] font-mono text-green-400",children:"connected"})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(TB,{}),a&&y.jsx("button",{type:"button",onClick:()=>a.auth.signOut(),className:"p-2 rounded-xl hover:bg-white/[0.05] text-zinc-600 hover:text-zinc-300 transition-colors cursor-pointer",title:"Sign out",children:y.jsx(Xz,{className:"w-3.5 h-3.5"})})]})]}),y.jsxs("main",{className:"flex-1 overflow-hidden flex flex-col min-h-0 relative",children:[y.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",style:{zIndex:0},children:[y.jsx("div",{className:"orb orb-pink"}),y.jsx("div",{className:"orb orb-gray"})]}),y.jsx(TL,{})]})]})]})}function $q(){const{session:t}=mp(),e=Fa(),{messages:r,streaming:n,isStreaming:i,isThinking:a,sendChatMessage:o,stopStreaming:c,addUserMessage:u,uploadAttachment:d}=WP(),[p,f]=j.useState(""),[m,v]=j.useState(null),[b,w]=j.useState(null),x=j.useRef(null),k=j.useRef(null),S=j.useRef(null);j.useLayoutEffect(()=>{const O=x.current;O&&(O.scrollTop=O.scrollHeight)});async function A(){const O=p.trim();if(!O&&!m||i||a)return;const N=crypto.randomUUID(),R=m==null?void 0:m.name,$=[O,R?`Attachment: ${R}`:""].filter(Boolean).join(`
|
|
446
|
+
`);const O=await C.signMessage(new TextEncoder().encode(b),"utf8");if(!O||!(O instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=O}}try{const{data:x,error:k}=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:b,signature:ko(w)},!((m=e.options)===null||m===void 0)&&m.captchaToken?{gotrue_meta_security:{captcha_token:(v=e.options)===null||v===void 0?void 0:v.captchaToken}}:null),xform:An});if(k)throw k;if(!x||!x.session||!x.user){const S=new ws;return this._returnResult({data:{user:null,session:null},error:S})}return x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("SIGNED_IN",x.session)),this._returnResult({data:Object.assign({},x),error:k})}catch(x){if(be(x))return this._returnResult({data:{user:null,session:null},error:x});throw x}}async _exchangeCodeForSession(e){const r=await Di(this.storage,`${this.storageKey}-code-verifier`),[n,i]=(r??"").split("/");try{if(!n&&this.flowType==="pkce")throw new x6;const{data:a,error:o}=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:An});if(await nr(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!a||!a.session||!a.user){const c=new ws;return this._returnResult({data:{user:null,session:null,redirectType:null},error:c})}return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers(i==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",a.session)),this._returnResult({data:Object.assign(Object.assign({},a),{redirectType:i??null}),error:o})}catch(a){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(a))return this._returnResult({data:{user:null,session:null,redirectType:null},error:a});throw a}}async signInWithIdToken(e){try{const{options:r,provider:n,token:i,access_token:a,nonce:o}=e,c=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:i,access_token:a,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:An}),{data:u,error:d}=c;if(d)return this._returnResult({data:{user:null,session:null},error:d});if(!u||!u.session||!u.user){const p=new ws;return this._returnResult({data:{user:null,session:null},error:p})}return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),this._returnResult({data:u,error:d})}catch(r){if(be(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,n,i,a,o;try{if("email"in e){const{email:c,options:u}=e;let d=null,p=null;this.flowType==="pkce"&&([d,p]=await _s(this.storage,this.storageKey));const{error:f}=await Ne(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:c,data:(r=u==null?void 0:u.data)!==null&&r!==void 0?r:{},create_user:(n=u==null?void 0:u.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:u==null?void 0:u.captchaToken},code_challenge:d,code_challenge_method:p},redirectTo:u==null?void 0:u.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:f})}if("phone"in e){const{phone:c,options:u}=e,{data:d,error:p}=await Ne(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:c,data:(i=u==null?void 0:u.data)!==null&&i!==void 0?i:{},create_user:(a=u==null?void 0:u.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:u==null?void 0:u.captchaToken},channel:(o=u==null?void 0:u.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:d==null?void 0:d.message_id},error:p})}throw new df("You must provide either an email or phone number.")}catch(c){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(c))return this._returnResult({data:{user:null,session:null},error:c});throw c}}async verifyOtp(e){var r,n;try{let i,a;"options"in e&&(i=(r=e.options)===null||r===void 0?void 0:r.redirectTo,a=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:o,error:c}=await Ne(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:i,xform:An});if(c)throw c;if(!o)throw new Error("An error occurred on token verification.");const u=o.session,d=o.user;return u!=null&&u.access_token&&(await this._saveSession(u),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",u)),this._returnResult({data:{user:d,session:u},error:null})}catch(i){if(be(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithSSO(e){var r,n,i,a,o;try{let c=null,u=null;this.flowType==="pkce"&&([c,u]=await _s(this.storage,this.storageKey));const d=await Ne(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((i=e==null?void 0:e.options)===null||i===void 0)&&i.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:c,code_challenge_method:u}),headers:this.headers,xform:K6});return!((a=d.data)===null||a===void 0)&&a.url&&Tr()&&!(!((o=e.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(d.data.url),this._returnResult(d)}catch(c){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(c))return this._returnResult({data:null,error:c});throw c}}async reauthenticate(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate()):await this._reauthenticate()}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new mr;const{error:i}=await Ne(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:i})})}catch(e){if(be(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:n,type:i,options:a}=e,{error:o}=await Ne(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:i,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},redirectTo:a==null?void 0:a.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in e){const{phone:n,type:i,options:a}=e,{data:o,error:c}=await Ne(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:i,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:c})}throw new df("You must provide either an email or phone number and a type")}catch(r){if(be(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async getSession(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async e=>e)):await this._useSession(async e=>e)}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),i=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await i}catch{}})()),i}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const i=[...this.pendingInLock];await Promise.all(i),this.pendingInLock.splice(0,i.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lock!=null&&!this.lockAcquired&&this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await Di(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=e.expires_at?e.expires_at*1e3-Date.now()<Dg:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.userStorage){const o=await Di(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=zg()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};e.user=q6(e.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:i,error:a}=await this._callRefreshToken(e.refresh_token);return a?this._returnResult({data:{session:null},error:a}):this._returnResult({data:{session:i},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;let r;return this.lock!=null?r=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser()):r=await this._getUser(),r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await Ne(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Pa}):await this._useSession(async r=>{var n,i,a;const{data:o,error:c}=r;if(c)throw c;return!(!((n=o.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new mr}:await Ne(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(a=(i=o.session)===null||i===void 0?void 0:i.access_token)!==null&&a!==void 0?a:void 0,xform:Pa})})}catch(r){if(be(r))return uf(r)&&(await this._removeSession(),await nr(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:r});throw r}}async updateUser(e,r={}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,r)):await this._updateUser(e,r)}async _updateUser(e,r={}){try{return await this._useSession(async n=>{const{data:i,error:a}=n;if(a)throw a;if(!i.session)throw new mr;const o=i.session;let c=null,u=null;this.flowType==="pkce"&&e.email!=null&&([c,u]=await _s(this.storage,this.storageKey));const{data:d,error:p}=await Ne(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:c,code_challenge_method:u}),jwt:o.access_token,xform:Pa});if(p)throw p;return o.user=d.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(n){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(n))return this._returnResult({data:{user:null},error:n});throw n}}async setSession(e){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e)):await this._setSession(e)}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new mr;const r=Date.now()/1e3;let n=r,i=!0,a=null;const{payload:o}=hf(e.access_token);if(o.exp&&(n=o.exp,i=n<=r),i){const{data:c,error:u}=await this._callRefreshToken(e.refresh_token);if(u)return this._returnResult({data:{user:null,session:null},error:u});if(!c)return{data:{user:null,session:null},error:null};a=c}else{const{data:c,error:u}=await this._getUser(e.access_token);if(u)return this._returnResult({data:{user:null,session:null},error:u});a={access_token:e.access_token,refresh_token:e.refresh_token,user:c.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return this._returnResult({data:{user:a.user,session:a},error:null})}catch(r){if(be(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}}async refreshSession(e){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e)):await this._refreshSession(e)}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){const{data:o,error:c}=r;if(c)throw c;e=(n=o.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new mr;const{data:i,error:a}=await this._callRefreshToken(e.refresh_token);return a?this._returnResult({data:{user:null,session:null},error:a}):i?this._returnResult({data:{user:i.user,session:i},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(be(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){var n;try{if(!Tr())throw new ff("No browser detected.");if(e.error||e.error_description||e.error_code)throw new ff(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new wE("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new ff("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new wE("No code detected.");const{data:A,error:C}=await this._exchangeCodeForSession(e.code);if(C)throw C;const T=new URL(window.location.href);return T.searchParams.delete("code"),window.history.replaceState(window.history.state,"",T.toString()),{data:{session:A.session,redirectType:(n=A.redirectType)!==null&&n!==void 0?n:null},error:null}}const{provider_token:i,provider_refresh_token:a,access_token:o,refresh_token:c,expires_in:u,expires_at:d,token_type:p}=e;if(!o||!u||!c||!p)throw new ff("No session defined in URL");const f=Math.round(Date.now()/1e3),m=parseInt(u);let v=f+m;d&&(v=parseInt(d));const b=v-f;b*1e3<=Ca&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${b}s, should have been closer to ${m}s`);const w=v-m;f-w>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",w,v,f):f-w<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",w,v,f);const{data:x,error:k}=await this._getUser(o);if(k)throw k;const S={provider_token:i,provider_refresh_token:a,access_token:o,expires_in:m,expires_at:v,refresh_token:c,token_type:p,user:x.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:S,redirectType:e.type},error:null})}catch(i){if(be(i))return this._returnResult({data:{session:null,redirectType:null},error:i});throw i}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error||e.error_description||e.error_code)}async _isPKCECallback(e){const r=await Di(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e)):await this._signOut(e)}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:i,error:a}=r;if(a&&!uf(a))return this._returnResult({error:a});const o=(n=i.session)===null||n===void 0?void 0:n.access_token;if(o){const{error:c}=await this.admin.signOut(o,e);if(c&&!(v6(c)&&(c.status===404||c.status===401||c.status===403)||uf(c)))return this._returnResult({error:c})}return e!=="others"&&(await this._removeSession(),await nr(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const r=T6(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(r)}):await this._emitInitialSession(r)))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,i;try{const{data:{session:a},error:o}=r;if(o)throw o;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",a),uf(a)?console.warn(a):console.error(a)}})}async resetPasswordForEmail(e,r={}){let n=null,i=null;this.flowType==="pkce"&&([n,i]=await _s(this.storage,this.storageKey,!0));try{return await Ne(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:i,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(a){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(a))return this._returnResult({data:null,error:a});throw a}}async getUserIdentities(){var e;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var r;try{const{data:n,error:i}=await this._useSession(async a=>{var o,c,u,d,p;const{data:f,error:m}=a;if(m)throw m;const v=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(c=e.options)===null||c===void 0?void 0:c.scopes,queryParams:(u=e.options)===null||u===void 0?void 0:u.queryParams,skipBrowserRedirect:!0});return await Ne(this.fetch,"GET",v,{headers:this.headers,jwt:(p=(d=f.session)===null||d===void 0?void 0:d.access_token)!==null&&p!==void 0?p:void 0})});if(i)throw i;return Tr()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),this._returnResult({data:{provider:e.provider,url:n==null?void 0:n.url},error:null})}catch(n){if(be(n))return this._returnResult({data:{provider:e.provider,url:null},error:n});throw n}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var n;try{const{error:i,data:{session:a}}=r;if(i)throw i;const{options:o,provider:c,token:u,access_token:d,nonce:p}=e,f=await Ne(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=a==null?void 0:a.access_token)!==null&&n!==void 0?n:void 0,body:{provider:c,id_token:u,access_token:d,nonce:p,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:An}),{data:m,error:v}=f;return v?this._returnResult({data:{user:null,session:null},error:v}):!m||!m.session||!m.user?this._returnResult({data:{user:null,session:null},error:new ws}):(m.session&&(await this._saveSession(m.session),await this._notifyAllSubscribers("USER_UPDATED",m.session)),this._returnResult({data:m,error:v}))}catch(i){if(await nr(this.storage,`${this.storageKey}-code-verifier`),be(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,i;const{data:a,error:o}=r;if(o)throw o;return await Ne(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(i=(n=a.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _refreshAccessToken(e){const r="#_refreshAccessToken()";this._debug(r,"begin");try{const n=Date.now();return await P6(async i=>(i>0&&await N6(200*Math.pow(2,i-1)),this._debug(r,"refreshing attempt",i),await Ne(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:An})),(i,a)=>{const o=200*Math.pow(2,i);return a&&Lg(a)&&Date.now()+o-n<Ca})}catch(n){if(this._debug(r,"error",n),be(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const n=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",n),Tr()&&!r.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e,r;const n="#_recoverAndRefresh()";this._debug(n,"begin");try{const i=await Di(this.storage,this.storageKey);if(i&&this.userStorage){let o=await Di(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:i.user},await Ns(this.userStorage,this.storageKey+"-user",o)),i.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:zg()}else if(i&&!i.user&&!i.user){const o=await Di(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(i.user=o.user,await nr(this.storage,this.storageKey+"-user"),await Ns(this.storage,this.storageKey,i)):i.user=zg()}if(this._debug(n,"session from storage",i),!this._isValidSession(i)){this._debug(n,"session is not valid"),i!==null&&await this._removeSession();return}const a=((r=i.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<Dg;if(this._debug(n,`session has${a?"":" not"} expired with margin of ${Dg}s`),a){if(this.autoRefreshToken&&i.refresh_token){const{error:o}=await this._callRefreshToken(i.refresh_token);o&&(w6(o)?this._debug(n,"refresh discarded by commit guard",o):(console.error(o),Lg(o)||(this._debug(n,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession())))}}else if(i.user&&i.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:c}=await this._getUser(i.access_token);!c&&(o!=null&&o.user)?(i.user=o.user,await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)):this._debug(n,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(n,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",i)}catch(i){this._debug(n,"error",i),console.error(i);return}finally{this._debug(n,"end")}}async _callRefreshToken(e){var r,n;if(!e)throw new mr;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const i="#_callRefreshToken()";this._debug(i,"begin");try{this.refreshingDeferred=new pp;const a=await Di(this.storage,this.storageKey),{data:o,error:c}=await this._refreshAccessToken(e);if(c)throw c;if(!o.session)throw new mr;const u=await Di(this.storage,this.storageKey);if(a!==null&&(u===null||u.refresh_token!==a.refresh_token)){this._debug(i,"commit guard: storage changed since refresh started, discarding rotated tokens",{startedWith:"present",nowHolds:u?"replaced":"cleared"});const m={data:null,error:new _E};return this.refreshingDeferred.resolve(m),m}const p=this._sessionRemovalEpoch;if(await this._saveSession(o.session),this._sessionRemovalEpoch!==p){this._debug(i,"commit guard (post-save): _removeSession ran during _saveSession, undoing write"),await nr(this.storage,this.storageKey),this.userStorage&&await nr(this.userStorage,this.storageKey+"-user");const m={data:null,error:new _E};return this.refreshingDeferred.resolve(m),m}await this._notifyAllSubscribers("TOKEN_REFRESHED",o.session);const f={data:o.session,error:null};return this.refreshingDeferred.resolve(f),f}catch(a){if(this._debug(i,"error",a),be(a)){const o={data:null,error:a};return Lg(a)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(o),o}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(a),a}finally{this.refreshingDeferred=null,this._debug(i,"end")}}async _notifyAllSubscribers(e,r,n=!0){const i=`#_notifyAllSubscribers(${e})`;this._debug(i,"begin",r,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:r});const a=[],o=Array.from(this.stateChangeEmitters.values()).map(async c=>{try{await c.callback(e,r)}catch(u){a.push(u)}});if(await Promise.all(o),a.length>0){for(let c=0;c<a.length;c+=1)console.error(a[c]);throw a[0]}}finally{this._debug(i,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await nr(this.storage,`${this.storageKey}-code-verifier`);const r=Object.assign({},e),n=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!n&&r.user&&await Ns(this.userStorage,this.storageKey+"-user",{user:r.user});const i=Object.assign({},r);delete i.user;const a=OE(i);await Ns(this.storage,this.storageKey,a)}else{const i=OE(r);await Ns(this.storage,this.storageKey,i)}}async _removeSession(){this._sessionRemovalEpoch+=1,this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await nr(this.storage,this.storageKey),await nr(this.storage,this.storageKey+"-code-verifier"),await nr(this.storage,this.storageKey+"-user"),this.userStorage&&await nr(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Tr()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Ca);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const r=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=r,r&&typeof r=="object"&&typeof r.unref=="function"?r.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(r)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const r=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,r&&clearTimeout(r)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async dispose(){var e;this._removeVisibilityChangedCallback(),await this._stopAutoRefresh(),(e=this.broadcastChannel)===null||e===void 0||e.close(),this.broadcastChannel=null,this.stateChangeEmitters.clear()}async _autoRefreshTokenTick(){if(this._debug("#_autoRefreshTokenTick()","begin"),this.lock!=null){try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const i=Math.floor((n.expires_at*1e3-e)/Ca);this._debug("#_autoRefreshTokenTick()",`access token expires in ${i} ticks, a tick lasts ${Ca}ms, refresh threshold is ${Oc} ticks`),i<=Oc&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof Y6)this._debug("auto refresh token tick lock not available");else throw e}return}if(this.refreshingDeferred!==null){this._debug("#_autoRefreshTokenTick()","refresh already in flight, skipping");return}try{const e=Date.now();try{await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const i=Math.floor((n.expires_at*1e3-e)/Ca);this._debug("#_autoRefreshTokenTick()",`access token expires in ${i} ticks, a tick lasts ${Ca}ms, refresh threshold is ${Oc} ticks`),i<=Oc&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Tr()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;if(this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"){if(this.autoRefreshToken&&this._startAutoRefresh(),!e)if(await this.initializePromise,this.lock!=null)await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()});else{if(document.visibilityState!=="visible"){this._debug(r,"visibilityState is no longer visible, skipping recovery");return}await this._recoverAndRefresh()}}else document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){const i=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&i.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&i.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[a,o]=await _s(this.storage,this.storageKey),c=new URLSearchParams({code_challenge:`${encodeURIComponent(a)}`,code_challenge_method:`${encodeURIComponent(o)}`});i.push(c.toString())}if(n!=null&&n.queryParams){const a=new URLSearchParams(n.queryParams);i.push(a.toString())}return n!=null&&n.skipBrowserRedirect&&i.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${i.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;const{data:i,error:a}=r;return a?this._returnResult({data:null,error:a}):await Ne(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=i==null?void 0:i.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,i;const{data:a,error:o}=r;if(o)return this._returnResult({data:null,error:o});const c=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:u,error:d}=await Ne(this.fetch,"POST",`${this.url}/factors`,{body:c,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return d?this._returnResult({data:null,error:d}):(e.factorType==="totp"&&u.type==="totp"&&(!((i=u==null?void 0:u.totp)===null||i===void 0)&&i.qr_code)&&(u.totp.qr_code=`data:image/svg+xml;utf-8,${u.totp.qr_code}`),this._returnResult({data:u,error:null}))})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _verify(e){const r=async()=>{try{return await this._useSession(async n=>{var i;const{data:a,error:o}=n;if(o)return this._returnResult({data:null,error:o});const c=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?IE(e.webauthn.credential_response):$E(e.webauthn.credential_response)})}:{code:e.code}),{data:u,error:d}=await Ne(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:c,headers:this.headers,jwt:(i=a==null?void 0:a.session)===null||i===void 0?void 0:i.access_token});return d?this._returnResult({data:null,error:d}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+u.expires_in},u)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",u),this._returnResult({data:u,error:d}))})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,r):r()}async _challenge(e){const r=async()=>{try{return await this._useSession(async n=>{var i;const{data:a,error:o}=n;if(o)return this._returnResult({data:null,error:o});const c=await Ne(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(i=a==null?void 0:a.session)===null||i===void 0?void 0:i.access_token});if(c.error)return c;const{data:u}=c;if(u.type!=="webauthn")return{data:u,error:null};switch(u.webauthn.type){case"create":return{data:Object.assign(Object.assign({},u),{webauthn:Object.assign(Object.assign({},u.webauthn),{credential_options:Object.assign(Object.assign({},u.webauthn.credential_options),{publicKey:PE(u.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},u),{webauthn:Object.assign(Object.assign({},u.webauthn),{credential_options:Object.assign(Object.assign({},u.webauthn.credential_options),{publicKey:RE(u.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,r):r()}async _challengeAndVerify(e){const{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?this._returnResult({data:null,error:n}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:n}=await this.getUser();if(n)return{data:null,error:n};const i={all:[],phone:[],totp:[],webauthn:[]};for(const a of(e=r==null?void 0:r.factors)!==null&&e!==void 0?e:[])i.all.push(a),a.status==="verified"&&i[a.factor_type].push(a);return{data:i,error:null}}async _getAuthenticatorAssuranceLevel(e){var r,n,i,a;if(e)try{const{payload:v}=hf(e);let b=null;v.aal&&(b=v.aal);let w=b;const{data:{user:x},error:k}=await this.getUser(e);if(k)return this._returnResult({data:null,error:k});((n=(r=x==null?void 0:x.factors)===null||r===void 0?void 0:r.filter(C=>C.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(w="aal2");const A=v.amr||[];return{data:{currentLevel:b,nextLevel:w,currentAuthenticationMethods:A},error:null}}catch(v){if(be(v))return this._returnResult({data:null,error:v});throw v}const{data:{session:o},error:c}=await this.getSession();if(c)return this._returnResult({data:null,error:c});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:u}=hf(o.access_token);let d=null;u.aal&&(d=u.aal);let p=d;((a=(i=o.user.factors)===null||i===void 0?void 0:i.filter(v=>v.status==="verified"))!==null&&a!==void 0?a:[]).length>0&&(p="aal2");const m=u.amr||[];return{data:{currentLevel:d,nextLevel:p,currentAuthenticationMethods:m},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;return i?this._returnResult({data:null,error:i}):n?await Ne(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:n.access_token,xform:a=>({data:a,error:null})}):this._returnResult({data:null,error:new mr})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:i},error:a}=n;if(a)return this._returnResult({data:null,error:a});if(!i)return this._returnResult({data:null,error:new mr});const o=await Ne(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:i.access_token,body:{action:"approve"},xform:c=>({data:c,error:null})});return o.data&&o.data.redirect_url&&Tr()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}}async _denyAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:i},error:a}=n;if(a)return this._returnResult({data:null,error:a});if(!i)return this._returnResult({data:null,error:new mr});const o=await Ne(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:i.access_token,body:{action:"deny"},xform:c=>({data:c,error:null})});return o.data&&o.data.redirect_url&&Tr()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;return n?this._returnResult({data:null,error:n}):r?await Ne(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new mr})})}catch(e){if(be(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;return i?this._returnResult({data:null,error:i}):n?(await Ne(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new mr})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(c=>c.kid===e);if(n)return n;const i=Date.now();if(n=this.jwks.keys.find(c=>c.kid===e),n&&this.jwks_cached_at+g6>i)return n;const{data:a,error:o}=await Ne(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!a.keys||a.keys.length===0||(this.jwks=a,this.jwks_cached_at=i,n=a.keys.find(c=>c.kid===e),!n)?null:n}async getClaims(e,r={}){try{let n=e;if(!n){const{data:v,error:b}=await this.getSession();if(b||!v.session)return this._returnResult({data:null,error:b});n=v.session.access_token}const{header:i,payload:a,signature:o,raw:{header:c,payload:u}}=hf(n);if(!(r!=null&&r.allowExpired))try{z6(a.exp)}catch(v){throw new Yf(v instanceof Error?v.message:"JWT validation failed")}const d=!i.alg||i.alg.startsWith("HS")||!i.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(i.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!d){const{error:v}=await this.getUser(n);if(v)throw v;return{data:{claims:a,header:i,signature:o},error:null}}const p=B6(i.alg),f=await crypto.subtle.importKey("jwk",d,p,!0,["verify"]);if(!await crypto.subtle.verify(p,f,o,A6(`${c}.${u}`)))throw new Yf("Invalid JWT signature");return{data:{claims:a,header:i,signature:o},error:null}}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}}async signInWithPasskey(e){var r,n,i;qn(this.experimental);try{if(!Qf())return this._returnResult({data:null,error:new Xn("Browser does not support WebAuthn",null)});const{data:a,error:o}=await this._startPasskeyAuthentication({options:{captchaToken:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}});if(o||!a)return this._returnResult({data:null,error:o});const c=RE(a.options),u=(i=(n=e==null?void 0:e.options)===null||n===void 0?void 0:n.signal)!==null&&i!==void 0?i:fx.createNewAbortSignal(),{data:d,error:p}=await fR({publicKey:c,signal:u});if(p||!d)return this._returnResult({data:null,error:p??new Xn("WebAuthn ceremony failed",null)});const f=$E(d);return this._verifyPasskeyAuthentication({challengeId:a.challenge_id,credential:f})}catch(a){if(be(a))return this._returnResult({data:null,error:a});throw a}}async registerPasskey(e){var r,n;qn(this.experimental);try{if(!Qf())return this._returnResult({data:null,error:new Xn("Browser does not support WebAuthn",null)});const{data:i,error:a}=await this._startPasskeyRegistration();if(a||!i)return this._returnResult({data:null,error:a});const o=PE(i.options),c=(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.signal)!==null&&n!==void 0?n:fx.createNewAbortSignal(),{data:u,error:d}=await dR({publicKey:o,signal:c});if(d||!u)return this._returnResult({data:null,error:d??new Xn("WebAuthn ceremony failed",null)});const p=IE(u);return this._verifyPasskeyRegistration({challengeId:i.challenge_id,credential:p})}catch(i){if(be(i))return this._returnResult({data:null,error:i});throw i}}async _startPasskeyRegistration(){qn(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new mr});const{data:i,error:a}=await Ne(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:r.access_token,body:{}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:i,error:null})})}catch(e){if(be(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){qn(this.experimental);try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new mr});const{data:a,error:o}=await Ne(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:n.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:a,error:null})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _startPasskeyAuthentication(e){var r;qn(this.experimental);try{const{data:n,error:i}=await Ne(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})}catch(n){if(be(n))return this._returnResult({data:null,error:n});throw n}}async _verifyPasskeyAuthentication(e){qn(this.experimental);try{const{data:r,error:n}=await Ne(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:An});return n?this._returnResult({data:null,error:n}):(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:r,error:null}))}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _listPasskeys(){qn(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new mr});const{data:i,error:a}=await Ne(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:r.access_token,xform:o=>({data:o,error:null})});return a?this._returnResult({data:null,error:a}):this._returnResult({data:i,error:null})})}catch(e){if(be(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){qn(this.experimental);try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new mr});const{data:a,error:o}=await Ne(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:n.access_token,body:{friendly_name:e.friendlyName}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:a,error:null})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}async _deletePasskey(e){qn(this.experimental);try{return await this._useSession(async r=>{const{data:{session:n},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new mr});const{error:a}=await Ne(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:n.access_token,noResolveJson:!0});return a?this._returnResult({data:null,error:a}):this._returnResult({data:null,error:null})})}catch(r){if(be(r))return this._returnResult({data:null,error:r});throw r}}}Vc.nextInstanceID={};const uU=Vc,dU="2.107.0";let Tc="",th;if(typeof Deno<"u"){var Ug;Tc="deno",th=(Ug=Deno.version)===null||Ug===void 0?void 0:Ug.deno}else if(typeof document<"u")Tc="web";else if(typeof navigator<"u"&&navigator.product==="ReactNative")Tc="react-native";else{var qg;Tc="node",th=typeof process<"u"?(qg=process.version)===null||qg===void 0?void 0:qg.replace(/^v/,""):void 0}const hR=[`runtime=${Tc}`];th&&hR.push(`runtime-version=${th}`);const fU={"X-Client-Info":`supabase-js/${dU}; ${hR.join("; ")}`},hU={headers:fU},pU={schema:"public"},mU={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},gU={},yU={enabled:!1,respectSamplingDecision:!0};function vU(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(p){try{d(n.next(p))}catch(f){o(f)}}function u(p){try{d(n.throw(p))}catch(f){o(f)}}function d(p){p.done?a(p.value):i(p.value).then(c,u)}d((n=n.apply(t,[])).next())})}let Fg=null;const bU="@opentelemetry/api";function xU(){return Fg===null&&(Fg=import(bU).catch(()=>null)),Fg}function wU(){return vU(this,void 0,void 0,function*(){try{const t=yield xU();if(!t||!t.propagation||!t.context)return null;const e={};t.propagation.inject(t.context.active(),e);const r=e.traceparent;return r?{traceparent:r,tracestate:e.tracestate,baggage:e.baggage}:null}catch{return null}})}function _U(t){if(!t||typeof t!="string")return null;const e=t.split("-");if(e.length!==4)return null;const[r,n,i,a]=e;if(r.length!==2||n.length!==32||i.length!==16||a.length!==2)return null;const o=/^[0-9a-f]+$/i;return!o.test(r)||!o.test(n)||!o.test(i)||!o.test(a)||n==="00000000000000000000000000000000"||i==="0000000000000000"?null:{version:r,traceId:n,parentId:i,traceFlags:a,isSampled:(parseInt(a,16)&1)===1}}function SU(t,e){if(!t||!e||e.length===0)return!1;let r;if(t instanceof URL)r=t;else try{r=new URL(t)}catch{return!1}for(const n of e)try{if(typeof n=="string"){if(kU(r.hostname,n))return!0}else if(n instanceof RegExp){if(n.test(r.hostname))return!0}else if(typeof n=="function"&&n(r))return!0}catch{continue}return!1}function kU(t,e){if(e===t)return!0;if(e.startsWith("*.")){const r=e.slice(2);if(t.endsWith(r)&&(t===r||t.endsWith("."+r)))return!0}return!1}function EU(t){const e=[];try{const r=new URL(t);e.push(r.hostname)}catch{}return e.push("*.supabase.co","*.supabase.in"),e.push("localhost","127.0.0.1","[::1]"),e}function Xc(t){"@babel/helpers - typeof";return Xc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xc(t)}function AU(t,e){if(Xc(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(Xc(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function OU(t){var e=AU(t,"string");return Xc(e)=="symbol"?e:e+""}function TU(t,e,r){return(e=OU(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ME(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function Ht(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ME(Object(r),!0).forEach(function(n){TU(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ME(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const CU=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),jU=()=>Headers,NU=(t,e,r,n,i)=>{const a=CU(n),o=jU(),c=(i==null?void 0:i.enabled)===!0,u=(i==null?void 0:i.respectSamplingDecision)!==!1,d=c?EU(e):null;return async(p,f)=>{var m;const v=(m=await r())!==null&&m!==void 0?m:t;let b=new o(f==null?void 0:f.headers);if(b.has("apikey")||b.set("apikey",t),b.has("Authorization")||b.set("Authorization",`Bearer ${v}`),d){const w=await PU(p,d,u);w&&(w.traceparent&&!b.has("traceparent")&&b.set("traceparent",w.traceparent),w.tracestate&&!b.has("tracestate")&&b.set("tracestate",w.tracestate),w.baggage&&!b.has("baggage")&&b.set("baggage",w.baggage))}return a(p,Ht(Ht({},f),{},{headers:b}))}};async function PU(t,e,r){if(!SU(typeof t=="string"||t instanceof URL?t:t.url,e))return null;const n=await wU();if(!n||!n.traceparent)return null;if(r){const i=_U(n.traceparent);if(i&&!i.isSampled)return null}return n}function DE(t){return typeof t=="boolean"?{enabled:t}:t}function RU(t){return t.endsWith("/")?t:t+"/"}function IU(t,e){var r,n,i,a,o,c;const{db:u,auth:d,realtime:p,global:f}=t,{db:m,auth:v,realtime:b,global:w}=e,x=DE(t.tracePropagation),k=DE(e.tracePropagation),S={db:Ht(Ht({},m),u),auth:Ht(Ht({},v),d),realtime:Ht(Ht({},b),p),storage:{},global:Ht(Ht(Ht({},w),f),{},{headers:Ht(Ht({},(r=w==null?void 0:w.headers)!==null&&r!==void 0?r:{}),(n=f==null?void 0:f.headers)!==null&&n!==void 0?n:{})}),tracePropagation:{enabled:(i=(a=x==null?void 0:x.enabled)!==null&&a!==void 0?a:k==null?void 0:k.enabled)!==null&&i!==void 0?i:!1,respectSamplingDecision:(o=(c=x==null?void 0:x.respectSamplingDecision)!==null&&c!==void 0?c:k==null?void 0:k.respectSamplingDecision)!==null&&o!==void 0?o:!0},accessToken:async()=>""};return t.accessToken?S.accessToken=t.accessToken:delete S.accessToken,S}function $U(t){const e=t==null?void 0:t.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(RU(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var MU=class extends uU{constructor(t){super(t)}},DU=class{constructor(t,e,r){var n,i;this.supabaseUrl=t,this.supabaseKey=e;const a=$U(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",a),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",a),this.storageUrl=new URL("storage/v1",a),this.functionsUrl=new URL("functions/v1",a);const o=`sb-${a.hostname.split(".")[0]}-auth-token`,c={db:pU,realtime:gU,auth:Ht(Ht({},mU),{},{storageKey:o}),global:hU,tracePropagation:yU},u=IU(r??{},c);if(this.settings=u,this.storageKey=(n=u.auth.storageKey)!==null&&n!==void 0?n:"",this.headers=(i=u.global.headers)!==null&&i!==void 0?i:{},u.accessToken)this.accessToken=u.accessToken,this.auth=new Proxy({},{get:(p,f)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(f)} is not possible`)}});else{var d;this.auth=this._initSupabaseAuthClient((d=u.auth)!==null&&d!==void 0?d:{},this.headers,u.global.fetch)}this.fetch=NU(e,t,this._getAccessToken.bind(this),u.global.fetch,u.tracePropagation),this.realtime=this._initRealtimeClient(Ht({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},u.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(p=>this.realtime.setAuth(p)).catch(p=>console.warn("Failed to set initial Realtime auth token:",p)),this.rest=new ZB(new URL("rest/v1",a).href,{headers:this.headers,schema:u.db.schema,fetch:this.fetch,timeout:u.db.timeout,urlLengthLimit:u.db.urlLengthLimit}),this.storage=new d6(this.storageUrl.href,this.headers,this.fetch,r==null?void 0:r.storage),u.accessToken||this._listenForAuthEvents()}get functions(){return new FB(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,r)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,r;if(t.accessToken)return await t.accessToken();const{data:n}=await t.auth.getSession();return(e=(r=n.session)===null||r===void 0?void 0:r.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:n,userStorage:i,storageKey:a,flowType:o,lock:c,debug:u,throwOnError:d,experimental:p,lockAcquireTimeout:f,skipAutoInitialize:m},v,b){const w={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new MU({url:this.authUrl.href,headers:Ht(Ht({},w),v),storageKey:a,autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:n,userStorage:i,flowType:o,lock:c,debug:u,throwOnError:d,experimental:p,fetch:b,lockAcquireTimeout:f,skipAutoInitialize:m,hasCustomAuthorizationHeader:Object.keys(this.headers).some(x=>x.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new I8(this.realtimeUrl.href,Ht(Ht({},t),{},{params:Ht(Ht({},{apikey:this.supabaseKey}),t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e==null?void 0:e.access_token)})}_handleTokenChanged(t,e,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const LU=(t,e,r)=>new DU(t,e,r);function zU(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const r=e.match(/^v(\d+)\./);return r?parseInt(r[1],10)<=18:!1}zU()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const pR=j.createContext({session:null,supabase:null,loading:!0,signIn:async()=>({error:"Not initialized"}),signOut:async()=>{}});function mp(){return j.useContext(pR)}function BU({children:t}){const[e,r]=j.useState(null),[n,i]=j.useState(null),[a,o]=j.useState(!0),c=j.useRef(null);j.useEffect(()=>{W4(()=>{var f;return((f=c.current)==null?void 0:f.access_token)??null})},[]);const u=j.useRef(null);j.useEffect(()=>{K4(async()=>{const f=u.current;if(!f)return null;const{data:m,error:v}=await f.auth.refreshSession();return v||!m.session?null:(c.current=m.session,i(m.session),m.session.access_token)})},[]),j.useEffect(()=>{fetch("/api/auth/config").then(f=>f.json()).then(f=>{if(f.supabaseUrl&&f.supabaseAnonKey){const m=LU(f.supabaseUrl,f.supabaseAnonKey);r(m),u.current=m,m.auth.getSession().then(({data:b})=>{c.current=b.session,i(b.session),o(!1)});const{data:{subscription:v}}=m.auth.onAuthStateChange((b,w)=>{c.current=w,i(w)});return()=>v.unsubscribe()}o(!1)}).catch(()=>{o(!1)})},[]);async function d(f,m){if(!e)return{error:"Supabase not configured"};const{error:v}=await e.auth.signInWithPassword({email:f,password:m});return{error:(v==null?void 0:v.message)??null}}async function p(){e&&(await e.auth.signOut(),c.current=null,i(null))}return y.jsx(pR.Provider,{value:{session:n,supabase:e,loading:a,signIn:d,signOut:p},children:t})}function mR(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(r=mR(t[e]))&&(n&&(n+=" "),n+=r)}else for(r in t)t[r]&&(n&&(n+=" "),n+=r);return n}function ot(){for(var t,e,r=0,n="",i=arguments.length;r<i;r++)(t=arguments[r])&&(e=mR(t))&&(n&&(n+=" "),n+=e);return n}const UU=(t,e)=>{const r=new Array(t.length+e.length);for(let n=0;n<t.length;n++)r[n]=t[n];for(let n=0;n<e.length;n++)r[t.length+n]=e[n];return r},qU=(t,e)=>({classGroupId:t,validator:e}),gR=(t=new Map,e=null,r)=>({nextPart:t,validators:e,classGroupId:r}),rh="-",LE=[],FU="arbitrary..",HU=t=>{const e=KU(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return WU(o);const c=o.split(rh),u=c[0]===""&&c.length>1?1:0;return yR(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=n[o],d=r[o];return u?d?UU(d,u):u:d||LE}return r[o]||LE}}},yR=(t,e,r)=>{if(t.length-e===0)return r.classGroupId;const i=t[e],a=r.nextPart.get(i);if(a){const d=yR(t,e+1,a);if(d)return d}const o=r.validators;if(o===null)return;const c=e===0?t.join(rh):t.slice(e).join(rh),u=o.length;for(let d=0;d<u;d++){const p=o[d];if(p.validator(c))return p.classGroupId}},WU=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),r=e.indexOf(":"),n=e.slice(0,r);return n?FU+n:void 0})(),KU=t=>{const{theme:e,classGroups:r}=t;return GU(r,e)},GU=(t,e)=>{const r=gR();for(const n in t){const i=t[n];l1(i,r,n,e)}return r},l1=(t,e,r,n)=>{const i=t.length;for(let a=0;a<i;a++){const o=t[a];VU(o,e,r,n)}},VU=(t,e,r,n)=>{if(typeof t=="string"){XU(t,e,r);return}if(typeof t=="function"){YU(t,e,r,n);return}JU(t,e,r,n)},XU=(t,e,r)=>{const n=t===""?e:vR(e,t);n.classGroupId=r},YU=(t,e,r,n)=>{if(ZU(t)){l1(t(n),e,r,n);return}e.validators===null&&(e.validators=[]),e.validators.push(qU(r,t))},JU=(t,e,r,n)=>{const i=Object.entries(t),a=i.length;for(let o=0;o<a;o++){const[c,u]=i[o];l1(u,vR(e,c),r,n)}},vR=(t,e)=>{let r=t;const n=e.split(rh),i=n.length;for(let a=0;a<i;a++){const o=n[a];let c=r.nextPart.get(o);c||(c=gR(),r.nextPart.set(o,c)),r=c}return r},ZU=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,QU=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=Object.create(null),n=Object.create(null);const i=(a,o)=>{r[a]=o,e++,e>t&&(e=0,n=r,r=Object.create(null))};return{get(a){let o=r[a];if(o!==void 0)return o;if((o=n[a])!==void 0)return i(a,o),o},set(a,o){a in r?r[a]=o:i(a,o)}}},hx="!",zE=":",eq=[],BE=(t,e,r,n,i)=>({modifiers:t,hasImportantModifier:e,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),tq=t=>{const{prefix:e,experimentalParseClassName:r}=t;let n=i=>{const a=[];let o=0,c=0,u=0,d;const p=i.length;for(let w=0;w<p;w++){const x=i[w];if(o===0&&c===0){if(x===zE){a.push(i.slice(u,w)),u=w+1;continue}if(x==="/"){d=w;continue}}x==="["?o++:x==="]"?o--:x==="("?c++:x===")"&&c--}const f=a.length===0?i:i.slice(u);let m=f,v=!1;f.endsWith(hx)?(m=f.slice(0,-1),v=!0):f.startsWith(hx)&&(m=f.slice(1),v=!0);const b=d&&d>u?d-u:void 0;return BE(a,v,m,b)};if(e){const i=e+zE,a=n;n=o=>o.startsWith(i)?a(o.slice(i.length)):BE(eq,!1,o,void 0,!0)}if(r){const i=n;n=a=>r({className:a,parseClassName:i})}return n},rq=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((r,n)=>{e.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let a=0;a<r.length;a++){const o=r[a],c=o[0]==="[",u=e.has(o);c||u?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(o)):i.push(o)}return i.length>0&&(i.sort(),n.push(...i)),n}},nq=t=>({cache:QU(t.cacheSize),parseClassName:tq(t),sortModifiers:rq(t),postfixLookupClassGroupIds:iq(t),...HU(t)}),iq=t=>{const e=Object.create(null),r=t.postfixLookupClassGroups;if(r)for(let n=0;n<r.length;n++)e[r[n]]=!0;return e},aq=/\s+/,oq=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=e,c=[],u=t.trim().split(aq);let d="";for(let p=u.length-1;p>=0;p-=1){const f=u[p],{isExternal:m,modifiers:v,hasImportantModifier:b,baseClassName:w,maybePostfixModifierPosition:x}=r(f);if(m){d=f+(d.length>0?" "+d:d);continue}let k=!!x,S;if(k){const N=w.substring(0,x);S=n(N);const R=S&&o[S]?n(w):void 0;R&&R!==S&&(S=R,k=!1)}else S=n(w);if(!S){if(!k){d=f+(d.length>0?" "+d:d);continue}if(S=n(w),!S){d=f+(d.length>0?" "+d:d);continue}k=!1}const A=v.length===0?"":v.length===1?v[0]:a(v).join(":"),C=b?A+hx:A,T=C+S;if(c.indexOf(T)>-1)continue;c.push(T);const O=i(S,k);for(let N=0;N<O.length;++N){const R=O[N];c.push(C+R)}d=f+(d.length>0?" "+d:d)}return d},sq=(...t)=>{let e=0,r,n,i="";for(;e<t.length;)(r=t[e++])&&(n=bR(r))&&(i&&(i+=" "),i+=n);return i},bR=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=bR(t[n]))&&(r&&(r+=" "),r+=e);return r},lq=(t,...e)=>{let r,n,i,a;const o=u=>{const d=e.reduce((p,f)=>f(p),t());return r=nq(d),n=r.cache.get,i=r.cache.set,a=c,c(u)},c=u=>{const d=n(u);if(d)return d;const p=oq(u,r);return i(u,p),p};return a=o,(...u)=>a(sq(...u))},cq=[],ir=t=>{const e=r=>r[t]||cq;return e.isThemeGetter=!0,e},xR=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,wR=/^\((?:(\w[\w-]*):)?(.+)\)$/i,uq=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,dq=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,fq=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,hq=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,pq=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mq=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ta=t=>uq.test(t),Ye=t=>!!t&&!Number.isNaN(Number(t)),gi=t=>!!t&&Number.isInteger(Number(t)),Hg=t=>t.endsWith("%")&&Ye(t.slice(0,-1)),zi=t=>dq.test(t),_R=()=>!0,gq=t=>fq.test(t)&&!hq.test(t),c1=()=>!1,yq=t=>pq.test(t),vq=t=>mq.test(t),bq=t=>!ke(t)&&!Oe(t),xq=t=>t.startsWith("@container")&&(t[10]==="/"&&t[11]!==void 0||t[11]==="s"&&t[16]!==void 0&&t.startsWith("-size/",10)||t[11]==="n"&&t[18]!==void 0&&t.startsWith("-normal/",10)),wq=t=>Ha(t,ER,c1),ke=t=>xR.test(t),vo=t=>Ha(t,AR,gq),UE=t=>Ha(t,Cq,Ye),_q=t=>Ha(t,TR,_R),Sq=t=>Ha(t,OR,c1),qE=t=>Ha(t,SR,c1),kq=t=>Ha(t,kR,vq),pf=t=>Ha(t,CR,yq),Oe=t=>wR.test(t),pc=t=>zo(t,AR),Eq=t=>zo(t,OR),FE=t=>zo(t,SR),Aq=t=>zo(t,ER),Oq=t=>zo(t,kR),mf=t=>zo(t,CR,!0),Tq=t=>zo(t,TR,!0),Ha=(t,e,r)=>{const n=xR.exec(t);return n?n[1]?e(n[1]):r(n[2]):!1},zo=(t,e,r=!1)=>{const n=wR.exec(t);return n?n[1]?e(n[1]):r:!1},SR=t=>t==="position"||t==="percentage",kR=t=>t==="image"||t==="url",ER=t=>t==="length"||t==="size"||t==="bg-size",AR=t=>t==="length",Cq=t=>t==="number",OR=t=>t==="family-name",TR=t=>t==="number"||t==="weight",CR=t=>t==="shadow",jq=()=>{const t=ir("color"),e=ir("font"),r=ir("text"),n=ir("font-weight"),i=ir("tracking"),a=ir("leading"),o=ir("breakpoint"),c=ir("container"),u=ir("spacing"),d=ir("radius"),p=ir("shadow"),f=ir("inset-shadow"),m=ir("text-shadow"),v=ir("drop-shadow"),b=ir("blur"),w=ir("perspective"),x=ir("aspect"),k=ir("ease"),S=ir("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],T=()=>[...C(),Oe,ke],O=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],R=()=>[Oe,ke,u],$=()=>[Ta,"full","auto",...R()],K=()=>[gi,"none","subgrid",Oe,ke],L=()=>["auto",{span:["full",gi,Oe,ke]},gi,Oe,ke],U=()=>[gi,"auto",Oe,ke],F=()=>["auto","min","max","fr",Oe,ke],X=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Y=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",...R()],Q=()=>[Ta,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],W=()=>[Ta,"screen","full","dvw","lvw","svw","min","max","fit",...R()],ee=()=>[Ta,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],q=()=>[t,Oe,ke],I=()=>[...C(),FE,qE,{position:[Oe,ke]}],B=()=>["no-repeat",{repeat:["","x","y","space","round"]}],J=()=>["auto","cover","contain",Aq,wq,{size:[Oe,ke]}],oe=()=>[Hg,pc,vo],ue=()=>["","none","full",d,Oe,ke],ve=()=>["",Ye,pc,vo],qe=()=>["solid","dashed","dotted","double"],xe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ae=()=>[Ye,Hg,FE,qE],Se=()=>["","none",b,Oe,ke],Me=()=>["none",Ye,Oe,ke],se=()=>["none",Ye,Oe,ke],rt=()=>[Ye,Oe,ke],Fe=()=>[Ta,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[zi],breakpoint:[zi],color:[_R],container:[zi],"drop-shadow":[zi],ease:["in","out","in-out"],font:[bq],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[zi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[zi],shadow:[zi],spacing:["px",Ye],text:[zi],"text-shadow":[zi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ta,ke,Oe,x]}],container:["container"],"container-type":[{"@container":["","normal","size",Oe,ke]}],"container-named":[xq],columns:[{columns:[Ye,ke,Oe,c]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:T()}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:$()}],"inset-x":[{"inset-x":$()}],"inset-y":[{"inset-y":$()}],start:[{"inset-s":$(),start:$()}],end:[{"inset-e":$(),end:$()}],"inset-bs":[{"inset-bs":$()}],"inset-be":[{"inset-be":$()}],top:[{top:$()}],right:[{right:$()}],bottom:[{bottom:$()}],left:[{left:$()}],visibility:["visible","invisible","collapse"],z:[{z:[gi,"auto",Oe,ke]}],basis:[{basis:[Ta,"full","auto",c,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ye,Ta,"auto","initial","none",ke]}],grow:[{grow:["",Ye,Oe,ke]}],shrink:[{shrink:["",Ye,Oe,ke]}],order:[{order:[gi,"first","last","none",Oe,ke]}],"grid-cols":[{"grid-cols":K()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":K()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":F()}],"auto-rows":[{"auto-rows":F()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...X(),"normal"]}],"justify-items":[{"justify-items":[...Y(),"normal"]}],"justify-self":[{"justify-self":["auto",...Y()]}],"align-content":[{content:["normal",...X()]}],"align-items":[{items:[...Y(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Y(),{baseline:["","last"]}]}],"place-content":[{"place-content":X()}],"place-items":[{"place-items":[...Y(),"baseline"]}],"place-self":[{"place-self":["auto",...Y()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mbs:[{mbs:G()}],mbe:[{mbe:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...W()]}],"min-inline-size":[{"min-inline":["auto",...W()]}],"max-inline-size":[{"max-inline":["none",...W()]}],"block-size":[{block:["auto",...ee()]}],"min-block-size":[{"min-block":["auto",...ee()]}],"max-block-size":[{"max-block":["none",...ee()]}],w:[{w:[c,"screen",...Q()]}],"min-w":[{"min-w":[c,"screen","none",...Q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",r,pc,vo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Tq,_q]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Hg,ke]}],"font-family":[{font:[Eq,Sq,e]}],"font-features":[{"font-features":[ke]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Oe,ke]}],"line-clamp":[{"line-clamp":[Ye,"none",Oe,UE]}],leading:[{leading:[a,...R()]}],"list-image":[{"list-image":["none",Oe,ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Oe,ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...qe(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ye,"from-font","auto",Oe,vo]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Ye,"auto",Oe,ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[gi,Oe,ke]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Oe,ke]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Oe,ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:I()}],"bg-repeat":[{bg:B()}],"bg-size":[{bg:J()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},gi,Oe,ke],radial:["",Oe,ke],conic:[gi,Oe,ke]},Oq,kq]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:oe()}],"gradient-via-pos":[{via:oe()}],"gradient-to-pos":[{to:oe()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:ue()}],"rounded-s":[{"rounded-s":ue()}],"rounded-e":[{"rounded-e":ue()}],"rounded-t":[{"rounded-t":ue()}],"rounded-r":[{"rounded-r":ue()}],"rounded-b":[{"rounded-b":ue()}],"rounded-l":[{"rounded-l":ue()}],"rounded-ss":[{"rounded-ss":ue()}],"rounded-se":[{"rounded-se":ue()}],"rounded-ee":[{"rounded-ee":ue()}],"rounded-es":[{"rounded-es":ue()}],"rounded-tl":[{"rounded-tl":ue()}],"rounded-tr":[{"rounded-tr":ue()}],"rounded-br":[{"rounded-br":ue()}],"rounded-bl":[{"rounded-bl":ue()}],"border-w":[{border:ve()}],"border-w-x":[{"border-x":ve()}],"border-w-y":[{"border-y":ve()}],"border-w-s":[{"border-s":ve()}],"border-w-e":[{"border-e":ve()}],"border-w-bs":[{"border-bs":ve()}],"border-w-be":[{"border-be":ve()}],"border-w-t":[{"border-t":ve()}],"border-w-r":[{"border-r":ve()}],"border-w-b":[{"border-b":ve()}],"border-w-l":[{"border-l":ve()}],"divide-x":[{"divide-x":ve()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ve()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...qe(),"hidden","none"]}],"divide-style":[{divide:[...qe(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...qe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ye,Oe,ke]}],"outline-w":[{outline:["",Ye,pc,vo]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",p,mf,pf]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",f,mf,pf]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:ve()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Ye,vo]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":ve()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",m,mf,pf]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Ye,Oe,ke]}],"mix-blend":[{"mix-blend":[...xe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":xe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ye]}],"mask-image-linear-from-pos":[{"mask-linear-from":ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":ae()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":ae()}],"mask-image-t-to-pos":[{"mask-t-to":ae()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":ae()}],"mask-image-r-to-pos":[{"mask-r-to":ae()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":ae()}],"mask-image-b-to-pos":[{"mask-b-to":ae()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":ae()}],"mask-image-l-to-pos":[{"mask-l-to":ae()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":ae()}],"mask-image-x-to-pos":[{"mask-x-to":ae()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":ae()}],"mask-image-y-to-pos":[{"mask-y-to":ae()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[Oe,ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":ae()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":C()}],"mask-image-conic-pos":[{"mask-conic":[Ye]}],"mask-image-conic-from-pos":[{"mask-conic-from":ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":ae()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:I()}],"mask-repeat":[{mask:B()}],"mask-size":[{mask:J()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Oe,ke]}],filter:[{filter:["","none",Oe,ke]}],blur:[{blur:Se()}],brightness:[{brightness:[Ye,Oe,ke]}],contrast:[{contrast:[Ye,Oe,ke]}],"drop-shadow":[{"drop-shadow":["","none",v,mf,pf]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Ye,Oe,ke]}],"hue-rotate":[{"hue-rotate":[Ye,Oe,ke]}],invert:[{invert:["",Ye,Oe,ke]}],saturate:[{saturate:[Ye,Oe,ke]}],sepia:[{sepia:["",Ye,Oe,ke]}],"backdrop-filter":[{"backdrop-filter":["","none",Oe,ke]}],"backdrop-blur":[{"backdrop-blur":Se()}],"backdrop-brightness":[{"backdrop-brightness":[Ye,Oe,ke]}],"backdrop-contrast":[{"backdrop-contrast":[Ye,Oe,ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ye,Oe,ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ye,Oe,ke]}],"backdrop-invert":[{"backdrop-invert":["",Ye,Oe,ke]}],"backdrop-opacity":[{"backdrop-opacity":[Ye,Oe,ke]}],"backdrop-saturate":[{"backdrop-saturate":[Ye,Oe,ke]}],"backdrop-sepia":[{"backdrop-sepia":["",Ye,Oe,ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Oe,ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ye,"initial",Oe,ke]}],ease:[{ease:["linear","initial",k,Oe,ke]}],delay:[{delay:[Ye,Oe,ke]}],animate:[{animate:["none",S,Oe,ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,Oe,ke]}],"perspective-origin":[{"perspective-origin":T()}],rotate:[{rotate:Me()}],"rotate-x":[{"rotate-x":Me()}],"rotate-y":[{"rotate-y":Me()}],"rotate-z":[{"rotate-z":Me()}],scale:[{scale:se()}],"scale-x":[{"scale-x":se()}],"scale-y":[{"scale-y":se()}],"scale-z":[{"scale-z":se()}],"scale-3d":["scale-3d"],skew:[{skew:rt()}],"skew-x":[{"skew-x":rt()}],"skew-y":[{"skew-y":rt()}],transform:[{transform:[Oe,ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:T()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Fe()}],"translate-x":[{"translate-x":Fe()}],"translate-y":[{"translate-y":Fe()}],"translate-z":[{"translate-z":Fe()}],"translate-none":["translate-none"],zoom:[{zoom:[gi,Oe,ke]}],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Oe,ke]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":q()}],"scrollbar-track-color":[{"scrollbar-track":q()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Oe,ke]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Ye,pc,vo,UE]}],stroke:[{stroke:["none",...q()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Nq=lq(jq);function Cc(...t){return Nq(ot(t))}const Pq=[{to:"/squads",icon:a1,label:"Squads"},{to:"/skills",icon:tx,label:"Skills"},{to:"/schedules",icon:yz,label:"Schedules"},{to:"/wiki",icon:PP,label:"Wiki"},{to:"/usage",icon:bz,label:"Usage"}],Rq=[{to:"/",icon:n1,label:"Chat"},{to:"/feed",icon:ex,label:"Inbox"},{to:"/settings",icon:pB,label:"Settings"}];function HE({to:t,icon:e,label:r,collapsed:n,badge:i}){return y.jsxs(tP,{to:t,end:t==="/",title:n?r:void 0,className:({isActive:a})=>Cc("w-full flex items-center gap-2.5 px-2 py-2 rounded-xl text-[11px] font-mono transition-colors cursor-pointer relative",n?"justify-center":"",a?"text-[#E43A9C]":"text-zinc-600 hover:text-zinc-300 hover:bg-white/[0.04]"),style:({isActive:a})=>a?{background:"rgba(228,58,156,0.1)"}:void 0,children:[y.jsx(e,{className:"w-3.5 h-3.5 flex-shrink-0"}),!n&&r,i!=null&&i>0&&y.jsx("span",{className:"absolute top-1 right-1 min-w-[14px] h-[14px] flex items-center justify-center rounded-full bg-[#E43A9C] text-[9px] text-white font-mono px-1",children:i>99?"99+":i})]})}function Iq(){const[t,e]=j.useState(!1),[r]=j.useState(CB),[n,i]=j.useState(0),{supabase:a}=mp();return j.useEffect(()=>{let o=!0;const c=()=>{Ge.get("/inbox?limit=200").then(d=>{if(!o)return;const p=d.entries??[];i(p.filter(f=>f.status==="pending").length)}).catch(()=>{})};c();const u=setInterval(c,3e4);return()=>{o=!1,clearInterval(u)}},[]),y.jsxs("div",{className:"flex h-screen overflow-hidden bg-background relative",children:[y.jsxs("div",{className:Cc("flex-shrink-0 flex flex-col border-r border-white/[0.06] bg-[#181818] transition-all duration-200",t?"w-[52px]":"w-[210px]"),children:[y.jsx("div",{className:Cc("h-[52px] flex items-center border-b border-white/[0.06] flex-shrink-0",t?"justify-center px-3":"justify-between pl-4 pr-3"),children:t?y.jsx(Ia,{height:26}):y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx(Ia,{height:26}),y.jsx("span",{className:"text-2xl text-white tracking-wider leading-none",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"IO"})]})}),y.jsx("nav",{className:"flex-1 py-2 px-1.5 space-y-0.5 overflow-y-auto",children:Pq.map(o=>y.jsx(HE,{collapsed:t,...o},o.to))}),y.jsxs("div",{className:"flex-shrink-0 border-t border-white/[0.06]",children:[y.jsx("div",{className:"py-1.5 px-1.5 space-y-0.5",children:Rq.map(o=>y.jsx(HE,{collapsed:t,badge:o.to==="/feed"?n:void 0,...o},o.to))}),y.jsxs("div",{className:"border-t border-white/[0.05] py-1.5 px-1.5 space-y-0.5",children:[y.jsxs("a",{href:`https://github.com/michaeljolley/io/releases/tag/v${r}`,target:"_blank",rel:"noreferrer",title:"GitHub",className:Cc("flex items-center gap-2.5 px-2 py-2 rounded-xl text-[11px] font-mono text-zinc-600 hover:text-zinc-300 hover:bg-white/[0.04] transition-colors cursor-pointer",t&&"justify-center"),children:[y.jsx(r1,{className:"w-3.5 h-3.5 flex-shrink-0"}),!t&&y.jsxs("span",{className:"text-zinc-700",children:["v",r]})]}),y.jsx("button",{type:"button",onClick:()=>e(!t),title:t?"Expand sidebar":"Collapse sidebar",className:Cc("w-full flex items-center gap-2.5 px-2 py-2 rounded-xl text-[11px] font-mono text-zinc-600 hover:text-zinc-300 hover:bg-white/[0.04] transition-colors cursor-pointer",t&&"justify-center"),children:t?y.jsx(Qw,{className:"w-3.5 h-3.5 flex-shrink-0"}):y.jsx(vl,{className:"w-3.5 h-3.5 flex-shrink-0"})})]})]})]}),y.jsxs("div",{className:"flex flex-col flex-1 min-w-0 overflow-hidden",children:[y.jsxs("div",{className:"h-[52px] flex-shrink-0 flex items-center justify-between px-4 border-b border-white/[0.06] bg-[#181818]",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(DB,{status:"connected"}),y.jsx("span",{className:"text-[11px] font-mono text-green-400",children:"connected"})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx(TB,{}),a&&y.jsx("button",{type:"button",onClick:()=>a.auth.signOut(),className:"p-2 rounded-xl hover:bg-white/[0.05] text-zinc-600 hover:text-zinc-300 transition-colors cursor-pointer",title:"Sign out",children:y.jsx(Xz,{className:"w-3.5 h-3.5"})})]})]}),y.jsxs("main",{className:"flex-1 overflow-hidden flex flex-col min-h-0 relative",children:[y.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",style:{zIndex:0},children:[y.jsx("div",{className:"orb orb-pink"}),y.jsx("div",{className:"orb orb-gray"})]}),y.jsx(TL,{})]})]})]})}function $q(){const{session:t}=mp(),e=Fa(),{messages:r,streaming:n,isStreaming:i,isThinking:a,sendChatMessage:o,stopStreaming:c,addUserMessage:u,uploadAttachment:d}=WP(),[p,f]=j.useState(""),[m,v]=j.useState(null),[b,w]=j.useState(null),x=j.useRef(null),k=j.useRef(null),S=j.useRef(null);j.useLayoutEffect(()=>{const O=x.current;O&&(O.scrollTop=O.scrollHeight)});async function A(){const O=p.trim();if(!O&&!m||i||a)return;const N=crypto.randomUUID(),R=m==null?void 0:m.name,$=[O,R?`Attachment: ${R}`:""].filter(Boolean).join(`
|
|
447
447
|
|
|
448
448
|
`);u({id:N,role:"user",content:O,timestamp:new Date().toISOString(),attachmentName:R}),f(""),v(null),S.current&&(S.current.value=""),k.current&&(k.current.style.height="auto");try{m&&await d(m,N),await o($)}catch{}}function C(O){O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),A())}function T(O){f(O.target.value),k.current&&(k.current.style.height="auto",k.current.style.height=`${Math.min(k.current.scrollHeight,160)}px`)}return y.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[y.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto px-5 py-5 space-y-5",children:[r.map(O=>{var N,R;return y.jsxs("div",{className:`flex gap-3 ${O.role==="user"?"flex-row-reverse":""}`,children:[y.jsx("div",{className:`flex-shrink-0 w-6 h-6 rounded-lg flex items-center justify-center text-[10px] font-mono mt-0.5 ${O.role==="user"?"border border-[#E43A9C]/30 text-[#E43A9C]":"bg-[#282828] border border-white/[0.07] text-zinc-500"}`,style:O.role==="user"?{background:"rgba(228,58,156,0.12)"}:void 0,children:O.role==="user"?((R=(N=t==null?void 0:t.user)==null?void 0:N.email)==null?void 0:R.charAt(0).toUpperCase())??"U":y.jsx(Ia,{height:12})}),y.jsxs("div",{className:`flex flex-col gap-1.5 max-w-[72%] ${O.role==="user"?"items-end":"items-start"}`,children:[O.toolCall&&y.jsxs("button",{type:"button",onClick:()=>w(b===O.id?null:O.id),className:"w-full text-left border border-white/[0.07] bg-[#1e1e1e] rounded-xl px-3 py-2 flex items-center gap-2 hover:border-[#E43A9C]/25 transition-colors",children:[y.jsx(qf,{className:"w-3 h-3 text-[#E43A9C] flex-shrink-0"}),y.jsx("span",{className:"text-[11px] font-mono text-zinc-400 flex-1",children:O.toolCall.name}),y.jsx(Pt,{variant:O.toolCall.status==="done"?"success":O.toolCall.status==="error"?"error":"warning",children:O.toolCall.status}),y.jsx(wz,{className:`w-3 h-3 text-zinc-600 transition-transform flex-shrink-0 ${b===O.id?"rotate-180":""}`})]}),O.toolCall&&b===O.id&&y.jsx("div",{className:"w-full bg-[#181818] border border-white/[0.06] rounded-xl px-3 py-2",children:y.jsx("p",{className:"text-[11px] font-mono text-zinc-500",children:O.toolCall.result})}),O.attachmentName&&y.jsx("div",{className:"rounded-xl border border-white/[0.08] bg-[#1e1e1e] px-3 py-2 text-[11px] font-mono text-zinc-400",children:O.attachmentName}),O.content&&y.jsx("div",{className:`rounded-2xl px-4 py-2.5 text-sm leading-relaxed ${O.role==="user"?"text-white rounded-tr-sm":"bg-[#222222] border border-white/[0.07] text-zinc-200 rounded-tl-sm"}`,style:O.role==="user"?{background:"linear-gradient(135deg, #D83333 0%, #C0285E 100%)"}:void 0,children:O.role==="user"?y.jsx("p",{className:"whitespace-pre-wrap",children:O.content}):y.jsx("div",{className:"prose-io",dangerouslySetInnerHTML:{__html:it.parse(O.content)}})}),y.jsx("span",{className:"text-[11px] text-zinc-700 font-mono px-0.5",children:lp(O.timestamp,e)})]})]},O.id)}),a&&y.jsxs("div",{className:"flex gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-lg flex items-center justify-center bg-[#282828] border border-white/[0.07] mt-0.5",children:y.jsx(Ia,{height:12})}),y.jsx("div",{className:"bg-[#222222] border border-white/[0.07] rounded-2xl rounded-tl-sm px-4 py-3 flex items-center gap-1.5",children:[0,120,240].map(O=>y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#E43A9C] animate-bounce",style:{animationDelay:`${O}ms`}},O))})]}),i&&n&&y.jsxs("div",{className:"flex gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-lg flex items-center justify-center bg-[#282828] border border-white/[0.07] mt-0.5",children:y.jsx(Ia,{height:12})}),y.jsx("div",{className:"bg-[#222222] border border-white/[0.07] rounded-2xl rounded-tl-sm px-4 py-2.5 max-w-[72%]",children:y.jsx("div",{className:"prose-io text-sm",dangerouslySetInnerHTML:{__html:it.parse(n)}})})]}),i&&!n&&y.jsxs("div",{className:"flex gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-lg flex items-center justify-center bg-[#282828] border border-white/[0.07] mt-0.5",children:y.jsx(Ia,{height:12})}),y.jsx("div",{className:"bg-[#222222] border border-white/[0.07] rounded-2xl rounded-tl-sm px-4 py-3 flex items-center gap-1.5",children:[0,120,240].map(O=>y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#E43A9C] animate-bounce",style:{animationDelay:`${O}ms`}},O))})]})]}),y.jsxs("div",{className:"border-t border-white/[0.06] p-4 flex-shrink-0",children:[y.jsxs("div",{className:"bg-[#1e1e1e] border border-white/[0.08] rounded-2xl overflow-hidden transition-colors focus-within:border-[#E43A9C]/30",children:[y.jsx("input",{ref:S,type:"file",className:"hidden",onChange:O=>{var N;return v(((N=O.target.files)==null?void 0:N[0])??null)}}),m&&y.jsxs("div",{className:"px-4 pt-3 text-[11px] font-mono text-zinc-400",children:["Attached: ",m.name]}),y.jsx("textarea",{ref:k,value:p,onChange:T,onKeyDown:C,placeholder:"Message IO…",rows:1,className:"w-full bg-transparent px-4 pt-3 pb-1 text-sm text-zinc-200 placeholder:text-zinc-700 resize-none focus:outline-none",style:{minHeight:"42px",maxHeight:"160px",fontFamily:"Inter, sans-serif"}}),y.jsxs("div",{className:"flex items-center justify-between px-3 pb-2.5",children:[y.jsx("button",{type:"button",onClick:()=>{var O;return(O=S.current)==null?void 0:O.click()},className:"p-1.5 rounded-lg hover:bg-white/[0.05] text-zinc-700 hover:text-zinc-400 transition-colors",children:y.jsx(DP,{className:"w-4 h-4"})}),y.jsx("div",{className:"flex items-center gap-2",children:i?y.jsxs("button",{type:"button",onClick:()=>c(),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-[11px] font-mono text-zinc-300 transition-colors",children:[y.jsx(up,{className:"w-3 h-3"})," Stop"]}):y.jsx("button",{type:"button",onClick:A,disabled:!p.trim()&&!m||a,className:"p-2 rounded-xl text-white disabled:opacity-30 disabled:cursor-not-allowed transition-opacity hover:opacity-90",style:{background:"linear-gradient(135deg, #D83333, #E43A9C)"},children:y.jsx(zP,{className:"w-3.5 h-3.5"})})})]})]}),y.jsx("p",{className:"text-center text-[11px] text-zinc-800 font-mono mt-2",children:"IO may make mistakes. Verify important outputs."})]})]})}const WE=["#38bdf8","#a78bfa","#34d399","#f59e0b","#f87171","#E43A9C"];function Mq(t){let e=0;for(let r=0;r<t.length;r++)e=t.charCodeAt(r)+((e<<5)-e);return WE[Math.abs(e)%WE.length]}function KE({name:t,color:e}){const r=t.toLowerCase(),n=e??(r==="orchestrator"||r==="io"?"#71717a":Mq(t));return y.jsx("span",{className:"inline-flex items-center px-1.5 py-px rounded text-[10px] font-mono border",style:{background:`${n}15`,color:n,borderColor:`${n}30`},children:t})}function mc(t){return t.status==="pending"}function Dq(){const[t,e]=j.useState([]),[r,n]=j.useState(null),[i,a]=j.useState(new Set),[o,c]=j.useState("all"),u=Fa();j.useEffect(()=>{Ge.get("/inbox").then(A=>e(A.entries??[])).catch(()=>{})},[]);const d=t.filter(mc).length,p=o==="unread"?t.filter(mc):t,f=p.length>0&&p.every(A=>i.has(A.id)),m=i.size>0;function v(A){m||(n(A),mc(A)&&(Ge.put(`/inbox/${A.id}/read`,{}).catch(()=>{}),e(C=>C.map(T=>T.id===A.id?{...T,status:"read"}:T))))}function b(A,C){A.stopPropagation(),a(T=>{const O=new Set(T);return O.has(C)?O.delete(C):O.add(C),O})}function w(){a(f?new Set:new Set(p.map(A=>A.id)))}function x(){const A=Array.from(i);Promise.allSettled(A.map(C=>Ge.put(`/inbox/${C}/read`,{}))),e(C=>C.map(T=>i.has(T.id)?{...T,status:"read"}:T)),a(new Set)}function k(){const A=Array.from(i);Promise.allSettled(A.map(C=>Ge.delete(`/inbox/${C}`))),e(C=>C.filter(T=>!i.has(T.id))),r&&i.has(r.id)&&n(null),a(new Set)}function S(A){Ge.delete(`/inbox/${A}`).catch(()=>{}),e(C=>C.filter(T=>T.id!==A)),(r==null?void 0:r.id)===A&&n(null)}return y.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[y.jsxs("div",{className:"w-72 flex-shrink-0 border-r border-white/[0.06] flex flex-col overflow-hidden",children:[y.jsxs("div",{className:"px-4 py-3 border-b border-white/[0.06] flex-shrink-0 space-y-2",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-lg tracking-wide text-zinc-200",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"Inbox"}),d>0&&y.jsxs(Pt,{variant:"default",children:[d," unread"]})]}),y.jsx("div",{className:"flex gap-1",children:["all","unread"].map(A=>y.jsx("button",{type:"button",onClick:()=>{c(A),a(new Set)},className:`flex-1 py-1 text-[11px] font-mono rounded-lg transition-colors cursor-pointer ${o===A?"text-[#E43A9C]":"text-zinc-600 hover:text-zinc-300"}`,style:o===A?{background:"rgba(228,58,156,0.12)"}:void 0,children:A},A))})]}),m&&y.jsxs("div",{className:"px-3 py-2 border-b border-white/[0.06] flex items-center gap-1.5 flex-shrink-0",style:{background:"rgba(228,58,156,0.06)"},children:[y.jsxs("span",{className:"text-[10px] font-mono text-zinc-500 flex-1",children:[i.size," selected"]}),y.jsxs("button",{type:"button",onClick:x,className:"flex items-center gap-1 px-2 py-1 rounded-lg text-[10px] font-mono text-zinc-400 hover:text-zinc-200 hover:bg-white/[0.06] transition-colors cursor-pointer",children:[y.jsx(Qb,{className:"w-3 h-3"}),"Mark read"]}),y.jsxs("button",{type:"button",onClick:k,className:"flex items-center gap-1 px-2 py-1 rounded-lg text-[10px] font-mono text-red-400 hover:text-red-300 hover:bg-red-500/10 transition-colors cursor-pointer",children:[y.jsx(Da,{className:"w-3 h-3"}),"Delete"]})]}),p.length>0&&y.jsxs("div",{className:"px-4 py-1.5 border-b border-white/[0.04] flex items-center gap-2 flex-shrink-0",children:[y.jsx("button",{type:"button",onClick:w,className:`w-3.5 h-3.5 rounded border flex items-center justify-center flex-shrink-0 transition-colors cursor-pointer ${f?"border-[#E43A9C] bg-[#E43A9C]":"border-white/20 hover:border-white/40"}`,children:f&&y.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",viewBox:"0 0 8 8","aria-hidden":"true",children:y.jsx("path",{d:"M1 4l2 2 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),y.jsx("span",{className:"text-[10px] font-mono text-zinc-700",children:"Select all"})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p.map(A=>{const C=i.has(A.id),T=(r==null?void 0:r.id)===A.id&&!m;return y.jsxs("div",{onClick:()=>v(A),onKeyDown:O=>O.key==="Enter"&&v(A),className:`flex items-start gap-2.5 px-3 py-3 border-b border-white/[0.04] cursor-pointer transition-colors ${T?"border-l-2 border-l-[#E43A9C] pl-2.5":"hover:bg-white/[0.025]"} ${C?"bg-[#E43A9C]/5":""}`,style:T?{background:"rgba(228,58,156,0.05)"}:void 0,children:[y.jsx("button",{type:"button",onClick:O=>b(O,A.id),className:`mt-0.5 w-3.5 h-3.5 rounded border flex items-center justify-center flex-shrink-0 transition-colors cursor-pointer ${C?"border-[#E43A9C] bg-[#E43A9C]":"border-white/20 hover:border-white/50"}`,children:C&&y.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",viewBox:"0 0 8 8","aria-hidden":"true",children:y.jsx("path",{d:"M1 4l2 2 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[mc(A)&&y.jsx("div",{className:"w-1 h-1 rounded-full bg-[#E43A9C] flex-shrink-0"}),y.jsx(KE,{name:A.squadName??(A.squadId?A.squadId.slice(0,8):"Orchestrator"),color:A.squadColor})]}),y.jsx("p",{className:`text-[11px] truncate ${mc(A)?"text-zinc-200":"text-zinc-500"}`,children:A.title}),y.jsx("p",{className:"text-[10px] text-zinc-700 font-mono mt-1",children:Fs(A.createdAt,u)})]})]},A.id)}),p.length===0&&y.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[y.jsx(ex,{size:32,className:"text-zinc-800 mb-2"}),y.jsx("p",{className:"text-[11px] font-mono text-zinc-700",children:o==="unread"?"All caught up":"No items yet"})]})]})]}),y.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:r&&!m?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"px-6 py-4 border-b border-white/[0.06] flex items-start justify-between flex-shrink-0",children:[y.jsxs("div",{className:"flex-1 min-w-0 mr-4",children:[y.jsx(KE,{name:r.squadName??(r.squadId?r.squadId.slice(0,8):"Orchestrator"),color:r.squadColor}),y.jsx("h3",{className:"text-sm font-mono text-zinc-100 mt-1.5",children:r.title}),y.jsx("p",{className:"text-[11px] text-zinc-700 font-mono mt-0.5",children:Fs(r.createdAt,u)})]}),y.jsxs("button",{type:"button",onClick:()=>S(r.id),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg font-mono text-[11px] text-zinc-400 bg-[#252525] hover:bg-red-500/10 hover:text-red-400 transition-colors cursor-pointer",children:[y.jsx(Da,{className:"w-3 h-3"}),"Delete"]})]}),y.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:y.jsx($u,{content:r.content})})]}):m?y.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 text-center px-8",children:[y.jsx("div",{className:"w-10 h-10 rounded-2xl flex items-center justify-center border border-[#E43A9C]/20",style:{background:"rgba(228,58,156,0.08)"},children:y.jsx(ex,{className:"w-4 h-4 text-[#E43A9C]"})}),y.jsxs("div",{children:[y.jsxs("p",{className:"text-sm font-mono text-zinc-300",children:[i.size," message",i.size!==1?"s":""," selected"]}),y.jsx("p",{className:"text-[11px] text-zinc-600 mt-1",children:"Use the actions above to mark as read or delete"})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsxs("button",{type:"button",onClick:x,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-mono text-zinc-300 border border-white/[0.1] hover:bg-white/[0.05] transition-colors cursor-pointer",children:[y.jsx(Qb,{className:"w-3 h-3"}),"Mark read"]}),y.jsxs("button",{type:"button",onClick:k,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-mono text-red-400 border border-red-500/20 hover:bg-red-500/10 transition-colors cursor-pointer",children:[y.jsx(Da,{className:"w-3 h-3"}),"Delete selected"]})]})]}):y.jsx("div",{className:"flex-1 flex items-center justify-center text-zinc-700 font-mono text-xs",children:"Select an item to read"})})]})}function Lq(){const{signIn:t}=mp(),[e,r]=j.useState(""),[n,i]=j.useState(""),[a,o]=j.useState(null),[c,u]=j.useState(!1);async function d(p){p.preventDefault(),o(null),u(!0);const{error:f}=await t(e,n);f&&o(f),u(!1)}return y.jsxs("div",{className:"min-h-screen bg-[#161616] flex items-center justify-center relative overflow-hidden",children:[y.jsx("div",{className:"absolute inset-0 opacity-[0.04]",style:{backgroundImage:"radial-gradient(circle, #E43A9C 1px, transparent 1px)",backgroundSize:"32px 32px"}}),y.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-[60%] w-[400px] h-[300px] rounded-full blur-3xl pointer-events-none",style:{background:"radial-gradient(ellipse, rgba(228,58,156,0.12) 0%, transparent 70%)"}}),y.jsxs("div",{className:"relative z-10 w-full max-w-[360px] mx-4",children:[y.jsxs("div",{className:"flex flex-col items-center mb-8 gap-3",children:[y.jsx(Ia,{height:52}),y.jsx("div",{className:"text-center",children:y.jsx("p",{className:"text-[11px] font-mono text-zinc-600 tracking-widest uppercase mt-1",children:"personal ai orchestrator"})})]}),y.jsxs("form",{onSubmit:d,className:"glass-card border border-white/[0.07] rounded-2xl p-6 space-y-4",children:[y.jsxs("div",{className:"space-y-1",children:[y.jsx("label",{htmlFor:"login-email",className:"text-[11px] font-mono text-zinc-500 block",children:"Email"}),y.jsx("input",{id:"login-email",type:"email",value:e,onChange:p=>r(p.target.value),required:!0,className:"w-full bg-[#161616] border border-white/[0.08] rounded-xl px-3 py-2.5 text-sm text-zinc-200 font-mono placeholder:text-zinc-700 focus:outline-none focus:border-[#E43A9C]/40 focus:ring-1 focus:ring-[#E43A9C]/15 transition-colors"})]}),y.jsxs("div",{className:"space-y-1",children:[y.jsx("label",{htmlFor:"login-password",className:"text-[11px] font-mono text-zinc-500 block",children:"Password"}),y.jsx("input",{id:"login-password",type:"password",value:n,onChange:p=>i(p.target.value),required:!0,placeholder:"••••••••",className:"w-full bg-[#161616] border border-white/[0.08] rounded-xl px-3 py-2.5 text-sm text-zinc-200 font-mono placeholder:text-zinc-700 focus:outline-none focus:border-[#E43A9C]/40 focus:ring-1 focus:ring-[#E43A9C]/15 transition-colors"})]}),a&&y.jsx("p",{className:"text-[11px] font-mono text-red-400",children:a}),y.jsx("button",{type:"submit",disabled:c,className:"w-full text-white font-mono text-sm rounded-xl py-3 mt-1 transition-opacity hover:opacity-90 disabled:opacity-50 flex items-center justify-center gap-2",style:{background:"linear-gradient(135deg, #D83333 0%, #E43A9C 55%, #F041FF 100%)"},children:c?y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Authenticating…"]}):"Sign In"})]}),y.jsx("p",{className:"text-center text-[11px] text-zinc-700 font-mono mt-4",children:"Secured by Supabase Auth"})]})]})}const jR="w-full bg-[#161616] border border-white/[0.08] rounded-xl px-3 py-2 text-[11px] text-zinc-300 font-mono placeholder:text-zinc-700 focus:outline-none focus:border-[#E43A9C]/40 focus:ring-1 focus:ring-[#E43A9C]/10 transition-colors",Ls="bg-[#161616] border border-white/[0.08] rounded-xl px-3 py-2 text-[11px] text-zinc-300 font-mono placeholder:text-zinc-700 focus:outline-none focus:border-[#E43A9C]/40 focus:ring-1 focus:ring-[#E43A9C]/10 transition-colors";function Fi({label:t,hint:e,align:r="center",children:n}){const i=r==="start"?"flex-1 min-w-0":"flex-1 flex justify-end items-center";return y.jsxs("div",{className:`glass-card border border-white/[0.07] rounded-2xl px-4 py-3.5 flex gap-4 ${r==="start"?"items-start":"items-center"}`,children:[y.jsxs("div",{className:"w-[140px] shrink-0",children:[y.jsx("span",{className:"text-[11px] font-mono text-zinc-400",children:t}),e&&y.jsxs("span",{className:"text-[10px] font-mono text-zinc-700 ml-1.5",children:["(",e,")"]})]}),y.jsx("div",{className:i,children:n})]})}function zq({onSave:t,onCancel:e,squads:r}){var b;const[n,i]=j.useState("io"),[a,o]=j.useState(((b=r[0])==null?void 0:b.id)??""),[c,u]=j.useState(""),[d,p]=j.useState(""),[f,m]=j.useState(""),v=()=>{!d.trim()||!f.trim()||!c.trim()||t({name:c.trim(),targetType:n==="io"?"orchestrator":"squad",targetId:n==="squad"?a:void 0,cron:d.trim(),prompt:f.trim()})};return y.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center p-6",style:{background:"rgba(0,0,0,0.55)",backdropFilter:"blur(4px)"},children:y.jsxs("div",{className:"glass-card border border-white/[0.09] rounded-2xl w-full max-w-lg shadow-2xl flex flex-col",style:{maxHeight:"90vh"},children:[y.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/[0.06] flex-shrink-0",children:[y.jsx("h3",{className:"text-lg tracking-wide text-zinc-100",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"New Schedule"}),y.jsx("button",{type:"button",onClick:e,className:"p-1.5 rounded-lg text-zinc-600 hover:text-zinc-300 hover:bg-white/[0.06] transition-colors cursor-pointer",children:y.jsx(UP,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"overflow-y-auto flex-1 px-5 py-4 space-y-2",children:[y.jsx(Fi,{label:"Name",children:y.jsx("input",{value:c,onChange:w=>u(w.target.value),placeholder:"Daily triage",className:`${Ls} w-48`})}),y.jsx(Fi,{label:"Type",children:y.jsx("div",{className:"flex gap-2",children:["io","squad"].map(w=>y.jsx("button",{type:"button",onClick:()=>i(w),className:`px-4 py-1.5 rounded-xl text-[11px] font-mono capitalize transition-colors border cursor-pointer ${n===w?"text-[#E43A9C] border-[#E43A9C]/30":"text-zinc-500 border-white/[0.08] hover:text-zinc-300 hover:bg-white/[0.04]"}`,style:n===w?{background:"rgba(228,58,156,0.08)"}:void 0,children:w==="io"?"IO":"Squad"},w))})}),n==="squad"&&y.jsx(Fi,{label:"Squad",children:y.jsx("select",{value:a,onChange:w=>o(w.target.value),className:`${Ls} w-48`,children:r.map(w=>y.jsx("option",{value:w.id,style:{background:"#1a1a1a",color:"#d4d4d8"},children:w.name},w.id))})}),y.jsx(Fi,{label:"Cron Expression",children:y.jsx("input",{value:d,onChange:w=>p(w.target.value),placeholder:"0 9 * * 1-5",className:`${Ls} w-40`})}),y.jsx(Fi,{label:"Prompt",hint:"supports Markdown",align:"start",children:y.jsx("textarea",{value:f,onChange:w=>m(w.target.value),placeholder:"Describe what IO or the squad should do when this schedule fires.",rows:8,className:`${jR} resize-none leading-relaxed`})})]}),y.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-white/[0.06] flex-shrink-0",children:[y.jsx(wi,{onClick:e,children:"Cancel"}),y.jsxs(Ba,{onClick:v,className:"px-4 py-1.5",children:[y.jsx(cp,{className:"w-3 h-3"}),"Create Schedule"]})]})]})})}function Bq({sched:t,squads:e,onSave:r,onBack:n}){var b,w;const[i,a]=j.useState(t.name),[o,c]=j.useState(t.cron),[u,d]=j.useState(t.prompt),[p,f]=j.useState(t.targetId??((b=e[0])==null?void 0:b.id)??""),m=()=>{!o.trim()||!u.trim()||!i.trim()||r({name:i.trim(),cron:o.trim(),prompt:u.trim(),targetId:t.targetType==="squad"?p:void 0})},v=t.targetType==="orchestrator"?"IO Schedule":`Squad — ${((w=e.find(x=>x.id===t.targetId))==null?void 0:w.name)??"Unknown"}`;return y.jsxs("div",{className:"flex-1 overflow-y-auto p-6 max-w-3xl",children:[y.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[y.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1.5 text-[11px] font-mono text-zinc-600 hover:text-zinc-300 transition-colors cursor-pointer",children:[y.jsx(vl,{className:"w-3.5 h-3.5"}),"Schedules"]}),y.jsx("span",{className:"text-zinc-700 text-[11px]",children:"/"}),y.jsx("span",{className:"text-[11px] font-mono text-zinc-400",children:"Edit"})]}),y.jsxs("div",{className:"flex items-start justify-between mb-6",children:[y.jsxs("div",{children:[y.jsx("h2",{className:"text-2xl tracking-wide text-zinc-100",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"Edit Schedule"}),y.jsx("p",{className:"text-[11px] font-mono text-zinc-600 mt-0.5",children:v})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(wi,{onClick:n,children:"Cancel"}),y.jsxs(Ba,{onClick:m,className:"px-4 py-1.5",children:[y.jsx(cp,{className:"w-3 h-3"}),"Save Changes"]})]})]}),y.jsxs("div",{className:"space-y-3",children:[y.jsx(Fi,{label:"Name",children:y.jsx("input",{value:i,onChange:x=>a(x.target.value),placeholder:"Schedule name",className:`${Ls} w-48`})}),t.targetType==="squad"&&y.jsx(Fi,{label:"Squad",children:y.jsx("select",{value:p,onChange:x=>f(x.target.value),className:`${Ls} w-48`,children:e.map(x=>y.jsx("option",{value:x.id,style:{background:"#1a1a1a",color:"#d4d4d8"},children:x.name},x.id))})}),y.jsx(Fi,{label:"Cron Expression",children:y.jsx("input",{value:o,onChange:x=>c(x.target.value),placeholder:"0 9 * * 1-5",className:`${Ls} w-40`})}),y.jsx(Fi,{label:"Prompt",hint:"supports Markdown",align:"start",children:y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("textarea",{value:u,onChange:x=>d(x.target.value),placeholder:"Describe what IO or the squad should do when this schedule fires.",className:`${jR} leading-relaxed resize-y`,style:{minHeight:"360px"}}),y.jsx("p",{className:"text-[10px] font-mono text-zinc-700",children:"Tip: use # headings and - lists to structure multi-step instructions."})]})})]})]})}function Uq(){const[t,e]=j.useState("squad"),[r,n]=j.useState([]),[i,a]=j.useState([]),[o,c]=j.useState(!1),[u,d]=j.useState(null),p=Fa();j.useEffect(()=>{f(),m()},[]);function f(){Ge.get("/schedules").then(R=>n(R.schedules)).catch(()=>{})}function m(){Ge.get("/squads").then(R=>a(R.squads)).catch(()=>{})}const v=r.filter(R=>R.targetType==="squad"),b=r.filter(R=>R.targetType==="orchestrator"),w=t==="squad"?v:b;async function x(R){try{await Ge.post("/schedules",R),Qe.success("Schedule created"),c(!1),f()}catch($){Qe.error($ instanceof Error?$.message:"Failed to create")}}async function k(R){if(u)try{await Ge.patch(`/schedules/${u.id}`,R),Qe.success("Schedule saved"),d(null),f()}catch{Qe.error("Failed to save schedule")}}const[S,A]=j.useState(null);async function C(R,$){A(R);try{await Ge.patch(`/schedules/${R}`,{enabled:!$}),Qe.success($?"Schedule paused":"Schedule resumed"),f()}catch{Qe.error("Failed to toggle schedule")}finally{A(null)}}async function T(R){A(R);try{await Ge.post(`/schedules/${R}/run`,{}),Qe.success("Schedule triggered")}catch{Qe.error("Failed to trigger schedule")}finally{A(null)}}async function O(R){A(R);try{await Ge.delete(`/schedules/${R}`),Qe.success("Schedule deleted"),f()}catch{Qe.error("Failed to delete")}finally{A(null)}}if(u)return y.jsx(Bq,{sched:u,squads:i,onSave:k,onBack:()=>d(null)});const N=t==="squad"?["Squad","Name","Cron","Next Run","Status",""]:["Name","Cron","Next Run","Status",""];return y.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[o&&y.jsx(zq,{onSave:x,onCancel:()=>c(!1),squads:i}),y.jsxs("div",{className:"flex items-center justify-between mb-5",children:[y.jsxs("div",{children:[y.jsx("h2",{className:"text-2xl tracking-wide text-zinc-100",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"Schedules"}),y.jsxs("p",{className:"text-[11px] text-zinc-600 font-mono mt-0.5",children:[r.filter(R=>R.enabled).length," active ·"," ",r.filter(R=>!R.enabled).length," paused"]})]}),y.jsxs(Ba,{onClick:()=>c(!0),className:"px-3 py-1.5",children:[y.jsx(i1,{className:"w-3.5 h-3.5"}),"Add Schedule"]})]}),y.jsx("div",{className:"flex gap-1 mb-4",children:[["squad","Squad Schedules"],["io","IO Schedules"]].map(([R,$])=>y.jsx("button",{type:"button",onClick:()=>e(R),className:`px-4 py-2 text-[11px] font-mono rounded-xl transition-colors cursor-pointer ${t===R?"text-[#E43A9C]":"text-zinc-600 hover:text-zinc-300 hover:bg-white/[0.04]"}`,style:t===R?{background:"rgba(228,58,156,0.12)"}:void 0,children:$},R))}),y.jsx("div",{className:"overflow-x-auto rounded-2xl border border-white/[0.07] glass-card",children:w.length===0?y.jsx("div",{className:"px-4 py-12 text-center text-zinc-600 font-mono text-sm",children:"No schedules for this category"}):y.jsxs("table",{className:"w-full text-[11px] font-mono min-w-[640px]",children:[y.jsx("thead",{children:y.jsx("tr",{className:"border-b border-white/[0.06]",style:{background:"rgba(20,20,20,0.6)"},children:N.map(R=>y.jsx("th",{className:"text-left px-4 py-2.5 text-zinc-600 font-medium",children:R},R))})}),y.jsx("tbody",{children:w.map(R=>{var $,K;return y.jsxs("tr",{className:`border-b border-white/[0.04] hover:bg-white/[0.015] transition-colors ${R.enabled?"":"opacity-50"}`,children:[t==="squad"?y.jsx("td",{className:"px-4 py-3",children:y.jsx(LB,{name:(($=i.find(L=>L.id===R.targetId))==null?void 0:$.name)??"Unknown",color:(K=i.find(L=>L.id===R.targetId))==null?void 0:K.color})}):null,y.jsx("td",{className:"px-4 py-3 text-zinc-300",children:R.name}),y.jsx("td",{className:"px-4 py-3 text-zinc-600 text-[10px]",children:R.cron}),y.jsx("td",{className:"px-4 py-3 text-zinc-600",children:y.jsxs("span",{className:"flex items-center gap-1",children:[y.jsx(e1,{className:"w-3 h-3"}),R.enabled&&R.nextRun?Fs(R.nextRun,p):"—"]})}),y.jsx("td",{className:"px-4 py-3",children:y.jsx(Pt,{variant:R.enabled?"success":"muted",children:R.enabled?"active":"paused"})}),y.jsx("td",{className:"px-4 py-3",children:y.jsxs("div",{className:`flex items-center gap-1 ${S===R.id?"opacity-50 pointer-events-none":""}`,children:[y.jsxs(wi,{onClick:()=>T(R.id),children:[y.jsx(oB,{className:"w-3 h-3"}),"Run now"]}),y.jsx(zB,{onClick:()=>C(R.id,R.enabled),children:R.enabled?y.jsxs(y.Fragment,{children:[y.jsx(tB,{className:"w-3 h-3"}),"Pause"]}):y.jsxs(y.Fragment,{children:[y.jsx(qf,{className:"w-3 h-3"}),"Resume"]})}),y.jsxs(wi,{onClick:()=>d(R),children:[y.jsx(nB,{className:"w-3 h-3"}),"Edit"]}),y.jsxs(Gf,{onClick:()=>O(R.id),children:[y.jsx(Da,{className:"w-3 h-3"}),"Delete"]})]})})]},R.id)})})]})})]})}const qq=[{id:"general",label:"General"},{id:"telegram",label:"Telegram"},{id:"auth",label:"Auth"}],Bo="rounded-xl border border-white/[0.07] bg-white/[0.04] px-3 py-2 text-sm font-mono text-zinc-300 outline-none focus:border-[#E43A9C]/50",GE=`${Bo} w-[72px]`,Fq=`${Bo} w-[100px]`,VE=`${Bo} w-[200px]`,XE=`${Bo} w-[320px]`,Hq=`${Bo} w-[140px] appearance-none bg-[url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20viewBox%3D%220%200%2012%2012%22%3E%3Cpath%20fill%3D%22%2371717a%22%20d%3D%22M3%204.5L6%208l3-3.5H3z%22%2F%3E%3C%2Fsvg%3E')] bg-[position:right_10px_center] bg-no-repeat pr-8`;function Wq(){const[t,e]=j.useState(null),[r,n]=j.useState("general");j.useEffect(()=>{Ge.get("/config").then(o=>e(o.config)).catch(()=>{})},[]);function i(o){t&&e({...t,...o})}async function a(){if(t)try{const{dataDir:o,...c}=t;await Ge.patch("/config",c),Qe.success("Settings saved")}catch{Qe.error("Failed to save settings")}}return t?y.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:y.jsxs("div",{className:"max-w-3xl",children:[y.jsx("h2",{className:"mb-6 text-2xl tracking-wide text-zinc-100",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"Settings"}),y.jsx("div",{className:"mb-6 flex gap-6 border-b border-white/[0.07]",children:qq.map(o=>y.jsx("button",{type:"button",onClick:()=>n(o.id),className:`-mb-px border-b-2 px-1 pb-3 text-[11px] font-mono transition-colors ${r===o.id?"border-[#E43A9C] text-[#E43A9C]":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:o.label},o.id))}),y.jsxs("div",{className:"glass-card rounded-2xl border border-white/[0.07] p-5",children:[r==="general"&&y.jsxs(y.Fragment,{children:[y.jsx(_n,{label:"Log Level",children:y.jsx("select",{value:t.logLevel,onChange:o=>i({logLevel:o.target.value}),className:Hq,children:["trace","debug","info","warn","error","fatal"].map(o=>y.jsx("option",{value:o,children:o},o))})}),y.jsx(_n,{label:"Default Model",children:y.jsx("input",{type:"text",value:t.defaultModel,onChange:o=>i({defaultModel:o.target.value}),className:VE})}),y.jsx(_n,{label:"Timezone",children:y.jsx("select",{value:t.timezone,onChange:o=>i({timezone:o.target.value}),className:`${Bo} w-[200px] appearance-none bg-[url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20viewBox%3D%220%200%2012%2012%22%3E%3Cpath%20fill%3D%22%2371717a%22%20d%3D%22M3%204.5L6%208l3-3.5H3z%22%2F%3E%3C%2Fsvg%3E')] bg-[position:right_10px_center] bg-no-repeat pr-8`,children:Q4.map(o=>y.jsx("option",{value:o.value,children:o.label},o.value))})}),y.jsx(_n,{label:"Max Instances",children:y.jsx("input",{type:"number",value:t.maxInstancesPerSquad,onChange:o=>i({maxInstancesPerSquad:Number(o.target.value)}),className:GE,min:1,max:10})}),y.jsx(_n,{label:"API Port",children:y.jsx("input",{type:"number",value:t.apiPort,onChange:o=>i({apiPort:Number(o.target.value)}),className:GE})}),y.jsx(_n,{label:"Pricing Refresh (hrs)",children:y.jsx("input",{type:"number",value:t.pricing.refreshIntervalHours,onChange:o=>i({pricing:{refreshIntervalHours:Number(o.target.value)}}),className:Fq,min:1})}),y.jsx(_n,{label:"Data Dir",children:y.jsx("input",{type:"text",value:t.dataDir,readOnly:!0,className:`${XE} cursor-default text-zinc-500`})})]}),r==="telegram"&&y.jsxs(y.Fragment,{children:[y.jsx(_n,{label:"Bot Token",children:y.jsx(Wg,{value:t.telegram.botToken??"",onChange:o=>i({telegram:{...t.telegram,botToken:o||null}}),size:"lg"})}),y.jsx(_n,{label:"Allowed Chat IDs",children:y.jsx("input",{type:"text",value:t.telegram.allowedChatIds.join(", "),onChange:o=>i({telegram:{...t.telegram,allowedChatIds:o.target.value.split(",").map(c=>Number(c.trim())).filter(c=>!Number.isNaN(c))}}),className:VE})})]}),r==="auth"&&y.jsxs(y.Fragment,{children:[y.jsx(_n,{label:"Project URL",children:y.jsx("input",{type:"text",value:t.supabase.projectUrl??"",onChange:o=>i({supabase:{...t.supabase,projectUrl:o.target.value||null}}),className:XE})}),y.jsx(_n,{label:"Anon Key",children:y.jsx(Wg,{value:t.supabase.anonKey??"",onChange:o=>i({supabase:{...t.supabase,anonKey:o||null}}),size:"lg"})}),y.jsx(_n,{label:"JWT Secret",children:y.jsx(Wg,{value:t.supabase.jwtSecret??"",onChange:o=>i({supabase:{...t.supabase,jwtSecret:o||null}}),size:"lg"})})]}),y.jsx("div",{className:"flex justify-end pt-6",children:y.jsx(Ba,{onClick:a,className:"px-4 py-2.5",children:"Save Settings"})})]})]})}):y.jsx("div",{className:"flex h-full items-center justify-center text-zinc-600",children:"Loading..."})}function _n({label:t,children:e}){return y.jsxs("div",{className:"flex items-center justify-between gap-6 border-b border-white/[0.07] py-3",children:[y.jsx("span",{className:"text-[11px] font-mono text-zinc-400 shrink-0",children:t}),y.jsx("div",{className:"flex justify-end",children:e})]})}function Wg({value:t,onChange:e,size:r="lg"}){const[n,i]=j.useState(!1),a=r==="lg"?"w-[320px]":"w-[200px]";return y.jsxs("div",{className:"relative",children:[y.jsx("input",{type:n?"text":"password",value:t,onChange:o=>e(o.target.value),className:`${Bo} ${a} pr-9`}),y.jsx("button",{type:"button",onClick:()=>i(o=>!o),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-zinc-600 transition-colors hover:text-zinc-400","aria-label":n?"Hide value":"Show value",children:n?y.jsx(Iz,{size:14}):y.jsx(Qb,{size:14})})]})}function gf(t){return"url"in t&&t.url?t.url:t.name}const Kq=[{id:"installed",label:"Installed"},{id:"awesome-copilot",label:"Awesome Copilot"},{id:"skillssh",label:"skills.sh"}];function YE(t){return t==="awesome-copilot"?"Awesome Copilot":"skills.sh"}function JE(t){return t?t>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M installs`:t>=1e3?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}K installs`:`${t} installs`:null}function Gq(t){const e=t.match(/^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/);if(!e)return{frontMatter:{},body:t};const r=e[1]??"",n=e[2]??"",i={};let a="",o=null;for(const c of r.split(`
|
|
449
449
|
`)){const u=c.match(/^(\w[\w-]*)\s*:\s*(.*)$/);if(u){a&&o&&(i[a]=o,o=null),a=u[1]??"";const d=(u[2]??"").trim();d===""||d==="[]"?o=[]:d.startsWith("[")&&d.endsWith("]")?i[a]=d.slice(1,-1).split(",").map(p=>p.trim().replace(/^["']|["']$/g,"")):i[a]=d.replace(/^["']|["']$/g,"")}else c.match(/^\s+-\s+(.+)/)&&a&&(o||(o=[]),o.push(c.replace(/^\s+-\s+/,"").trim()))}return a&&o&&(i[a]=o),{frontMatter:i,body:n}}const ZE=["name","description","version","author","license","argument_hint","argument-hint","use_when","use-when","enhancements","metadata","tags"];function Vq({content:t}){const{frontMatter:e,body:r}=Gq(t),n=ZE.filter(o=>e[o]!==void 0),i=Object.keys(e).filter(o=>!ZE.includes(o)),a=[...n,...i];return y.jsxs("div",{children:[a.length>0&&y.jsxs("div",{className:"border-b border-white/[0.05] pb-4 mb-4",children:[y.jsx("p",{className:"text-[10px] font-mono text-zinc-700 uppercase tracking-wider mb-3",children:"Front Matter"}),y.jsx("div",{className:"space-y-2",children:a.map(o=>{const c=e[o];return c==null||Array.isArray(c)&&c.length===0?null:y.jsxs("div",{className:"flex gap-3 items-start",children:[y.jsx("span",{className:"text-[10px] font-mono text-zinc-600 w-28 flex-shrink-0 pt-0.5",children:o}),y.jsx("div",{className:"flex-1 min-w-0",children:Array.isArray(c)?y.jsx("div",{className:"flex flex-wrap gap-1",children:c.map(u=>y.jsx(Pt,{variant:"muted",children:u},`${o}-${u}`))}):typeof c=="object"?y.jsx("div",{className:"space-y-0.5",children:Object.entries(c).map(([u,d])=>y.jsxs("p",{className:"text-[11px] font-mono text-zinc-400",children:[y.jsxs("span",{className:"text-zinc-600",children:[u,":"]})," ",d]},u))}):o==="use_when"||o==="use-when"?y.jsx("p",{className:"text-[11px] text-zinc-300 leading-relaxed",children:c}):o==="argument_hint"||o==="argument-hint"?y.jsx("code",{className:"text-[11px] font-mono text-[#E43A9C] bg-[#2d1a24] px-1.5 py-0.5 rounded",children:c}):y.jsx("span",{className:"text-[11px] font-mono text-zinc-300",children:c})})]},o)})})]}),r.trim()&&y.jsxs("div",{children:[y.jsx("p",{className:"text-[10px] font-mono text-zinc-700 uppercase tracking-wider mb-3",children:"Body"}),y.jsx($u,{content:r})]})]})}function Xq(){const[t,e]=j.useState("installed"),[r,n]=j.useState([]),[i,a]=j.useState([]),[o,c]=j.useState(null),[u,d]=j.useState(null),[p,f]=j.useState(""),[m,v]=j.useState(!1),[b,w]=j.useState(!1),[x,k]=j.useState(!1),[S,A]=j.useState(""),[C,T]=j.useState(null),[O,N]=j.useState(null),R=j.useCallback(async()=>{try{const I=await Ge.get("/skills"),B=new Set(I.skills.map(J=>J.name.toLowerCase()));n(I.skills),a(J=>J.map(oe=>({...oe,installed:B.has(oe.name.toLowerCase())})))}catch(I){Qe.error(I instanceof Error?I.message:"Failed to load skills")}},[]),$=j.useCallback(async I=>{w(!0);try{const B=await Ge.get(`/skills/${encodeURIComponent(I)}`);d(B),A(B.content)}catch(B){Qe.error(B instanceof Error?B.message:"Failed to load skill"),d(null)}finally{w(!1)}},[]);j.useEffect(()=>{R()},[R]),j.useEffect(()=>{if(t==="installed"){N(null);return}const I=p.trim();if(t==="skillssh"&&!I){a([]),N(null),v(!1);return}let B=!1;v(!0);const J=window.setTimeout(async()=>{try{const oe=await Ge.get(`/skills/discover?source=${t}&q=${encodeURIComponent(I)}`);if(B)return;a(oe.skills),N(null)}catch(oe){if(B)return;a([]),N(oe instanceof Error?oe.message:"Discovery failed")}finally{B||v(!1)}},250);return()=>{B=!0,window.clearTimeout(J)}},[p,t]);const K=j.useMemo(()=>{const I=p.trim().toLowerCase();return I?r.filter(B=>[B.name,B.description,B.preview].some(J=>J.toLowerCase().includes(I))):r},[r,p]),L=t==="installed"?K:i,U=K.find(I=>I.name===o)??null,F=i.find(I=>gf(I)===o)??null,X=(U==null?void 0:U.name)??(F==null?void 0:F.name)??null;j.useEffect(()=>{if(k(!1),!L.length){c(null),t!=="installed"&&d(null);return}if(!o||!L.some(I=>gf(I)===o)){const I=L[0];I&&c(gf(I))}},[o,t,L]),j.useEffect(()=>{if(t!=="installed"||!X){d(null);return}$(X)},[$,X,t]);async function Y(I){if(!I.url&&!I.registrySource){Qe.error("Install source is not available for this skill yet");return}T(I.name);try{await Ge.post("/skills/install",{name:I.name,source:I.source,url:I.url,registrySource:I.registrySource,skillId:I.skillId}),Qe.success(`Installed ${I.title||I.name}`),await R(),a(B=>B.map(J=>J.name===I.name?{...J,installed:!0}:J))}catch(B){Qe.error(B instanceof Error?B.message:"Install failed")}finally{T(null)}}async function G(I){T(I);try{await Ge.delete(`/skills/${encodeURIComponent(I)}`),Qe.success(`Removed ${I}`),await R(),a(B=>B.map(J=>J.name===I?{...J,installed:!1}:J))}catch(B){Qe.error(B instanceof Error?B.message:"Failed to remove skill")}finally{T(null)}}async function Q(){if(u){T(u.name);try{await Ge.put(`/skills/${encodeURIComponent(u.name)}`,{content:S}),Qe.success(`Updated ${u.name}`),k(!1),await Promise.all([R(),$(u.name)])}catch(I){Qe.error(I instanceof Error?I.message:"Failed to save skill")}finally{T(null)}}}const W=!!(U!=null&&U.activatedForOrchestrator),ee=C===(u==null?void 0:u.name),q=C===(F==null?void 0:F.name);return y.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[y.jsxs("div",{className:"w-64 flex-shrink-0 border-r border-white/[0.06] flex flex-col overflow-hidden",children:[y.jsxs("div",{className:"px-2.5 pt-2.5 pb-2 flex-shrink-0 border-b border-white/[0.06] space-y-2",children:[y.jsxs("div",{className:"relative",children:[y.jsx(LP,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3 w-3 -translate-y-1/2 text-zinc-700"}),y.jsx("input",{type:"text",value:p,onChange:I=>f(I.target.value),placeholder:"Search skills…",className:"w-full bg-[#181818] border border-white/[0.06] rounded-xl pl-7 pr-2 py-1.5 text-[11px] text-zinc-300 font-mono placeholder:text-zinc-700 focus:outline-none focus:border-[#E43A9C]/30 transition-colors"})]}),y.jsx("div",{className:"flex flex-col gap-0.5",children:Kq.map(I=>y.jsxs("button",{type:"button",onClick:()=>e(I.id),className:`w-full text-left px-2.5 py-1.5 rounded-lg text-[11px] font-mono transition-colors flex items-center justify-between cursor-pointer ${t===I.id?"text-[#E43A9C]":"text-zinc-500 hover:text-zinc-300 hover:bg-white/[0.04]"}`,style:t===I.id?{background:"rgba(228,58,156,0.10)"}:void 0,children:[y.jsx("span",{children:I.label}),I.id==="installed"&&y.jsx("span",{className:"text-[10px] text-zinc-600",children:r.length})]},I.id))})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto py-1.5",children:[m&&t!=="installed"?y.jsxs("div",{className:"flex items-center gap-2 rounded-2xl border border-white/[0.08] bg-white/[0.03] px-3 py-3 font-mono text-[11px] text-zinc-500",children:[y.jsx(Ts,{className:"h-3.5 w-3.5 animate-spin"})," Searching registry..."]}):null,L.map(I=>{const B=gf(I),J=o===B,oe=I.description||("preview"in I?I.preview:"No description available.");return y.jsxs("button",{type:"button",onClick:()=>{k(!1),c(B)},className:`w-full text-left px-3 py-2.5 border-b border-white/[0.03] transition-colors cursor-pointer ${J?"border-l-2 border-l-[#E43A9C] bg-[#E43A9C]/5":"hover:bg-white/[0.03]"}`,children:[y.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[y.jsx("span",{className:"truncate font-mono text-[11px] text-zinc-200",children:I.name}),"installed"in I&&I.installed?y.jsx(Pt,{variant:"success",children:"installed"}):null]}),y.jsx("p",{className:"line-clamp-2 font-mono text-[10px] leading-relaxed text-zinc-600",children:oe})]},`${t}:${B}`)}),!m&&L.length===0?y.jsx("div",{className:"px-4 py-8",children:y.jsx("p",{className:"font-mono text-[11px] leading-relaxed text-zinc-500",children:O||(t==="skillssh"&&!p.trim()?"Start typing to search the skills.sh registry.":p.trim()?"No skills match your search.":"No skills available in this source.")})}):null]})]}),y.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto p-5",children:t==="installed"&&U?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4 border-b border-white/[0.06] pb-5",children:[y.jsxs("div",{className:"flex min-w-0 gap-4",children:[y.jsx("div",{className:"flex h-14 w-14 shrink-0 items-center justify-center rounded-2xl bg-[#E43A9C]/12 text-[#E43A9C]",children:y.jsx(tx,{className:"h-6 w-6"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h3",{className:"truncate text-[34px] uppercase tracking-[0.08em] text-zinc-100",style:{fontFamily:"'Bebas Neue', sans-serif"},children:U.name}),y.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[y.jsx(Pt,{variant:"success",children:"installed"}),W?y.jsx(Pt,{variant:"warning",children:"active"}):y.jsx(Pt,{variant:"muted",children:"inactive"}),y.jsx(Pt,{variant:"muted",children:"local skill"})]}),y.jsxs("div",{className:"mt-3 space-y-1 font-mono text-[11px] text-zinc-500",children:[y.jsxs("p",{children:["path: ",U.filePath]}),y.jsxs("p",{children:["orchestrator: ",W?"enabled":"disabled"]})]})]})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[x?y.jsxs(Ba,{onClick:Q,disabled:ee||S===(u==null?void 0:u.content),className:"px-3 py-2",children:[ee?y.jsx(Ts,{className:"h-3.5 w-3.5 animate-spin"}):y.jsx(Ff,{className:"h-3.5 w-3.5"}),"Save"]}):y.jsxs(wi,{onClick:()=>k(!0),className:"px-3 py-2",children:[y.jsx(Ff,{className:"h-3.5 w-3.5"})," Edit"]}),y.jsxs(Gf,{onClick:()=>G(U.name),className:"px-3 py-2",children:[ee?y.jsx(Ts,{className:"h-3.5 w-3.5 animate-spin"}):y.jsx(Da,{className:"h-3.5 w-3.5"}),"Remove"]})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:b&&!u?y.jsxs("div",{className:"flex items-center gap-2 font-mono text-[11px] text-zinc-500",children:[y.jsx(Ts,{className:"h-3.5 w-3.5 animate-spin"})," Loading skill..."]}):x?y.jsxs("div",{className:"space-y-3",children:[y.jsx("textarea",{value:S,onChange:I=>A(I.target.value),className:"min-h-[440px] w-full rounded-2xl border border-white/[0.08] bg-black/30 p-4 font-mono text-[12px] leading-6 text-zinc-200 outline-none transition-colors focus:border-[#E43A9C]/50"}),y.jsxs("div",{className:"flex items-center justify-between font-mono text-[11px] text-zinc-500",children:[y.jsx("span",{children:"Editing raw SKILL.md"}),y.jsx(wi,{onClick:()=>{k(!1),A((u==null?void 0:u.content)??"")},className:"px-3 py-2",children:"Cancel"})]})]}):u?y.jsx(Vq,{content:u.content}):y.jsx("p",{className:"font-mono text-[11px] text-zinc-500",children:"Select an installed skill to inspect it."})})]}):t!=="installed"&&F?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4 border-b border-white/[0.06] pb-5",children:[y.jsxs("div",{className:"flex min-w-0 gap-4",children:[y.jsx("div",{className:"flex h-14 w-14 shrink-0 items-center justify-center rounded-2xl bg-[#E43A9C]/12 text-[#E43A9C]",children:y.jsx(gB,{className:"h-6 w-6"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h3",{className:"truncate text-[34px] uppercase tracking-[0.08em] text-zinc-100",style:{fontFamily:"'Bebas Neue', sans-serif"},children:F.title||F.name}),y.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[y.jsx(Pt,{variant:F.installed?"success":"default",children:F.installed?"installed":"available"}),y.jsx(Pt,{variant:"muted",children:YE(F.source)}),JE(F.installs)?y.jsx(Pt,{variant:"info",children:JE(F.installs)}):null]}),y.jsxs("div",{className:"mt-3 space-y-1 font-mono text-[11px] text-zinc-500",children:[y.jsxs("p",{children:["registry: ",YE(F.source)]}),F.registrySource?y.jsxs("p",{children:["source: ",F.registrySource]}):null,F.url?y.jsxs("p",{children:["url: ",F.url]}):null]})]})]}),y.jsx("div",{className:"flex items-center gap-2",children:F.installed?y.jsx(wi,{onClick:()=>{e("installed"),c(F.name)},className:"px-3 py-2",children:"Open installed"}):y.jsxs(Ba,{onClick:()=>Y(F),disabled:q||!F.url&&!F.registrySource,className:"px-3 py-2",children:[q?y.jsx(Ts,{className:"h-3.5 w-3.5 animate-spin"}):y.jsx(Nz,{className:"h-3.5 w-3.5"}),"Install"]})})]}),y.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[y.jsx("div",{className:"rounded-2xl border border-white/[0.06] bg-white/[0.02] p-5",children:y.jsx("p",{className:"font-mono text-[12px] leading-7 text-zinc-300",children:F.description||"No registry description is available for this skill yet."})}),y.jsx("div",{className:"mt-4 rounded-2xl border border-dashed border-white/[0.08] bg-black/20 p-4 font-mono text-[11px] leading-6 text-zinc-500",children:"Install will fetch the skill definition from the selected registry source and add it to your local skills library."})]})]}):y.jsx("div",{className:"flex h-full items-center justify-center rounded-2xl border border-dashed border-white/[0.08] bg-white/[0.02] p-8 text-center",children:y.jsxs("div",{children:[y.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-[#E43A9C]/12 text-[#E43A9C]",children:y.jsx(tx,{className:"h-6 w-6"})}),y.jsx("h3",{className:"text-[28px] uppercase tracking-[0.08em] text-zinc-100",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"Select a Skill"}),y.jsx("p",{className:"mt-2 font-mono text-[11px] leading-relaxed text-zinc-500",children:"Choose a skill from the left panel to inspect details, install registry entries, or edit local definitions."})]})})})]})}function $f(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);return`hsl(${(e%360+360)%360}, 70%, 65%)`}function yf(){const{name:t,instanceId:e,role:r}=hL();return t&&r?y.jsx(n9,{squadName:t,role:r}):t&&e?y.jsx(r9,{squadName:t,instanceId:e}):t?y.jsx(Zq,{name:t}):y.jsx(Yq,{})}function Yq(){const[t,e]=j.useState([]),[r,n]=j.useState(null),i=gl();return j.useEffect(()=>{Promise.all([Ge.get("/squads"),Ge.get("/config")]).then(([a,o])=>{e(a.squads),n(o.config.maxInstancesPerSquad)}).catch(()=>{})},[]),y.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[y.jsx("div",{className:"mb-6",children:y.jsxs("div",{children:[y.jsx("h2",{className:"text-2xl tracking-wide text-zinc-100",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"Squads"}),y.jsxs("p",{className:"text-[11px] text-zinc-600 font-mono mt-0.5",children:[t.length," squads · ",t.reduce((a,o)=>a+(o.activeInstances||0),0)," ","active instances"]})]})}),y.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:[t.map(a=>{var c;const o=a.color||"#38bdf8";return y.jsxs("button",{type:"button",onClick:()=>i(`/squads/${a.name}`),className:"text-left rounded-2xl p-5 transition-all group cursor-pointer",style:{border:`1px solid ${o}30`,background:`${o}08`,backdropFilter:"blur(20px)"},onMouseEnter:u=>{u.currentTarget.style.borderColor=`${o}70`,u.currentTarget.style.background=`${o}12`},onMouseLeave:u=>{u.currentTarget.style.borderColor=`${o}30`,u.currentTarget.style.background=`${o}08`},children:[y.jsxs("div",{className:"flex items-start justify-between mb-1",children:[y.jsx("h3",{className:"text-sm font-mono transition-colors",style:{color:o},children:a.name}),y.jsx(Pt,{variant:Ms(a.status),children:a.status})]}),y.jsxs("div",{className:"flex items-center justify-between mb-3",children:[y.jsx("p",{className:"text-[11px] text-zinc-600 font-mono",children:((c=a.config)==null?void 0:c.prMode)??"draft-pr"}),y.jsxs("span",{className:"text-[11px] text-zinc-600 font-mono flex items-center gap-1",children:[y.jsx(Tz,{className:"w-3 h-3"}),a.activeInstances,"/",r??(a.totalInstances||a.memberCount)]})]}),a.repoUrl&&y.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-zinc-700 font-mono mb-4",children:[y.jsx(r1,{className:"w-3 h-3 flex-shrink-0"}),y.jsx("span",{className:"truncate",children:a.repoUrl.replace("https://github.com/","")})]}),a.recentActivity&&a.recentActivity.length>0&&y.jsxs("div",{className:"border-t pt-3",style:{borderColor:`${o}15`},children:[y.jsx("p",{className:"text-[10px] font-mono uppercase tracking-wider mb-2",style:{color:`${o}80`},children:"Recent Work"}),y.jsx("ul",{className:"space-y-1.5",children:a.recentActivity.map(u=>{const d={className:"w-3.5 h-3.5 flex-shrink-0 mt-px"},p=Jq(u.status,d),f=u.objective?u.objective.length>60?`${u.objective.slice(0,60)}…`:u.objective:u.issueRef||"Instance";return y.jsxs("li",{className:"flex items-start gap-1.5 text-[11px] font-mono text-zinc-600",children:[p,y.jsx("span",{className:"truncate",children:f})]},u.id)})})]})]},a.id)}),t.length===0&&y.jsxs("div",{className:"col-span-full text-center py-12 text-zinc-600",children:[y.jsx(a1,{size:48,className:"mx-auto mb-3 opacity-30"}),y.jsx("p",{className:"text-[11px] font-mono",children:"No squads hired yet. Ask IO to hire a squad for a project."})]})]})]})}function Jq(t,e){const r=t.toLowerCase();return r.includes("complete")||r.includes("success")||r.includes("done")?y.jsx(RP,{...e,style:{color:"#34d399"}}):r.includes("warning")||r.includes("review")?y.jsx(wB,{...e,style:{color:"#fbbf24"}}):r.includes("error")||r.includes("fail")?y.jsx(IP,{...e,style:{color:"#f87171"}}):r.includes("working")||r.includes("progress")||r.includes("running")?y.jsx(MP,{...e,style:{color:"#E43A9C"}}):y.jsx(Wz,{...e,style:{color:"#60a5fa"}})}function Hs(t,e){const r="w-4 h-4",n={color:e},i=t.toLowerCase();return i.includes("lead")||i.includes("pm")||i.includes("technical")?y.jsx(t1,{className:r,style:n}):i.includes("qa")||i.includes("test")?y.jsx(mz,{className:r,style:n}):i.includes("scribe")?y.jsx(uB,{className:r,style:n}):y.jsx(qc,{className:r,style:n})}function Zq({name:t}){var k;const[e,r]=j.useState(null),[n,i]=j.useState("agents"),[a,o]=j.useState([]),[c,u]=j.useState(0),[d,p]=j.useState(null),[f,m]=j.useState([]),v=gl(),b=Fa();j.useEffect(()=>{Ge.get(`/squads/${t}`).then(r).catch(()=>{})},[t]),j.useEffect(()=>{n==="history"&&Ge.get(`/squads/${t}/history`).then(S=>{o(S.items),u(S.total)}).catch(()=>{}),n==="schedules"&&e&&Ge.get(`/schedules?targetId=${e.squad.id}`).then(S=>m(S.schedules)).catch(()=>{})},[n,t,e]);const w=S=>{Ge.get(`/squads/${t}/history/${S.id}`).then(p).catch(()=>Qe.error("Failed to load activity detail"))};if(!e)return y.jsx("div",{className:"h-full flex items-center justify-center text-zinc-600",children:"Loading..."});const x=e.squad.color||"#38bdf8";return d?y.jsx(Qq,{activity:d,squadColor:x,squadName:e.squad.name,onBack:()=>p(null)}):y.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{background:`${x}06`},children:[y.jsxs("button",{type:"button",onClick:()=>v("/squads"),className:"flex items-center gap-1.5 text-[11px] text-zinc-600 hover:text-zinc-300 font-mono mb-5 transition-colors",children:[y.jsx(vl,{className:"w-3.5 h-3.5"})," All Squads"]}),y.jsxs("div",{className:"flex items-start justify-between mb-5",children:[y.jsxs("div",{children:[y.jsx("h2",{className:"text-3xl tracking-wide",style:{fontFamily:"'Bebas Neue', sans-serif",color:x},children:e.squad.name}),y.jsxs("p",{className:"text-[11px] text-zinc-600 font-mono",children:[((k=e.squad.config)==null?void 0:k.prMode)??"draft-pr"," · ",e.squad.autonomyTier||"standard"," ","autonomy"]}),e.squad.repoUrl&&y.jsxs("a",{href:e.squad.repoUrl,target:"_blank",rel:"noreferrer",className:"text-[11px] font-mono text-[#E43A9C] hover:text-[#F041FF] flex items-center gap-1 mt-1 transition-colors",children:[y.jsx(r1,{className:"w-3 h-3"}),e.squad.repoUrl.replace("https://github.com/","")]})]}),y.jsx(Pt,{variant:Ms(e.squad.status),children:e.squad.status})]}),y.jsx("div",{className:"flex gap-0 mb-5 border-b border-white/[0.06]",children:["agents","instances","schedules","history"].map(S=>y.jsx("button",{type:"button",onClick:()=>i(S),className:`px-4 py-2 text-[11px] font-mono capitalize transition-colors border-b-2 -mb-px ${n===S?"text-[#E43A9C] border-[#E43A9C]":"text-zinc-600 hover:text-zinc-300 border-transparent"}`,children:S},S))}),n==="agents"&&y.jsx("div",{className:"space-y-2",children:e.members.map(S=>y.jsxs("button",{type:"button",onClick:()=>v(`/squads/${t}/agents/${S.roleName||S.role}`),className:"w-full glass-card border border-white/[0.07] rounded-2xl p-4 flex items-center gap-3 hover:bg-white/[0.03] transition-colors cursor-pointer text-left",children:[y.jsx("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center flex-shrink-0",style:{border:`1px solid ${x}30`,background:`${x}12`},children:Hs(S.roleName||S.role,x)}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-sm font-mono text-zinc-200",children:S.displayName}),y.jsx(Pt,{variant:Ms(S.status),children:S.status})]}),y.jsx("p",{className:"text-[11px] text-zinc-600 font-mono mt-0.5",children:S.role}),S.currentTask&&y.jsx("p",{className:"text-xs text-zinc-500 mt-1 truncate",children:S.currentTask})]})]},S.id))}),n==="instances"&&y.jsx("div",{className:"space-y-2",children:e.instances.length===0?y.jsx("div",{className:"text-center py-16 text-zinc-700 font-mono text-sm",children:"No active instances"}):e.instances.map(S=>y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl p-4 flex items-center gap-4",children:[y.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2 text-[11px] font-mono",children:[y.jsxs("div",{children:[y.jsx("span",{className:"text-zinc-700",children:"ID"}),y.jsx("p",{className:"text-zinc-300 mt-0.5 truncate",children:S.id.slice(0,8)})]}),y.jsxs("div",{children:[y.jsx("span",{className:"text-zinc-700",children:"Branch"}),y.jsx("p",{className:"text-zinc-300 mt-0.5 truncate",children:S.branch||"—"})]}),y.jsxs("div",{children:[y.jsx("span",{className:"text-zinc-700",children:"Status"}),y.jsx("p",{className:"text-zinc-300 mt-0.5",children:y.jsx(Pt,{variant:Ms(S.status),children:S.status})})]}),y.jsxs("div",{children:[y.jsx("span",{className:"text-zinc-700",children:"Tasks"}),y.jsxs("p",{className:"text-zinc-300 mt-0.5",children:[S.tasksComplete,"/",S.taskCount]})]})]}),y.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[y.jsx("button",{type:"button",onClick:()=>v(`/squads/${t}/instances/${S.id}`),title:"View instance agents",className:"p-2 rounded-xl hover:bg-white/[0.06] transition-colors cursor-pointer",style:{color:x},children:y.jsx(qf,{className:"w-4 h-4"})}),y.jsx("button",{type:"button",onClick:async()=>{try{await Ge.post(`/squads/${t}/instances/${S.id}/cancel`),Qe.success("Instance cancelled")}catch{Qe.error("Failed to cancel instance")}},title:"Stop instance",className:"p-2 rounded-xl hover:bg-red-500/10 text-zinc-600 hover:text-red-400 transition-colors cursor-pointer",children:y.jsx(up,{className:"w-4 h-4"})})]})]},S.id))}),n==="schedules"&&y.jsx("div",{className:"overflow-auto rounded-2xl border border-white/[0.07] glass-card",children:f.length===0?y.jsx("div",{className:"text-center py-16 text-zinc-700 font-mono text-sm",children:"No schedules for this squad"}):y.jsxs("table",{className:"w-full text-[11px] font-mono",children:[y.jsx("thead",{children:y.jsx("tr",{className:"border-b border-white/[0.06]",style:{background:"rgba(20,20,20,0.6)"},children:["Schedule","Next Run","Status"].map(S=>y.jsx("th",{className:"text-left px-4 py-2.5 text-zinc-600 font-medium",children:S},S))})}),y.jsx("tbody",{children:f.map(S=>y.jsxs("tr",{className:`border-b border-white/[0.04] hover:bg-white/[0.015] transition-colors ${S.enabled?"":"opacity-50"}`,children:[y.jsxs("td",{className:"px-4 py-3",children:[y.jsx("div",{className:"text-zinc-300",children:S.name||S.prompt}),y.jsx("div",{className:"text-zinc-700 text-[10px] mt-0.5",children:S.cron})]}),y.jsx("td",{className:"px-4 py-3 text-zinc-600",children:y.jsxs("span",{className:"flex items-center gap-1",children:[y.jsx(e1,{className:"w-3 h-3"}),S.enabled&&S.nextRun?Fs(S.nextRun,b):"—"]})}),y.jsx("td",{className:"px-4 py-3",children:y.jsx(Pt,{variant:S.enabled?"success":"muted",children:S.enabled?"active":"paused"})})]},S.id))})]})}),n==="history"&&y.jsxs("div",{className:"space-y-2",children:[a.length===0?y.jsx("div",{className:"text-center py-16 text-zinc-700 font-mono text-sm",children:"No history yet"}):a.map(S=>y.jsxs("button",{type:"button",onClick:()=>w(S),className:"w-full glass-card border border-white/[0.07] rounded-2xl px-4 py-3.5 flex items-center gap-3 hover:bg-white/[0.03] transition-colors cursor-pointer text-left",children:[y.jsx("div",{className:"flex-shrink-0",children:S.status==="completed"?y.jsx(RP,{className:"w-4 h-4",style:{color:"#34d399"}}):y.jsx(IP,{className:"w-4 h-4",style:{color:"#f87171"}})}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsx("p",{className:"text-[12px] text-zinc-300 font-mono truncate",children:S.title}),y.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[y.jsx("span",{className:"text-[10px] text-zinc-700 font-mono",children:Fs(S.completedAt||S.createdAt,b)}),y.jsxs("span",{className:"text-[10px] text-zinc-700 font-mono flex items-center gap-1",children:[y.jsx(qf,{className:"w-2.5 h-2.5"}),S.duration||"—"]}),y.jsxs("span",{className:"text-[10px] text-zinc-700 font-mono flex items-center gap-1",children:[y.jsx(qc,{className:"w-2.5 h-2.5"}),S.agentCount," agent",S.agentCount!==1?"s":""]})]})]}),y.jsx(Pt,{variant:S.status==="completed"?"success":"error",children:S.status})]},S.id)),a.length<c&&y.jsx("button",{type:"button",onClick:()=>{Ge.get(`/squads/${t}/history?offset=${a.length}`).then(S=>{o(A=>[...A,...S.items])}).catch(()=>{})},className:"w-full text-center py-3 text-[11px] font-mono text-zinc-600 hover:text-zinc-300 transition-colors cursor-pointer",children:"Load more"})]})]})}function Qq({activity:t,squadColor:e,squadName:r,onBack:n}){const i=Fa(),[a,o]=j.useState(new Set),c=j.useMemo(()=>{const v={};for(const b of t.agentEntries)v[b.agentId]=$f(b.agentName);return v},[t]),u={thought:{label:"Thinking",icon:n1},tool_call:{label:"Tool Call",icon:BP},tool_result:{label:"Tool Result",icon:$P},message:{label:"Message",icon:qc},decision:{label:"Decision",icon:t1}},d={label:"Message",icon:qc},p=v=>u[v]??d,f=v=>{o(b=>{const w=new Set(b);return w.has(v)?w.delete(v):w.add(v),w})},m=j.useMemo(()=>{const v=t.agentEntries.flatMap(b=>b.events.map(w=>({ev:w,entry:b})));return v.sort((b,w)=>b.ev.timestamp.localeCompare(w.ev.timestamp)),a.size>0?v.filter(({entry:b})=>a.has(b.agentId)):v},[t,a]);return y.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{background:`${e}06`},children:[y.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1.5 text-[11px] text-zinc-600 hover:text-zinc-300 font-mono mb-5 transition-colors cursor-pointer",children:[y.jsx(vl,{className:"w-3.5 h-3.5"})," Back to ",r]}),y.jsxs("div",{className:"flex items-start justify-between mb-5",children:[y.jsxs("div",{children:[y.jsx("h2",{className:"text-2xl tracking-wide",style:{fontFamily:"'Bebas Neue', sans-serif",color:e},children:t.title}),y.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[y.jsx("span",{className:"text-[11px] text-zinc-600 font-mono",children:Fs(t.completedAt||t.createdAt,i)}),y.jsxs("span",{className:"text-[11px] text-zinc-700 font-mono flex items-center gap-1",children:[y.jsx(e1,{className:"w-3 h-3"}),t.duration||"—"]})]})]}),y.jsx(Pt,{variant:t.status==="completed"?"success":"error",children:t.status})]}),y.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[t.agentEntries.map(v=>{const b=c[v.agentId],w=a.has(v.agentId),k=!(a.size>0)||w;return y.jsxs("button",{type:"button",onClick:()=>f(v.agentId),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl border transition-all cursor-pointer",style:{borderColor:k?`${b}30`:"rgba(255,255,255,0.05)",background:k?`${b}10`:"transparent",opacity:k?1:.4},children:[Hs(v.roleType||v.role,b),y.jsx("span",{className:"text-[11px] font-mono",style:{color:k?b:"#71717a"},children:v.agentName}),y.jsxs("span",{className:"text-[10px] font-mono text-zinc-500",children:["— ",v.role]})]},v.agentId)}),a.size>0&&y.jsx("button",{type:"button",onClick:()=>o(new Set),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-xl border border-white/[0.1] text-[11px] font-mono text-zinc-400 hover:text-zinc-200 transition-colors cursor-pointer",children:"Show all"})]}),y.jsxs("div",{className:"relative pl-10",children:[y.jsx("div",{className:"absolute left-[15px] top-0 bottom-0 w-px bg-white/[0.06]"}),y.jsx("div",{className:"space-y-3",children:m.map(({ev:v,entry:b})=>{const w=c[b.agentId],{label:x,icon:k}=p(v.kind),S=v.kind==="tool_call"||v.kind==="tool_result";return y.jsxs("div",{className:"relative",children:[y.jsx("div",{className:"absolute -left-10 top-3 w-[30px] h-[30px] rounded-full flex items-center justify-center",style:{background:`${w}15`,border:`1px solid ${w}35`},children:y.jsx(k,{className:"w-3.5 h-3.5",style:{color:w}})}),y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl px-4 py-3",children:[y.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[y.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[Hs(b.roleType||b.role,w),y.jsx("span",{className:"text-[10px] font-mono",style:{color:w},children:b.agentName})]}),y.jsx("span",{className:"text-zinc-700 text-[10px]",children:"·"}),y.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider text-zinc-500",children:x}),v.label&&y.jsx("span",{className:"text-[10px] font-mono text-zinc-600 border border-white/[0.08] rounded px-1.5 py-px bg-white/[0.03]",children:v.label}),v.status==="error"&&y.jsx(Pt,{variant:"error",children:"failed"}),v.status==="ok"&&v.kind==="tool_result"&&y.jsx(Pt,{variant:"success",children:"ok"})]}),y.jsx("span",{className:"text-[10px] font-mono text-zinc-700 flex-shrink-0 ml-2",children:lp(v.timestamp,i)})]}),S?y.jsx("pre",{className:"text-[11px] font-mono text-zinc-400 whitespace-pre-wrap leading-relaxed overflow-x-auto rounded-lg p-2 mt-1 bg-black/20",children:v.content}):y.jsx($u,{content:v.content,className:"text-[12px] [&_pre]:text-[10px]"})]})]},v.id)})})]})]})}const e9={thought:{label:"Thinking",icon:n1,color:"#a78bfa",bg:"rgba(167,139,250,0.1)"},tool_call:{label:"Tool Call",icon:BP,color:"#38bdf8",bg:"rgba(56,189,248,0.1)"},tool_result:{label:"Tool Result",icon:$P,color:"#34d399",bg:"rgba(52,211,153,0.1)"},message:{label:"Message",icon:qc,color:"#E43A9C",bg:"rgba(228,58,156,0.15)"},decision:{label:"Decision",icon:t1,color:"#fbbf24",bg:"rgba(251,191,36,0.1)"},meeting:{label:"Meeting",icon:a1,color:"#818cf8",bg:"rgba(129,140,248,0.1)"}};function t9(t){const e=t.toLowerCase();return e.includes("meeting")?"meeting":e.includes("tool_call")||e.includes("tool-call")?"tool_call":e.includes("tool_result")||e.includes("tool-result")?"tool_result":e.includes("thought")||e.includes("thinking")||e.includes("reason")?"thought":e.includes("decision")?"decision":"message"}function r9({squadName:t,instanceId:e}){const[r,n]=j.useState(null),[i,a]=j.useState([]),[o,c]=j.useState(null),[u,d]=j.useState("running"),[p,f]=j.useState(0),m=gl(),v=Fa(),b=j.useRef(null),w=j.useRef(null),x=j.useRef(!0),k=j.useCallback(()=>{const $=b.current;if(!$)return;const K=100;x.current=$.scrollHeight-$.scrollTop-$.clientHeight<K,x.current&&f(0)},[]);if(j.useEffect(()=>{Ge.get(`/squads/${t}/instances/${e}`).then($=>{n($),d($.instance.status)}).catch(()=>{Qe.error("Failed to load instance")})},[t,e]),FP({onEvent:$=>{if(!$.event)return;const K=$.event;if((K.type==="instance:completed"||K.type==="instance:failed"||K.type==="instance.completed"||K.type==="instance.failed")&&K.instanceId===e){d(K.type==="instance:completed"||K.type==="instance.completed"?"completed":"failed");return}if((K.type.startsWith("agent:")||K.type.startsWith("agent."))&&K.instanceId===e){const L=K.data,U=(L==null?void 0:L.tool)||null,F=typeof(L==null?void 0:L.success)=="boolean"?L.success:null;let X="";if(U&&(L!=null&&L.arguments)){const G=L.arguments;if(typeof G=="string")X=G;else if(typeof G=="object"&&G!==null){const Q=G;Q.command?X=String(Q.command):X=JSON.stringify(G,null,2)}}else L!=null&&L.result?X=String(L.result):L!=null&&L.error?X=String(L.error):X=(L==null?void 0:L.content)||"";try{const G=JSON.parse(X);typeof G=="object"&&G!==null&&(X=G.message??G.content??G.response??G.decision??JSON.stringify(G,null,2))}catch{}const Y={id:K.id,agent:K.agentRole||(L==null?void 0:L.agentRole)||"unknown",type:K.type.replace(/^agent[:.]/,""),content:X,toolName:U,success:F,model:K.model||(L==null?void 0:L.model)||null,tokensUsed:null,timestamp:K.timestamp};a(G=>[...G,Y]),x.current?setTimeout(()=>{var G;return(G=w.current)==null?void 0:G.scrollIntoView({behavior:"smooth"})},50):f(G=>G+1)}}}),!r)return y.jsx("div",{className:"h-full flex items-center justify-center text-zinc-600",children:"Loading..."});const S=r.squadColor||"#38bdf8",A=[...r.activity,...i],C=Array.from(new Map(A.map($=>[$.id,$])).values());C.sort(($,K)=>$.timestamp.localeCompare(K.timestamp));const T=o?C.filter($=>$.agent===o):C,O=[...new Set(C.map($=>$.agent))],N={};for(const $ of O)N[$]=$f($);const R=u==="running"||u==="working"||u==="meeting"||u==="planning";return y.jsxs("div",{ref:b,onScroll:k,className:"flex-1 overflow-y-auto p-6",style:{background:`${S}06`},children:[y.jsxs("button",{type:"button",onClick:()=>m(`/squads/${t}`),className:"flex items-center gap-1.5 text-[11px] text-zinc-600 hover:text-zinc-300 font-mono mb-5 transition-colors",children:[y.jsx(vl,{className:"w-3.5 h-3.5"})," Back to ",t]}),y.jsxs("div",{className:"flex items-start justify-between mb-5",children:[y.jsxs("div",{children:[y.jsx("h2",{className:"text-2xl tracking-wide",style:{fontFamily:"'Bebas Neue', sans-serif",color:S},children:"Instance"}),y.jsx("p",{className:"text-[11px] text-zinc-600 font-mono mt-0.5",children:r.instance.id.slice(0,8)}),r.instance.branch&&y.jsx("p",{className:"text-[11px] text-zinc-700 font-mono mt-0.5",children:r.instance.branch})]}),y.jsx(Pt,{variant:Ms(u),children:u})]}),y.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[r.members.map($=>{const K=$.roleName||$.role,L=N[K]||$f(K),U=o===K;return y.jsxs("button",{type:"button",onClick:()=>c(U?null:K),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl border transition-all cursor-pointer",style:{borderColor:U?L:`${L}30`,background:U?`${L}25`:`${L}10`,opacity:o&&!U?.5:1},children:[Hs(K,L),y.jsx("span",{className:"text-[11px] font-mono",style:{color:L},children:$.displayName}),y.jsx(Pt,{variant:Ms($.status),children:$.status}),$.status==="working"&&y.jsx("button",{type:"button",onClick:async F=>{F.stopPropagation();try{await Ge.post(`/squads/${t}/instances/${e}/cancel`),Qe.success("Instance cancelled")}catch{Qe.error("Failed to cancel instance")}},title:"Cancel instance",className:"ml-1 p-1 rounded-lg hover:bg-red-500/10 text-zinc-600 hover:text-red-400 transition-colors cursor-pointer",children:y.jsx(up,{className:"w-3 h-3"})})]},$.id)}),o&&y.jsx("button",{type:"button",onClick:()=>c(null),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-xl border border-white/[0.1] text-[11px] font-mono text-zinc-400 hover:text-zinc-200 transition-colors cursor-pointer",children:"Show all"})]}),y.jsxs("div",{className:"relative pl-10",children:[y.jsx("div",{className:"absolute left-[15px] top-0 bottom-0 w-px bg-white/[0.06]"}),y.jsxs("div",{className:"space-y-3",children:[T.length===0&&y.jsx("div",{className:"text-center py-12 text-zinc-700 font-mono text-sm",children:"No activity recorded yet"}),T.map($=>{const K=t9($.type),L=e9[K],U=L.icon,F=N[$.agent]||$f($.agent),X=K==="tool_call"||K==="tool_result",Y=$.type.toLowerCase().includes("error")||$.type.toLowerCase().includes("fail");return y.jsxs("div",{className:"relative",children:[y.jsx("div",{className:"absolute -left-10 top-3 w-[30px] h-[30px] rounded-full flex items-center justify-center",style:{background:`${F}15`,border:`1px solid ${F}35`},children:y.jsx(U,{className:"w-3.5 h-3.5",style:{color:F}})}),y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl px-4 py-3",children:[y.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[y.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[Hs($.agent,F),y.jsx("span",{className:"text-[10px] font-mono",style:{color:F},children:$.agent})]}),y.jsx("span",{className:"text-zinc-700 text-[10px]",children:"·"}),y.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider text-zinc-500",children:L.label}),$.toolName&&y.jsx("span",{className:"text-[10px] font-mono text-sky-400 border border-sky-400/20 rounded px-1.5 py-px bg-sky-400/[0.06]",children:$.toolName}),$.model&&y.jsx("span",{className:"text-[10px] font-mono text-zinc-600 border border-white/[0.08] rounded px-1.5 py-px bg-white/[0.03]",children:$.model}),$.success===!0&&y.jsx("span",{className:"text-[10px] font-mono text-emerald-400 border border-emerald-400/20 rounded px-1.5 py-px bg-emerald-400/[0.08]",children:"success"}),$.success===!1&&y.jsx("span",{className:"text-[10px] font-mono text-red-400 border border-red-400/20 rounded px-1.5 py-px bg-red-400/[0.08]",children:"failed"}),Y&&$.success===null&&y.jsx(Pt,{variant:"error",children:"failed"})]}),y.jsx("span",{className:"text-[10px] font-mono text-zinc-700 flex-shrink-0 ml-2",children:lp($.timestamp,v)})]}),X?y.jsx("pre",{className:"text-[11px] font-mono text-zinc-400 whitespace-pre-wrap leading-relaxed overflow-x-auto rounded-lg p-2 mt-1 bg-black/20",children:$.content}):y.jsx($u,{content:$.content,className:"text-[12px] [&_pre]:text-[10px]"})]})]},$.id)}),R&&y.jsxs("div",{className:"relative",children:[y.jsx("div",{className:"absolute -left-10 top-3 w-[30px] h-[30px] rounded-full flex items-center justify-center",style:{background:`${S}15`,border:`1px solid ${S}40`},children:y.jsx(MP,{className:"w-3.5 h-3.5 animate-spin",style:{color:S}})}),y.jsx("div",{className:"glass-card border rounded-2xl px-4 py-3",style:{borderColor:`${S}20`},children:y.jsx("span",{className:"text-[11px] font-mono",style:{color:S},children:"Working…"})})]})]})]}),y.jsx("div",{ref:w}),p>0&&y.jsxs("button",{type:"button",onClick:()=>{var $;($=w.current)==null||$.scrollIntoView({behavior:"smooth"}),f(0)},className:"fixed bottom-6 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-4 py-2 rounded-full border border-white/[0.1] bg-zinc-900/90 backdrop-blur-sm text-[11px] font-mono text-zinc-300 hover:text-white shadow-lg transition-all cursor-pointer z-50",children:[y.jsx(cz,{className:"w-3.5 h-3.5"}),p," new event",p!==1?"s":""]})]})}function n9({squadName:t,role:e}){const r=gl(),[n,i]=j.useState(null),[a,o]=j.useState(""),[c,u]=j.useState(!1),[d,p]=j.useState(""),[f,m]=j.useState(!1),[v,b]=j.useState("#38bdf8");j.useEffect(()=>{Ge.get(`/squads/${t}`).then(x=>{b(x.squad.color||"#38bdf8");const k=x.members.find(S=>S.roleName===e||S.role===e);k&&i(k)}).catch(()=>{}),Ge.get(`/squads/${t}/members/${e}/skill`).then(x=>{o(x.content)}).catch(()=>{})},[t,e]);const w=async()=>{m(!0);try{await Ge.put(`/squads/${t}/members/${e}/skill`,{content:d}),o(d),u(!1),Qe.success("Skill file saved")}catch{Qe.error("Failed to save skill file")}finally{m(!1)}};return n?y.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{background:`${v}06`},children:[y.jsxs("button",{type:"button",onClick:()=>r(`/squads/${t}`),className:"flex items-center gap-1.5 text-[11px] text-zinc-600 hover:text-zinc-300 font-mono mb-5 transition-colors cursor-pointer",children:[y.jsx(vl,{className:"w-3.5 h-3.5"})," Back to ",t]}),y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl p-5 mb-5",children:[y.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[y.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{border:`1px solid ${v}30`,background:`${v}12`},children:Hs(n.roleName,v)}),y.jsxs("div",{children:[y.jsx("h2",{className:"text-xl tracking-wide",style:{fontFamily:"'Bebas Neue', sans-serif",color:v},children:n.displayName}),y.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[y.jsx("span",{className:"text-[11px] font-mono text-zinc-500",children:n.roleName}),n.veto&&y.jsx("span",{className:"text-[10px] font-mono text-amber-400 border border-amber-400/20 rounded px-1.5 py-px bg-amber-400/[0.06]",children:"veto"})]})]})]}),n.tools.length>0&&y.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:n.tools.map(x=>y.jsx("span",{className:"text-[10px] font-mono text-zinc-500 border border-white/[0.08] rounded px-1.5 py-px bg-white/[0.03]",children:x},x))})]}),y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl p-5",children:[y.jsxs("div",{className:"flex items-center justify-between mb-4",children:[y.jsx("h3",{className:"text-sm font-mono text-zinc-300",children:"Skill File"}),c?y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("button",{type:"button",onClick:()=>u(!1),className:"px-3 py-1.5 rounded-lg text-[11px] font-mono text-zinc-500 hover:text-zinc-300 border border-white/[0.1] transition-colors cursor-pointer",children:"Cancel"}),y.jsxs("button",{type:"button",onClick:w,disabled:f,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-mono text-emerald-400 border border-emerald-400/30 hover:bg-emerald-400/10 transition-colors cursor-pointer disabled:opacity-50",children:[y.jsx(cp,{className:"w-3 h-3"})," ",f?"Saving...":"Save"]})]}):y.jsxs("button",{type:"button",onClick:()=>{p(a),u(!0)},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-mono text-zinc-400 hover:text-zinc-200 border border-white/[0.1] hover:border-white/[0.2] transition-colors cursor-pointer",children:[y.jsx(Ff,{className:"w-3 h-3"})," Edit"]})]}),c?y.jsx("textarea",{value:d,onChange:x=>p(x.target.value),className:"w-full h-[500px] bg-black/30 border border-white/[0.08] rounded-xl p-4 text-[12px] font-mono text-zinc-300 resize-y focus:outline-none focus:border-white/[0.2] leading-relaxed",spellCheck:!1}):a?y.jsx($u,{content:a,className:"text-[12px] [&_pre]:text-[11px]"}):y.jsx("p",{className:"text-zinc-700 text-[12px] font-mono py-8 text-center",children:"No skill file configured for this agent"})]})]}):y.jsx("div",{className:"h-full flex items-center justify-center text-zinc-600",children:"Loading..."})}var Kg,QE;function Qr(){if(QE)return Kg;QE=1;var t=Array.isArray;return Kg=t,Kg}var Gg,eA;function NR(){if(eA)return Gg;eA=1;var t=typeof ef=="object"&&ef&&ef.Object===Object&&ef;return Gg=t,Gg}var Vg,tA;function Ai(){if(tA)return Vg;tA=1;var t=NR(),e=typeof self=="object"&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return Vg=r,Vg}var Xg,rA;function Du(){if(rA)return Xg;rA=1;var t=Ai(),e=t.Symbol;return Xg=e,Xg}var Yg,nA;function i9(){if(nA)return Yg;nA=1;var t=Du(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,i=t?t.toStringTag:void 0;function a(o){var c=r.call(o,i),u=o[i];try{o[i]=void 0;var d=!0}catch{}var p=n.call(o);return d&&(c?o[i]=u:delete o[i]),p}return Yg=a,Yg}var Jg,iA;function a9(){if(iA)return Jg;iA=1;var t=Object.prototype,e=t.toString;function r(n){return e.call(n)}return Jg=r,Jg}var Zg,aA;function ra(){if(aA)return Zg;aA=1;var t=Du(),e=i9(),r=a9(),n="[object Null]",i="[object Undefined]",a=t?t.toStringTag:void 0;function o(c){return c==null?c===void 0?i:n:a&&a in Object(c)?e(c):r(c)}return Zg=o,Zg}var Qg,oA;function na(){if(oA)return Qg;oA=1;function t(e){return e!=null&&typeof e=="object"}return Qg=t,Qg}var ey,sA;function xl(){if(sA)return ey;sA=1;var t=ra(),e=na(),r="[object Symbol]";function n(i){return typeof i=="symbol"||e(i)&&t(i)==r}return ey=n,ey}var ty,lA;function u1(){if(lA)return ty;lA=1;var t=Qr(),e=xl(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(a,o){if(t(a))return!1;var c=typeof a;return c=="number"||c=="symbol"||c=="boolean"||a==null||e(a)?!0:n.test(a)||!r.test(a)||o!=null&&a in Object(o)}return ty=i,ty}var ry,cA;function Wa(){if(cA)return ry;cA=1;function t(e){var r=typeof e;return e!=null&&(r=="object"||r=="function")}return ry=t,ry}var ny,uA;function d1(){if(uA)return ny;uA=1;var t=ra(),e=Wa(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(c){if(!e(c))return!1;var u=t(c);return u==n||u==i||u==r||u==a}return ny=o,ny}var iy,dA;function o9(){if(dA)return iy;dA=1;var t=Ai(),e=t["__core-js_shared__"];return iy=e,iy}var ay,fA;function s9(){if(fA)return ay;fA=1;var t=o9(),e=(function(){var n=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!e&&e in n}return ay=r,ay}var oy,hA;function PR(){if(hA)return oy;hA=1;var t=Function.prototype,e=t.toString;function r(n){if(n!=null){try{return e.call(n)}catch{}try{return n+""}catch{}}return""}return oy=r,oy}var sy,pA;function l9(){if(pA)return sy;pA=1;var t=d1(),e=s9(),r=Wa(),n=PR(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,c=Object.prototype,u=o.toString,d=c.hasOwnProperty,p=RegExp("^"+u.call(d).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(m){if(!r(m)||e(m))return!1;var v=t(m)?p:a;return v.test(n(m))}return sy=f,sy}var ly,mA;function c9(){if(mA)return ly;mA=1;function t(e,r){return e==null?void 0:e[r]}return ly=t,ly}var cy,gA;function Uo(){if(gA)return cy;gA=1;var t=l9(),e=c9();function r(n,i){var a=e(n,i);return t(a)?a:void 0}return cy=r,cy}var uy,yA;function gp(){if(yA)return uy;yA=1;var t=Uo(),e=t(Object,"create");return uy=e,uy}var dy,vA;function u9(){if(vA)return dy;vA=1;var t=gp();function e(){this.__data__=t?t(null):{},this.size=0}return dy=e,dy}var fy,bA;function d9(){if(bA)return fy;bA=1;function t(e){var r=this.has(e)&&delete this.__data__[e];return this.size-=r?1:0,r}return fy=t,fy}var hy,xA;function f9(){if(xA)return hy;xA=1;var t=gp(),e="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(a){var o=this.__data__;if(t){var c=o[a];return c===e?void 0:c}return n.call(o,a)?o[a]:void 0}return hy=i,hy}var py,wA;function h9(){if(wA)return py;wA=1;var t=gp(),e=Object.prototype,r=e.hasOwnProperty;function n(i){var a=this.__data__;return t?a[i]!==void 0:r.call(a,i)}return py=n,py}var my,_A;function p9(){if(_A)return my;_A=1;var t=gp(),e="__lodash_hash_undefined__";function r(n,i){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=t&&i===void 0?e:i,this}return my=r,my}var gy,SA;function m9(){if(SA)return gy;SA=1;var t=u9(),e=d9(),r=f9(),n=h9(),i=p9();function a(o){var c=-1,u=o==null?0:o.length;for(this.clear();++c<u;){var d=o[c];this.set(d[0],d[1])}}return a.prototype.clear=t,a.prototype.delete=e,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,gy=a,gy}var yy,kA;function g9(){if(kA)return yy;kA=1;function t(){this.__data__=[],this.size=0}return yy=t,yy}var vy,EA;function f1(){if(EA)return vy;EA=1;function t(e,r){return e===r||e!==e&&r!==r}return vy=t,vy}var by,AA;function yp(){if(AA)return by;AA=1;var t=f1();function e(r,n){for(var i=r.length;i--;)if(t(r[i][0],n))return i;return-1}return by=e,by}var xy,OA;function y9(){if(OA)return xy;OA=1;var t=yp(),e=Array.prototype,r=e.splice;function n(i){var a=this.__data__,o=t(a,i);if(o<0)return!1;var c=a.length-1;return o==c?a.pop():r.call(a,o,1),--this.size,!0}return xy=n,xy}var wy,TA;function v9(){if(TA)return wy;TA=1;var t=yp();function e(r){var n=this.__data__,i=t(n,r);return i<0?void 0:n[i][1]}return wy=e,wy}var _y,CA;function b9(){if(CA)return _y;CA=1;var t=yp();function e(r){return t(this.__data__,r)>-1}return _y=e,_y}var Sy,jA;function x9(){if(jA)return Sy;jA=1;var t=yp();function e(r,n){var i=this.__data__,a=t(i,r);return a<0?(++this.size,i.push([r,n])):i[a][1]=n,this}return Sy=e,Sy}var ky,NA;function vp(){if(NA)return ky;NA=1;var t=g9(),e=y9(),r=v9(),n=b9(),i=x9();function a(o){var c=-1,u=o==null?0:o.length;for(this.clear();++c<u;){var d=o[c];this.set(d[0],d[1])}}return a.prototype.clear=t,a.prototype.delete=e,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,ky=a,ky}var Ey,PA;function h1(){if(PA)return Ey;PA=1;var t=Uo(),e=Ai(),r=t(e,"Map");return Ey=r,Ey}var Ay,RA;function w9(){if(RA)return Ay;RA=1;var t=m9(),e=vp(),r=h1();function n(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}return Ay=n,Ay}var Oy,IA;function _9(){if(IA)return Oy;IA=1;function t(e){var r=typeof e;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?e!=="__proto__":e===null}return Oy=t,Oy}var Ty,$A;function bp(){if($A)return Ty;$A=1;var t=_9();function e(r,n){var i=r.__data__;return t(n)?i[typeof n=="string"?"string":"hash"]:i.map}return Ty=e,Ty}var Cy,MA;function S9(){if(MA)return Cy;MA=1;var t=bp();function e(r){var n=t(this,r).delete(r);return this.size-=n?1:0,n}return Cy=e,Cy}var jy,DA;function k9(){if(DA)return jy;DA=1;var t=bp();function e(r){return t(this,r).get(r)}return jy=e,jy}var Ny,LA;function E9(){if(LA)return Ny;LA=1;var t=bp();function e(r){return t(this,r).has(r)}return Ny=e,Ny}var Py,zA;function A9(){if(zA)return Py;zA=1;var t=bp();function e(r,n){var i=t(this,r),a=i.size;return i.set(r,n),this.size+=i.size==a?0:1,this}return Py=e,Py}var Ry,BA;function p1(){if(BA)return Ry;BA=1;var t=w9(),e=S9(),r=k9(),n=E9(),i=A9();function a(o){var c=-1,u=o==null?0:o.length;for(this.clear();++c<u;){var d=o[c];this.set(d[0],d[1])}}return a.prototype.clear=t,a.prototype.delete=e,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,Ry=a,Ry}var Iy,UA;function RR(){if(UA)return Iy;UA=1;var t=p1(),e="Expected a function";function r(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(e);var a=function(){var o=arguments,c=i?i.apply(this,o):o[0],u=a.cache;if(u.has(c))return u.get(c);var d=n.apply(this,o);return a.cache=u.set(c,d)||u,d};return a.cache=new(r.Cache||t),a}return r.Cache=t,Iy=r,Iy}var $y,qA;function O9(){if(qA)return $y;qA=1;var t=RR(),e=500;function r(n){var i=t(n,function(o){return a.size===e&&a.clear(),o}),a=i.cache;return i}return $y=r,$y}var My,FA;function T9(){if(FA)return My;FA=1;var t=O9(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=t(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(e,function(o,c,u,d){a.push(u?d.replace(r,"$1"):c||o)}),a});return My=n,My}var Dy,HA;function m1(){if(HA)return Dy;HA=1;function t(e,r){for(var n=-1,i=e==null?0:e.length,a=Array(i);++n<i;)a[n]=r(e[n],n,e);return a}return Dy=t,Dy}var Ly,WA;function C9(){if(WA)return Ly;WA=1;var t=Du(),e=m1(),r=Qr(),n=xl(),i=t?t.prototype:void 0,a=i?i.toString:void 0;function o(c){if(typeof c=="string")return c;if(r(c))return e(c,o)+"";if(n(c))return a?a.call(c):"";var u=c+"";return u=="0"&&1/c==-1/0?"-0":u}return Ly=o,Ly}var zy,KA;function IR(){if(KA)return zy;KA=1;var t=C9();function e(r){return r==null?"":t(r)}return zy=e,zy}var By,GA;function $R(){if(GA)return By;GA=1;var t=Qr(),e=u1(),r=T9(),n=IR();function i(a,o){return t(a)?a:e(a,o)?[a]:r(n(a))}return By=i,By}var Uy,VA;function xp(){if(VA)return Uy;VA=1;var t=xl();function e(r){if(typeof r=="string"||t(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Uy=e,Uy}var qy,XA;function g1(){if(XA)return qy;XA=1;var t=$R(),e=xp();function r(n,i){i=t(i,n);for(var a=0,o=i.length;n!=null&&a<o;)n=n[e(i[a++])];return a&&a==o?n:void 0}return qy=r,qy}var Fy,YA;function MR(){if(YA)return Fy;YA=1;var t=g1();function e(r,n,i){var a=r==null?void 0:t(r,n);return a===void 0?i:a}return Fy=e,Fy}var j9=MR();const Tn=vt(j9);var Hy,JA;function N9(){if(JA)return Hy;JA=1;function t(e){return e==null}return Hy=t,Hy}var P9=N9();const tt=vt(P9);var Wy,ZA;function R9(){if(ZA)return Wy;ZA=1;var t=ra(),e=Qr(),r=na(),n="[object String]";function i(a){return typeof a=="string"||!e(a)&&r(a)&&t(a)==n}return Wy=i,Wy}var I9=R9();const Ro=vt(I9);var $9=d1();const Je=vt($9);var M9=Wa();const wl=vt(M9);var Ky={exports:{}},pt={};/**
|
|
@@ -517,4 +517,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
517
517
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RM(t,e){if(t){if(typeof t=="string")return jw(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return jw(t,e)}}function zne(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Bne(t){if(Array.isArray(t))return jw(t)}function jw(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function PN(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function ie(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?PN(Object(r),!0).forEach(function(n){ze(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):PN(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ze(t,e,r){return e=IM(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function IM(t){var e=Une(t,"string");return dl(e)=="symbol"?e:e+""}function Une(t,e){if(dl(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(dl(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var qne={xAxis:["bottom","top"],yAxis:["left","right"]},Fne={width:"100%",height:"100%"},$M={x:0,y:0};function jf(t){return t}var Hne=function(e,r){return r==="horizontal"?e.x:r==="vertical"?e.y:r==="centric"?e.angle:e.radius},Wne=function(e,r,n,i){var a=r.find(function(p){return p&&p.index===n});if(a){if(e==="horizontal")return{x:a.coordinate,y:i.y};if(e==="vertical")return{x:i.x,y:a.coordinate};if(e==="centric"){var o=a.coordinate,c=i.radius;return ie(ie(ie({},i),wr(i.cx,i.cy,c,o)),{},{angle:o,radius:c})}var u=a.coordinate,d=i.angle;return ie(ie(ie({},i),wr(i.cx,i.cy,u,d)),{},{angle:d,radius:u})}return $M},Kp=function(e,r){var n=r.graphicalItems,i=r.dataStartIndex,a=r.dataEndIndex,o=(n??[]).reduce(function(c,u){var d=u.props.data;return d&&d.length?[].concat(fl(c),fl(d)):c},[]);return o.length>0?o:e&&e.length&&ge(i)&&ge(a)?e.slice(i,a+1):[]};function MM(t){return t==="number"?[0,"auto"]:void 0}var Nw=function(e,r,n,i){var a=e.graphicalItems,o=e.tooltipAxis,c=Kp(r,e);return n<0||!a||!a.length||n>=c.length?null:a.reduce(function(u,d){var p,f=(p=d.props.data)!==null&&p!==void 0?p:r;f&&e.dataStartIndex+e.dataEndIndex!==0&&e.dataEndIndex-e.dataStartIndex>=n&&(f=f.slice(e.dataStartIndex,e.dataEndIndex+1));var m;if(o.dataKey&&!o.allowDuplicatedCategory){var v=f===void 0?c:f;m=nh(v,o.dataKey,i)}else m=f&&f[n]||c[n];return m?[].concat(fl(u),[M$(d,m)]):u},[])},RN=function(e,r,n,i){var a=i||{x:e.chartX,y:e.chartY},o=Hne(a,n),c=e.orderedTooltipTicks,u=e.tooltipAxis,d=e.tooltipTicks,p=tY(o,c,d,u);if(p>=0&&d){var f=d[p]&&d[p].value,m=Nw(e,r,p,f),v=Wne(n,c,p,a);return{activeTooltipIndex:p,activeLabel:f,activePayload:m,activeCoordinate:v}}return null},Kne=function(e,r){var n=r.axes,i=r.graphicalItems,a=r.axisType,o=r.axisIdKey,c=r.stackGroups,u=r.dataStartIndex,d=r.dataEndIndex,p=e.layout,f=e.children,m=e.stackOffset,v=R$(p,a);return n.reduce(function(b,w){var x,k=w.type.defaultProps!==void 0?ie(ie({},w.type.defaultProps),w.props):w.props,S=k.type,A=k.dataKey,C=k.allowDataOverflow,T=k.allowDuplicatedCategory,O=k.scale,N=k.ticks,R=k.includeHidden,$=k[o];if(b[$])return b;var K=Kp(e.data,{graphicalItems:i.filter(function(B){var J,oe=o in B.props?B.props[o]:(J=B.type.defaultProps)===null||J===void 0?void 0:J[o];return oe===$}),dataStartIndex:u,dataEndIndex:d}),L=K.length,U,F,X;vne(k.domain,C,S)&&(U=Vx(k.domain,null,C),v&&(S==="number"||O!=="auto")&&(X=Lc(K,A,"category")));var Y=MM(S);if(!U||U.length===0){var G,Q=(G=k.domain)!==null&&G!==void 0?G:Y;if(A){if(U=Lc(K,A,S),S==="category"&&v){var W=K9(U);T&&W?(F=U,U=qh(0,L)):T||(U=Gj(Q,U,w).reduce(function(B,J){return B.indexOf(J)>=0?B:[].concat(fl(B),[J])},[]))}else if(S==="category")T?U=U.filter(function(B){return B!==""&&!tt(B)}):U=Gj(Q,U,w).reduce(function(B,J){return B.indexOf(J)>=0||J===""||tt(J)?B:[].concat(fl(B),[J])},[]);else if(S==="number"){var ee=oY(K,i.filter(function(B){var J,oe,ue=o in B.props?B.props[o]:(J=B.type.defaultProps)===null||J===void 0?void 0:J[o],ve="hide"in B.props?B.props.hide:(oe=B.type.defaultProps)===null||oe===void 0?void 0:oe.hide;return ue===$&&(R||!ve)}),A,a,p);ee&&(U=ee)}v&&(S==="number"||O!=="auto")&&(X=Lc(K,A,"category"))}else v?U=qh(0,L):c&&c[$]&&c[$].hasStack&&S==="number"?U=m==="expand"?[0,1]:$$(c[$].stackGroups,u,d):U=P$(K,i.filter(function(B){var J=o in B.props?B.props[o]:B.type.defaultProps[o],oe="hide"in B.props?B.props.hide:B.type.defaultProps.hide;return J===$&&(R||!oe)}),S,p,!0);if(S==="number")U=Tw(f,U,$,a,N),Q&&(U=Vx(Q,U,C));else if(S==="category"&&Q){var q=Q,I=U.every(function(B){return q.indexOf(B)>=0});I&&(U=q)}}return ie(ie({},b),{},ze({},$,ie(ie({},k),{},{axisType:a,domain:U,categoricalDomain:X,duplicateDomain:F,originalDomain:(x=k.domain)!==null&&x!==void 0?x:Y,isCategorical:v,layout:p})))},{})},Gne=function(e,r){var n=r.graphicalItems,i=r.Axis,a=r.axisType,o=r.axisIdKey,c=r.stackGroups,u=r.dataStartIndex,d=r.dataEndIndex,p=e.layout,f=e.children,m=Kp(e.data,{graphicalItems:n,dataStartIndex:u,dataEndIndex:d}),v=m.length,b=R$(p,a),w=-1;return n.reduce(function(x,k){var S=k.type.defaultProps!==void 0?ie(ie({},k.type.defaultProps),k.props):k.props,A=S[o],C=MM("number");if(!x[A]){w++;var T;return b?T=qh(0,v):c&&c[A]&&c[A].hasStack?(T=$$(c[A].stackGroups,u,d),T=Tw(f,T,A,a)):(T=Vx(C,P$(m,n.filter(function(O){var N,R,$=o in O.props?O.props[o]:(N=O.type.defaultProps)===null||N===void 0?void 0:N[o],K="hide"in O.props?O.props.hide:(R=O.type.defaultProps)===null||R===void 0?void 0:R.hide;return $===A&&!K}),"number",p),i.defaultProps.allowDataOverflow),T=Tw(f,T,A,a)),ie(ie({},x),{},ze({},A,ie(ie({axisType:a},i.defaultProps),{},{hide:!0,orientation:Tn(qne,"".concat(a,".").concat(w%2),null),domain:T,originalDomain:C,isCategorical:b,layout:p})))}return x},{})},Vne=function(e,r){var n=r.axisType,i=n===void 0?"xAxis":n,a=r.AxisComp,o=r.graphicalItems,c=r.stackGroups,u=r.dataStartIndex,d=r.dataEndIndex,p=e.children,f="".concat(i,"Id"),m=Cn(p,a),v={};return m&&m.length?v=Kne(e,{axes:m,graphicalItems:o,axisType:i,axisIdKey:f,stackGroups:c,dataStartIndex:u,dataEndIndex:d}):o&&o.length&&(v=Gne(e,{Axis:a,graphicalItems:o,axisType:i,axisIdKey:f,stackGroups:c,dataStartIndex:u,dataEndIndex:d})),v},Xne=function(e){var r=Ra(e),n=Ki(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:j1(n,function(i){return i.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Ph(r,n)}},IN=function(e){var r=e.children,n=e.defaultShowTooltip,i=sn(r,rl),a=0,o=0;return e.data&&e.data.length!==0&&(o=e.data.length-1),i&&i.props&&(i.props.startIndex>=0&&(a=i.props.startIndex),i.props.endIndex>=0&&(o=i.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:a,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!n}},Yne=function(e){return!e||!e.length?!1:e.some(function(r){var n=Gi(r&&r.type);return n&&n.indexOf("Bar")>=0})},$N=function(e){return e==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:e==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:e==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},Jne=function(e,r){var n=e.props,i=e.graphicalItems,a=e.xAxisMap,o=a===void 0?{}:a,c=e.yAxisMap,u=c===void 0?{}:c,d=n.width,p=n.height,f=n.children,m=n.margin||{},v=sn(f,rl),b=sn(f,Bs),w=Object.keys(u).reduce(function(T,O){var N=u[O],R=N.orientation;return!N.mirror&&!N.hide?ie(ie({},T),{},ze({},R,T[R]+N.width)):T},{left:m.left||0,right:m.right||0}),x=Object.keys(o).reduce(function(T,O){var N=o[O],R=N.orientation;return!N.mirror&&!N.hide?ie(ie({},T),{},ze({},R,Tn(T,"".concat(R))+N.height)):T},{top:m.top||0,bottom:m.bottom||0}),k=ie(ie({},x),w),S=k.bottom;v&&(k.bottom+=v.props.height||rl.defaultProps.height),b&&r&&(k=iY(k,i,n,r));var A=d-k.left-k.right,C=p-k.top-k.bottom;return ie(ie({brushBottom:S},k),{},{width:Math.max(A,0),height:Math.max(C,0)})},Zne=function(e,r){if(r==="xAxis")return e[r].width;if(r==="yAxis")return e[r].height},DM=function(e){var r=e.chartName,n=e.GraphicalChild,i=e.defaultTooltipEventType,a=i===void 0?"axis":i,o=e.validateTooltipEventTypes,c=o===void 0?["axis"]:o,u=e.axisComponents,d=e.legendContent,p=e.formatAxisMap,f=e.defaultProps,m=function(k,S){var A=S.graphicalItems,C=S.stackGroups,T=S.offset,O=S.updateId,N=S.dataStartIndex,R=S.dataEndIndex,$=k.barSize,K=k.layout,L=k.barGap,U=k.barCategoryGap,F=k.maxBarSize,X=$N(K),Y=X.numericAxisName,G=X.cateAxisName,Q=Yne(A),W=[];return A.forEach(function(ee,q){var I=Kp(k.data,{graphicalItems:[ee],dataStartIndex:N,dataEndIndex:R}),B=ee.type.defaultProps!==void 0?ie(ie({},ee.type.defaultProps),ee.props):ee.props,J=B.dataKey,oe=B.maxBarSize,ue=B["".concat(Y,"Id")],ve=B["".concat(G,"Id")],qe={},xe=u.reduce(function(cr,_t){var Sr=S["".concat(_t.axisType,"Map")],Ir=B["".concat(_t.axisType,"Id")];Sr&&Sr[Ir]||_t.axisType==="zAxis"||Mo();var ni=Sr[Ir];return ie(ie({},cr),{},ze(ze({},_t.axisType,ni),"".concat(_t.axisType,"Ticks"),Ki(ni)))},qe),ae=xe[G],Se=xe["".concat(G,"Ticks")],Me=C&&C[ue]&&C[ue].hasStack&&vY(ee,C[ue].stackGroups),se=Gi(ee.type).indexOf("Bar")>=0,rt=Ph(ae,Se),Fe=[],kt=Q&&rY({barSize:$,stackGroups:C,totalSize:Zne(xe,G)});if(se){var wt,Et,_r=tt(oe)?F:oe,Ut=(wt=(Et=Ph(ae,Se,!0))!==null&&Et!==void 0?Et:_r)!==null&&wt!==void 0?wt:0;Fe=nY({barGap:L,barCategoryGap:U,bandSize:Ut!==rt?Ut:rt,sizeList:kt[ve],maxBarSize:_r}),Ut!==rt&&(Fe=Fe.map(function(cr){return ie(ie({},cr),{},{position:ie(ie({},cr.position),{},{offset:cr.position.offset-Ut/2})})}))}var Rr=ee&&ee.type&&ee.type.getComposedData;Rr&&W.push({props:ie(ie({},Rr(ie(ie({},xe),{},{displayedData:I,props:k,dataKey:J,item:ee,bandSize:rt,barPosition:Fe,offset:T,stackedData:Me,layout:K,dataStartIndex:N,dataEndIndex:R}))),{},ze(ze(ze({key:ee.key||"item-".concat(q)},Y,xe[Y]),G,xe[G]),"animationId",O)),childIndex:aF(ee,k.children),item:ee})}),W},v=function(k,S){var A=k.props,C=k.dataStartIndex,T=k.dataEndIndex,O=k.updateId;if(!sO({props:A}))return null;var N=A.children,R=A.layout,$=A.stackOffset,K=A.data,L=A.reverseStackOrder,U=$N(R),F=U.numericAxisName,X=U.cateAxisName,Y=Cn(N,n),G=mY(K,Y,"".concat(F,"Id"),"".concat(X,"Id"),$,L),Q=u.reduce(function(B,J){var oe="".concat(J.axisType,"Map");return ie(ie({},B),{},ze({},oe,Vne(A,ie(ie({},J),{},{graphicalItems:Y,stackGroups:J.axisType===F&&G,dataStartIndex:C,dataEndIndex:T}))))},{}),W=Jne(ie(ie({},Q),{},{props:A,graphicalItems:Y}),S==null?void 0:S.legendBBox);Object.keys(Q).forEach(function(B){Q[B]=p(A,Q[B],W,B.replace("Map",""),r)});var ee=Q["".concat(X,"Map")],q=Xne(ee),I=m(A,ie(ie({},Q),{},{dataStartIndex:C,dataEndIndex:T,updateId:O,graphicalItems:Y,stackGroups:G,offset:W}));return ie(ie({formattedGraphicalItems:I,graphicalItems:Y,offset:W,stackGroups:G},q),Q)},b=(function(x){function k(S){var A,C,T;return Nne(this,k),T=Ine(this,k,[S]),ze(T,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),ze(T,"accessibilityManager",new yne),ze(T,"handleLegendBBoxUpdate",function(O){if(O){var N=T.state,R=N.dataStartIndex,$=N.dataEndIndex,K=N.updateId;T.setState(ie({legendBBox:O},v({props:T.props,dataStartIndex:R,dataEndIndex:$,updateId:K},ie(ie({},T.state),{},{legendBBox:O}))))}}),ze(T,"handleReceiveSyncEvent",function(O,N,R){if(T.props.syncId===O){if(R===T.eventEmitterSymbol&&typeof T.props.syncMethod!="function")return;T.applySyncEvent(N)}}),ze(T,"handleBrushChange",function(O){var N=O.startIndex,R=O.endIndex;if(N!==T.state.dataStartIndex||R!==T.state.dataEndIndex){var $=T.state.updateId;T.setState(function(){return ie({dataStartIndex:N,dataEndIndex:R},v({props:T.props,dataStartIndex:N,dataEndIndex:R,updateId:$},T.state))}),T.triggerSyncEvent({dataStartIndex:N,dataEndIndex:R})}}),ze(T,"handleMouseEnter",function(O){var N=T.getMouseInfo(O);if(N){var R=ie(ie({},N),{},{isTooltipActive:!0});T.setState(R),T.triggerSyncEvent(R);var $=T.props.onMouseEnter;Je($)&&$(R,O)}}),ze(T,"triggeredAfterMouseMove",function(O){var N=T.getMouseInfo(O),R=N?ie(ie({},N),{},{isTooltipActive:!0}):{isTooltipActive:!1};T.setState(R),T.triggerSyncEvent(R);var $=T.props.onMouseMove;Je($)&&$(R,O)}),ze(T,"handleItemMouseEnter",function(O){T.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),ze(T,"handleItemMouseLeave",function(){T.setState(function(){return{isTooltipActive:!1}})}),ze(T,"handleMouseMove",function(O){O.persist(),T.throttleTriggeredAfterMouseMove(O)}),ze(T,"handleMouseLeave",function(O){T.throttleTriggeredAfterMouseMove.cancel();var N={isTooltipActive:!1};T.setState(N),T.triggerSyncEvent(N);var R=T.props.onMouseLeave;Je(R)&&R(N,O)}),ze(T,"handleOuterEvent",function(O){var N=iF(O),R=Tn(T.props,"".concat(N));if(N&&Je(R)){var $,K;/.*touch.*/i.test(N)?K=T.getMouseInfo(O.changedTouches[0]):K=T.getMouseInfo(O),R(($=K)!==null&&$!==void 0?$:{},O)}}),ze(T,"handleClick",function(O){var N=T.getMouseInfo(O);if(N){var R=ie(ie({},N),{},{isTooltipActive:!0});T.setState(R),T.triggerSyncEvent(R);var $=T.props.onClick;Je($)&&$(R,O)}}),ze(T,"handleMouseDown",function(O){var N=T.props.onMouseDown;if(Je(N)){var R=T.getMouseInfo(O);N(R,O)}}),ze(T,"handleMouseUp",function(O){var N=T.props.onMouseUp;if(Je(N)){var R=T.getMouseInfo(O);N(R,O)}}),ze(T,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&T.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),ze(T,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&T.handleMouseDown(O.changedTouches[0])}),ze(T,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&T.handleMouseUp(O.changedTouches[0])}),ze(T,"handleDoubleClick",function(O){var N=T.props.onDoubleClick;if(Je(N)){var R=T.getMouseInfo(O);N(R,O)}}),ze(T,"handleContextMenu",function(O){var N=T.props.onContextMenu;if(Je(N)){var R=T.getMouseInfo(O);N(R,O)}}),ze(T,"triggerSyncEvent",function(O){T.props.syncId!==void 0&&Fb.emit(Hb,T.props.syncId,O,T.eventEmitterSymbol)}),ze(T,"applySyncEvent",function(O){var N=T.props,R=N.layout,$=N.syncMethod,K=T.state.updateId,L=O.dataStartIndex,U=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)T.setState(ie({dataStartIndex:L,dataEndIndex:U},v({props:T.props,dataStartIndex:L,dataEndIndex:U,updateId:K},T.state)));else if(O.activeTooltipIndex!==void 0){var F=O.chartX,X=O.chartY,Y=O.activeTooltipIndex,G=T.state,Q=G.offset,W=G.tooltipTicks;if(!Q)return;if(typeof $=="function")Y=$(W,O);else if($==="value"){Y=-1;for(var ee=0;ee<W.length;ee++)if(W[ee].value===O.activeLabel){Y=ee;break}}var q=ie(ie({},Q),{},{x:Q.left,y:Q.top}),I=Math.min(F,q.x+q.width),B=Math.min(X,q.y+q.height),J=W[Y]&&W[Y].value,oe=Nw(T.state,T.props.data,Y),ue=W[Y]?{x:R==="horizontal"?W[Y].coordinate:I,y:R==="horizontal"?B:W[Y].coordinate}:$M;T.setState(ie(ie({},O),{},{activeLabel:J,activeCoordinate:ue,activePayload:oe,activeTooltipIndex:Y}))}else T.setState(O)}),ze(T,"renderCursor",function(O){var N,R=T.state,$=R.isTooltipActive,K=R.activeCoordinate,L=R.activePayload,U=R.offset,F=R.activeTooltipIndex,X=R.tooltipAxisBandSize,Y=T.getTooltipEventType(),G=(N=O.props.active)!==null&&N!==void 0?N:$,Q=T.props.layout,W=O.key||"_recharts-cursor";return M.createElement(kne,{key:W,activeCoordinate:K,activePayload:L,activeTooltipIndex:F,chartName:r,element:O,isActive:G,layout:Q,offset:U,tooltipAxisBandSize:X,tooltipEventType:Y})}),ze(T,"renderPolarAxis",function(O,N,R){var $=Tn(O,"type.axisType"),K=Tn(T.state,"".concat($,"Map")),L=O.type.defaultProps,U=L!==void 0?ie(ie({},L),O.props):O.props,F=K&&K[U["".concat($,"Id")]];return j.cloneElement(O,ie(ie({},F),{},{className:ot($,F.className),key:O.key||"".concat(N,"-").concat(R),ticks:Ki(F,!0)}))}),ze(T,"renderPolarGrid",function(O){var N=O.props,R=N.radialLines,$=N.polarAngles,K=N.polarRadius,L=T.state,U=L.radiusAxisMap,F=L.angleAxisMap,X=Ra(U),Y=Ra(F),G=Y.cx,Q=Y.cy,W=Y.innerRadius,ee=Y.outerRadius;return j.cloneElement(O,{polarAngles:Array.isArray($)?$:Ki(Y,!0).map(function(q){return q.coordinate}),polarRadius:Array.isArray(K)?K:Ki(X,!0).map(function(q){return q.coordinate}),cx:G,cy:Q,innerRadius:W,outerRadius:ee,key:O.key||"polar-grid",radialLines:R})}),ze(T,"renderLegend",function(){var O=T.state.formattedGraphicalItems,N=T.props,R=N.children,$=N.width,K=N.height,L=T.props.margin||{},U=$-(L.left||0)-(L.right||0),F=j$({children:R,formattedGraphicalItems:O,legendWidth:U,legendContent:d});if(!F)return null;var X=F.item,Y=NN(F,Ene);return j.cloneElement(X,ie(ie({},Y),{},{chartWidth:$,chartHeight:K,margin:L,onBBoxUpdate:T.handleLegendBBoxUpdate}))}),ze(T,"renderTooltip",function(){var O,N=T.props,R=N.children,$=N.accessibilityLayer,K=sn(R,ln);if(!K)return null;var L=T.state,U=L.isTooltipActive,F=L.activeCoordinate,X=L.activePayload,Y=L.activeLabel,G=L.offset,Q=(O=K.props.active)!==null&&O!==void 0?O:U;return j.cloneElement(K,{viewBox:ie(ie({},G),{},{x:G.left,y:G.top}),active:Q,label:Y,payload:Q?X:[],coordinate:F,accessibilityLayer:$})}),ze(T,"renderBrush",function(O){var N=T.props,R=N.margin,$=N.data,K=T.state,L=K.offset,U=K.dataStartIndex,F=K.dataEndIndex,X=K.updateId;return j.cloneElement(O,{key:O.key||"_recharts-brush",onChange:Ef(T.handleBrushChange,O.props.onChange),data:$,x:ge(O.props.x)?O.props.x:L.left,y:ge(O.props.y)?O.props.y:L.top+L.height+L.brushBottom-(R.bottom||0),width:ge(O.props.width)?O.props.width:L.width,startIndex:U,endIndex:F,updateId:"brush-".concat(X)})}),ze(T,"renderReferenceElement",function(O,N,R){if(!O)return null;var $=T,K=$.clipPathId,L=T.state,U=L.xAxisMap,F=L.yAxisMap,X=L.offset,Y=O.type.defaultProps||{},G=O.props,Q=G.xAxisId,W=Q===void 0?Y.xAxisId:Q,ee=G.yAxisId,q=ee===void 0?Y.yAxisId:ee;return j.cloneElement(O,{key:O.key||"".concat(N,"-").concat(R),xAxis:U[W],yAxis:F[q],viewBox:{x:X.left,y:X.top,width:X.width,height:X.height},clipPathId:K})}),ze(T,"renderActivePoints",function(O){var N=O.item,R=O.activePoint,$=O.basePoint,K=O.childIndex,L=O.isRange,U=[],F=N.props.key,X=N.item.type.defaultProps!==void 0?ie(ie({},N.item.type.defaultProps),N.item.props):N.item.props,Y=X.activeDot,G=X.dataKey,Q=ie(ie({index:K,dataKey:G,cx:R.x,cy:R.y,r:4,fill:r_(N.item),strokeWidth:2,stroke:"#fff",payload:R.payload,value:R.value},at(Y,!1)),ih(Y));return U.push(k.renderActiveDot(Y,Q,"".concat(F,"-activePoint-").concat(K))),$?U.push(k.renderActiveDot(Y,ie(ie({},Q),{},{cx:$.x,cy:$.y}),"".concat(F,"-basePoint-").concat(K))):L&&U.push(null),U}),ze(T,"renderGraphicChild",function(O,N,R){var $=T.filterFormatItem(O,N,R);if(!$)return null;var K=T.getTooltipEventType(),L=T.state,U=L.isTooltipActive,F=L.tooltipAxis,X=L.activeTooltipIndex,Y=L.activeLabel,G=T.props.children,Q=sn(G,ln),W=$.props,ee=W.points,q=W.isRange,I=W.baseLine,B=$.item.type.defaultProps!==void 0?ie(ie({},$.item.type.defaultProps),$.item.props):$.item.props,J=B.activeDot,oe=B.hide,ue=B.activeBar,ve=B.activeShape,qe=!!(!oe&&U&&Q&&(J||ue||ve)),xe={};K!=="axis"&&Q&&Q.props.trigger==="click"?xe={onClick:Ef(T.handleItemMouseEnter,O.props.onClick)}:K!=="axis"&&(xe={onMouseLeave:Ef(T.handleItemMouseLeave,O.props.onMouseLeave),onMouseEnter:Ef(T.handleItemMouseEnter,O.props.onMouseEnter)});var ae=j.cloneElement(O,ie(ie({},$.props),xe));function Se(_t){return typeof F.dataKey=="function"?F.dataKey(_t.payload):null}if(qe)if(X>=0){var Me,se;if(F.dataKey&&!F.allowDuplicatedCategory){var rt=typeof F.dataKey=="function"?Se:"payload.".concat(F.dataKey.toString());Me=nh(ee,rt,Y),se=q&&I&&nh(I,rt,Y)}else Me=ee==null?void 0:ee[X],se=q&&I&&I[X];if(ve||ue){var Fe=O.props.activeIndex!==void 0?O.props.activeIndex:X;return[j.cloneElement(O,ie(ie(ie({},$.props),xe),{},{activeIndex:Fe})),null,null]}if(!tt(Me))return[ae].concat(fl(T.renderActivePoints({item:$,activePoint:Me,basePoint:se,childIndex:X,isRange:q})))}else{var kt,wt=(kt=T.getItemByXY(T.state.activeCoordinate))!==null&&kt!==void 0?kt:{graphicalItem:ae},Et=wt.graphicalItem,_r=Et.item,Ut=_r===void 0?O:_r,Rr=Et.childIndex,cr=ie(ie(ie({},$.props),xe),{},{activeIndex:Rr});return[j.cloneElement(Ut,cr),null,null]}return q?[ae,null,null]:[ae,null]}),ze(T,"renderCustomized",function(O,N,R){return j.cloneElement(O,ie(ie({key:"recharts-customized-".concat(R)},T.props),T.state))}),ze(T,"renderMap",{CartesianGrid:{handler:jf,once:!0},ReferenceArea:{handler:T.renderReferenceElement},ReferenceLine:{handler:jf},ReferenceDot:{handler:T.renderReferenceElement},XAxis:{handler:jf},YAxis:{handler:jf},Brush:{handler:T.renderBrush,once:!0},Bar:{handler:T.renderGraphicChild},Line:{handler:T.renderGraphicChild},Area:{handler:T.renderGraphicChild},Radar:{handler:T.renderGraphicChild},RadialBar:{handler:T.renderGraphicChild},Scatter:{handler:T.renderGraphicChild},Pie:{handler:T.renderGraphicChild},Funnel:{handler:T.renderGraphicChild},Tooltip:{handler:T.renderCursor,once:!0},PolarGrid:{handler:T.renderPolarGrid,once:!0},PolarAngleAxis:{handler:T.renderPolarAxis},PolarRadiusAxis:{handler:T.renderPolarAxis},Customized:{handler:T.renderCustomized}}),T.clipPathId="".concat((A=S.id)!==null&&A!==void 0?A:zu("recharts"),"-clip"),T.throttleTriggeredAfterMouseMove=jI(T.triggeredAfterMouseMove,(C=S.throttleDelay)!==null&&C!==void 0?C:1e3/60),T.state={},T}return Dne(k,x),Rne(k,[{key:"componentDidMount",value:function(){var A,C;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(C=this.props.margin.top)!==null&&C!==void 0?C:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var A=this.props,C=A.children,T=A.data,O=A.height,N=A.layout,R=sn(C,ln);if(R){var $=R.props.defaultIndex;if(!(typeof $!="number"||$<0||$>this.state.tooltipTicks.length-1)){var K=this.state.tooltipTicks[$]&&this.state.tooltipTicks[$].value,L=Nw(this.state,T,$,K),U=this.state.tooltipTicks[$].coordinate,F=(this.state.offset.top+O)/2,X=N==="horizontal",Y=X?{x:U,y:F}:{y:U,x:F},G=this.state.formattedGraphicalItems.find(function(W){var ee=W.item;return ee.type.name==="Scatter"});G&&(Y=ie(ie({},Y),G.props.points[$].tooltipPosition),L=G.props.points[$].tooltipPayload);var Q={activeTooltipIndex:$,isTooltipActive:!0,activeLabel:K,activePayload:L,activeCoordinate:Y};this.setState(Q),this.renderCursor(R),this.accessibilityManager.setIndex($)}}}},{key:"getSnapshotBeforeUpdate",value:function(A,C){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==C.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==A.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==A.margin){var T,O;this.accessibilityManager.setDetails({offset:{left:(T=this.props.margin.left)!==null&&T!==void 0?T:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(A){gx([sn(A.children,ln)],[sn(this.props.children,ln)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var A=sn(this.props.children,ln);if(A&&typeof A.props.shared=="boolean"){var C=A.props.shared?"axis":"item";return c.indexOf(C)>=0?C:a}return a}},{key:"getMouseInfo",value:function(A){if(!this.container)return null;var C=this.container,T=C.getBoundingClientRect(),O=WW(T),N={chartX:Math.round(A.pageX-O.left),chartY:Math.round(A.pageY-O.top)},R=T.width/C.offsetWidth||1,$=this.inRange(N.chartX,N.chartY,R);if(!$)return null;var K=this.state,L=K.xAxisMap,U=K.yAxisMap,F=this.getTooltipEventType(),X=RN(this.state,this.props.data,this.props.layout,$);if(F!=="axis"&&L&&U){var Y=Ra(L).scale,G=Ra(U).scale,Q=Y&&Y.invert?Y.invert(N.chartX):null,W=G&&G.invert?G.invert(N.chartY):null;return ie(ie({},N),{},{xValue:Q,yValue:W},X)}return X?ie(ie({},N),X):null}},{key:"inRange",value:function(A,C){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,N=A/T,R=C/T;if(O==="horizontal"||O==="vertical"){var $=this.state.offset,K=N>=$.left&&N<=$.left+$.width&&R>=$.top&&R<=$.top+$.height;return K?{x:N,y:R}:null}var L=this.state,U=L.angleAxisMap,F=L.radiusAxisMap;if(U&&F){var X=Ra(U);return Yj({x:N,y:R},X)}return null}},{key:"parseEventsOfWrapper",value:function(){var A=this.props.children,C=this.getTooltipEventType(),T=sn(A,ln),O={};T&&C==="axis"&&(T.props.trigger==="click"?O={onClick:this.handleClick}:O={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var N=ih(this.props,this.handleOuterEvent);return ie(ie({},N),O)}},{key:"addListener",value:function(){Fb.on(Hb,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Fb.removeListener(Hb,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(A,C,T){for(var O=this.state.formattedGraphicalItems,N=0,R=O.length;N<R;N++){var $=O[N];if($.item===A||$.props.key===A.key||C===Gi($.item.type)&&T===$.childIndex)return $}return null}},{key:"renderClipPath",value:function(){var A=this.clipPathId,C=this.state.offset,T=C.left,O=C.top,N=C.height,R=C.width;return M.createElement("defs",null,M.createElement("clipPath",{id:A},M.createElement("rect",{x:T,y:O,height:N,width:R})))}},{key:"getXScales",value:function(){var A=this.state.xAxisMap;return A?Object.entries(A).reduce(function(C,T){var O=jN(T,2),N=O[0],R=O[1];return ie(ie({},C),{},ze({},N,R.scale))},{}):null}},{key:"getYScales",value:function(){var A=this.state.yAxisMap;return A?Object.entries(A).reduce(function(C,T){var O=jN(T,2),N=O[0],R=O[1];return ie(ie({},C),{},ze({},N,R.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(A){var C;return(C=this.state.xAxisMap)===null||C===void 0||(C=C[A])===null||C===void 0?void 0:C.scale}},{key:"getYScaleByAxisId",value:function(A){var C;return(C=this.state.yAxisMap)===null||C===void 0||(C=C[A])===null||C===void 0?void 0:C.scale}},{key:"getItemByXY",value:function(A){var C=this.state,T=C.formattedGraphicalItems,O=C.activeItem;if(T&&T.length)for(var N=0,R=T.length;N<R;N++){var $=T[N],K=$.props,L=$.item,U=L.type.defaultProps!==void 0?ie(ie({},L.type.defaultProps),L.props):L.props,F=Gi(L.type);if(F==="Bar"){var X=(K.data||[]).find(function(W){return fQ(A,W)});if(X)return{graphicalItem:$,payload:X}}else if(F==="RadialBar"){var Y=(K.data||[]).find(function(W){return Yj(A,W)});if(Y)return{graphicalItem:$,payload:Y}}else if(zp($,O)||Bp($,O)||ku($,O)){var G=ree({graphicalItem:$,activeTooltipItem:O,itemData:U.data}),Q=U.activeIndex===void 0?G:U.activeIndex;return{graphicalItem:ie(ie({},$),{},{childIndex:Q}),payload:ku($,O)?U.data[G]:$.props.data[G]}}}return null}},{key:"render",value:function(){var A=this;if(!sO(this))return null;var C=this.props,T=C.children,O=C.className,N=C.width,R=C.height,$=C.style,K=C.compact,L=C.title,U=C.desc,F=NN(C,Ane),X=at(F,!1);if(K)return M.createElement(dN,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},M.createElement(vx,$s({},X,{width:N,height:R,title:L,desc:U}),this.renderClipPath(),cO(T,this.renderMap)));if(this.props.accessibilityLayer){var Y,G;X.tabIndex=(Y=this.props.tabIndex)!==null&&Y!==void 0?Y:0,X.role=(G=this.props.role)!==null&&G!==void 0?G:"application",X.onKeyDown=function(W){A.accessibilityManager.keyboardEvent(W)},X.onFocus=function(){A.accessibilityManager.focus()}}var Q=this.parseEventsOfWrapper();return M.createElement(dN,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},M.createElement("div",$s({className:ot("recharts-wrapper",O),style:ie({position:"relative",cursor:"default",width:N,height:R},$)},Q,{ref:function(ee){A.container=ee}}),M.createElement(vx,$s({},X,{width:N,height:R,title:L,desc:U,style:Fne}),this.renderClipPath(),cO(T,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(j.Component);ze(b,"displayName",r),ze(b,"defaultProps",ie({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},f)),ze(b,"getDerivedStateFromProps",function(x,k){var S=x.dataKey,A=x.data,C=x.children,T=x.width,O=x.height,N=x.layout,R=x.stackOffset,$=x.margin,K=k.dataStartIndex,L=k.dataEndIndex;if(k.updateId===void 0){var U=IN(x);return ie(ie(ie({},U),{},{updateId:0},v(ie(ie({props:x},U),{},{updateId:0}),k)),{},{prevDataKey:S,prevData:A,prevWidth:T,prevHeight:O,prevLayout:N,prevStackOffset:R,prevMargin:$,prevChildren:C})}if(S!==k.prevDataKey||A!==k.prevData||T!==k.prevWidth||O!==k.prevHeight||N!==k.prevLayout||R!==k.prevStackOffset||!zs($,k.prevMargin)){var F=IN(x),X={chartX:k.chartX,chartY:k.chartY,isTooltipActive:k.isTooltipActive},Y=ie(ie({},RN(k,A,N)),{},{updateId:k.updateId+1}),G=ie(ie(ie({},F),X),Y);return ie(ie(ie({},G),v(ie({props:x},G),k)),{},{prevDataKey:S,prevData:A,prevWidth:T,prevHeight:O,prevLayout:N,prevStackOffset:R,prevMargin:$,prevChildren:C})}if(!gx(C,k.prevChildren)){var Q,W,ee,q,I=sn(C,rl),B=I&&(Q=(W=I.props)===null||W===void 0?void 0:W.startIndex)!==null&&Q!==void 0?Q:K,J=I&&(ee=(q=I.props)===null||q===void 0?void 0:q.endIndex)!==null&&ee!==void 0?ee:L,oe=B!==K||J!==L,ue=!tt(A),ve=ue&&!oe?k.updateId:k.updateId+1;return ie(ie({updateId:ve},v(ie(ie({props:x},k),{},{updateId:ve,dataStartIndex:B,dataEndIndex:J}),k)),{},{prevChildren:C,dataStartIndex:B,dataEndIndex:J})}return null}),ze(b,"renderActiveDot",function(x,k,S){var A;return j.isValidElement(x)?A=j.cloneElement(x,k):Je(x)?A=x(k):A=M.createElement(i_,k),M.createElement(Xt,{className:"recharts-active-dot",key:S},A)});var w=j.forwardRef(function(k,S){return M.createElement(b,$s({},k,{ref:S}))});return w.displayName=b.displayName,w},Qne=DM({chartName:"LineChart",GraphicalChild:Ku,axisComponents:[{axisType:"xAxis",AxisComp:Ua},{axisType:"yAxis",AxisComp:qa}],formatAxisMap:rM}),Pw=DM({chartName:"BarChart",GraphicalChild:ta,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Ua},{axisType:"yAxis",AxisComp:qa}],formatAxisMap:rM});const rp={backgroundColor:"#1e1e1e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"12px",color:"#e4e0dc",fontSize:"11px",fontFamily:"JetBrains Mono, monospace"};function It(t){return t>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(Math.round(t))}function Zn(t){return`$${t.toFixed(2)}`}function Ma({label:t,value:e,sub:r,accent:n}){return y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl px-5 py-4",children:[y.jsx("p",{className:"text-[11px] font-mono text-zinc-600 mb-1",children:t}),y.jsx("p",{className:`text-xl font-mono font-medium ${n?"text-[#E43A9C]":"text-zinc-100"}`,children:e}),r&&y.jsx("p",{className:"text-[10px] font-mono text-zinc-600 mt-0.5",children:r})]})}const eie={summary:"Summary","by squad":"By Squad","by agent":"By Agent",io:"IO",timeline:"Timeline"};function tie({tabs:t,active:e,onChange:r}){return y.jsx("div",{className:"flex gap-0 border-b border-white/[0.06] mb-5",children:t.map(n=>y.jsx("button",{type:"button",onClick:()=>r(n),className:`px-4 py-2 text-[11px] font-mono transition-colors border-b-2 -mb-px cursor-pointer ${e===n?"text-[#E43A9C] border-[#E43A9C]":"text-zinc-600 hover:text-zinc-300 border-transparent"}`,children:eie[n]??n},n))})}function rie({records:t,totals:e}){const r=e.totalInputTokens+e.totalOutputTokens,n=new Map;for(const o of t){const c=o.squadId??"__io__",u=o.squadName??(o.squadId?`${o.squadId.slice(0,8)} (deleted)`:"IO Orchestrator"),d=n.get(c)??{name:u,inputTokens:0,outputTokens:0,calls:0,cost:0};d.inputTokens+=o.inputTokens,d.outputTokens+=o.outputTokens,d.calls+=1,d.cost+=o.estimatedCostUsd??0,n.set(c,d)}const i=Array.from(n.values()).sort((o,c)=>c.cost-o.cost),a=i.map(o=>({name:o.name.length>12?`${o.name.slice(0,12)}…`:o.name,cost:Number.parseFloat(o.cost.toFixed(2)),tokens:Math.round((o.inputTokens+o.outputTokens)/1e3)}));return y.jsxs("div",{className:"space-y-5",children:[y.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[y.jsx(Ma,{label:"Total Tokens",value:It(r),sub:`${It(e.totalInputTokens)} in · ${It(e.totalOutputTokens)} out`}),y.jsx(Ma,{label:"Total Cost",value:Zn(e.totalCostUsd),accent:!0}),y.jsx(Ma,{label:"API Calls",value:It(e.callCount),sub:"across all entities"}),y.jsx(Ma,{label:"Avg Cost / Call",value:e.callCount>0?Zn(e.totalCostUsd/e.callCount):"$0.00",sub:`over ${e.callCount} calls`})]}),y.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:[y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl p-4",children:[y.jsx("p",{className:"text-[11px] font-mono text-zinc-500 mb-3",children:"Cost by entity"}),a.length>0?y.jsx(mh,{width:"100%",height:180,children:y.jsxs(Pw,{data:a,barCategoryGap:"35%",children:[y.jsx(Cu,{vertical:!1,stroke:"rgba(255,255,255,0.04)"}),y.jsx(Ua,{dataKey:"name",tick:{fill:"#52525b",fontSize:10,fontFamily:"JetBrains Mono, monospace"},axisLine:!1,tickLine:!1}),y.jsx(qa,{tick:{fill:"#52525b",fontSize:10,fontFamily:"JetBrains Mono, monospace"},axisLine:!1,tickLine:!1,tickFormatter:o=>`$${o}`,width:40}),y.jsx(ln,{contentStyle:rp,cursor:{fill:"rgba(255,255,255,0.03)"},formatter:o=>[`$${o.toFixed(2)}`,"Cost"]}),y.jsx(ta,{dataKey:"cost",fill:"url(#costGrad)",radius:[6,6,0,0]}),y.jsx("defs",{children:y.jsxs("linearGradient",{id:"costGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[y.jsx("stop",{offset:"0%",stopColor:"#E43A9C"}),y.jsx("stop",{offset:"100%",stopColor:"#D83333",stopOpacity:.7})]})})]})}):y.jsx("div",{className:"h-[180px] flex items-center justify-center text-zinc-700 text-[11px] font-mono",children:"No data"})]}),y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl p-4",children:[y.jsx("p",{className:"text-[11px] font-mono text-zinc-500 mb-3",children:"Tokens by entity (k)"}),a.length>0?y.jsx(mh,{width:"100%",height:180,children:y.jsxs(Pw,{data:a,barCategoryGap:"35%",children:[y.jsx(Cu,{vertical:!1,stroke:"rgba(255,255,255,0.04)"}),y.jsx(Ua,{dataKey:"name",tick:{fill:"#52525b",fontSize:10,fontFamily:"JetBrains Mono, monospace"},axisLine:!1,tickLine:!1}),y.jsx(qa,{tick:{fill:"#52525b",fontSize:10,fontFamily:"JetBrains Mono, monospace"},axisLine:!1,tickLine:!1,tickFormatter:o=>`${o}k`,width:40}),y.jsx(ln,{contentStyle:rp,cursor:{fill:"rgba(255,255,255,0.03)"},formatter:o=>[`${o}k`,"Tokens"]}),y.jsx(ta,{dataKey:"tokens",fill:"url(#tokenGrad)",radius:[6,6,0,0]}),y.jsx("defs",{children:y.jsxs("linearGradient",{id:"tokenGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[y.jsx("stop",{offset:"0%",stopColor:"#818cf8"}),y.jsx("stop",{offset:"100%",stopColor:"#6366f1",stopOpacity:.7})]})})]})}):y.jsx("div",{className:"h-[180px] flex items-center justify-center text-zinc-700 text-[11px] font-mono",children:"No data"})]})]}),y.jsx("div",{className:"overflow-auto rounded-2xl border border-white/[0.07] glass-card",children:y.jsxs("table",{className:"w-full text-[11px] font-mono",children:[y.jsx("thead",{children:y.jsx("tr",{className:"border-b border-white/[0.06] bg-[#1a1a1a]",children:["Entity","Input","Output","Calls","Cost"].map(o=>y.jsx("th",{className:`text-left px-4 py-2.5 text-zinc-600 font-medium ${o==="Cost"?"text-right":""}`,children:o},o))})}),y.jsxs("tbody",{children:[i.map(o=>y.jsxs("tr",{className:"border-b border-white/[0.04] hover:bg-white/[0.015] transition-colors",children:[y.jsx("td",{className:"px-4 py-3 text-zinc-300",children:o.name}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:It(o.inputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:It(o.outputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:o.calls}),y.jsx("td",{className:"px-4 py-3 text-right text-[#E43A9C]",children:Zn(o.cost)})]},o.name)),y.jsxs("tr",{className:"bg-[#1a1a1a]",children:[y.jsx("td",{className:"px-4 py-3 text-zinc-200 font-medium",children:"Total"}),y.jsx("td",{className:"px-4 py-3 text-zinc-300",children:It(e.totalInputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-300",children:It(e.totalOutputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-300",children:e.callCount}),y.jsx("td",{className:"px-4 py-3 text-right text-[#E43A9C] font-medium",children:Zn(e.totalCostUsd)})]})]})]})})]})}function nie({records:t}){const[e,r]=j.useState([]),[n,i]=j.useState("cost"),[a,o]=j.useState("desc");function c(f){f===n?o(m=>m==="asc"?"desc":"asc"):(i(f),o("desc"))}const u=j.useMemo(()=>{const f=new Map;for(const v of t){if(!v.squadId)continue;const b=f.get(v.squadId)??{id:v.squadId,name:v.squadName??`${v.squadId.slice(0,8)} (deleted)`,agents:new Map,inputTokens:0,outputTokens:0,calls:0,cost:0};b.inputTokens+=v.inputTokens,b.outputTokens+=v.outputTokens,b.calls+=1,b.cost+=v.estimatedCostUsd??0;const w=`${v.agentRole??"unknown"}:${v.model}`,x=b.agents.get(w)??{role:v.agentRole??"unknown",model:v.model,inputTokens:0,outputTokens:0,calls:0,cost:0};x.inputTokens+=v.inputTokens,x.outputTokens+=v.outputTokens,x.calls+=1,x.cost+=v.estimatedCostUsd??0,b.agents.set(w,x),f.set(v.squadId,b)}return[...Array.from(f.values())].sort((v,b)=>{const w=v[n],x=b[n],k=typeof w=="string"?w.localeCompare(x):w-x;return a==="desc"?-k:k})},[t,n,a]),d=f=>r(m=>m.includes(f)?m.filter(v=>v!==f):[...m,f]),p=[{key:"name",label:"Squad"},{key:"inputTokens",label:"In"},{key:"outputTokens",label:"Out"},{key:"calls",label:"Calls"},{key:"cost",label:"Cost"}];return u.length===0?y.jsx("div",{className:"text-center py-12 text-zinc-700 text-[11px] font-mono",children:"No squad usage data"}):y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"flex items-center gap-1 px-1 mb-1",children:[y.jsx("span",{className:"text-[10px] font-mono text-zinc-700 mr-1",children:"sort by"}),p.map(f=>y.jsxs("button",{type:"button",onClick:()=>c(f.key),className:`flex items-center gap-0.5 px-2 py-1 rounded-lg text-[10px] font-mono transition-colors ${n===f.key?"text-[#E43A9C]":"text-zinc-600 hover:text-zinc-400 hover:bg-white/[0.04]"}`,style:n===f.key?{background:"rgba(228,58,156,0.1)"}:void 0,children:[f.label,n===f.key&&y.jsx("span",{className:"text-[9px]",children:a==="desc"?"↓":"↑"})]},f.key))]}),u.map(f=>{const m=e.includes(f.id),v=Array.from(f.agents.values());return y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl overflow-hidden",children:[y.jsxs("button",{type:"button",onClick:()=>d(f.id),className:"w-full flex items-center gap-3 px-4 py-3.5 hover:bg-white/[0.02] transition-colors text-left cursor-pointer",children:[y.jsx("div",{className:`transition-transform ${m?"rotate-90":""}`,children:y.jsx(Qw,{className:"w-3.5 h-3.5 text-zinc-600"})}),y.jsx("span",{className:"text-sm font-mono text-zinc-100 flex-1",children:f.name}),y.jsxs("div",{className:"flex items-center gap-6 text-[11px] font-mono",children:[y.jsxs("span",{className:"text-zinc-500 hidden sm:block",children:[y.jsx("span",{className:"text-zinc-700 mr-1",children:"in"}),It(f.inputTokens)]}),y.jsxs("span",{className:"text-zinc-500 hidden sm:block",children:[y.jsx("span",{className:"text-zinc-700 mr-1",children:"out"}),It(f.outputTokens)]}),y.jsxs("span",{className:"text-zinc-500",children:[y.jsx("span",{className:"text-zinc-700 mr-1",children:"calls"}),f.calls]}),y.jsx("span",{className:"text-[#E43A9C] font-medium w-16 text-right",children:Zn(f.cost)})]})]}),m&&y.jsx("div",{className:"border-t border-white/[0.05]",children:y.jsxs("table",{className:"w-full text-[11px] font-mono",children:[y.jsx("thead",{children:y.jsx("tr",{className:"bg-[#191919]",children:["Agent","Model","Input","Output","Calls","Cost"].map(b=>y.jsx("th",{className:`text-left px-4 py-2 text-zinc-700 font-medium ${b==="Cost"?"text-right":""}`,children:b},b))})}),y.jsx("tbody",{children:v.map(b=>y.jsxs("tr",{className:"border-t border-white/[0.04] hover:bg-white/[0.015] transition-colors",children:[y.jsx("td",{className:"px-4 py-2.5 text-zinc-300",children:b.role}),y.jsx("td",{className:"px-4 py-2.5 text-zinc-600",children:b.model}),y.jsx("td",{className:"px-4 py-2.5 text-zinc-500",children:It(b.inputTokens)}),y.jsx("td",{className:"px-4 py-2.5 text-zinc-500",children:It(b.outputTokens)}),y.jsx("td",{className:"px-4 py-2.5 text-zinc-500",children:b.calls}),y.jsx("td",{className:"px-4 py-2.5 text-right text-[#E43A9C]",children:Zn(b.cost)})]},b.role))})]})})]},f.id)})]})}function iie({records:t}){const e=j.useMemo(()=>{const n=new Map;for(const i of t){const a=`${i.squadId??"io"}:${i.agentRole??"orchestrator"}:${i.model}`,o=n.get(a)??{name:i.agentRole??"orchestrator",squad:i.squadName??(i.squadId?i.squadId.slice(0,8):"IO"),model:i.model,inputTokens:0,outputTokens:0,calls:0,cost:0};o.inputTokens+=i.inputTokens,o.outputTokens+=i.outputTokens,o.calls+=1,o.cost+=i.estimatedCostUsd??0,n.set(a,o)}return Array.from(n.values()).sort((i,a)=>a.cost-i.cost)},[t]),r=e.reduce((n,i)=>n+i.cost,0);return y.jsx("div",{className:"overflow-auto rounded-2xl border border-white/[0.07] glass-card",children:y.jsxs("table",{className:"w-full text-[11px] font-mono",children:[y.jsx("thead",{children:y.jsx("tr",{className:"border-b border-white/[0.06] bg-[#1a1a1a]",children:["Agent","Squad","Model","Input","Output","Calls","Cost","% of total"].map(n=>y.jsx("th",{className:`text-left px-4 py-2.5 text-zinc-600 font-medium ${n==="Cost"?"text-right":""}`,children:n},n))})}),y.jsx("tbody",{children:e.map(n=>y.jsxs("tr",{className:"border-b border-white/[0.04] hover:bg-white/[0.015] transition-colors",children:[y.jsx("td",{className:"px-4 py-3 text-zinc-300",children:n.name}),y.jsx("td",{className:"px-4 py-3 text-zinc-600",children:n.squad}),y.jsx("td",{className:"px-4 py-3 text-zinc-600",children:n.model}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:It(n.inputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:It(n.outputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:n.calls}),y.jsx("td",{className:"px-4 py-3 text-right text-[#E43A9C]",children:Zn(n.cost)}),y.jsx("td",{className:"px-4 py-3",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("div",{className:"w-16 h-1.5 rounded-full bg-[#252525] overflow-hidden",children:y.jsx("div",{className:"h-full bg-[#E43A9C] rounded-full",style:{width:`${r>0?n.cost/r*100:0}%`}})}),y.jsx("span",{className:"text-zinc-600 text-[10px]",children:r>0?`${(n.cost/r*100).toFixed(1)}%`:"0%"})]})})]},`${n.squad}:${n.name}`))})]})})}function aie({records:t}){const e=j.useMemo(()=>t.filter(o=>!o.squadId),[t]),r=j.useMemo(()=>{const o=new Map;for(const c of e){const u=`${c.agentRole??"orchestrator"}:${c.model}`,d=o.get(u)??{name:c.agentRole??"orchestrator",model:c.model,inputTokens:0,outputTokens:0,calls:0,cost:0};d.inputTokens+=c.inputTokens,d.outputTokens+=c.outputTokens,d.calls+=1,d.cost+=c.estimatedCostUsd??0,o.set(u,d)}return Array.from(o.values()).sort((c,u)=>u.cost-c.cost)},[e]),n=e.reduce((o,c)=>o+c.inputTokens,0),i=e.reduce((o,c)=>o+c.outputTokens,0),a=e.reduce((o,c)=>o+(c.estimatedCostUsd??0),0);return y.jsxs("div",{className:"space-y-5",children:[y.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[y.jsx(Ma,{label:"IO Tokens",value:It(n+i),sub:`${It(n)} in · ${It(i)} out`}),y.jsx(Ma,{label:"IO Cost",value:Zn(a),accent:!0}),y.jsx(Ma,{label:"IO Calls",value:It(e.length)}),y.jsx(Ma,{label:"IO Roles",value:String(r.length)})]}),y.jsx("div",{className:"overflow-auto rounded-2xl border border-white/[0.07] glass-card",children:y.jsxs("table",{className:"w-full text-[11px] font-mono",children:[y.jsx("thead",{children:y.jsx("tr",{className:"border-b border-white/[0.06] bg-[#1a1a1a]",children:["Role","Model","Input","Output","Calls","Cost"].map(o=>y.jsx("th",{className:`text-left px-4 py-2.5 text-zinc-600 font-medium ${o==="Cost"?"text-right":""}`,children:o},o))})}),y.jsx("tbody",{children:r.map(o=>y.jsxs("tr",{className:"border-b border-white/[0.04] hover:bg-white/[0.015] transition-colors",children:[y.jsx("td",{className:"px-4 py-3 text-zinc-300",children:o.name}),y.jsx("td",{className:"px-4 py-3 text-zinc-600",children:o.model}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:It(o.inputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:It(o.outputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:o.calls}),y.jsx("td",{className:"px-4 py-3 text-right text-[#E43A9C]",children:Zn(o.cost)})]},o.name))})]})})]})}function oie({records:t}){const e=Fa(),r=j.useMemo(()=>{const i=new Map;for(const a of t){const o=a.timestamp.slice(0,10),c=i.get(o)??{date:o,inputTokens:0,outputTokens:0,cost:0,calls:0};c.inputTokens+=a.inputTokens,c.outputTokens+=a.outputTokens,c.cost+=a.estimatedCostUsd??0,c.calls+=1,i.set(o,c)}return Array.from(i.values()).sort((a,o)=>a.date.localeCompare(o.date))},[t]),n=r.map(i=>({...i,label:ez(i.date,e),tokens:i.inputTokens+i.outputTokens}));return y.jsxs("div",{className:"space-y-5",children:[y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl p-5",children:[y.jsx("p",{className:"text-[11px] font-mono text-zinc-500 mb-3",children:"Tokens per day"}),n.length>0?y.jsx(mh,{width:"100%",height:220,children:y.jsxs(Qne,{data:n,children:[y.jsx(Cu,{vertical:!1,stroke:"rgba(255,255,255,0.04)"}),y.jsx(Ua,{dataKey:"label",tick:{fill:"#52525b",fontSize:10,fontFamily:"JetBrains Mono, monospace"},axisLine:!1,tickLine:!1}),y.jsx(qa,{tick:{fill:"#52525b",fontSize:10,fontFamily:"JetBrains Mono, monospace"},axisLine:!1,tickLine:!1,tickFormatter:It,width:44}),y.jsx(ln,{contentStyle:rp,cursor:{fill:"rgba(255,255,255,0.03)"},formatter:i=>[It(i),"Tokens"]}),y.jsx(Ku,{type:"monotone",dataKey:"tokens",stroke:"#E43A9C",strokeWidth:2,dot:!1})]})}):y.jsx("div",{className:"h-[220px] flex items-center justify-center text-zinc-700 text-[11px] font-mono",children:"No data"})]}),y.jsxs("div",{className:"glass-card border border-white/[0.07] rounded-2xl p-5",children:[y.jsx("p",{className:"text-[11px] font-mono text-zinc-500 mb-3",children:"Cost per day"}),n.length>0?y.jsx(mh,{width:"100%",height:180,children:y.jsxs(Pw,{data:n,barCategoryGap:"20%",children:[y.jsx(Cu,{vertical:!1,stroke:"rgba(255,255,255,0.04)"}),y.jsx(Ua,{dataKey:"label",tick:{fill:"#52525b",fontSize:10,fontFamily:"JetBrains Mono, monospace"},axisLine:!1,tickLine:!1}),y.jsx(qa,{tick:{fill:"#52525b",fontSize:10,fontFamily:"JetBrains Mono, monospace"},axisLine:!1,tickLine:!1,tickFormatter:i=>`$${i.toFixed(2)}`,width:44}),y.jsx(ln,{contentStyle:rp,cursor:{fill:"rgba(255,255,255,0.03)"},formatter:i=>[Zn(i),"Cost"]}),y.jsx(ta,{dataKey:"cost",fill:"url(#costGradTl)",radius:[4,4,0,0]}),y.jsx("defs",{children:y.jsxs("linearGradient",{id:"costGradTl",x1:"0",y1:"0",x2:"0",y2:"1",children:[y.jsx("stop",{offset:"0%",stopColor:"#E43A9C"}),y.jsx("stop",{offset:"100%",stopColor:"#D83333",stopOpacity:.7})]})})]})}):y.jsx("div",{className:"h-[180px] flex items-center justify-center text-zinc-700 text-[11px] font-mono",children:"No data"})]}),y.jsx("div",{className:"overflow-auto rounded-2xl border border-white/[0.07] glass-card",children:y.jsxs("table",{className:"w-full text-[11px] font-mono",children:[y.jsx("thead",{children:y.jsx("tr",{className:"border-b border-white/[0.06] bg-[#1a1a1a]",children:["Date","Input","Output","Calls","Cost"].map(i=>y.jsx("th",{className:`text-left px-4 py-2.5 text-zinc-600 font-medium ${i==="Cost"?"text-right":""}`,children:i},i))})}),y.jsx("tbody",{children:r.map(i=>y.jsxs("tr",{className:"border-b border-white/[0.04] hover:bg-white/[0.015] transition-colors",children:[y.jsx("td",{className:"px-4 py-3 text-zinc-300",children:i.date}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:It(i.inputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:It(i.outputTokens)}),y.jsx("td",{className:"px-4 py-3 text-zinc-500",children:i.calls}),y.jsx("td",{className:"px-4 py-3 text-right text-[#E43A9C]",children:Zn(i.cost)})]},i.date))})]})})]})}function sie(){const[t,e]=j.useState("summary"),[r,n]=j.useState(null),[i,a]=j.useState("14d"),o=["summary","by squad","by agent","io","timeline"];if(j.useEffect(()=>{const u=new Date;i==="7d"?u.setDate(u.getDate()-7):i==="14d"?u.setDate(u.getDate()-14):i==="30d"?u.setDate(u.getDate()-30):u.setDate(u.getDate()-1),Ge.get(`/usage?since=${u.toISOString()}`).then(n).catch(()=>{})},[i]),!r)return y.jsx("div",{className:"h-full flex items-center justify-center text-zinc-600 font-mono text-[11px]",children:"Loading..."});const c=i==="1d"?"Today":`Last ${i}`;return y.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[y.jsxs("div",{className:"flex items-start justify-between mb-5 gap-4 flex-wrap",children:[y.jsxs("div",{children:[y.jsx("h2",{className:"text-2xl tracking-wide text-zinc-100",style:{fontFamily:"'Bebas Neue', sans-serif"},children:"Usage"}),y.jsx("p",{className:"text-[11px] text-zinc-600 font-mono mt-0.5",children:c})]}),y.jsx("div",{className:"flex gap-1 p-1 rounded-xl bg-white/[0.03] border border-white/[0.07]",children:["1d","7d","14d","30d"].map(u=>y.jsx("button",{type:"button",onClick:()=>a(u),className:`px-3 py-1.5 rounded-lg text-[11px] font-mono transition-colors cursor-pointer ${i===u?"text-[#E43A9C]":"text-zinc-600 hover:text-zinc-400"}`,style:i===u?{background:"rgba(228,58,156,0.12)"}:void 0,children:u},u))})]}),y.jsx(tie,{tabs:o,active:t,onChange:u=>e(u)}),t==="summary"&&y.jsx(rie,{records:r.records,totals:r.totals}),t==="by squad"&&y.jsx(nie,{records:r.records}),t==="by agent"&&y.jsx(iie,{records:r.records}),t==="io"&&y.jsx(aie,{records:r.records}),t==="timeline"&&y.jsx(oie,{records:r.records})]})}function LM(t){return[...t].sort((e,r)=>e.isDir!==r.isDir?e.isDir?-1:1:e.name.localeCompare(r.name)).map(e=>({...e,children:LM(e.children)}))}function lie(t){const e=[];for(const r of t){const n=r.path.split("/").filter(Boolean);let i=e,a="";if(r.isDir){for(const o of n){a=a?`${a}/${o}`:o;let c=i.find(u=>u.path===a);c||(c={name:o,path:a,isDir:!0,children:[]},i.push(c)),i=c.children}continue}for(const[o,c]of n.entries()){const u=o===n.length-1;a=a?`${a}/${c}`:c;let d=i.find(p=>p.path===a);d||(d={name:u&&r.name||c,path:a,isDir:!u,children:[]},i.push(d)),i=d.children}}return LM(e)}function zM(t,e){return e?t.flatMap(r=>{const n=r.name.toLowerCase().includes(e)||r.path.toLowerCase().includes(e);if(!r.isDir)return n?[r]:[];if(n)return[r];const i=zM(r.children,e);return i.length?[{...r,children:i}]:[]}):t}function Rw(t){const e=new Set;for(const r of t)if(r.isDir){e.add(r.path);for(const n of Rw(r.children))e.add(n)}return e}function cie(t){const e=t.split("/").filter(Boolean),r=[];let n="";for(const i of e.slice(0,-1))n=n?`${n}/${i}`:i,r.push(n);return r}function BM({node:t,depth:e,selectedPage:r,expandedPaths:n,autoExpandedPaths:i,onToggle:a,onSelect:o,onAddToFolder:c,onDeleteFolder:u}){const d=r===t.path,p=t.isDir&&(n.has(t.path)||i.has(t.path)),f=12+e*16,m=t.isDir&&["io","shared","squads","templates"].includes(t.path);return t.isDir?y.jsxs("div",{children:[y.jsxs("div",{className:"flex w-full items-center group rounded-lg py-2 pr-3 text-left text-[11px] font-mono text-zinc-400 transition-colors hover:bg-white/[0.04] hover:text-zinc-200",style:{paddingLeft:f},children:[y.jsxs("button",{type:"button",onClick:()=>a(t.path),className:"flex items-center gap-2 flex-1 min-w-0",children:[y.jsx(Qw,{size:14,className:`shrink-0 transition-transform ${p?"rotate-90":""}`}),p?y.jsx(zz,{size:14,className:"shrink-0 text-zinc-500"}):y.jsx(Uz,{size:14,className:"shrink-0 text-zinc-500"}),y.jsx("span",{className:"truncate",children:t.name})]}),y.jsxs("div",{className:"flex items-center gap-0.5",children:[!m&&y.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),u(t.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-red-500/20 transition-opacity text-zinc-600 hover:text-red-400",title:`Delete ${t.name}`,children:y.jsx(Da,{size:12})}),y.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),c(t.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-white/[0.08] transition-opacity text-zinc-600 hover:text-zinc-300",title:`Add page to ${t.name}`,children:y.jsx(i1,{size:12})})]})]}),p&&y.jsx("div",{children:t.children.map(v=>y.jsx(BM,{node:v,depth:e+1,selectedPage:r,expandedPaths:n,autoExpandedPaths:i,onToggle:a,onSelect:o,onAddToFolder:c,onDeleteFolder:u},v.path))})]}):y.jsxs("button",{type:"button",onClick:()=>o(t.path),className:`flex w-full items-center gap-2 rounded-lg py-2 pr-3 text-left text-[11px] font-mono transition-colors ${d?"border-l-2 border-[#E43A9C] bg-[#E43A9C]/10 text-[#E43A9C]":"text-zinc-500 hover:bg-white/[0.04] hover:text-zinc-300"}`,style:{paddingLeft:f},children:[y.jsx(Dz,{size:14,className:"shrink-0"}),y.jsx("span",{className:"truncate",children:t.name})]})}function uie(){const[t,e]=j.useState([]),[r,n]=j.useState(null),[i,a]=j.useState(""),[o,c]=j.useState(!1),[u,d]=j.useState(""),[p,f]=j.useState(""),[m,v]=j.useState(""),[b,w]=j.useState(new Set),[x,k]=j.useState(!1),[S,A]=j.useState(null),C=j.useRef(null);j.useEffect(()=>{L()},[]);const T=j.useMemo(()=>lie(t),[t]),O=m.trim().toLowerCase(),N=j.useMemo(()=>zM(T,O),[T,O]),R=j.useMemo(()=>{const I=O?Rw(N):new Set;if(r)for(const B of cie(r))I.add(B);return I},[N,O,r]),$=r?(function I(B){for(const J of B){if(J.path===r)return J;const oe=I(J.children);if(oe)return oe}return null})(N):null,K=($==null?void 0:$.name)??(r?r.split("/").pop()??"":"");j.useEffect(()=>{const I=Rw(T);w(B=>new Set([...B,...I]))},[T]);async function L(){try{const I=await Ge.get("/wiki/all");e(I.pages)}catch{e([])}}function U(I){if(I.startsWith("squads/")){const B=I.split("/"),J=B[1]??"",oe=B.slice(2).join("/");return{scope:J,relativePath:oe}}return I.startsWith("templates/")?{scope:"templates",relativePath:I.slice(10)}:I.startsWith("io/")?{scope:"io",relativePath:I.slice(3)}:I.startsWith("shared/")?{scope:"shared",relativePath:I.slice(7)}:{scope:"shared",relativePath:I}}async function F(I){try{const{scope:B,relativePath:J}=U(I),oe=await Ge.get(`/wiki/${B}/${J}`);a(oe.content),d(oe.content),n(I),c(!1)}catch{Qe.error("Failed to load page")}}async function X(){if(r)try{const{scope:I,relativePath:B}=U(r);await Ge.put(`/wiki/${I}/${B}`,{content:u}),a(u),c(!1),Qe.success("Page saved")}catch{Qe.error("Failed to save page")}}async function Y(){if(r)try{const{scope:I,relativePath:B}=U(r);await Ge.delete(`/wiki/${I}/${B}`),Qe.success("Page deleted"),n(null),a(""),d(""),c(!1),L()}catch{Qe.error("Failed to delete page")}}function G(I){f(`${I}/`),setTimeout(()=>{const B=C.current;B&&(B.focus(),B.setSelectionRange(B.value.length,B.value.length))},0)}function Q(I){A(I)}async function W(){if(S)try{await Ge.delete(`/wiki/dir/${S}`),Qe.success(`Deleted ${S}`),r!=null&&r.startsWith(S)&&(n(null),a(""),d(""),c(!1)),L()}catch{Qe.error("Failed to delete directory")}finally{A(null)}}async function ee(){let I=p.trim().replace(/^\/+|\/+$/g,"");if(!I)return;I=I.replace(/\.md$/i,"");const B=I.startsWith("io/")||I.startsWith("shared/")||I.startsWith("squads/")?I:`shared/${I}`;k(!0);try{const{scope:J,relativePath:oe}=U(B),ue=oe.split("/").slice(-1)[0]??oe;await Ge.put(`/wiki/${J}/${oe}`,{content:`# ${ue}
|
|
518
518
|
|
|
519
519
|
`}),Qe.success("Page created"),f(""),await L(),await F(B)}catch{Qe.error("Failed to create page")}finally{k(!1)}}function q(I){w(B=>{const J=new Set(B);return J.has(I)?J.delete(I):J.add(I),J})}return y.jsxs("div",{className:"flex h-full",children:[y.jsxs("div",{className:"flex h-full w-64 flex-col border-r border-white/[0.07] bg-[#181818]",children:[y.jsx("div",{className:"border-b border-white/[0.07] p-3",children:y.jsxs("div",{className:"relative",children:[y.jsx(LP,{className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-600"}),y.jsx("input",{type:"text",value:m,onChange:I=>v(I.target.value),placeholder:"Search pages...",className:"w-full rounded-lg border border-white/[0.07] bg-white/[0.04] py-2 pl-8 pr-3 text-[11px] font-mono text-zinc-300 outline-none placeholder:text-zinc-700 focus:border-[#E43A9C]/50"})]})}),y.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-3",children:N.length>0?N.map(I=>y.jsx(BM,{node:I,depth:0,selectedPage:r,expandedPaths:b,autoExpandedPaths:R,onToggle:q,onSelect:F,onAddToFolder:G,onDeleteFolder:Q},I.path)):y.jsx("p",{className:"py-4 text-center font-mono text-[11px] text-zinc-700",children:"No pages found"})}),y.jsx("div",{className:"border-t border-white/[0.07] p-3",children:y.jsxs("div",{className:"space-y-2",children:[y.jsx("input",{ref:C,type:"text",value:p,onChange:I=>f(I.target.value),onKeyDown:I=>{I.key==="Enter"&&ee(),I.key==="Escape"&&f("")},placeholder:"folder/new-page",className:"w-full rounded-lg border border-white/[0.07] bg-white/[0.04] px-3 py-2 text-[11px] font-mono text-zinc-300 outline-none placeholder:text-zinc-700 focus:border-[#E43A9C]/50"}),y.jsx(Ba,{onClick:ee,disabled:!p.trim()||x,className:"w-full justify-center px-3 py-2",children:x?y.jsxs(y.Fragment,{children:[y.jsx(Ts,{size:13,className:"animate-spin"})," Creating..."]}):y.jsxs(y.Fragment,{children:[y.jsx(i1,{size:13})," Add Page"]})})]})})]}),y.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:r?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-white/[0.07] px-6",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("h3",{className:"truncate font-mono text-sm text-zinc-100",children:K}),y.jsxs("p",{className:"truncate font-mono text-[11px] text-zinc-500",children:[r,".md"]})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[o?y.jsxs(y.Fragment,{children:[y.jsxs(Ba,{onClick:X,className:"px-3 py-1.5",children:[y.jsx(cp,{size:12})," Save"]}),y.jsx(wi,{onClick:()=>{c(!1),d(i)},className:"px-3 py-1.5",children:"Cancel"})]}):y.jsxs(wi,{onClick:()=>{c(!0),d(i)},className:"px-3 py-1.5",children:[y.jsx(Ff,{size:12})," Edit"]}),y.jsxs(Gf,{onClick:Y,className:"px-3 py-1.5",children:[y.jsx(Da,{size:12})," Delete"]})]})]}),y.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:o?y.jsx("textarea",{value:u,onChange:I=>d(I.target.value),className:"h-full min-h-[320px] w-full resize-none rounded-xl border border-white/[0.07] bg-[#181818] p-4 font-mono text-sm text-zinc-300 outline-none focus:border-[#E43A9C]/50"}):y.jsx("div",{className:"mx-auto max-w-4xl",children:y.jsx("div",{className:"prose-io text-sm text-zinc-300",dangerouslySetInnerHTML:{__html:it.parse(i)}})})})]}):y.jsx("div",{className:"flex h-full items-center justify-center",children:y.jsxs("div",{className:"text-center",children:[y.jsx(PP,{size:48,className:"mx-auto mb-3 text-zinc-800"}),y.jsx("p",{className:"font-mono text-[11px] text-zinc-700",children:"Select a page to view"})]})})}),S&&y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"w-full max-w-sm rounded-2xl border border-white/[0.07] bg-[#1a1a1a] p-6 shadow-2xl",children:[y.jsx("h3",{className:"mb-2 text-sm font-medium text-zinc-100",children:"Delete directory?"}),y.jsxs("p",{className:"mb-4 text-xs text-zinc-400",children:["This will permanently delete"," ",y.jsx("span",{className:"font-mono text-zinc-200",children:S})," and all its contents."]}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx(wi,{onClick:()=>A(null),className:"px-3 py-1.5",children:"Cancel"}),y.jsxs(Gf,{onClick:W,className:"px-3 py-1.5",children:[y.jsx(Da,{size:12})," Delete"]})]})]})})]})}function die({children:t}){const{session:e,supabase:r,loading:n}=mp();return n?y.jsx("div",{className:"min-h-screen flex items-center justify-center text-[var(--color-muted-foreground)]",children:"Loading..."}):r?e?y.jsx(y.Fragment,{children:t}):y.jsx(Lq,{}):y.jsx(y.Fragment,{children:t})}function fie(){const{pathname:t}=ti(),e=t==="/"||t==="/chat"||t.startsWith("/chat/");return y.jsxs(y.Fragment,{children:[y.jsx(jL,{children:y.jsxs(Yr,{element:y.jsx(Iq,{}),children:[y.jsx(Yr,{index:!0,element:y.jsx($q,{})}),y.jsx(Yr,{path:"squads",element:y.jsx(yf,{})}),y.jsx(Yr,{path:"squads/:name",element:y.jsx(yf,{})}),y.jsx(Yr,{path:"squads/:name/instances/:instanceId",element:y.jsx(yf,{})}),y.jsx(Yr,{path:"squads/:name/agents/:role",element:y.jsx(yf,{})}),y.jsx(Yr,{path:"feed",element:y.jsx(Dq,{})}),y.jsx(Yr,{path:"skills",element:y.jsx(Xq,{})}),y.jsx(Yr,{path:"schedules",element:y.jsx(Uq,{})}),y.jsx(Yr,{path:"wiki",element:y.jsx(uie,{})}),y.jsx(Yr,{path:"settings",element:y.jsx(Wq,{})}),y.jsx(Yr,{path:"usage",element:y.jsx(sie,{})}),y.jsx(Yr,{path:"*",element:y.jsx(OL,{to:"/",replace:!0})})]})}),!e&&y.jsx(MB,{})]})}function hie(){return y.jsx(BU,{children:y.jsx(die,{children:y.jsx(Z4,{children:y.jsx($B,{children:y.jsx(fie,{})})})})})}OD.createRoot(document.getElementById("root")).render(y.jsx(j.StrictMode,{children:y.jsxs(e5,{children:[y.jsx(hie,{}),y.jsx(D5,{theme:"dark",position:"bottom-right"})]})}));
|
|
520
|
-
//# sourceMappingURL=index-
|
|
520
|
+
//# sourceMappingURL=index-Bkx7szi0.js.map
|
package/dist/web/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
href="https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap"
|
|
12
12
|
/>
|
|
13
13
|
<title>IO</title>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-Bkx7szi0.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-B6F0UZkW.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|