@telemetryos/root-sdk 1.16.0 → 1.16.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @telemetryos/root-sdk
2
2
 
3
+ ## 1.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Standardize ESLint configs and rename spec files to test (#69)
8
+ Change media.openPicker from request to subscription pattern (#68)
9
+ - Updated dependencies
10
+ - @telemetryos/sdk-bridge@1.16.1
11
+
3
12
  ## 1.16.0
4
13
 
5
14
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const nt="1.16.0",it={version:nt};class Ee{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("accounts.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current account");return e.account}}class $e{constructor(e){this._client=e}async getById(e){return(await this._client.request("applications.getById",{applicationId:e})).application}async getBySpecifier(e){return(await this._client.request("applications.getBySpecifier",{applicationSpecifier:e})).application}async getAllByMountPoint(e){return(await this._client.request("applications.getAllByMountPoint",{mountPoint:e})).applications}async setDependencies(e){return await this._client._dependencyStore.setDependencies(e),(t,s)=>this._client._dependencyStore.handleFor(t,s)}bind(e,t){if(this._client._messageInterceptors.has(e))throw new Error(`Interceptor already bound for message ${e}`);this._client._messageInterceptors.set(e,t)}}class je{constructor(e){this._client=e}async getAllFolders(){return(await this._client.request("mediaFolders.getAll",{})).folders}async getAllByFolderId(e){return(await this._client.request("media.getAllByFolderId",{folderId:e})).contents}async getAllByTag(e){return(await this._client.request("media.getAllByTag",{tagName:e})).contents}async getById(e){return(await this._client.request("media.getById",{id:e})).content}async openPicker(e){return(await this._client.request("media.openPicker",{accept:e==null?void 0:e.accept,currentValue:e==null?void 0:e.currentValue})).selection}}var b;(function(i){i.assertEqual=n=>{};function e(n){}i.assertIs=e;function t(n){throw new Error}i.assertNever=t,i.arrayToEnum=n=>{const a={};for(const r of n)a[r]=r;return a},i.getValidEnumValues=n=>{const a=i.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),r={};for(const o of a)r[o]=n[o];return i.objectValues(r)},i.objectValues=n=>i.objectKeys(n).map(function(a){return n[a]}),i.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&a.push(r);return a},i.find=(n,a)=>{for(const r of n)if(a(r))return r},i.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(r=>typeof r=="string"?`'${r}'`:r).join(a)}i.joinValues=s,i.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var ye;(function(i){i.mergeShapes=(e,t)=>({...e,...t})})(ye||(ye={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),A=i=>{switch(typeof i){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(i)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(i)?h.array:i===null?h.null:i.then&&typeof i.then=="function"&&i.catch&&typeof i.catch=="function"?h.promise:typeof Map<"u"&&i instanceof Map?h.map:typeof Set<"u"&&i instanceof Set?h.set:typeof Date<"u"&&i instanceof Date?h.date:h.object;default:return h.unknown}},d=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class N extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const r of a.issues)if(r.code==="invalid_union")r.unionErrors.map(n);else if(r.code==="invalid_return_type")n(r.returnTypeError);else if(r.code==="invalid_arguments")n(r.argumentsError);else if(r.path.length===0)s._errors.push(t(r));else{let o=s,c=0;for(;c<r.path.length;){const l=r.path[c];c===r.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(r))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}static assert(e){if(!(e instanceof N))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}N.create=i=>new N(i);const de=(i,e)=>{let t;switch(i.code){case d.invalid_type:i.received===h.undefined?t="Required":t=`Expected ${i.expected}, received ${i.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(i.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${b.joinValues(i.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${b.joinValues(i.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${b.joinValues(i.options)}, received '${i.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof i.validation=="object"?"includes"in i.validation?(t=`Invalid input: must include "${i.validation.includes}"`,typeof i.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${i.validation.position}`)):"startsWith"in i.validation?t=`Invalid input: must start with "${i.validation.startsWith}"`:"endsWith"in i.validation?t=`Invalid input: must end with "${i.validation.endsWith}"`:b.assertNever(i.validation):i.validation!=="regex"?t=`Invalid ${i.validation}`:t="Invalid";break;case d.too_small:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at least":"more than"} ${i.minimum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at least":"over"} ${i.minimum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="bigint"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(i.minimum))}`:t="Invalid input";break;case d.too_big:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at most":"less than"} ${i.maximum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at most":"under"} ${i.maximum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="bigint"?t=`BigInt must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly":i.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(i.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${i.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,b.assertNever(i)}return{message:t}};let at=de;function rt(){return at}const ot=i=>{const{data:e,path:t,errorMaps:s,issueData:n}=i,a=[...t,...n.path||[]],r={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(r,{data:e,defaultError:o}).message;return{...n,path:a,message:o}};function u(i,e){const t=rt(),s=ot({issueData:e,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,t,t===de?void 0:de].filter(n=>!!n)});i.common.issues.push(s)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return g;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t){const a=await n.key,r=await n.value;s.push({key:a,value:r})}return T.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:r}=n;if(a.status==="aborted"||r.status==="aborted")return g;a.status==="dirty"&&e.dirty(),r.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof r.value<"u"||n.alwaysSet)&&(s[a.value]=r.value)}return{status:e.value,value:s}}}const g=Object.freeze({status:"aborted"}),ue=i=>({status:"dirty",value:i}),C=i=>({status:"valid",value:i}),ve=i=>i.status==="aborted",be=i=>i.status==="dirty",q=i=>i.status==="valid",se=i=>typeof Promise<"u"&&i instanceof Promise;var p;(function(i){i.errToObj=e=>typeof e=="string"?{message:e}:e||{},i.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));class ${constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const we=(i,e)=>{if(q(e))return{success:!0,data:e.value};if(!i.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new N(i.common.issues);return this._error=t,this._error}}};function y(i){if(!i)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=i;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,r)=>{const{message:o}=i;return a.code==="invalid_enum_value"?{message:o??r.defaultError}:typeof r.data>"u"?{message:o??s??r.defaultError}:a.code!=="invalid_type"?{message:r.defaultError}:{message:o??t??r.defaultError}},description:n}}class v{get description(){return this._def.description}_getType(e){return A(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:A(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:A(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(se(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)},n=this._parseSync({data:e,path:s.path,parent:s});return we(s,n)}"~validate"(e){var t,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:n});return q(a)?{value:a.value}:{issues:n.common.issues}}catch(a){(s=(t=a==null?void 0:a.message)==null?void 0:t.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(a=>q(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(se(n)?n:Promise.resolve(n));return we(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const r=e(n),o=()=>a.addIssue({code:d.custom,...s(n)});return typeof Promise<"u"&&r instanceof Promise?r.then(c=>c?!0:(o(),!1)):r?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new L({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return E.create(this,this._def)}nullable(){return D.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I.create(this)}promise(){return re.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return ae.create(this,e,this._def)}transform(e){return new L({...y(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new fe({...y(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new At({typeName:_.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new me({...y(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ge.create(this,e)}readonly(){return _e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ct=/^c[^\s-]{8,}$/i,dt=/^[0-9a-z]+$/,ut=/^[0-9A-HJKMNP-TV-Z]{26}$/i,lt=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ht=/^[a-z0-9_-]{21}$/i,pt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ft=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,mt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ce;const gt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,yt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,vt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,bt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Pe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",xt=new RegExp(`^${Pe}$`);function Re(i){let e="[0-5]\\d";i.precision?e=`${e}\\.\\d{${i.precision}}`:i.precision==null&&(e=`${e}(\\.\\d+)?`);const t=i.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function St(i){return new RegExp(`^${Re(i)}$`)}function Tt(i){let e=`${Pe}T${Re(i)}`;const t=[];return t.push(i.local?"Z?":"Z"),i.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ct(i,e){return!!((e==="v4"||!e)&&gt.test(i)||(e==="v6"||!e)&&vt.test(i))}function It(i,e){if(!pt.test(i))return!1;try{const[t]=i.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Nt(i,e){return!!((e==="v4"||!e)&&yt.test(i)||(e==="v6"||!e)&&bt.test(i))}class O extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.string,received:n.parsedType}),g}const t=new T;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,r=e.data.length<n.value;(a||r)&&(s=this._getOrReturnCtx(e,s),a?u(s,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):r&&u(s,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")mt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"email",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")ce||(ce=new RegExp(_t,"u")),ce.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"emoji",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")lt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"uuid",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="nanoid")ht.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"nanoid",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")ct.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")dt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid2",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")ut.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ulid",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),u(s,{validation:"url",code:d.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"regex",code:d.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Tt(n).test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="date"?xt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"date",message:n.message}),t.dirty()):n.kind==="time"?St(n).test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"time",message:n.message}),t.dirty()):n.kind==="duration"?ft.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"duration",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="ip"?Ct(e.data,n.version)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ip",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="jwt"?It(e.data,n.alg)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"jwt",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="cidr"?Nt(e.data,n.version)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cidr",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="base64"?wt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"base64",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="base64url"?kt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"base64url",code:d.invalid_string,message:n.message}),t.dirty()):b.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:d.invalid_string,...p.errToObj(s)})}_addCheck(e){return new O({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...p.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...p.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...p.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new O({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new O({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new O({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}O.create=i=>new O({checks:[],typeName:_.ZodString,coerce:(i==null?void 0:i.coerce)??!1,...y(i)});function Zt(i,e){const t=(i.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(i.toFixed(n).replace(".","")),r=Number.parseInt(e.toFixed(n).replace(".",""));return a%r/10**n}class Y extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.number,received:n.parsedType}),g}let t;const s=new T;for(const n of this._def.checks)n.kind==="int"?b.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),u(t,{code:d.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?Zt(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),u(t,{code:d.not_finite,message:n.message}),s.dirty()):b.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Y.create=i=>new Y({checks:[],typeName:_.ZodNumber,coerce:(i==null?void 0:i.coerce)||!1,...y(i)});class X extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let t;const s=new T;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):b.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.bigint,received:t.parsedType}),g}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new X({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}X.create=i=>new X({checks:[],typeName:_.ZodBigInt,coerce:(i==null?void 0:i.coerce)??!1,...y(i)});class ke extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.boolean,received:t.parsedType}),g}return C(e.data)}}ke.create=i=>new ke({typeName:_.ZodBoolean,coerce:(i==null?void 0:i.coerce)||!1,...y(i)});class ne extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.date,received:n.parsedType}),g}if(Number.isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_date}),g}const t=new T;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):b.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ne.create=i=>new ne({checks:[],coerce:(i==null?void 0:i.coerce)||!1,typeName:_.ZodDate,...y(i)});class xe extends v{_parse(e){if(this._getType(e)!==h.symbol){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.symbol,received:t.parsedType}),g}return C(e.data)}}xe.create=i=>new xe({typeName:_.ZodSymbol,...y(i)});class Se extends v{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.undefined,received:t.parsedType}),g}return C(e.data)}}Se.create=i=>new Se({typeName:_.ZodUndefined,...y(i)});class Te extends v{_parse(e){if(this._getType(e)!==h.null){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.null,received:t.parsedType}),g}return C(e.data)}}Te.create=i=>new Te({typeName:_.ZodNull,...y(i)});class le extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}le.create=i=>new le({typeName:_.ZodAny,...y(i)});class Ce extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}Ce.create=i=>new Ce({typeName:_.ZodUnknown,...y(i)});class j extends v{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.never,received:t.parsedType}),g}}j.create=i=>new j({typeName:_.ZodNever,...y(i)});class Ie extends v{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.void,received:t.parsedType}),g}return C(e.data)}}Ie.create=i=>new Ie({typeName:_.ZodVoid,...y(i)});class I extends v{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==h.array)return u(t,{code:d.invalid_type,expected:h.array,received:t.parsedType}),g;if(n.exactLength!==null){const r=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(r||o)&&(u(t,{code:r?d.too_big:d.too_small,minimum:o?n.exactLength.value:void 0,maximum:r?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(u(t,{code:d.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(u(t,{code:d.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((r,o)=>n.type._parseAsync(new $(t,r,t.path,o)))).then(r=>T.mergeArray(s,r));const a=[...t.data].map((r,o)=>n.type._parseSync(new $(t,r,t.path,o)));return T.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new I({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new I({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new I({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}}I.create=(i,e)=>new I({type:i,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...y(e)});function M(i){if(i instanceof k){const e={};for(const t in i.shape){const s=i.shape[t];e[t]=E.create(M(s))}return new k({...i._def,shape:()=>e})}else return i instanceof I?new I({...i._def,type:M(i.element)}):i instanceof E?E.create(M(i.unwrap())):i instanceof D?D.create(M(i.unwrap())):i instanceof R?R.create(i.items.map(e=>M(e))):i}class k extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=b.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==h.object){const c=this._getOrReturnCtx(e);return u(c,{code:d.invalid_type,expected:h.object,received:c.parsedType}),g}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),r=[];if(!(this._def.catchall instanceof j&&this._def.unknownKeys==="strip"))for(const c in s.data)a.includes(c)||r.push(c);const o=[];for(const c of a){const l=n[c],f=s.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new $(s,f,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof j){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of r)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")r.length>0&&(u(s,{code:d.unrecognized_keys,keys:r}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of r){const f=s.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new $(s,f,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const f=await l.key,w=await l.value;c.push({key:f,value:w,alwaysSet:l.alwaysSet})}return c}).then(c=>T.mergeObjectSync(t,c)):T.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new k({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a;const r=((a=(n=this._def).errorMap)==null?void 0:a.call(n,t,s).message)??s.defaultError;return t.code==="unrecognized_keys"?{message:p.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new k({...this._def,unknownKeys:"strip"})}passthrough(){return new k({...this._def,unknownKeys:"passthrough"})}extend(e){return new k({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new k({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new k({...this._def,catchall:e})}pick(e){const t={};for(const s of b.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new k({...this._def,shape:()=>t})}omit(e){const t={};for(const s of b.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new k({...this._def,shape:()=>t})}deepPartial(){return M(this)}partial(e){const t={};for(const s of b.objectKeys(this.shape)){const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new k({...this._def,shape:()=>t})}required(e){const t={};for(const s of b.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof E;)n=n._def.innerType;t[s]=n}return new k({...this._def,shape:()=>t})}keyof(){return Fe(b.objectKeys(this.shape))}}k.create=(i,e)=>new k({shape:()=>i,unknownKeys:"strip",catchall:j.create(),typeName:_.ZodObject,...y(e)});k.strictCreate=(i,e)=>new k({shape:()=>i,unknownKeys:"strict",catchall:j.create(),typeName:_.ZodObject,...y(e)});k.lazycreate=(i,e)=>new k({shape:i,unknownKeys:"strip",catchall:j.create(),typeName:_.ZodObject,...y(e)});class ie extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const r=a.map(o=>new N(o.ctx.common.issues));return u(t,{code:d.invalid_union,unionErrors:r}),g}if(t.common.async)return Promise.all(s.map(async a=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(n);{let a;const r=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:l});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:l}),l.common.issues.length&&r.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=r.map(c=>new N(c));return u(t,{code:d.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}}ie.create=(i,e)=>new ie({options:i,typeName:_.ZodUnion,...y(e)});function he(i,e){const t=A(i),s=A(e);if(i===e)return{valid:!0,data:i};if(t===h.object&&s===h.object){const n=b.objectKeys(e),a=b.objectKeys(i).filter(o=>n.indexOf(o)!==-1),r={...i,...e};for(const o of a){const c=he(i[o],e[o]);if(!c.valid)return{valid:!1};r[o]=c.data}return{valid:!0,data:r}}else if(t===h.array&&s===h.array){if(i.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<i.length;a++){const r=i[a],o=e[a],c=he(r,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===h.date&&s===h.date&&+i==+e?{valid:!0,data:i}:{valid:!1}}class ae extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,r)=>{if(ve(a)||ve(r))return g;const o=he(a.value,r.value);return o.valid?((be(a)||be(r))&&t.dirty(),{status:t.value,value:o.data}):(u(s,{code:d.invalid_intersection_types}),g)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,r])=>n(a,r)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ae.create=(i,e,t)=>new ae({left:i,right:e,typeName:_.ZodIntersection,...y(t)});class R extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return u(s,{code:d.invalid_type,expected:h.array,received:s.parsedType}),g;if(s.data.length<this._def.items.length)return u(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&s.data.length>this._def.items.length&&(u(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,r)=>{const o=this._def.items[r]||this._def.rest;return o?o._parse(new $(s,a,s.path,r)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>T.mergeArray(t,a)):T.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new R({...this._def,rest:e})}}R.create=(i,e)=>{if(!Array.isArray(i))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new R({items:i,typeName:_.ZodTuple,rest:null,...y(e)})};class Ne extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return u(s,{code:d.invalid_type,expected:h.map,received:s.parsedType}),g;const n=this._def.keyType,a=this._def.valueType,r=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new $(s,o,s.path,[l,"key"])),value:a._parse(new $(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of r){const l=await c.key,f=await c.value;if(l.status==="aborted"||f.status==="aborted")return g;(l.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(l.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of r){const l=c.key,f=c.value;if(l.status==="aborted"||f.status==="aborted")return g;(l.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(l.value,f.value)}return{status:t.value,value:o}}}}Ne.create=(i,e,t)=>new Ne({valueType:e,keyType:i,typeName:_.ZodMap,...y(t)});class ee extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return u(s,{code:d.invalid_type,expected:h.set,received:s.parsedType}),g;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(u(s,{code:d.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(u(s,{code:d.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function r(c){const l=new Set;for(const f of c){if(f.status==="aborted")return g;f.status==="dirty"&&t.dirty(),l.add(f.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>a._parse(new $(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>r(c)):r(o)}min(e,t){return new ee({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new ee({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ee.create=(i,e)=>new ee({valueType:i,minSize:null,maxSize:null,typeName:_.ZodSet,...y(e)});class Ze extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ze.create=(i,e)=>new Ze({getter:i,typeName:_.ZodLazy,...y(e)});class pe extends v{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}}pe.create=(i,e)=>new pe({value:i,typeName:_.ZodLiteral,...y(e)});function Fe(i,e){return new H({values:i,typeName:_.ZodEnum,...y(e)})}class H extends v{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{expected:b.joinValues(s),received:t.parsedType,code:d.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{received:t.data,code:d.invalid_enum_value,options:s}),g}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return H.create(e,{...this._def,...t})}exclude(e,t=this._def){return H.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}H.create=Fe;class Ae extends v{_parse(e){const t=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const n=b.objectValues(t);return u(s,{expected:b.joinValues(n),received:s.parsedType,code:d.invalid_type}),g}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=b.objectValues(t);return u(s,{received:s.data,code:d.invalid_enum_value,options:n}),g}return C(e.data)}get enum(){return this._def.values}}Ae.create=(i,e)=>new Ae({values:i,typeName:_.ZodNativeEnum,...y(e)});class re extends v{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return u(t,{code:d.invalid_type,expected:h.promise,received:t.parsedType}),g;const s=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return C(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}re.create=(i,e)=>new re({type:i,typeName:_.ZodPromise,...y(e)});class L extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:r=>{u(s,r),r.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const r=n.transform(s.data,a);if(s.common.async)return Promise.resolve(r).then(async o=>{if(t.value==="aborted")return g;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?g:c.status==="dirty"||t.value==="dirty"?ue(c.value):c});{if(t.value==="aborted")return g;const o=this._def.schema._parseSync({data:r,path:s.path,parent:s});return o.status==="aborted"?g:o.status==="dirty"||t.value==="dirty"?ue(o.value):o}}if(n.type==="refinement"){const r=o=>{const c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),r(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),r(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const r=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!q(r))return g;const o=n.transform(r.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(r=>q(r)?Promise.resolve(n.transform(r.value,a)).then(o=>({status:t.value,value:o})):g);b.assertNever(n)}}L.create=(i,e,t)=>new L({schema:i,typeName:_.ZodEffects,effect:e,...y(t)});L.createWithPreprocess=(i,e,t)=>new L({schema:e,effect:{type:"preprocess",transform:i},typeName:_.ZodEffects,...y(t)});class E extends v{_parse(e){return this._getType(e)===h.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}E.create=(i,e)=>new E({innerType:i,typeName:_.ZodOptional,...y(e)});class D extends v{_parse(e){return this._getType(e)===h.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}D.create=(i,e)=>new D({innerType:i,typeName:_.ZodNullable,...y(e)});class fe extends v{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}fe.create=(i,e)=>new fe({innerType:i,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class me extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return se(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}me.create=(i,e)=>new me({innerType:i,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class Oe extends v{_parse(e){if(this._getType(e)!==h.nan){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.nan,received:t.parsedType}),g}return{status:"valid",value:e.data}}}Oe.create=i=>new Oe({typeName:_.ZodNaN,...y(i)});class At extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class ge extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?g:n.status==="dirty"?(t.dirty(),ue(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?g:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new ge({in:e,out:t,typeName:_.ZodPipeline})}}class _e extends v{_parse(e){const t=this._def.innerType._parse(e),s=n=>(q(n)&&(n.value=Object.freeze(n.value)),n);return se(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}}_e.create=(i,e)=>new _e({innerType:i,typeName:_.ZodReadonly,...y(e)});var _;(function(i){i.ZodString="ZodString",i.ZodNumber="ZodNumber",i.ZodNaN="ZodNaN",i.ZodBigInt="ZodBigInt",i.ZodBoolean="ZodBoolean",i.ZodDate="ZodDate",i.ZodSymbol="ZodSymbol",i.ZodUndefined="ZodUndefined",i.ZodNull="ZodNull",i.ZodAny="ZodAny",i.ZodUnknown="ZodUnknown",i.ZodNever="ZodNever",i.ZodVoid="ZodVoid",i.ZodArray="ZodArray",i.ZodObject="ZodObject",i.ZodUnion="ZodUnion",i.ZodDiscriminatedUnion="ZodDiscriminatedUnion",i.ZodIntersection="ZodIntersection",i.ZodTuple="ZodTuple",i.ZodRecord="ZodRecord",i.ZodMap="ZodMap",i.ZodSet="ZodSet",i.ZodFunction="ZodFunction",i.ZodLazy="ZodLazy",i.ZodLiteral="ZodLiteral",i.ZodEnum="ZodEnum",i.ZodEffects="ZodEffects",i.ZodNativeEnum="ZodNativeEnum",i.ZodOptional="ZodOptional",i.ZodNullable="ZodNullable",i.ZodDefault="ZodDefault",i.ZodCatch="ZodCatch",i.ZodPromise="ZodPromise",i.ZodBranded="ZodBranded",i.ZodPipeline="ZodPipeline",i.ZodReadonly="ZodReadonly"})(_||(_={}));const Z=O.create,Me=le.create;j.create;I.create;const qe=k.create;ie.create;ae.create;R.create;const He=pe.create,Ot=H.create;re.create;E.create;D.create;const Le=qe({type:He("bridge"),name:Z(),data:Me()});function Et(i){return{...i,type:"bridge"}}const De=qe({type:He("client"),telemetrySdkVersion:Z(),applicationSpecifier:Z(),applicationInstance:Z(),runtime:Ot(["window","worker"]),name:Z(),data:Me(),responseName:Z().optional(),subscriptionName:Z().optional(),unsubscribeName:Z().optional()});function W(i){return{...i,type:"client"}}class Ve{constructor(e){this._client=e}get application(){return new J("application","application",this._client)}get instance(){return new J("instance",this._client.applicationInstance,this._client)}get device(){return new J("device",this._client.deviceId,this._client)}shared(e){return new J("shared",e,this._client)}}class J{constructor(e,t,s){this._kind=e,this._namespace=t,this._client=s}async set(e,t){return(await this._client.request("store.set",{kind:this._kind,namespace:this._namespace,key:e,value:t})).success}async get(e){return(await this._client.request("store.get",{kind:this._kind,namespace:this._namespace,key:e})).value}async subscribe(e,t){return(await this._client.subscribe("store.subscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async unsubscribe(e,t){return(await this._client.unsubscribe("store.unsubscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async delete(e){return(await this._client.request("store.delete",{kind:this._kind,namespace:this._namespace,key:e})).success}}class $t{constructor(e){if(e._client._applicationSpecifier!=="rootSettingsNavigation")throw new Error("RootSettingsNavigation can only be used in the rootSettingsNavigation mount point");this._store=e}async setRootSettingsNavigation(e){var t;const s=this._store.shared("root-settings-navigation"),n=(t=await s.get("navigation"))!==null&&t!==void 0?t:{},a=this._store._client._applicationSpecifier;n[a]={applicationSpecifier:a,entries:e.entries},s.set("navigation",n)}async getRootSettingsNavigation(){var e;const s=(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{},n=this._store._client._applicationSpecifier;return s[n]}async getAllRootSettingsNavigation(){var e;return(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{}}}class ze{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("users.getCurrent",{});if(!e.success)throw new Error(e.error||"Failed to fetch current user");return e.user}}class Be{constructor(e){this._client=e}async fetch(e,t){var s;let n;typeof e=="string"?n=e:e instanceof URL?n=e.toString():(n=e.url,t||(t={method:e.method,headers:e.headers,body:e.body,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity}));let a={};t!=null&&t.headers&&(t.headers instanceof Headers?t.headers.forEach((f,w)=>{a[w]=f}):Array.isArray(t.headers)?t.headers.forEach(([f,w])=>{a[f]=w}):a=t.headers);const r=await this._client.request("proxy.fetch",{url:n,method:(t==null?void 0:t.method)||"GET",headers:a,body:(s=t==null?void 0:t.body)!==null&&s!==void 0?s:null});if(!r.success)throw new TypeError(r.errorMessage,{cause:r.errorCause?Error(r.errorCause):void 0});const o=new Headers(r.headers),c={status:r.status,statusText:r.statusText,headers:o};let l=null;if(r.body!==null&&r.body!==void 0)if(r.bodyType==="binary"){const f=atob(r.body),w=new Uint8Array(f.length);for(let S=0;S<f.length;S++)w[S]=f.charCodeAt(S);l=w}else r.bodyType==="text"?l=r.body:r.bodyType==="json"&&(l=JSON.stringify(r.body));return new Response(l,c)}}class Ue{constructor(e){this._client=e}async getInformation(){const e=await this._client.request("devices.getInformation",{});if(!e.success)throw new Error("Failed to get device information");return e.deviceInformation}async getCapabilities(){const e=await this._client.request("devices.getCapabilities",{});if(!e.success)throw new Error("Failed to get device capabilities");return e.capabilities}}class Ke{constructor(e){this._client=e}async getCities(e){const t=await this._client.request("weather.getCities",e);if(!t.success)throw new Error(t.error||"Failed to fetch cities");return t.data||[]}async getConditions(e){const t=await this._client.request("weather.getConditions",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather conditions");return t}async getDailyForecast(e){const t=await this._client.request("weather.getDailyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch daily forecast");return t}async getHourlyForecast(e){const t=await this._client.request("weather.getHourlyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch hourly forecast");return t}async getAlerts(e){const t=await this._client.request("weather.getAlerts",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather alerts");return t}}class We{constructor(e){this._client=e}async getSymbols(){const e=await this._client.request("currency.getSymbols",{});if(!e.success||!e.symbols)throw new Error("Failed to fetch currency symbols");return e.symbols}async getRates(e){var t,s,n;const a=await this._client.request("currency.getRates",e);if(!a.success||!a.rates)throw((t=a.error)===null||t===void 0?void 0:t.code)===201?new Error(`Invalid base currency '${e.base}'`):((s=a.error)===null||s===void 0?void 0:s.code)===202?new Error(`Invalid target currency symbol '${e.symbols}'`):new Error(((n=a.error)===null||n===void 0?void 0:n.message)||"Failed to fetch currency rates");return a.rates}}class Je{constructor(e){this._client=e}async getColorScheme(){return(await this._client.request("environment.getColorScheme",{})).colorScheme}async subscribeColorScheme(e){return(await this._client.subscribe("environment.subscribeColorScheme",{},e)).success}async unsubscribeColorScheme(e){return(await this._client.unsubscribe("environment.unsubscribeColorScheme",{},e)).success}}class Qe{constructor(e){this._client=e}async discover(){const e=await this._client.request("mqtt.discover",{});if(!e.success)throw new Error("Failed to discover MQTT brokers");return e.brokers}async connect(e,t){const s=await this._client.request("mqtt.connect",{brokerUrl:e,...t});if(!s.success)throw new Error("Failed to connect to MQTT broker");return s.clientId}async disconnect(e){if(!(await this._client.request("mqtt.disconnect",{clientId:e})).success)throw new Error("Failed to disconnect from MQTT broker")}async publish(e,t,s,n){if(!(await this._client.request("mqtt.publish",{clientId:e,topic:t,payload:s,...n})).success)throw new Error("Failed to publish MQTT message")}async subscribe(e,t,s,n){return(await this._client.subscribe("mqtt.subscribe",{clientId:e,topic:t,...n},s)).success}async unsubscribe(e,t,s){return(await this._client.unsubscribe("mqtt.unsubscribe",{clientId:e,topic:t},s)).success}async getConnectionStatus(e){const t=await this._client.request("mqtt.getConnectionStatus",{clientId:e});if(!t.success)throw new Error("Failed to get MQTT connection status");return t.status}async subscribeConnectionStatus(e,t){return(await this._client.subscribe("mqtt.subscribeConnectionStatus",{clientId:e},t)).success}async unsubscribeConnectionStatus(e,t){return(await this._client.unsubscribe("mqtt.unsubscribeConnectionStatus",{clientId:e},t)).success}}class Ge{constructor(e){this._originalPushState=null,this._originalReplaceState=null,this._popstateHandler=null,this._backHandler=null,this._forwardHandler=null,this._client=e}bind(){typeof window>"u"||this._originalPushState||(this._originalPushState=history.pushState.bind(history),history.pushState=(...e)=>{this._originalPushState(...e),this._sendLocationChanged()},this._originalReplaceState=history.replaceState.bind(history),history.replaceState=(...e)=>{this._originalReplaceState(...e),this._sendLocationChanged()},this._popstateHandler=()=>this._sendLocationChanged(),window.addEventListener("popstate",this._popstateHandler),this._backHandler=()=>history.back(),this._forwardHandler=()=>history.forward(),this._client.on("navigation.back",this._backHandler),this._client.on("navigation.forward",this._forwardHandler),this._sendLocationChanged())}unbind(){typeof window>"u"||(this._originalPushState&&(history.pushState=this._originalPushState,this._originalPushState=null),this._originalReplaceState&&(history.replaceState=this._originalReplaceState,this._originalReplaceState=null),this._popstateHandler&&(window.removeEventListener("popstate",this._popstateHandler),this._popstateHandler=null),this._backHandler&&(this._client.off("navigation.back",this._backHandler),this._backHandler=null),this._forwardHandler&&(this._client.off("navigation.forward",this._forwardHandler),this._forwardHandler=null))}_sendLocationChanged(){this._client.send("navigation.locationChanged",{pathname:window.location.pathname})}}const B=1e3*30,Ye=1e3*5,oe=typeof window>"u"&&typeof self<"u",te=oe?"worker":"window",Q=oe?self:window;function U(i){oe?self.postMessage(i):Q.parent.postMessage(i,"*")}class Xe{constructor(){this._applicationInstance="",this._applicationSpecifier="",this._deviceId="",this._heartbeatInterval=null,this._heartbeatSignature=K(),this._messageInterceptors=new Map,this._onHandlers=new Map,this._onceHandlers=new Map,this._subscriptionNamesByHandler=new Map,this._subscriptionNamesBySubjectName=new Map,this._dependencyStore=new Pt(this),this._navigation=new Ge(this)}get accounts(){return new Ee(this)}get users(){return new ze(this)}get store(){return new Ve(this)}get applications(){return new $e(this)}get media(){return new je(this)}get proxy(){return new Be(this)}get devices(){return new Ue(this)}get rootSettingsNavigation(){return new $t(this.store)}get weather(){return new Ke(this)}get currency(){return new We(this)}get environment(){return new Je(this)}get mqtt(){return new Qe(this)}get applicationSpecifier(){return this._applicationSpecifier}get applicationInstance(){return this._applicationInstance}get deviceId(){return this._deviceId}bind(){var e,t;const s=new URL(Q.location.href),n=s.searchParams;this._applicationInstance=n.get("applicationInstance")||"single",this._deviceId=n.get("deviceId")||this._applicationInstance;const a=/^[a-z0-9-]{40}$/i;if(this._applicationSpecifier=(e=n.get("applicationSpecifier"))!==null&&e!==void 0?e:"",!this._applicationSpecifier||!a.test(this._applicationSpecifier)){const r=s.hostname.split(".");this._applicationSpecifier=(t=r[0])!==null&&t!==void 0?t:""}if(!this._applicationSpecifier||!a.test(this._applicationSpecifier))throw console.error("TelemetryOS apps require an applicationSpecifier in the URL query parameters or subdomain. Make sure your app is being served correctly through the TelemetryOS platform or development environment."),new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);this._windowMessageHandler=r=>{if(r.source===Q||!r.data||typeof r.data!="object"||!("type"in r.data)||r.data.type!=="client"&&r.data.type!=="bridge")return;let o;if(r.data.type==="client"){const c=De.safeParse(r.data);if(!c.success){const S=r.data;S&&typeof S=="object"&&S.type==="client"&&console.warn("[sdk-client] Received a message that looks like a client message but failed schema validation. This may indicate a version mismatch between the SDK and the host environment.",c.error.issues);return}const l=c.data,f=this._messageInterceptors.get(l.name);if(!f)return U(l);let w;try{w=f(l)}catch(S){console.error(`Error in interceptor for message ${l.name}:`,S)}if(!w)return;o={...w,type:"bridge",...r.data.responseName?{name:r.data.responseName}:{}}}if(!o){const c=Le.safeParse(r.data);if(!c.success){const w=r.data;w&&typeof w=="object"&&w.type==="bridge"&&console.warn("[sdk-client] Received a message that looks like a bridge message but failed schema validation. This may indicate a version mismatch between the SDK and the host environment.",c.error.issues);return}o=c.data;const l=this._onHandlers.get(o.name),f=this._onceHandlers.get(o.name);if(l)for(const w of l)w(o.data);if(f){for(const w of f)w(o.data);this._onceHandlers.delete(o.name)}}if(!oe)for(let c=0;c<window.frames.length;c+=1)window.frames[c].postMessage(o,"*")},Q.addEventListener("message",this._windowMessageHandler),this._navigation.bind(),this._heartbeatInterval=setInterval(()=>{this.send("heartbeat",{signature:this._heartbeatSignature})},Ye)}unbind(){this._windowMessageHandler&&(this._navigation.unbind(),Q.removeEventListener("message",this._windowMessageHandler),this._heartbeatInterval&&clearInterval(this._heartbeatInterval))}send(e,t){const s=W({telemetrySdkVersion:G,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,runtime:te,name:e,data:t});U(s)}request(e,t,s){var n;const a=K(),r=W({telemetrySdkVersion:G,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,runtime:te,name:e,data:t,responseName:a});U(r);const o=(n=s==null?void 0:s.timeout)!==null&&n!==void 0?n:B;let c=!1,l;const f=new Promise(S=>{l=P=>{c||S(P)},this.once(a,l)});if(o===0)return f;const w=new Promise((S,P)=>{const V=new Error(`${e} message request with response name of ${a} timed out after ${o}`);setTimeout(()=>{c=!0,this.off(a,l),P(V)},o)});return Promise.race([w,f])}async subscribe(e,t,s){let n,a;typeof t=="function"?a=t:(n=t,a=s);const r=K(),o=K();let c=this._subscriptionNamesBySubjectName.get(e);c||(c=[],this._subscriptionNamesBySubjectName.set(e,c)),c.push(r),this._subscriptionNamesByHandler.set(a,r),this.on(r,a);const l=W({telemetrySdkVersion:G,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,runtime:te,name:e,data:n,responseName:o,subscriptionName:r});U(l);let f=!1,w;const S=new Promise((V,F)=>{const z=new Error(`${e} subscribe request with subscription name of ${r} and response name of ${o} timed out after ${B}`);setTimeout(()=>{f=!0,this.off(o,w),F(z)},B)}),P=new Promise(V=>{w=F=>{f||V(F)},this.once(o,w)});return Promise.race([S,P])}async unsubscribe(e,t,s){let n,a;typeof t=="function"?a=t:(n=t,a=s);const r=K();let o=[];if(a){const c=this._subscriptionNamesByHandler.get(a);if(!c)return{success:!1};o=[c],this._subscriptionNamesByHandler.delete(a)}else if(!this._subscriptionNamesBySubjectName.get(e))return{success:!1};for await(const c of o){this.off(c,a);const l=W({telemetrySdkVersion:G,applicationInstance:this._applicationInstance,applicationSpecifier:this._applicationSpecifier,runtime:te,name:e,data:n,responseName:r,unsubscribeName:c});U(l);let f=!1,w;const S=new Promise((F,z)=>{const st=new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${r} timed out after ${B}`);setTimeout(()=>{f=!0,this.off(r,w),z(st)},B)}),P=new Promise(F=>{w=z=>{f||F(z)},this.once(r,w)});if(!(await Promise.race([S,P])).success)return{success:!1}}return{success:!0}}on(e,t){var s;const n=(s=this._onHandlers.get(e))!==null&&s!==void 0?s:[];n.length===0&&this._onHandlers.set(e,n),n.push(t)}once(e,t){var s;const n=(s=this._onceHandlers.get(e))!==null&&s!==void 0?s:[];n.length===0&&this._onceHandlers.set(e,n),n.push(t)}off(e,t){const s=this._onHandlers.get(e),n=this._onceHandlers.get(e);if(!(!s&&!n)){if(s){for(let a=0;a<s.length;a+=1)t&&s[a]!==t||(s.splice(a,1),a-=1);s.length===0&&this._onHandlers.delete(e)}if(n){for(let a=0;a<n.length;a+=1)t&&n[a]!==t||(n.splice(a,1),a-=1);n.length===0&&this._onceHandlers.delete(e)}}}}function K(){return Math.random().toString(36).slice(2,9)}const jt=3;class Pt{constructor(e){this._client=e,this._dependencies=new Map,this._heartbeatTimeouts=new Map,this._client._messageInterceptors.set("heartbeat",t=>{this._handleHeartbeat(t.applicationSpecifier,t.applicationInstance)})}async setDependencies(e){this._client.send("applications.setDependencies",{applicationSpecifiers:e});const t=[];for(const[s,n]of this._dependencies.entries()){const[a,r]=s.split(":");(!e[a]||!e[a].includes(r))&&(t.push(n._destroy()),this._dependencies.delete(s))}await Promise.all(t)}handleFor(e,t){let s=this._dependencies.get(`${e}:${t}`);return s||(s=new et(this,e,t),this._dependencies.set(`${e}:${t}`,s),s)}_handleHeartbeat(e,t){const s=`${e}:${t}`,n=this._dependencies.get(s);if(!n)return;const a=this._heartbeatTimeouts.get(s);a&&clearTimeout(a),this._heartbeatTimeouts.set(s,setTimeout(()=>{this._heartbeatTimeouts.delete(s),n._resetIframe()},Ye*jt))}}class et{get status(){return this._status}get application(){return structuredClone(this._application)}constructor(e,t,s){this._store=e,this._specifier=t,this._instanceId=s,this._status="unloaded",this._application=null,this._iframe=null,this._onStatusHandlers=new Set,this._subscriptionHandler=n=>{this._status=n.status,this._application=n.application;for(const a of this._onStatusHandlers)a(n.status)},this._store._client.subscribe("applications.dependency",{applicationSpecifier:this._specifier,applicationInstance:this._instanceId},this._subscriptionHandler).catch(n=>{console.error(`Dependency subscription failed for ${this._specifier}:${this._instanceId}:`,n)})}async frame(){return new Promise(e=>{if(this._iframe)return e(this._iframe);if(this._status==="ready")return this._iframe=this._buildIframe(),e(this._iframe);let t;const s=n=>{if(n==="ready")return t(),this._iframe=this._buildIframe(),e(this._iframe);if(n==="unloaded")return t(),e(null)};t=this.onStatus(s)})}onStatus(e){return this._onStatusHandlers.add(e),()=>{this._onStatusHandlers.delete(e)}}_buildIframe(){var e,t;const s=(t=(e=this._application)===null||e===void 0?void 0:e.versions)===null||t===void 0?void 0:t[0],n=s==null?void 0:s.baseUrl;if(!n)return console.error(`No baseUrl for dependency ${this._specifier}:${this._instanceId}`),null;const a=new URL(n);a.searchParams.set("applicationSpecifier",this._specifier),a.searchParams.set("applicationInstance",this._instanceId),a.searchParams.set("deviceId",this._store._client.deviceId);const r=document.createElement("iframe");return r.src=a.toString(),r}async _resetIframe(){if(!this._iframe)return;const e=this._iframe,t=e.src;e.src="about:blank";try{await this._store._client.request("applications.reset",{applicationSpecifier:this._specifier,applicationInstance:this._instanceId,cause:"heartbeat-timeout"})}catch(s){console.error(`Failed to reset application ${this._specifier}:${this._instanceId}:`,s)}this._iframe===e&&e.isConnected&&(e.src=t)}async _destroy(){this._status="unloaded",this._iframe&&(this._iframe.src="about:blank"),this._iframe=null;for(const s of this._onStatusHandlers)s("unloaded");const e=`${this._specifier}:${this._instanceId}`,t=this._store._heartbeatTimeouts.get(e);t&&(clearTimeout(t),this._store._heartbeatTimeouts.delete(e));try{await this._store._client.request("applications.destroy",{applicationSpecifier:this._specifier,applicationInstance:this._instanceId})}catch(s){console.error(`Failed to destroy ${this._specifier}:${this._instanceId}:`,s)}await this._store._client.unsubscribe("applications.dependency",{applicationSpecifier:this._specifier,applicationInstance:this._instanceId},this._subscriptionHandler).catch(s=>{console.error(`Dependency unsubscription failed for ${this._specifier}:${this._instanceId}:`,s)})}}const G=it.version;let m=null;function Rt(){return m}function Ft(i){tt(),m=new Xe,m.bind()}function tt(){m==null||m.unbind(),m=null}function Mt(...i){return x(m),m.on(...i)}function qt(...i){return x(m),m.once(...i)}function Ht(...i){return x(m),m.off(...i)}function Lt(...i){return x(m),m.send(...i)}function Dt(...i){return x(m),m.request(...i)}function Vt(...i){return x(m),m.subscribe(...i)}function zt(...i){return x(m),m.unsubscribe(...i)}function Bt(){return x(m),m.store}function Ut(){return x(m),m.applications}function Kt(){return x(m),m.media}function Wt(){return x(m),m.accounts}function Jt(){return x(m),m.users}function Qt(){return x(m),m.devices}function Gt(){return x(m),m.proxy}function Yt(){return x(m),m.rootSettingsNavigation}function Xt(){return x(m),m.weather}function es(){return x(m),m.currency}function ts(){return x(m),m.environment}function ss(){return x(m),m.mqtt}function x(i){if(!i)throw new Error("SDK is not configured")}exports.Accounts=Ee;exports.Applications=$e;exports.Client=Xe;exports.Currency=We;exports.DependencyHandle=et;exports.Devices=Ue;exports.Environment=Je;exports.Media=je;exports.Mqtt=Qe;exports.Navigation=Ge;exports.Proxy=Be;exports.Store=Ve;exports.StoreSlice=J;exports.Users=ze;exports.Weather=Ke;exports.accounts=Wt;exports.applications=Ut;exports.bridgeMessageValidator=Le;exports.clientMessageValidator=De;exports.configure=Ft;exports.currency=es;exports.destroy=tt;exports.devices=Qt;exports.environment=ts;exports.formatBridgeMessage=Et;exports.formatClientMessage=W;exports.globalClient=Rt;exports.media=Kt;exports.mqtt=ss;exports.off=Ht;exports.on=Mt;exports.once=qt;exports.proxy=Gt;exports.request=Dt;exports.rootSettingsNavigation=Yt;exports.send=Lt;exports.store=Bt;exports.subscribe=Vt;exports.telemetrySdkVersion=G;exports.unsubscribe=zt;exports.users=Jt;exports.weather=Xt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const nt="1.16.1",it={version:nt};class Ee{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("accounts.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current account");return e.account}}class $e{constructor(e){this._client=e}async getById(e){return(await this._client.request("applications.getById",{applicationId:e})).application}async getBySpecifier(e){return(await this._client.request("applications.getBySpecifier",{applicationSpecifier:e})).application}async getAllByMountPoint(e){return(await this._client.request("applications.getAllByMountPoint",{mountPoint:e})).applications}async setDependencies(e){return await this._client._dependencyStore.setDependencies(e),(t,s)=>this._client._dependencyStore.handleFor(t,s)}bind(e,t){if(this._client._messageInterceptors.has(e))throw new Error(`Interceptor already bound for message ${e}`);this._client._messageInterceptors.set(e,t)}}class Pe{constructor(e){this._client=e}async getAllFolders(){return(await this._client.request("mediaFolders.getAll",{})).folders}async getAllByFolderId(e){return(await this._client.request("media.getAllByFolderId",{folderId:e})).contents}async getAllByTag(e){return(await this._client.request("media.getAllByTag",{tagName:e})).contents}async getById(e){return(await this._client.request("media.getById",{id:e})).content}async openPicker(e){return new Promise((t,s)=>{const n=a=>{this._client.unsubscribe("media.openPicker",n),t(a.selection)};this._client.subscribe("media.openPicker",{accept:e==null?void 0:e.accept,currentValue:e==null?void 0:e.currentValue},n).then(a=>{a.success||s(new Error("Failed to open media picker"))}).catch(s)})}}var b;(function(i){i.assertEqual=n=>{};function e(n){}i.assertIs=e;function t(n){throw new Error}i.assertNever=t,i.arrayToEnum=n=>{const a={};for(const r of n)a[r]=r;return a},i.getValidEnumValues=n=>{const a=i.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),r={};for(const o of a)r[o]=n[o];return i.objectValues(r)},i.objectValues=n=>i.objectKeys(n).map(function(a){return n[a]}),i.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&a.push(r);return a},i.find=(n,a)=>{for(const r of n)if(a(r))return r},i.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(r=>typeof r=="string"?`'${r}'`:r).join(a)}i.joinValues=s,i.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var ye;(function(i){i.mergeShapes=(e,t)=>({...e,...t})})(ye||(ye={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),A=i=>{switch(typeof i){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(i)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(i)?h.array:i===null?h.null:i.then&&typeof i.then=="function"&&i.catch&&typeof i.catch=="function"?h.promise:typeof Map<"u"&&i instanceof Map?h.map:typeof Set<"u"&&i instanceof Set?h.set:typeof Date<"u"&&i instanceof Date?h.date:h.object;default:return h.unknown}},d=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class N extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const r of a.issues)if(r.code==="invalid_union")r.unionErrors.map(n);else if(r.code==="invalid_return_type")n(r.returnTypeError);else if(r.code==="invalid_arguments")n(r.argumentsError);else if(r.path.length===0)s._errors.push(t(r));else{let o=s,c=0;for(;c<r.path.length;){const l=r.path[c];c===r.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(r))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}static assert(e){if(!(e instanceof N))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}N.create=i=>new N(i);const de=(i,e)=>{let t;switch(i.code){case d.invalid_type:i.received===h.undefined?t="Required":t=`Expected ${i.expected}, received ${i.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(i.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${b.joinValues(i.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${b.joinValues(i.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${b.joinValues(i.options)}, received '${i.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof i.validation=="object"?"includes"in i.validation?(t=`Invalid input: must include "${i.validation.includes}"`,typeof i.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${i.validation.position}`)):"startsWith"in i.validation?t=`Invalid input: must start with "${i.validation.startsWith}"`:"endsWith"in i.validation?t=`Invalid input: must end with "${i.validation.endsWith}"`:b.assertNever(i.validation):i.validation!=="regex"?t=`Invalid ${i.validation}`:t="Invalid";break;case d.too_small:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at least":"more than"} ${i.minimum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at least":"over"} ${i.minimum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="bigint"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(i.minimum))}`:t="Invalid input";break;case d.too_big:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at most":"less than"} ${i.maximum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at most":"under"} ${i.maximum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="bigint"?t=`BigInt must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly":i.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(i.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${i.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,b.assertNever(i)}return{message:t}};let at=de;function rt(){return at}const ot=i=>{const{data:e,path:t,errorMaps:s,issueData:n}=i,a=[...t,...n.path||[]],r={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(r,{data:e,defaultError:o}).message;return{...n,path:a,message:o}};function u(i,e){const t=rt(),s=ot({issueData:e,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,t,t===de?void 0:de].filter(n=>!!n)});i.common.issues.push(s)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return g;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t){const a=await n.key,r=await n.value;s.push({key:a,value:r})}return T.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:r}=n;if(a.status==="aborted"||r.status==="aborted")return g;a.status==="dirty"&&e.dirty(),r.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof r.value<"u"||n.alwaysSet)&&(s[a.value]=r.value)}return{status:e.value,value:s}}}const g=Object.freeze({status:"aborted"}),ue=i=>({status:"dirty",value:i}),C=i=>({status:"valid",value:i}),ve=i=>i.status==="aborted",be=i=>i.status==="dirty",q=i=>i.status==="valid",se=i=>typeof Promise<"u"&&i instanceof Promise;var p;(function(i){i.errToObj=e=>typeof e=="string"?{message:e}:e||{},i.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));class ${constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const we=(i,e)=>{if(q(e))return{success:!0,data:e.value};if(!i.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new N(i.common.issues);return this._error=t,this._error}}};function y(i){if(!i)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=i;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,r)=>{const{message:o}=i;return a.code==="invalid_enum_value"?{message:o??r.defaultError}:typeof r.data>"u"?{message:o??s??r.defaultError}:a.code!=="invalid_type"?{message:r.defaultError}:{message:o??t??r.defaultError}},description:n}}class v{get description(){return this._def.description}_getType(e){return A(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:A(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:A(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(se(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)},n=this._parseSync({data:e,path:s.path,parent:s});return we(s,n)}"~validate"(e){var t,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:n});return q(a)?{value:a.value}:{issues:n.common.issues}}catch(a){(s=(t=a==null?void 0:a.message)==null?void 0:t.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(a=>q(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(se(n)?n:Promise.resolve(n));return we(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const r=e(n),o=()=>a.addIssue({code:d.custom,...s(n)});return typeof Promise<"u"&&r instanceof Promise?r.then(c=>c?!0:(o(),!1)):r?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new L({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return E.create(this,this._def)}nullable(){return D.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I.create(this)}promise(){return re.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return ae.create(this,e,this._def)}transform(e){return new L({...y(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new fe({...y(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new At({typeName:_.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new me({...y(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ge.create(this,e)}readonly(){return _e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ct=/^c[^\s-]{8,}$/i,dt=/^[0-9a-z]+$/,ut=/^[0-9A-HJKMNP-TV-Z]{26}$/i,lt=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ht=/^[a-z0-9_-]{21}$/i,pt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ft=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,mt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ce;const gt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,yt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,vt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,bt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,je="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",xt=new RegExp(`^${je}$`);function Re(i){let e="[0-5]\\d";i.precision?e=`${e}\\.\\d{${i.precision}}`:i.precision==null&&(e=`${e}(\\.\\d+)?`);const t=i.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function St(i){return new RegExp(`^${Re(i)}$`)}function Tt(i){let e=`${je}T${Re(i)}`;const t=[];return t.push(i.local?"Z?":"Z"),i.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ct(i,e){return!!((e==="v4"||!e)&&gt.test(i)||(e==="v6"||!e)&&vt.test(i))}function It(i,e){if(!pt.test(i))return!1;try{const[t]=i.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Nt(i,e){return!!((e==="v4"||!e)&&yt.test(i)||(e==="v6"||!e)&&bt.test(i))}class O extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.string,received:n.parsedType}),g}const t=new T;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,r=e.data.length<n.value;(a||r)&&(s=this._getOrReturnCtx(e,s),a?u(s,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):r&&u(s,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")mt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"email",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")ce||(ce=new RegExp(_t,"u")),ce.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"emoji",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")lt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"uuid",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="nanoid")ht.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"nanoid",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")ct.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")dt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid2",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")ut.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ulid",code:d.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),u(s,{validation:"url",code:d.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"regex",code:d.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Tt(n).test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="date"?xt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"date",message:n.message}),t.dirty()):n.kind==="time"?St(n).test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"time",message:n.message}),t.dirty()):n.kind==="duration"?ft.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"duration",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="ip"?Ct(e.data,n.version)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ip",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="jwt"?It(e.data,n.alg)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"jwt",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="cidr"?Nt(e.data,n.version)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cidr",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="base64"?wt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"base64",code:d.invalid_string,message:n.message}),t.dirty()):n.kind==="base64url"?kt.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"base64url",code:d.invalid_string,message:n.message}),t.dirty()):b.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:d.invalid_string,...p.errToObj(s)})}_addCheck(e){return new O({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...p.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...p.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...p.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new O({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new O({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new O({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}O.create=i=>new O({checks:[],typeName:_.ZodString,coerce:(i==null?void 0:i.coerce)??!1,...y(i)});function Zt(i,e){const t=(i.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(i.toFixed(n).replace(".","")),r=Number.parseInt(e.toFixed(n).replace(".",""));return a%r/10**n}class Y extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.number,received:n.parsedType}),g}let t;const s=new T;for(const n of this._def.checks)n.kind==="int"?b.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),u(t,{code:d.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?Zt(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),u(t,{code:d.not_finite,message:n.message}),s.dirty()):b.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Y.create=i=>new Y({checks:[],typeName:_.ZodNumber,coerce:(i==null?void 0:i.coerce)||!1,...y(i)});class X extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let t;const s=new T;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),u(t,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):b.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.bigint,received:t.parsedType}),g}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new X({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}X.create=i=>new X({checks:[],typeName:_.ZodBigInt,coerce:(i==null?void 0:i.coerce)??!1,...y(i)});class ke extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.boolean,received:t.parsedType}),g}return C(e.data)}}ke.create=i=>new ke({typeName:_.ZodBoolean,coerce:(i==null?void 0:i.coerce)||!1,...y(i)});class ne extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.date,received:n.parsedType}),g}if(Number.isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_date}),g}const t=new T;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):b.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ne.create=i=>new ne({checks:[],coerce:(i==null?void 0:i.coerce)||!1,typeName:_.ZodDate,...y(i)});class xe extends v{_parse(e){if(this._getType(e)!==h.symbol){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.symbol,received:t.parsedType}),g}return C(e.data)}}xe.create=i=>new xe({typeName:_.ZodSymbol,...y(i)});class Se extends v{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.undefined,received:t.parsedType}),g}return C(e.data)}}Se.create=i=>new Se({typeName:_.ZodUndefined,...y(i)});class Te extends v{_parse(e){if(this._getType(e)!==h.null){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.null,received:t.parsedType}),g}return C(e.data)}}Te.create=i=>new Te({typeName:_.ZodNull,...y(i)});class le extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}le.create=i=>new le({typeName:_.ZodAny,...y(i)});class Ce extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}Ce.create=i=>new Ce({typeName:_.ZodUnknown,...y(i)});class P extends v{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.never,received:t.parsedType}),g}}P.create=i=>new P({typeName:_.ZodNever,...y(i)});class Ie extends v{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.void,received:t.parsedType}),g}return C(e.data)}}Ie.create=i=>new Ie({typeName:_.ZodVoid,...y(i)});class I extends v{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==h.array)return u(t,{code:d.invalid_type,expected:h.array,received:t.parsedType}),g;if(n.exactLength!==null){const r=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(r||o)&&(u(t,{code:r?d.too_big:d.too_small,minimum:o?n.exactLength.value:void 0,maximum:r?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(u(t,{code:d.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(u(t,{code:d.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((r,o)=>n.type._parseAsync(new $(t,r,t.path,o)))).then(r=>T.mergeArray(s,r));const a=[...t.data].map((r,o)=>n.type._parseSync(new $(t,r,t.path,o)));return T.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new I({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new I({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new I({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}}I.create=(i,e)=>new I({type:i,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...y(e)});function M(i){if(i instanceof k){const e={};for(const t in i.shape){const s=i.shape[t];e[t]=E.create(M(s))}return new k({...i._def,shape:()=>e})}else return i instanceof I?new I({...i._def,type:M(i.element)}):i instanceof E?E.create(M(i.unwrap())):i instanceof D?D.create(M(i.unwrap())):i instanceof R?R.create(i.items.map(e=>M(e))):i}class k extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=b.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==h.object){const c=this._getOrReturnCtx(e);return u(c,{code:d.invalid_type,expected:h.object,received:c.parsedType}),g}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),r=[];if(!(this._def.catchall instanceof P&&this._def.unknownKeys==="strip"))for(const c in s.data)a.includes(c)||r.push(c);const o=[];for(const c of a){const l=n[c],f=s.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new $(s,f,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof P){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of r)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")r.length>0&&(u(s,{code:d.unrecognized_keys,keys:r}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of r){const f=s.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new $(s,f,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const f=await l.key,w=await l.value;c.push({key:f,value:w,alwaysSet:l.alwaysSet})}return c}).then(c=>T.mergeObjectSync(t,c)):T.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new k({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a;const r=((a=(n=this._def).errorMap)==null?void 0:a.call(n,t,s).message)??s.defaultError;return t.code==="unrecognized_keys"?{message:p.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new k({...this._def,unknownKeys:"strip"})}passthrough(){return new k({...this._def,unknownKeys:"passthrough"})}extend(e){return new k({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new k({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new k({...this._def,catchall:e})}pick(e){const t={};for(const s of b.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new k({...this._def,shape:()=>t})}omit(e){const t={};for(const s of b.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new k({...this._def,shape:()=>t})}deepPartial(){return M(this)}partial(e){const t={};for(const s of b.objectKeys(this.shape)){const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new k({...this._def,shape:()=>t})}required(e){const t={};for(const s of b.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof E;)n=n._def.innerType;t[s]=n}return new k({...this._def,shape:()=>t})}keyof(){return Fe(b.objectKeys(this.shape))}}k.create=(i,e)=>new k({shape:()=>i,unknownKeys:"strip",catchall:P.create(),typeName:_.ZodObject,...y(e)});k.strictCreate=(i,e)=>new k({shape:()=>i,unknownKeys:"strict",catchall:P.create(),typeName:_.ZodObject,...y(e)});k.lazycreate=(i,e)=>new k({shape:i,unknownKeys:"strip",catchall:P.create(),typeName:_.ZodObject,...y(e)});class ie extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const r=a.map(o=>new N(o.ctx.common.issues));return u(t,{code:d.invalid_union,unionErrors:r}),g}if(t.common.async)return Promise.all(s.map(async a=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(n);{let a;const r=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:l});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:l}),l.common.issues.length&&r.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=r.map(c=>new N(c));return u(t,{code:d.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}}ie.create=(i,e)=>new ie({options:i,typeName:_.ZodUnion,...y(e)});function he(i,e){const t=A(i),s=A(e);if(i===e)return{valid:!0,data:i};if(t===h.object&&s===h.object){const n=b.objectKeys(e),a=b.objectKeys(i).filter(o=>n.indexOf(o)!==-1),r={...i,...e};for(const o of a){const c=he(i[o],e[o]);if(!c.valid)return{valid:!1};r[o]=c.data}return{valid:!0,data:r}}else if(t===h.array&&s===h.array){if(i.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<i.length;a++){const r=i[a],o=e[a],c=he(r,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===h.date&&s===h.date&&+i==+e?{valid:!0,data:i}:{valid:!1}}class ae extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,r)=>{if(ve(a)||ve(r))return g;const o=he(a.value,r.value);return o.valid?((be(a)||be(r))&&t.dirty(),{status:t.value,value:o.data}):(u(s,{code:d.invalid_intersection_types}),g)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,r])=>n(a,r)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ae.create=(i,e,t)=>new ae({left:i,right:e,typeName:_.ZodIntersection,...y(t)});class R extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return u(s,{code:d.invalid_type,expected:h.array,received:s.parsedType}),g;if(s.data.length<this._def.items.length)return u(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&s.data.length>this._def.items.length&&(u(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,r)=>{const o=this._def.items[r]||this._def.rest;return o?o._parse(new $(s,a,s.path,r)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>T.mergeArray(t,a)):T.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new R({...this._def,rest:e})}}R.create=(i,e)=>{if(!Array.isArray(i))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new R({items:i,typeName:_.ZodTuple,rest:null,...y(e)})};class Ne extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return u(s,{code:d.invalid_type,expected:h.map,received:s.parsedType}),g;const n=this._def.keyType,a=this._def.valueType,r=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new $(s,o,s.path,[l,"key"])),value:a._parse(new $(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of r){const l=await c.key,f=await c.value;if(l.status==="aborted"||f.status==="aborted")return g;(l.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(l.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of r){const l=c.key,f=c.value;if(l.status==="aborted"||f.status==="aborted")return g;(l.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(l.value,f.value)}return{status:t.value,value:o}}}}Ne.create=(i,e,t)=>new Ne({valueType:e,keyType:i,typeName:_.ZodMap,...y(t)});class ee extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return u(s,{code:d.invalid_type,expected:h.set,received:s.parsedType}),g;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(u(s,{code:d.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(u(s,{code:d.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function r(c){const l=new Set;for(const f of c){if(f.status==="aborted")return g;f.status==="dirty"&&t.dirty(),l.add(f.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>a._parse(new $(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>r(c)):r(o)}min(e,t){return new ee({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new ee({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ee.create=(i,e)=>new ee({valueType:i,minSize:null,maxSize:null,typeName:_.ZodSet,...y(e)});class Ze extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ze.create=(i,e)=>new Ze({getter:i,typeName:_.ZodLazy,...y(e)});class pe extends v{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}}pe.create=(i,e)=>new pe({value:i,typeName:_.ZodLiteral,...y(e)});function Fe(i,e){return new H({values:i,typeName:_.ZodEnum,...y(e)})}class H extends v{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{expected:b.joinValues(s),received:t.parsedType,code:d.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{received:t.data,code:d.invalid_enum_value,options:s}),g}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return H.create(e,{...this._def,...t})}exclude(e,t=this._def){return H.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}H.create=Fe;class Ae extends v{_parse(e){const t=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const n=b.objectValues(t);return u(s,{expected:b.joinValues(n),received:s.parsedType,code:d.invalid_type}),g}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=b.objectValues(t);return u(s,{received:s.data,code:d.invalid_enum_value,options:n}),g}return C(e.data)}get enum(){return this._def.values}}Ae.create=(i,e)=>new Ae({values:i,typeName:_.ZodNativeEnum,...y(e)});class re extends v{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return u(t,{code:d.invalid_type,expected:h.promise,received:t.parsedType}),g;const s=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return C(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}re.create=(i,e)=>new re({type:i,typeName:_.ZodPromise,...y(e)});class L extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:r=>{u(s,r),r.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const r=n.transform(s.data,a);if(s.common.async)return Promise.resolve(r).then(async o=>{if(t.value==="aborted")return g;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?g:c.status==="dirty"||t.value==="dirty"?ue(c.value):c});{if(t.value==="aborted")return g;const o=this._def.schema._parseSync({data:r,path:s.path,parent:s});return o.status==="aborted"?g:o.status==="dirty"||t.value==="dirty"?ue(o.value):o}}if(n.type==="refinement"){const r=o=>{const c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),r(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),r(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const r=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!q(r))return g;const o=n.transform(r.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(r=>q(r)?Promise.resolve(n.transform(r.value,a)).then(o=>({status:t.value,value:o})):g);b.assertNever(n)}}L.create=(i,e,t)=>new L({schema:i,typeName:_.ZodEffects,effect:e,...y(t)});L.createWithPreprocess=(i,e,t)=>new L({schema:e,effect:{type:"preprocess",transform:i},typeName:_.ZodEffects,...y(t)});class E extends v{_parse(e){return this._getType(e)===h.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}E.create=(i,e)=>new E({innerType:i,typeName:_.ZodOptional,...y(e)});class D extends v{_parse(e){return this._getType(e)===h.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}D.create=(i,e)=>new D({innerType:i,typeName:_.ZodNullable,...y(e)});class fe extends v{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}fe.create=(i,e)=>new fe({innerType:i,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class me extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return se(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}me.create=(i,e)=>new me({innerType:i,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class Oe extends v{_parse(e){if(this._getType(e)!==h.nan){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.nan,received:t.parsedType}),g}return{status:"valid",value:e.data}}}Oe.create=i=>new Oe({typeName:_.ZodNaN,...y(i)});class At extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class ge extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?g:n.status==="dirty"?(t.dirty(),ue(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?g:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new ge({in:e,out:t,typeName:_.ZodPipeline})}}class _e extends v{_parse(e){const t=this._def.innerType._parse(e),s=n=>(q(n)&&(n.value=Object.freeze(n.value)),n);return se(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}}_e.create=(i,e)=>new _e({innerType:i,typeName:_.ZodReadonly,...y(e)});var _;(function(i){i.ZodString="ZodString",i.ZodNumber="ZodNumber",i.ZodNaN="ZodNaN",i.ZodBigInt="ZodBigInt",i.ZodBoolean="ZodBoolean",i.ZodDate="ZodDate",i.ZodSymbol="ZodSymbol",i.ZodUndefined="ZodUndefined",i.ZodNull="ZodNull",i.ZodAny="ZodAny",i.ZodUnknown="ZodUnknown",i.ZodNever="ZodNever",i.ZodVoid="ZodVoid",i.ZodArray="ZodArray",i.ZodObject="ZodObject",i.ZodUnion="ZodUnion",i.ZodDiscriminatedUnion="ZodDiscriminatedUnion",i.ZodIntersection="ZodIntersection",i.ZodTuple="ZodTuple",i.ZodRecord="ZodRecord",i.ZodMap="ZodMap",i.ZodSet="ZodSet",i.ZodFunction="ZodFunction",i.ZodLazy="ZodLazy",i.ZodLiteral="ZodLiteral",i.ZodEnum="ZodEnum",i.ZodEffects="ZodEffects",i.ZodNativeEnum="ZodNativeEnum",i.ZodOptional="ZodOptional",i.ZodNullable="ZodNullable",i.ZodDefault="ZodDefault",i.ZodCatch="ZodCatch",i.ZodPromise="ZodPromise",i.ZodBranded="ZodBranded",i.ZodPipeline="ZodPipeline",i.ZodReadonly="ZodReadonly"})(_||(_={}));const Z=O.create,Me=le.create;P.create;I.create;const qe=k.create;ie.create;ae.create;R.create;const He=pe.create,Ot=H.create;re.create;E.create;D.create;const Le=qe({type:He("bridge"),name:Z(),data:Me()});function Et(i){return{...i,type:"bridge"}}const De=qe({type:He("client"),telemetrySdkVersion:Z(),applicationSpecifier:Z(),applicationInstance:Z(),runtime:Ot(["window","worker"]),name:Z(),data:Me(),responseName:Z().optional(),subscriptionName:Z().optional(),unsubscribeName:Z().optional()});function W(i){return{...i,type:"client"}}class Ve{constructor(e){this._client=e}get application(){return new J("application","application",this._client)}get instance(){return new J("instance",this._client.applicationInstance,this._client)}get device(){return new J("device",this._client.deviceId,this._client)}shared(e){return new J("shared",e,this._client)}}class J{constructor(e,t,s){this._kind=e,this._namespace=t,this._client=s}async set(e,t){return(await this._client.request("store.set",{kind:this._kind,namespace:this._namespace,key:e,value:t})).success}async get(e){return(await this._client.request("store.get",{kind:this._kind,namespace:this._namespace,key:e})).value}async subscribe(e,t){return(await this._client.subscribe("store.subscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async unsubscribe(e,t){return(await this._client.unsubscribe("store.unsubscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async delete(e){return(await this._client.request("store.delete",{kind:this._kind,namespace:this._namespace,key:e})).success}}class $t{constructor(e){if(e._client._applicationSpecifier!=="rootSettingsNavigation")throw new Error("RootSettingsNavigation can only be used in the rootSettingsNavigation mount point");this._store=e}async setRootSettingsNavigation(e){var t;const s=this._store.shared("root-settings-navigation"),n=(t=await s.get("navigation"))!==null&&t!==void 0?t:{},a=this._store._client._applicationSpecifier;n[a]={applicationSpecifier:a,entries:e.entries},s.set("navigation",n)}async getRootSettingsNavigation(){var e;const s=(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{},n=this._store._client._applicationSpecifier;return s[n]}async getAllRootSettingsNavigation(){var e;return(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{}}}class ze{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("users.getCurrent",{});if(!e.success)throw new Error(e.error||"Failed to fetch current user");return e.user}}class Be{constructor(e){this._client=e}async fetch(e,t){var s;let n;typeof e=="string"?n=e:e instanceof URL?n=e.toString():(n=e.url,t||(t={method:e.method,headers:e.headers,body:e.body,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity}));let a={};t!=null&&t.headers&&(t.headers instanceof Headers?t.headers.forEach((f,w)=>{a[w]=f}):Array.isArray(t.headers)?t.headers.forEach(([f,w])=>{a[f]=w}):a=t.headers);const r=await this._client.request("proxy.fetch",{url:n,method:(t==null?void 0:t.method)||"GET",headers:a,body:(s=t==null?void 0:t.body)!==null&&s!==void 0?s:null});if(!r.success)throw new TypeError(r.errorMessage,{cause:r.errorCause?Error(r.errorCause):void 0});const o=new Headers(r.headers),c={status:r.status,statusText:r.statusText,headers:o};let l=null;if(r.body!==null&&r.body!==void 0)if(r.bodyType==="binary"){const f=atob(r.body),w=new Uint8Array(f.length);for(let S=0;S<f.length;S++)w[S]=f.charCodeAt(S);l=w}else r.bodyType==="text"?l=r.body:r.bodyType==="json"&&(l=JSON.stringify(r.body));return new Response(l,c)}}class Ue{constructor(e){this._client=e}async getInformation(){const e=await this._client.request("devices.getInformation",{});if(!e.success)throw new Error("Failed to get device information");return e.deviceInformation}async getCapabilities(){const e=await this._client.request("devices.getCapabilities",{});if(!e.success)throw new Error("Failed to get device capabilities");return e.capabilities}}class Ke{constructor(e){this._client=e}async getCities(e){const t=await this._client.request("weather.getCities",e);if(!t.success)throw new Error(t.error||"Failed to fetch cities");return t.data||[]}async getConditions(e){const t=await this._client.request("weather.getConditions",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather conditions");return t}async getDailyForecast(e){const t=await this._client.request("weather.getDailyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch daily forecast");return t}async getHourlyForecast(e){const t=await this._client.request("weather.getHourlyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch hourly forecast");return t}async getAlerts(e){const t=await this._client.request("weather.getAlerts",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather alerts");return t}}class We{constructor(e){this._client=e}async getSymbols(){const e=await this._client.request("currency.getSymbols",{});if(!e.success||!e.symbols)throw new Error("Failed to fetch currency symbols");return e.symbols}async getRates(e){var t,s,n;const a=await this._client.request("currency.getRates",e);if(!a.success||!a.rates)throw((t=a.error)===null||t===void 0?void 0:t.code)===201?new Error(`Invalid base currency '${e.base}'`):((s=a.error)===null||s===void 0?void 0:s.code)===202?new Error(`Invalid target currency symbol '${e.symbols}'`):new Error(((n=a.error)===null||n===void 0?void 0:n.message)||"Failed to fetch currency rates");return a.rates}}class Je{constructor(e){this._client=e}async getColorScheme(){return(await this._client.request("environment.getColorScheme",{})).colorScheme}async subscribeColorScheme(e){return(await this._client.subscribe("environment.subscribeColorScheme",{},e)).success}async unsubscribeColorScheme(e){return(await this._client.unsubscribe("environment.unsubscribeColorScheme",{},e)).success}}class Qe{constructor(e){this._client=e}async discover(){const e=await this._client.request("mqtt.discover",{});if(!e.success)throw new Error("Failed to discover MQTT brokers");return e.brokers}async connect(e,t){const s=await this._client.request("mqtt.connect",{brokerUrl:e,...t});if(!s.success)throw new Error("Failed to connect to MQTT broker");return s.clientId}async disconnect(e){if(!(await this._client.request("mqtt.disconnect",{clientId:e})).success)throw new Error("Failed to disconnect from MQTT broker")}async publish(e,t,s,n){if(!(await this._client.request("mqtt.publish",{clientId:e,topic:t,payload:s,...n})).success)throw new Error("Failed to publish MQTT message")}async subscribe(e,t,s,n){return(await this._client.subscribe("mqtt.subscribe",{clientId:e,topic:t,...n},s)).success}async unsubscribe(e,t,s){return(await this._client.unsubscribe("mqtt.unsubscribe",{clientId:e,topic:t},s)).success}async getConnectionStatus(e){const t=await this._client.request("mqtt.getConnectionStatus",{clientId:e});if(!t.success)throw new Error("Failed to get MQTT connection status");return t.status}async subscribeConnectionStatus(e,t){return(await this._client.subscribe("mqtt.subscribeConnectionStatus",{clientId:e},t)).success}async unsubscribeConnectionStatus(e,t){return(await this._client.unsubscribe("mqtt.unsubscribeConnectionStatus",{clientId:e},t)).success}}class Ge{constructor(e){this._originalPushState=null,this._originalReplaceState=null,this._popstateHandler=null,this._backHandler=null,this._forwardHandler=null,this._client=e}bind(){typeof window>"u"||this._originalPushState||(this._originalPushState=history.pushState.bind(history),history.pushState=(...e)=>{this._originalPushState(...e),this._sendLocationChanged()},this._originalReplaceState=history.replaceState.bind(history),history.replaceState=(...e)=>{this._originalReplaceState(...e),this._sendLocationChanged()},this._popstateHandler=()=>this._sendLocationChanged(),window.addEventListener("popstate",this._popstateHandler),this._backHandler=()=>history.back(),this._forwardHandler=()=>history.forward(),this._client.on("navigation.back",this._backHandler),this._client.on("navigation.forward",this._forwardHandler),this._sendLocationChanged())}unbind(){typeof window>"u"||(this._originalPushState&&(history.pushState=this._originalPushState,this._originalPushState=null),this._originalReplaceState&&(history.replaceState=this._originalReplaceState,this._originalReplaceState=null),this._popstateHandler&&(window.removeEventListener("popstate",this._popstateHandler),this._popstateHandler=null),this._backHandler&&(this._client.off("navigation.back",this._backHandler),this._backHandler=null),this._forwardHandler&&(this._client.off("navigation.forward",this._forwardHandler),this._forwardHandler=null))}_sendLocationChanged(){this._client.send("navigation.locationChanged",{pathname:window.location.pathname})}}const B=1e3*30,Ye=1e3*5,oe=typeof window>"u"&&typeof self<"u",te=oe?"worker":"window",Q=oe?self:window;function U(i){oe?self.postMessage(i):Q.parent.postMessage(i,"*")}class Xe{constructor(){this._applicationInstance="",this._applicationSpecifier="",this._deviceId="",this._heartbeatInterval=null,this._heartbeatSignature=K(),this._messageInterceptors=new Map,this._onHandlers=new Map,this._onceHandlers=new Map,this._subscriptionNamesByHandler=new Map,this._subscriptionNamesBySubjectName=new Map,this._dependencyStore=new jt(this),this._navigation=new Ge(this)}get accounts(){return new Ee(this)}get users(){return new ze(this)}get store(){return new Ve(this)}get applications(){return new $e(this)}get media(){return new Pe(this)}get proxy(){return new Be(this)}get devices(){return new Ue(this)}get rootSettingsNavigation(){return new $t(this.store)}get weather(){return new Ke(this)}get currency(){return new We(this)}get environment(){return new Je(this)}get mqtt(){return new Qe(this)}get applicationSpecifier(){return this._applicationSpecifier}get applicationInstance(){return this._applicationInstance}get deviceId(){return this._deviceId}bind(){var e,t;const s=new URL(Q.location.href),n=s.searchParams;this._applicationInstance=n.get("applicationInstance")||"single",this._deviceId=n.get("deviceId")||this._applicationInstance;const a=/^[a-z0-9-]{40}$/i;if(this._applicationSpecifier=(e=n.get("applicationSpecifier"))!==null&&e!==void 0?e:"",!this._applicationSpecifier||!a.test(this._applicationSpecifier)){const r=s.hostname.split(".");this._applicationSpecifier=(t=r[0])!==null&&t!==void 0?t:""}if(!this._applicationSpecifier||!a.test(this._applicationSpecifier))throw console.error("TelemetryOS apps require an applicationSpecifier in the URL query parameters or subdomain. Make sure your app is being served correctly through the TelemetryOS platform or development environment."),new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);this._windowMessageHandler=r=>{if(r.source===Q||!r.data||typeof r.data!="object"||!("type"in r.data)||r.data.type!=="client"&&r.data.type!=="bridge")return;let o;if(r.data.type==="client"){const c=De.safeParse(r.data);if(!c.success){const S=r.data;S&&typeof S=="object"&&S.type==="client"&&console.warn("[sdk-client] Received a message that looks like a client message but failed schema validation. This may indicate a version mismatch between the SDK and the host environment.",c.error.issues);return}const l=c.data,f=this._messageInterceptors.get(l.name);if(!f)return U(l);let w;try{w=f(l)}catch(S){console.error(`Error in interceptor for message ${l.name}:`,S)}if(!w)return;o={...w,type:"bridge",...r.data.responseName?{name:r.data.responseName}:{}}}if(!o){const c=Le.safeParse(r.data);if(!c.success){const w=r.data;w&&typeof w=="object"&&w.type==="bridge"&&console.warn("[sdk-client] Received a message that looks like a bridge message but failed schema validation. This may indicate a version mismatch between the SDK and the host environment.",c.error.issues);return}o=c.data;const l=this._onHandlers.get(o.name),f=this._onceHandlers.get(o.name);if(l)for(const w of l)w(o.data);if(f){for(const w of f)w(o.data);this._onceHandlers.delete(o.name)}}if(!oe)for(let c=0;c<window.frames.length;c+=1)window.frames[c].postMessage(o,"*")},Q.addEventListener("message",this._windowMessageHandler),this._navigation.bind(),this._heartbeatInterval=setInterval(()=>{this.send("heartbeat",{signature:this._heartbeatSignature})},Ye)}unbind(){this._windowMessageHandler&&(this._navigation.unbind(),Q.removeEventListener("message",this._windowMessageHandler),this._heartbeatInterval&&clearInterval(this._heartbeatInterval))}send(e,t){const s=W({telemetrySdkVersion:G,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,runtime:te,name:e,data:t});U(s)}request(e,t,s){var n;const a=K(),r=W({telemetrySdkVersion:G,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,runtime:te,name:e,data:t,responseName:a});U(r);const o=(n=s==null?void 0:s.timeout)!==null&&n!==void 0?n:B;let c=!1,l;const f=new Promise(S=>{l=j=>{c||S(j)},this.once(a,l)});if(o===0)return f;const w=new Promise((S,j)=>{const V=new Error(`${e} message request with response name of ${a} timed out after ${o}`);setTimeout(()=>{c=!0,this.off(a,l),j(V)},o)});return Promise.race([w,f])}async subscribe(e,t,s){let n,a;typeof t=="function"?a=t:(n=t,a=s);const r=K(),o=K();let c=this._subscriptionNamesBySubjectName.get(e);c||(c=[],this._subscriptionNamesBySubjectName.set(e,c)),c.push(r),this._subscriptionNamesByHandler.set(a,r),this.on(r,a);const l=W({telemetrySdkVersion:G,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,runtime:te,name:e,data:n,responseName:o,subscriptionName:r});U(l);let f=!1,w;const S=new Promise((V,F)=>{const z=new Error(`${e} subscribe request with subscription name of ${r} and response name of ${o} timed out after ${B}`);setTimeout(()=>{f=!0,this.off(o,w),F(z)},B)}),j=new Promise(V=>{w=F=>{f||V(F)},this.once(o,w)});return Promise.race([S,j])}async unsubscribe(e,t,s){let n,a;typeof t=="function"?a=t:(n=t,a=s);const r=K();let o=[];if(a){const c=this._subscriptionNamesByHandler.get(a);if(!c)return{success:!1};o=[c],this._subscriptionNamesByHandler.delete(a)}else if(!this._subscriptionNamesBySubjectName.get(e))return{success:!1};for await(const c of o){this.off(c,a);const l=W({telemetrySdkVersion:G,applicationInstance:this._applicationInstance,applicationSpecifier:this._applicationSpecifier,runtime:te,name:e,data:n,responseName:r,unsubscribeName:c});U(l);let f=!1,w;const S=new Promise((F,z)=>{const st=new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${r} timed out after ${B}`);setTimeout(()=>{f=!0,this.off(r,w),z(st)},B)}),j=new Promise(F=>{w=z=>{f||F(z)},this.once(r,w)});if(!(await Promise.race([S,j])).success)return{success:!1}}return{success:!0}}on(e,t){var s;const n=(s=this._onHandlers.get(e))!==null&&s!==void 0?s:[];n.length===0&&this._onHandlers.set(e,n),n.push(t)}once(e,t){var s;const n=(s=this._onceHandlers.get(e))!==null&&s!==void 0?s:[];n.length===0&&this._onceHandlers.set(e,n),n.push(t)}off(e,t){const s=this._onHandlers.get(e),n=this._onceHandlers.get(e);if(!(!s&&!n)){if(s){for(let a=0;a<s.length;a+=1)t&&s[a]!==t||(s.splice(a,1),a-=1);s.length===0&&this._onHandlers.delete(e)}if(n){for(let a=0;a<n.length;a+=1)t&&n[a]!==t||(n.splice(a,1),a-=1);n.length===0&&this._onceHandlers.delete(e)}}}}function K(){return Math.random().toString(36).slice(2,9)}const Pt=3;class jt{constructor(e){this._client=e,this._dependencies=new Map,this._heartbeatTimeouts=new Map,this._client._messageInterceptors.set("heartbeat",t=>{this._handleHeartbeat(t.applicationSpecifier,t.applicationInstance)})}async setDependencies(e){this._client.send("applications.setDependencies",{applicationSpecifiers:e});const t=[];for(const[s,n]of this._dependencies.entries()){const[a,r]=s.split(":");(!e[a]||!e[a].includes(r))&&(t.push(n._destroy()),this._dependencies.delete(s))}await Promise.all(t)}handleFor(e,t){let s=this._dependencies.get(`${e}:${t}`);return s||(s=new et(this,e,t),this._dependencies.set(`${e}:${t}`,s),s)}_handleHeartbeat(e,t){const s=`${e}:${t}`,n=this._dependencies.get(s);if(!n)return;const a=this._heartbeatTimeouts.get(s);a&&clearTimeout(a),this._heartbeatTimeouts.set(s,setTimeout(()=>{this._heartbeatTimeouts.delete(s),n._resetIframe()},Ye*Pt))}}class et{get status(){return this._status}get application(){return structuredClone(this._application)}constructor(e,t,s){this._store=e,this._specifier=t,this._instanceId=s,this._status="unloaded",this._application=null,this._iframe=null,this._onStatusHandlers=new Set,this._subscriptionHandler=n=>{this._status=n.status,this._application=n.application;for(const a of this._onStatusHandlers)a(n.status)},this._store._client.subscribe("applications.dependency",{applicationSpecifier:this._specifier,applicationInstance:this._instanceId},this._subscriptionHandler).catch(n=>{console.error(`Dependency subscription failed for ${this._specifier}:${this._instanceId}:`,n)})}async frame(){return new Promise(e=>{if(this._iframe)return e(this._iframe);if(this._status==="ready")return this._iframe=this._buildIframe(),e(this._iframe);let t;const s=n=>{if(n==="ready")return t(),this._iframe=this._buildIframe(),e(this._iframe);if(n==="unloaded")return t(),e(null)};t=this.onStatus(s)})}onStatus(e){return this._onStatusHandlers.add(e),()=>{this._onStatusHandlers.delete(e)}}_buildIframe(){var e,t;const s=(t=(e=this._application)===null||e===void 0?void 0:e.versions)===null||t===void 0?void 0:t[0],n=s==null?void 0:s.baseUrl;if(!n)return console.error(`No baseUrl for dependency ${this._specifier}:${this._instanceId}`),null;const a=new URL(n);a.searchParams.set("applicationSpecifier",this._specifier),a.searchParams.set("applicationInstance",this._instanceId),a.searchParams.set("deviceId",this._store._client.deviceId);const r=document.createElement("iframe");return r.src=a.toString(),r}async _resetIframe(){if(!this._iframe)return;const e=this._iframe,t=e.src;e.src="about:blank";try{await this._store._client.request("applications.reset",{applicationSpecifier:this._specifier,applicationInstance:this._instanceId,cause:"heartbeat-timeout"})}catch(s){console.error(`Failed to reset application ${this._specifier}:${this._instanceId}:`,s)}this._iframe===e&&e.isConnected&&(e.src=t)}async _destroy(){this._status="unloaded",this._iframe&&(this._iframe.src="about:blank"),this._iframe=null;for(const s of this._onStatusHandlers)s("unloaded");const e=`${this._specifier}:${this._instanceId}`,t=this._store._heartbeatTimeouts.get(e);t&&(clearTimeout(t),this._store._heartbeatTimeouts.delete(e));try{await this._store._client.request("applications.destroy",{applicationSpecifier:this._specifier,applicationInstance:this._instanceId})}catch(s){console.error(`Failed to destroy ${this._specifier}:${this._instanceId}:`,s)}await this._store._client.unsubscribe("applications.dependency",{applicationSpecifier:this._specifier,applicationInstance:this._instanceId},this._subscriptionHandler).catch(s=>{console.error(`Dependency unsubscription failed for ${this._specifier}:${this._instanceId}:`,s)})}}const G=it.version;let m=null;function Rt(){return m}function Ft(i){tt(),m=new Xe,m.bind()}function tt(){m==null||m.unbind(),m=null}function Mt(...i){return x(m),m.on(...i)}function qt(...i){return x(m),m.once(...i)}function Ht(...i){return x(m),m.off(...i)}function Lt(...i){return x(m),m.send(...i)}function Dt(...i){return x(m),m.request(...i)}function Vt(...i){return x(m),m.subscribe(...i)}function zt(...i){return x(m),m.unsubscribe(...i)}function Bt(){return x(m),m.store}function Ut(){return x(m),m.applications}function Kt(){return x(m),m.media}function Wt(){return x(m),m.accounts}function Jt(){return x(m),m.users}function Qt(){return x(m),m.devices}function Gt(){return x(m),m.proxy}function Yt(){return x(m),m.rootSettingsNavigation}function Xt(){return x(m),m.weather}function es(){return x(m),m.currency}function ts(){return x(m),m.environment}function ss(){return x(m),m.mqtt}function x(i){if(!i)throw new Error("SDK is not configured")}exports.Accounts=Ee;exports.Applications=$e;exports.Client=Xe;exports.Currency=We;exports.DependencyHandle=et;exports.Devices=Ue;exports.Environment=Je;exports.Media=Pe;exports.Mqtt=Qe;exports.Navigation=Ge;exports.Proxy=Be;exports.Store=Ve;exports.StoreSlice=J;exports.Users=ze;exports.Weather=Ke;exports.accounts=Wt;exports.applications=Ut;exports.bridgeMessageValidator=Le;exports.clientMessageValidator=De;exports.configure=Ft;exports.currency=es;exports.destroy=tt;exports.devices=Qt;exports.environment=ts;exports.formatBridgeMessage=Et;exports.formatClientMessage=W;exports.globalClient=Rt;exports.media=Kt;exports.mqtt=ss;exports.off=Ht;exports.on=Mt;exports.once=qt;exports.proxy=Gt;exports.request=Dt;exports.rootSettingsNavigation=Yt;exports.send=Lt;exports.store=Bt;exports.subscribe=Vt;exports.telemetrySdkVersion=G;exports.unsubscribe=zt;exports.users=Jt;exports.weather=Xt;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const He = "1.16.0", Le = {
1
+ const He = "1.16.1", Le = {
2
2
  version: He
3
3
  };
4
4
  class De {
@@ -175,14 +175,24 @@ class ze {
175
175
  * Opens a full-screen media picker dialog in the host window.
176
176
  * This allows users to browse folders, view media, and select an item.
177
177
  *
178
+ * Uses a subscription pattern internally so the picker can remain open
179
+ * indefinitely without hitting the 30-second request timeout.
180
+ *
178
181
  * @param options Optional picker options including content type filter and current value
179
182
  * @returns A promise that resolves to the selected media, or null if cancelled
180
183
  */
181
184
  async openPicker(e) {
182
- return (await this._client.request("media.openPicker", {
183
- accept: e == null ? void 0 : e.accept,
184
- currentValue: e == null ? void 0 : e.currentValue
185
- })).selection;
185
+ return new Promise((t, s) => {
186
+ const n = (a) => {
187
+ this._client.unsubscribe("media.openPicker", n), t(a.selection);
188
+ };
189
+ this._client.subscribe("media.openPicker", {
190
+ accept: e == null ? void 0 : e.accept,
191
+ currentValue: e == null ? void 0 : e.currentValue
192
+ }, n).then((a) => {
193
+ a.success || s(new Error("Failed to open media picker"));
194
+ }).catch(s);
195
+ });
186
196
  }
187
197
  }
188
198
  var b;
@@ -1653,7 +1663,7 @@ Ce.create = (i) => new Ce({
1653
1663
  typeName: _.ZodUnknown,
1654
1664
  ...y(i)
1655
1665
  });
1656
- class j extends v {
1666
+ class P extends v {
1657
1667
  _parse(e) {
1658
1668
  const t = this._getOrReturnCtx(e);
1659
1669
  return u(t, {
@@ -1663,7 +1673,7 @@ class j extends v {
1663
1673
  }), g;
1664
1674
  }
1665
1675
  }
1666
- j.create = (i) => new j({
1676
+ P.create = (i) => new P({
1667
1677
  typeName: _.ZodNever,
1668
1678
  ...y(i)
1669
1679
  });
@@ -1793,7 +1803,7 @@ class k extends v {
1793
1803
  }), g;
1794
1804
  }
1795
1805
  const { status: t, ctx: s } = this._processInputParams(e), { shape: n, keys: a } = this._getCached(), r = [];
1796
- if (!(this._def.catchall instanceof j && this._def.unknownKeys === "strip"))
1806
+ if (!(this._def.catchall instanceof P && this._def.unknownKeys === "strip"))
1797
1807
  for (const c in s.data)
1798
1808
  a.includes(c) || r.push(c);
1799
1809
  const o = [];
@@ -1805,7 +1815,7 @@ class k extends v {
1805
1815
  alwaysSet: c in s.data
1806
1816
  });
1807
1817
  }
1808
- if (this._def.catchall instanceof j) {
1818
+ if (this._def.catchall instanceof P) {
1809
1819
  const c = this._def.unknownKeys;
1810
1820
  if (c === "passthrough")
1811
1821
  for (const l of r)
@@ -2037,27 +2047,27 @@ class k extends v {
2037
2047
  });
2038
2048
  }
2039
2049
  keyof() {
2040
- return je(b.objectKeys(this.shape));
2050
+ return Pe(b.objectKeys(this.shape));
2041
2051
  }
2042
2052
  }
2043
2053
  k.create = (i, e) => new k({
2044
2054
  shape: () => i,
2045
2055
  unknownKeys: "strip",
2046
- catchall: j.create(),
2056
+ catchall: P.create(),
2047
2057
  typeName: _.ZodObject,
2048
2058
  ...y(e)
2049
2059
  });
2050
2060
  k.strictCreate = (i, e) => new k({
2051
2061
  shape: () => i,
2052
2062
  unknownKeys: "strict",
2053
- catchall: j.create(),
2063
+ catchall: P.create(),
2054
2064
  typeName: _.ZodObject,
2055
2065
  ...y(e)
2056
2066
  });
2057
2067
  k.lazycreate = (i, e) => new k({
2058
2068
  shape: i,
2059
2069
  unknownKeys: "strip",
2060
- catchall: j.create(),
2070
+ catchall: P.create(),
2061
2071
  typeName: _.ZodObject,
2062
2072
  ...y(e)
2063
2073
  });
@@ -2395,7 +2405,7 @@ pe.create = (i, e) => new pe({
2395
2405
  typeName: _.ZodLiteral,
2396
2406
  ...y(e)
2397
2407
  });
2398
- function je(i, e) {
2408
+ function Pe(i, e) {
2399
2409
  return new H({
2400
2410
  values: i,
2401
2411
  typeName: _.ZodEnum,
@@ -2456,7 +2466,7 @@ class H extends v {
2456
2466
  });
2457
2467
  }
2458
2468
  }
2459
- H.create = je;
2469
+ H.create = Pe;
2460
2470
  class Ae extends v {
2461
2471
  _parse(e) {
2462
2472
  const t = b.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
@@ -2780,8 +2790,8 @@ var _;
2780
2790
  (function(i) {
2781
2791
  i.ZodString = "ZodString", i.ZodNumber = "ZodNumber", i.ZodNaN = "ZodNaN", i.ZodBigInt = "ZodBigInt", i.ZodBoolean = "ZodBoolean", i.ZodDate = "ZodDate", i.ZodSymbol = "ZodSymbol", i.ZodUndefined = "ZodUndefined", i.ZodNull = "ZodNull", i.ZodAny = "ZodAny", i.ZodUnknown = "ZodUnknown", i.ZodNever = "ZodNever", i.ZodVoid = "ZodVoid", i.ZodArray = "ZodArray", i.ZodObject = "ZodObject", i.ZodUnion = "ZodUnion", i.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", i.ZodIntersection = "ZodIntersection", i.ZodTuple = "ZodTuple", i.ZodRecord = "ZodRecord", i.ZodMap = "ZodMap", i.ZodSet = "ZodSet", i.ZodFunction = "ZodFunction", i.ZodLazy = "ZodLazy", i.ZodLiteral = "ZodLiteral", i.ZodEnum = "ZodEnum", i.ZodEffects = "ZodEffects", i.ZodNativeEnum = "ZodNativeEnum", i.ZodOptional = "ZodOptional", i.ZodNullable = "ZodNullable", i.ZodDefault = "ZodDefault", i.ZodCatch = "ZodCatch", i.ZodPromise = "ZodPromise", i.ZodBranded = "ZodBranded", i.ZodPipeline = "ZodPipeline", i.ZodReadonly = "ZodReadonly";
2782
2792
  })(_ || (_ = {}));
2783
- const Z = O.create, Pe = le.create;
2784
- j.create;
2793
+ const Z = O.create, je = le.create;
2794
+ P.create;
2785
2795
  I.create;
2786
2796
  const Re = k.create;
2787
2797
  ie.create;
@@ -2794,9 +2804,9 @@ D.create;
2794
2804
  const yt = Re({
2795
2805
  type: Fe("bridge"),
2796
2806
  name: Z(),
2797
- data: Pe()
2807
+ data: je()
2798
2808
  });
2799
- function Pt(i) {
2809
+ function jt(i) {
2800
2810
  return { ...i, type: "bridge" };
2801
2811
  }
2802
2812
  const vt = Re({
@@ -2806,7 +2816,7 @@ const vt = Re({
2806
2816
  applicationInstance: Z(),
2807
2817
  runtime: gt(["window", "worker"]),
2808
2818
  name: Z(),
2809
- data: Pe(),
2819
+ data: je(),
2810
2820
  responseName: Z().optional(),
2811
2821
  subscriptionName: Z().optional(),
2812
2822
  unsubscribeName: Z().optional()
@@ -3769,16 +3779,16 @@ class At {
3769
3779
  const o = (n = s == null ? void 0 : s.timeout) !== null && n !== void 0 ? n : B;
3770
3780
  let c = !1, l;
3771
3781
  const f = new Promise((S) => {
3772
- l = (P) => {
3773
- c || S(P);
3782
+ l = (j) => {
3783
+ c || S(j);
3774
3784
  }, this.once(a, l);
3775
3785
  });
3776
3786
  if (o === 0)
3777
3787
  return f;
3778
- const w = new Promise((S, P) => {
3788
+ const w = new Promise((S, j) => {
3779
3789
  const V = new Error(`${e} message request with response name of ${a} timed out after ${o}`);
3780
3790
  setTimeout(() => {
3781
- c = !0, this.off(a, l), P(V);
3791
+ c = !0, this.off(a, l), j(V);
3782
3792
  }, o);
3783
3793
  });
3784
3794
  return Promise.race([w, f]);
@@ -3806,12 +3816,12 @@ class At {
3806
3816
  setTimeout(() => {
3807
3817
  f = !0, this.off(o, w), F(z);
3808
3818
  }, B);
3809
- }), P = new Promise((V) => {
3819
+ }), j = new Promise((V) => {
3810
3820
  w = (F) => {
3811
3821
  f || V(F);
3812
3822
  }, this.once(o, w);
3813
3823
  });
3814
- return Promise.race([S, P]);
3824
+ return Promise.race([S, j]);
3815
3825
  }
3816
3826
  async unsubscribe(e, t, s) {
3817
3827
  let n, a;
@@ -3844,12 +3854,12 @@ class At {
3844
3854
  setTimeout(() => {
3845
3855
  f = !0, this.off(r, w), z(qe);
3846
3856
  }, B);
3847
- }), P = new Promise((F) => {
3857
+ }), j = new Promise((F) => {
3848
3858
  w = (z) => {
3849
3859
  f || F(z);
3850
3860
  }, this.once(r, w);
3851
3861
  });
3852
- if (!(await Promise.race([S, P])).success)
3862
+ if (!(await Promise.race([S, j])).success)
3853
3863
  return { success: !1 };
3854
3864
  }
3855
3865
  return { success: !0 };
@@ -4102,9 +4112,9 @@ function Rt() {
4102
4112
  return m;
4103
4113
  }
4104
4114
  function Ft(i) {
4105
- jt(), m = new At(), m.bind();
4115
+ Pt(), m = new At(), m.bind();
4106
4116
  }
4107
- function jt() {
4117
+ function Pt() {
4108
4118
  m == null || m.unbind(), m = null;
4109
4119
  }
4110
4120
  function Mt(...i) {
@@ -4190,10 +4200,10 @@ export {
4190
4200
  vt as clientMessageValidator,
4191
4201
  Ft as configure,
4192
4202
  es as currency,
4193
- jt as destroy,
4203
+ Pt as destroy,
4194
4204
  Qt as devices,
4195
4205
  ts as environment,
4196
- Pt as formatBridgeMessage,
4206
+ jt as formatBridgeMessage,
4197
4207
  Y as formatClientMessage,
4198
4208
  Rt as globalClient,
4199
4209
  Kt as media,
package/dist/media.d.ts CHANGED
@@ -74,6 +74,9 @@ export declare class Media {
74
74
  * Opens a full-screen media picker dialog in the host window.
75
75
  * This allows users to browse folders, view media, and select an item.
76
76
  *
77
+ * Uses a subscription pattern internally so the picker can remain open
78
+ * indefinitely without hitting the 30-second request timeout.
79
+ *
77
80
  * @param options Optional picker options including content type filter and current value
78
81
  * @returns A promise that resolves to the selected media, or null if cancelled
79
82
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telemetryos/root-sdk",
3
- "version": "1.16.0",
3
+ "version": "1.16.1",
4
4
  "description": "The official TelemetryOS root application sdk package. Provides types and apis for building root TelemetryOS applications.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -35,7 +35,7 @@
35
35
  "license": "",
36
36
  "repository": "github:TelemetryTV/Application-API",
37
37
  "dependencies": {
38
- "@telemetryos/sdk-bridge": "^1.16.0",
38
+ "@telemetryos/sdk-bridge": "^1.16.1",
39
39
  "zod": "^3.24.4"
40
40
  },
41
41
  "devDependencies": {
File without changes
File without changes
File without changes
File without changes