heyio 0.17.0 → 0.17.1
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/paths.js +16 -5
- package/package.json +1 -1
- package/web-dist/assets/{InboxView-CR3ZzT5n.js → InboxView-D9wKrR06.js} +1 -1
- package/web-dist/assets/{index-0BbiIS_l.css → index-BGJDwDoi.css} +1 -1
- package/web-dist/assets/{index-DCeo0qxD.js → index-BGjTyM3L.js} +5 -5
- package/web-dist/index.html +2 -2
|
@@ -69,16 +69,16 @@ Request ID: ${l}`),c){let k=`
|
|
|
69
69
|
Resources:`;for(const A of c){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}`);k+=`
|
|
70
70
|
- ${A}`}y+=k}return`${x}
|
|
71
71
|
${y}`}class De extends Error{constructor({message:e,code:s,cause:r,name:n}){var i;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=(i=n??(r instanceof Error?r.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=s}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class _n extends De{constructor(e,s){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s,message:e}),this.name="WebAuthnUnknownError",this.originalError=s}}function bm({error:t,options:e}){var s,r,n;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new De({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((s=i.authenticatorSelection)===null||s===void 0?void 0:s.requireResidentKey)===!0)return new De({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((r=i.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new De({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new De({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 De({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new De({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(a=>a.type==="public-key").length===0?new De({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new De({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(ou(o)){if(i.rp.id!==o)return new De({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new De({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new De({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 De({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 De({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function ym({error:t,options:e}){const{publicKey:s}=e;if(!s)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new De({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new De({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const r=window.location.hostname;if(ou(r)){if(s.rpId!==r)return new De({message:`The RP ID "${s.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new De({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new De({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 De({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class _m{createNewAbortSignal(){if(this.controller){const s=new Error("Cancelling existing WebAuthn API call for new one");s.name="AbortError",this.controller.abort(s)}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 Ki=new _m;function Ja(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:s,excludeCredentials:r}=t,n=Vn(t,["challenge","user","excludeCredentials"]),i=Ks(e).buffer,o=Object.assign(Object.assign({},s),{id:Ks(s.id).buffer}),a=Object.assign(Object.assign({},n),{challenge:i,user:o});if(r&&r.length>0){a.excludeCredentials=new Array(r.length);for(let l=0;l<r.length;l++){const c=r[l];a.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:Ks(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return a}function Ya(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:s}=t,r=Vn(t,["challenge","allowCredentials"]),n=Ks(e).buffer,i=Object.assign(Object.assign({},r),{challenge:n});if(s&&s.length>0){i.allowCredentials=new Array(s.length);for(let o=0;o<s.length;o++){const a=s[o];i.allowCredentials[o]=Object.assign(Object.assign({},a),{id:Ks(a.id).buffer,type:a.type||"public-key",transports:a.transports})}}return i}function Xa(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t;return{id:t.id,rawId:t.id,response:{attestationObject:ks(new Uint8Array(t.response.attestationObject)),clientDataJSON:ks(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Za(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t,r=t.getClientExtensionResults(),n=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:ks(new Uint8Array(n.authenticatorData)),clientDataJSON:ks(new Uint8Array(n.clientDataJSON)),signature:ks(new Uint8Array(n.signature)),userHandle:n.userHandle?ks(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function ou(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function wn(){var t,e;return!!(ze()&&"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 au(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new _n("Browser returned unexpected credential type",e)}:{data:null,error:new _n("Empty credential response",e)}}catch(e){return{data:null,error:bm({error:e,options:t})}}}async function lu(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new _n("Browser returned unexpected credential type",e)}:{data:null,error:new _n("Empty credential response",e)}}catch(e){return{data:null,error:ym({error:e,options:t})}}}const wm={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},xm={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function xn(...t){const e=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),s=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),r={};for(const n of t)if(n)for(const i in n){const o=n[i];if(o!==void 0)if(Array.isArray(o))r[i]=o;else if(s(o))r[i]=o;else if(e(o)){const a=r[i];e(a)?r[i]=xn(a,o):r[i]=xn(o)}else r[i]=o}return r}function km(t,e){return xn(wm,t,e||{})}function Sm(t,e){return xn(xm,t,e||{})}class Em{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:s,friendlyName:r,signal:n},i){var o;try{const{data:a,error:l}=await this.client.mfa.challenge({factorId:e,webauthn:s});if(!a)return{data:null,error:l};const c=n??Ki.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:u}=a.webauthn.credential_options.publicKey;if(!u.name){const d=r;if(d)u.name=`${u.id}:${d}`;else{const p=(await this.client.getUser()).data.user,m=((o=p==null?void 0:p.user_metadata)===null||o===void 0?void 0:o.name)||(p==null?void 0:p.email)||(p==null?void 0:p.id)||"User";u.name=`${u.id}:${m}`}}u.displayName||(u.displayName=u.name)}switch(a.webauthn.type){case"create":{const u=km(a.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:d,error:f}=await au({publicKey:u,signal:c});return d?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:d}},error:null}:{data:null,error:f}}case"request":{const u=Sm(a.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:d,error:f}=await lu(Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:u,signal:c}));return d?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:d}},error:null}:{data:null,error:f}}}}catch(a){return z(a)?{data:null,error:a}:{data:null,error:new bt("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:s,webauthn:r}){return this.client.mfa.verify({factorId:s,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!s)return{data:null,error:new Pr("rpId is required for WebAuthn authentication")};try{if(!wn())return{data:null,error:new bt("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this.challenge({factorId:e,webauthn:{rpId:s,rpOrigins:r},signal:n},{request:i});if(!o)return{data:null,error:a};const{webauthn:l}=o;return this._verify({factorId:e,challengeId:o.challengeId,webauthn:{type:l.type,rpId:s,rpOrigins:r,credential_response:l.credential_response}})}catch(o){return z(o)?{data:null,error:o}:{data:null,error:new bt("Unexpected error in authenticate",o)}}}async _register({friendlyName:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!s)return{data:null,error:new Pr("rpId is required for WebAuthn registration")};try{if(!wn())return{data:null,error:new bt("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this._enroll({friendlyName:e});if(!o)return await this.client.mfa.listFactors().then(u=>{var d;return(d=u.data)===null||d===void 0?void 0:d.all.find(f=>f.factor_type==="webauthn"&&f.friendly_name===e&&f.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u==null?void 0:u.id}):void 0),{data:null,error:a};const{data:l,error:c}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:s,rpOrigins:r},signal:n},{create:i});return l?this._verify({factorId:o.id,challengeId:l.challengeId,webauthn:{rpId:s,rpOrigins:r,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(o){return z(o)?{data:null,error:o}:{data:null,error:new bt("Unexpected error in register",o)}}}}pm();const Tm={url:Og,storageKey:$g,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Pg,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function Qa(t,e,s){return await s()}const js={};class Ir{get jwks(){var e,s;return(s=(e=js[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&s!==void 0?s:{keys:[]}}set jwks(e){js[this.storageKey]=Object.assign(Object.assign({},js[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,s;return(s=(e=js[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&s!==void 0?s:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){js[this.storageKey]=Object.assign(Object.assign({},js[this.storageKey]),{cachedAt:e})}constructor(e){var s,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.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const o=Object.assign(Object.assign({},Tm),e);if(this.storageKey=o.storageKey,this.instanceID=(s=Ir.nextInstanceID[this.storageKey])!==null&&s!==void 0?s:0,Ir.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!o.debug,typeof o.debug=="function"&&(this.logger=o.debug),this.instanceID>0&&ze()){const a=`${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(a),this.logDebugMessages&&console.trace(a)}if(this.persistSession=o.persistSession,this.autoRefreshToken=o.autoRefreshToken,this.experimental=(r=o.experimental)!==null&&r!==void 0?r:{},this.admin=new hm({url:o.url,headers:o.headers,fetch:o.fetch,experimental:this.experimental}),this.url=o.url,this.headers=o.headers,this.fetch=ru(o.fetch),this.lock=o.lock||Qa,this.detectSessionInUrl=o.detectSessionInUrl,this.flowType=o.flowType,this.hasCustomAuthorizationHeader=o.hasCustomAuthorizationHeader,this.throwOnError=o.throwOnError,this.lockAcquireTimeout=o.lockAcquireTimeout,o.lock?this.lock=o.lock:this.persistSession&&ze()&&(!((n=globalThis==null?void 0:globalThis.navigator)===null||n===void 0)&&n.locks)?this.lock=fm:this.lock=Qa,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 Em(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?(o.storage?this.storage=o.storage:su()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Ga(this.memoryStorage)),o.userStorage&&(this.userStorage=o.userStorage)):(this.memoryStorage={},this.storage=Ga(this.memoryStorage)),ze()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(i=this.broadcastChannel)===null||i===void 0||i.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a);try{await this._notifyAllSubscribers(a.data.event,a.data.session,!1)}catch(l){this._debug("#broadcastChannel","error",l)}})}o.skipAutoInitialize||this.initialize().catch(a=>{this._debug("#initialize()","error",a)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${Qc}) ${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()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let s={},r="none";if(ze()&&(s=Kg(window.location.href),this._isImplicitGrantCallback(s)?r="implicit":await this._isPKCECallback(s)&&(r="pkce")),ze()&&this.detectSessionInUrl&&r!=="none"){const{data:n,error:i}=await this._getSessionFromURL(s,r);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),Ug(i)){const l=(e=i.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:i}}return{error:i}}const{session:o,redirectType:a}=n;return this._debug("#_initialize()","detected session in URL",o,"redirect type",a),await this._saveSession(o),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(s){return z(s)?this._returnResult({error:s}):this._returnResult({error:new bt("Unexpected error during initialization",s)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var s,r,n;try{const i=await ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(n=e==null?void 0:e.options)===null||n===void 0?void 0:n.captchaToken}},xform:ht}),{data:o,error:a}=i;if(a||!o)return this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(z(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(e){var s,r,n;try{let i;if("email"in e){const{email:u,password:d,options:f}=e;let p=null,m=null;this.flowType==="pkce"&&([p,m]=await Is(this.storage,this.storageKey)),i=await ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:u,password:d,data:(s=f==null?void 0:f.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:p,code_challenge_method:m},xform:ht})}else if("phone"in e){const{phone:u,password:d,options:f}=e;i=await ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:d,data:(r=f==null?void 0:f.data)!==null&&r!==void 0?r:{},channel:(n=f==null?void 0:f.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:ht})}else throw new Yr("You must provide either an email or phone number and a password");const{data:o,error:a}=i;if(a||!o)return await Ge(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithPassword(e){try{let s;if("email"in e){const{email:i,password:o,options:a}=e;s=await ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:Wa})}else if("phone"in e){const{phone:i,password:o,options:a}=e;s=await ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:Wa})}else throw new Yr("You must provide either an email or phone number and a password");const{data:r,error:n}=s;if(n)return this._returnResult({data:{user:null,session:null},error:n});if(!r||!r.session||!r.user){const i=new Ps;return this._returnResult({data:{user:null,session:null},error:i})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:n})}catch(s){if(z(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOAuth(e){var s,r,n,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(s=e.options)===null||s===void 0?void 0:s.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(n=e.options)===null||n===void 0?void 0:n.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:s}=e;switch(s){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${s}"`)}}async signInWithEthereum(e){var s,r,n,i,o,a,l,c,u,d,f;let p,m;if("message"in e)p=e.message,m=e.signature;else{const{chain:b,wallet:x,statement:y,options:k}=e;let A;if(ze())if(typeof x=="object")A=x;else{const B=window;if("ethereum"in B&&typeof B.ethereum=="object"&&"request"in B.ethereum&&typeof B.ethereum.request=="function")A=B.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"||!(k!=null&&k.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=x}const L=new URL((s=k==null?void 0:k.url)!==null&&s!==void 0?s:window.location.href),N=await A.request({method:"eth_requestAccounts"}).then(B=>B).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!N||N.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const $=iu(N[0]);let E=(r=k==null?void 0:k.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!E){const B=await A.request({method:"eth_chainId"});E=gm(B)}const M={domain:L.host,address:$,statement:y,uri:L.href,version:"1",chainId:E,nonce:(n=k==null?void 0:k.signInWithEthereum)===null||n===void 0?void 0:n.nonce,issuedAt:(o=(i=k==null?void 0:k.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(a=k==null?void 0:k.signInWithEthereum)===null||a===void 0?void 0:a.expirationTime,notBefore:(l=k==null?void 0:k.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=k==null?void 0:k.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=k==null?void 0:k.signInWithEthereum)===null||u===void 0?void 0:u.resources};p=vm(M),m=await A.request({method:"personal_sign",params:[mm(p),$]})}try{const{data:b,error:x}=await ee(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:p,signature:m},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:ht});if(x)throw x;if(!b||!b.session||!b.user){const y=new Ps;return this._returnResult({data:{user:null,session:null},error:y})}return b.session&&(await this._saveSession(b.session),await this._notifyAllSubscribers("SIGNED_IN",b.session)),this._returnResult({data:Object.assign({},b),error:x})}catch(b){if(z(b))return this._returnResult({data:{user:null,session:null},error:b});throw b}}async signInWithSolana(e){var s,r,n,i,o,a,l,c,u,d,f,p;let m,b;if("message"in e)m=e.message,b=e.signature;else{const{chain:x,wallet:y,statement:k,options:A}=e;let L;if(ze())if(typeof y=="object")L=y;else{const $=window;if("solana"in $&&typeof $.solana=="object"&&("signIn"in $.solana&&typeof $.solana.signIn=="function"||"signMessage"in $.solana&&typeof $.solana.signMessage=="function"))L=$.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 y!="object"||!(A!=null&&A.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");L=y}const N=new URL((s=A==null?void 0:A.url)!==null&&s!==void 0?s:window.location.href);if("signIn"in L&&L.signIn){const $=await L.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},A==null?void 0:A.signInWithSolana),{version:"1",domain:N.host,uri:N.href}),k?{statement:k}:null));let E;if(Array.isArray($)&&$[0]&&typeof $[0]=="object")E=$[0];else if($&&typeof $=="object"&&"signedMessage"in $&&"signature"in $)E=$;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in E&&"signature"in E&&(typeof E.signedMessage=="string"||E.signedMessage instanceof Uint8Array)&&E.signature instanceof Uint8Array)m=typeof E.signedMessage=="string"?E.signedMessage:new TextDecoder().decode(E.signedMessage),b=E.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in L)||typeof L.signMessage!="function"||!("publicKey"in L)||typeof L!="object"||!L.publicKey||!("toBase58"in L.publicKey)||typeof L.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");m=[`${N.host} wants you to sign in with your Solana account:`,L.publicKey.toBase58(),...k?["",k,""]:[""],"Version: 1",`URI: ${N.href}`,`Issued At: ${(n=(r=A==null?void 0:A.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&n!==void 0?n:new Date().toISOString()}`,...!((i=A==null?void 0:A.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${A.signInWithSolana.notBefore}`]:[],...!((o=A==null?void 0:A.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${A.signInWithSolana.expirationTime}`]:[],...!((a=A==null?void 0:A.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${A.signInWithSolana.chainId}`]:[],...!((l=A==null?void 0:A.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${A.signInWithSolana.nonce}`]:[],...!((c=A==null?void 0:A.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${A.signInWithSolana.requestId}`]:[],...!((d=(u=A==null?void 0:A.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||d===void 0)&&d.length?["Resources",...A.signInWithSolana.resources.map(E=>`- ${E}`)]:[]].join(`
|
|
72
|
-
`);const $=await L.signMessage(new TextEncoder().encode(m),"utf8");if(!$||!($ instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");b=$}}try{const{data:x,error:y}=await ee(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:m,signature:ks(b)},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(p=e.options)===null||p===void 0?void 0:p.captchaToken}}:null),xform:ht});if(y)throw y;if(!x||!x.session||!x.user){const k=new Ps;return this._returnResult({data:{user:null,session:null},error:k})}return x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("SIGNED_IN",x.session)),this._returnResult({data:Object.assign({},x),error:y})}catch(x){if(z(x))return this._returnResult({data:{user:null,session:null},error:x});throw x}}async _exchangeCodeForSession(e){const s=await vs(this.storage,`${this.storageKey}-code-verifier`),[r,n]=(s??"").split("/");try{if(!r&&this.flowType==="pkce")throw new Dg;const{data:i,error:o}=await ee(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:ht});if(await Ge(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!i||!i.session||!i.user){const a=new Ps;return this._returnResult({data:{user:null,session:null,redirectType:null},error:a})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers(n==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:n??null}),error:o})}catch(i){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(e){try{const{options:s,provider:r,token:n,access_token:i,nonce:o}=e,a=await ee(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:n,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},xform:ht}),{data:l,error:c}=a;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l||!l.session||!l.user){const u=new Ps;return this._returnResult({data:{user:null,session:null},error:u})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),this._returnResult({data:l,error:c})}catch(s){if(z(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOtp(e){var s,r,n,i,o;try{if("email"in e){const{email:a,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await Is(this.storage,this.storageKey));const{error:d}=await ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(s=l==null?void 0:l.data)!==null&&s!==void 0?s:{},create_user:(r=l==null?void 0:l.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l==null?void 0:l.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:d})}if("phone"in e){const{phone:a,options:l}=e,{data:c,error:u}=await ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(n=l==null?void 0:l.data)!==null&&n!==void 0?n:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:u})}throw new Yr("You must provide either an email or phone number.")}catch(a){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async verifyOtp(e){var s,r;try{let n,i;"options"in e&&(n=(s=e.options)===null||s===void 0?void 0:s.redirectTo,i=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:o,error:a}=await ee(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:n,xform:ht});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,c=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(n){if(z(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithSSO(e){var s,r,n,i,o;try{let a=null,l=null;this.flowType==="pkce"&&([a,l]=await Is(this.storage,this.storageKey));const c=await ee(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:(r=(s=e.options)===null||s===void 0?void 0:s.redirectTo)!==null&&r!==void 0?r:void 0}),!((n=e==null?void 0:e.options)===null||n===void 0)&&n.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:l}),headers:this.headers,xform:cm});return!((i=c.data)===null||i===void 0)&&i.url&&ze()&&!(!((o=e.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(a){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(a))return this._returnResult({data:null,error:a});throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)throw r;if(!s)throw new Ve;const{error:n}=await ee(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:s.access_token});return this._returnResult({data:{user:null,session:null},error:n})})}catch(e){if(z(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const s=`${this.url}/resend`;if("email"in e){const{email:r,type:n,options:i}=e,{error:o}=await ee(this.fetch,"POST",s,{headers:this.headers,body:{email:r,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in e){const{phone:r,type:n,options:i}=e,{data:o,error:a}=await ee(this.fetch,"POST",s,{headers:this.headers,body:{phone:r,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a})}throw new Yr("You must provide either an email or phone number and a type")}catch(s){if(z(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async s=>s))}async _acquireLock(e,s){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await r,await s()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=s();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await r}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 s=await this.__loadSession();return await e(s)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const s=await vs(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",s),s!==null&&(this._isValidSession(s)?e=s:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<di:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const o=await vs(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=fi()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};e.user=im(e.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{session:null},error:i}):this._returnResult({data:{session:n},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const s=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return s.data.user&&(this.suppressGetSessionWarning=!0),s}async _getUser(e){try{return e?await ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:cs}):await this._useSession(async s=>{var r,n,i;const{data:o,error:a}=s;if(a)throw a;return!(!((r=o.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Ve}:await ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0,xform:cs})})}catch(s){if(z(s))return Jr(s)&&(await this._removeSession(),await Ge(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:s});throw s}}async updateUser(e,s={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,s))}async _updateUser(e,s={}){try{return await this._useSession(async r=>{const{data:n,error:i}=r;if(i)throw i;if(!n.session)throw new Ve;const o=n.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await Is(this.storage,this.storageKey));const{data:c,error:u}=await ee(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:s==null?void 0:s.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:cs});if(u)throw u;return o.user=c.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(r){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(r))return this._returnResult({data:{user:null},error:r});throw r}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Ve;const s=Date.now()/1e3;let r=s,n=!0,i=null;const{payload:o}=Zr(e.access_token);if(o.exp&&(r=o.exp,n=r<=s),n){const{data:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:r-s,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(s){if(z(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async s=>{var r;if(!e){const{data:o,error:a}=s;if(a)throw a;e=(r=o.session)!==null&&r!==void 0?r:void 0}if(!(e!=null&&e.refresh_token))throw new Ve;const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):n?this._returnResult({data:{user:n.user,session:n},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(s){if(z(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async _getSessionFromURL(e,s){var r;try{if(!ze())throw new Xr("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Xr(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(s){case"implicit":if(this.flowType==="pkce")throw new Da("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Xr("Not a valid implicit grant flow url.");break;default:}if(s==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Da("No code detected.");const{data:A,error:L}=await this._exchangeCodeForSession(e.code);if(L)throw L;const N=new URL(window.location.href);return N.searchParams.delete("code"),window.history.replaceState(window.history.state,"",N.toString()),{data:{session:A.session,redirectType:(r=A.redirectType)!==null&&r!==void 0?r:null},error:null}}const{provider_token:n,provider_refresh_token:i,access_token:o,refresh_token:a,expires_in:l,expires_at:c,token_type:u}=e;if(!o||!l||!a||!u)throw new Xr("No session defined in URL");const d=Math.round(Date.now()/1e3),f=parseInt(l);let p=d+f;c&&(p=parseInt(c));const m=p-d;m*1e3<=Ms&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${m}s, should have been closer to ${f}s`);const b=p-f;d-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,p,d):d-b<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",b,p,d);const{data:x,error:y}=await this._getUser(o);if(y)throw y;const k={provider_token:n,provider_refresh_token:i,access_token:o,expires_in:f,expires_at:p,refresh_token:a,token_type:u,user:x.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:k,redirectType:e.type},error:null})}catch(n){if(z(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const s=await vs(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&s)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async s=>{var r;const{data:n,error:i}=s;if(i&&!Jr(i))return this._returnResult({error:i});const o=(r=n.session)===null||r===void 0?void 0:r.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(Lg(a)&&(a.status===404||a.status===401||a.status===403)||Jr(a)))return this._returnResult({error:a})}return e!=="others"&&(await this._removeSession(),await Ge(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const s=Wg(),r={id:s,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",s),this.stateChangeEmitters.delete(s)}};return this._debug("#onAuthStateChange()","registered callback with id",s),this.stateChangeEmitters.set(s,r),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(s)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async s=>{var r,n;try{const{data:{session:i},error:o}=s;if(o)throw o;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),Jr(i)?console.warn(i):console.error(i)}})}async resetPasswordForEmail(e,s={}){let r=null,n=null;this.flowType==="pkce"&&([r,n]=await Is(this.storage,this.storageKey,!0));try{return await ee(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:n,gotrue_meta_security:{captcha_token:s.captchaToken}},headers:this.headers,redirectTo:s.redirectTo})}catch(i){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:s,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:(e=s.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var s;try{const{data:r,error:n}=await this._useSession(async i=>{var o,a,l,c,u;const{data:d,error:f}=i;if(f)throw f;const p=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await ee(this.fetch,"GET",p,{headers:this.headers,jwt:(u=(c=d.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(n)throw n;return ze()&&!(!((s=e.options)===null||s===void 0)&&s.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),this._returnResult({data:{provider:e.provider,url:r==null?void 0:r.url},error:null})}catch(r){if(z(r))return this._returnResult({data:{provider:e.provider,url:null},error:r});throw r}}async linkIdentityIdToken(e){return await this._useSession(async s=>{var r;try{const{error:n,data:{session:i}}=s;if(n)throw n;const{options:o,provider:a,token:l,access_token:c,nonce:u}=e,d=await ee(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=i==null?void 0:i.access_token)!==null&&r!==void 0?r:void 0,body:{provider:a,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:ht}),{data:f,error:p}=d;return p?this._returnResult({data:{user:null,session:null},error:p}):!f||!f.session||!f.user?this._returnResult({data:{user:null,session:null},error:new Ps}):(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("USER_UPDATED",f.session)),this._returnResult({data:f,error:p}))}catch(n){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}})}async unlinkIdentity(e){try{return await this._useSession(async s=>{var r,n;const{data:i,error:o}=s;if(o)throw o;return await ee(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(r=i.session)===null||r===void 0?void 0:r.access_token)!==null&&n!==void 0?n:void 0})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _refreshAccessToken(e){const s=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{const r=Date.now();return await Jg(async n=>(n>0&&await zg(200*Math.pow(2,n-1)),this._debug(s,"refreshing attempt",n),await ee(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:ht})),(n,i)=>{const o=200*Math.pow(2,n);return i&&hi(i)&&Date.now()+o-r<Ms})}catch(r){if(this._debug(s,"error",r),z(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}finally{this._debug(s,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,s){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:s.redirectTo,scopes:s.scopes,queryParams:s.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",s,"url",r),ze()&&!s.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,s;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const n=await vs(this.storage,this.storageKey);if(n&&this.userStorage){let o=await vs(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:n.user},await Bs(this.userStorage,this.storageKey+"-user",o)),n.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:fi()}else if(n&&!n.user&&!n.user){const o=await vs(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(n.user=o.user,await Ge(this.storage,this.storageKey+"-user"),await Bs(this.storage,this.storageKey,n)):n.user=fi()}if(this._debug(r,"session from storage",n),!this._isValidSession(n)){this._debug(r,"session is not valid"),n!==null&&await this._removeSession();return}const i=((s=n.expires_at)!==null&&s!==void 0?s:1/0)*1e3-Date.now()<di;if(this._debug(r,`session has${i?"":" not"} expired with margin of ${di}s`),i){if(this.autoRefreshToken&&n.refresh_token){const{error:o}=await this._callRefreshToken(n.refresh_token);o&&(console.error(o),hi(o)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(n.user&&n.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:a}=await this._getUser(n.access_token);!a&&(o!=null&&o.user)?(n.user=o.user,await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(r,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(r,"error",n),console.error(n);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var s,r;if(!e)throw new Ve;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const n=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{this.refreshingDeferred=new Kn;const{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new Ve;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const a={data:i.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(i){if(this._debug(n,"error",i),z(i)){const o={data:null,error:i};return hi(i)||await this._removeSession(),(s=this.refreshingDeferred)===null||s===void 0||s.resolve(o),o}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(i),i}finally{this.refreshingDeferred=null,this._debug(n,"end")}}async _notifyAllSubscribers(e,s,r=!0){const n=`#_notifyAllSubscribers(${e})`;this._debug(n,"begin",s,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:s});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,s)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;a<i.length;a+=1)console.error(i[a]);throw i[0]}}finally{this._debug(n,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await Ge(this.storage,`${this.storageKey}-code-verifier`);const s=Object.assign({},e),r=s.user&&s.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&s.user&&await Bs(this.userStorage,this.storageKey+"-user",{user:s.user});const n=Object.assign({},s);delete n.user;const i=Va(n);await Bs(this.storage,this.storageKey,i)}else{const n=Va(s);await Bs(this.storage,this.storageKey,n)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Ge(this.storage,this.storageKey),await Ge(this.storage,this.storageKey+"-code-verifier"),await Ge(this.storage,this.storageKey+"-user"),this.userStorage&&await Ge(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ze()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(s){console.error("removing visibilitychange callback failed",s)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Ms);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const s=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const s=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,s&&clearTimeout(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async s=>{const{data:{session:r}}=s;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((r.expires_at*1e3-e)/Ms);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${Ms}ms, refresh threshold is ${Fi} ticks`),n<=Fi&&await this._callRefreshToken(r.refresh_token)})}catch(s){console.error("Auto refresh tick failed with error. This is likely a transient error.",s)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof nu)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ze()||!(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 s=`#_onVisibilityChanged(${e})`;this._debug(s,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(s,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,s,r){const n=[`provider=${encodeURIComponent(s)}`];if(r!=null&&r.redirectTo&&n.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r!=null&&r.scopes&&n.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[i,o]=await Is(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});n.push(a.toString())}if(r!=null&&r.queryParams){const i=new URLSearchParams(r.queryParams);n.push(i.toString())}return r!=null&&r.skipBrowserRedirect&&n.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${n.join("&")}`}async _unenroll(e){try{return await this._useSession(async s=>{var r;const{data:n,error:i}=s;return i?this._returnResult({data:null,error:i}):await ee(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _enroll(e){try{return await this._useSession(async s=>{var r,n;const{data:i,error:o}=s;if(o)return this._returnResult({data:null,error:o});const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await ee(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((n=l==null?void 0:l.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var r;const{data:n,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?Xa(e.webauthn.credential_response):Za(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:l}=await ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});return l?this._returnResult({data:null,error:l}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),this._returnResult({data:a,error:l}))})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var r;const{data:n,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=await ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});if(o.error)return o;const{data:a}=o;if(a.type!=="webauthn")return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:Ja(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:Ya(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}})}async _challengeAndVerify(e){const{data:s,error:r}=await this._challenge({factorId:e.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:e.factorId,challengeId:s.id,code:e.code})}async _listFactors(){var e;const{data:{user:s},error:r}=await this.getUser();if(r)return{data:null,error:r};const n={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=s==null?void 0:s.factors)!==null&&e!==void 0?e:[])n.all.push(i),i.status==="verified"&&n[i.factor_type].push(i);return{data:n,error:null}}async _getAuthenticatorAssuranceLevel(e){var s,r,n,i;if(e)try{const{payload:p}=Zr(e);let m=null;p.aal&&(m=p.aal);let b=m;const{data:{user:x},error:y}=await this.getUser(e);if(y)return this._returnResult({data:null,error:y});((r=(s=x==null?void 0:x.factors)===null||s===void 0?void 0:s.filter(L=>L.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(b="aal2");const A=p.amr||[];return{data:{currentLevel:m,nextLevel:b,currentAuthenticationMethods:A},error:null}}catch(p){if(z(p))return this._returnResult({data:null,error:p});throw p}const{data:{session:o},error:a}=await this.getSession();if(a)return this._returnResult({data:null,error:a});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=Zr(o.access_token);let c=null;l.aal&&(c=l.aal);let u=c;((i=(n=o.user.factors)===null||n===void 0?void 0:n.filter(p=>p.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(u="aal2");const f=l.amr||[];return{data:{currentLevel:c,nextLevel:u,currentAuthenticationMethods:f},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;return n?this._returnResult({data:null,error:n}):r?await ee(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new Ve})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _approveAuthorization(e,s){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 Ve});const o=await ee(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"approve"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&ze()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(z(r))return this._returnResult({data:null,error:r});throw r}}async _denyAuthorization(e,s){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 Ve});const o=await ee(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"deny"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&ze()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(z(r))return this._returnResult({data:null,error:r});throw r}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;return r?this._returnResult({data:null,error:r}):s?await ee(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,xform:n=>({data:n,error:null})}):this._returnResult({data:null,error:new Ve})})}catch(e){if(z(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;return n?this._returnResult({data:null,error:n}):r?(await ee(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new Ve})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async fetchJwk(e,s={keys:[]}){let r=s.keys.find(a=>a.kid===e);if(r)return r;const n=Date.now();if(r=this.jwks.keys.find(a=>a.kid===e),r&&this.jwks_cached_at+jg>n)return r;const{data:i,error:o}=await ee(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=n,r=i.keys.find(a=>a.kid===e),!r)?null:r}async getClaims(e,s={}){try{let r=e;if(!r){const{data:p,error:m}=await this.getSession();if(m||!p.session)return this._returnResult({data:null,error:m});r=p.session.access_token}const{header:n,payload:i,signature:o,raw:{header:a,payload:l}}=Zr(r);s!=null&&s.allowExpired||sm(i.exp);const c=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,s!=null&&s.keys?{keys:s.keys}:s==null?void 0:s.jwks);if(!c){const{error:p}=await this.getUser(r);if(p)throw p;return{data:{claims:i,header:n,signature:o},error:null}}const u=rm(n.alg),d=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,d,o,Vg(`${a}.${l}`)))throw new Wi("Invalid JWT signature");return{data:{claims:i,header:n,signature:o},error:null}}catch(r){if(z(r))return this._returnResult({data:null,error:r});throw r}}async signInWithPasskey(e){var s,r,n;mt(this.experimental);try{if(!wn())return this._returnResult({data:null,error:new bt("Browser does not support WebAuthn",null)});const{data:i,error:o}=await this._startPasskeyAuthentication({options:{captchaToken:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}});if(o||!i)return this._returnResult({data:null,error:o});const a=Ya(i.options),l=(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.signal)!==null&&n!==void 0?n:Ki.createNewAbortSignal(),{data:c,error:u}=await lu({publicKey:a,signal:l});if(u||!c)return this._returnResult({data:null,error:u??new bt("WebAuthn ceremony failed",null)});const d=Za(c);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:d})}catch(i){if(z(i))return this._returnResult({data:null,error:i});throw i}}async registerPasskey(e){var s,r;mt(this.experimental);try{if(!wn())return this._returnResult({data:null,error:new bt("Browser does not support WebAuthn",null)});const{data:n,error:i}=await this._startPasskeyRegistration();if(i||!n)return this._returnResult({data:null,error:i});const o=Ja(n.options),a=(r=(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.signal)!==null&&r!==void 0?r:Ki.createNewAbortSignal(),{data:l,error:c}=await au({publicKey:o,signal:a});if(c||!l)return this._returnResult({data:null,error:c??new bt("WebAuthn ceremony failed",null)});const u=Xa(l);return this._verifyPasskeyRegistration({challengeId:n.challenge_id,credential:u})}catch(n){if(z(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyRegistration(){mt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!s)return this._returnResult({data:null,error:new Ve});const{data:n,error:i}=await ee(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:s.access_token,body:{}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(z(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){mt(this.experimental);try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new Ve});const{data:i,error:o}=await ee(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:r.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _startPasskeyAuthentication(e){var s;mt(this.experimental);try{const{data:r,error:n}=await ee(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:r,error:null})}catch(r){if(z(r))return this._returnResult({data:null,error:r});throw r}}async _verifyPasskeyAuthentication(e){mt(this.experimental);try{const{data:s,error:r}=await ee(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:ht});return r?this._returnResult({data:null,error:r}):(s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),this._returnResult({data:s,error:null}))}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _listPasskeys(){mt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!s)return this._returnResult({data:null,error:new Ve});const{data:n,error:i}=await ee(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:s.access_token,xform:o=>({data:o,error:null})});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(z(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){mt(this.experimental);try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new Ve});const{data:i,error:o}=await ee(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,body:{friendly_name:e.friendlyName}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _deletePasskey(e){mt(this.experimental);try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new Ve});const{error:i}=await ee(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,noResolveJson:!0});return i?this._returnResult({data:null,error:i}):this._returnResult({data:null,error:null})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}}Ir.nextInstanceID={};const Am=Ir,Cm="2.105.4";let or="";typeof Deno<"u"?or="deno":typeof document<"u"?or="web":typeof navigator<"u"&&navigator.product==="ReactNative"?or="react-native":or="node";const Rm={"X-Client-Info":`supabase-js-${or}/${Cm}`},Om={headers:Rm},$m={schema:"public"},Pm={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Im={};function jr(t){"@babel/helpers - typeof";return jr=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},jr(t)}function jm(t,e){if(jr(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(jr(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Nm(t){var e=jm(t,"string");return jr(e)=="symbol"?e:e+""}function Lm(t,e,s){return(e=Nm(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function el(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,r)}return s}function je(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?el(Object(s),!0).forEach(function(r){Lm(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):el(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}const Um=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Dm=()=>Headers,Mm=(t,e,s)=>{const r=Um(s),n=Dm();return async(i,o)=>{var a;const l=(a=await e())!==null&&a!==void 0?a:t;let c=new n(o==null?void 0:o.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),r(i,je(je({},o),{},{headers:c}))}};function Bm(t){return t.endsWith("/")?t:t+"/"}function Hm(t,e){var s,r;const{db:n,auth:i,realtime:o,global:a}=t,{db:l,auth:c,realtime:u,global:d}=e,f={db:je(je({},l),n),auth:je(je({},c),i),realtime:je(je({},u),o),storage:{},global:je(je(je({},d),a),{},{headers:je(je({},(s=d==null?void 0:d.headers)!==null&&s!==void 0?s:{}),(r=a==null?void 0:a.headers)!==null&&r!==void 0?r:{})}),accessToken:async()=>""};return t.accessToken?f.accessToken=t.accessToken:delete f.accessToken,f}function Fm(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(Bm(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var Vm=class extends Am{constructor(t){super(t)}},qm=class{constructor(t,e,s){var r,n;this.supabaseUrl=t,this.supabaseKey=e;const i=Fm(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const o=`sb-${i.hostname.split(".")[0]}-auth-token`,a={db:$m,realtime:Im,auth:je(je({},Pm),{},{storageKey:o}),global:Om},l=Hm(s??{},a);if(this.storageKey=(r=l.auth.storageKey)!==null&&r!==void 0?r:"",this.headers=(n=l.global.headers)!==null&&n!==void 0?n:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(u,d)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(d)} is not possible`)}});else{var c;this.auth=this._initSupabaseAuthClient((c=l.auth)!==null&&c!==void 0?c:{},this.headers,l.global.fetch)}this.fetch=Mm(e,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(je({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(u=>this.realtime.setAuth(u)).catch(u=>console.warn("Failed to set initial Realtime auth token:",u)),this.rest=new mp(new URL("rest/v1",i).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new Rg(this.storageUrl.href,this.headers,this.fetch,s==null?void 0:s.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new op(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={},s={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,s)}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,s;if(t.accessToken)return await t.accessToken();const{data:r}=await t.auth.getSession();return(e=(s=r.session)===null||s===void 0?void 0:s.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:r,userStorage:n,storageKey:i,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,lockAcquireTimeout:d,skipAutoInitialize:f},p,m){const b={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Vm({url:this.authUrl.href,headers:je(je({},b),p),storageKey:i,autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:r,userStorage:n,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,fetch:m,lockAcquireTimeout:d,skipAutoInitialize:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(x=>x.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new Zp(this.realtimeUrl.href,je(je({},t),{},{params:je(je({},{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,s){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==s?(this.changedAccessToken=s,this.realtime.setAuth(s)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const Wm=(t,e,s)=>new qm(t,e,s);function Km(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const s=e.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}Km()&&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");let Qr=null,en=null;async function cu(){if(en)return en;try{const t=await fetch("/api/auth/config");if(!t.ok)throw new Error(`HTTP ${t.status}`);return en=await t.json(),en}catch{return{authEnabled:!1,supabaseUrl:null,supabaseAnonKey:null}}}async function gi(){if(Qr)return Qr;const t=await cu();return!t.authEnabled||!t.supabaseUrl||!t.supabaseAnonKey?null:(Qr=Wm(t.supabaseUrl,t.supabaseAnonKey,{auth:{persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!0}}),Qr)}const Br=Tc("auth",()=>{const t=F(null),e=F(null),s=F(!1),r=F(!1),n=F(!1);let i=null;async function o(){const d=await cu();if(n.value=d.authEnabled,!d.authEnabled){r.value=!0;return}const f=await gi();if(!f){r.value=!0;return}await new Promise(p=>{f.auth.onAuthStateChange((m,b)=>{e.value=b,t.value=(b==null?void 0:b.user)??null,m==="INITIAL_SESSION"&&p()})}),r.value=!0}async function a(){if(!r.value)return i||(i=o().catch(()=>{i=null})),i}async function l(d,f){const p=await gi();if(!p)return"Auth not configured";s.value=!0;try{const{error:m}=await p.auth.signInWithPassword({email:d,password:f});return m?m.message:null}finally{s.value=!1}}async function c(){const d=await gi();d&&await d.auth.signOut(),t.value=null,e.value=null}function u(){var d;return((d=e.value)==null?void 0:d.access_token)??null}return{user:t,session:e,loading:s,initialized:r,authEnabled:n,init:a,signIn:l,signOut:c,getAccessToken:u}});async function ke(t,e){const s=Br(),r=s.getAccessToken(),n=new Headers(e==null?void 0:e.headers);r&&n.set("Authorization",`Bearer ${r}`);const i=await fetch(t,{...e,headers:n});return i.status===401&&s.authEnabled&&await s.signOut(),i}function Gn(t){const s=Br().getAccessToken();if(!s)return t;const r=t.includes("?")?"&":"?";return`${t}${r}token=${encodeURIComponent(s)}`}const Gm={key:0,class:"flex items-center gap-2.5 min-w-0"},zm={key:1,class:"w-8 h-8 rounded-lg bg-accent/10 border border-accent/20 flex items-center justify-center"},Jm={class:"flex-1 py-3 overflow-y-auto overflow-x-hidden"},Ym={key:1,class:"text-[13px] font-medium truncate"},Xm={class:"shrink-0"},Zm={class:"p-2.5"},Qm={class:"flex items-center gap-2 px-2 py-1.5 rounded-lg bg-surface-2/50 mb-1.5"},ev={class:"w-6 h-6 rounded-full bg-accent/10 border border-accent/20 flex items-center justify-center shrink-0"},tv={class:"text-[10px] text-accent font-semibold"},sv={class:"min-w-0 flex-1"},rv={class:"text-xs text-txt-primary truncate leading-tight"},nv={class:"flex items-center justify-between px-2"},iv={class:"flex items-center gap-1.5"},ov={key:0,class:"text-[10px] text-txt-muted font-mono"},av={key:1,class:"flex items-center gap-1.5 px-2"},lv={key:0,class:"text-[10px] text-txt-muted font-mono"},cv={key:1,class:"flex flex-col items-center gap-1.5"},tl="io-nav-collapsed",uv=gt({__name:"AppNav",setup(t){const e=sp(),s=Hc(),r=Br(),n=F(""),i=F(0),o=F(0),a=F(!1);let l=null;const c=[{to:"/chat",name:"chat",icon:"💬",label:"Chat"},{to:"/inbox",name:"inbox",icon:"📥",label:"Inbox"},{to:"/skills",name:"skills",icon:"⚙️",label:"Skills"},{to:"/squads",name:"squads",icon:"👥",label:"Squads"},{to:"/wiki",name:"wiki",icon:"📚",label:"Wiki"},{to:"/schedules",name:"schedules",icon:"📅",label:"Schedules"},{to:"/notifications",name:"notifications",icon:"🔔",label:"Notifications"},{to:"/activity",name:"activity",icon:"📊",label:"Activity"}],u=$e(()=>{var y;return(((y=r.user)==null?void 0:y.email)??"").charAt(0).toUpperCase()});function d(x){return e.name===x}function f(){a.value=!a.value;try{localStorage.setItem(tl,String(a.value))}catch{}}async function p(){await r.signOut(),s.push("/login")}function m(){i.value=0}function b(){o.value=0}return ts(async()=>{try{const x=localStorage.getItem(tl);x!==null&&(a.value=x==="true")}catch{}try{const x=await ke("/api/status");if(x.ok){const y=await x.json();n.value=y.version??""}}catch{}try{const x=await ke("/api/notifications?unread=true&limit=1");if(x.ok){const y=await x.json();i.value=y.unreadCount??0}}catch{}try{const x=await ke("/api/inbox/count");if(x.ok){const y=await x.json();o.value=y.count??0}}catch{}l=new EventSource(Gn("/api/events")),l.onmessage=x=>{try{JSON.parse(x.data).type==="notification"&&e.name!=="notifications"&&i.value++}catch{}}}),Nn(()=>{l==null||l.close(),l=null}),(x,y)=>Oe(e).name!=="login"?(_(),w("nav",{key:0,class:fe(["relative z-10 flex flex-col shrink-0 nav-sidebar border-r border-edge bg-surface-1/70 backdrop-blur-md",a.value?"nav-collapsed":"nav-expanded"])},[h("div",{class:fe(["flex items-center h-14 px-3 shrink-0",a.value?"justify-center":"justify-between"])},[a.value?(_(),w("div",zm,[...y[1]||(y[1]=[h("span",{class:"text-accent font-bold text-xs font-mono tracking-tight"},"IO",-1)])])):(_(),w("div",Gm,[...y[0]||(y[0]=[Dn('<div class="w-8 h-8 rounded-lg bg-accent/10 border border-accent/20 flex items-center justify-center shrink-0" data-v-e8febfce><span class="text-accent font-bold text-sm font-mono tracking-tight" data-v-e8febfce>IO</span></div><div class="min-w-0" data-v-e8febfce><p class="text-sm font-semibold text-txt-primary leading-tight tracking-tight" data-v-e8febfce>IO Assistant</p><p class="text-[10px] text-txt-muted leading-tight" data-v-e8febfce>Terminal · Dashboard</p></div>',2)])])),a.value?(_(),w("button",{key:3,onClick:f,class:"absolute -right-3 top-4 w-6 h-6 rounded-full bg-surface-2 border border-edge-bright shadow-card flex items-center justify-center text-txt-muted hover:text-accent hover:border-accent/30 transition-all duration-150 z-20",title:"Expand sidebar"},[...y[3]||(y[3]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[h("path",{d:"M6 3l5 5-5 5"})],-1)])])):(_(),w("button",{key:2,onClick:f,class:"p-1.5 rounded-md text-txt-muted hover:text-txt-secondary hover:bg-surface-3/50 transition-all duration-150 shrink-0 ml-1",title:"Collapse sidebar"},[...y[2]||(y[2]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"},[h("path",{d:"M10 3L5 8l5 5"})],-1)])]))],2),y[11]||(y[11]=h("div",{class:"mx-3 h-px bg-gradient-to-r from-transparent via-edge to-transparent"},null,-1)),h("div",Jm,[h("ul",{class:fe(["space-y-0.5",a.value?"px-1.5":"px-2"])},[(_(),w(be,null,qe(c,k=>h("li",{key:k.to},[He(Oe(Mc),{to:k.to,class:fe(["group flex items-center rounded-lg transition-all duration-150 relative",[a.value?"justify-center p-2":"px-2.5 py-2 gap-2.5",d(k.name)?"bg-accent/10 text-accent":"text-txt-secondary hover:text-txt-primary hover:bg-surface-3/40"]]),title:a.value?k.label:void 0,onClick:A=>k.name==="notifications"?m():k.name==="inbox"?b():void 0},{default:xr(()=>[d(k.name)?(_(),w("span",{key:0,class:fe(["absolute left-0 top-1/2 -translate-y-1/2 w-[3px] rounded-r-full bg-accent shadow-glow-sm",a.value?"h-4":"h-5"])},null,2)):Y("",!0),h("span",{class:fe(["text-base leading-none shrink-0 transition-transform duration-150 group-hover:scale-105",a.value?"":"ml-0.5"])},R(k.icon),3),a.value?Y("",!0):(_(),w("span",Ym,R(k.label),1)),k.name==="notifications"&&i.value>0?(_(),w("span",{key:2,class:fe(["absolute flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full min-w-[16px] h-[16px] px-0.5 ring-2 ring-surface-1",a.value?"top-0 right-0":"top-0.5 right-1"])},R(i.value>99?"99+":i.value),3)):Y("",!0),k.name==="inbox"&&o.value>0?(_(),w("span",{key:3,class:fe(["absolute flex items-center justify-center bg-accent text-surface-0 text-[9px] font-bold rounded-full min-w-[16px] h-[16px] px-0.5 ring-2 ring-surface-1",a.value?"top-0 right-0":"top-0.5 right-1"])},R(o.value>99?"99+":o.value),3)):Y("",!0)]),_:2},1032,["to","class","title","onClick"])])),64))],2)]),h("div",Xm,[y[10]||(y[10]=h("div",{class:"mx-3 h-px bg-gradient-to-r from-transparent via-edge to-transparent"},null,-1)),h("div",Zm,[a.value?(_(),w("div",cv,[y[9]||(y[9]=h("a",{href:"https://github.com/michaeljolley/io",target:"_blank",rel:"noopener",class:"p-1.5 rounded-md text-txt-muted hover:text-accent hover:bg-surface-3/50 transition-all duration-150",title:"GitHub"},[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"currentColor"},[h("path",{d:"M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.166 6.839 9.489.5.092.682-.217.682-.482 0-.237-.009-.868-.013-1.703-2.782.604-3.369-1.342-3.369-1.342-.454-1.154-1.11-1.462-1.11-1.462-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.578 9.578 0 0112 6.836a9.59 9.59 0 012.504.337c1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.203 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.741 0 .267.18.578.688.48C19.138 20.163 22 16.418 22 12c0-5.523-4.477-10-10-10z"})])],-1)),Oe(r).authEnabled&&Oe(r).user?(_(),w("button",{key:0,onClick:p,class:"p-1.5 rounded-md text-txt-muted hover:text-red-400 hover:bg-surface-3/50 transition-all duration-150",title:"Sign out"},[...y[8]||(y[8]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-3.5 w-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"},[h("path",{d:"M6 2H3a1 1 0 00-1 1v10a1 1 0 001 1h3M11 11l3-3-3-3M14 8H6"})],-1)])])):Y("",!0)])):(_(),w(be,{key:0},[Oe(r).authEnabled&&Oe(r).user?(_(),w(be,{key:0},[h("div",Qm,[h("div",ev,[h("span",tv,R(u.value),1)]),h("div",sv,[h("p",rv,R(Oe(r).user.email),1)])]),h("div",nv,[h("span",iv,[n.value?(_(),w("span",ov,"v"+R(n.value),1)):Y("",!0),y[4]||(y[4]=h("span",{class:"text-[10px] text-txt-muted"},"·",-1)),y[5]||(y[5]=h("a",{href:"https://github.com/michaeljolley/io",target:"_blank",rel:"noopener",class:"text-[10px] text-txt-muted hover:text-accent transition-colors"}," GitHub ",-1))]),h("button",{onClick:p,class:"text-[11px] text-txt-muted hover:text-red-400 transition-colors px-1.5 py-0.5 rounded hover:bg-surface-3/50"}," Sign out ")])],64)):(_(),w("div",av,[n.value?(_(),w("span",lv,"v"+R(n.value),1)):Y("",!0),y[6]||(y[6]=h("span",{class:"text-[10px] text-txt-muted"},"·",-1)),y[7]||(y[7]=h("a",{href:"https://github.com/michaeljolley/io",target:"_blank",rel:"noopener",class:"text-[10px] text-txt-muted hover:text-accent transition-colors"}," GitHub ",-1))]))],64))])])],2)):Y("",!0)}}),Hr=(t,e)=>{const s=t.__vccOpts||t;for(const[r,n]of e)s[r]=n;return s},dv=Hr(uv,[["__scopeId","data-v-e8febfce"]]),hv={class:"flex h-screen bg-surface-0 relative overflow-hidden"},fv={class:"flex-1 overflow-auto relative z-0"},pv=gt({__name:"App",setup(t){return(e,s)=>(_(),w("div",hv,[s[0]||(s[0]=h("div",{class:"pointer-events-none absolute inset-0 overflow-hidden","aria-hidden":"true"},[h("div",{class:"absolute -top-[40%] -left-[20%] w-[60%] h-[80%] rounded-full bg-accent/[0.02] blur-[120px]"}),h("div",{class:"absolute -bottom-[30%] -right-[10%] w-[50%] h-[60%] rounded-full bg-accent/[0.015] blur-[100px]"})],-1)),He(dv),h("main",fv,[He(Oe(Bc),null,{default:xr(({Component:r})=>[He(yc,{name:"view",mode:"out-in"},{default:xr(()=>[(_(),fc(xd(r)))]),_:2},1024)]),_:1})])]))}}),gv=Hr(pv,[["__scopeId","data-v-715b28be"]]),mv="modulepreload",vv=function(t){return"/"+t},sl={},bv=function(e,s,r){let n=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));n=Promise.allSettled(s.map(l=>{if(l=vv(l),l in sl)return;sl[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":mv,c||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),c)return new Promise((f,p)=>{d.addEventListener("load",f),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})},yv=Tc("chat",()=>{const t=F([]),e=F(!1);function s(i){t.value.push(i)}function r(i){const o=t.value[t.value.length-1];o&&o.role==="assistant"&&(o.content+=i)}function n(i){const o=t.value[t.value.length-1];o&&o.role==="assistant"&&(o.streaming=i)}return{messages:t,isLoading:e,addMessage:s,appendToLast:r,setLastStreaming:n}});function Pt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\*\*\*(.*?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`([^`]+)`/g,'<code class="bg-gray-800 px-1 rounded text-blue-300 font-mono text-xs">$1</code>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,s,r)=>`<a href="${/^https?:\/\//i.test(r)||r.startsWith("/")||r.startsWith("#")?r:"#"}" target="_blank" rel="noopener" class="text-blue-400 hover:underline">${s}</a>`)}function uu(t){const e=t.trim();return e.startsWith("|")&&e.endsWith("|")&&e.length>2}function rl(t){return uu(t)&&/^\|[\s|:\-]+\|$/.test(t.trim())}function mi(t){return t.trim().slice(1,-1).split("|").map(e=>e.trim())}function _v(t){const e=t.trim();return e.startsWith(":")&&e.endsWith(":")?"text-center":e.endsWith(":")?"text-right":"text-left"}function wv(t){if(t.length<2)return t.map(a=>`<p class="my-1">${Pt(a)}</p>`).join(`
|
|
73
|
-
`);const e=mi(t[0]),s=t[1],r=rl(s)?mi(s).map(
|
|
72
|
+
`);const $=await L.signMessage(new TextEncoder().encode(m),"utf8");if(!$||!($ instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");b=$}}try{const{data:x,error:y}=await ee(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:m,signature:ks(b)},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(p=e.options)===null||p===void 0?void 0:p.captchaToken}}:null),xform:ht});if(y)throw y;if(!x||!x.session||!x.user){const k=new Ps;return this._returnResult({data:{user:null,session:null},error:k})}return x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("SIGNED_IN",x.session)),this._returnResult({data:Object.assign({},x),error:y})}catch(x){if(z(x))return this._returnResult({data:{user:null,session:null},error:x});throw x}}async _exchangeCodeForSession(e){const s=await vs(this.storage,`${this.storageKey}-code-verifier`),[r,n]=(s??"").split("/");try{if(!r&&this.flowType==="pkce")throw new Dg;const{data:i,error:o}=await ee(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:ht});if(await Ge(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!i||!i.session||!i.user){const a=new Ps;return this._returnResult({data:{user:null,session:null,redirectType:null},error:a})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers(n==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:n??null}),error:o})}catch(i){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(e){try{const{options:s,provider:r,token:n,access_token:i,nonce:o}=e,a=await ee(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:n,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},xform:ht}),{data:l,error:c}=a;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l||!l.session||!l.user){const u=new Ps;return this._returnResult({data:{user:null,session:null},error:u})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),this._returnResult({data:l,error:c})}catch(s){if(z(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOtp(e){var s,r,n,i,o;try{if("email"in e){const{email:a,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await Is(this.storage,this.storageKey));const{error:d}=await ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(s=l==null?void 0:l.data)!==null&&s!==void 0?s:{},create_user:(r=l==null?void 0:l.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l==null?void 0:l.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:d})}if("phone"in e){const{phone:a,options:l}=e,{data:c,error:u}=await ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(n=l==null?void 0:l.data)!==null&&n!==void 0?n:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:u})}throw new Yr("You must provide either an email or phone number.")}catch(a){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async verifyOtp(e){var s,r;try{let n,i;"options"in e&&(n=(s=e.options)===null||s===void 0?void 0:s.redirectTo,i=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:o,error:a}=await ee(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:n,xform:ht});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,c=o.user;return l!=null&&l.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(n){if(z(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithSSO(e){var s,r,n,i,o;try{let a=null,l=null;this.flowType==="pkce"&&([a,l]=await Is(this.storage,this.storageKey));const c=await ee(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:(r=(s=e.options)===null||s===void 0?void 0:s.redirectTo)!==null&&r!==void 0?r:void 0}),!((n=e==null?void 0:e.options)===null||n===void 0)&&n.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:l}),headers:this.headers,xform:cm});return!((i=c.data)===null||i===void 0)&&i.url&&ze()&&!(!((o=e.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(a){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(a))return this._returnResult({data:null,error:a});throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)throw r;if(!s)throw new Ve;const{error:n}=await ee(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:s.access_token});return this._returnResult({data:{user:null,session:null},error:n})})}catch(e){if(z(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const s=`${this.url}/resend`;if("email"in e){const{email:r,type:n,options:i}=e,{error:o}=await ee(this.fetch,"POST",s,{headers:this.headers,body:{email:r,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in e){const{phone:r,type:n,options:i}=e,{data:o,error:a}=await ee(this.fetch,"POST",s,{headers:this.headers,body:{phone:r,type:n,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a})}throw new Yr("You must provide either an email or phone number and a type")}catch(s){if(z(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async s=>s))}async _acquireLock(e,s){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await r,await s()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=s();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await r}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 s=await this.__loadSession();return await e(s)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const s=await vs(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",s),s!==null&&(this._isValidSession(s)?e=s:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<di:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const o=await vs(this.userStorage,this.storageKey+"-user");o!=null&&o.user?e.user=o.user:e.user=fi()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};e.user=im(e.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{session:null},error:i}):this._returnResult({data:{session:n},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const s=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return s.data.user&&(this.suppressGetSessionWarning=!0),s}async _getUser(e){try{return e?await ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:cs}):await this._useSession(async s=>{var r,n,i;const{data:o,error:a}=s;if(a)throw a;return!(!((r=o.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Ve}:await ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0,xform:cs})})}catch(s){if(z(s))return Jr(s)&&(await this._removeSession(),await Ge(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:s});throw s}}async updateUser(e,s={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,s))}async _updateUser(e,s={}){try{return await this._useSession(async r=>{const{data:n,error:i}=r;if(i)throw i;if(!n.session)throw new Ve;const o=n.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await Is(this.storage,this.storageKey));const{data:c,error:u}=await ee(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:s==null?void 0:s.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:cs});if(u)throw u;return o.user=c.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(r){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(r))return this._returnResult({data:{user:null},error:r});throw r}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Ve;const s=Date.now()/1e3;let r=s,n=!0,i=null;const{payload:o}=Zr(e.access_token);if(o.exp&&(r=o.exp,n=r<=s),n){const{data:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:r-s,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(s){if(z(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async s=>{var r;if(!e){const{data:o,error:a}=s;if(a)throw a;e=(r=o.session)!==null&&r!==void 0?r:void 0}if(!(e!=null&&e.refresh_token))throw new Ve;const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):n?this._returnResult({data:{user:n.user,session:n},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(s){if(z(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async _getSessionFromURL(e,s){var r;try{if(!ze())throw new Xr("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Xr(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(s){case"implicit":if(this.flowType==="pkce")throw new Da("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Xr("Not a valid implicit grant flow url.");break;default:}if(s==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Da("No code detected.");const{data:A,error:L}=await this._exchangeCodeForSession(e.code);if(L)throw L;const N=new URL(window.location.href);return N.searchParams.delete("code"),window.history.replaceState(window.history.state,"",N.toString()),{data:{session:A.session,redirectType:(r=A.redirectType)!==null&&r!==void 0?r:null},error:null}}const{provider_token:n,provider_refresh_token:i,access_token:o,refresh_token:a,expires_in:l,expires_at:c,token_type:u}=e;if(!o||!l||!a||!u)throw new Xr("No session defined in URL");const d=Math.round(Date.now()/1e3),f=parseInt(l);let p=d+f;c&&(p=parseInt(c));const m=p-d;m*1e3<=Ms&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${m}s, should have been closer to ${f}s`);const b=p-f;d-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,p,d):d-b<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",b,p,d);const{data:x,error:y}=await this._getUser(o);if(y)throw y;const k={provider_token:n,provider_refresh_token:i,access_token:o,expires_in:f,expires_at:p,refresh_token:a,token_type:u,user:x.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:k,redirectType:e.type},error:null})}catch(n){if(z(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const s=await vs(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&s)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async s=>{var r;const{data:n,error:i}=s;if(i&&!Jr(i))return this._returnResult({error:i});const o=(r=n.session)===null||r===void 0?void 0:r.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(Lg(a)&&(a.status===404||a.status===401||a.status===403)||Jr(a)))return this._returnResult({error:a})}return e!=="others"&&(await this._removeSession(),await Ge(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const s=Wg(),r={id:s,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",s),this.stateChangeEmitters.delete(s)}};return this._debug("#onAuthStateChange()","registered callback with id",s),this.stateChangeEmitters.set(s,r),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(s)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async s=>{var r,n;try{const{data:{session:i},error:o}=s;if(o)throw o;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),Jr(i)?console.warn(i):console.error(i)}})}async resetPasswordForEmail(e,s={}){let r=null,n=null;this.flowType==="pkce"&&([r,n]=await Is(this.storage,this.storageKey,!0));try{return await ee(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:n,gotrue_meta_security:{captcha_token:s.captchaToken}},headers:this.headers,redirectTo:s.redirectTo})}catch(i){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:s,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:(e=s.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var s;try{const{data:r,error:n}=await this._useSession(async i=>{var o,a,l,c,u;const{data:d,error:f}=i;if(f)throw f;const p=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await ee(this.fetch,"GET",p,{headers:this.headers,jwt:(u=(c=d.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(n)throw n;return ze()&&!(!((s=e.options)===null||s===void 0)&&s.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),this._returnResult({data:{provider:e.provider,url:r==null?void 0:r.url},error:null})}catch(r){if(z(r))return this._returnResult({data:{provider:e.provider,url:null},error:r});throw r}}async linkIdentityIdToken(e){return await this._useSession(async s=>{var r;try{const{error:n,data:{session:i}}=s;if(n)throw n;const{options:o,provider:a,token:l,access_token:c,nonce:u}=e,d=await ee(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=i==null?void 0:i.access_token)!==null&&r!==void 0?r:void 0,body:{provider:a,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:ht}),{data:f,error:p}=d;return p?this._returnResult({data:{user:null,session:null},error:p}):!f||!f.session||!f.user?this._returnResult({data:{user:null,session:null},error:new Ps}):(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("USER_UPDATED",f.session)),this._returnResult({data:f,error:p}))}catch(n){if(await Ge(this.storage,`${this.storageKey}-code-verifier`),z(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}})}async unlinkIdentity(e){try{return await this._useSession(async s=>{var r,n;const{data:i,error:o}=s;if(o)throw o;return await ee(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(r=i.session)===null||r===void 0?void 0:r.access_token)!==null&&n!==void 0?n:void 0})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _refreshAccessToken(e){const s=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{const r=Date.now();return await Jg(async n=>(n>0&&await zg(200*Math.pow(2,n-1)),this._debug(s,"refreshing attempt",n),await ee(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:ht})),(n,i)=>{const o=200*Math.pow(2,n);return i&&hi(i)&&Date.now()+o-r<Ms})}catch(r){if(this._debug(s,"error",r),z(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}finally{this._debug(s,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,s){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:s.redirectTo,scopes:s.scopes,queryParams:s.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",s,"url",r),ze()&&!s.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,s;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const n=await vs(this.storage,this.storageKey);if(n&&this.userStorage){let o=await vs(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:n.user},await Bs(this.userStorage,this.storageKey+"-user",o)),n.user=(e=o==null?void 0:o.user)!==null&&e!==void 0?e:fi()}else if(n&&!n.user&&!n.user){const o=await vs(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(n.user=o.user,await Ge(this.storage,this.storageKey+"-user"),await Bs(this.storage,this.storageKey,n)):n.user=fi()}if(this._debug(r,"session from storage",n),!this._isValidSession(n)){this._debug(r,"session is not valid"),n!==null&&await this._removeSession();return}const i=((s=n.expires_at)!==null&&s!==void 0?s:1/0)*1e3-Date.now()<di;if(this._debug(r,`session has${i?"":" not"} expired with margin of ${di}s`),i){if(this.autoRefreshToken&&n.refresh_token){const{error:o}=await this._callRefreshToken(n.refresh_token);o&&(console.error(o),hi(o)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(n.user&&n.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:a}=await this._getUser(n.access_token);!a&&(o!=null&&o.user)?(n.user=o.user,await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(r,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(r,"error",n),console.error(n);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var s,r;if(!e)throw new Ve;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const n=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{this.refreshingDeferred=new Kn;const{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new Ve;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const a={data:i.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(i){if(this._debug(n,"error",i),z(i)){const o={data:null,error:i};return hi(i)||await this._removeSession(),(s=this.refreshingDeferred)===null||s===void 0||s.resolve(o),o}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(i),i}finally{this.refreshingDeferred=null,this._debug(n,"end")}}async _notifyAllSubscribers(e,s,r=!0){const n=`#_notifyAllSubscribers(${e})`;this._debug(n,"begin",s,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:s});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,s)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;a<i.length;a+=1)console.error(i[a]);throw i[0]}}finally{this._debug(n,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await Ge(this.storage,`${this.storageKey}-code-verifier`);const s=Object.assign({},e),r=s.user&&s.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&s.user&&await Bs(this.userStorage,this.storageKey+"-user",{user:s.user});const n=Object.assign({},s);delete n.user;const i=Va(n);await Bs(this.storage,this.storageKey,i)}else{const n=Va(s);await Bs(this.storage,this.storageKey,n)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Ge(this.storage,this.storageKey),await Ge(this.storage,this.storageKey+"-code-verifier"),await Ge(this.storage,this.storageKey+"-user"),this.userStorage&&await Ge(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ze()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(s){console.error("removing visibilitychange callback failed",s)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Ms);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const s=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const s=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,s&&clearTimeout(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async s=>{const{data:{session:r}}=s;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((r.expires_at*1e3-e)/Ms);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${Ms}ms, refresh threshold is ${Fi} ticks`),n<=Fi&&await this._callRefreshToken(r.refresh_token)})}catch(s){console.error("Auto refresh tick failed with error. This is likely a transient error.",s)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof nu)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ze()||!(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 s=`#_onVisibilityChanged(${e})`;this._debug(s,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(s,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,s,r){const n=[`provider=${encodeURIComponent(s)}`];if(r!=null&&r.redirectTo&&n.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r!=null&&r.scopes&&n.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[i,o]=await Is(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});n.push(a.toString())}if(r!=null&&r.queryParams){const i=new URLSearchParams(r.queryParams);n.push(i.toString())}return r!=null&&r.skipBrowserRedirect&&n.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${n.join("&")}`}async _unenroll(e){try{return await this._useSession(async s=>{var r;const{data:n,error:i}=s;return i?this._returnResult({data:null,error:i}):await ee(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _enroll(e){try{return await this._useSession(async s=>{var r,n;const{data:i,error:o}=s;if(o)return this._returnResult({data:null,error:o});const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await ee(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((n=l==null?void 0:l.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var r;const{data:n,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?Xa(e.webauthn.credential_response):Za(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:l}=await ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});return l?this._returnResult({data:null,error:l}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),this._returnResult({data:a,error:l}))})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var r;const{data:n,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=await ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(r=n==null?void 0:n.session)===null||r===void 0?void 0:r.access_token});if(o.error)return o;const{data:a}=o;if(a.type!=="webauthn")return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:Ja(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:Ya(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}})}async _challengeAndVerify(e){const{data:s,error:r}=await this._challenge({factorId:e.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:e.factorId,challengeId:s.id,code:e.code})}async _listFactors(){var e;const{data:{user:s},error:r}=await this.getUser();if(r)return{data:null,error:r};const n={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=s==null?void 0:s.factors)!==null&&e!==void 0?e:[])n.all.push(i),i.status==="verified"&&n[i.factor_type].push(i);return{data:n,error:null}}async _getAuthenticatorAssuranceLevel(e){var s,r,n,i;if(e)try{const{payload:p}=Zr(e);let m=null;p.aal&&(m=p.aal);let b=m;const{data:{user:x},error:y}=await this.getUser(e);if(y)return this._returnResult({data:null,error:y});((r=(s=x==null?void 0:x.factors)===null||s===void 0?void 0:s.filter(L=>L.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(b="aal2");const A=p.amr||[];return{data:{currentLevel:m,nextLevel:b,currentAuthenticationMethods:A},error:null}}catch(p){if(z(p))return this._returnResult({data:null,error:p});throw p}const{data:{session:o},error:a}=await this.getSession();if(a)return this._returnResult({data:null,error:a});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=Zr(o.access_token);let c=null;l.aal&&(c=l.aal);let u=c;((i=(n=o.user.factors)===null||n===void 0?void 0:n.filter(p=>p.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(u="aal2");const f=l.amr||[];return{data:{currentLevel:c,nextLevel:u,currentAuthenticationMethods:f},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;return n?this._returnResult({data:null,error:n}):r?await ee(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:r.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new Ve})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _approveAuthorization(e,s){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 Ve});const o=await ee(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"approve"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&ze()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(z(r))return this._returnResult({data:null,error:r});throw r}}async _denyAuthorization(e,s){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 Ve});const o=await ee(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"deny"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&ze()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(z(r))return this._returnResult({data:null,error:r});throw r}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;return r?this._returnResult({data:null,error:r}):s?await ee(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,xform:n=>({data:n,error:null})}):this._returnResult({data:null,error:new Ve})})}catch(e){if(z(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;return n?this._returnResult({data:null,error:n}):r?(await ee(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new Ve})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async fetchJwk(e,s={keys:[]}){let r=s.keys.find(a=>a.kid===e);if(r)return r;const n=Date.now();if(r=this.jwks.keys.find(a=>a.kid===e),r&&this.jwks_cached_at+jg>n)return r;const{data:i,error:o}=await ee(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=n,r=i.keys.find(a=>a.kid===e),!r)?null:r}async getClaims(e,s={}){try{let r=e;if(!r){const{data:p,error:m}=await this.getSession();if(m||!p.session)return this._returnResult({data:null,error:m});r=p.session.access_token}const{header:n,payload:i,signature:o,raw:{header:a,payload:l}}=Zr(r);s!=null&&s.allowExpired||sm(i.exp);const c=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,s!=null&&s.keys?{keys:s.keys}:s==null?void 0:s.jwks);if(!c){const{error:p}=await this.getUser(r);if(p)throw p;return{data:{claims:i,header:n,signature:o},error:null}}const u=rm(n.alg),d=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,d,o,Vg(`${a}.${l}`)))throw new Wi("Invalid JWT signature");return{data:{claims:i,header:n,signature:o},error:null}}catch(r){if(z(r))return this._returnResult({data:null,error:r});throw r}}async signInWithPasskey(e){var s,r,n;mt(this.experimental);try{if(!wn())return this._returnResult({data:null,error:new bt("Browser does not support WebAuthn",null)});const{data:i,error:o}=await this._startPasskeyAuthentication({options:{captchaToken:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}});if(o||!i)return this._returnResult({data:null,error:o});const a=Ya(i.options),l=(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.signal)!==null&&n!==void 0?n:Ki.createNewAbortSignal(),{data:c,error:u}=await lu({publicKey:a,signal:l});if(u||!c)return this._returnResult({data:null,error:u??new bt("WebAuthn ceremony failed",null)});const d=Za(c);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:d})}catch(i){if(z(i))return this._returnResult({data:null,error:i});throw i}}async registerPasskey(e){var s,r;mt(this.experimental);try{if(!wn())return this._returnResult({data:null,error:new bt("Browser does not support WebAuthn",null)});const{data:n,error:i}=await this._startPasskeyRegistration();if(i||!n)return this._returnResult({data:null,error:i});const o=Ja(n.options),a=(r=(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.signal)!==null&&r!==void 0?r:Ki.createNewAbortSignal(),{data:l,error:c}=await au({publicKey:o,signal:a});if(c||!l)return this._returnResult({data:null,error:c??new bt("WebAuthn ceremony failed",null)});const u=Xa(l);return this._verifyPasskeyRegistration({challengeId:n.challenge_id,credential:u})}catch(n){if(z(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyRegistration(){mt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!s)return this._returnResult({data:null,error:new Ve});const{data:n,error:i}=await ee(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:s.access_token,body:{}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(z(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){mt(this.experimental);try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new Ve});const{data:i,error:o}=await ee(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:r.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _startPasskeyAuthentication(e){var s;mt(this.experimental);try{const{data:r,error:n}=await ee(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:r,error:null})}catch(r){if(z(r))return this._returnResult({data:null,error:r});throw r}}async _verifyPasskeyAuthentication(e){mt(this.experimental);try{const{data:s,error:r}=await ee(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:ht});return r?this._returnResult({data:null,error:r}):(s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),this._returnResult({data:s,error:null}))}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _listPasskeys(){mt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:s},error:r}=e;if(r)return this._returnResult({data:null,error:r});if(!s)return this._returnResult({data:null,error:new Ve});const{data:n,error:i}=await ee(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:s.access_token,xform:o=>({data:o,error:null})});return i?this._returnResult({data:null,error:i}):this._returnResult({data:n,error:null})})}catch(e){if(z(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){mt(this.experimental);try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new Ve});const{data:i,error:o}=await ee(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,body:{friendly_name:e.friendlyName}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}async _deletePasskey(e){mt(this.experimental);try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new Ve});const{error:i}=await ee(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:r.access_token,noResolveJson:!0});return i?this._returnResult({data:null,error:i}):this._returnResult({data:null,error:null})})}catch(s){if(z(s))return this._returnResult({data:null,error:s});throw s}}}Ir.nextInstanceID={};const Am=Ir,Cm="2.105.4";let or="";typeof Deno<"u"?or="deno":typeof document<"u"?or="web":typeof navigator<"u"&&navigator.product==="ReactNative"?or="react-native":or="node";const Rm={"X-Client-Info":`supabase-js-${or}/${Cm}`},Om={headers:Rm},$m={schema:"public"},Pm={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Im={};function jr(t){"@babel/helpers - typeof";return jr=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},jr(t)}function jm(t,e){if(jr(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e);if(jr(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Nm(t){var e=jm(t,"string");return jr(e)=="symbol"?e:e+""}function Lm(t,e,s){return(e=Nm(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function el(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,r)}return s}function je(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?el(Object(s),!0).forEach(function(r){Lm(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):el(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}const Um=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Dm=()=>Headers,Mm=(t,e,s)=>{const r=Um(s),n=Dm();return async(i,o)=>{var a;const l=(a=await e())!==null&&a!==void 0?a:t;let c=new n(o==null?void 0:o.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),r(i,je(je({},o),{},{headers:c}))}};function Bm(t){return t.endsWith("/")?t:t+"/"}function Hm(t,e){var s,r;const{db:n,auth:i,realtime:o,global:a}=t,{db:l,auth:c,realtime:u,global:d}=e,f={db:je(je({},l),n),auth:je(je({},c),i),realtime:je(je({},u),o),storage:{},global:je(je(je({},d),a),{},{headers:je(je({},(s=d==null?void 0:d.headers)!==null&&s!==void 0?s:{}),(r=a==null?void 0:a.headers)!==null&&r!==void 0?r:{})}),accessToken:async()=>""};return t.accessToken?f.accessToken=t.accessToken:delete f.accessToken,f}function Fm(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(Bm(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var Vm=class extends Am{constructor(t){super(t)}},qm=class{constructor(t,e,s){var r,n;this.supabaseUrl=t,this.supabaseKey=e;const i=Fm(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const o=`sb-${i.hostname.split(".")[0]}-auth-token`,a={db:$m,realtime:Im,auth:je(je({},Pm),{},{storageKey:o}),global:Om},l=Hm(s??{},a);if(this.storageKey=(r=l.auth.storageKey)!==null&&r!==void 0?r:"",this.headers=(n=l.global.headers)!==null&&n!==void 0?n:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(u,d)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(d)} is not possible`)}});else{var c;this.auth=this._initSupabaseAuthClient((c=l.auth)!==null&&c!==void 0?c:{},this.headers,l.global.fetch)}this.fetch=Mm(e,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(je({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(u=>this.realtime.setAuth(u)).catch(u=>console.warn("Failed to set initial Realtime auth token:",u)),this.rest=new mp(new URL("rest/v1",i).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new Rg(this.storageUrl.href,this.headers,this.fetch,s==null?void 0:s.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new op(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={},s={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,s)}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,s;if(t.accessToken)return await t.accessToken();const{data:r}=await t.auth.getSession();return(e=(s=r.session)===null||s===void 0?void 0:s.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:r,userStorage:n,storageKey:i,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,lockAcquireTimeout:d,skipAutoInitialize:f},p,m){const b={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Vm({url:this.authUrl.href,headers:je(je({},b),p),storageKey:i,autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:r,userStorage:n,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,fetch:m,lockAcquireTimeout:d,skipAutoInitialize:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(x=>x.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new Zp(this.realtimeUrl.href,je(je({},t),{},{params:je(je({},{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,s){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==s?(this.changedAccessToken=s,this.realtime.setAuth(s)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const Wm=(t,e,s)=>new qm(t,e,s);function Km(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const s=e.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}Km()&&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");let Qr=null,en=null;async function cu(){if(en)return en;try{const t=await fetch("/api/auth/config");if(!t.ok)throw new Error(`HTTP ${t.status}`);return en=await t.json(),en}catch{return{authEnabled:!1,supabaseUrl:null,supabaseAnonKey:null}}}async function gi(){if(Qr)return Qr;const t=await cu();return!t.authEnabled||!t.supabaseUrl||!t.supabaseAnonKey?null:(Qr=Wm(t.supabaseUrl,t.supabaseAnonKey,{auth:{persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!0}}),Qr)}const Br=Tc("auth",()=>{const t=F(null),e=F(null),s=F(!1),r=F(!1),n=F(!1);let i=null;async function o(){const d=await cu();if(n.value=d.authEnabled,!d.authEnabled){r.value=!0;return}const f=await gi();if(!f){r.value=!0;return}await new Promise(p=>{f.auth.onAuthStateChange((m,b)=>{e.value=b,t.value=(b==null?void 0:b.user)??null,m==="INITIAL_SESSION"&&p()})}),r.value=!0}async function a(){if(!r.value)return i||(i=o().catch(()=>{i=null})),i}async function l(d,f){const p=await gi();if(!p)return"Auth not configured";s.value=!0;try{const{error:m}=await p.auth.signInWithPassword({email:d,password:f});return m?m.message:null}finally{s.value=!1}}async function c(){const d=await gi();d&&await d.auth.signOut(),t.value=null,e.value=null}function u(){var d;return((d=e.value)==null?void 0:d.access_token)??null}return{user:t,session:e,loading:s,initialized:r,authEnabled:n,init:a,signIn:l,signOut:c,getAccessToken:u}});async function ke(t,e){const s=Br(),r=s.getAccessToken(),n=new Headers(e==null?void 0:e.headers);r&&n.set("Authorization",`Bearer ${r}`);const i=await fetch(t,{...e,headers:n});return i.status===401&&s.authEnabled&&await s.signOut(),i}function Gn(t){const s=Br().getAccessToken();if(!s)return t;const r=t.includes("?")?"&":"?";return`${t}${r}token=${encodeURIComponent(s)}`}const Gm={key:0,class:"flex items-center gap-2.5 min-w-0"},zm={key:1,class:"w-8 h-8 rounded-lg bg-accent/10 border border-accent/20 flex items-center justify-center"},Jm={class:"flex-1 py-3 overflow-y-auto overflow-x-hidden"},Ym={key:1,class:"text-[13px] font-medium truncate"},Xm={class:"shrink-0"},Zm={class:"p-2.5"},Qm={class:"flex items-center gap-2 px-2 py-1.5 rounded-lg bg-surface-2/50 mb-1.5"},e0={class:"w-6 h-6 rounded-full bg-accent/10 border border-accent/20 flex items-center justify-center shrink-0"},t0={class:"text-[10px] text-accent font-semibold"},s0={class:"min-w-0 flex-1"},r0={class:"text-xs text-txt-primary truncate leading-tight"},n0={class:"flex items-center justify-between px-2"},i0={class:"flex items-center gap-1.5"},o0={key:0,class:"text-[10px] text-txt-muted font-mono"},a0={key:1,class:"flex items-center gap-1.5 px-2"},l0={key:0,class:"text-[10px] text-txt-muted font-mono"},c0={key:1,class:"flex flex-col items-center gap-1.5"},tl="io-nav-collapsed",u0=gt({__name:"AppNav",setup(t){const e=sp(),s=Hc(),r=Br(),n=F(""),i=F(0),o=F(0),a=F(!1);let l=null;const c=[{to:"/chat",name:"chat",icon:"💬",label:"Chat"},{to:"/inbox",name:"inbox",icon:"📥",label:"Inbox"},{to:"/skills",name:"skills",icon:"⚙️",label:"Skills"},{to:"/squads",name:"squads",icon:"👥",label:"Squads"},{to:"/wiki",name:"wiki",icon:"📚",label:"Wiki"},{to:"/schedules",name:"schedules",icon:"📅",label:"Schedules"},{to:"/notifications",name:"notifications",icon:"🔔",label:"Notifications"},{to:"/activity",name:"activity",icon:"📊",label:"Activity"}],u=$e(()=>{var y;return(((y=r.user)==null?void 0:y.email)??"").charAt(0).toUpperCase()});function d(x){return e.name===x}function f(){a.value=!a.value;try{localStorage.setItem(tl,String(a.value))}catch{}}async function p(){await r.signOut(),s.push("/login")}function m(){i.value=0}function b(){o.value=0}return ts(async()=>{try{const x=localStorage.getItem(tl);x!==null&&(a.value=x==="true")}catch{}try{const x=await ke("/api/status");if(x.ok){const y=await x.json();n.value=y.version??""}}catch{}try{const x=await ke("/api/notifications?unread=true&limit=1");if(x.ok){const y=await x.json();i.value=y.unreadCount??0}}catch{}try{const x=await ke("/api/inbox/count");if(x.ok){const y=await x.json();o.value=y.count??0}}catch{}l=new EventSource(Gn("/api/events")),l.onmessage=x=>{try{JSON.parse(x.data).type==="notification"&&e.name!=="notifications"&&i.value++}catch{}}}),Nn(()=>{l==null||l.close(),l=null}),(x,y)=>Oe(e).name!=="login"?(_(),w("nav",{key:0,class:fe(["relative z-10 flex flex-col shrink-0 nav-sidebar border-r border-edge bg-surface-1/70 backdrop-blur-md",a.value?"nav-collapsed":"nav-expanded"])},[h("div",{class:fe(["flex items-center h-14 px-3 shrink-0",a.value?"justify-center":"justify-between"])},[a.value?(_(),w("div",zm,[...y[1]||(y[1]=[h("span",{class:"text-accent font-bold text-xs font-mono tracking-tight"},"IO",-1)])])):(_(),w("div",Gm,[...y[0]||(y[0]=[Dn('<div class="w-8 h-8 rounded-lg bg-accent/10 border border-accent/20 flex items-center justify-center shrink-0" data-v-c37feebe><span class="text-accent font-bold text-sm font-mono tracking-tight" data-v-c37feebe>IO</span></div><div class="min-w-0" data-v-c37feebe><p class="text-sm font-semibold text-txt-primary leading-tight tracking-tight" data-v-c37feebe>IO Assistant</p><p class="text-[10px] text-txt-muted leading-tight" data-v-c37feebe>Terminal · Dashboard</p></div>',2)])])),a.value?(_(),w("button",{key:3,onClick:f,class:"absolute -right-3 top-4 w-6 h-6 rounded-full bg-surface-2 border border-edge-bright shadow-card flex items-center justify-center text-txt-muted hover:text-accent hover:border-accent/30 transition-all duration-150 z-20",title:"Expand sidebar"},[...y[3]||(y[3]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[h("path",{d:"M6 3l5 5-5 5"})],-1)])])):(_(),w("button",{key:2,onClick:f,class:"p-1.5 rounded-md text-txt-muted hover:text-txt-secondary hover:bg-surface-3/50 transition-all duration-150 shrink-0 ml-1",title:"Collapse sidebar"},[...y[2]||(y[2]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"},[h("path",{d:"M10 3L5 8l5 5"})],-1)])]))],2),y[11]||(y[11]=h("div",{class:"mx-3 h-px bg-gradient-to-r from-transparent via-edge to-transparent"},null,-1)),h("div",Jm,[h("ul",{class:fe(["space-y-0.5",a.value?"px-1.5":"px-2"])},[(_(),w(be,null,qe(c,k=>h("li",{key:k.to},[He(Oe(Mc),{to:k.to,class:fe(["group flex items-center rounded-lg transition-all duration-150 relative",[a.value?"justify-center p-2":"px-2.5 py-2 gap-2.5",d(k.name)?"bg-accent/10 text-accent":"text-txt-secondary hover:text-txt-primary hover:bg-surface-3/40"]]),title:a.value?k.label:void 0,onClick:A=>k.name==="notifications"?m():k.name==="inbox"?b():void 0},{default:xr(()=>[d(k.name)?(_(),w("span",{key:0,class:fe(["absolute left-0 top-1/2 -translate-y-1/2 w-[3px] rounded-r-full bg-accent shadow-glow-sm",a.value?"h-4":"h-5"])},null,2)):Y("",!0),h("span",{class:fe(["text-base leading-none shrink-0 transition-transform duration-150 group-hover:scale-105",a.value?"":"ml-0.5"])},R(k.icon),3),a.value?Y("",!0):(_(),w("span",Ym,R(k.label),1)),k.name==="notifications"&&i.value>0?(_(),w("span",{key:2,class:fe(["absolute flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full min-w-[16px] h-[16px] px-0.5 ring-2 ring-surface-1",a.value?"top-0 right-0":"top-0.5 right-1"])},R(i.value>99?"99+":i.value),3)):Y("",!0),k.name==="inbox"&&o.value>0?(_(),w("span",{key:3,class:fe(["absolute flex items-center justify-center bg-accent text-surface-0 text-[9px] font-bold rounded-full min-w-[16px] h-[16px] px-0.5 ring-2 ring-surface-1",a.value?"top-0 right-0":"top-0.5 right-1"])},R(o.value>99?"99+":o.value),3)):Y("",!0)]),_:2},1032,["to","class","title","onClick"])])),64))],2)]),h("div",Xm,[y[10]||(y[10]=h("div",{class:"mx-3 h-px bg-gradient-to-r from-transparent via-edge to-transparent"},null,-1)),h("div",Zm,[a.value?(_(),w("div",c0,[y[9]||(y[9]=h("a",{href:"https://github.com/michaeljolley/io",target:"_blank",rel:"noopener",class:"p-1.5 rounded-md text-txt-muted hover:text-accent hover:bg-surface-3/50 transition-all duration-150",title:"GitHub"},[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"currentColor"},[h("path",{d:"M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.166 6.839 9.489.5.092.682-.217.682-.482 0-.237-.009-.868-.013-1.703-2.782.604-3.369-1.342-3.369-1.342-.454-1.154-1.11-1.462-1.11-1.462-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.578 9.578 0 0112 6.836a9.59 9.59 0 012.504.337c1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.203 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.741 0 .267.18.578.688.48C19.138 20.163 22 16.418 22 12c0-5.523-4.477-10-10-10z"})])],-1)),Oe(r).authEnabled&&Oe(r).user?(_(),w("button",{key:0,onClick:p,class:"p-1.5 rounded-md text-txt-muted hover:text-red-400 hover:bg-surface-3/50 transition-all duration-150",title:"Sign out"},[...y[8]||(y[8]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-3.5 w-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"},[h("path",{d:"M6 2H3a1 1 0 00-1 1v10a1 1 0 001 1h3M11 11l3-3-3-3M14 8H6"})],-1)])])):Y("",!0)])):(_(),w(be,{key:0},[Oe(r).authEnabled&&Oe(r).user?(_(),w(be,{key:0},[h("div",Qm,[h("div",e0,[h("span",t0,R(u.value),1)]),h("div",s0,[h("p",r0,R(Oe(r).user.email),1)])]),h("div",n0,[h("span",i0,[n.value?(_(),w("span",o0,"v"+R(n.value),1)):Y("",!0),y[4]||(y[4]=h("span",{class:"text-[10px] text-txt-muted"},"·",-1)),y[5]||(y[5]=h("a",{href:"https://github.com/michaeljolley/io",target:"_blank",rel:"noopener",class:"text-[10px] text-txt-muted hover:text-accent transition-colors"},[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-3 w-3",viewBox:"0 0 24 24",fill:"currentColor"},[h("path",{d:"M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.166 6.839 9.489.5.092.682-.217.682-.482 0-.237-.009-.868-.013-1.703-2.782.604-3.369-1.342-3.369-1.342-.454-1.154-1.11-1.462-1.11-1.462-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.578 9.578 0 0112 6.836a9.59 9.59 0 012.504.337c1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.203 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.741 0 .267.18.578.688.48C19.138 20.163 22 16.418 22 12c0-5.523-4.477-10-10-10z"})])],-1))]),h("button",{onClick:p,class:"text-[11px] text-txt-muted hover:text-red-400 transition-colors px-1.5 py-0.5 rounded hover:bg-surface-3/50"}," Sign out ")])],64)):(_(),w("div",a0,[n.value?(_(),w("span",l0,"v"+R(n.value),1)):Y("",!0),y[6]||(y[6]=h("span",{class:"text-[10px] text-txt-muted"},"·",-1)),y[7]||(y[7]=h("a",{href:"https://github.com/michaeljolley/io",target:"_blank",rel:"noopener",class:"text-[10px] text-txt-muted hover:text-accent transition-colors"},[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-3 w-3",viewBox:"0 0 24 24",fill:"currentColor"},[h("path",{d:"M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.166 6.839 9.489.5.092.682-.217.682-.482 0-.237-.009-.868-.013-1.703-2.782.604-3.369-1.342-3.369-1.342-.454-1.154-1.11-1.462-1.11-1.462-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.578 9.578 0 0112 6.836a9.59 9.59 0 012.504.337c1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.203 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.741 0 .267.18.578.688.48C19.138 20.163 22 16.418 22 12c0-5.523-4.477-10-10-10z"})])],-1))]))],64))])])],2)):Y("",!0)}}),Hr=(t,e)=>{const s=t.__vccOpts||t;for(const[r,n]of e)s[r]=n;return s},d0=Hr(u0,[["__scopeId","data-v-c37feebe"]]),h0={class:"flex h-screen bg-surface-0 relative overflow-hidden"},f0={class:"flex-1 overflow-auto relative z-0"},p0=gt({__name:"App",setup(t){return(e,s)=>(_(),w("div",h0,[s[0]||(s[0]=h("div",{class:"pointer-events-none absolute inset-0 overflow-hidden","aria-hidden":"true"},[h("div",{class:"absolute -top-[40%] -left-[20%] w-[60%] h-[80%] rounded-full bg-accent/[0.02] blur-[120px]"}),h("div",{class:"absolute -bottom-[30%] -right-[10%] w-[50%] h-[60%] rounded-full bg-accent/[0.015] blur-[100px]"})],-1)),He(d0),h("main",f0,[He(Oe(Bc),null,{default:xr(({Component:r})=>[He(yc,{name:"view",mode:"out-in"},{default:xr(()=>[(_(),fc(xd(r)))]),_:2},1024)]),_:1})])]))}}),g0=Hr(p0,[["__scopeId","data-v-715b28be"]]),m0="modulepreload",v0=function(t){return"/"+t},sl={},b0=function(e,s,r){let n=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));n=Promise.allSettled(s.map(l=>{if(l=v0(l),l in sl)return;sl[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":m0,c||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),c)return new Promise((f,p)=>{d.addEventListener("load",f),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})},y0=Tc("chat",()=>{const t=F([]),e=F(!1);function s(i){t.value.push(i)}function r(i){const o=t.value[t.value.length-1];o&&o.role==="assistant"&&(o.content+=i)}function n(i){const o=t.value[t.value.length-1];o&&o.role==="assistant"&&(o.streaming=i)}return{messages:t,isLoading:e,addMessage:s,appendToLast:r,setLastStreaming:n}});function Pt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\*\*\*(.*?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`([^`]+)`/g,'<code class="bg-gray-800 px-1 rounded text-blue-300 font-mono text-xs">$1</code>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,s,r)=>`<a href="${/^https?:\/\//i.test(r)||r.startsWith("/")||r.startsWith("#")?r:"#"}" target="_blank" rel="noopener" class="text-blue-400 hover:underline">${s}</a>`)}function uu(t){const e=t.trim();return e.startsWith("|")&&e.endsWith("|")&&e.length>2}function rl(t){return uu(t)&&/^\|[\s|:\-]+\|$/.test(t.trim())}function mi(t){return t.trim().slice(1,-1).split("|").map(e=>e.trim())}function _0(t){const e=t.trim();return e.startsWith(":")&&e.endsWith(":")?"text-center":e.endsWith(":")?"text-right":"text-left"}function w0(t){if(t.length<2)return t.map(a=>`<p class="my-1">${Pt(a)}</p>`).join(`
|
|
73
|
+
`);const e=mi(t[0]),s=t[1],r=rl(s)?mi(s).map(_0):e.map(()=>"text-left"),n=rl(s)?t.slice(2):t.slice(1),i=e.map((a,l)=>`<th class="px-3 py-1.5 font-medium text-gray-300 ${r[l]??"text-left"}">${Pt(a)}</th>`).join(""),o=n.map(a=>{const l=mi(a);return`<tr class="border-b border-gray-800">${e.map((u,d)=>`<td class="px-3 py-1.5 text-gray-400 ${r[d]??"text-left"}">${Pt(l[d]??"")}</td>`).join("")}</tr>`}).join("");return`<div class="overflow-x-auto my-2"><table class="border-collapse w-full text-sm"><thead><tr class="border-b border-gray-700">${i}</tr></thead><tbody>${o}</tbody></table></div>`}function x0(t){if(!t.startsWith(`---
|
|
74
74
|
`)&&t!=="---")return{frontmatter:null,body:t};const e=t.indexOf(`
|
|
75
75
|
---
|
|
76
76
|
`,3),s=t.indexOf(`
|
|
77
77
|
---`,3),r=e!==-1?e:s!==-1&&t.slice(s).trimEnd()==="---"?s:-1;if(r===-1)return{frontmatter:null,body:t};const n=t.slice(4,r),i=e!==-1?t.slice(e+5):"",o={};for(const a of n.split(`
|
|
78
78
|
`)){const l=a.match(/^([^:]+):\s*(.*)$/);if(!l)continue;const c=l[1].trim();let u=l[2].trim();(u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'"))&&(u=u.slice(1,-1)),o[c]=u}return{frontmatter:Object.keys(o).length>0?o:null,body:i}}function zn(t){if(!t)return"";const e=t.split(`
|
|
79
|
-
`),s=[];let r=!1,n=!1,i=!1,o=[],a=[];function l(){n&&(s.push("</ul>"),n=!1)}function c(){i&&(s.push(
|
|
79
|
+
`),s=[];let r=!1,n=!1,i=!1,o=[],a=[];function l(){n&&(s.push("</ul>"),n=!1)}function c(){i&&(s.push(w0(a)),a=[],i=!1)}for(const u of e){if(u.startsWith("```")){if(l(),c(),!r)r=!0,o=[];else{const y=o.join(`
|
|
80
80
|
`).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");s.push(`<pre class="bg-gray-900 border border-gray-800 rounded p-3 my-2 overflow-x-auto"><code class="font-mono text-xs text-green-300">${y}</code></pre>`),r=!1,o=[]}continue}if(r){o.push(u);continue}if(uu(u)){l(),i=!0,a.push(u);continue}i&&c();const d=u.match(/^####\s+(.+)/),f=u.match(/^###\s+(.+)/),p=u.match(/^##\s+(.+)/),m=u.match(/^#\s+(.+)/);if(d){l(),s.push(`<h4 class="text-sm font-semibold text-gray-200 mt-4 mb-1">${Pt(d[1])}</h4>`);continue}if(f){l(),s.push(`<h3 class="text-base font-semibold text-gray-100 mt-5 mb-2">${Pt(f[1])}</h3>`);continue}if(p){l(),s.push(`<h2 class="text-lg font-bold text-gray-100 mt-6 mb-2 pb-1 border-b border-gray-800">${Pt(p[1])}</h2>`);continue}if(m){l(),s.push(`<h1 class="text-xl font-bold text-gray-100 mt-6 mb-3">${Pt(m[1])}</h1>`);continue}if(/^---+$/.test(u.trim())){l(),s.push('<hr class="border-gray-800 my-4" />');continue}const b=u.match(/^[-*+]\s+(.+)/);if(b){n||(s.push('<ul class="list-disc list-inside my-2 space-y-1 pl-2">'),n=!0),s.push(`<li>${Pt(b[1])}</li>`);continue}const x=u.match(/^\d+\.\s+(.+)/);if(x){n||(s.push('<ol class="list-decimal list-inside my-2 space-y-1 pl-2">'),n=!0),s.push(`<li>${Pt(x[1])}</li>`);continue}if(u.trim()===""){l(),s.push('<div class="my-2"></div>');continue}l(),s.push(`<p class="my-1">${Pt(u)}</p>`)}if(r&&o.length){const u=o.join(`
|
|
81
81
|
`).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");s.push(`<pre class="bg-gray-900 border border-gray-800 rounded p-3 my-2 overflow-x-auto"><code class="font-mono text-xs text-green-300">${u}</code></pre>`)}return c(),l(),s.join(`
|
|
82
|
-
`)}const
|
|
82
|
+
`)}const k0={class:"flex flex-col h-full relative bg-surface-0"},S0={key:0,class:"flex flex-col items-center justify-center h-full select-none animate-fade-in"},E0={class:"flex flex-wrap justify-center gap-2 mt-8 max-w-md"},T0=["onClick"],A0={key:1,class:"max-w-3xl mx-auto space-y-5"},C0={key:0,class:"max-w-[80%] px-4 py-2.5 rounded-2xl rounded-br-md text-sm whitespace-pre-wrap bg-accent/[0.12] text-txt-primary border border-accent/20"},R0={key:1,class:"max-w-[85%] flex gap-2.5 items-start"},O0=["innerHTML"],$0={key:0,class:"flex justify-start animate-fade-in"},P0={class:"shrink-0 border-t border-edge/50 bg-surface-1/60 backdrop-blur-md p-3 sm:p-4"},I0={class:"flex-1 relative group"},j0=["disabled"],N0=["disabled"],L0={class:"hidden sm:inline"},U0=["disabled"],D0='<span class="stream-cursor"></span>',M0=gt({__name:"ChatView",setup(t){const e=y0(),s=F(""),r=F(!1),n=F(null),i=F(!1),o=F(null),a=["Check squad status","Run my schedules","Summarize recent activity","What skills are installed?"];function l(x){s.value=x,Es(()=>b())}async function c(){if(!r.value){r.value=!0;try{await ke("/api/orchestrator/abort",{method:"POST"})}catch{}finally{r.value=!1}}}const u=$e(()=>e.messages.some(x=>x.streaming));function d(){const x=n.value;x&&(i.value=x.scrollTop+x.clientHeight<x.scrollHeight-100)}function f(){Es(()=>{n.value&&(n.value.scrollTop=n.value.scrollHeight)})}us(()=>e.messages.length,()=>{i.value||f()});function p(x){x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),b())}function m(){const x=o.value;x&&(x.style.height="auto",x.style.height=Math.min(x.scrollHeight,200)+"px")}async function b(){const x=s.value.trim();if(!x||e.isLoading)return;s.value="",Es(()=>{o.value&&(o.value.style.height="auto")}),e.isLoading=!0,e.addMessage({id:crypto.randomUUID(),role:"user",content:x}),e.addMessage({id:crypto.randomUUID(),role:"assistant",content:"",streaming:!0}),f();const y=new EventSource(Gn("/api/events"));y.onmessage=k=>{try{const A=JSON.parse(k.data);A.type==="delta"?(e.appendToLast(A.text),f()):A.type==="done"&&(e.setLastStreaming(!1),e.isLoading=!1,y.close(),f())}catch{}},y.onerror=()=>{e.setLastStreaming(!1),e.isLoading=!1,y.close()};try{await ke("/api/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:x})})}catch{e.appendToLast(`
|
|
83
83
|
|
|
84
|
-
[Error: failed to reach IO]`),e.setLastStreaming(!1),e.isLoading=!1,y.close()}}return(x,y)=>(_(),w("div",kv,[h("div",{ref_key:"messagesEl",ref:n,class:"flex-1 overflow-y-auto px-4 py-6 sm:px-6",onScroll:d},[Oe(e).messages.length===0?(_(),w("div",Sv,[y[1]||(y[1]=h("div",{class:"w-16 h-16 rounded-2xl bg-accent/10 border border-accent/20 flex items-center justify-center mb-5 shadow-glow"},[h("span",{class:"text-accent font-bold text-2xl font-mono tracking-tighter"},"IO")],-1)),y[2]||(y[2]=h("p",{class:"text-txt-secondary text-sm font-medium mb-1"},"What can I help you build?",-1)),y[3]||(y[3]=h("p",{class:"text-txt-muted text-xs"},"Send a message to start a conversation",-1)),h("div",Ev,[(_(),w(be,null,qe(a,k=>h("button",{key:k,onClick:A=>l(k),class:"px-3 py-1.5 text-xs text-txt-secondary bg-surface-2/60 border border-edge rounded-full hover:border-accent/30 hover:text-accent hover:bg-accent/5 transition-all duration-200"},R(k),9,Tv)),64))])])):(_(),w("div",Av,[(_(!0),w(be,null,qe(Oe(e).messages,k=>(_(),w("div",{key:k.id,class:fe(["flex animate-fade-in",k.role==="user"?"justify-end":"justify-start"])},[k.role==="user"?(_(),w("div",Cv,R(k.content),1)):(_(),w("div",Rv,[y[4]||(y[4]=h("div",{class:"shrink-0 w-6 h-6 rounded-lg bg-surface-3/60 border border-edge flex items-center justify-center mt-0.5"},[h("span",{class:"text-accent text-[10px] font-bold font-mono"},"IO")],-1)),h("div",{class:"chat-md min-w-0 px-4 py-2.5 rounded-2xl rounded-tl-md text-sm bg-surface-2/70 text-txt-primary border border-edge",innerHTML:Oe(zn)(k.content)+(k.streaming?Dv:"")},null,8,Ov)]))],2))),128)),Oe(e).isLoading&&!u.value?(_(),w("div",$v,[...y[5]||(y[5]=[Dn('<div class="flex gap-2.5 items-start" data-v-f2ce91f6><div class="shrink-0 w-6 h-6 rounded-lg bg-surface-3/60 border border-edge flex items-center justify-center" data-v-f2ce91f6><span class="text-accent text-[10px] font-bold font-mono" data-v-f2ce91f6>IO</span></div><div class="px-4 py-3 rounded-2xl rounded-tl-md bg-surface-2/70 border border-edge flex items-center gap-1" data-v-f2ce91f6><span class="thinking-dot" style="animation-delay:0s;" data-v-f2ce91f6></span><span class="thinking-dot" style="animation-delay:0.15s;" data-v-f2ce91f6></span><span class="thinking-dot" style="animation-delay:0.3s;" data-v-f2ce91f6></span></div></div>',1)])])):Y("",!0)]))],544),He(yc,{name:"scroll-btn"},{default:xr(()=>[i.value?(_(),w("button",{key:0,onClick:f,class:"absolute bottom-24 left-1/2 -translate-x-1/2 z-10 w-8 h-8 rounded-full bg-surface-2/90 backdrop-blur-sm border border-edge-bright text-txt-secondary hover:text-accent hover:border-accent/40 hover:shadow-glow-sm flex items-center justify-center transition-all duration-200",title:"Scroll to bottom"},[...y[6]||(y[6]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-4 h-4",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[h("path",{d:"M4 6l4 4 4-4"})],-1)])])):Y("",!0)]),_:1}),h("div",Pv,[h("form",{onSubmit:Yt(b,["prevent"]),class:"max-w-3xl mx-auto flex gap-2 items-end"},[h("div",Iv,[lt(h("textarea",{ref_key:"inputEl",ref:o,"onUpdate:modelValue":y[0]||(y[0]=k=>s.value=k),placeholder:"Message IO…",disabled:Oe(e).isLoading,rows:"1",class:"w-full bg-surface-2/60 border border-edge rounded-xl px-4 py-2.5 pr-3 text-sm text-txt-primary placeholder-txt-muted/60 resize-none overflow-hidden focus:outline-none focus:border-accent/40 focus:shadow-glow-sm disabled:opacity-40 transition-all duration-200",onKeydown:p,onInput:m},null,40,jv),[[yt,s.value]])]),Oe(e).isLoading?(_(),w("button",{key:0,type:"button",onClick:c,disabled:r.value,class:"shrink-0 h-10 px-3.5 rounded-xl text-sm font-medium bg-red-500/15 text-red-400 border border-red-500/25 hover:bg-red-500/25 hover:border-red-500/40 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-150 flex items-center gap-1.5",title:"Stop"},[y[7]||(y[7]=h("span",{class:"w-2.5 h-2.5 rounded-[3px] bg-red-400"},null,-1)),h("span",Lv,R(r.value?"Stopping…":"Stop"),1)],8,Nv)):(_(),w("button",{key:1,type:"submit",disabled:!s.value.trim(),class:"shrink-0 w-10 h-10 rounded-xl flex items-center justify-center bg-accent/15 text-accent border border-accent/25 hover:bg-accent/25 hover:border-accent/40 hover:shadow-glow-sm disabled:opacity-25 disabled:cursor-not-allowed disabled:hover:shadow-none transition-all duration-150",title:"Send"},[...y[8]||(y[8]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor"},[h("path",{d:"M1.724 1.053a.5.5 0 0 1 .54-.068l12 6a.5.5 0 0 1 0 .894l-12 6A.5.5 0 0 1 1.5 13.5v-4.379l6.5-1.121-6.5-1.121V2.5a.5.5 0 0 1 .224-.447Z"})],-1)])],8,Uv))],32)])]))}}),Bv=Hr(Mv,[["__scopeId","data-v-f2ce91f6"]]),Hv={class:"flex flex-col h-full bg-surface-0"},Fv={key:0,class:"flex flex-col h-full overflow-hidden animate-fade-in"},Vv={class:"flex items-center gap-3 px-6 py-3.5 border-b border-edge shrink-0 bg-surface-1/60 backdrop-blur-sm"},qv={class:"text-base font-semibold text-txt-primary truncate"},Wv={class:"text-[11px] text-txt-muted font-mono shrink-0 bg-surface-2/60 px-1.5 py-0.5 rounded"},Kv={key:0,class:"flex-1 flex items-center justify-center"},Gv={key:1,class:"flex-1 p-6"},zv={class:"inline-flex items-center gap-2 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2"},Jv={key:2,class:"flex-1 overflow-y-auto p-6 skill-content text-sm text-txt-secondary leading-relaxed"},Yv={key:0,class:"mb-6 bg-surface-2/60 border border-edge rounded-xl p-5"},Xv={key:0,class:"mb-3"},Zv={class:"text-base font-semibold text-txt-primary"},Qv={key:1,class:"mb-3"},e0={class:"text-sm text-txt-secondary"},t0={class:"flex flex-wrap gap-6 mt-1"},s0={key:0},r0={class:"text-sm text-accent font-mono"},n0={key:1},i0={class:"text-sm text-txt-secondary"},o0={key:2,class:"mt-3 pt-3 border-t border-edge grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 items-baseline"},a0={class:"text-[10px] text-txt-muted uppercase tracking-wider whitespace-nowrap"},l0={class:"text-xs text-txt-secondary font-mono"},c0=["innerHTML"],u0={key:1,class:"flex-1 overflow-y-auto p-6"},d0={class:"max-w-3xl"},h0={class:"mb-6 bg-surface-2/40 border border-edge rounded-xl p-4"},f0={class:"flex gap-1 mb-3"},p0={class:"flex gap-2"},g0=["disabled"],m0=["disabled"],v0={class:"flex flex-col gap-2"},b0=["disabled"],y0=["disabled"],_0=["disabled"],w0={key:0,class:"flex items-center gap-2 bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 p-3 rounded-lg mb-4 text-sm animate-fade-in"},x0={key:1,class:"flex items-center gap-2 bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg mb-4 text-sm animate-fade-in"},k0={key:2,class:"mb-4"},S0={key:3,class:"flex items-center justify-center py-16"},E0={key:4,class:"flex items-center gap-2 bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg mb-4 text-sm"},T0={key:5,class:"text-txt-muted text-sm text-center py-16"},A0={key:6,class:"text-txt-muted text-sm text-center py-12"},C0={key:7,class:"grid gap-3"},R0=["onClick"],O0={class:"flex justify-between items-start mb-1.5"},$0={class:"min-w-0"},P0={class:"font-semibold text-txt-primary text-sm group-hover:text-accent transition-colors duration-150"},I0={class:"text-[11px] text-txt-muted font-mono mt-0.5"},j0=["onClick"],N0={class:"text-xs text-txt-secondary mb-2 line-clamp-2"},L0={class:"text-[10px] text-txt-muted font-mono truncate"},U0=gt({__name:"SkillsView",setup(t){const e=F([]),s=F(!0),r=F(null),n=F(""),i=F(!1),o=F(null),a=F(null),l=F("url"),c=F(""),u=F(""),d=F(!1),f=F(null),p=F(""),m=F(!1),b=F(null),x=$e(()=>xv(p.value)),y=$e(()=>x.value.frontmatter),k=$e(()=>zn(x.value.body)),A=["name","description","version","author"],L=$e(()=>y.value?Object.entries(y.value).filter(([q])=>!A.includes(q)):[]),N=F(""),$=$e(()=>{const q=N.value.toLowerCase().trim();return q?e.value.filter(O=>O.name.toLowerCase().includes(q)||O.slug.toLowerCase().includes(q)||(O.description??"").toLowerCase().includes(q)):e.value});async function E(q){f.value=q,p.value="",b.value=null,m.value=!0;try{const O=await ke(`/api/skills/${encodeURIComponent(q.slug)}`);if(O.status===404)b.value="Skill not found";else if(!O.ok)b.value=`Failed to load skill (HTTP ${O.status})`;else{const ce=await O.json();p.value=ce.content??""}}catch(O){b.value=O instanceof Error?O.message:"Failed to load skill"}finally{m.value=!1}}function M(){f.value=null,p.value="",b.value=null}async function B(){try{const q=await ke("/api/skills");if(!q.ok)throw new Error(`HTTP error! status: ${q.status}`);const O=await q.json();e.value=O.skills}catch(q){r.value=q instanceof Error?q.message:"Failed to load skills"}finally{s.value=!1}}async function te(){if(!(i.value||n.value.trim()==="")){i.value=!0,o.value=null,a.value=null;try{const q=await ke("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repoUrl:n.value.trim()})});if(q.ok){const O=await q.json();e.value=[O.skill,...e.value],n.value="",a.value=`✓ Installed: ${O.skill.name}`,setTimeout(()=>{a.value=null},4e3),B()}else{let O="Install failed";try{O=(await q.json()).error??q.statusText??O}catch{O=q.statusText||O}o.value=O}}catch(q){o.value=q instanceof Error?q.message:"Install failed"}finally{i.value=!1}}}async function de(){if(!(d.value||c.value.trim()===""||u.value.trim()==="")){d.value=!0,o.value=null,a.value=null;try{const q=await ke("/api/skills/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u.value.trim(),slug:c.value.trim()})});if(q.ok){const O=await q.json();e.value=[O.skill,...e.value],c.value="",u.value="",a.value=`✓ Installed: ${O.skill.name}`,setTimeout(()=>{a.value=null},4e3),B()}else{let O="Install failed";try{O=(await q.json()).error??q.statusText??O}catch{O=q.statusText||O}o.value=O}}catch(q){o.value=q instanceof Error?q.message:"Install failed"}finally{d.value=!1}}}async function V(q){if(confirm(`Delete skill "${q.name}"? This cannot be undone.`))try{const O=await ke(`/api/skills/${encodeURIComponent(q.slug)}`,{method:"DELETE"});if(O.ok)e.value=e.value.filter(ce=>ce.slug!==q.slug),a.value=`✓ Deleted: ${q.name}`,setTimeout(()=>{a.value=null},3e3);else{const ce=await O.json().catch(()=>({}));o.value=ce.error??(O.status===404?"Skill not found":`Delete failed (HTTP ${O.status})`)}}catch(O){o.value=O instanceof Error?O.message:"Delete failed"}}return ts(B),(q,O)=>(_(),w("div",Hv,[f.value?(_(),w("div",Fv,[h("div",Vv,[h("button",{onClick:M,class:"text-txt-muted hover:text-accent transition-colors flex items-center gap-1.5 text-sm group"},[...O[6]||(O[6]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-3.5 h-3.5 transition-transform group-hover:-translate-x-0.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[h("path",{d:"M10 3L5 8l5 5"})],-1),he(" Back ",-1)])]),O[7]||(O[7]=h("div",{class:"w-px h-5 bg-edge"},null,-1)),h("h2",qv,R(f.value.name),1),h("span",Wv,R(f.value.slug),1)]),m.value?(_(),w("div",Kv,[...O[8]||(O[8]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading… ")],-1)])])):b.value?(_(),w("div",Gv,[h("div",zv,[O[9]||(O[9]=h("span",null,"⚠",-1)),he(" "+R(b.value),1)])])):(_(),w("div",Jv,[y.value?(_(),w("div",Yv,[y.value.name?(_(),w("div",Xv,[O[10]||(O[10]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-widest mb-0.5"},"Name",-1)),h("p",Zv,R(y.value.name),1)])):Y("",!0),y.value.description?(_(),w("div",Qv,[O[11]||(O[11]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-widest mb-0.5"},"Description",-1)),h("p",e0,R(y.value.description),1)])):Y("",!0),h("div",t0,[y.value.version?(_(),w("div",s0,[O[12]||(O[12]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-widest mb-0.5"},"Version",-1)),h("p",r0,R(y.value.version),1)])):Y("",!0),y.value.author?(_(),w("div",n0,[O[13]||(O[13]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-widest mb-0.5"},"Author",-1)),h("p",i0,R(y.value.author),1)])):Y("",!0)]),L.value.length>0?(_(),w("dl",o0,[(_(!0),w(be,null,qe(L.value,([ce,ge])=>(_(),w(be,{key:ce},[h("dt",a0,R(ce),1),h("dd",l0,R(ge),1)],64))),128))])):Y("",!0)])):Y("",!0),h("div",{innerHTML:k.value},null,8,c0)]))])):(_(),w("div",u0,[h("div",d0,[O[20]||(O[20]=Dn('<div class="flex items-end justify-between mb-6" data-v-a63e75bb><div data-v-a63e75bb><h2 class="text-xl font-bold text-txt-primary tracking-tight" data-v-a63e75bb>Skills</h2><p class="text-xs text-txt-muted mt-0.5" data-v-a63e75bb>Manage installed Copilot skills</p></div><div class="flex items-center gap-2" data-v-a63e75bb><a href="https://github.com/github/awesome-copilot" target="_blank" rel="noopener noreferrer" class="flex items-center gap-1.5 text-xs text-txt-muted bg-surface-2/50 border border-edge px-2.5 py-1 rounded-full hover:border-accent/30 hover:text-accent transition-all duration-200" data-v-a63e75bb><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="w-3 h-3 fill-current" aria-hidden="true" data-v-a63e75bb><path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z" data-v-a63e75bb></path></svg> awesome-copilot </a><a href="https://skills.sh" target="_blank" rel="noopener noreferrer" class="flex items-center gap-1.5 text-xs text-txt-muted bg-surface-2/50 border border-edge px-2.5 py-1 rounded-full hover:border-accent/30 hover:text-accent transition-all duration-200" data-v-a63e75bb><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="w-3 h-3 fill-current" aria-hidden="true" data-v-a63e75bb><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8c0 .93.16 1.82.46 2.65L5 8.5V7H3.5l-.07.01A6.492 6.492 0 0 0 1.5 8Zm6.5 6.5c.93 0 1.82-.17 2.65-.47L8.5 11H7v2.5c.17.01.33.01.5.01Zm-5.3-1.7c.56.4 1.19.7 1.87.88L5 11H3.5c.34.66.79 1.25 1.2 1.8ZM8.5 1.5V4H10l2.5 2.5c.02-.16.03-.33.03-.5A6.5 6.5 0 0 0 8.5 1.5Zm-1 0A6.5 6.5 0 0 0 1.97 6H3.5L6 3.5V1.53c-.51.1-1 .26-1.5.46V1.5ZM11 8.5l-2.5 2.5H10l1.88-1.88A6.47 6.47 0 0 0 11 8.5ZM6 6v4h4V6H6Z" data-v-a63e75bb></path></svg> skills.sh </a></div></div>',1)),h("div",h0,[h("div",f0,[h("button",{type:"button",onClick:O[0]||(O[0]=ce=>l.value="url"),class:fe(["px-3 py-1.5 text-xs font-medium rounded-lg transition-all duration-150",l.value==="url"?"bg-accent/10 text-accent border border-accent/20":"text-txt-muted hover:text-txt-secondary hover:bg-surface-3/40 border border-transparent"])}," From URL ",2),h("button",{type:"button",onClick:O[1]||(O[1]=ce=>l.value="paste"),class:fe(["px-3 py-1.5 text-xs font-medium rounded-lg transition-all duration-150",l.value==="paste"?"bg-accent/10 text-accent border border-accent/20":"text-txt-muted hover:text-txt-secondary hover:bg-surface-3/40 border border-transparent"])}," Paste SKILL.md ",2)]),l.value==="url"?(_(),w("form",{key:0,onSubmit:Yt(te,["prevent"])},[h("div",p0,[lt(h("input",{"onUpdate:modelValue":O[2]||(O[2]=ce=>n.value=ce),type:"url",placeholder:"https://github.com/owner/repo.git","aria-label":"Git repository URL",disabled:i.value,class:"flex-1 bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm disabled:opacity-40 transition-all duration-200"},null,8,g0),[[yt,n.value]]),h("button",{type:"submit",disabled:i.value||n.value.trim()==="",class:"bg-accent/15 text-accent border border-accent/25 px-4 py-2 rounded-lg text-sm font-medium hover:bg-accent/25 hover:border-accent/40 disabled:opacity-30 disabled:cursor-not-allowed transition-all duration-150 whitespace-nowrap"},R(i.value?"Installing…":"Install"),9,m0)])],32)):(_(),w("form",{key:1,onSubmit:Yt(de,["prevent"])},[h("div",v0,[h("div",null,[lt(h("input",{"onUpdate:modelValue":O[3]||(O[3]=ce=>c.value=ce),type:"text",placeholder:"my-skill","aria-label":"Skill slug",disabled:d.value,class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm disabled:opacity-40 transition-all duration-200"},null,8,b0),[[yt,c.value]]),O[14]||(O[14]=h("p",{class:"text-[10px] text-txt-muted mt-1 ml-1"},"Unique identifier (lowercase, hyphens ok)",-1))]),lt(h("textarea",{"onUpdate:modelValue":O[4]||(O[4]=ce=>u.value=ce),placeholder:"Paste SKILL.md content here…","aria-label":"SKILL.md content",disabled:d.value,rows:"6",class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary font-mono placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm disabled:opacity-40 resize-y transition-all duration-200"},null,8,y0),[[yt,u.value]]),h("button",{type:"submit",disabled:d.value||c.value.trim()===""||u.value.trim()==="",class:"self-end bg-accent/15 text-accent border border-accent/25 px-4 py-2 rounded-lg text-sm font-medium hover:bg-accent/25 hover:border-accent/40 disabled:opacity-30 disabled:cursor-not-allowed transition-all duration-150"},R(d.value?"Installing…":"Install"),9,_0)])],32))]),a.value?(_(),w("div",w0,[O[15]||(O[15]=h("span",null,"✓",-1)),he(" "+R(a.value),1)])):Y("",!0),o.value?(_(),w("div",x0,[O[16]||(O[16]=h("span",null,"⚠",-1)),he(" "+R(o.value),1)])):Y("",!0),!s.value&&!r.value&&e.value.length>0?(_(),w("div",k0,[lt(h("input",{"onUpdate:modelValue":O[5]||(O[5]=ce=>N.value=ce),type:"search",placeholder:"Search skills…","aria-label":"Search skills",class:"w-full bg-surface-2/50 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,N.value]])])):Y("",!0),s.value?(_(),w("div",S0,[...O[17]||(O[17]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading skills… ")],-1)])])):r.value?(_(),w("div",E0,[O[18]||(O[18]=h("span",null,"⚠",-1)),he(" "+R(r.value),1)])):e.value.length===0?(_(),w("div",T0," No skills installed yet ")):$.value.length===0?(_(),w("div",A0," No matching skills ")):(_(),w("div",C0,[(_(!0),w(be,null,qe($.value,ce=>(_(),w("div",{key:ce.slug,onClick:ge=>E(ce),class:"group bg-surface-2/40 border border-edge rounded-xl p-4 hover:border-edge-bright hover:shadow-card-hover hover:bg-surface-2/70 transition-all duration-200 cursor-pointer"},[h("div",O0,[h("div",$0,[h("h3",P0,R(ce.name),1),h("p",I0,R(ce.slug),1)]),h("button",{onClick:Yt(ge=>V(ce),["stop"]),class:"shrink-0 ml-2 p-1.5 rounded-lg text-txt-muted/0 group-hover:text-txt-muted hover:!text-red-400 hover:bg-red-500/10 transition-all duration-150",title:"Delete skill"},[...O[19]||(O[19]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"},[h("path",{d:"M2 4h12M5.333 4V2.667a1.333 1.333 0 011.334-1.334h2.666a1.333 1.333 0 011.334 1.334V4m2 0v9.333a1.333 1.333 0 01-1.334 1.334H4.667a1.333 1.333 0 01-1.334-1.334V4h9.334z"})],-1)])],8,j0)]),h("p",N0,R(ce.description),1),h("p",L0,R(ce.path),1)],8,R0))),128))]))])]))]))}}),D0=Hr(U0,[["__scopeId","data-v-a63e75bb"]]),M0={class:"flex flex-col h-full bg-surface-0"},B0={class:"flex-1 overflow-y-auto p-6"},H0={class:"max-w-4xl"},F0={class:"flex justify-between items-end mb-6"},V0={class:"space-y-3"},q0=["disabled"],W0={key:0,class:"mt-3 flex items-center gap-2 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2"},K0={key:1,class:"flex items-center justify-center py-16"},G0={key:2,class:"flex items-center gap-2 bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg mb-4 text-sm"},z0={key:3,class:"text-txt-muted text-sm text-center py-16"},J0={key:4,class:"grid gap-3"},Y0=["onClick","aria-expanded"],X0={class:"flex justify-between items-start mb-2"},Z0={class:"flex-1 flex items-center gap-2.5"},Q0={class:"min-w-0"},eb={class:"font-semibold text-txt-primary text-sm"},tb={class:"text-[11px] text-txt-muted font-mono"},sb={class:"flex items-center gap-2 shrink-0"},rb={key:0,class:"px-2 py-0.5 rounded-md text-[10px] font-medium bg-purple-500/10 text-purple-300 border border-purple-500/20"},nb={class:"text-xs text-txt-muted font-mono ml-6"},ib={key:0,class:"border-t border-edge px-4 pb-4 pt-3 animate-fade-in"},ob={class:"flex justify-between items-center text-[10px] text-txt-muted mb-3"},ab={key:0,class:"font-mono"},lb={key:0,class:"flex items-center gap-2 text-txt-muted text-xs py-3"},cb={key:1,class:"text-red-400 text-xs py-2"},ub={key:2,class:"text-txt-muted text-xs italic py-2"},db={key:3,class:"space-y-1.5"},hb={class:"flex-1 min-w-0"},fb={class:"flex items-center gap-1.5"},pb={class:"text-sm font-medium text-txt-primary truncate"},gb={key:0,title:"Team Lead",class:"text-xs"},mb={key:1,title:"QA / Veto Power",class:"text-xs"},vb={class:"text-[10px] text-txt-muted"},bb={class:"flex items-center gap-1 shrink-0"},yb=["onClick"],_b=["onClick","disabled"],wb={class:"bg-surface-1 border border-edge rounded-xl w-full max-w-2xl max-h-[85vh] flex flex-col shadow-2xl animate-fade-in"},xb={class:"flex justify-between items-center px-5 py-3.5 border-b border-edge"},kb={class:"text-sm font-semibold text-txt-primary flex items-center gap-2"},Sb={class:"text-xs font-normal text-txt-muted"},Eb={class:"text-[10px] text-txt-muted mt-0.5 flex items-center gap-1.5"},Tb={class:"flex items-center gap-3"},Ab={class:"flex items-center gap-1.5 text-[10px] text-txt-muted cursor-pointer select-none"},Cb={key:0,class:"bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg text-sm"},Rb={key:1,class:"text-txt-muted italic text-center py-8"},Ob={class:"shrink-0"},$b={class:"flex-1 min-w-0"},Pb={class:"text-txt-secondary break-words"},Ib={class:"text-txt-muted text-[10px] ml-2"},jb={key:0,class:"text-txt-muted italic text-center py-4"},Nb={class:"flex justify-between items-center mb-1"},Lb={class:"text-accent"},Ub={class:"text-txt-muted text-[10px]"},Db={class:"text-txt-secondary whitespace-pre-wrap break-words"},Mb=gt({__name:"SquadsView",setup(t){const e=new Set(["system"]),s={"a-team":"The A-Team",transformers:"Transformers",thundercats:"ThunderCats","gi-joe":"G.I. Joe",aliens:"Aliens",ghostbusters:"Ghostbusters"},r=F([]),n=F(!0),i=F(null),o=F(!1),a=F(!1),l=F(null),c=zt({}),u=zt({});function d(T){return[...T].sort((C,K)=>{const le=Le=>Le.is_lead?0:Le.is_qa?1:2;return le(C)-le(K)})}const f=zt({}),p=zt({}),m=F(new Set),b=F(null),x=F([]),y=F(null),k=F(!1),A=F(!0),L=F(null);let N=null;const $=$e(()=>y.value?"Disconnected":k.value?"Live":"Connecting…"),E=$e(()=>x.value.filter(T=>!(!T.summary||e.has(T.summary.kind)||T.type==="assistant.message_delta"))),M=T=>{try{return new Date(T).toLocaleTimeString()}catch{return""}},B=T=>{const C=T.data;if(!C||typeof C!="object")return"";if(typeof C.deltaContent=="string")return C.deltaContent;if(typeof C.content=="string")return C.content;if(typeof C.text=="string")return C.text;try{return JSON.stringify(C,null,2)}catch{return String(C)}},te=()=>{Es(()=>{const T=L.value;T&&(T.scrollTop=T.scrollHeight)})},de=T=>{if(!T.currentTaskId)return;V(),b.value=T,x.value=[],y.value=null,k.value=!1,A.value=!0;const C=Gn(`/api/tasks/${encodeURIComponent(T.currentTaskId)}/events`),K=new EventSource(C);N=K,K.onopen=()=>{k.value=!0},K.onmessage=le=>{try{const Le=JSON.parse(le.data);x.value.push(Le),te()}catch{}},K.onerror=()=>{k.value=!1,x.value.length===0&&(y.value="Connection error. Retrying…")}},V=()=>{if(N){try{N.close()}catch{}N=null}b.value=null,x.value=[],y.value=null,k.value=!1};io(()=>{V()});const q=async(T,C)=>{if(!m.value.has(C)){m.value=new Set(m.value).add(C);try{await ke(`/api/tasks/${encodeURIComponent(C)}/cancel`,{method:"POST"}),await We(T,!0)}catch(K){p[T]=K instanceof Error?K.message:"Failed to stop task"}finally{const K=new Set(m.value);K.delete(C),m.value=K}}},O=F({slug:"",name:"",projectPath:""}),ce=T=>T?s[T]??T:"",ge=T=>new Date(T).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),ie=T=>!!c[T],me=async T=>{c[T]=!c[T],c[T]&&!u[T]&&!f[T]&&await We(T)},We=async(T,C=!1)=>{if(!(!C&&f[T])){f[T]=!0,p[T]=null;try{const K=await ke(`/api/squads/${encodeURIComponent(T)}/agents`);if(!K.ok)throw new Error(`HTTP error! status: ${K.status}`);const le=await K.json();u[T]=le.agents}catch(K){p[T]=K instanceof Error?K.message:"Failed to load agents"}finally{f[T]=!1}}},Xe=async()=>{try{const T=await ke("/api/squads");if(!T.ok)throw new Error(`HTTP error! status: ${T.status}`);const C=await T.json();r.value=C.squads}catch(T){i.value=T instanceof Error?T.message:"Failed to load squads"}finally{n.value=!1}},H=async()=>{if(!O.value.slug||!O.value.name||!O.value.projectPath){l.value="All fields are required";return}a.value=!0,l.value=null;try{const T=await ke("/api/squads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:O.value.slug,name:O.value.name,projectPath:O.value.projectPath})});if(!T.ok)throw new Error(`HTTP error! status: ${T.status}`);O.value={slug:"",name:"",projectPath:""},o.value=!1,await Xe()}catch(T){l.value=T instanceof Error?T.message:"Failed to create squad"}finally{a.value=!1}};return ts(()=>{Xe()}),(T,C)=>(_(),w("div",M0,[h("div",B0,[h("div",H0,[h("div",F0,[C[5]||(C[5]=h("div",null,[h("h2",{class:"text-xl font-bold text-txt-primary tracking-tight"},"Squads"),h("p",{class:"text-xs text-txt-muted mt-0.5"},"Manage teams and monitor agents")],-1)),h("button",{onClick:C[0]||(C[0]=K=>o.value=!o.value),class:fe(["px-3.5 py-2 rounded-lg text-sm font-medium transition-all duration-150",o.value?"bg-surface-3/50 text-txt-secondary border border-edge hover:bg-surface-3/70":"bg-accent/15 text-accent border border-accent/25 hover:bg-accent/25 hover:border-accent/40"])},R(o.value?"Cancel":"New Squad"),3)]),o.value?(_(),w("form",{key:0,onSubmit:Yt(H,["prevent"]),class:"bg-surface-2/40 border border-edge rounded-xl p-5 mb-6 animate-fade-in"},[C[7]||(C[7]=h("h3",{class:"font-semibold text-txt-primary text-sm mb-4"},"Create New Squad",-1)),h("div",V0,[lt(h("input",{"onUpdate:modelValue":C[1]||(C[1]=K=>O.value.slug=K),type:"text",placeholder:"Squad slug (e.g., frontend-team)",class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,O.value.slug]]),lt(h("input",{"onUpdate:modelValue":C[2]||(C[2]=K=>O.value.name=K),type:"text",placeholder:"Squad name (e.g., Frontend Team)",class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,O.value.name]]),lt(h("input",{"onUpdate:modelValue":C[3]||(C[3]=K=>O.value.projectPath=K),type:"text",placeholder:"Project path (e.g., /path/to/project)",class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,O.value.projectPath]]),h("button",{type:"submit",disabled:a.value||!O.value.slug||!O.value.name||!O.value.projectPath,class:"w-full bg-accent/15 text-accent border border-accent/25 px-4 py-2 rounded-lg text-sm font-medium hover:bg-accent/25 hover:border-accent/40 disabled:opacity-30 disabled:cursor-not-allowed transition-all duration-150"},R(a.value?"Creating…":"Create Squad"),9,q0)]),l.value?(_(),w("div",W0,[C[6]||(C[6]=h("span",null,"⚠",-1)),he(" "+R(l.value),1)])):Y("",!0)],32)):Y("",!0),n.value?(_(),w("div",K0,[...C[8]||(C[8]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading squads… ")],-1)])])):i.value?(_(),w("div",G0,[C[9]||(C[9]=h("span",null,"⚠",-1)),he(" "+R(i.value),1)])):r.value.length===0?(_(),w("div",z0," No squads created yet ")):(_(),w("div",J0,[(_(!0),w(be,null,qe(r.value,K=>(_(),w("div",{key:K.id,class:"bg-surface-2/40 border border-edge rounded-xl overflow-hidden hover:border-edge-bright transition-all duration-200"},[h("button",{type:"button",onClick:le=>me(K.slug),class:"w-full text-left p-4 focus:outline-none","aria-expanded":ie(K.slug)},[h("div",X0,[h("div",Z0,[(_(),w("svg",{xmlns:"http://www.w3.org/2000/svg",class:fe(["w-3.5 h-3.5 text-txt-muted transition-transform duration-200 shrink-0",ie(K.slug)?"rotate-90":""]),viewBox:"0 0 16 16",fill:"currentColor"},[...C[10]||(C[10]=[h("path",{d:"M6 3l5 5-5 5z"},null,-1)])],2)),h("div",Q0,[h("h3",eb,R(K.name),1),h("p",tb,R(K.slug),1)])]),h("div",sb,[K.universe?(_(),w("span",rb," 🎬 "+R(ce(K.universe)),1)):Y("",!0),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium",K.status==="working"?"bg-accent/10 text-accent border border-accent/20":K.status==="error"?"bg-red-500/10 text-red-400 border border-red-500/20":"bg-surface-3/60 text-txt-muted border border-edge"])},[h("span",{class:fe(["w-1.5 h-1.5 rounded-full",K.status==="working"?"bg-accent animate-pulse":K.status==="error"?"bg-red-400":"bg-txt-muted/50"])},null,2),he(" "+R(K.status),1)],2)])]),h("p",nb,"📁 "+R(K.project_path),1)],8,Y0),ie(K.slug)?(_(),w("div",ib,[h("div",ob,[K.model?(_(),w("span",ab,"Model: "+R(K.model),1)):Y("",!0),h("span",null,R(ge(K.created_at)),1)]),C[14]||(C[14]=h("h4",{class:"text-xs font-semibold text-txt-secondary uppercase tracking-wider mb-2"},"Team Roster",-1)),f[K.slug]?(_(),w("div",lb,[...C[11]||(C[11]=[h("span",{class:"w-3 h-3 border-2 border-edge border-t-accent rounded-full animate-spin"},null,-1),he(" Loading agents… ",-1)])])):p[K.slug]?(_(),w("div",cb,R(p[K.slug]),1)):!u[K.slug]||u[K.slug].length===0?(_(),w("div",ub," No agents assigned yet ")):(_(),w("ul",db,[(_(!0),w(be,null,qe(d(u[K.slug]??[]),le=>(_(),w("li",{key:le.id??le.character_name,class:fe(["flex items-center gap-3 rounded-lg px-3 py-2 transition-all duration-150",le.status==="working"?"bg-accent/[0.06] border border-accent/15":"bg-surface-1/50 border border-edge"])},[h("div",{class:fe(["w-7 h-7 rounded-full flex items-center justify-center shrink-0 text-[10px] font-bold",le.status==="working"?"bg-accent/15 text-accent border border-accent/25":le.status==="error"?"bg-red-500/15 text-red-400 border border-red-500/25":"bg-surface-3/60 text-txt-muted border border-edge"])},R((le.character_name??"?").charAt(0).toUpperCase()),3),h("div",hb,[h("div",fb,[h("span",pb,R(le.character_name),1),le.is_lead?(_(),w("span",gb,"👑")):Y("",!0),le.is_qa?(_(),w("span",mb,"🛡️")):Y("",!0)]),h("span",vb,R(le.role_title),1)]),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0",le.status==="working"?"bg-accent/10 text-accent":le.status==="error"?"bg-red-500/10 text-red-400":"bg-surface-3/40 text-txt-muted"])},[h("span",{class:fe(["w-1.5 h-1.5 rounded-full",le.status==="working"?"bg-accent animate-pulse":le.status==="error"?"bg-red-400":"bg-emerald-400"])},null,2),he(" "+R(le.status),1)],2),h("div",bb,[le.status==="working"&&le.currentTaskId?(_(),w("button",{key:0,type:"button",onClick:Le=>de(le),class:"text-[10px] font-medium px-2 py-1 rounded-md bg-accent/10 text-accent border border-accent/20 hover:bg-accent/20 transition-all duration-150 flex items-center gap-1",title:"Preview live work"},[...C[12]||(C[12]=[h("span",{"aria-hidden":"true"},"👁",-1),he(" Preview ",-1)])],8,yb)):Y("",!0),le.status==="working"&&le.currentTaskId?(_(),w("button",{key:1,type:"button",onClick:Le=>q(K.slug,le.currentTaskId),disabled:m.value.has(le.currentTaskId),class:"text-[10px] font-medium px-2 py-1 rounded-md bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 disabled:opacity-40 transition-all duration-150 flex items-center gap-1",title:"Stop task"},[C[13]||(C[13]=h("span",{class:"w-2 h-2 rounded-[2px] bg-red-400"},null,-1)),he(" "+R(m.value.has(le.currentTaskId)?"Stopping…":"Stop"),1)],8,_b)):Y("",!0)])],2))),128))]))])):Y("",!0)]))),128))]))])]),b.value?(_(),w("div",{key:0,class:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4 z-50",onClick:Yt(V,["self"])},[h("div",wb,[h("div",xb,[h("div",null,[h("h3",kb,[he(R(b.value.character_name)+" ",1),h("span",Sb,"— "+R(b.value.role_title),1)]),h("p",Eb,[h("span",{class:fe(["inline-block w-1.5 h-1.5 rounded-full",k.value?"bg-emerald-400 animate-pulse":"bg-txt-muted/50"])},null,2),he(" "+R($.value),1)])]),h("div",Tb,[h("label",Ab,[lt(h("input",{type:"checkbox","onUpdate:modelValue":C[4]||(C[4]=K=>A.value=K),class:"rounded bg-surface-3 border-edge accent-accent"},null,512),[[_c,A.value]]),C[15]||(C[15]=he(" Summary ",-1))]),h("button",{type:"button",onClick:V,class:"text-txt-muted hover:text-txt-primary text-lg leading-none transition-colors p-1","aria-label":"Close"},"×")])]),h("div",{ref_key:"previewScrollEl",ref:L,class:"overflow-y-auto p-4 space-y-2 flex-1 font-mono text-xs"},[y.value?(_(),w("div",Cb,R(y.value),1)):x.value.length===0?(_(),w("div",Rb," Waiting for activity… ")):A.value?(_(),w(be,{key:2},[(_(!0),w(be,null,qe(E.value,(K,le)=>(_(),w("div",{key:le,class:"flex items-start gap-2 py-1.5 px-1"},[h("span",Ob,R(K.summary.icon),1),h("div",$b,[h("span",Pb,R(K.summary.summary),1),h("span",Ib,R(M(K.ts)),1)])]))),128)),E.value.length===0?(_(),w("div",jb," Processing… ")):Y("",!0)],64)):(_(!0),w(be,{key:3},qe(x.value,(K,le)=>(_(),w("div",{key:le,class:"border border-edge rounded-lg p-2.5 bg-surface-0"},[h("div",Nb,[h("span",Lb,R(K.type),1),h("span",Ub,R(M(K.ts)),1)]),h("pre",Db,R(B(K)),1)]))),128))],512),h("div",{class:"px-4 py-3 border-t border-edge flex justify-end"},[h("button",{type:"button",onClick:V,class:"bg-surface-3/50 hover:bg-surface-3/70 text-txt-secondary text-sm px-4 py-1.5 rounded-lg border border-edge transition-all duration-150"}," Close ")])])])):Y("",!0)]))}}),Bb={class:"flex flex-col h-full bg-surface-0"},Hb={class:"flex-1 overflow-y-auto p-6"},Fb={class:"max-w-4xl"},Vb={class:"flex justify-between items-end mb-6"},qb=["disabled"],Wb={key:0,class:"flex items-center gap-2 bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg mb-6 text-sm"},Kb={class:"mb-8"},Gb={key:0,class:"flex items-center justify-center py-10"},zb={key:1,class:"text-txt-muted text-sm text-center py-10"},Jb={key:2,class:"grid gap-3"},Yb={class:"flex justify-between items-start mb-2.5"},Xb={class:"flex items-center gap-3 min-w-0"},Zb={class:"min-w-0"},Qb={class:"font-semibold text-txt-primary text-sm"},ey={class:"flex items-center gap-1.5 mt-0.5 flex-wrap"},ty={class:"text-[10px] text-txt-muted font-mono"},sy={key:0,class:"text-[10px] text-txt-secondary bg-surface-3/50 px-1.5 py-0.5 rounded border border-edge"},ry={key:1,class:"text-[10px] text-purple-300 bg-purple-500/10 px-1.5 py-0.5 rounded border border-purple-500/20"},ny=["title"],iy={key:0,class:"bg-surface-0/60 border border-edge rounded-lg p-3 mb-2.5 ml-12"},oy={class:"text-sm text-txt-primary break-words"},ay={class:"flex justify-between items-center ml-12"},ly={class:"text-[10px] text-txt-muted"},cy=["onClick","disabled"],uy={key:0,class:"flex items-center justify-center py-10"},dy={key:1,class:"text-txt-muted text-sm text-center py-10"},hy={key:2,class:"relative"},fy={class:"space-y-1"},py=["onClick"],gy={class:"flex justify-between items-start gap-3"},my={class:"min-w-0 flex-1"},vy={class:"flex items-center gap-2 mb-0.5"},by={class:"text-sm font-medium text-txt-primary truncate group-hover:text-accent transition-colors"},yy={key:0,class:"text-[10px] text-txt-muted bg-surface-3/40 px-1.5 py-0.5 rounded border border-edge"},_y={class:"text-xs text-txt-secondary truncate"},wy={class:"text-[10px] text-txt-muted mt-1"},xy={key:0},ky={key:0,class:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse"},Sy={class:"bg-surface-1 border border-edge rounded-xl w-full max-w-2xl max-h-[85vh] flex flex-col shadow-2xl animate-fade-in"},Ey={class:"overflow-y-auto p-5 space-y-4"},Ty={key:0,class:"flex items-center justify-center py-10"},Ay={key:1,class:"bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg text-sm"},Cy={class:"flex justify-between items-start gap-3"},Ry={class:"text-sm text-txt-primary font-medium"},Oy={key:0,class:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse"},$y={class:"text-[11px] text-txt-muted font-mono break-all bg-surface-0/60 px-2 py-1 rounded border border-edge"},Py={key:0},Iy={class:"text-sm text-txt-secondary"},jy={class:"grid grid-cols-2 gap-4"},Ny={class:"text-sm text-txt-secondary"},Ly={class:"text-sm text-txt-secondary"},Uy={key:1},Dy={class:"text-sm text-accent font-mono"},My={class:"text-sm text-txt-primary bg-surface-0/60 border border-edge rounded-lg p-3 whitespace-pre-wrap break-words font-sans"},By={class:"flex justify-between items-center mb-2"},Hy={class:"flex items-center gap-1.5 text-[10px] text-txt-muted cursor-pointer select-none"},Fy={key:0,class:"text-sm text-txt-muted italic"},Vy={key:1,class:"text-sm text-txt-muted italic"},qy={key:2,class:"bg-surface-0/60 border border-edge rounded-lg divide-y divide-edge max-h-96 overflow-y-auto"},Wy=["onClick"],Ky={class:"shrink-0"},Gy={class:"flex-1 break-words"},zy={class:"text-[10px] text-txt-muted shrink-0"},Jy={key:0,class:"mt-2 pl-6 space-y-1"},Yy={key:0,class:"text-xs text-txt-secondary bg-surface-1 border border-edge rounded-lg p-2 whitespace-pre-wrap break-words font-mono"},Xy={class:"text-[11px] text-txt-muted bg-surface-1 border border-edge rounded-lg p-2 whitespace-pre-wrap break-words font-mono max-h-48 overflow-y-auto"},Zy={class:"text-[10px] text-txt-muted font-mono"},Qy={key:0,class:"text-sm text-txt-primary bg-surface-0/60 border border-edge rounded-lg p-3 whitespace-pre-wrap break-words font-mono max-h-96 overflow-y-auto"},e_={key:1,class:"text-sm text-txt-muted italic"},t_={class:"px-5 py-3 border-t border-edge flex justify-between items-center"},s_=["disabled"],r_={key:1},n_=gt({__name:"AgentActivityView",setup(t){const e=F([]),s=F([]),r=F(!0),n=F(null),i=F(new Set),o=F(null),a=F(null),l=F(!1),c=F(null),u=F([]),d=F(!1),f=F(!1),p=F(new Set);let m=null,b=null,x=null;const y=H=>H.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),k=H=>{if(!H)return"";const T=H.includes("T")?H:H.replace(" ","T")+"Z",C=new Date(T);return Number.isNaN(C.getTime())?H:C.toLocaleString()},A=H=>{switch(H){case"running":return"bg-accent/10 text-accent border border-accent/20";case"done":return"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20";case"failed":return"bg-red-500/10 text-red-400 border border-red-500/20";case"cancelled":return"bg-amber-500/10 text-amber-400 border border-amber-500/20";default:return"bg-surface-3/50 text-txt-muted border border-edge"}},L=$e(()=>{if(!a.value)return null;const H=a.value.started_at,T=a.value.completed_at;if(!H||!T)return null;const C=new Date(H.includes("T")?H:H.replace(" ","T")+"Z").getTime(),K=new Date(T.includes("T")?T:T.replace(" ","T")+"Z").getTime();if(Number.isNaN(C)||Number.isNaN(K))return null;const le=Math.max(0,Math.round((K-C)/1e3));if(le<60)return`${le}s`;const Le=Math.floor(le/60),I=le%60;return`${Le}m ${I}s`}),N=async H=>{if(!i.value.has(H)){i.value=new Set(i.value).add(H);try{await ke(`/api/tasks/${encodeURIComponent(H)}/cancel`,{method:"POST"}),await M(),o.value===H&&await B(H)}catch(T){n.value=T instanceof Error?T.message:"Failed to stop task"}finally{const T=new Set(i.value);T.delete(H),i.value=T}}},$=async()=>{try{const H=await ke("/api/agents");if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);const T=await H.json();e.value=T.agents}catch(H){n.value=H instanceof Error?H.message:"Failed to load agents"}},E=async()=>{try{const H=await ke("/api/tasks?limit=50");if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);const T=await H.json();s.value=T.tasks}catch(H){n.value=H instanceof Error?H.message:"Failed to load tasks"}},M=async()=>{r.value=!0,n.value=null;try{await Promise.all([$(),E()])}finally{r.value=!1}},B=async H=>{l.value=!0,c.value=null;try{const T=await ke(`/api/tasks/${encodeURIComponent(H)}`);if(!T.ok)throw new Error(`HTTP error! status: ${T.status}`);const C=await T.json();a.value=C.task}catch(T){c.value=T instanceof Error?T.message:"Failed to load task",a.value=null}finally{l.value=!1}},te=H=>{if(!H)return"";const T=new Date(H);return Number.isNaN(T.getTime())?"":T.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})},de=H=>{try{return JSON.stringify(H,null,2)}catch{return String(H)}},V=H=>{if(H.status==="success")return"text-emerald-300";if(H.status==="error")return"text-red-300";if(H.status==="pending")return"text-accent";switch(H.kind){case"message":return"text-txt-primary";case"reasoning":return"text-purple-300";case"tool":return"text-blue-300";case"outcome":return"text-amber-300";default:return"text-txt-secondary"}},q=H=>{if(f.value)return;const T=new Set(p.value);T.has(H)?T.delete(H):T.add(H),p.value=T},O=async(H,T={})=>{T.initial&&(d.value=!0);try{const C=await ke(`/api/tasks/${encodeURIComponent(H)}/activity`);if(!C.ok)return;const K=await C.json();u.value=K.activity??[]}catch{}finally{T.initial&&(d.value=!1)}},ce=H=>{b||(b=setTimeout(()=>{b=null,o.value===H&&O(H)},250))},ge=H=>{ie(),O(H,{initial:!0});try{m=new EventSource(Gn(`/api/tasks/${encodeURIComponent(H)}/events`)),m.onmessage=()=>{ce(H)},m.onerror=()=>{}}catch{m=null}},ie=()=>{m&&(m.close(),m=null),b&&(clearTimeout(b),b=null)},me=H=>{o.value=H,a.value=null,u.value=[],p.value=new Set,B(H),ge(H)},We=()=>{o.value=null,a.value=null,c.value=null,u.value=[],p.value=new Set,ie()},Xe=H=>{H.key==="Escape"&&o.value&&We()};return us(o,H=>{H?document.addEventListener("keydown",Xe):document.removeEventListener("keydown",Xe)}),ts(()=>{M(),x=setInterval(M,5e3)}),us(()=>{var H;return(H=a.value)==null?void 0:H.status},H=>{H&&H!=="running"&&(o.value&&O(o.value),ie())}),Nn(()=>{x&&clearInterval(x),document.removeEventListener("keydown",Xe),ie()}),(H,T)=>(_(),w("div",Bb,[h("div",Hb,[h("div",Fb,[h("div",Vb,[T[2]||(T[2]=h("div",null,[h("h2",{class:"text-xl font-bold text-txt-primary tracking-tight"},"Activity"),h("p",{class:"text-xs text-txt-muted mt-0.5"},"Monitor agents and recent tasks")],-1)),h("button",{onClick:M,disabled:r.value,class:"px-3.5 py-2 rounded-lg text-sm font-medium transition-all duration-150 bg-accent/15 text-accent border border-accent/25 hover:bg-accent/25 hover:border-accent/40 disabled:opacity-30 disabled:cursor-not-allowed"},R(r.value?"Refreshing…":"Refresh"),9,qb)]),n.value?(_(),w("div",Wb,[T[3]||(T[3]=h("span",null,"⚠",-1)),he(" "+R(n.value),1)])):Y("",!0),h("section",Kb,[T[7]||(T[7]=h("h3",{class:"text-xs font-semibold text-txt-secondary uppercase tracking-wider mb-3"},"Active Agents",-1)),r.value&&e.value.length===0?(_(),w("div",Gb,[...T[4]||(T[4]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading agents… ")],-1)])])):e.value.length===0?(_(),w("div",zb," No active agents ")):(_(),w("div",Jb,[(_(!0),w(be,null,qe(e.value,C=>(_(),w("div",{key:C.slug+(C.characterName||""),class:fe(["group bg-surface-2/40 border rounded-xl p-4 transition-all duration-200",C.status==="working"?"border-accent/20 hover:border-accent/35":"border-edge hover:border-edge-bright"])},[h("div",Yb,[h("div",Xb,[h("div",{class:fe(["w-9 h-9 rounded-xl flex items-center justify-center shrink-0 text-xs font-bold",C.status==="working"?"bg-accent/15 text-accent border border-accent/25":C.status==="error"?"bg-red-500/15 text-red-400 border border-red-500/25":"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20"])},R((C.name??"?").charAt(0).toUpperCase()),3),h("div",Zb,[h("h3",Qb,R(C.name),1),h("div",ey,[h("span",ty,R(C.slug),1),C.roleTitle?(_(),w("span",sy,R(C.roleTitle),1)):Y("",!0),C.universe?(_(),w("span",ry," 🎬 "+R(C.universe),1)):Y("",!0),C.model&&C.status==="working"?(_(),w("span",{key:2,class:"text-[10px] text-emerald-300 bg-emerald-500/10 px-1.5 py-0.5 rounded border border-emerald-500/20",title:`Model: ${C.model}`}," 🧠 "+R(C.model),9,ny)):Y("",!0)])])]),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0",C.status==="working"?"bg-accent/10 text-accent border border-accent/20":C.status==="error"?"bg-red-500/10 text-red-400 border border-red-500/20":"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20"])},[h("span",{class:fe(["w-1.5 h-1.5 rounded-full",C.status==="working"?"bg-accent animate-pulse":C.status==="error"?"bg-red-400":"bg-emerald-400"])},null,2),he(" "+R(C.status==="working"?"Working":C.status==="error"?"Error":"Idle"),1)],2)]),C.currentTask?(_(),w("div",iy,[T[5]||(T[5]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-wider mb-1"},"Current Task",-1)),h("p",oy,R(C.currentTask),1)])):Y("",!0),h("div",ay,[h("div",ly," Last updated: "+R(y(new Date)),1),C.status==="working"&&C.currentTaskId?(_(),w("button",{key:0,type:"button",onClick:K=>N(C.currentTaskId),disabled:i.value.has(C.currentTaskId),class:"text-[10px] font-medium px-2.5 py-1 rounded-md bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 disabled:opacity-40 transition-all duration-150 flex items-center gap-1",title:"Stop task"},[T[6]||(T[6]=h("span",{class:"w-2 h-2 rounded-[2px] bg-red-400"},null,-1)),he(" "+R(i.value.has(C.currentTaskId)?"Stopping…":"Stop"),1)],8,cy)):Y("",!0)])],2))),128))]))]),h("section",null,[T[10]||(T[10]=h("h3",{class:"text-xs font-semibold text-txt-secondary uppercase tracking-wider mb-3"},"Recent Activity",-1)),r.value&&s.value.length===0?(_(),w("div",uy,[...T[8]||(T[8]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading activity… ")],-1)])])):s.value.length===0?(_(),w("div",dy," No recent activity yet ")):(_(),w("div",hy,[T[9]||(T[9]=h("div",{class:"absolute left-[15px] top-0 bottom-0 w-px bg-gradient-to-b from-accent/30 via-edge to-transparent"},null,-1)),h("div",fy,[(_(!0),w(be,null,qe(s.value,C=>(_(),w("button",{key:C.task_id,type:"button",onClick:K=>me(C.task_id),class:"w-full text-left relative pl-10 pr-4 py-3 rounded-lg hover:bg-surface-2/40 transition-all duration-150 group"},[h("div",{class:fe(["absolute left-[11px] top-4 w-[9px] h-[9px] rounded-full border-2 z-10",C.status==="running"?"bg-accent border-accent shadow-glow-sm":C.status==="done"?"bg-emerald-400 border-emerald-400":C.status==="failed"?"bg-red-400 border-red-400":C.status==="cancelled"?"bg-amber-400 border-amber-400":"bg-surface-3 border-edge"])},null,2),h("div",gy,[h("div",my,[h("div",vy,[h("span",by,R(C.agent_slug),1),C.origin_channel?(_(),w("span",yy,"via "+R(C.origin_channel),1)):Y("",!0)]),h("p",_y,R(C.description),1),h("p",wy,[he(R(k(C.started_at))+" ",1),C.completed_at?(_(),w("span",xy," · "+R(k(C.completed_at)),1)):Y("",!0)])]),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0",A(C.status)])},[C.status==="running"?(_(),w("span",ky)):Y("",!0),he(" "+R(C.status),1)],2)])],8,py))),128))])]))])])]),o.value?(_(),w("div",{key:0,class:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4 z-50",onClick:Yt(We,["self"])},[h("div",Sy,[h("div",{class:"flex justify-between items-center px-5 py-3.5 border-b border-edge"},[T[11]||(T[11]=h("h3",{class:"text-sm font-semibold text-txt-primary"},"Task Details",-1)),h("button",{type:"button",onClick:We,class:"text-txt-muted hover:text-txt-primary text-lg leading-none transition-colors p-1","aria-label":"Close"},"×")]),h("div",Ey,[l.value?(_(),w("div",Ty,[...T[12]||(T[12]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading task… ")],-1)])])):c.value?(_(),w("div",Ay,R(c.value),1)):a.value?(_(),w(be,{key:2},[h("div",Cy,[h("div",null,[T[13]||(T[13]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Agent",-1)),h("p",Ry,R(a.value.agent_slug),1)]),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium",A(a.value.status)])},[a.value.status==="running"?(_(),w("span",Oy)):Y("",!0),he(" "+R(a.value.status),1)],2)]),h("div",null,[T[14]||(T[14]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Task ID",-1)),h("p",$y,R(a.value.task_id),1)]),a.value.origin_channel?(_(),w("div",Py,[T[15]||(T[15]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Origin",-1)),h("p",Iy,R(a.value.origin_channel),1)])):Y("",!0),h("div",jy,[h("div",null,[T[16]||(T[16]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Started",-1)),h("p",Ny,R(k(a.value.started_at)),1)]),h("div",null,[T[17]||(T[17]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Completed",-1)),h("p",Ly,R(a.value.completed_at?k(a.value.completed_at):"—"),1)])]),L.value?(_(),w("div",Uy,[T[18]||(T[18]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Duration",-1)),h("p",Dy,R(L.value),1)])):Y("",!0),h("div",null,[T[19]||(T[19]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Description",-1)),h("pre",My,R(a.value.description),1)]),h("div",null,[h("div",By,[T[21]||(T[21]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted"},"Activity",-1)),h("label",Hy,[lt(h("input",{type:"checkbox","onUpdate:modelValue":T[0]||(T[0]=C=>f.value=C),class:"rounded bg-surface-3 border-edge accent-accent"},null,512),[[_c,f.value]]),T[20]||(T[20]=he(" Show details ",-1))])]),d.value&&u.value.length===0?(_(),w("div",Fy,"Loading activity…")):u.value.length===0?(_(),w("div",Vy,"No activity yet")):(_(),w("ul",qy,[(_(!0),w(be,null,qe(u.value,(C,K)=>(_(),w("li",{key:`${C.ts}-${K}-${C.rawType}`,class:"px-3 py-2 text-sm hover:bg-surface-2/40 cursor-pointer transition-colors",onClick:le=>q(K)},[h("div",{class:fe(["flex items-start gap-2",V(C)])},[h("span",Ky,R(C.icon),1),h("span",Gy,R(C.summary),1),h("span",zy,R(te(C.ts)),1)],2),f.value||p.value.has(K)?(_(),w("div",Jy,[C.detail?(_(),w("pre",Yy,R(C.detail),1)):Y("",!0),h("pre",Xy,R(de(C.raw)),1),h("p",Zy,R(C.rawType),1)])):Y("",!0)],8,Wy))),128))]))]),h("div",null,[T[22]||(T[22]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Result",-1)),a.value.result?(_(),w("pre",Qy,R(a.value.result),1)):(_(),w("p",e_,"No result yet"))])],64)):Y("",!0)]),h("div",t_,[a.value&&a.value.status==="running"?(_(),w("button",{key:0,type:"button",onClick:T[1]||(T[1]=C=>N(a.value.task_id)),disabled:i.value.has(a.value.task_id),class:"text-xs font-medium px-3 py-1.5 rounded-lg bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 disabled:opacity-40 transition-all duration-150"},R(i.value.has(a.value.task_id)?"Stopping…":"Stop Task"),9,s_)):(_(),w("span",r_)),h("button",{type:"button",onClick:We,class:"bg-surface-3/50 hover:bg-surface-3/70 text-txt-secondary text-sm px-4 py-1.5 rounded-lg border border-edge transition-all duration-150"}," Close ")])])])):Y("",!0)]))}}),i_={class:"flex flex-col h-full"},o_={class:"flex-1 overflow-y-auto p-6"},a_={class:"flex justify-between items-center mb-6"},l_=["disabled"],c_={key:0,class:"flex items-center justify-center py-16"},u_={key:1,class:"bg-red-500/10 border border-red-500/20 text-red-400 p-4 rounded-xl mb-4 text-sm"},d_={open:"",class:"mb-8 group/section"},h_={class:"cursor-pointer select-none flex items-center gap-3 text-sm font-semibold text-txt-primary mb-4 py-2"},f_={class:"text-[10px] font-mono text-txt-muted bg-surface-2 px-2 py-0.5 rounded-full border border-edge"},p_={key:0,class:"flex flex-col items-center py-8"},g_={key:1,class:"grid gap-3"},m_={class:"flex flex-wrap items-start gap-3"},v_={class:"flex-1 min-w-0"},b_={class:"flex flex-wrap items-center gap-2 mb-1.5"},y_={class:"font-semibold text-txt-primary break-words min-w-0"},__={key:0,class:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"},w_={class:"flex flex-wrap items-center gap-3 text-xs text-txt-muted mt-1"},x_={class:"font-mono text-accent/80 bg-surface-0/60 px-2 py-0.5 rounded-lg border border-edge/50 break-all"},k_={key:0,class:"flex items-center gap-1 shrink-0"},S_={key:1,class:"flex items-center gap-1 shrink-0"},E_={key:0,class:"text-xs text-txt-muted mt-1.5 break-words"},T_={class:"flex flex-wrap items-center gap-1.5"},A_=["onClick","disabled"],C_=["onClick","disabled"],R_=["onClick","disabled"],O_=["onClick"],$_=["onClick","disabled"],P_={key:0,class:"mt-3"},I_=["onClick"],j_={key:1,class:"mt-4 pt-4 border-t border-edge/50"},N_={class:"text-[10px] font-semibold text-txt-muted uppercase tracking-widest mb-3"},L_={key:0,class:"flex items-center gap-2 text-txt-muted text-xs py-2 justify-center"},U_={key:1,class:"text-txt-muted text-xs py-2 text-center"},D_={key:2,class:"space-y-1.5"},M_={class:"flex-1 min-w-0"},B_={class:"flex flex-wrap items-center gap-2"},H_={class:"text-txt-secondary"},F_={key:0,class:"text-txt-muted mt-0.5"},V_={key:1,class:"text-red-400 mt-1 break-words bg-red-500/5 rounded px-2 py-1 border border-red-500/10"},q_={open:"",class:"group/section"},W_={class:"cursor-pointer select-none flex items-center gap-3 text-sm font-semibold text-txt-primary mb-4 py-2"},K_={class:"text-[10px] font-mono text-txt-muted bg-surface-2 px-2 py-0.5 rounded-full border border-edge"},G_={key:0,class:"flex flex-col items-center py-8"},z_={key:1,class:"grid gap-3"},J_={class:"flex flex-wrap items-start gap-3"},Y_={class:"flex-1 min-w-0"},X_={class:"flex flex-wrap items-center gap-2 mb-1.5"},Z_={class:"font-semibold text-txt-primary break-words min-w-0"},Q_={class:"text-[10px] font-mono text-accent/60 bg-accent/5 px-2 py-0.5 rounded-full border border-accent/10 shrink-0"},ew={key:0,class:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"},tw={class:"flex flex-wrap items-center gap-3 text-xs text-txt-muted mt-1"},sw={class:"font-mono text-accent/80 bg-surface-0/60 px-2 py-0.5 rounded-lg border border-edge/50 break-all"},rw={key:0,class:"flex items-center gap-1 shrink-0"},nw={key:1,class:"flex items-center gap-1 shrink-0"},iw={key:0,class:"text-xs text-txt-muted mt-1.5 break-words"},ow={class:"flex flex-wrap items-center gap-1.5"},aw=["onClick","disabled"],lw=["onClick","disabled"],cw=["onClick","disabled"],uw=["onClick"],dw=["onClick","disabled"],hw={key:0,class:"mt-3"},fw=["onClick"],pw={key:1,class:"mt-4 pt-4 border-t border-edge/50"},gw={class:"text-[10px] font-semibold text-txt-muted uppercase tracking-widest mb-3"},mw={key:0,class:"flex items-center gap-2 text-txt-muted text-xs py-2 justify-center"},vw={key:1,class:"text-txt-muted text-xs py-2 text-center"},bw={key:2,class:"space-y-1.5"},yw={class:"flex-1 min-w-0"},_w={class:"flex flex-wrap items-center gap-2"},ww={class:"text-txt-secondary"},xw={key:0,class:"text-txt-muted mt-0.5"},kw={key:1,class:"text-red-400 mt-1 break-words bg-red-500/5 rounded px-2 py-1 border border-red-500/10"},Sw=gt({__name:"SchedulesView",setup(t){const e=F([]),s=F([]),r=F(!0),n=F(null),i=F(new Set),o=F(new Map),a=F(new Map),l=F(new Set),c=F(new Set);function u(N){const $=N.includes("T")||N.endsWith("Z")?N:N.replace(" ","T")+"Z";return new Date($).toLocaleString()}function d(N){return N==="done"?"bg-emerald-400":N==="failed"?"bg-red-400":"bg-accent animate-pulse"}function f(N){return N==="done"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":N==="failed"?"bg-red-500/10 text-red-400 border-red-500/20":"bg-accent/10 text-accent border-accent/20"}function p(N,$){const E=`${N}-${$}`,M=new Set(c.value);M.has(E)?M.delete(E):M.add(E),c.value=M}async function m(N,$){const E=`${N}-${$}`,M=o.value.get(E)??!1,B=new Map(o.value);if(B.set(E,!M),o.value=B,!M&&!a.value.has(E)){const te=new Set(l.value);te.add(E),l.value=te;try{const de=await ke(`/api/schedules/${N}/${$}/runs?limit=25`);if(de.ok){const V=await de.json(),q=new Map(a.value);q.set(E,V.runs??[]),a.value=q}}catch{}finally{const de=new Set(l.value);de.delete(E),l.value=de}}}async function b(){r.value=!0,n.value=null,a.value=new Map;try{const N=await ke("/api/schedules");if(!N.ok)throw new Error(`HTTP ${N.status}`);const $=await N.json();e.value=$.io,s.value=$.squads}catch(N){n.value=N instanceof Error?N.message:"Failed to load schedules"}finally{r.value=!1}}async function x(N,$){if(!i.value.has(N)){i.value=new Set(i.value).add(N);try{await $(),await b()}catch(E){n.value=E instanceof Error?E.message:"Action failed"}finally{const E=new Set(i.value);E.delete(N),i.value=E}}}async function y(N,$){await x(`${N}-${$}`,async()=>{const E=await ke(`/api/schedules/${N}/${$}/pause`,{method:"POST"});if(!E.ok)throw new Error(`HTTP ${E.status}`)})}async function k(N,$){await x(`${N}-${$}`,async()=>{const E=await ke(`/api/schedules/${N}/${$}/resume`,{method:"POST"});if(!E.ok)throw new Error(`HTTP ${E.status}`)})}async function A(N,$){await x(`${N}-${$}`,async()=>{const E=await ke(`/api/schedules/${N}/${$}/run-now`,{method:"POST"});if(!E.ok)throw new Error(`HTTP ${E.status}`)})}async function L(N,$,E){window.confirm(`Delete schedule '${E}'?`)&&await x(`${N}-${$}`,async()=>{const M=await ke(`/api/schedules/${N}/${$}`,{method:"DELETE"});if(!M.ok)throw new Error(`HTTP ${M.status}`)})}return ts(b),(N,$)=>(_(),w("div",i_,[h("div",o_,[h("div",a_,[$[1]||($[1]=h("div",null,[h("h2",{class:"text-xl font-semibold text-txt-primary tracking-tight"},"Schedules"),h("p",{class:"text-xs text-txt-muted mt-0.5"},"Automated tasks & cron jobs")],-1)),h("button",{onClick:b,disabled:r.value,class:"flex items-center gap-1.5 bg-surface-2/60 hover:bg-surface-3/60 disabled:opacity-50 text-txt-secondary hover:text-txt-primary border border-edge hover:border-edge-bright px-3.5 py-2 rounded-xl text-sm transition-all duration-200"},[...$[0]||($[0]=[h("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.992 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182"})],-1),he(" Refresh ",-1)])],8,l_)]),r.value?(_(),w("div",c_,[...$[2]||($[2]=[h("div",{class:"flex items-center gap-3 text-txt-muted text-sm"},[h("div",{class:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse"}),he(" Loading schedules… ")],-1)])])):n.value?(_(),w("div",u_,R(n.value),1)):(_(),w(be,{key:2},[h("details",d_,[h("summary",h_,[$[3]||($[3]=h("svg",{class:"w-4 h-4 text-accent transition-transform group-open/section:rotate-90",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})],-1)),$[4]||($[4]=h("span",{class:"tracking-wide uppercase text-xs text-txt-secondary"},"IO Schedules",-1)),h("span",f_,R(e.value.length),1),$[5]||($[5]=h("div",{class:"flex-1 h-px bg-gradient-to-r from-edge to-transparent"},null,-1))]),e.value.length===0?(_(),w("div",p_,[...$[6]||($[6]=[h("div",{class:"w-10 h-10 rounded-xl bg-surface-2 border border-edge flex items-center justify-center mb-3"},[h("svg",{class:"w-5 h-5 text-txt-muted",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1),h("p",{class:"text-txt-muted text-sm"},"No IO schedules configured",-1)])])):(_(),w("div",g_,[(_(!0),w(be,null,qe(e.value,E=>(_(),w("div",{key:E.id,class:"bg-surface-2/50 border border-edge rounded-xl p-4 hover:border-edge-bright hover:shadow-card transition-all duration-200 overflow-hidden"},[h("div",m_,[h("div",v_,[h("div",b_,[h("span",y_,R(E.name),1),h("span",{class:fe(["inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium tracking-wide uppercase border shrink-0",E.enabled?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-surface-3/60 text-txt-muted border-edge"])},[E.enabled?(_(),w("span",__)):Y("",!0),he(" "+R(E.enabled?"Active":"Paused"),1)],2)]),h("div",w_,[h("code",x_,R(E.cron_expr),1),E.next_run_at?(_(),w("span",k_,[$[7]||($[7]=h("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 8.689c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062A1.125 1.125 0 013 16.811V8.69zM12.75 8.689c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062a1.125 1.125 0 01-1.683-.977V8.69z"})],-1)),he(" "+R(u(E.next_run_at)),1)])):Y("",!0),E.last_run_at?(_(),w("span",S_,[$[8]||($[8]=h("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),he(" "+R(u(E.last_run_at)),1)])):Y("",!0)]),E.notes?(_(),w("p",E_,R(E.notes),1)):Y("",!0)]),h("div",T_,[E.enabled?(_(),w("button",{key:0,onClick:M=>y("io",E.id),disabled:i.value.has(`io-${E.id}`),class:"text-txt-secondary hover:text-txt-primary disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-surface-3/40 hover:bg-surface-3 border border-edge/50 hover:border-edge transition-all duration-200",title:"Pause"},"⏸ Pause",8,A_)):(_(),w("button",{key:1,onClick:M=>k("io",E.id),disabled:i.value.has(`io-${E.id}`),class:"text-txt-secondary hover:text-txt-primary disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-surface-3/40 hover:bg-surface-3 border border-edge/50 hover:border-edge transition-all duration-200",title:"Resume"},"▶ Resume",8,C_)),h("button",{onClick:M=>A("io",E.id),disabled:i.value.has(`io-${E.id}`),class:"text-accent hover:text-white disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-accent/10 hover:bg-accent/20 border border-accent/20 hover:border-accent/40 transition-all duration-200",title:"Run now"},"▶ Run now",8,R_),h("button",{onClick:M=>m("io",E.id),class:fe(["text-xs px-2.5 py-1.5 rounded-lg border transition-all duration-200",o.value.get(`io-${E.id}`)?"bg-accent/10 text-accent border-accent/20":"bg-surface-3/40 hover:bg-surface-3 text-txt-secondary hover:text-txt-primary border-edge/50 hover:border-edge"]),title:"Toggle run history"},"📋 History",10,O_),h("button",{onClick:M=>L("io",E.id,E.name),disabled:i.value.has(`io-${E.id}`),class:"text-red-400/70 hover:text-red-400 disabled:opacity-50 text-xs px-2 py-1.5 rounded-lg hover:bg-red-500/10 border border-transparent hover:border-red-500/20 transition-all duration-200",title:"Delete"},[...$[9]||($[9]=[h("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)])],8,$_)])]),E.prompt?(_(),w("div",P_,[h("p",{class:fe(["text-xs text-txt-muted break-words",c.value.has(`io-${E.id}`)?"":"line-clamp-2"])},R(E.prompt),3),E.prompt.length>120?(_(),w("button",{key:0,onClick:M=>p("io",E.id),class:"text-[10px] text-accent/70 hover:text-accent mt-1 transition-colors"},R(c.value.has(`io-${E.id}`)?"Show less ▲":"Show more ▼"),9,I_)):Y("",!0)])):Y("",!0),o.value.get(`io-${E.id}`)?(_(),w("div",j_,[h("h4",N_," Run history — "+R(E.name),1),l.value.has(`io-${E.id}`)?(_(),w("div",L_,[...$[10]||($[10]=[h("div",{class:"w-1 h-1 rounded-full bg-accent animate-pulse"},null,-1),he(" Loading… ",-1)])])):!a.value.get(`io-${E.id}`)||a.value.get(`io-${E.id}`).length===0?(_(),w("div",U_," No history yet ")):(_(),w("ul",D_,[(_(!0),w(be,null,qe(a.value.get(`io-${E.id}`),M=>(_(),w("li",{key:M.id,class:"flex items-start gap-2.5 text-xs bg-surface-0/50 rounded-lg p-2.5 border border-edge/30"},[h("span",{class:fe(["w-2 h-2 rounded-full mt-1 shrink-0",d(M.status)])},null,2),h("div",M_,[h("div",B_,[h("span",H_,R(u(M.started_at)),1),h("span",{class:fe(["px-1.5 py-0.5 rounded-full text-[10px] font-medium tracking-wide uppercase border shrink-0",f(M.status)])},R(M.status),3)]),M.completed_at?(_(),w("div",F_," Completed: "+R(u(M.completed_at)),1)):Y("",!0),M.error_text?(_(),w("div",V_,R(M.error_text),1)):Y("",!0)])]))),128))]))])):Y("",!0)]))),128))]))]),h("details",q_,[h("summary",W_,[$[11]||($[11]=h("svg",{class:"w-4 h-4 text-accent transition-transform group-open/section:rotate-90",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})],-1)),$[12]||($[12]=h("span",{class:"tracking-wide uppercase text-xs text-txt-secondary"},"Squad Schedules",-1)),h("span",K_,R(s.value.length),1),$[13]||($[13]=h("div",{class:"flex-1 h-px bg-gradient-to-r from-edge to-transparent"},null,-1))]),s.value.length===0?(_(),w("div",G_,[...$[14]||($[14]=[h("div",{class:"w-10 h-10 rounded-xl bg-surface-2 border border-edge flex items-center justify-center mb-3"},[h("svg",{class:"w-5 h-5 text-txt-muted",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 18.72a9.094 9.094 0 003.741-.479 3 3 0 00-4.682-2.72m.94 3.198l.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0112 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 016 18.719m12 0a5.971 5.971 0 00-.941-3.197m0 0A5.995 5.995 0 0012 12.75a5.995 5.995 0 00-5.058 2.772m0 0a3 3 0 00-4.681 2.72 8.986 8.986 0 003.74.477m.94-3.197a5.971 5.971 0 00-.94 3.197M15 6.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z"})])],-1),h("p",{class:"text-txt-muted text-sm"},"No squad schedules configured",-1)])])):(_(),w("div",z_,[(_(!0),w(be,null,qe(s.value,E=>(_(),w("div",{key:E.id,class:"bg-surface-2/50 border border-edge rounded-xl p-4 hover:border-edge-bright hover:shadow-card transition-all duration-200 overflow-hidden"},[h("div",J_,[h("div",Y_,[h("div",X_,[h("span",Z_,R(E.name),1),h("span",Q_,R(E.squad_slug),1),h("span",{class:fe(["inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium tracking-wide uppercase border shrink-0",E.enabled?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-surface-3/60 text-txt-muted border-edge"])},[E.enabled?(_(),w("span",ew)):Y("",!0),he(" "+R(E.enabled?"Active":"Paused"),1)],2)]),h("div",tw,[h("code",sw,R(E.cron_expr),1),E.next_run_at?(_(),w("span",rw,[$[15]||($[15]=h("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 8.689c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062A1.125 1.125 0 013 16.811V8.69zM12.75 8.689c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062a1.125 1.125 0 01-1.683-.977V8.69z"})],-1)),he(" "+R(u(E.next_run_at)),1)])):Y("",!0),E.last_run_at?(_(),w("span",nw,[$[16]||($[16]=h("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),he(" "+R(u(E.last_run_at)),1)])):Y("",!0)]),E.notes?(_(),w("p",iw,R(E.notes),1)):Y("",!0)]),h("div",ow,[E.enabled?(_(),w("button",{key:0,onClick:M=>y("squads",E.id),disabled:i.value.has(`squads-${E.id}`),class:"text-txt-secondary hover:text-txt-primary disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-surface-3/40 hover:bg-surface-3 border border-edge/50 hover:border-edge transition-all duration-200",title:"Pause"},"⏸ Pause",8,aw)):(_(),w("button",{key:1,onClick:M=>k("squads",E.id),disabled:i.value.has(`squads-${E.id}`),class:"text-txt-secondary hover:text-txt-primary disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-surface-3/40 hover:bg-surface-3 border border-edge/50 hover:border-edge transition-all duration-200",title:"Resume"},"▶ Resume",8,lw)),h("button",{onClick:M=>A("squads",E.id),disabled:i.value.has(`squads-${E.id}`),class:"text-accent hover:text-white disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-accent/10 hover:bg-accent/20 border border-accent/20 hover:border-accent/40 transition-all duration-200",title:"Run now"},"▶ Run now",8,cw),h("button",{onClick:M=>m("squads",E.id),class:fe(["text-xs px-2.5 py-1.5 rounded-lg border transition-all duration-200",o.value.get(`squads-${E.id}`)?"bg-accent/10 text-accent border-accent/20":"bg-surface-3/40 hover:bg-surface-3 text-txt-secondary hover:text-txt-primary border-edge/50 hover:border-edge"]),title:"Toggle run history"},"📋 History",10,uw),h("button",{onClick:M=>L("squads",E.id,E.name),disabled:i.value.has(`squads-${E.id}`),class:"text-red-400/70 hover:text-red-400 disabled:opacity-50 text-xs px-2 py-1.5 rounded-lg hover:bg-red-500/10 border border-transparent hover:border-red-500/20 transition-all duration-200",title:"Delete"},[...$[17]||($[17]=[h("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)])],8,dw)])]),E.prompt?(_(),w("div",hw,[h("p",{class:fe(["text-xs text-txt-muted break-words",c.value.has(`squads-${E.id}`)?"":"line-clamp-2"])},R(E.prompt),3),E.prompt.length>120?(_(),w("button",{key:0,onClick:M=>p("squads",E.id),class:"text-[10px] text-accent/70 hover:text-accent mt-1 transition-colors"},R(c.value.has(`squads-${E.id}`)?"Show less ▲":"Show more ▼"),9,fw)):Y("",!0)])):Y("",!0),o.value.get(`squads-${E.id}`)?(_(),w("div",pw,[h("h4",gw," Run history — "+R(E.name),1),l.value.has(`squads-${E.id}`)?(_(),w("div",mw,[...$[18]||($[18]=[h("div",{class:"w-1 h-1 rounded-full bg-accent animate-pulse"},null,-1),he(" Loading… ",-1)])])):!a.value.get(`squads-${E.id}`)||a.value.get(`squads-${E.id}`).length===0?(_(),w("div",vw," No history yet ")):(_(),w("ul",bw,[(_(!0),w(be,null,qe(a.value.get(`squads-${E.id}`),M=>(_(),w("li",{key:M.id,class:"flex items-start gap-2.5 text-xs bg-surface-0/50 rounded-lg p-2.5 border border-edge/30"},[h("span",{class:fe(["w-2 h-2 rounded-full mt-1 shrink-0",d(M.status)])},null,2),h("div",yw,[h("div",_w,[h("span",ww,R(u(M.started_at)),1),h("span",{class:fe(["px-1.5 py-0.5 rounded-full text-[10px] font-medium tracking-wide uppercase border shrink-0",f(M.status)])},R(M.status),3)]),M.completed_at?(_(),w("div",xw," Completed: "+R(u(M.completed_at)),1)):Y("",!0),M.error_text?(_(),w("div",kw,R(M.error_text),1)):Y("",!0)])]))),128))]))])):Y("",!0)]))),128))]))])],64))])]))}}),Ew={class:"flex flex-col h-full p-6"},Tw={class:"flex justify-between items-center mb-6"},Aw={key:0,class:"flex-1 flex items-center justify-center"},Cw={key:1,class:"flex-1 flex flex-col items-center justify-center"},Rw={key:2,class:"space-y-2 overflow-y-auto flex-1 pr-1"},Ow=["onClick"],$w={class:"p-4"},Pw={class:"flex items-start gap-3"},Iw={class:"flex flex-col items-center pt-1"},jw={key:0,class:"w-2 h-2 rounded-full bg-accent shadow-glow-sm shrink-0"},Nw={key:1,class:"w-2 h-2 rounded-full bg-edge shrink-0"},Lw={class:"flex-1 min-w-0"},Uw={class:"flex items-center gap-2 mb-1"},Dw={class:"text-sm font-medium text-txt-primary truncate"},Mw={key:0,class:"text-[10px] font-mono tracking-wider uppercase text-txt-muted bg-surface-0/60 px-1.5 py-0.5 rounded border border-edge/50 shrink-0"},Bw={class:"text-xs text-txt-muted"},Hw=["onClick"],Fw={key:0,class:"px-4 pb-4 pt-0"},Vw=["innerHTML"],qw=gt({__name:"NotificationsView",setup(t){const e=F([]),s=F(!0),r=F(new Set);function n(c){try{const u=c.includes("T")||c.endsWith("Z")?c:c.replace(" ","T")+"Z";return new Date(u).toLocaleString()}catch{return c}}function i(c){const u=new Set(r.value);u.has(c)?u.delete(c):u.add(c),r.value=u}async function o(){try{const c=await ke("/api/notifications?limit=100");if(c.ok){const u=await c.json();e.value=u.notifications??[]}}catch{}s.value=!1}async function a(c){try{await ke(`/api/notifications/${c}/read`,{method:"POST"});const u=e.value.find(d=>d.id===c);u&&(u.read_at=new Date().toISOString())}catch{}}async function l(){try{await ke("/api/notifications/read-all",{method:"POST"});for(const c of e.value)c.read_at||(c.read_at=new Date().toISOString())}catch{}}return ts(o),(c,u)=>(_(),w("div",Ew,[h("div",Tw,[u[0]||(u[0]=h("div",null,[h("h2",{class:"text-xl font-semibold text-txt-primary tracking-tight"},"Notifications"),h("p",{class:"text-xs text-txt-muted mt-0.5"},"Background activity & alerts")],-1)),e.value.length>0?(_(),w("button",{key:0,onClick:l,class:"text-xs text-accent hover:text-accent-glow transition-colors font-medium"}," Mark all read ")):Y("",!0)]),s.value?(_(),w("div",Aw,[...u[1]||(u[1]=[h("div",{class:"flex items-center gap-3 text-txt-muted text-sm"},[h("div",{class:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse"}),he(" Loading… ")],-1)])])):e.value.length===0?(_(),w("div",Cw,[...u[2]||(u[2]=[h("div",{class:"w-12 h-12 rounded-xl bg-surface-2 border border-edge flex items-center justify-center mb-4"},[h("svg",{class:"w-6 h-6 text-txt-muted",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"})])],-1),h("p",{class:"text-txt-muted text-sm"},"No notifications yet",-1)])])):(_(),w("ul",Rw,[(_(!0),w(be,null,qe(e.value,d=>{var f;return _(),w("li",{key:d.id,class:fe(["group rounded-xl border transition-all duration-200 cursor-pointer overflow-hidden",d.read_at?"bg-surface-1/40 border-edge/50 opacity-60 hover:opacity-80":"bg-surface-2/60 border-edge hover:border-edge-bright hover:shadow-card"]),onClick:p=>i(d.id)},[h("div",$w,[h("div",Pw,[h("div",Iw,[d.read_at?(_(),w("span",Nw)):(_(),w("span",jw))]),h("div",Lw,[h("div",Uw,[h("span",Dw,R(d.title),1),(f=d.source)!=null&&f.type?(_(),w("span",Mw,R(d.source.type),1)):Y("",!0)]),h("p",Bw,R(n(d.created_at)),1)]),d.read_at?Y("",!0):(_(),w("button",{key:0,onClick:Yt(p=>a(d.id),["stop"]),class:"text-txt-muted hover:text-accent shrink-0 opacity-0 group-hover:opacity-100 transition-all duration-200 p-1 rounded-lg hover:bg-accent/10",title:"Mark as read"},[...u[3]||(u[3]=[h("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"})],-1)])],8,Hw))])]),r.value.has(d.id)?(_(),w("div",Fw,[h("div",{class:"ml-5 mt-2 text-sm text-txt-secondary bg-surface-0/60 rounded-xl p-4 border border-edge/50 wiki-content",innerHTML:Oe(zn)(d.text)},null,8,Vw)])):Y("",!0)],10,Ow)}),128))]))]))}}),Ww={class:"flex h-full overflow-hidden bg-surface-0"},Kw={class:"w-72 shrink-0 bg-surface-1/70 backdrop-blur-sm border-r border-edge flex flex-col"},Gw={class:"p-3.5 shrink-0"},zw={class:"flex items-center justify-between mb-3"},Jw={class:"text-[10px] text-txt-muted font-mono bg-surface-2/60 px-1.5 py-0.5 rounded"},Yw={key:0,class:"flex-1 flex items-center justify-center"},Xw={key:1,class:"flex-1 p-4"},Zw={class:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2"},Qw={key:2,class:"flex-1 overflow-y-auto py-2 px-2"},ex={key:0,class:"px-2 py-3 text-sm text-txt-muted text-center"},tx=["onClick"],sx={key:0,class:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-r-full bg-accent shadow-glow-sm"},rx={class:"flex-1 min-w-0 flex flex-col overflow-hidden"},nx={key:0,class:"flex-1 flex flex-col items-center justify-center select-none"},ix={key:1,class:"flex-1 flex items-center justify-center"},ox={key:2,class:"flex-1 p-6"},ax={class:"inline-flex items-center gap-2 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2"},lx={key:3,class:"flex-1 overflow-y-auto"},cx={class:"max-w-3xl mx-auto px-6 py-6"},ux={class:"text-xl font-bold text-txt-primary mb-4 pb-3 border-b border-edge"},dx=["innerHTML"],hx=gt({__name:"WikiView",setup(t){const e=F([]),s=F(null),r=F(""),n=F(""),i=F(!1),o=F(!1),a=F(""),l=F(""),c=$e(()=>{const p=n.value.trim().toLowerCase();return p?e.value.filter(m=>m.title.toLowerCase().includes(p)):e.value}),u=$e(()=>zn(r.value));async function d(){i.value=!0,a.value="";try{const p=await ke("/api/wiki");if(!p.ok)throw new Error(`HTTP ${p.status}`);const m=await p.json();e.value=m.pages??[]}catch(p){a.value=p instanceof Error?p.message:"Failed to load pages"}finally{i.value=!1}}async function f(p){var m;if(((m=s.value)==null?void 0:m.path)!==p.path){s.value=p,r.value="",o.value=!0,l.value="";try{const b=await ke(`/api/wiki/${encodeURIComponent(p.path)}`);if(!b.ok)throw new Error(`HTTP ${b.status}`);const x=await b.json();r.value=x.content??""}catch(b){l.value=b instanceof Error?b.message:"Failed to load page"}finally{o.value=!1}}}return ts(d),(p,m)=>(_(),w("div",Ww,[h("div",Kw,[h("div",Gw,[h("div",zw,[m[1]||(m[1]=h("h2",{class:"text-sm font-semibold text-txt-primary tracking-tight flex items-center gap-1.5"},[h("span",{class:"text-base"},"📚"),he(" Wiki ")],-1)),h("span",Jw,R(c.value.length),1)]),lt(h("input",{"onUpdate:modelValue":m[0]||(m[0]=b=>n.value=b),type:"text",placeholder:"Filter pages…",class:"w-full px-3 py-1.5 text-sm bg-surface-2/50 border border-edge rounded-lg text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,n.value]])]),m[3]||(m[3]=h("div",{class:"mx-3 h-px bg-gradient-to-r from-transparent via-edge to-transparent"},null,-1)),i.value?(_(),w("div",Yw,[...m[2]||(m[2]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading… ")],-1)])])):a.value?(_(),w("div",Xw,[h("div",Zw,R(a.value),1)])):(_(),w("ul",Qw,[c.value.length===0?(_(),w("li",ex," No pages found ")):Y("",!0),(_(!0),w(be,null,qe(c.value,b=>{var x,y,k;return _(),w("li",{key:b.path,onClick:A=>f(b),class:fe(["relative px-2.5 py-2 rounded-lg cursor-pointer text-sm transition-all duration-150 mb-0.5",((x=s.value)==null?void 0:x.path)===b.path?"bg-accent/10 text-accent":"text-txt-secondary hover:text-txt-primary hover:bg-surface-3/40"])},[((y=s.value)==null?void 0:y.path)===b.path?(_(),w("span",sx)):Y("",!0),h("span",{class:fe(((k=s.value)==null?void 0:k.path)===b.path?"ml-1":"")},R(b.title),3)],10,tx)}),128))]))]),h("div",rx,[s.value?o.value?(_(),w("div",ix,[...m[5]||(m[5]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading… ")],-1)])])):l.value?(_(),w("div",ox,[h("div",ax,[m[6]||(m[6]=h("span",null,"⚠",-1)),he(" "+R(l.value),1)])])):(_(),w("div",lx,[h("div",cx,[h("h1",ux,R(s.value.title),1),h("div",{class:"wiki-content text-txt-secondary text-sm leading-relaxed",innerHTML:u.value},null,8,dx)])])):(_(),w("div",nx,[...m[4]||(m[4]=[h("div",{class:"w-12 h-12 rounded-xl bg-surface-2/60 border border-edge flex items-center justify-center mb-4"},[h("span",{class:"text-2xl"},"📖")],-1),h("p",{class:"text-txt-muted text-sm"},"Select a page to start reading",-1)])]))])]))}}),fx=Hr(hx,[["__scopeId","data-v-a74f92fe"]]),px={class:"relative flex items-center justify-center h-screen bg-surface-0 overflow-hidden"},gx={class:"relative w-full max-w-sm mx-4 animate-fade-in"},mx={class:"glass rounded-2xl border border-edge p-8 shadow-glow"},vx={key:0,class:"flex items-center gap-2 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-xl px-3.5 py-2.5"},bx=["disabled"],yx=gt({__name:"LoginView",setup(t){const e=Br(),s=Hc(),r=F(""),n=F(""),i=F(null);async function o(){i.value=null;const a=await e.signIn(r.value,n.value);a?i.value=a:s.push("/chat")}return(a,l)=>(_(),w("div",px,[l[6]||(l[6]=h("div",{class:"pointer-events-none absolute inset-0"},[h("div",{class:"absolute top-1/4 left-1/3 w-[500px] h-[500px] bg-accent/[0.04] rounded-full blur-[120px]"}),h("div",{class:"absolute bottom-1/4 right-1/4 w-[400px] h-[400px] bg-accent-dim/[0.06] rounded-full blur-[100px]"})],-1)),h("div",gx,[h("div",mx,[l[5]||(l[5]=Dn('<div class="flex flex-col items-center mb-8"><div class="w-14 h-14 rounded-xl bg-accent/10 border border-accent/20 flex items-center justify-center mb-4 shadow-glow-sm"><span class="text-accent font-mono font-bold text-2xl tracking-tighter">IO</span></div><h1 class="text-xl font-semibold text-txt-primary tracking-tight">Welcome back</h1><p class="text-sm text-txt-muted mt-1">Sign in to continue</p></div>',1)),h("form",{onSubmit:Yt(o,["prevent"]),class:"space-y-5"},[h("div",null,[l[2]||(l[2]=h("label",{for:"email",class:"block text-xs font-medium text-txt-secondary mb-1.5 tracking-wide uppercase"},"Email",-1)),lt(h("input",{id:"email","onUpdate:modelValue":l[0]||(l[0]=c=>r.value=c),type:"email",required:"",autocomplete:"email",class:"w-full px-3.5 py-2.5 bg-surface-0/60 border border-edge rounded-xl text-txt-primary placeholder-txt-muted text-sm focus:outline-none focus:border-accent/50 focus:ring-1 focus:ring-accent/20 focus:shadow-glow-sm transition-all duration-200",placeholder:"you@example.com"},null,512),[[yt,r.value]])]),h("div",null,[l[3]||(l[3]=h("label",{for:"password",class:"block text-xs font-medium text-txt-secondary mb-1.5 tracking-wide uppercase"},"Password",-1)),lt(h("input",{id:"password","onUpdate:modelValue":l[1]||(l[1]=c=>n.value=c),type:"password",required:"",autocomplete:"current-password",class:"w-full px-3.5 py-2.5 bg-surface-0/60 border border-edge rounded-xl text-txt-primary placeholder-txt-muted text-sm focus:outline-none focus:border-accent/50 focus:ring-1 focus:ring-accent/20 focus:shadow-glow-sm transition-all duration-200",placeholder:"••••••••"},null,512),[[yt,n.value]])]),i.value?(_(),w("div",vx,[l[4]||(l[4]=h("svg",{class:"w-4 h-4 shrink-0",viewBox:"0 0 20 20",fill:"currentColor"},[h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z","clip-rule":"evenodd"})],-1)),he(" "+R(i.value),1)])):Y("",!0),h("button",{type:"submit",disabled:Oe(e).loading,class:"w-full py-2.5 px-4 bg-accent hover:bg-accent-glow disabled:opacity-50 disabled:cursor-not-allowed text-surface-0 font-semibold text-sm rounded-xl transition-all duration-200 shadow-glow-sm hover:shadow-glow"},R(Oe(e).loading?"Signing in…":"Sign in"),9,bx)],32)])])]))}}),du=tp({history:Nf("/"),routes:[{path:"/",redirect:"/chat"},{path:"/login",name:"login",component:yx,meta:{public:!0}},{path:"/chat",name:"chat",component:Bv},{path:"/skills",name:"skills",component:D0},{path:"/squads",name:"squads",component:Mb},{path:"/activity",name:"activity",component:n_},{path:"/wiki",name:"wiki",component:fx},{path:"/schedules",name:"schedules",component:Sw},{path:"/notifications",name:"notifications",component:qw},{path:"/inbox",name:"inbox",component:()=>bv(()=>import("./InboxView-CR3ZzT5n.js"),[])}]});du.beforeEach(async t=>{const e=Br();return e.initialized||await e.init(),!e.authEnabled||t.meta.public||e.user?!0:{name:"login"}});const mo=Fh(gv);mo.use(Wh());mo.use(du);mo.mount("#app");export{be as F,h as a,Y as b,w as c,gt as d,he as e,Dn as f,F as g,ke as h,_ as i,zn as j,ts as o,qe as r,R as t,Oe as u,Yt as w};
|
|
84
|
+
[Error: failed to reach IO]`),e.setLastStreaming(!1),e.isLoading=!1,y.close()}}return(x,y)=>(_(),w("div",k0,[h("div",{ref_key:"messagesEl",ref:n,class:"flex-1 overflow-y-auto px-4 py-6 sm:px-6",onScroll:d},[Oe(e).messages.length===0?(_(),w("div",S0,[y[1]||(y[1]=h("div",{class:"w-16 h-16 rounded-2xl bg-accent/10 border border-accent/20 flex items-center justify-center mb-5 shadow-glow"},[h("span",{class:"text-accent font-bold text-2xl font-mono tracking-tighter"},"IO")],-1)),y[2]||(y[2]=h("p",{class:"text-txt-secondary text-sm font-medium mb-1"},"What can I help you build?",-1)),y[3]||(y[3]=h("p",{class:"text-txt-muted text-xs"},"Send a message to start a conversation",-1)),h("div",E0,[(_(),w(be,null,qe(a,k=>h("button",{key:k,onClick:A=>l(k),class:"px-3 py-1.5 text-xs text-txt-secondary bg-surface-2/60 border border-edge rounded-full hover:border-accent/30 hover:text-accent hover:bg-accent/5 transition-all duration-200"},R(k),9,T0)),64))])])):(_(),w("div",A0,[(_(!0),w(be,null,qe(Oe(e).messages,k=>(_(),w("div",{key:k.id,class:fe(["flex animate-fade-in",k.role==="user"?"justify-end":"justify-start"])},[k.role==="user"?(_(),w("div",C0,R(k.content),1)):(_(),w("div",R0,[y[4]||(y[4]=h("div",{class:"shrink-0 w-6 h-6 rounded-lg bg-surface-3/60 border border-edge flex items-center justify-center mt-0.5"},[h("span",{class:"text-accent text-[10px] font-bold font-mono"},"IO")],-1)),h("div",{class:"chat-md min-w-0 px-4 py-2.5 rounded-2xl rounded-tl-md text-sm bg-surface-2/70 text-txt-primary border border-edge",innerHTML:Oe(zn)(k.content)+(k.streaming?D0:"")},null,8,O0)]))],2))),128)),Oe(e).isLoading&&!u.value?(_(),w("div",$0,[...y[5]||(y[5]=[Dn('<div class="flex gap-2.5 items-start" data-v-f2ce91f6><div class="shrink-0 w-6 h-6 rounded-lg bg-surface-3/60 border border-edge flex items-center justify-center" data-v-f2ce91f6><span class="text-accent text-[10px] font-bold font-mono" data-v-f2ce91f6>IO</span></div><div class="px-4 py-3 rounded-2xl rounded-tl-md bg-surface-2/70 border border-edge flex items-center gap-1" data-v-f2ce91f6><span class="thinking-dot" style="animation-delay:0s;" data-v-f2ce91f6></span><span class="thinking-dot" style="animation-delay:0.15s;" data-v-f2ce91f6></span><span class="thinking-dot" style="animation-delay:0.3s;" data-v-f2ce91f6></span></div></div>',1)])])):Y("",!0)]))],544),He(yc,{name:"scroll-btn"},{default:xr(()=>[i.value?(_(),w("button",{key:0,onClick:f,class:"absolute bottom-24 left-1/2 -translate-x-1/2 z-10 w-8 h-8 rounded-full bg-surface-2/90 backdrop-blur-sm border border-edge-bright text-txt-secondary hover:text-accent hover:border-accent/40 hover:shadow-glow-sm flex items-center justify-center transition-all duration-200",title:"Scroll to bottom"},[...y[6]||(y[6]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-4 h-4",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[h("path",{d:"M4 6l4 4 4-4"})],-1)])])):Y("",!0)]),_:1}),h("div",P0,[h("form",{onSubmit:Yt(b,["prevent"]),class:"max-w-3xl mx-auto flex gap-2 items-end"},[h("div",I0,[lt(h("textarea",{ref_key:"inputEl",ref:o,"onUpdate:modelValue":y[0]||(y[0]=k=>s.value=k),placeholder:"Message IO…",disabled:Oe(e).isLoading,rows:"1",class:"w-full bg-surface-2/60 border border-edge rounded-xl px-4 py-2.5 pr-3 text-sm text-txt-primary placeholder-txt-muted/60 resize-none overflow-hidden focus:outline-none focus:border-accent/40 focus:shadow-glow-sm disabled:opacity-40 transition-all duration-200",onKeydown:p,onInput:m},null,40,j0),[[yt,s.value]])]),Oe(e).isLoading?(_(),w("button",{key:0,type:"button",onClick:c,disabled:r.value,class:"shrink-0 h-10 px-3.5 rounded-xl text-sm font-medium bg-red-500/15 text-red-400 border border-red-500/25 hover:bg-red-500/25 hover:border-red-500/40 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-150 flex items-center gap-1.5",title:"Stop"},[y[7]||(y[7]=h("span",{class:"w-2.5 h-2.5 rounded-[3px] bg-red-400"},null,-1)),h("span",L0,R(r.value?"Stopping…":"Stop"),1)],8,N0)):(_(),w("button",{key:1,type:"submit",disabled:!s.value.trim(),class:"shrink-0 w-10 h-10 rounded-xl flex items-center justify-center bg-accent/15 text-accent border border-accent/25 hover:bg-accent/25 hover:border-accent/40 hover:shadow-glow-sm disabled:opacity-25 disabled:cursor-not-allowed disabled:hover:shadow-none transition-all duration-150",title:"Send"},[...y[8]||(y[8]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor"},[h("path",{d:"M1.724 1.053a.5.5 0 0 1 .54-.068l12 6a.5.5 0 0 1 0 .894l-12 6A.5.5 0 0 1 1.5 13.5v-4.379l6.5-1.121-6.5-1.121V2.5a.5.5 0 0 1 .224-.447Z"})],-1)])],8,U0))],32)])]))}}),B0=Hr(M0,[["__scopeId","data-v-f2ce91f6"]]),H0={class:"flex flex-col h-full bg-surface-0"},F0={key:0,class:"flex flex-col h-full overflow-hidden animate-fade-in"},V0={class:"flex items-center gap-3 px-6 py-3.5 border-b border-edge shrink-0 bg-surface-1/60 backdrop-blur-sm"},q0={class:"text-base font-semibold text-txt-primary truncate"},W0={class:"text-[11px] text-txt-muted font-mono shrink-0 bg-surface-2/60 px-1.5 py-0.5 rounded"},K0={key:0,class:"flex-1 flex items-center justify-center"},G0={key:1,class:"flex-1 p-6"},z0={class:"inline-flex items-center gap-2 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2"},J0={key:2,class:"flex-1 overflow-y-auto p-6 skill-content text-sm text-txt-secondary leading-relaxed"},Y0={key:0,class:"mb-6 bg-surface-2/60 border border-edge rounded-xl p-5"},X0={key:0,class:"mb-3"},Z0={class:"text-base font-semibold text-txt-primary"},Q0={key:1,class:"mb-3"},ev={class:"text-sm text-txt-secondary"},tv={class:"flex flex-wrap gap-6 mt-1"},sv={key:0},rv={class:"text-sm text-accent font-mono"},nv={key:1},iv={class:"text-sm text-txt-secondary"},ov={key:2,class:"mt-3 pt-3 border-t border-edge grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 items-baseline"},av={class:"text-[10px] text-txt-muted uppercase tracking-wider whitespace-nowrap"},lv={class:"text-xs text-txt-secondary font-mono"},cv=["innerHTML"],uv={key:1,class:"flex-1 overflow-y-auto p-6"},dv={class:"max-w-3xl"},hv={class:"mb-6 bg-surface-2/40 border border-edge rounded-xl p-4"},fv={class:"flex gap-1 mb-3"},pv={class:"flex gap-2"},gv=["disabled"],mv=["disabled"],vv={class:"flex flex-col gap-2"},bv=["disabled"],yv=["disabled"],_v=["disabled"],wv={key:0,class:"flex items-center gap-2 bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 p-3 rounded-lg mb-4 text-sm animate-fade-in"},xv={key:1,class:"flex items-center gap-2 bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg mb-4 text-sm animate-fade-in"},kv={key:2,class:"mb-4"},Sv={key:3,class:"flex items-center justify-center py-16"},Ev={key:4,class:"flex items-center gap-2 bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg mb-4 text-sm"},Tv={key:5,class:"text-txt-muted text-sm text-center py-16"},Av={key:6,class:"text-txt-muted text-sm text-center py-12"},Cv={key:7,class:"grid gap-3"},Rv=["onClick"],Ov={class:"flex justify-between items-start mb-1.5"},$v={class:"min-w-0"},Pv={class:"font-semibold text-txt-primary text-sm group-hover:text-accent transition-colors duration-150"},Iv={class:"text-[11px] text-txt-muted font-mono mt-0.5"},jv=["onClick"],Nv={class:"text-xs text-txt-secondary mb-2 line-clamp-2"},Lv={class:"text-[10px] text-txt-muted font-mono truncate"},Uv=gt({__name:"SkillsView",setup(t){const e=F([]),s=F(!0),r=F(null),n=F(""),i=F(!1),o=F(null),a=F(null),l=F("url"),c=F(""),u=F(""),d=F(!1),f=F(null),p=F(""),m=F(!1),b=F(null),x=$e(()=>x0(p.value)),y=$e(()=>x.value.frontmatter),k=$e(()=>zn(x.value.body)),A=["name","description","version","author"],L=$e(()=>y.value?Object.entries(y.value).filter(([q])=>!A.includes(q)):[]),N=F(""),$=$e(()=>{const q=N.value.toLowerCase().trim();return q?e.value.filter(O=>O.name.toLowerCase().includes(q)||O.slug.toLowerCase().includes(q)||(O.description??"").toLowerCase().includes(q)):e.value});async function E(q){f.value=q,p.value="",b.value=null,m.value=!0;try{const O=await ke(`/api/skills/${encodeURIComponent(q.slug)}`);if(O.status===404)b.value="Skill not found";else if(!O.ok)b.value=`Failed to load skill (HTTP ${O.status})`;else{const ce=await O.json();p.value=ce.content??""}}catch(O){b.value=O instanceof Error?O.message:"Failed to load skill"}finally{m.value=!1}}function M(){f.value=null,p.value="",b.value=null}async function B(){try{const q=await ke("/api/skills");if(!q.ok)throw new Error(`HTTP error! status: ${q.status}`);const O=await q.json();e.value=O.skills}catch(q){r.value=q instanceof Error?q.message:"Failed to load skills"}finally{s.value=!1}}async function te(){if(!(i.value||n.value.trim()==="")){i.value=!0,o.value=null,a.value=null;try{const q=await ke("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repoUrl:n.value.trim()})});if(q.ok){const O=await q.json();e.value=[O.skill,...e.value],n.value="",a.value=`✓ Installed: ${O.skill.name}`,setTimeout(()=>{a.value=null},4e3),B()}else{let O="Install failed";try{O=(await q.json()).error??q.statusText??O}catch{O=q.statusText||O}o.value=O}}catch(q){o.value=q instanceof Error?q.message:"Install failed"}finally{i.value=!1}}}async function de(){if(!(d.value||c.value.trim()===""||u.value.trim()==="")){d.value=!0,o.value=null,a.value=null;try{const q=await ke("/api/skills/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u.value.trim(),slug:c.value.trim()})});if(q.ok){const O=await q.json();e.value=[O.skill,...e.value],c.value="",u.value="",a.value=`✓ Installed: ${O.skill.name}`,setTimeout(()=>{a.value=null},4e3),B()}else{let O="Install failed";try{O=(await q.json()).error??q.statusText??O}catch{O=q.statusText||O}o.value=O}}catch(q){o.value=q instanceof Error?q.message:"Install failed"}finally{d.value=!1}}}async function V(q){if(confirm(`Delete skill "${q.name}"? This cannot be undone.`))try{const O=await ke(`/api/skills/${encodeURIComponent(q.slug)}`,{method:"DELETE"});if(O.ok)e.value=e.value.filter(ce=>ce.slug!==q.slug),a.value=`✓ Deleted: ${q.name}`,setTimeout(()=>{a.value=null},3e3);else{const ce=await O.json().catch(()=>({}));o.value=ce.error??(O.status===404?"Skill not found":`Delete failed (HTTP ${O.status})`)}}catch(O){o.value=O instanceof Error?O.message:"Delete failed"}}return ts(B),(q,O)=>(_(),w("div",H0,[f.value?(_(),w("div",F0,[h("div",V0,[h("button",{onClick:M,class:"text-txt-muted hover:text-accent transition-colors flex items-center gap-1.5 text-sm group"},[...O[6]||(O[6]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-3.5 h-3.5 transition-transform group-hover:-translate-x-0.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[h("path",{d:"M10 3L5 8l5 5"})],-1),he(" Back ",-1)])]),O[7]||(O[7]=h("div",{class:"w-px h-5 bg-edge"},null,-1)),h("h2",q0,R(f.value.name),1),h("span",W0,R(f.value.slug),1)]),m.value?(_(),w("div",K0,[...O[8]||(O[8]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading… ")],-1)])])):b.value?(_(),w("div",G0,[h("div",z0,[O[9]||(O[9]=h("span",null,"⚠",-1)),he(" "+R(b.value),1)])])):(_(),w("div",J0,[y.value?(_(),w("div",Y0,[y.value.name?(_(),w("div",X0,[O[10]||(O[10]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-widest mb-0.5"},"Name",-1)),h("p",Z0,R(y.value.name),1)])):Y("",!0),y.value.description?(_(),w("div",Q0,[O[11]||(O[11]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-widest mb-0.5"},"Description",-1)),h("p",ev,R(y.value.description),1)])):Y("",!0),h("div",tv,[y.value.version?(_(),w("div",sv,[O[12]||(O[12]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-widest mb-0.5"},"Version",-1)),h("p",rv,R(y.value.version),1)])):Y("",!0),y.value.author?(_(),w("div",nv,[O[13]||(O[13]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-widest mb-0.5"},"Author",-1)),h("p",iv,R(y.value.author),1)])):Y("",!0)]),L.value.length>0?(_(),w("dl",ov,[(_(!0),w(be,null,qe(L.value,([ce,ge])=>(_(),w(be,{key:ce},[h("dt",av,R(ce),1),h("dd",lv,R(ge),1)],64))),128))])):Y("",!0)])):Y("",!0),h("div",{innerHTML:k.value},null,8,cv)]))])):(_(),w("div",uv,[h("div",dv,[O[20]||(O[20]=Dn('<div class="flex items-end justify-between mb-6" data-v-a63e75bb><div data-v-a63e75bb><h2 class="text-xl font-bold text-txt-primary tracking-tight" data-v-a63e75bb>Skills</h2><p class="text-xs text-txt-muted mt-0.5" data-v-a63e75bb>Manage installed Copilot skills</p></div><div class="flex items-center gap-2" data-v-a63e75bb><a href="https://github.com/github/awesome-copilot" target="_blank" rel="noopener noreferrer" class="flex items-center gap-1.5 text-xs text-txt-muted bg-surface-2/50 border border-edge px-2.5 py-1 rounded-full hover:border-accent/30 hover:text-accent transition-all duration-200" data-v-a63e75bb><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="w-3 h-3 fill-current" aria-hidden="true" data-v-a63e75bb><path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z" data-v-a63e75bb></path></svg> awesome-copilot </a><a href="https://skills.sh" target="_blank" rel="noopener noreferrer" class="flex items-center gap-1.5 text-xs text-txt-muted bg-surface-2/50 border border-edge px-2.5 py-1 rounded-full hover:border-accent/30 hover:text-accent transition-all duration-200" data-v-a63e75bb><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="w-3 h-3 fill-current" aria-hidden="true" data-v-a63e75bb><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8c0 .93.16 1.82.46 2.65L5 8.5V7H3.5l-.07.01A6.492 6.492 0 0 0 1.5 8Zm6.5 6.5c.93 0 1.82-.17 2.65-.47L8.5 11H7v2.5c.17.01.33.01.5.01Zm-5.3-1.7c.56.4 1.19.7 1.87.88L5 11H3.5c.34.66.79 1.25 1.2 1.8ZM8.5 1.5V4H10l2.5 2.5c.02-.16.03-.33.03-.5A6.5 6.5 0 0 0 8.5 1.5Zm-1 0A6.5 6.5 0 0 0 1.97 6H3.5L6 3.5V1.53c-.51.1-1 .26-1.5.46V1.5ZM11 8.5l-2.5 2.5H10l1.88-1.88A6.47 6.47 0 0 0 11 8.5ZM6 6v4h4V6H6Z" data-v-a63e75bb></path></svg> skills.sh </a></div></div>',1)),h("div",hv,[h("div",fv,[h("button",{type:"button",onClick:O[0]||(O[0]=ce=>l.value="url"),class:fe(["px-3 py-1.5 text-xs font-medium rounded-lg transition-all duration-150",l.value==="url"?"bg-accent/10 text-accent border border-accent/20":"text-txt-muted hover:text-txt-secondary hover:bg-surface-3/40 border border-transparent"])}," From URL ",2),h("button",{type:"button",onClick:O[1]||(O[1]=ce=>l.value="paste"),class:fe(["px-3 py-1.5 text-xs font-medium rounded-lg transition-all duration-150",l.value==="paste"?"bg-accent/10 text-accent border border-accent/20":"text-txt-muted hover:text-txt-secondary hover:bg-surface-3/40 border border-transparent"])}," Paste SKILL.md ",2)]),l.value==="url"?(_(),w("form",{key:0,onSubmit:Yt(te,["prevent"])},[h("div",pv,[lt(h("input",{"onUpdate:modelValue":O[2]||(O[2]=ce=>n.value=ce),type:"url",placeholder:"https://github.com/owner/repo.git","aria-label":"Git repository URL",disabled:i.value,class:"flex-1 bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm disabled:opacity-40 transition-all duration-200"},null,8,gv),[[yt,n.value]]),h("button",{type:"submit",disabled:i.value||n.value.trim()==="",class:"bg-accent/15 text-accent border border-accent/25 px-4 py-2 rounded-lg text-sm font-medium hover:bg-accent/25 hover:border-accent/40 disabled:opacity-30 disabled:cursor-not-allowed transition-all duration-150 whitespace-nowrap"},R(i.value?"Installing…":"Install"),9,mv)])],32)):(_(),w("form",{key:1,onSubmit:Yt(de,["prevent"])},[h("div",vv,[h("div",null,[lt(h("input",{"onUpdate:modelValue":O[3]||(O[3]=ce=>c.value=ce),type:"text",placeholder:"my-skill","aria-label":"Skill slug",disabled:d.value,class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm disabled:opacity-40 transition-all duration-200"},null,8,bv),[[yt,c.value]]),O[14]||(O[14]=h("p",{class:"text-[10px] text-txt-muted mt-1 ml-1"},"Unique identifier (lowercase, hyphens ok)",-1))]),lt(h("textarea",{"onUpdate:modelValue":O[4]||(O[4]=ce=>u.value=ce),placeholder:"Paste SKILL.md content here…","aria-label":"SKILL.md content",disabled:d.value,rows:"6",class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary font-mono placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm disabled:opacity-40 resize-y transition-all duration-200"},null,8,yv),[[yt,u.value]]),h("button",{type:"submit",disabled:d.value||c.value.trim()===""||u.value.trim()==="",class:"self-end bg-accent/15 text-accent border border-accent/25 px-4 py-2 rounded-lg text-sm font-medium hover:bg-accent/25 hover:border-accent/40 disabled:opacity-30 disabled:cursor-not-allowed transition-all duration-150"},R(d.value?"Installing…":"Install"),9,_v)])],32))]),a.value?(_(),w("div",wv,[O[15]||(O[15]=h("span",null,"✓",-1)),he(" "+R(a.value),1)])):Y("",!0),o.value?(_(),w("div",xv,[O[16]||(O[16]=h("span",null,"⚠",-1)),he(" "+R(o.value),1)])):Y("",!0),!s.value&&!r.value&&e.value.length>0?(_(),w("div",kv,[lt(h("input",{"onUpdate:modelValue":O[5]||(O[5]=ce=>N.value=ce),type:"search",placeholder:"Search skills…","aria-label":"Search skills",class:"w-full bg-surface-2/50 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,N.value]])])):Y("",!0),s.value?(_(),w("div",Sv,[...O[17]||(O[17]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading skills… ")],-1)])])):r.value?(_(),w("div",Ev,[O[18]||(O[18]=h("span",null,"⚠",-1)),he(" "+R(r.value),1)])):e.value.length===0?(_(),w("div",Tv," No skills installed yet ")):$.value.length===0?(_(),w("div",Av," No matching skills ")):(_(),w("div",Cv,[(_(!0),w(be,null,qe($.value,ce=>(_(),w("div",{key:ce.slug,onClick:ge=>E(ce),class:"group bg-surface-2/40 border border-edge rounded-xl p-4 hover:border-edge-bright hover:shadow-card-hover hover:bg-surface-2/70 transition-all duration-200 cursor-pointer"},[h("div",Ov,[h("div",$v,[h("h3",Pv,R(ce.name),1),h("p",Iv,R(ce.slug),1)]),h("button",{onClick:Yt(ge=>V(ce),["stop"]),class:"shrink-0 ml-2 p-1.5 rounded-lg text-txt-muted/0 group-hover:text-txt-muted hover:!text-red-400 hover:bg-red-500/10 transition-all duration-150",title:"Delete skill"},[...O[19]||(O[19]=[h("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"},[h("path",{d:"M2 4h12M5.333 4V2.667a1.333 1.333 0 011.334-1.334h2.666a1.333 1.333 0 011.334 1.334V4m2 0v9.333a1.333 1.333 0 01-1.334 1.334H4.667a1.333 1.333 0 01-1.334-1.334V4h9.334z"})],-1)])],8,jv)]),h("p",Nv,R(ce.description),1),h("p",Lv,R(ce.path),1)],8,Rv))),128))]))])]))]))}}),Dv=Hr(Uv,[["__scopeId","data-v-a63e75bb"]]),Mv={class:"flex flex-col h-full bg-surface-0"},Bv={class:"flex-1 overflow-y-auto p-6"},Hv={class:"max-w-4xl"},Fv={class:"flex justify-between items-end mb-6"},Vv={class:"space-y-3"},qv=["disabled"],Wv={key:0,class:"mt-3 flex items-center gap-2 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2"},Kv={key:1,class:"flex items-center justify-center py-16"},Gv={key:2,class:"flex items-center gap-2 bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg mb-4 text-sm"},zv={key:3,class:"text-txt-muted text-sm text-center py-16"},Jv={key:4,class:"grid gap-3"},Yv=["onClick","aria-expanded"],Xv={class:"flex justify-between items-start mb-2"},Zv={class:"flex-1 flex items-center gap-2.5"},Qv={class:"min-w-0"},eb={class:"font-semibold text-txt-primary text-sm"},tb={class:"text-[11px] text-txt-muted font-mono"},sb={class:"flex items-center gap-2 shrink-0"},rb={key:0,class:"px-2 py-0.5 rounded-md text-[10px] font-medium bg-purple-500/10 text-purple-300 border border-purple-500/20"},nb={class:"text-xs text-txt-muted font-mono ml-6"},ib={key:0,class:"border-t border-edge px-4 pb-4 pt-3 animate-fade-in"},ob={class:"flex justify-between items-center text-[10px] text-txt-muted mb-3"},ab={key:0,class:"font-mono"},lb={key:0,class:"flex items-center gap-2 text-txt-muted text-xs py-3"},cb={key:1,class:"text-red-400 text-xs py-2"},ub={key:2,class:"text-txt-muted text-xs italic py-2"},db={key:3,class:"space-y-1.5"},hb={class:"flex-1 min-w-0"},fb={class:"flex items-center gap-1.5"},pb={class:"text-sm font-medium text-txt-primary truncate"},gb={key:0,title:"Team Lead",class:"text-xs"},mb={key:1,title:"QA / Veto Power",class:"text-xs"},vb={class:"text-[10px] text-txt-muted"},bb={class:"flex items-center gap-1 shrink-0"},yb=["onClick"],_b=["onClick","disabled"],wb={class:"bg-surface-1 border border-edge rounded-xl w-full max-w-2xl max-h-[85vh] flex flex-col shadow-2xl animate-fade-in"},xb={class:"flex justify-between items-center px-5 py-3.5 border-b border-edge"},kb={class:"text-sm font-semibold text-txt-primary flex items-center gap-2"},Sb={class:"text-xs font-normal text-txt-muted"},Eb={class:"text-[10px] text-txt-muted mt-0.5 flex items-center gap-1.5"},Tb={class:"flex items-center gap-3"},Ab={class:"flex items-center gap-1.5 text-[10px] text-txt-muted cursor-pointer select-none"},Cb={key:0,class:"bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg text-sm"},Rb={key:1,class:"text-txt-muted italic text-center py-8"},Ob={class:"shrink-0"},$b={class:"flex-1 min-w-0"},Pb={class:"text-txt-secondary break-words"},Ib={class:"text-txt-muted text-[10px] ml-2"},jb={key:0,class:"text-txt-muted italic text-center py-4"},Nb={class:"flex justify-between items-center mb-1"},Lb={class:"text-accent"},Ub={class:"text-txt-muted text-[10px]"},Db={class:"text-txt-secondary whitespace-pre-wrap break-words"},Mb=gt({__name:"SquadsView",setup(t){const e=new Set(["system"]),s={"a-team":"The A-Team",transformers:"Transformers",thundercats:"ThunderCats","gi-joe":"G.I. Joe",aliens:"Aliens",ghostbusters:"Ghostbusters"},r=F([]),n=F(!0),i=F(null),o=F(!1),a=F(!1),l=F(null),c=zt({}),u=zt({});function d(T){return[...T].sort((C,K)=>{const le=Le=>Le.is_lead?0:Le.is_qa?1:2;return le(C)-le(K)})}const f=zt({}),p=zt({}),m=F(new Set),b=F(null),x=F([]),y=F(null),k=F(!1),A=F(!0),L=F(null);let N=null;const $=$e(()=>y.value?"Disconnected":k.value?"Live":"Connecting…"),E=$e(()=>x.value.filter(T=>!(!T.summary||e.has(T.summary.kind)||T.type==="assistant.message_delta"))),M=T=>{try{return new Date(T).toLocaleTimeString()}catch{return""}},B=T=>{const C=T.data;if(!C||typeof C!="object")return"";if(typeof C.deltaContent=="string")return C.deltaContent;if(typeof C.content=="string")return C.content;if(typeof C.text=="string")return C.text;try{return JSON.stringify(C,null,2)}catch{return String(C)}},te=()=>{Es(()=>{const T=L.value;T&&(T.scrollTop=T.scrollHeight)})},de=T=>{if(!T.currentTaskId)return;V(),b.value=T,x.value=[],y.value=null,k.value=!1,A.value=!0;const C=Gn(`/api/tasks/${encodeURIComponent(T.currentTaskId)}/events`),K=new EventSource(C);N=K,K.onopen=()=>{k.value=!0},K.onmessage=le=>{try{const Le=JSON.parse(le.data);x.value.push(Le),te()}catch{}},K.onerror=()=>{k.value=!1,x.value.length===0&&(y.value="Connection error. Retrying…")}},V=()=>{if(N){try{N.close()}catch{}N=null}b.value=null,x.value=[],y.value=null,k.value=!1};io(()=>{V()});const q=async(T,C)=>{if(!m.value.has(C)){m.value=new Set(m.value).add(C);try{await ke(`/api/tasks/${encodeURIComponent(C)}/cancel`,{method:"POST"}),await We(T,!0)}catch(K){p[T]=K instanceof Error?K.message:"Failed to stop task"}finally{const K=new Set(m.value);K.delete(C),m.value=K}}},O=F({slug:"",name:"",projectPath:""}),ce=T=>T?s[T]??T:"",ge=T=>new Date(T).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),ie=T=>!!c[T],me=async T=>{c[T]=!c[T],c[T]&&!u[T]&&!f[T]&&await We(T)},We=async(T,C=!1)=>{if(!(!C&&f[T])){f[T]=!0,p[T]=null;try{const K=await ke(`/api/squads/${encodeURIComponent(T)}/agents`);if(!K.ok)throw new Error(`HTTP error! status: ${K.status}`);const le=await K.json();u[T]=le.agents}catch(K){p[T]=K instanceof Error?K.message:"Failed to load agents"}finally{f[T]=!1}}},Xe=async()=>{try{const T=await ke("/api/squads");if(!T.ok)throw new Error(`HTTP error! status: ${T.status}`);const C=await T.json();r.value=C.squads}catch(T){i.value=T instanceof Error?T.message:"Failed to load squads"}finally{n.value=!1}},H=async()=>{if(!O.value.slug||!O.value.name||!O.value.projectPath){l.value="All fields are required";return}a.value=!0,l.value=null;try{const T=await ke("/api/squads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:O.value.slug,name:O.value.name,projectPath:O.value.projectPath})});if(!T.ok)throw new Error(`HTTP error! status: ${T.status}`);O.value={slug:"",name:"",projectPath:""},o.value=!1,await Xe()}catch(T){l.value=T instanceof Error?T.message:"Failed to create squad"}finally{a.value=!1}};return ts(()=>{Xe()}),(T,C)=>(_(),w("div",Mv,[h("div",Bv,[h("div",Hv,[h("div",Fv,[C[5]||(C[5]=h("div",null,[h("h2",{class:"text-xl font-bold text-txt-primary tracking-tight"},"Squads"),h("p",{class:"text-xs text-txt-muted mt-0.5"},"Manage teams and monitor agents")],-1)),h("button",{onClick:C[0]||(C[0]=K=>o.value=!o.value),class:fe(["px-3.5 py-2 rounded-lg text-sm font-medium transition-all duration-150",o.value?"bg-surface-3/50 text-txt-secondary border border-edge hover:bg-surface-3/70":"bg-accent/15 text-accent border border-accent/25 hover:bg-accent/25 hover:border-accent/40"])},R(o.value?"Cancel":"New Squad"),3)]),o.value?(_(),w("form",{key:0,onSubmit:Yt(H,["prevent"]),class:"bg-surface-2/40 border border-edge rounded-xl p-5 mb-6 animate-fade-in"},[C[7]||(C[7]=h("h3",{class:"font-semibold text-txt-primary text-sm mb-4"},"Create New Squad",-1)),h("div",Vv,[lt(h("input",{"onUpdate:modelValue":C[1]||(C[1]=K=>O.value.slug=K),type:"text",placeholder:"Squad slug (e.g., frontend-team)",class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,O.value.slug]]),lt(h("input",{"onUpdate:modelValue":C[2]||(C[2]=K=>O.value.name=K),type:"text",placeholder:"Squad name (e.g., Frontend Team)",class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,O.value.name]]),lt(h("input",{"onUpdate:modelValue":C[3]||(C[3]=K=>O.value.projectPath=K),type:"text",placeholder:"Project path (e.g., /path/to/project)",class:"w-full bg-surface-1/80 border border-edge rounded-lg px-3 py-2 text-sm text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,O.value.projectPath]]),h("button",{type:"submit",disabled:a.value||!O.value.slug||!O.value.name||!O.value.projectPath,class:"w-full bg-accent/15 text-accent border border-accent/25 px-4 py-2 rounded-lg text-sm font-medium hover:bg-accent/25 hover:border-accent/40 disabled:opacity-30 disabled:cursor-not-allowed transition-all duration-150"},R(a.value?"Creating…":"Create Squad"),9,qv)]),l.value?(_(),w("div",Wv,[C[6]||(C[6]=h("span",null,"⚠",-1)),he(" "+R(l.value),1)])):Y("",!0)],32)):Y("",!0),n.value?(_(),w("div",Kv,[...C[8]||(C[8]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading squads… ")],-1)])])):i.value?(_(),w("div",Gv,[C[9]||(C[9]=h("span",null,"⚠",-1)),he(" "+R(i.value),1)])):r.value.length===0?(_(),w("div",zv," No squads created yet ")):(_(),w("div",Jv,[(_(!0),w(be,null,qe(r.value,K=>(_(),w("div",{key:K.id,class:"bg-surface-2/40 border border-edge rounded-xl overflow-hidden hover:border-edge-bright transition-all duration-200"},[h("button",{type:"button",onClick:le=>me(K.slug),class:"w-full text-left p-4 focus:outline-none","aria-expanded":ie(K.slug)},[h("div",Xv,[h("div",Zv,[(_(),w("svg",{xmlns:"http://www.w3.org/2000/svg",class:fe(["w-3.5 h-3.5 text-txt-muted transition-transform duration-200 shrink-0",ie(K.slug)?"rotate-90":""]),viewBox:"0 0 16 16",fill:"currentColor"},[...C[10]||(C[10]=[h("path",{d:"M6 3l5 5-5 5z"},null,-1)])],2)),h("div",Qv,[h("h3",eb,R(K.name),1),h("p",tb,R(K.slug),1)])]),h("div",sb,[K.universe?(_(),w("span",rb," 🎬 "+R(ce(K.universe)),1)):Y("",!0),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium",K.status==="working"?"bg-accent/10 text-accent border border-accent/20":K.status==="error"?"bg-red-500/10 text-red-400 border border-red-500/20":"bg-surface-3/60 text-txt-muted border border-edge"])},[h("span",{class:fe(["w-1.5 h-1.5 rounded-full",K.status==="working"?"bg-accent animate-pulse":K.status==="error"?"bg-red-400":"bg-txt-muted/50"])},null,2),he(" "+R(K.status),1)],2)])]),h("p",nb,"📁 "+R(K.project_path),1)],8,Yv),ie(K.slug)?(_(),w("div",ib,[h("div",ob,[K.model?(_(),w("span",ab,"Model: "+R(K.model),1)):Y("",!0),h("span",null,R(ge(K.created_at)),1)]),C[14]||(C[14]=h("h4",{class:"text-xs font-semibold text-txt-secondary uppercase tracking-wider mb-2"},"Team Roster",-1)),f[K.slug]?(_(),w("div",lb,[...C[11]||(C[11]=[h("span",{class:"w-3 h-3 border-2 border-edge border-t-accent rounded-full animate-spin"},null,-1),he(" Loading agents… ",-1)])])):p[K.slug]?(_(),w("div",cb,R(p[K.slug]),1)):!u[K.slug]||u[K.slug].length===0?(_(),w("div",ub," No agents assigned yet ")):(_(),w("ul",db,[(_(!0),w(be,null,qe(d(u[K.slug]??[]),le=>(_(),w("li",{key:le.id??le.character_name,class:fe(["flex items-center gap-3 rounded-lg px-3 py-2 transition-all duration-150",le.status==="working"?"bg-accent/[0.06] border border-accent/15":"bg-surface-1/50 border border-edge"])},[h("div",{class:fe(["w-7 h-7 rounded-full flex items-center justify-center shrink-0 text-[10px] font-bold",le.status==="working"?"bg-accent/15 text-accent border border-accent/25":le.status==="error"?"bg-red-500/15 text-red-400 border border-red-500/25":"bg-surface-3/60 text-txt-muted border border-edge"])},R((le.character_name??"?").charAt(0).toUpperCase()),3),h("div",hb,[h("div",fb,[h("span",pb,R(le.character_name),1),le.is_lead?(_(),w("span",gb,"👑")):Y("",!0),le.is_qa?(_(),w("span",mb,"🛡️")):Y("",!0)]),h("span",vb,R(le.role_title),1)]),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0",le.status==="working"?"bg-accent/10 text-accent":le.status==="error"?"bg-red-500/10 text-red-400":"bg-surface-3/40 text-txt-muted"])},[h("span",{class:fe(["w-1.5 h-1.5 rounded-full",le.status==="working"?"bg-accent animate-pulse":le.status==="error"?"bg-red-400":"bg-emerald-400"])},null,2),he(" "+R(le.status),1)],2),h("div",bb,[le.status==="working"&&le.currentTaskId?(_(),w("button",{key:0,type:"button",onClick:Le=>de(le),class:"text-[10px] font-medium px-2 py-1 rounded-md bg-accent/10 text-accent border border-accent/20 hover:bg-accent/20 transition-all duration-150 flex items-center gap-1",title:"Preview live work"},[...C[12]||(C[12]=[h("span",{"aria-hidden":"true"},"👁",-1),he(" Preview ",-1)])],8,yb)):Y("",!0),le.status==="working"&&le.currentTaskId?(_(),w("button",{key:1,type:"button",onClick:Le=>q(K.slug,le.currentTaskId),disabled:m.value.has(le.currentTaskId),class:"text-[10px] font-medium px-2 py-1 rounded-md bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 disabled:opacity-40 transition-all duration-150 flex items-center gap-1",title:"Stop task"},[C[13]||(C[13]=h("span",{class:"w-2 h-2 rounded-[2px] bg-red-400"},null,-1)),he(" "+R(m.value.has(le.currentTaskId)?"Stopping…":"Stop"),1)],8,_b)):Y("",!0)])],2))),128))]))])):Y("",!0)]))),128))]))])]),b.value?(_(),w("div",{key:0,class:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4 z-50",onClick:Yt(V,["self"])},[h("div",wb,[h("div",xb,[h("div",null,[h("h3",kb,[he(R(b.value.character_name)+" ",1),h("span",Sb,"— "+R(b.value.role_title),1)]),h("p",Eb,[h("span",{class:fe(["inline-block w-1.5 h-1.5 rounded-full",k.value?"bg-emerald-400 animate-pulse":"bg-txt-muted/50"])},null,2),he(" "+R($.value),1)])]),h("div",Tb,[h("label",Ab,[lt(h("input",{type:"checkbox","onUpdate:modelValue":C[4]||(C[4]=K=>A.value=K),class:"rounded bg-surface-3 border-edge accent-accent"},null,512),[[_c,A.value]]),C[15]||(C[15]=he(" Summary ",-1))]),h("button",{type:"button",onClick:V,class:"text-txt-muted hover:text-txt-primary text-lg leading-none transition-colors p-1","aria-label":"Close"},"×")])]),h("div",{ref_key:"previewScrollEl",ref:L,class:"overflow-y-auto p-4 space-y-2 flex-1 font-mono text-xs"},[y.value?(_(),w("div",Cb,R(y.value),1)):x.value.length===0?(_(),w("div",Rb," Waiting for activity… ")):A.value?(_(),w(be,{key:2},[(_(!0),w(be,null,qe(E.value,(K,le)=>(_(),w("div",{key:le,class:"flex items-start gap-2 py-1.5 px-1"},[h("span",Ob,R(K.summary.icon),1),h("div",$b,[h("span",Pb,R(K.summary.summary),1),h("span",Ib,R(M(K.ts)),1)])]))),128)),E.value.length===0?(_(),w("div",jb," Processing… ")):Y("",!0)],64)):(_(!0),w(be,{key:3},qe(x.value,(K,le)=>(_(),w("div",{key:le,class:"border border-edge rounded-lg p-2.5 bg-surface-0"},[h("div",Nb,[h("span",Lb,R(K.type),1),h("span",Ub,R(M(K.ts)),1)]),h("pre",Db,R(B(K)),1)]))),128))],512),h("div",{class:"px-4 py-3 border-t border-edge flex justify-end"},[h("button",{type:"button",onClick:V,class:"bg-surface-3/50 hover:bg-surface-3/70 text-txt-secondary text-sm px-4 py-1.5 rounded-lg border border-edge transition-all duration-150"}," Close ")])])])):Y("",!0)]))}}),Bb={class:"flex flex-col h-full bg-surface-0"},Hb={class:"flex-1 overflow-y-auto p-6"},Fb={class:"max-w-4xl"},Vb={class:"flex justify-between items-end mb-6"},qb=["disabled"],Wb={key:0,class:"flex items-center gap-2 bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg mb-6 text-sm"},Kb={class:"mb-8"},Gb={key:0,class:"flex items-center justify-center py-10"},zb={key:1,class:"text-txt-muted text-sm text-center py-10"},Jb={key:2,class:"grid gap-3"},Yb={class:"flex justify-between items-start mb-2.5"},Xb={class:"flex items-center gap-3 min-w-0"},Zb={class:"min-w-0"},Qb={class:"font-semibold text-txt-primary text-sm"},ey={class:"flex items-center gap-1.5 mt-0.5 flex-wrap"},ty={class:"text-[10px] text-txt-muted font-mono"},sy={key:0,class:"text-[10px] text-txt-secondary bg-surface-3/50 px-1.5 py-0.5 rounded border border-edge"},ry={key:1,class:"text-[10px] text-purple-300 bg-purple-500/10 px-1.5 py-0.5 rounded border border-purple-500/20"},ny=["title"],iy={key:0,class:"bg-surface-0/60 border border-edge rounded-lg p-3 mb-2.5 ml-12"},oy={class:"text-sm text-txt-primary break-words"},ay={class:"flex justify-between items-center ml-12"},ly={class:"text-[10px] text-txt-muted"},cy=["onClick","disabled"],uy={key:0,class:"flex items-center justify-center py-10"},dy={key:1,class:"text-txt-muted text-sm text-center py-10"},hy={key:2,class:"relative"},fy={class:"space-y-1"},py=["onClick"],gy={class:"flex justify-between items-start gap-3"},my={class:"min-w-0 flex-1"},vy={class:"flex items-center gap-2 mb-0.5"},by={class:"text-sm font-medium text-txt-primary truncate group-hover:text-accent transition-colors"},yy={key:0,class:"text-[10px] text-txt-muted bg-surface-3/40 px-1.5 py-0.5 rounded border border-edge"},_y={class:"text-xs text-txt-secondary truncate"},wy={class:"text-[10px] text-txt-muted mt-1"},xy={key:0},ky={key:0,class:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse"},Sy={class:"bg-surface-1 border border-edge rounded-xl w-full max-w-2xl max-h-[85vh] flex flex-col shadow-2xl animate-fade-in"},Ey={class:"overflow-y-auto p-5 space-y-4"},Ty={key:0,class:"flex items-center justify-center py-10"},Ay={key:1,class:"bg-red-500/10 text-red-400 border border-red-500/20 p-3 rounded-lg text-sm"},Cy={class:"flex justify-between items-start gap-3"},Ry={class:"text-sm text-txt-primary font-medium"},Oy={key:0,class:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse"},$y={class:"text-[11px] text-txt-muted font-mono break-all bg-surface-0/60 px-2 py-1 rounded border border-edge"},Py={key:0},Iy={class:"text-sm text-txt-secondary"},jy={class:"grid grid-cols-2 gap-4"},Ny={class:"text-sm text-txt-secondary"},Ly={class:"text-sm text-txt-secondary"},Uy={key:1},Dy={class:"text-sm text-accent font-mono"},My={class:"text-sm text-txt-primary bg-surface-0/60 border border-edge rounded-lg p-3 whitespace-pre-wrap break-words font-sans"},By={class:"flex justify-between items-center mb-2"},Hy={class:"flex items-center gap-1.5 text-[10px] text-txt-muted cursor-pointer select-none"},Fy={key:0,class:"text-sm text-txt-muted italic"},Vy={key:1,class:"text-sm text-txt-muted italic"},qy={key:2,class:"bg-surface-0/60 border border-edge rounded-lg divide-y divide-edge max-h-96 overflow-y-auto"},Wy=["onClick"],Ky={class:"shrink-0"},Gy={class:"flex-1 break-words"},zy={class:"text-[10px] text-txt-muted shrink-0"},Jy={key:0,class:"mt-2 pl-6 space-y-1"},Yy={key:0,class:"text-xs text-txt-secondary bg-surface-1 border border-edge rounded-lg p-2 whitespace-pre-wrap break-words font-mono"},Xy={class:"text-[11px] text-txt-muted bg-surface-1 border border-edge rounded-lg p-2 whitespace-pre-wrap break-words font-mono max-h-48 overflow-y-auto"},Zy={class:"text-[10px] text-txt-muted font-mono"},Qy={key:0,class:"text-sm text-txt-primary bg-surface-0/60 border border-edge rounded-lg p-3 whitespace-pre-wrap break-words font-mono max-h-96 overflow-y-auto"},e_={key:1,class:"text-sm text-txt-muted italic"},t_={class:"px-5 py-3 border-t border-edge flex justify-between items-center"},s_=["disabled"],r_={key:1},n_=gt({__name:"AgentActivityView",setup(t){const e=F([]),s=F([]),r=F(!0),n=F(null),i=F(new Set),o=F(null),a=F(null),l=F(!1),c=F(null),u=F([]),d=F(!1),f=F(!1),p=F(new Set);let m=null,b=null,x=null;const y=H=>H.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),k=H=>{if(!H)return"";const T=H.includes("T")?H:H.replace(" ","T")+"Z",C=new Date(T);return Number.isNaN(C.getTime())?H:C.toLocaleString()},A=H=>{switch(H){case"running":return"bg-accent/10 text-accent border border-accent/20";case"done":return"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20";case"failed":return"bg-red-500/10 text-red-400 border border-red-500/20";case"cancelled":return"bg-amber-500/10 text-amber-400 border border-amber-500/20";default:return"bg-surface-3/50 text-txt-muted border border-edge"}},L=$e(()=>{if(!a.value)return null;const H=a.value.started_at,T=a.value.completed_at;if(!H||!T)return null;const C=new Date(H.includes("T")?H:H.replace(" ","T")+"Z").getTime(),K=new Date(T.includes("T")?T:T.replace(" ","T")+"Z").getTime();if(Number.isNaN(C)||Number.isNaN(K))return null;const le=Math.max(0,Math.round((K-C)/1e3));if(le<60)return`${le}s`;const Le=Math.floor(le/60),I=le%60;return`${Le}m ${I}s`}),N=async H=>{if(!i.value.has(H)){i.value=new Set(i.value).add(H);try{await ke(`/api/tasks/${encodeURIComponent(H)}/cancel`,{method:"POST"}),await M(),o.value===H&&await B(H)}catch(T){n.value=T instanceof Error?T.message:"Failed to stop task"}finally{const T=new Set(i.value);T.delete(H),i.value=T}}},$=async()=>{try{const H=await ke("/api/agents");if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);const T=await H.json();e.value=T.agents}catch(H){n.value=H instanceof Error?H.message:"Failed to load agents"}},E=async()=>{try{const H=await ke("/api/tasks?limit=50");if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);const T=await H.json();s.value=T.tasks}catch(H){n.value=H instanceof Error?H.message:"Failed to load tasks"}},M=async()=>{r.value=!0,n.value=null;try{await Promise.all([$(),E()])}finally{r.value=!1}},B=async H=>{l.value=!0,c.value=null;try{const T=await ke(`/api/tasks/${encodeURIComponent(H)}`);if(!T.ok)throw new Error(`HTTP error! status: ${T.status}`);const C=await T.json();a.value=C.task}catch(T){c.value=T instanceof Error?T.message:"Failed to load task",a.value=null}finally{l.value=!1}},te=H=>{if(!H)return"";const T=new Date(H);return Number.isNaN(T.getTime())?"":T.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})},de=H=>{try{return JSON.stringify(H,null,2)}catch{return String(H)}},V=H=>{if(H.status==="success")return"text-emerald-300";if(H.status==="error")return"text-red-300";if(H.status==="pending")return"text-accent";switch(H.kind){case"message":return"text-txt-primary";case"reasoning":return"text-purple-300";case"tool":return"text-blue-300";case"outcome":return"text-amber-300";default:return"text-txt-secondary"}},q=H=>{if(f.value)return;const T=new Set(p.value);T.has(H)?T.delete(H):T.add(H),p.value=T},O=async(H,T={})=>{T.initial&&(d.value=!0);try{const C=await ke(`/api/tasks/${encodeURIComponent(H)}/activity`);if(!C.ok)return;const K=await C.json();u.value=K.activity??[]}catch{}finally{T.initial&&(d.value=!1)}},ce=H=>{b||(b=setTimeout(()=>{b=null,o.value===H&&O(H)},250))},ge=H=>{ie(),O(H,{initial:!0});try{m=new EventSource(Gn(`/api/tasks/${encodeURIComponent(H)}/events`)),m.onmessage=()=>{ce(H)},m.onerror=()=>{}}catch{m=null}},ie=()=>{m&&(m.close(),m=null),b&&(clearTimeout(b),b=null)},me=H=>{o.value=H,a.value=null,u.value=[],p.value=new Set,B(H),ge(H)},We=()=>{o.value=null,a.value=null,c.value=null,u.value=[],p.value=new Set,ie()},Xe=H=>{H.key==="Escape"&&o.value&&We()};return us(o,H=>{H?document.addEventListener("keydown",Xe):document.removeEventListener("keydown",Xe)}),ts(()=>{M(),x=setInterval(M,5e3)}),us(()=>{var H;return(H=a.value)==null?void 0:H.status},H=>{H&&H!=="running"&&(o.value&&O(o.value),ie())}),Nn(()=>{x&&clearInterval(x),document.removeEventListener("keydown",Xe),ie()}),(H,T)=>(_(),w("div",Bb,[h("div",Hb,[h("div",Fb,[h("div",Vb,[T[2]||(T[2]=h("div",null,[h("h2",{class:"text-xl font-bold text-txt-primary tracking-tight"},"Activity"),h("p",{class:"text-xs text-txt-muted mt-0.5"},"Monitor agents and recent tasks")],-1)),h("button",{onClick:M,disabled:r.value,class:"px-3.5 py-2 rounded-lg text-sm font-medium transition-all duration-150 bg-accent/15 text-accent border border-accent/25 hover:bg-accent/25 hover:border-accent/40 disabled:opacity-30 disabled:cursor-not-allowed"},R(r.value?"Refreshing…":"Refresh"),9,qb)]),n.value?(_(),w("div",Wb,[T[3]||(T[3]=h("span",null,"⚠",-1)),he(" "+R(n.value),1)])):Y("",!0),h("section",Kb,[T[7]||(T[7]=h("h3",{class:"text-xs font-semibold text-txt-secondary uppercase tracking-wider mb-3"},"Active Agents",-1)),r.value&&e.value.length===0?(_(),w("div",Gb,[...T[4]||(T[4]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading agents… ")],-1)])])):e.value.length===0?(_(),w("div",zb," No active agents ")):(_(),w("div",Jb,[(_(!0),w(be,null,qe(e.value,C=>(_(),w("div",{key:C.slug+(C.characterName||""),class:fe(["group bg-surface-2/40 border rounded-xl p-4 transition-all duration-200",C.status==="working"?"border-accent/20 hover:border-accent/35":"border-edge hover:border-edge-bright"])},[h("div",Yb,[h("div",Xb,[h("div",{class:fe(["w-9 h-9 rounded-xl flex items-center justify-center shrink-0 text-xs font-bold",C.status==="working"?"bg-accent/15 text-accent border border-accent/25":C.status==="error"?"bg-red-500/15 text-red-400 border border-red-500/25":"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20"])},R((C.name??"?").charAt(0).toUpperCase()),3),h("div",Zb,[h("h3",Qb,R(C.name),1),h("div",ey,[h("span",ty,R(C.slug),1),C.roleTitle?(_(),w("span",sy,R(C.roleTitle),1)):Y("",!0),C.universe?(_(),w("span",ry," 🎬 "+R(C.universe),1)):Y("",!0),C.model&&C.status==="working"?(_(),w("span",{key:2,class:"text-[10px] text-emerald-300 bg-emerald-500/10 px-1.5 py-0.5 rounded border border-emerald-500/20",title:`Model: ${C.model}`}," 🧠 "+R(C.model),9,ny)):Y("",!0)])])]),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0",C.status==="working"?"bg-accent/10 text-accent border border-accent/20":C.status==="error"?"bg-red-500/10 text-red-400 border border-red-500/20":"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20"])},[h("span",{class:fe(["w-1.5 h-1.5 rounded-full",C.status==="working"?"bg-accent animate-pulse":C.status==="error"?"bg-red-400":"bg-emerald-400"])},null,2),he(" "+R(C.status==="working"?"Working":C.status==="error"?"Error":"Idle"),1)],2)]),C.currentTask?(_(),w("div",iy,[T[5]||(T[5]=h("p",{class:"text-[10px] text-txt-muted uppercase tracking-wider mb-1"},"Current Task",-1)),h("p",oy,R(C.currentTask),1)])):Y("",!0),h("div",ay,[h("div",ly," Last updated: "+R(y(new Date)),1),C.status==="working"&&C.currentTaskId?(_(),w("button",{key:0,type:"button",onClick:K=>N(C.currentTaskId),disabled:i.value.has(C.currentTaskId),class:"text-[10px] font-medium px-2.5 py-1 rounded-md bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 disabled:opacity-40 transition-all duration-150 flex items-center gap-1",title:"Stop task"},[T[6]||(T[6]=h("span",{class:"w-2 h-2 rounded-[2px] bg-red-400"},null,-1)),he(" "+R(i.value.has(C.currentTaskId)?"Stopping…":"Stop"),1)],8,cy)):Y("",!0)])],2))),128))]))]),h("section",null,[T[10]||(T[10]=h("h3",{class:"text-xs font-semibold text-txt-secondary uppercase tracking-wider mb-3"},"Recent Activity",-1)),r.value&&s.value.length===0?(_(),w("div",uy,[...T[8]||(T[8]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading activity… ")],-1)])])):s.value.length===0?(_(),w("div",dy," No recent activity yet ")):(_(),w("div",hy,[T[9]||(T[9]=h("div",{class:"absolute left-[15px] top-0 bottom-0 w-px bg-gradient-to-b from-accent/30 via-edge to-transparent"},null,-1)),h("div",fy,[(_(!0),w(be,null,qe(s.value,C=>(_(),w("button",{key:C.task_id,type:"button",onClick:K=>me(C.task_id),class:"w-full text-left relative pl-10 pr-4 py-3 rounded-lg hover:bg-surface-2/40 transition-all duration-150 group"},[h("div",{class:fe(["absolute left-[11px] top-4 w-[9px] h-[9px] rounded-full border-2 z-10",C.status==="running"?"bg-accent border-accent shadow-glow-sm":C.status==="done"?"bg-emerald-400 border-emerald-400":C.status==="failed"?"bg-red-400 border-red-400":C.status==="cancelled"?"bg-amber-400 border-amber-400":"bg-surface-3 border-edge"])},null,2),h("div",gy,[h("div",my,[h("div",vy,[h("span",by,R(C.agent_slug),1),C.origin_channel?(_(),w("span",yy,"via "+R(C.origin_channel),1)):Y("",!0)]),h("p",_y,R(C.description),1),h("p",wy,[he(R(k(C.started_at))+" ",1),C.completed_at?(_(),w("span",xy," · "+R(k(C.completed_at)),1)):Y("",!0)])]),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0",A(C.status)])},[C.status==="running"?(_(),w("span",ky)):Y("",!0),he(" "+R(C.status),1)],2)])],8,py))),128))])]))])])]),o.value?(_(),w("div",{key:0,class:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4 z-50",onClick:Yt(We,["self"])},[h("div",Sy,[h("div",{class:"flex justify-between items-center px-5 py-3.5 border-b border-edge"},[T[11]||(T[11]=h("h3",{class:"text-sm font-semibold text-txt-primary"},"Task Details",-1)),h("button",{type:"button",onClick:We,class:"text-txt-muted hover:text-txt-primary text-lg leading-none transition-colors p-1","aria-label":"Close"},"×")]),h("div",Ey,[l.value?(_(),w("div",Ty,[...T[12]||(T[12]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading task… ")],-1)])])):c.value?(_(),w("div",Ay,R(c.value),1)):a.value?(_(),w(be,{key:2},[h("div",Cy,[h("div",null,[T[13]||(T[13]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Agent",-1)),h("p",Ry,R(a.value.agent_slug),1)]),h("span",{class:fe(["flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium",A(a.value.status)])},[a.value.status==="running"?(_(),w("span",Oy)):Y("",!0),he(" "+R(a.value.status),1)],2)]),h("div",null,[T[14]||(T[14]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Task ID",-1)),h("p",$y,R(a.value.task_id),1)]),a.value.origin_channel?(_(),w("div",Py,[T[15]||(T[15]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Origin",-1)),h("p",Iy,R(a.value.origin_channel),1)])):Y("",!0),h("div",jy,[h("div",null,[T[16]||(T[16]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Started",-1)),h("p",Ny,R(k(a.value.started_at)),1)]),h("div",null,[T[17]||(T[17]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Completed",-1)),h("p",Ly,R(a.value.completed_at?k(a.value.completed_at):"—"),1)])]),L.value?(_(),w("div",Uy,[T[18]||(T[18]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Duration",-1)),h("p",Dy,R(L.value),1)])):Y("",!0),h("div",null,[T[19]||(T[19]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Description",-1)),h("pre",My,R(a.value.description),1)]),h("div",null,[h("div",By,[T[21]||(T[21]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted"},"Activity",-1)),h("label",Hy,[lt(h("input",{type:"checkbox","onUpdate:modelValue":T[0]||(T[0]=C=>f.value=C),class:"rounded bg-surface-3 border-edge accent-accent"},null,512),[[_c,f.value]]),T[20]||(T[20]=he(" Show details ",-1))])]),d.value&&u.value.length===0?(_(),w("div",Fy,"Loading activity…")):u.value.length===0?(_(),w("div",Vy,"No activity yet")):(_(),w("ul",qy,[(_(!0),w(be,null,qe(u.value,(C,K)=>(_(),w("li",{key:`${C.ts}-${K}-${C.rawType}`,class:"px-3 py-2 text-sm hover:bg-surface-2/40 cursor-pointer transition-colors",onClick:le=>q(K)},[h("div",{class:fe(["flex items-start gap-2",V(C)])},[h("span",Ky,R(C.icon),1),h("span",Gy,R(C.summary),1),h("span",zy,R(te(C.ts)),1)],2),f.value||p.value.has(K)?(_(),w("div",Jy,[C.detail?(_(),w("pre",Yy,R(C.detail),1)):Y("",!0),h("pre",Xy,R(de(C.raw)),1),h("p",Zy,R(C.rawType),1)])):Y("",!0)],8,Wy))),128))]))]),h("div",null,[T[22]||(T[22]=h("p",{class:"text-[10px] uppercase tracking-widest text-txt-muted mb-0.5"},"Result",-1)),a.value.result?(_(),w("pre",Qy,R(a.value.result),1)):(_(),w("p",e_,"No result yet"))])],64)):Y("",!0)]),h("div",t_,[a.value&&a.value.status==="running"?(_(),w("button",{key:0,type:"button",onClick:T[1]||(T[1]=C=>N(a.value.task_id)),disabled:i.value.has(a.value.task_id),class:"text-xs font-medium px-3 py-1.5 rounded-lg bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 disabled:opacity-40 transition-all duration-150"},R(i.value.has(a.value.task_id)?"Stopping…":"Stop Task"),9,s_)):(_(),w("span",r_)),h("button",{type:"button",onClick:We,class:"bg-surface-3/50 hover:bg-surface-3/70 text-txt-secondary text-sm px-4 py-1.5 rounded-lg border border-edge transition-all duration-150"}," Close ")])])])):Y("",!0)]))}}),i_={class:"flex flex-col h-full"},o_={class:"flex-1 overflow-y-auto p-6"},a_={class:"flex justify-between items-center mb-6"},l_=["disabled"],c_={key:0,class:"flex items-center justify-center py-16"},u_={key:1,class:"bg-red-500/10 border border-red-500/20 text-red-400 p-4 rounded-xl mb-4 text-sm"},d_={open:"",class:"mb-8 group/section"},h_={class:"cursor-pointer select-none flex items-center gap-3 text-sm font-semibold text-txt-primary mb-4 py-2"},f_={class:"text-[10px] font-mono text-txt-muted bg-surface-2 px-2 py-0.5 rounded-full border border-edge"},p_={key:0,class:"flex flex-col items-center py-8"},g_={key:1,class:"grid gap-3"},m_={class:"flex flex-wrap items-start gap-3"},v_={class:"flex-1 min-w-0"},b_={class:"flex flex-wrap items-center gap-2 mb-1.5"},y_={class:"font-semibold text-txt-primary break-words min-w-0"},__={key:0,class:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"},w_={class:"flex flex-wrap items-center gap-3 text-xs text-txt-muted mt-1"},x_={class:"font-mono text-accent/80 bg-surface-0/60 px-2 py-0.5 rounded-lg border border-edge/50 break-all"},k_={key:0,class:"flex items-center gap-1 shrink-0"},S_={key:1,class:"flex items-center gap-1 shrink-0"},E_={key:0,class:"text-xs text-txt-muted mt-1.5 break-words"},T_={class:"flex flex-wrap items-center gap-1.5"},A_=["onClick","disabled"],C_=["onClick","disabled"],R_=["onClick","disabled"],O_=["onClick"],$_=["onClick","disabled"],P_={key:0,class:"mt-3"},I_=["onClick"],j_={key:1,class:"mt-4 pt-4 border-t border-edge/50"},N_={class:"text-[10px] font-semibold text-txt-muted uppercase tracking-widest mb-3"},L_={key:0,class:"flex items-center gap-2 text-txt-muted text-xs py-2 justify-center"},U_={key:1,class:"text-txt-muted text-xs py-2 text-center"},D_={key:2,class:"space-y-1.5"},M_={class:"flex-1 min-w-0"},B_={class:"flex flex-wrap items-center gap-2"},H_={class:"text-txt-secondary"},F_={key:0,class:"text-txt-muted mt-0.5"},V_={key:1,class:"text-red-400 mt-1 break-words bg-red-500/5 rounded px-2 py-1 border border-red-500/10"},q_={open:"",class:"group/section"},W_={class:"cursor-pointer select-none flex items-center gap-3 text-sm font-semibold text-txt-primary mb-4 py-2"},K_={class:"text-[10px] font-mono text-txt-muted bg-surface-2 px-2 py-0.5 rounded-full border border-edge"},G_={key:0,class:"flex flex-col items-center py-8"},z_={key:1,class:"grid gap-3"},J_={class:"flex flex-wrap items-start gap-3"},Y_={class:"flex-1 min-w-0"},X_={class:"flex flex-wrap items-center gap-2 mb-1.5"},Z_={class:"font-semibold text-txt-primary break-words min-w-0"},Q_={class:"text-[10px] font-mono text-accent/60 bg-accent/5 px-2 py-0.5 rounded-full border border-accent/10 shrink-0"},ew={key:0,class:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"},tw={class:"flex flex-wrap items-center gap-3 text-xs text-txt-muted mt-1"},sw={class:"font-mono text-accent/80 bg-surface-0/60 px-2 py-0.5 rounded-lg border border-edge/50 break-all"},rw={key:0,class:"flex items-center gap-1 shrink-0"},nw={key:1,class:"flex items-center gap-1 shrink-0"},iw={key:0,class:"text-xs text-txt-muted mt-1.5 break-words"},ow={class:"flex flex-wrap items-center gap-1.5"},aw=["onClick","disabled"],lw=["onClick","disabled"],cw=["onClick","disabled"],uw=["onClick"],dw=["onClick","disabled"],hw={key:0,class:"mt-3"},fw=["onClick"],pw={key:1,class:"mt-4 pt-4 border-t border-edge/50"},gw={class:"text-[10px] font-semibold text-txt-muted uppercase tracking-widest mb-3"},mw={key:0,class:"flex items-center gap-2 text-txt-muted text-xs py-2 justify-center"},vw={key:1,class:"text-txt-muted text-xs py-2 text-center"},bw={key:2,class:"space-y-1.5"},yw={class:"flex-1 min-w-0"},_w={class:"flex flex-wrap items-center gap-2"},ww={class:"text-txt-secondary"},xw={key:0,class:"text-txt-muted mt-0.5"},kw={key:1,class:"text-red-400 mt-1 break-words bg-red-500/5 rounded px-2 py-1 border border-red-500/10"},Sw=gt({__name:"SchedulesView",setup(t){const e=F([]),s=F([]),r=F(!0),n=F(null),i=F(new Set),o=F(new Map),a=F(new Map),l=F(new Set),c=F(new Set);function u(N){const $=N.includes("T")||N.endsWith("Z")?N:N.replace(" ","T")+"Z";return new Date($).toLocaleString()}function d(N){return N==="done"?"bg-emerald-400":N==="failed"?"bg-red-400":"bg-accent animate-pulse"}function f(N){return N==="done"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":N==="failed"?"bg-red-500/10 text-red-400 border-red-500/20":"bg-accent/10 text-accent border-accent/20"}function p(N,$){const E=`${N}-${$}`,M=new Set(c.value);M.has(E)?M.delete(E):M.add(E),c.value=M}async function m(N,$){const E=`${N}-${$}`,M=o.value.get(E)??!1,B=new Map(o.value);if(B.set(E,!M),o.value=B,!M&&!a.value.has(E)){const te=new Set(l.value);te.add(E),l.value=te;try{const de=await ke(`/api/schedules/${N}/${$}/runs?limit=25`);if(de.ok){const V=await de.json(),q=new Map(a.value);q.set(E,V.runs??[]),a.value=q}}catch{}finally{const de=new Set(l.value);de.delete(E),l.value=de}}}async function b(){r.value=!0,n.value=null,a.value=new Map;try{const N=await ke("/api/schedules");if(!N.ok)throw new Error(`HTTP ${N.status}`);const $=await N.json();e.value=$.io,s.value=$.squads}catch(N){n.value=N instanceof Error?N.message:"Failed to load schedules"}finally{r.value=!1}}async function x(N,$){if(!i.value.has(N)){i.value=new Set(i.value).add(N);try{await $(),await b()}catch(E){n.value=E instanceof Error?E.message:"Action failed"}finally{const E=new Set(i.value);E.delete(N),i.value=E}}}async function y(N,$){await x(`${N}-${$}`,async()=>{const E=await ke(`/api/schedules/${N}/${$}/pause`,{method:"POST"});if(!E.ok)throw new Error(`HTTP ${E.status}`)})}async function k(N,$){await x(`${N}-${$}`,async()=>{const E=await ke(`/api/schedules/${N}/${$}/resume`,{method:"POST"});if(!E.ok)throw new Error(`HTTP ${E.status}`)})}async function A(N,$){await x(`${N}-${$}`,async()=>{const E=await ke(`/api/schedules/${N}/${$}/run-now`,{method:"POST"});if(!E.ok)throw new Error(`HTTP ${E.status}`)})}async function L(N,$,E){window.confirm(`Delete schedule '${E}'?`)&&await x(`${N}-${$}`,async()=>{const M=await ke(`/api/schedules/${N}/${$}`,{method:"DELETE"});if(!M.ok)throw new Error(`HTTP ${M.status}`)})}return ts(b),(N,$)=>(_(),w("div",i_,[h("div",o_,[h("div",a_,[$[1]||($[1]=h("div",null,[h("h2",{class:"text-xl font-semibold text-txt-primary tracking-tight"},"Schedules"),h("p",{class:"text-xs text-txt-muted mt-0.5"},"Automated tasks & cron jobs")],-1)),h("button",{onClick:b,disabled:r.value,class:"flex items-center gap-1.5 bg-surface-2/60 hover:bg-surface-3/60 disabled:opacity-50 text-txt-secondary hover:text-txt-primary border border-edge hover:border-edge-bright px-3.5 py-2 rounded-xl text-sm transition-all duration-200"},[...$[0]||($[0]=[h("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.992 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182"})],-1),he(" Refresh ",-1)])],8,l_)]),r.value?(_(),w("div",c_,[...$[2]||($[2]=[h("div",{class:"flex items-center gap-3 text-txt-muted text-sm"},[h("div",{class:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse"}),he(" Loading schedules… ")],-1)])])):n.value?(_(),w("div",u_,R(n.value),1)):(_(),w(be,{key:2},[h("details",d_,[h("summary",h_,[$[3]||($[3]=h("svg",{class:"w-4 h-4 text-accent transition-transform group-open/section:rotate-90",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})],-1)),$[4]||($[4]=h("span",{class:"tracking-wide uppercase text-xs text-txt-secondary"},"IO Schedules",-1)),h("span",f_,R(e.value.length),1),$[5]||($[5]=h("div",{class:"flex-1 h-px bg-gradient-to-r from-edge to-transparent"},null,-1))]),e.value.length===0?(_(),w("div",p_,[...$[6]||($[6]=[h("div",{class:"w-10 h-10 rounded-xl bg-surface-2 border border-edge flex items-center justify-center mb-3"},[h("svg",{class:"w-5 h-5 text-txt-muted",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1),h("p",{class:"text-txt-muted text-sm"},"No IO schedules configured",-1)])])):(_(),w("div",g_,[(_(!0),w(be,null,qe(e.value,E=>(_(),w("div",{key:E.id,class:"bg-surface-2/50 border border-edge rounded-xl p-4 hover:border-edge-bright hover:shadow-card transition-all duration-200 overflow-hidden"},[h("div",m_,[h("div",v_,[h("div",b_,[h("span",y_,R(E.name),1),h("span",{class:fe(["inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium tracking-wide uppercase border shrink-0",E.enabled?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-surface-3/60 text-txt-muted border-edge"])},[E.enabled?(_(),w("span",__)):Y("",!0),he(" "+R(E.enabled?"Active":"Paused"),1)],2)]),h("div",w_,[h("code",x_,R(E.cron_expr),1),E.next_run_at?(_(),w("span",k_,[$[7]||($[7]=h("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 8.689c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062A1.125 1.125 0 013 16.811V8.69zM12.75 8.689c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062a1.125 1.125 0 01-1.683-.977V8.69z"})],-1)),he(" "+R(u(E.next_run_at)),1)])):Y("",!0),E.last_run_at?(_(),w("span",S_,[$[8]||($[8]=h("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),he(" "+R(u(E.last_run_at)),1)])):Y("",!0)]),E.notes?(_(),w("p",E_,R(E.notes),1)):Y("",!0)]),h("div",T_,[E.enabled?(_(),w("button",{key:0,onClick:M=>y("io",E.id),disabled:i.value.has(`io-${E.id}`),class:"text-txt-secondary hover:text-txt-primary disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-surface-3/40 hover:bg-surface-3 border border-edge/50 hover:border-edge transition-all duration-200",title:"Pause"},"⏸ Pause",8,A_)):(_(),w("button",{key:1,onClick:M=>k("io",E.id),disabled:i.value.has(`io-${E.id}`),class:"text-txt-secondary hover:text-txt-primary disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-surface-3/40 hover:bg-surface-3 border border-edge/50 hover:border-edge transition-all duration-200",title:"Resume"},"▶ Resume",8,C_)),h("button",{onClick:M=>A("io",E.id),disabled:i.value.has(`io-${E.id}`),class:"text-accent hover:text-white disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-accent/10 hover:bg-accent/20 border border-accent/20 hover:border-accent/40 transition-all duration-200",title:"Run now"},"▶ Run now",8,R_),h("button",{onClick:M=>m("io",E.id),class:fe(["text-xs px-2.5 py-1.5 rounded-lg border transition-all duration-200",o.value.get(`io-${E.id}`)?"bg-accent/10 text-accent border-accent/20":"bg-surface-3/40 hover:bg-surface-3 text-txt-secondary hover:text-txt-primary border-edge/50 hover:border-edge"]),title:"Toggle run history"},"📋 History",10,O_),h("button",{onClick:M=>L("io",E.id,E.name),disabled:i.value.has(`io-${E.id}`),class:"text-red-400/70 hover:text-red-400 disabled:opacity-50 text-xs px-2 py-1.5 rounded-lg hover:bg-red-500/10 border border-transparent hover:border-red-500/20 transition-all duration-200",title:"Delete"},[...$[9]||($[9]=[h("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)])],8,$_)])]),E.prompt?(_(),w("div",P_,[h("p",{class:fe(["text-xs text-txt-muted break-words",c.value.has(`io-${E.id}`)?"":"line-clamp-2"])},R(E.prompt),3),E.prompt.length>120?(_(),w("button",{key:0,onClick:M=>p("io",E.id),class:"text-[10px] text-accent/70 hover:text-accent mt-1 transition-colors"},R(c.value.has(`io-${E.id}`)?"Show less ▲":"Show more ▼"),9,I_)):Y("",!0)])):Y("",!0),o.value.get(`io-${E.id}`)?(_(),w("div",j_,[h("h4",N_," Run history — "+R(E.name),1),l.value.has(`io-${E.id}`)?(_(),w("div",L_,[...$[10]||($[10]=[h("div",{class:"w-1 h-1 rounded-full bg-accent animate-pulse"},null,-1),he(" Loading… ",-1)])])):!a.value.get(`io-${E.id}`)||a.value.get(`io-${E.id}`).length===0?(_(),w("div",U_," No history yet ")):(_(),w("ul",D_,[(_(!0),w(be,null,qe(a.value.get(`io-${E.id}`),M=>(_(),w("li",{key:M.id,class:"flex items-start gap-2.5 text-xs bg-surface-0/50 rounded-lg p-2.5 border border-edge/30"},[h("span",{class:fe(["w-2 h-2 rounded-full mt-1 shrink-0",d(M.status)])},null,2),h("div",M_,[h("div",B_,[h("span",H_,R(u(M.started_at)),1),h("span",{class:fe(["px-1.5 py-0.5 rounded-full text-[10px] font-medium tracking-wide uppercase border shrink-0",f(M.status)])},R(M.status),3)]),M.completed_at?(_(),w("div",F_," Completed: "+R(u(M.completed_at)),1)):Y("",!0),M.error_text?(_(),w("div",V_,R(M.error_text),1)):Y("",!0)])]))),128))]))])):Y("",!0)]))),128))]))]),h("details",q_,[h("summary",W_,[$[11]||($[11]=h("svg",{class:"w-4 h-4 text-accent transition-transform group-open/section:rotate-90",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})],-1)),$[12]||($[12]=h("span",{class:"tracking-wide uppercase text-xs text-txt-secondary"},"Squad Schedules",-1)),h("span",K_,R(s.value.length),1),$[13]||($[13]=h("div",{class:"flex-1 h-px bg-gradient-to-r from-edge to-transparent"},null,-1))]),s.value.length===0?(_(),w("div",G_,[...$[14]||($[14]=[h("div",{class:"w-10 h-10 rounded-xl bg-surface-2 border border-edge flex items-center justify-center mb-3"},[h("svg",{class:"w-5 h-5 text-txt-muted",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 18.72a9.094 9.094 0 003.741-.479 3 3 0 00-4.682-2.72m.94 3.198l.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0112 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 016 18.719m12 0a5.971 5.971 0 00-.941-3.197m0 0A5.995 5.995 0 0012 12.75a5.995 5.995 0 00-5.058 2.772m0 0a3 3 0 00-4.681 2.72 8.986 8.986 0 003.74.477m.94-3.197a5.971 5.971 0 00-.94 3.197M15 6.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z"})])],-1),h("p",{class:"text-txt-muted text-sm"},"No squad schedules configured",-1)])])):(_(),w("div",z_,[(_(!0),w(be,null,qe(s.value,E=>(_(),w("div",{key:E.id,class:"bg-surface-2/50 border border-edge rounded-xl p-4 hover:border-edge-bright hover:shadow-card transition-all duration-200 overflow-hidden"},[h("div",J_,[h("div",Y_,[h("div",X_,[h("span",Z_,R(E.name),1),h("span",Q_,R(E.squad_slug),1),h("span",{class:fe(["inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium tracking-wide uppercase border shrink-0",E.enabled?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-surface-3/60 text-txt-muted border-edge"])},[E.enabled?(_(),w("span",ew)):Y("",!0),he(" "+R(E.enabled?"Active":"Paused"),1)],2)]),h("div",tw,[h("code",sw,R(E.cron_expr),1),E.next_run_at?(_(),w("span",rw,[$[15]||($[15]=h("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 8.689c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062A1.125 1.125 0 013 16.811V8.69zM12.75 8.689c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062a1.125 1.125 0 01-1.683-.977V8.69z"})],-1)),he(" "+R(u(E.next_run_at)),1)])):Y("",!0),E.last_run_at?(_(),w("span",nw,[$[16]||($[16]=h("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),he(" "+R(u(E.last_run_at)),1)])):Y("",!0)]),E.notes?(_(),w("p",iw,R(E.notes),1)):Y("",!0)]),h("div",ow,[E.enabled?(_(),w("button",{key:0,onClick:M=>y("squads",E.id),disabled:i.value.has(`squads-${E.id}`),class:"text-txt-secondary hover:text-txt-primary disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-surface-3/40 hover:bg-surface-3 border border-edge/50 hover:border-edge transition-all duration-200",title:"Pause"},"⏸ Pause",8,aw)):(_(),w("button",{key:1,onClick:M=>k("squads",E.id),disabled:i.value.has(`squads-${E.id}`),class:"text-txt-secondary hover:text-txt-primary disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-surface-3/40 hover:bg-surface-3 border border-edge/50 hover:border-edge transition-all duration-200",title:"Resume"},"▶ Resume",8,lw)),h("button",{onClick:M=>A("squads",E.id),disabled:i.value.has(`squads-${E.id}`),class:"text-accent hover:text-white disabled:opacity-50 text-xs px-2.5 py-1.5 rounded-lg bg-accent/10 hover:bg-accent/20 border border-accent/20 hover:border-accent/40 transition-all duration-200",title:"Run now"},"▶ Run now",8,cw),h("button",{onClick:M=>m("squads",E.id),class:fe(["text-xs px-2.5 py-1.5 rounded-lg border transition-all duration-200",o.value.get(`squads-${E.id}`)?"bg-accent/10 text-accent border-accent/20":"bg-surface-3/40 hover:bg-surface-3 text-txt-secondary hover:text-txt-primary border-edge/50 hover:border-edge"]),title:"Toggle run history"},"📋 History",10,uw),h("button",{onClick:M=>L("squads",E.id,E.name),disabled:i.value.has(`squads-${E.id}`),class:"text-red-400/70 hover:text-red-400 disabled:opacity-50 text-xs px-2 py-1.5 rounded-lg hover:bg-red-500/10 border border-transparent hover:border-red-500/20 transition-all duration-200",title:"Delete"},[...$[17]||($[17]=[h("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)])],8,dw)])]),E.prompt?(_(),w("div",hw,[h("p",{class:fe(["text-xs text-txt-muted break-words",c.value.has(`squads-${E.id}`)?"":"line-clamp-2"])},R(E.prompt),3),E.prompt.length>120?(_(),w("button",{key:0,onClick:M=>p("squads",E.id),class:"text-[10px] text-accent/70 hover:text-accent mt-1 transition-colors"},R(c.value.has(`squads-${E.id}`)?"Show less ▲":"Show more ▼"),9,fw)):Y("",!0)])):Y("",!0),o.value.get(`squads-${E.id}`)?(_(),w("div",pw,[h("h4",gw," Run history — "+R(E.name),1),l.value.has(`squads-${E.id}`)?(_(),w("div",mw,[...$[18]||($[18]=[h("div",{class:"w-1 h-1 rounded-full bg-accent animate-pulse"},null,-1),he(" Loading… ",-1)])])):!a.value.get(`squads-${E.id}`)||a.value.get(`squads-${E.id}`).length===0?(_(),w("div",vw," No history yet ")):(_(),w("ul",bw,[(_(!0),w(be,null,qe(a.value.get(`squads-${E.id}`),M=>(_(),w("li",{key:M.id,class:"flex items-start gap-2.5 text-xs bg-surface-0/50 rounded-lg p-2.5 border border-edge/30"},[h("span",{class:fe(["w-2 h-2 rounded-full mt-1 shrink-0",d(M.status)])},null,2),h("div",yw,[h("div",_w,[h("span",ww,R(u(M.started_at)),1),h("span",{class:fe(["px-1.5 py-0.5 rounded-full text-[10px] font-medium tracking-wide uppercase border shrink-0",f(M.status)])},R(M.status),3)]),M.completed_at?(_(),w("div",xw," Completed: "+R(u(M.completed_at)),1)):Y("",!0),M.error_text?(_(),w("div",kw,R(M.error_text),1)):Y("",!0)])]))),128))]))])):Y("",!0)]))),128))]))])],64))])]))}}),Ew={class:"flex flex-col h-full p-6"},Tw={class:"flex justify-between items-center mb-6"},Aw={key:0,class:"flex-1 flex items-center justify-center"},Cw={key:1,class:"flex-1 flex flex-col items-center justify-center"},Rw={key:2,class:"space-y-2 overflow-y-auto flex-1 pr-1"},Ow=["onClick"],$w={class:"p-4"},Pw={class:"flex items-start gap-3"},Iw={class:"flex flex-col items-center pt-1"},jw={key:0,class:"w-2 h-2 rounded-full bg-accent shadow-glow-sm shrink-0"},Nw={key:1,class:"w-2 h-2 rounded-full bg-edge shrink-0"},Lw={class:"flex-1 min-w-0"},Uw={class:"flex items-center gap-2 mb-1"},Dw={class:"text-sm font-medium text-txt-primary truncate"},Mw={key:0,class:"text-[10px] font-mono tracking-wider uppercase text-txt-muted bg-surface-0/60 px-1.5 py-0.5 rounded border border-edge/50 shrink-0"},Bw={class:"text-xs text-txt-muted"},Hw=["onClick"],Fw={key:0,class:"px-4 pb-4 pt-0"},Vw=["innerHTML"],qw=gt({__name:"NotificationsView",setup(t){const e=F([]),s=F(!0),r=F(new Set);function n(c){try{const u=c.includes("T")||c.endsWith("Z")?c:c.replace(" ","T")+"Z";return new Date(u).toLocaleString()}catch{return c}}function i(c){const u=new Set(r.value);u.has(c)?u.delete(c):u.add(c),r.value=u}async function o(){try{const c=await ke("/api/notifications?limit=100");if(c.ok){const u=await c.json();e.value=u.notifications??[]}}catch{}s.value=!1}async function a(c){try{await ke(`/api/notifications/${c}/read`,{method:"POST"});const u=e.value.find(d=>d.id===c);u&&(u.read_at=new Date().toISOString())}catch{}}async function l(){try{await ke("/api/notifications/read-all",{method:"POST"});for(const c of e.value)c.read_at||(c.read_at=new Date().toISOString())}catch{}}return ts(o),(c,u)=>(_(),w("div",Ew,[h("div",Tw,[u[0]||(u[0]=h("div",null,[h("h2",{class:"text-xl font-semibold text-txt-primary tracking-tight"},"Notifications"),h("p",{class:"text-xs text-txt-muted mt-0.5"},"Background activity & alerts")],-1)),e.value.length>0?(_(),w("button",{key:0,onClick:l,class:"text-xs text-accent hover:text-accent-glow transition-colors font-medium"}," Mark all read ")):Y("",!0)]),s.value?(_(),w("div",Aw,[...u[1]||(u[1]=[h("div",{class:"flex items-center gap-3 text-txt-muted text-sm"},[h("div",{class:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse"}),he(" Loading… ")],-1)])])):e.value.length===0?(_(),w("div",Cw,[...u[2]||(u[2]=[h("div",{class:"w-12 h-12 rounded-xl bg-surface-2 border border-edge flex items-center justify-center mb-4"},[h("svg",{class:"w-6 h-6 text-txt-muted",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"})])],-1),h("p",{class:"text-txt-muted text-sm"},"No notifications yet",-1)])])):(_(),w("ul",Rw,[(_(!0),w(be,null,qe(e.value,d=>{var f;return _(),w("li",{key:d.id,class:fe(["group rounded-xl border transition-all duration-200 cursor-pointer overflow-hidden",d.read_at?"bg-surface-1/40 border-edge/50 opacity-60 hover:opacity-80":"bg-surface-2/60 border-edge hover:border-edge-bright hover:shadow-card"]),onClick:p=>i(d.id)},[h("div",$w,[h("div",Pw,[h("div",Iw,[d.read_at?(_(),w("span",Nw)):(_(),w("span",jw))]),h("div",Lw,[h("div",Uw,[h("span",Dw,R(d.title),1),(f=d.source)!=null&&f.type?(_(),w("span",Mw,R(d.source.type),1)):Y("",!0)]),h("p",Bw,R(n(d.created_at)),1)]),d.read_at?Y("",!0):(_(),w("button",{key:0,onClick:Yt(p=>a(d.id),["stop"]),class:"text-txt-muted hover:text-accent shrink-0 opacity-0 group-hover:opacity-100 transition-all duration-200 p-1 rounded-lg hover:bg-accent/10",title:"Mark as read"},[...u[3]||(u[3]=[h("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},[h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"})],-1)])],8,Hw))])]),r.value.has(d.id)?(_(),w("div",Fw,[h("div",{class:"ml-5 mt-2 text-sm text-txt-secondary bg-surface-0/60 rounded-xl p-4 border border-edge/50 wiki-content",innerHTML:Oe(zn)(d.text)},null,8,Vw)])):Y("",!0)],10,Ow)}),128))]))]))}}),Ww={class:"flex h-full overflow-hidden bg-surface-0"},Kw={class:"w-72 shrink-0 bg-surface-1/70 backdrop-blur-sm border-r border-edge flex flex-col"},Gw={class:"p-3.5 shrink-0"},zw={class:"flex items-center justify-between mb-3"},Jw={class:"text-[10px] text-txt-muted font-mono bg-surface-2/60 px-1.5 py-0.5 rounded"},Yw={key:0,class:"flex-1 flex items-center justify-center"},Xw={key:1,class:"flex-1 p-4"},Zw={class:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2"},Qw={key:2,class:"flex-1 overflow-y-auto py-2 px-2"},ex={key:0,class:"px-2 py-3 text-sm text-txt-muted text-center"},tx=["onClick"],sx={key:0,class:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-r-full bg-accent shadow-glow-sm"},rx={class:"flex-1 min-w-0 flex flex-col overflow-hidden"},nx={key:0,class:"flex-1 flex flex-col items-center justify-center select-none"},ix={key:1,class:"flex-1 flex items-center justify-center"},ox={key:2,class:"flex-1 p-6"},ax={class:"inline-flex items-center gap-2 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2"},lx={key:3,class:"flex-1 overflow-y-auto"},cx={class:"max-w-3xl mx-auto px-6 py-6"},ux={class:"text-xl font-bold text-txt-primary mb-4 pb-3 border-b border-edge"},dx=["innerHTML"],hx=gt({__name:"WikiView",setup(t){const e=F([]),s=F(null),r=F(""),n=F(""),i=F(!1),o=F(!1),a=F(""),l=F(""),c=$e(()=>{const p=n.value.trim().toLowerCase();return p?e.value.filter(m=>m.title.toLowerCase().includes(p)):e.value}),u=$e(()=>zn(r.value));async function d(){i.value=!0,a.value="";try{const p=await ke("/api/wiki");if(!p.ok)throw new Error(`HTTP ${p.status}`);const m=await p.json();e.value=m.pages??[]}catch(p){a.value=p instanceof Error?p.message:"Failed to load pages"}finally{i.value=!1}}async function f(p){var m;if(((m=s.value)==null?void 0:m.path)!==p.path){s.value=p,r.value="",o.value=!0,l.value="";try{const b=await ke(`/api/wiki/${encodeURIComponent(p.path)}`);if(!b.ok)throw new Error(`HTTP ${b.status}`);const x=await b.json();r.value=x.content??""}catch(b){l.value=b instanceof Error?b.message:"Failed to load page"}finally{o.value=!1}}}return ts(d),(p,m)=>(_(),w("div",Ww,[h("div",Kw,[h("div",Gw,[h("div",zw,[m[1]||(m[1]=h("h2",{class:"text-sm font-semibold text-txt-primary tracking-tight flex items-center gap-1.5"},[h("span",{class:"text-base"},"📚"),he(" Wiki ")],-1)),h("span",Jw,R(c.value.length),1)]),lt(h("input",{"onUpdate:modelValue":m[0]||(m[0]=b=>n.value=b),type:"text",placeholder:"Filter pages…",class:"w-full px-3 py-1.5 text-sm bg-surface-2/50 border border-edge rounded-lg text-txt-primary placeholder-txt-muted/50 focus:outline-none focus:border-accent/40 focus:shadow-glow-sm transition-all duration-200"},null,512),[[yt,n.value]])]),m[3]||(m[3]=h("div",{class:"mx-3 h-px bg-gradient-to-r from-transparent via-edge to-transparent"},null,-1)),i.value?(_(),w("div",Yw,[...m[2]||(m[2]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading… ")],-1)])])):a.value?(_(),w("div",Xw,[h("div",Zw,R(a.value),1)])):(_(),w("ul",Qw,[c.value.length===0?(_(),w("li",ex," No pages found ")):Y("",!0),(_(!0),w(be,null,qe(c.value,b=>{var x,y,k;return _(),w("li",{key:b.path,onClick:A=>f(b),class:fe(["relative px-2.5 py-2 rounded-lg cursor-pointer text-sm transition-all duration-150 mb-0.5",((x=s.value)==null?void 0:x.path)===b.path?"bg-accent/10 text-accent":"text-txt-secondary hover:text-txt-primary hover:bg-surface-3/40"])},[((y=s.value)==null?void 0:y.path)===b.path?(_(),w("span",sx)):Y("",!0),h("span",{class:fe(((k=s.value)==null?void 0:k.path)===b.path?"ml-1":"")},R(b.title),3)],10,tx)}),128))]))]),h("div",rx,[s.value?o.value?(_(),w("div",ix,[...m[5]||(m[5]=[h("div",{class:"flex items-center gap-2 text-txt-muted text-sm"},[h("span",{class:"w-4 h-4 border-2 border-edge border-t-accent rounded-full animate-spin"}),he(" Loading… ")],-1)])])):l.value?(_(),w("div",ox,[h("div",ax,[m[6]||(m[6]=h("span",null,"⚠",-1)),he(" "+R(l.value),1)])])):(_(),w("div",lx,[h("div",cx,[h("h1",ux,R(s.value.title),1),h("div",{class:"wiki-content text-txt-secondary text-sm leading-relaxed",innerHTML:u.value},null,8,dx)])])):(_(),w("div",nx,[...m[4]||(m[4]=[h("div",{class:"w-12 h-12 rounded-xl bg-surface-2/60 border border-edge flex items-center justify-center mb-4"},[h("span",{class:"text-2xl"},"📖")],-1),h("p",{class:"text-txt-muted text-sm"},"Select a page to start reading",-1)])]))])]))}}),fx=Hr(hx,[["__scopeId","data-v-a74f92fe"]]),px={class:"relative flex items-center justify-center h-screen bg-surface-0 overflow-hidden"},gx={class:"relative w-full max-w-sm mx-4 animate-fade-in"},mx={class:"glass rounded-2xl border border-edge p-8 shadow-glow"},vx={key:0,class:"flex items-center gap-2 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-xl px-3.5 py-2.5"},bx=["disabled"],yx=gt({__name:"LoginView",setup(t){const e=Br(),s=Hc(),r=F(""),n=F(""),i=F(null);async function o(){i.value=null;const a=await e.signIn(r.value,n.value);a?i.value=a:s.push("/chat")}return(a,l)=>(_(),w("div",px,[l[6]||(l[6]=h("div",{class:"pointer-events-none absolute inset-0"},[h("div",{class:"absolute top-1/4 left-1/3 w-[500px] h-[500px] bg-accent/[0.04] rounded-full blur-[120px]"}),h("div",{class:"absolute bottom-1/4 right-1/4 w-[400px] h-[400px] bg-accent-dim/[0.06] rounded-full blur-[100px]"})],-1)),h("div",gx,[h("div",mx,[l[5]||(l[5]=Dn('<div class="flex flex-col items-center mb-8"><div class="w-14 h-14 rounded-xl bg-accent/10 border border-accent/20 flex items-center justify-center mb-4 shadow-glow-sm"><span class="text-accent font-mono font-bold text-2xl tracking-tighter">IO</span></div><h1 class="text-xl font-semibold text-txt-primary tracking-tight">Welcome back</h1><p class="text-sm text-txt-muted mt-1">Sign in to continue</p></div>',1)),h("form",{onSubmit:Yt(o,["prevent"]),class:"space-y-5"},[h("div",null,[l[2]||(l[2]=h("label",{for:"email",class:"block text-xs font-medium text-txt-secondary mb-1.5 tracking-wide uppercase"},"Email",-1)),lt(h("input",{id:"email","onUpdate:modelValue":l[0]||(l[0]=c=>r.value=c),type:"email",required:"",autocomplete:"email",class:"w-full px-3.5 py-2.5 bg-surface-0/60 border border-edge rounded-xl text-txt-primary placeholder-txt-muted text-sm focus:outline-none focus:border-accent/50 focus:ring-1 focus:ring-accent/20 focus:shadow-glow-sm transition-all duration-200",placeholder:"you@example.com"},null,512),[[yt,r.value]])]),h("div",null,[l[3]||(l[3]=h("label",{for:"password",class:"block text-xs font-medium text-txt-secondary mb-1.5 tracking-wide uppercase"},"Password",-1)),lt(h("input",{id:"password","onUpdate:modelValue":l[1]||(l[1]=c=>n.value=c),type:"password",required:"",autocomplete:"current-password",class:"w-full px-3.5 py-2.5 bg-surface-0/60 border border-edge rounded-xl text-txt-primary placeholder-txt-muted text-sm focus:outline-none focus:border-accent/50 focus:ring-1 focus:ring-accent/20 focus:shadow-glow-sm transition-all duration-200",placeholder:"••••••••"},null,512),[[yt,n.value]])]),i.value?(_(),w("div",vx,[l[4]||(l[4]=h("svg",{class:"w-4 h-4 shrink-0",viewBox:"0 0 20 20",fill:"currentColor"},[h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z","clip-rule":"evenodd"})],-1)),he(" "+R(i.value),1)])):Y("",!0),h("button",{type:"submit",disabled:Oe(e).loading,class:"w-full py-2.5 px-4 bg-accent hover:bg-accent-glow disabled:opacity-50 disabled:cursor-not-allowed text-surface-0 font-semibold text-sm rounded-xl transition-all duration-200 shadow-glow-sm hover:shadow-glow"},R(Oe(e).loading?"Signing in…":"Sign in"),9,bx)],32)])])]))}}),du=tp({history:Nf("/"),routes:[{path:"/",redirect:"/chat"},{path:"/login",name:"login",component:yx,meta:{public:!0}},{path:"/chat",name:"chat",component:B0},{path:"/skills",name:"skills",component:Dv},{path:"/squads",name:"squads",component:Mb},{path:"/activity",name:"activity",component:n_},{path:"/wiki",name:"wiki",component:fx},{path:"/schedules",name:"schedules",component:Sw},{path:"/notifications",name:"notifications",component:qw},{path:"/inbox",name:"inbox",component:()=>b0(()=>import("./InboxView-D9wKrR06.js"),[])}]});du.beforeEach(async t=>{const e=Br();return e.initialized||await e.init(),!e.authEnabled||t.meta.public||e.user?!0:{name:"login"}});const mo=Fh(g0);mo.use(Wh());mo.use(du);mo.mount("#app");export{be as F,h as a,Y as b,w as c,gt as d,he as e,Dn as f,F as g,ke as h,_ as i,zn as j,ts as o,qe as r,R as t,Oe as u,Yt as w};
|