mutts 1.0.0 → 1.0.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.
Files changed (53) hide show
  1. package/dist/chunks/{decorator-BXsign4Z.js → decorator-8qjFb7dw.js} +2 -2
  2. package/dist/chunks/decorator-8qjFb7dw.js.map +1 -0
  3. package/dist/chunks/{decorator-CPbZNnsX.esm.js → decorator-AbRkXM5O.esm.js} +2 -2
  4. package/dist/chunks/decorator-AbRkXM5O.esm.js.map +1 -0
  5. package/dist/decorator.d.ts +1 -1
  6. package/dist/decorator.esm.js +1 -1
  7. package/dist/decorator.js +1 -1
  8. package/dist/destroyable.esm.js +1 -1
  9. package/dist/destroyable.js +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.esm.js +2 -2
  12. package/dist/index.js +2 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/mutts.umd.js +1 -1
  15. package/dist/mutts.umd.js.map +1 -1
  16. package/dist/mutts.umd.min.js +1 -1
  17. package/dist/mutts.umd.min.js.map +1 -1
  18. package/dist/reactive.d.ts +4 -3
  19. package/dist/reactive.esm.js +61 -57
  20. package/dist/reactive.esm.js.map +1 -1
  21. package/dist/reactive.js +61 -56
  22. package/dist/reactive.js.map +1 -1
  23. package/dist/std-decorators.esm.js +1 -1
  24. package/dist/std-decorators.js +1 -1
  25. package/docs/reactive.md +616 -0
  26. package/package.json +1 -2
  27. package/dist/chunks/decorator-BXsign4Z.js.map +0 -1
  28. package/dist/chunks/decorator-CPbZNnsX.esm.js.map +0 -1
  29. package/src/decorator.test.ts +0 -495
  30. package/src/decorator.ts +0 -205
  31. package/src/destroyable.test.ts +0 -155
  32. package/src/destroyable.ts +0 -158
  33. package/src/eventful.test.ts +0 -380
  34. package/src/eventful.ts +0 -69
  35. package/src/index.ts +0 -7
  36. package/src/indexable.test.ts +0 -388
  37. package/src/indexable.ts +0 -124
  38. package/src/promiseChain.test.ts +0 -201
  39. package/src/promiseChain.ts +0 -99
  40. package/src/reactive/array.test.ts +0 -923
  41. package/src/reactive/array.ts +0 -352
  42. package/src/reactive/core.test.ts +0 -1663
  43. package/src/reactive/core.ts +0 -866
  44. package/src/reactive/index.ts +0 -28
  45. package/src/reactive/interface.test.ts +0 -1477
  46. package/src/reactive/interface.ts +0 -231
  47. package/src/reactive/map.test.ts +0 -866
  48. package/src/reactive/map.ts +0 -162
  49. package/src/reactive/set.test.ts +0 -289
  50. package/src/reactive/set.ts +0 -142
  51. package/src/std-decorators.test.ts +0 -679
  52. package/src/std-decorators.ts +0 -182
  53. package/src/utils.ts +0 -52
@@ -36,7 +36,7 @@ const nativeConstructors = new Set([
36
36
  Boolean,
37
37
  ]);
38
38
  function isConstructor(fn) {
39
- return fn && (nativeConstructors.has(fn) || fn.toString().startsWith('class '));
39
+ return fn && (nativeConstructors.has(fn) || fn.toString?.().startsWith('class '));
40
40
  }
41
41
  function renamed(fct, name) {
42
42
  return Object.defineProperties(fct, {
@@ -173,4 +173,4 @@ exports.legacyDecorator = legacyDecorator;
173
173
  exports.modernDecorator = modernDecorator;
174
174
  exports.renamed = renamed;
175
175
  exports.zip = zip;
176
- //# sourceMappingURL=decorator-BXsign4Z.js.map
176
+ //# sourceMappingURL=decorator-8qjFb7dw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator-8qjFb7dw.js","sources":["../../src/utils.ts","../../src/decorator.ts"],"sourcesContent":["type ElementTypes<T extends readonly unknown[]> = {\n\t[K in keyof T]: T[K] extends readonly (infer U)[] ? U : T[K]\n}\n\nexport function zip<T extends (readonly unknown[])[]>(...args: T): ElementTypes<T>[] {\n\tif (!args.length) return []\n\tconst minLength = Math.min(...args.map((arr) => arr.length))\n\tconst result: ElementTypes<T>[] = []\n\n\tfor (let i = 0; i < minLength; i++) {\n\t\tconst tuple = args.map((arr) => arr[i]) as ElementTypes<T>\n\t\tresult.push(tuple)\n\t}\n\n\treturn result\n}\n\nconst nativeConstructors = new Set<Function>([\n\tObject,\n\tArray,\n\tDate,\n\tFunction,\n\tSet,\n\tMap,\n\tWeakMap,\n\tWeakSet,\n\tPromise,\n\tError,\n\tTypeError,\n\tReferenceError,\n\tSyntaxError,\n\tRangeError,\n\tURIError,\n\tEvalError,\n\tReflect,\n\tProxy,\n\tRegExp,\n\tString,\n\tNumber,\n\tBoolean,\n] as Function[])\nexport function isConstructor(fn: Function): boolean {\n\treturn fn && (nativeConstructors.has(fn) || fn.toString?.().startsWith('class '))\n}\n\nexport function renamed<F extends Function>(fct: F, name: string): F {\n\treturn Object.defineProperties(fct, {\n\t\tname: {\n\t\t\tvalue: name,\n\t\t},\n\t})\n}\n","// biome-ignore-all lint/suspicious/noConfusingVoidType: We *love* voids\n// Standardized decorator system that works with both Legacy and Modern decorators\n\nimport { isConstructor } from './utils'\n\nexport class DecoratorError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message)\n\t\tthis.name = 'DecoratorException'\n\t}\n}\n//#region all decorator types\n\n// Used for get/set and method decorators\nexport type LegacyPropertyDecorator<T> = (\n\ttarget: T,\n\tname: string | symbol,\n\tdescriptor: PropertyDescriptor\n) => any\n\nexport type LegacyClassDecorator<T> = (target: T) => any\n\nexport type ModernMethodDecorator<T> = (target: T, context: ClassMethodDecoratorContext) => any\n\nexport type ModernGetterDecorator<T> = (target: T, context: ClassGetterDecoratorContext) => any\n\nexport type ModernSetterDecorator<T> = (target: T, context: ClassSetterDecoratorContext) => any\n\nexport type ModernAccessorDecorator<T> = (target: T, context: ClassAccessorDecoratorContext) => any\n\nexport type ModernClassDecorator<T> = (target: T, context: ClassDecoratorContext) => any\n\n//#endregion\n\ntype DDMethod<T> = (\n\toriginal: (this: T, ...args: any[]) => any,\n\tname: PropertyKey\n) => ((this: T, ...args: any[]) => any) | void\n\ntype DDGetter<T> = (original: (this: T) => any, name: PropertyKey) => ((this: T) => any) | void\n\ntype DDSetter<T> = (\n\toriginal: (this: T, value: any) => void,\n\tname: PropertyKey\n) => ((this: T, value: any) => void) | void\n\ntype DDClass<T> = <Ctor extends new (...args: any[]) => T = new (...args: any[]) => T>(\n\ttarget: Ctor\n) => Ctor | void\nexport interface DecoratorDescription<T> {\n\tmethod?: DDMethod<T>\n\tclass?: DDClass<T>\n\tgetter?: DDGetter<T>\n\tsetter?: DDSetter<T>\n\tdefault?: (...args: any[]) => any\n}\n\nexport type Decorator<T, Description extends DecoratorDescription<T>> = (Description extends {\n\tmethod: DDMethod<T>\n}\n\t? LegacyPropertyDecorator<T> & ModernMethodDecorator<T>\n\t: unknown) &\n\t(Description extends { class: DDClass<new (...args: any[]) => T> }\n\t\t? LegacyClassDecorator<new (...args: any[]) => T> &\n\t\t\t\tModernClassDecorator<new (...args: any[]) => T>\n\t\t: unknown) &\n\t(Description extends { getter: DDGetter<T> }\n\t\t? LegacyPropertyDecorator<T> & ModernGetterDecorator<T> & ModernAccessorDecorator<T>\n\t\t: unknown) &\n\t(Description extends { setter: DDSetter<T> }\n\t\t? LegacyPropertyDecorator<T> & ModernSetterDecorator<T> & ModernAccessorDecorator<T>\n\t\t: unknown) &\n\t(Description extends { default: infer Signature } ? Signature : unknown)\n\nexport type DecoratorFactory<T> = <Description extends DecoratorDescription<T>>(\n\tdescription: Description\n) => (Description extends { method: DDMethod<T> }\n\t? LegacyPropertyDecorator<T> & ModernMethodDecorator<T>\n\t: unknown) &\n\t(Description extends { class: DDClass<new (...args: any[]) => T> }\n\t\t? LegacyClassDecorator<new (...args: any[]) => T> &\n\t\t\t\tModernClassDecorator<new (...args: any[]) => T>\n\t\t: unknown) &\n\t(Description extends { getter: DDGetter<T> }\n\t\t? LegacyPropertyDecorator<T> & ModernGetterDecorator<T> & ModernAccessorDecorator<T>\n\t\t: unknown) &\n\t(Description extends { setter: DDSetter<T> }\n\t\t? LegacyPropertyDecorator<T> & ModernSetterDecorator<T> & ModernAccessorDecorator<T>\n\t\t: unknown) &\n\t(Description extends { default: infer Signature } ? Signature : unknown)\n\nexport function legacyDecorator<T = any>(description: DecoratorDescription<T>): any {\n\treturn function (\n\t\ttarget: any,\n\t\tpropertyKey?: PropertyKey,\n\t\tdescriptor?: PropertyDescriptor,\n\t\t...args: any[]\n\t) {\n\t\tif (propertyKey === undefined) {\n\t\t\tif (isConstructor(target)) {\n\t\t\t\tif (!('class' in description)) throw new Error('Decorator cannot be applied to a class')\n\t\t\t\treturn description.class?.(target)\n\t\t\t}\n\t\t} else if (typeof target === 'object' && ['string', 'symbol'].includes(typeof propertyKey)) {\n\t\t\tif (!descriptor) throw new Error('Decorator cannot be applied to a field')\n\t\t\telse if (typeof descriptor === 'object' && 'configurable' in descriptor) {\n\t\t\t\tif ('get' in descriptor || 'set' in descriptor) {\n\t\t\t\t\tif (!('getter' in description || 'setter' in description))\n\t\t\t\t\t\tthrow new Error('Decorator cannot be applied to a getter or setter')\n\t\t\t\t\tif ('getter' in description) {\n\t\t\t\t\t\tconst newGetter = description.getter?.(descriptor.get, propertyKey)\n\t\t\t\t\t\tif (newGetter) descriptor.get = newGetter\n\t\t\t\t\t}\n\t\t\t\t\tif ('setter' in description) {\n\t\t\t\t\t\tconst newSetter = description.setter?.(descriptor.set, propertyKey)\n\t\t\t\t\t\tif (newSetter) descriptor.set = newSetter\n\t\t\t\t\t}\n\t\t\t\t\treturn descriptor\n\t\t\t\t} else if (typeof descriptor.value === 'function') {\n\t\t\t\t\tif (!('method' in description)) throw new Error('Decorator cannot be applied to a method')\n\t\t\t\t\tconst newMethod = description.method?.(descriptor.value, propertyKey)\n\t\t\t\t\tif (newMethod) descriptor.value = newMethod\n\t\t\t\t\treturn descriptor\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!('default' in description))\n\t\t\tthrow new Error('Decorator do not have a default implementation')\n\t\treturn description.default.call(this, target, propertyKey, descriptor, ...args)\n\t}\n}\n\nexport function modernDecorator<T = any>(description: DecoratorDescription<T>): any {\n\treturn function (target: any, context?: DecoratorContext, ...args: any[]) {\n\t\tif (!context?.kind || typeof context.kind !== 'string') {\n\t\t\tif (!('default' in description))\n\t\t\t\tthrow new Error('Decorator do not have a default implementation')\n\t\t\treturn description.default.call(this, target, context, ...args)\n\t\t}\n\t\tswitch (context.kind) {\n\t\t\tcase 'class':\n\t\t\t\tif (!('class' in description)) throw new Error('Decorator cannot be applied to a class')\n\t\t\t\treturn description.class?.(target)\n\t\t\tcase 'field':\n\t\t\t\tthrow new Error('Decorator cannot be applied to a field')\n\t\t\tcase 'getter':\n\t\t\t\tif (!('getter' in description)) throw new Error('Decorator cannot be applied to a getter')\n\t\t\t\treturn description.getter?.(target, context.name)\n\t\t\tcase 'setter':\n\t\t\t\tif (!('setter' in description)) throw new Error('Decorator cannot be applied to a setter')\n\t\t\t\treturn description.setter?.(target, context.name)\n\t\t\tcase 'method':\n\t\t\t\tif (!('method' in description)) throw new Error('Decorator cannot be applied to a method')\n\t\t\t\treturn description.method?.(target, context.name)\n\t\t\tcase 'accessor': {\n\t\t\t\tif (!('getter' in description || 'setter' in description))\n\t\t\t\t\tthrow new Error('Decorator cannot be applied to a getter or setter')\n\t\t\t\tconst rv: Partial<ClassAccessorDecoratorResult<any, any>> = {}\n\t\t\t\tif ('getter' in description) {\n\t\t\t\t\tconst newGetter = description.getter?.(target.get, context.name)\n\t\t\t\t\tif (newGetter) rv.get = newGetter\n\t\t\t\t}\n\t\t\t\tif ('setter' in description) {\n\t\t\t\t\tconst newSetter = description.setter?.(target.set, context.name)\n\t\t\t\t\tif (newSetter) rv.set = newSetter\n\t\t\t\t}\n\t\t\t\treturn rv\n\t\t\t}\n\t\t\t//return description.accessor?.(target, context.name, target)\n\t\t}\n\t}\n}\n\n/**\n * Detects if the decorator is being called in modern (Modern) or legacy (Legacy) mode\n * based on the arguments passed to the decorator function\n */\nfunction detectDecoratorMode(\n\t_target: any,\n\tcontextOrKey?: any,\n\t_descriptor?: any\n): 'modern' | 'legacy' {\n\t// Modern decorators have a context object as the second parameter\n\t// Legacy decorators have a string/symbol key as the second parameter\n\tif (\n\t\ttypeof contextOrKey === 'object' &&\n\t\tcontextOrKey !== null &&\n\t\ttypeof contextOrKey.kind === 'string'\n\t) {\n\t\treturn 'modern'\n\t}\n\treturn 'legacy'\n}\n\nexport const decorator: DecoratorFactory<any> = (description: DecoratorDescription<any>) => {\n\treturn ((target: any, contextOrKey?: any, ...args: any[]) => {\n\t\tconst mode = detectDecoratorMode(target, contextOrKey, args[0])\n\t\treturn mode === 'modern'\n\t\t\t? modernDecorator(description)(target, contextOrKey, ...args)\n\t\t\t: legacyDecorator(description)(target, contextOrKey, ...args)\n\t}) as any\n}\n\nexport type GenericClassDecorator<T> = LegacyClassDecorator<abstract new (...args: any[]) => T> &\n\tModernClassDecorator<abstract new (...args: any[]) => T>\n"],"names":[],"mappings":";;AAIM,SAAU,GAAG,CAAmC,GAAG,IAAO,EAAA;IAC/D,IAAI,CAAC,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,EAAE;IAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAsB,EAAE;AAEpC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;AACnC,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAoB;AAC1D,QAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IACnB;AAEA,IAAA,OAAO,MAAM;AACd;AAEA,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAW;IAC5C,MAAM;IACN,KAAK;IACL,IAAI;IACJ,QAAQ;IACR,GAAG;IACH,GAAG;IACH,OAAO;IACP,OAAO;IACP,OAAO;IACP,KAAK;IACL,SAAS;IACT,cAAc;IACd,WAAW;IACX,UAAU;IACV,QAAQ;IACR,SAAS;IACT,OAAO;IACP,KAAK;IACL,MAAM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I,CAAC,CAAC,CAAC,CAAC;QAC/D,OAAO,IAAI,KAAK;AACf,cAAE,eAAe,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI;AAC5D,cAAE,eAAe,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;AAC/D,IAAA,CAAC;AACF;;;;;;;;;;"}
@@ -34,7 +34,7 @@ const nativeConstructors = new Set([
34
34
  Boolean,
35
35
  ]);
36
36
  function isConstructor(fn) {
37
- return fn && (nativeConstructors.has(fn) || fn.toString().startsWith('class '));
37
+ return fn && (nativeConstructors.has(fn) || fn.toString?.().startsWith('class '));
38
38
  }
39
39
  function renamed(fct, name) {
40
40
  return Object.defineProperties(fct, {
@@ -165,4 +165,4 @@ const decorator = (description) => {
165
165
  };
166
166
 
167
167
  export { DecoratorError as D, decorator as d, isConstructor as i, legacyDecorator as l, modernDecorator as m, renamed as r, zip as z };
168
- //# sourceMappingURL=decorator-CPbZNnsX.esm.js.map
168
+ //# sourceMappingURL=decorator-AbRkXM5O.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator-AbRkXM5O.esm.js","sources":["../../src/utils.ts","../../src/decorator.ts"],"sourcesContent":["type ElementTypes<T extends readonly unknown[]> = {\n\t[K in keyof T]: T[K] extends readonly (infer U)[] ? U : T[K]\n}\n\nexport function zip<T extends (readonly unknown[])[]>(...args: T): ElementTypes<T>[] {\n\tif (!args.length) return []\n\tconst minLength = Math.min(...args.map((arr) => arr.length))\n\tconst result: ElementTypes<T>[] = []\n\n\tfor (let i = 0; i < minLength; i++) {\n\t\tconst tuple = args.map((arr) => arr[i]) as ElementTypes<T>\n\t\tresult.push(tuple)\n\t}\n\n\treturn result\n}\n\nconst nativeConstructors = new Set<Function>([\n\tObject,\n\tArray,\n\tDate,\n\tFunction,\n\tSet,\n\tMap,\n\tWeakMap,\n\tWeakSet,\n\tPromise,\n\tError,\n\tTypeError,\n\tReferenceError,\n\tSyntaxError,\n\tRangeError,\n\tURIError,\n\tEvalError,\n\tReflect,\n\tProxy,\n\tRegExp,\n\tString,\n\tNumber,\n\tBoolean,\n] as Function[])\nexport function isConstructor(fn: Function): boolean {\n\treturn fn && (nativeConstructors.has(fn) || fn.toString?.().startsWith('class '))\n}\n\nexport function renamed<F extends Function>(fct: F, name: string): F {\n\treturn Object.defineProperties(fct, {\n\t\tname: {\n\t\t\tvalue: name,\n\t\t},\n\t})\n}\n","// biome-ignore-all lint/suspicious/noConfusingVoidType: We *love* voids\n// Standardized decorator system that works with both Legacy and Modern decorators\n\nimport { isConstructor } from './utils'\n\nexport class DecoratorError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message)\n\t\tthis.name = 'DecoratorException'\n\t}\n}\n//#region all decorator types\n\n// Used for get/set and method decorators\nexport type LegacyPropertyDecorator<T> = (\n\ttarget: T,\n\tname: string | symbol,\n\tdescriptor: PropertyDescriptor\n) => any\n\nexport type LegacyClassDecorator<T> = (target: T) => any\n\nexport type ModernMethodDecorator<T> = (target: T, context: ClassMethodDecoratorContext) => any\n\nexport type ModernGetterDecorator<T> = (target: T, context: ClassGetterDecoratorContext) => any\n\nexport type ModernSetterDecorator<T> = (target: T, context: ClassSetterDecoratorContext) => any\n\nexport type ModernAccessorDecorator<T> = (target: T, context: ClassAccessorDecoratorContext) => any\n\nexport type ModernClassDecorator<T> = (target: T, context: ClassDecoratorContext) => any\n\n//#endregion\n\ntype DDMethod<T> = (\n\toriginal: (this: T, ...args: any[]) => any,\n\tname: PropertyKey\n) => ((this: T, ...args: any[]) => any) | void\n\ntype DDGetter<T> = (original: (this: T) => any, name: PropertyKey) => ((this: T) => any) | void\n\ntype DDSetter<T> = (\n\toriginal: (this: T, value: any) => void,\n\tname: PropertyKey\n) => ((this: T, value: any) => void) | void\n\ntype DDClass<T> = <Ctor extends new (...args: any[]) => T = new (...args: any[]) => T>(\n\ttarget: Ctor\n) => Ctor | void\nexport interface DecoratorDescription<T> {\n\tmethod?: DDMethod<T>\n\tclass?: DDClass<T>\n\tgetter?: DDGetter<T>\n\tsetter?: DDSetter<T>\n\tdefault?: (...args: any[]) => any\n}\n\nexport type Decorator<T, Description extends DecoratorDescription<T>> = (Description extends {\n\tmethod: DDMethod<T>\n}\n\t? LegacyPropertyDecorator<T> & ModernMethodDecorator<T>\n\t: unknown) &\n\t(Description extends { class: DDClass<new (...args: any[]) => T> }\n\t\t? LegacyClassDecorator<new (...args: any[]) => T> &\n\t\t\t\tModernClassDecorator<new (...args: any[]) => T>\n\t\t: unknown) &\n\t(Description extends { getter: DDGetter<T> }\n\t\t? LegacyPropertyDecorator<T> & ModernGetterDecorator<T> & ModernAccessorDecorator<T>\n\t\t: unknown) &\n\t(Description extends { setter: DDSetter<T> }\n\t\t? LegacyPropertyDecorator<T> & ModernSetterDecorator<T> & ModernAccessorDecorator<T>\n\t\t: unknown) &\n\t(Description extends { default: infer Signature } ? Signature : unknown)\n\nexport type DecoratorFactory<T> = <Description extends DecoratorDescription<T>>(\n\tdescription: Description\n) => (Description extends { method: DDMethod<T> }\n\t? LegacyPropertyDecorator<T> & ModernMethodDecorator<T>\n\t: unknown) &\n\t(Description extends { class: DDClass<new (...args: any[]) => T> }\n\t\t? LegacyClassDecorator<new (...args: any[]) => T> &\n\t\t\t\tModernClassDecorator<new (...args: any[]) => T>\n\t\t: unknown) &\n\t(Description extends { getter: DDGetter<T> }\n\t\t? LegacyPropertyDecorator<T> & ModernGetterDecorator<T> & ModernAccessorDecorator<T>\n\t\t: unknown) &\n\t(Description extends { setter: DDSetter<T> }\n\t\t? LegacyPropertyDecorator<T> & ModernSetterDecorator<T> & ModernAccessorDecorator<T>\n\t\t: unknown) &\n\t(Description extends { default: infer Signature } ? Signature : unknown)\n\nexport function legacyDecorator<T = any>(description: DecoratorDescription<T>): any {\n\treturn function (\n\t\ttarget: any,\n\t\tpropertyKey?: PropertyKey,\n\t\tdescriptor?: PropertyDescriptor,\n\t\t...args: any[]\n\t) {\n\t\tif (propertyKey === undefined) {\n\t\t\tif (isConstructor(target)) {\n\t\t\t\tif (!('class' in description)) throw new Error('Decorator cannot be applied to a class')\n\t\t\t\treturn description.class?.(target)\n\t\t\t}\n\t\t} else if (typeof target === 'object' && ['string', 'symbol'].includes(typeof propertyKey)) {\n\t\t\tif (!descriptor) throw new Error('Decorator cannot be applied to a field')\n\t\t\telse if (typeof descriptor === 'object' && 'configurable' in descriptor) {\n\t\t\t\tif ('get' in descriptor || 'set' in descriptor) {\n\t\t\t\t\tif (!('getter' in description || 'setter' in description))\n\t\t\t\t\t\tthrow new Error('Decorator cannot be applied to a getter or setter')\n\t\t\t\t\tif ('getter' in description) {\n\t\t\t\t\t\tconst newGetter = description.getter?.(descriptor.get, propertyKey)\n\t\t\t\t\t\tif (newGetter) descriptor.get = newGetter\n\t\t\t\t\t}\n\t\t\t\t\tif ('setter' in description) {\n\t\t\t\t\t\tconst newSetter = description.setter?.(descriptor.set, propertyKey)\n\t\t\t\t\t\tif (newSetter) descriptor.set = newSetter\n\t\t\t\t\t}\n\t\t\t\t\treturn descriptor\n\t\t\t\t} else if (typeof descriptor.value === 'function') {\n\t\t\t\t\tif (!('method' in description)) throw new Error('Decorator cannot be applied to a method')\n\t\t\t\t\tconst newMethod = description.method?.(descriptor.value, propertyKey)\n\t\t\t\t\tif (newMethod) descriptor.value = newMethod\n\t\t\t\t\treturn descriptor\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!('default' in description))\n\t\t\tthrow new Error('Decorator do not have a default implementation')\n\t\treturn description.default.call(this, target, propertyKey, descriptor, ...args)\n\t}\n}\n\nexport function modernDecorator<T = any>(description: DecoratorDescription<T>): any {\n\treturn function (target: any, context?: DecoratorContext, ...args: any[]) {\n\t\tif (!context?.kind || typeof context.kind !== 'string') {\n\t\t\tif (!('default' in description))\n\t\t\t\tthrow new Error('Decorator do not have a default implementation')\n\t\t\treturn description.default.call(this, target, context, ...args)\n\t\t}\n\t\tswitch (context.kind) {\n\t\t\tcase 'class':\n\t\t\t\tif (!('class' in description)) throw new Error('Decorator cannot be applied to a class')\n\t\t\t\treturn description.class?.(target)\n\t\t\tcase 'field':\n\t\t\t\tthrow new Error('Decorator cannot be applied to a field')\n\t\t\tcase 'getter':\n\t\t\t\tif (!('getter' in description)) throw new Error('Decorator cannot be applied to a getter')\n\t\t\t\treturn description.getter?.(target, context.name)\n\t\t\tcase 'setter':\n\t\t\t\tif (!('setter' in description)) throw new Error('Decorator cannot be applied to a setter')\n\t\t\t\treturn description.setter?.(target, context.name)\n\t\t\tcase 'method':\n\t\t\t\tif (!('method' in description)) throw new Error('Decorator cannot be applied to a method')\n\t\t\t\treturn description.method?.(target, context.name)\n\t\t\tcase 'accessor': {\n\t\t\t\tif (!('getter' in description || 'setter' in description))\n\t\t\t\t\tthrow new Error('Decorator cannot be applied to a getter or setter')\n\t\t\t\tconst rv: Partial<ClassAccessorDecoratorResult<any, any>> = {}\n\t\t\t\tif ('getter' in description) {\n\t\t\t\t\tconst newGetter = description.getter?.(target.get, context.name)\n\t\t\t\t\tif (newGetter) rv.get = newGetter\n\t\t\t\t}\n\t\t\t\tif ('setter' in description) {\n\t\t\t\t\tconst newSetter = description.setter?.(target.set, context.name)\n\t\t\t\t\tif (newSetter) rv.set = newSetter\n\t\t\t\t}\n\t\t\t\treturn rv\n\t\t\t}\n\t\t\t//return description.accessor?.(target, context.name, target)\n\t\t}\n\t}\n}\n\n/**\n * Detects if the decorator is being called in modern (Modern) or legacy (Legacy) mode\n * based on the arguments passed to the decorator function\n */\nfunction detectDecoratorMode(\n\t_target: any,\n\tcontextOrKey?: any,\n\t_descriptor?: any\n): 'modern' | 'legacy' {\n\t// Modern decorators have a context object as the second parameter\n\t// Legacy decorators have a string/symbol key as the second parameter\n\tif (\n\t\ttypeof contextOrKey === 'object' &&\n\t\tcontextOrKey !== null &&\n\t\ttypeof contextOrKey.kind === 'string'\n\t) {\n\t\treturn 'modern'\n\t}\n\treturn 'legacy'\n}\n\nexport const decorator: DecoratorFactory<any> = (description: DecoratorDescription<any>) => {\n\treturn ((target: any, contextOrKey?: any, ...args: any[]) => {\n\t\tconst mode = detectDecoratorMode(target, contextOrKey, args[0])\n\t\treturn mode === 'modern'\n\t\t\t? modernDecorator(description)(target, contextOrKey, ...args)\n\t\t\t: legacyDecorator(description)(target, contextOrKey, ...args)\n\t}) as any\n}\n\nexport type GenericClassDecorator<T> = LegacyClassDecorator<abstract new (...args: any[]) => T> &\n\tModernClassDecorator<abstract new (...args: any[]) => T>\n"],"names":[],"mappings":"AAIM,SAAU,GAAG,CAAmC,GAAG,IAAO,EAAA;IAC/D,IAAI,CAAC,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,EAAE;IAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAsB,EAAE;AAEpC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;AACnC,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAoB;AAC1D,QAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IACnB;AAEA,IAAA,OAAO,MAAM;AACd;AAEA,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAW;IAC5C,MAAM;IACN,KAAK;IACL,IAAI;IACJ,QAAQ;IACR,GAAG;IACH,GAAG;IACH,OAAO;IACP,OAAO;IACP,OAAO;IACP,KAAK;IACL,SAAS;IACT,cAAc;IACd,WAAW;IACX,UAAU;IACV,QAAQ;IACR,SAAS;IACT,OAAO;IACP,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;AACO,CAAA,CAAC;AACV,SAAU,aAAa,CAAC,EAAY,EAAA;IACzC,OAAO,EA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AAE,YAAY,EAAE,GAAG,IAAI;AAC5D,cAAE,eAAe,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;AAC/D,IAAA,CAAC;AACF;;;;"}
@@ -44,7 +44,7 @@ type DecoratorFactory<T> = <Description extends DecoratorDescription<T>>(descrip
44
44
  declare function legacyDecorator<T = any>(description: DecoratorDescription<T>): any;
45
45
  declare function modernDecorator<T = any>(description: DecoratorDescription<T>): any;
46
46
  declare const decorator: DecoratorFactory<any>;
47
- type GenericClassDecorator<T> = LegacyClassDecorator<new (...args: any[]) => T> & ModernClassDecorator<new (...args: any[]) => T>;
47
+ type GenericClassDecorator<T> = LegacyClassDecorator<abstract new (...args: any[]) => T> & ModernClassDecorator<abstract new (...args: any[]) => T>;
48
48
 
49
49
  export { DecoratorError, decorator, legacyDecorator, modernDecorator };
50
50
  export type { Decorator, DecoratorDescription, DecoratorFactory, GenericClassDecorator, LegacyClassDecorator, LegacyPropertyDecorator, ModernAccessorDecorator, ModernClassDecorator, ModernGetterDecorator, ModernMethodDecorator, ModernSetterDecorator };
@@ -1,2 +1,2 @@
1
- export { D as DecoratorError, d as decorator, l as legacyDecorator, m as modernDecorator } from './chunks/decorator-CPbZNnsX.esm.js';
1
+ export { D as DecoratorError, d as decorator, l as legacyDecorator, m as modernDecorator } from './chunks/decorator-AbRkXM5O.esm.js';
2
2
  //# sourceMappingURL=decorator.esm.js.map
package/dist/decorator.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var decorator = require('./chunks/decorator-BXsign4Z.js');
3
+ var decorator = require('./chunks/decorator-8qjFb7dw.js');
4
4
 
5
5
 
6
6
 
@@ -1,4 +1,4 @@
1
- import { d as decorator } from './chunks/decorator-CPbZNnsX.esm.js';
1
+ import { d as decorator } from './chunks/decorator-AbRkXM5O.esm.js';
2
2
 
3
3
  // Integrated with `using` statement via Symbol.dispose
4
4
  const fr = new FinalizationRegistry((f) => f());
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var decorator = require('./chunks/decorator-BXsign4Z.js');
3
+ var decorator = require('./chunks/decorator-8qjFb7dw.js');
4
4
 
5
5
  // Integrated with `using` statement via Symbol.dispose
6
6
  const fr = new FinalizationRegistry((f) => f());
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { Decorator, DecoratorDescription, DecoratorError, DecoratorFactory, Gene
2
2
  export { ContextManager, Destroyable, DestructionError, allocated, allocatedValues, callOnGC, destructor } from './destroyable.js';
3
3
  export { Eventful } from './eventful.js';
4
4
  export { Indexable, getAt, setAt } from './indexable.js';
5
- export { ReactiveBase, ReactiveError, ScopedCallback, computed, effect, getState, immutables, invalidateComputed, isNonReactive, isReactive, profileInfo, reactive, reactiveOptions, unreactive, untracked, unwrap, watch } from './reactive.js';
5
+ export { ReactiveBase, ReactiveError, ScopedCallback, atomic, computed, effect, getState, immutables, invalidateComputed, isNonReactive, isReactive, profileInfo, reactive, reactiveOptions, unreactive, untracked, unwrap, watch } from './reactive.js';
6
6
  export { cache, cached, debounce, deprecated, describe, isCached, throttle } from './std-decorators.js';
7
7
 
8
8
  type ElementTypes<T extends readonly unknown[]> = {
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- export { D as DecoratorError, d as decorator, i as isConstructor, l as legacyDecorator, m as modernDecorator, r as renamed, z as zip } from './chunks/decorator-CPbZNnsX.esm.js';
1
+ export { D as DecoratorError, d as decorator, i as isConstructor, l as legacyDecorator, m as modernDecorator, r as renamed, z as zip } from './chunks/decorator-AbRkXM5O.esm.js';
2
2
  export { Destroyable, DestructionError, allocated, allocatedValues, callOnGC, destructor } from './destroyable.esm.js';
3
3
  export { Eventful } from './eventful.esm.js';
4
4
  export { Indexable, getAt, setAt } from './indexable.esm.js';
5
- export { ReactiveBase, ReactiveError, computed, effect, getState, immutables, invalidateComputed, isNonReactive, isReactive, profileInfo, reactive, reactiveOptions, unreactive, untracked, unwrap, watch } from './reactive.esm.js';
5
+ export { ReactiveBase, ReactiveError, atomic, computed, effect, getState, immutables, invalidateComputed, isNonReactive, isReactive, profileInfo, reactive, reactiveOptions, unreactive, untracked, unwrap, watch } from './reactive.esm.js';
6
6
  export { cache, cached, debounce, deprecated, describe, isCached, throttle } from './std-decorators.esm.js';
7
7
  //# sourceMappingURL=index.esm.js.map
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var decorator = require('./chunks/decorator-BXsign4Z.js');
3
+ var decorator = require('./chunks/decorator-8qjFb7dw.js');
4
4
  var destroyable = require('./destroyable.js');
5
5
  var eventful = require('./eventful.js');
6
6
  var indexable = require('./indexable.js');
@@ -28,6 +28,7 @@ exports.getAt = indexable.getAt;
28
28
  exports.setAt = indexable.setAt;
29
29
  exports.ReactiveBase = reactive.ReactiveBase;
30
30
  exports.ReactiveError = reactive.ReactiveError;
31
+ exports.atomic = reactive.atomic;
31
32
  exports.computed = reactive.computed;
32
33
  exports.effect = reactive.effect;
33
34
  exports.getState = reactive.getState;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/mutts.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Mutts={})}(this,function(t){"use strict";const e=new Set([Object,Array,Date,Function,Set,Map,WeakMap,WeakSet,Promise,Error,TypeError,ReferenceError,SyntaxError,RangeError,URIError,EvalError,Reflect,Proxy,RegExp,String,Number,Boolean]);function n(t){return t&&(e.has(t)||t.toString().startsWith("class "))}function r(t,e){return Object.defineProperties(t,{name:{value:e}})}class o extends Error{constructor(t){super(t),this.name="DecoratorException"}}function s(t){return function(e,r,o,...s){if(void 0===r){if(n(e)){if(!("class"in t))throw new Error("Decorator cannot be applied to a class");return t.class?.(e)}}else if("object"==typeof e&&["string","symbol"].includes(typeof r)){if(!o)throw new Error("Decorator cannot be applied to a field");if("object"==typeof o&&"configurable"in o){if("get"in o||"set"in o){if(!("getter"in t)&&!("setter"in t))throw new Error("Decorator cannot be applied to a getter or setter");if("getter"in t){const e=t.getter?.(o.get,r);e&&(o.get=e)}if("setter"in t){const e=t.setter?.(o.set,r);e&&(o.set=e)}return o}if("function"==typeof o.value){if(!("method"in t))throw new Error("Decorator cannot be applied to a method");const e=t.method?.(o.value,r);return e&&(o.value=e),o}}}if(!("default"in t))throw new Error("Decorator do not have a default implementation");return t.default.call(this,e,r,o,...s)}}function i(t){return function(e,n,...r){if(!n?.kind||"string"!=typeof n.kind){if(!("default"in t))throw new Error("Decorator do not have a default implementation");return t.default.call(this,e,n,...r)}switch(n.kind){case"class":if(!("class"in t))throw new Error("Decorator cannot be applied to a class");return t.class?.(e);case"field":throw new Error("Decorator cannot be applied to a field");case"getter":if(!("getter"in t))throw new Error("Decorator cannot be applied to a getter");return t.getter?.(e,n.name);case"setter":if(!("setter"in t))throw new Error("Decorator cannot be applied to a setter");return t.setter?.(e,n.name);case"method":if(!("method"in t))throw new Error("Decorator cannot be applied to a method");return t.method?.(e,n.name);case"accessor":{if(!("getter"in t)&&!("setter"in t))throw new Error("Decorator cannot be applied to a getter or setter");const r={};if("getter"in t){const o=t.getter?.(e.get,n.name);o&&(r.get=o)}if("setter"in t){const o=t.setter?.(e.set,n.name);o&&(r.set=o)}return r}}}}const c=t=>(e,n,...r)=>{const o=function(t,e){return"object"==typeof e&&null!==e&&"string"==typeof e.kind?"modern":"legacy"}(0,n,r[0]);return"modern"===o?i(t)(e,n,...r):s(t)(e,n,...r)},a=new FinalizationRegistry(t=>t()),h=Symbol("destructor"),l=Symbol("allocated");class u extends Error{static throw(t){return()=>{throw new u(t)}}constructor(t){super(`Object is destroyed. ${t}`),this.name="DestroyedAccessError"}}const f={[Symbol.toStringTag]:"MutTs Destroyable",get:u.throw("Cannot access destroyed object"),set:u.throw("Cannot access destroyed object")};const d=c({setter:(t,e)=>function(n){return this[l][e]=n,t.call(this,n)}});function p(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}var y,g;"function"==typeof SuppressedError&&SuppressedError;y=new WeakMap,g=new WeakMap;const b=Symbol("getAt"),m=Symbol("setAt");function w(t,e){t&&"function"!=typeof t&&(e=t,t=void 0),t||(t=class{}),e||(e={get(t){if("function"!=typeof this[b])throw new Error("Indexable class must have an [getAt] method");return this[b](t)},set(t,e){if("function"!=typeof this[m])throw new Error("Indexable class has read-only numeric index access");this[m](t,e)}});class n extends t{}return Object.setPrototypeOf(n.prototype,new Proxy(t.prototype,{[Symbol.toStringTag]:"MutTs Indexable",get(t,n,r){if(n in t){const e=Object.getOwnPropertyDescriptor(t,n)?.get;return e?e.call(r):t[n]}if("string"==typeof n){if("length"===n&&e.getLength)return e.getLength.call(r);const t=Number(n);if(!Number.isNaN(t))return e.get.call(r,t)}},set(t,n,r,o){if(n in t){const e=Object.getOwnPropertyDescriptor(t,n)?.set;return e?e.call(o,r):t[n]=r,!0}if("string"==typeof n){if("length"===n&&e.setLength)return e.setLength.call(o,r),!0;const t=Number(n);if(!Number.isNaN(t)){if(!e.set)throw new Error("Indexable class has read-only numeric index access");return e.set.call(o,t,r),!0}}return Object.defineProperty(o,n,{value:r,writable:!0,enumerable:!0,configurable:!0}),!0}})),n}const v=new WeakMap,S=new WeakMap,j=new WeakMap,x=new WeakMap,O=new WeakSet,E=new WeakMap,k=new WeakMap,M=new WeakSet;function*D(t){let e=t.next();for(;!e.done;)yield at(e.value),e=t.next()}function*W(t){let e=t.next();for(;!e.done;){const[n,r]=e.value;yield[at(n),at(r)],e=t.next()}}const P=new WeakMap,R={objectToProxy:S,proxyToObject:j,effectToReactiveObjects:v,watchers:P,objectParents:x,objectsWithDeepWatchers:O,deepWatchers:E,effectToDeepWatchedObjects:k,nonReactiveObjects:M},T=Symbol("native-reactive"),z=Symbol("non-reactive"),A=Symbol("unreactive-properties"),N=Symbol("prototype-forwarding"),C=Symbol("all-props"),I=Symbol("root-function");function $(t,e){return Object.defineProperty(t,I,{value:L(e),writable:!1})}function L(t){return t?.[I]||t}class F extends Error{constructor(t){super(t),this.name="ReactiveError"}}const B={enter:t=>{},leave:t=>{},chain:(t,e)=>{},maxEffectChain:100,maxDeepWatchDepth:100,instanceMembers:!0,warn:(...t)=>{}};function K(t,...e){for(const n of e)for(const e of n){const n=t.get(e);if(n)for(const t of Array.from(n))Y(t)}}function U(t,e,n){G(t,e,[n])}function G(t,e,n){!function(t,e){t=ht(t);const n={},r=q(t);r&&Object.assign(r,{evolution:e,next:n});V.set(t,n)}(t=ht(t),e);const r=P.get(t);r&&(n?K(r,[C],n):K(r,r.keys())),O.has(t)&&rt(t)}const V=new WeakMap;function q(t){t=ht(t);let e=V.get(t);return e||(e={},V.set(t,e)),e}function H(t,e=C){if(t=ht(t),J&&("symbol"!=typeof e||e===C)){let n=P.get(t);n||(n=new Map,P.set(t,n));let r=n.get(e);r||(r=new Set,n.set(e,r)),r.add(J);let o=v.get(J);o||(o=new Set,v.set(J,o)),o.add(t)}}let J,Q,X;function Y(t){const e=L(t);if(B?.chain(L(t),L(J)),X)X.set(e,t);else{const n=[];X=new Map([[e,t]]);try{for(;X.size;){if(n.length>B.maxEffectChain)throw new F("[reactive] Max effect chain reached");const[t,e]=X.entries().next().value;n.push(t),e(),X.delete(t)}}finally{X=void 0}}}function Z(t,e,n){if(L(t)===L(J))return e();const r=J,o=Q;J=t,n||(Q=t);try{return e()}finally{J=r,Q=o}}function _(t,e,n){let r=x.get(t);r||(r=new Set,x.set(t,r)),r.add({parent:e,prop:n})}function tt(t,e,n){const r=x.get(t);r&&(r.delete({parent:e,prop:n}),0===r.size&&x.delete(t))}function et(t){return O.has(t)||nt(t)}function nt(t){const e=x.get(t);if(!e)return!1;for(const{parent:t}of e){if(O.has(t))return!0;if(nt(t))return!0}return!1}function rt(t,e){const n=x.get(t);if(n)for(const{parent:t}of n){const e=E.get(t);if(e)for(const t of e)Y(t);rt(t)}}const ot={[Symbol.toStringTag]:"MutTs Reactive",get(t,e,n){if(e===z)return!1;if(t[A]?.has(e)||"symbol"==typeof e)return Reflect.get(t,e,n);const r=!(e in t);(!B.instanceMembers||Object.hasOwn(n,e)||r)&&H(t,e);const o=Reflect.get(t,e,n);if("object"==typeof o&&null!==o){const n=at(o);return et(t)&&_(n,t,e),n}return o},set(t,e,n,r){if(t[A]?.has(e))return Reflect.set(t,e,n,r);const o=N in t&&t[N]instanceof Array&&(!Number.isNaN(Number(e))||"length"===e),s=ht(n);if(o)return t[e]=s,!0;const i=t[e],c=e in t;return function(t,e,n,r){O.has(t)&&("object"==typeof n&&null!==n&&tt(n,t,e),"object"==typeof r&&null!==r)&&_(at(r),t,e)}(t,e,i,s),i!==s&&(Reflect.set(t,e,s,r),U(t,{type:c?"set":"add",prop:e},e)),!0},deleteProperty(t,e){if(!Object.hasOwn(t,e))return!1;const n=t[e];return O.has(t)&&"object"==typeof n&&null!==n&&tt(n,t,e),delete t[e],U(t,{type:"del",prop:e},e),O.has(t)&&rt(t),!0},getPrototypeOf:t=>N in t?t[N]:Object.getPrototypeOf(t),setPrototypeOf:(t,e)=>!(N in t)&&(Object.setPrototypeOf(t,e),!0),ownKeys:t=>(H(t,C),Reflect.ownKeys(t))},st=new WeakSet;class it{constructor(){return st.has(new.target)?at(this):this}}function ct(t){if(!t||"object"!=typeof t)return t;const e=t;if(j.has(e)||yt(e))return e;if(S.has(e))return S.get(e);const n=!(T in e)||e instanceof e[T]?e:new e[T](e);n!==e&&j.set(n,e);const r=new Proxy(n,ot);return S.set(e,r),j.set(r,e),r}const at=c({class(t){if(t.prototype instanceof it)return st.add(t),t;class e extends t{constructor(...n){return super(...n),new.target===e||st.has(new.target)||B.warn(`${t.name} has been inherited by ${this.constructor.name} that is not reactive.\n@reactive decorator must be applied to the leaf class OR classes have to extend ReactiveBase.`),at(this)}}return Object.defineProperty(e,"name",{value:`Reactive<${t.name}>`}),e},get:t=>ct(t),default:ct});function ht(t){return j.get(t)??t}function lt(t){Z(void 0,t,!0)}const ut=new WeakMap,ft=new FinalizationRegistry(t=>t());function dt(t,...e){let n=null;const r=$(t=>Z(s,t),t);let o=!1;function s(){n?.(),B.enter(t);const i=Z(o?void 0:s,()=>t(r,...e));B.leave(t),n=()=>{n=null,i?.();const t=v.get(s);if(t){for(const e of t){const t=P.get(e);if(t){for(const[e,n]of t.entries())n.delete(s),0===n.size&&t.delete(e);0===t.size&&P.delete(e)}}v.delete(s)}}}if($(s,t),X){const e=X;try{X=new Map([[t,s]]),s(),X.delete(t);for(const[t,n]of X)e.set(t,n)}finally{X=e}}else Y(s);const i=()=>{if(o)return;o=!0,n?.();const t=ut.get(s);if(t){for(const e of t)e();ut.delete(s)}ft.unregister(i)};if(!Q){const t=()=>i();return ft.register(t,i,t),t}let c=ut.get(Q);c||(c=new Set,ut.set(Q,c));const a=Q,h=()=>{c.delete(h),0===c.size&&ut.delete(a),i()};return c.add(h),h}const pt=new Set;function yt(t){return null===t||"object"!=typeof t||(!!M.has(t)||(!!t[z]||!!Array.from(pt).some(e=>e(t))))}function gt(...t){for(const e of t)e&&(e.prototype[z]=!0);return t[0]}function bt(t,e){t.prototype[T]=e,gt(e)}function mt(t,e,{immediate:n=!1}={}){if(null==t)return;if("object"!=typeof t)throw new Error("Target of deep watching must be an object");const r=$(()=>e(t),e);return dt(()=>{O.add(t);let o=k.get(r);o||(o=new Set,k.set(r,o)),o.add(t);const s=new WeakSet;return function t(e,n=0){if(!(s.has(e)||!function(t){return null!==t&&"object"==typeof t}(e)||n>B.maxDeepWatchDepth||yt(e))){s.add(e),O.add(e),o.add(e);for(const r in ht(e))if(Object.hasOwn(e,r)){const o=e[r];t("object"==typeof o&&null!==o?at(o):o,n+1)}if(Array.isArray(e)||e instanceof Array){const r=e.length;for(let o=0;o<r;o++){const r=e[o];t("object"==typeof r&&null!==r?at(r):r,n+1)}}else if(e instanceof Set)for(const r of e){t("object"==typeof r&&null!==r?at(r):r,n+1)}else if(e instanceof Map)for(const[r,o]of e){t("object"==typeof o&&null!==o?at(o):o,n+1)}}}(t),n&&e(t),n=!0,()=>{const t=k.get(r);if(t){for(const e of t){const t=E.get(e);t?(t.delete(r),0===t.size&&(E.delete(e),O.delete(e))):O.delete(e)}k.delete(r)}}})}let wt;gt(Date,RegExp,Error,Promise,Function),"undefined"!=typeof window&&function(...t){for(const e of t){try{Object.defineProperty(e,z,{value:!0,writable:!1,enumerable:!1,configurable:!1})}catch{}z in e||M.add(e)}t[0]}(window,document),"undefined"!=typeof Element&&gt(Element,Node);const vt=new WeakMap;function St(t){const e=L(t);let n=[];return H(vt,e),vt.has(e)||Z(void 0,()=>{const r=dt($(o=>{const s=wt;if(vt.has(e)){for(const t of n)t();n=[],vt.delete(e),U(vt,{type:"set",prop:e},e),r()}else try{wt=n,vt.set(e,t(o))}finally{wt=s}},t))}),vt.get(e)}const jt=c({getter(t,e){const n=new WeakMap;return function(){return n.has(this)||n.set(this,r(()=>t.call(this),`${String(this.constructor.name)}.${String(e)}`)),St(n.get(this))}},default:t=>St(t)}),xt=Symbol("unset-yet");function Ot(t){if(yt(t=ht(t)))return t;try{Object.defineProperty(t,z,{value:!0,writable:!1,enumerable:!1,configurable:!0})}catch{}z in t||M.add(t);for(const e in t)Ot(t[e]);return t}const Et=c({class(t){gt(t)},default:function(t,...e){return"object"==typeof t?Ot(t):n=>{n.prototype[A]=new Set(n.prototype[A]||[]),n.prototype[A].add(t);for(const t of e)n.prototype[A].add(t);return n}}});Object.assign(R,{computedCache:vt});const kt=Symbol("native"),Mt=Array.isArray;Array.isArray=t=>Mt(t)||t instanceof Array&&kt in t;class Dt{}function*Wt(t,{length:e=!0}={}){yield t,e&&(yield"length")}function*Pt(t,e,{length:n=!1}={}){const r=Math.min(t,e),o=Math.max(t,e);for(let t=r;t<=o;t++)yield t;n&&(yield"length")}class Rt extends(w(Dt,{get(t){return H(this[kt],t),at(this[kt][t])},set(t,e){const n=t>=this[kt].length;this[kt][t]=e,G(this[kt],{type:"bunch",method:"set"},Wt(t,{length:n}))},getLength(){return H(this[kt],"length"),this[kt].length},setLength(t){const e=this[kt].length;try{this[kt].length=t}finally{G(this[kt],{type:"set",prop:"length"},Pt(e,t,{length:!0}))}}})){constructor(t){super(),Object.defineProperties(this,{[kt]:{value:t},[N]:{value:t}})}at(t){const e=t<0?this[kt].length+t:t;if(H(this,e),!(e<0||e>=this[kt].length))return at(this[kt][e])}push(...t){const e=this[kt].length;try{return this[kt].push(...t)}finally{G(this,{type:"bunch",method:"push"},Pt(e,e+t.length-1,{length:!0}))}}pop(){if(0!==this[kt].length)try{return at(this[kt].pop())}finally{G(this,{type:"bunch",method:"pop"},Wt(this[kt].length))}}shift(){if(0!==this[kt].length)try{return at(this[kt].shift())}finally{G(this,{type:"bunch",method:"shift"},Pt(0,this[kt].length+1,{length:!0}))}}unshift(...t){try{return this[kt].unshift(...t)}finally{G(this,{type:"bunch",method:"unshift"},Pt(0,this[kt].length-t.length,{length:!0}))}}splice(t,e,...n){const r=this[kt].length;void 0===e&&(e=r-t);try{return at(void 0===e?this[kt].splice(t):this[kt].splice(t,e,...n))}finally{G(this,{type:"bunch",method:"splice"},e===n.length?Pt(t,t+e):Pt(t,r+Math.max(n.length-e,0),{length:!0}))}}reverse(){try{return this[kt].reverse()}finally{G(this,{type:"bunch",method:"reverse"},Pt(0,this[kt].length-1))}}sort(t){try{return this[kt].sort(t)}finally{G(this,{type:"bunch",method:"sort"},Pt(0,this[kt].length-1))}}fill(t,e,n){try{return void 0===e?this[kt].fill(t):void 0===n?this[kt].fill(t,e):this[kt].fill(t,e,n)}finally{G(this,{type:"bunch",method:"fill"},Pt(0,this[kt].length-1))}}copyWithin(t,e,n){try{return void 0===n?this[kt].copyWithin(t,e):this[kt].copyWithin(t,e,n)}finally{G(this,{type:"bunch",method:"copyWithin"},Pt(0,this[kt].length-1))}}toReversed(){return H(this),at(this[kt].toReversed())}toSorted(t){return H(this),at(this[kt].toSorted(t))}toSpliced(t,e,...n){return H(this),void 0===e?this[kt].toSpliced(t):this[kt].toSpliced(t,e,...n)}with(t,e){return H(this),at(this[kt].with(t,e))}entries(){return H(this),W(this[kt].entries())}keys(){return H(this),this[kt].keys()}values(){return H(this),D(this[kt].values())}[Symbol.iterator](){H(this);const t=this[kt][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:at(e.value),done:!1}}}}indexOf(t,e){return H(this),this[kt].indexOf(t,e)}lastIndexOf(t,e){return H(this),this[kt].lastIndexOf(t,e)}includes(t,e){return H(this),this[kt].includes(t,e)}find(t,e){return H(this),at(this[kt].find(t,e))}findIndex(t,e){return H(this),this[kt].findIndex(t,e)}flat(){return H(this),at(this[kt].flat())}flatMap(t,e){return H(this),at(this[kt].flatMap(t,e))}filter(t,e){return H(this),at(this[kt].filter(t,e))}map(t,e){return H(this),at(this[kt].map(t,e))}reduce(t,e){H(this);const n=void 0===e?this[kt].reduce(t):this[kt].reduce(t,e);return at(n)}reduceRight(t,e){H(this);const n=void 0!==e?this[kt].reduceRight(t,e):this[kt].reduceRight(t);return at(n)}slice(t,e){for(const n of Pt(t||0,e||this[kt].length-1))H(this,n);return void 0===t?this[kt].slice():void 0===e?this[kt].slice(t):this[kt].slice(t,e)}concat(...t){return H(this),at(this[kt].concat(...t))}join(t){return H(this),this[kt].join(t)}forEach(t,e){H(this),this[kt].forEach(t,e)}every(t,e){return H(this),this[kt].every(t,e)}some(t,e){return H(this),this[kt].some(t,e)}}const Tt=Symbol("native");class zt{constructor(t){Object.defineProperties(this,{[Tt]:{value:t},[N]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveMap"}})}get size(){return H(this,"size"),this[Tt].size}clear(){const t=this[Tt].size>0;if(this[Tt].clear(),t){const t={type:"bunch",method:"clear"};U(this,t,"size"),G(this.content,t)}}entries(){return H(this.content),W(this[Tt].entries())}forEach(t,e){H(this.content),this[Tt].forEach(t,e)}keys(){return H(this.content),this[Tt].keys()}values(){return H(this.content),D(this[Tt].values())}[Symbol.iterator](){H(this.content);const t=this[Tt][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:[e.value[0],at(e.value[1])],done:!1}}}}delete(t){const e=this[Tt].has(t),n=this[Tt].delete(t);if(e){const e={type:"del",prop:t};U(this.content,e,t),U(this,e,"size")}return n}get(t){return H(this.content,t),at(this[Tt].get(t))}has(t){return H(this.content,t),this[Tt].has(t)}set(t,e){const n=this[Tt].has(t),r=this[Tt].get(t),o=at(e);if(this[Tt].set(t,o),!n||r!==o){const e={type:n?"set":"add",prop:t};U(this.content,e,t),U(this,e,"size")}return this}}const At=Symbol("native");class Nt{constructor(t){Object.defineProperties(this,{[At]:{value:t},[N]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveSet"}})}get size(){return H(this,"size"),this[At].size}add(t){const e=this[At].has(t),n=at(t);if(this[At].add(n),!e){const t={type:"add",prop:n};U(this.content,t,n),U(this,t,"size")}return this}clear(){const t=this[At].size>0;if(this[At].clear(),t){const t={type:"bunch",method:"clear"};U(this,t,"size"),G(this.content,t)}}delete(t){const e=this[At].has(t),n=this[At].delete(t);if(e){const e={type:"del",prop:t};U(this.content,e,t),U(this,e,"size")}return n}has(t){return H(this.content,t),this[At].has(t)}entries(){return H(this.content),W(this[At].entries())}forEach(t,e){H(this.content),this[At].forEach(t,e)}keys(){return H(this.content),D(this[At].keys())}values(){return H(this.content),D(this[At].values())}[Symbol.iterator](){H(this.content);const t=this[At][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:at(e.value),done:!1}}}}}bt(WeakMap,class{constructor(t){Object.defineProperties(this,{[Tt]:{value:t},[N]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveWeakMap"}})}delete(t){const e=this[Tt].has(t),n=this[Tt].delete(t);return e&&U(this.content,{type:"del",prop:t},t),n}get(t){return H(this.content,t),at(this[Tt].get(t))}has(t){return H(this.content,t),this[Tt].has(t)}set(t,e){return U(this.content,{type:this[Tt].has(t)?"set":"add",prop:t},t),this[Tt].set(t,e),this}}),bt(Map,zt),bt(WeakSet,class{constructor(t){Object.defineProperties(this,{[At]:{value:t},[N]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveWeakSet"}})}add(t){const e=this[At].has(t);return this[At].add(t),e||U(this.content,{type:"add",prop:t},t),this}delete(t){const e=this[At].has(t),n=this[At].delete(t);return e&&U(this.content,{type:"del",prop:t},t),n}has(t){return H(this.content,t),this[At].has(t)}}),bt(Set,Nt),bt(Array,Rt);const Ct=[],It=c({getter:(t,e)=>function(){const n=Ct.findIndex(t=>t.object===this&&t.prop===e);if(n>-1)throw new Error(`Circular dependency detected: ${Ct.slice(n).map(t=>`${t.object.constructor.name}.${String(t.prop)}`).join(" -> ")} -> again`);Ct.push({object:this,prop:e});try{const n=t.call(this);return $t(this,e,n),n}finally{Ct.pop()}}});function $t(t,e,n){Object.defineProperty(t,e,{value:n})}const Lt=Object.assign(c({method:(t,e)=>function(...n){return Lt.warn(this,e),t.apply(this,n)},getter:(t,e)=>function(){return Lt.warn(this,e),t.call(this)},setter:(t,e)=>function(n){return Lt.warn(this,e),t.call(this,n)},class:t=>class extends t{constructor(...t){super(...t),Lt.warn(this,"constructor")}},default:t=>c({method:(e,n)=>function(...r){return Lt.warn(this,n,t),e.apply(this,r)},getter:(e,n)=>function(){return Lt.warn(this,n,t),e.call(this)},setter:(e,n)=>function(r){return Lt.warn(this,n,t),e.call(this,r)},class:e=>class extends e{constructor(...e){super(...e),Lt.warn(this,"constructor",t)}}})}),{warn:(t,e,n)=>{}});t.DecoratorError=o,t.Destroyable=function(t,e){var n;return t&&"function"!=typeof t&&(e=t,t=void 0),t||(t=class{}),n=class extends t{static destroy(t){const e=n.destructors.get(t);if(!e)return!1;a.unregister(t),n.destructors.delete(t),Object.setPrototypeOf(t,new Proxy({},f));for(const e of Object.getOwnPropertyNames(t))delete t[e];return e(),!0}static isDestroyable(t){return n.destructors.has(t)}constructor(...t){super(...t);const r={};this[l]=r;const o=e?.destructor??this[h];if(!o)throw new u("Destructor is not defined");function s(){o(r)}n.destructors.set(this,s),a.register(this,s,this)}},n.destructors=new WeakMap,n},t.DestructionError=u,t.Eventful=class{constructor(){y.set(this,new Map),g.set(this,[])}hook(t){return p(this,g,"f").includes(t)||p(this,g,"f").push(t),()=>{p(this,g,"f").splice(p(this,g,"f").indexOf(t),1)}}on(t,e){if("object"==typeof t)for(const e of Object.keys(t))this.on(e,t[e]);else if(void 0!==e){let n=p(this,y,"f").get(t);n||(n=[],p(this,y,"f").set(t,n)),n.push(e)}return()=>this.off(t,e)}off(t,e){if("object"==typeof t)for(const e of Object.keys(t))this.off(e,t[e]);else if(null!=e){const n=p(this,y,"f").get(t);n&&p(this,y,"f").set(t,n.filter(t=>t!==e))}else p(this,y,"f").delete(t)}emit(t,...e){const n=p(this,y,"f").get(t);if(n)for(const t of n)t.apply(this,e);for(const n of p(this,g,"f"))n.call(this,t,...e)}},t.Indexable=w,t.ReactiveBase=it,t.ReactiveError=F,t.allocated=d,t.allocatedValues=l,t.cache=$t,t.cached=It,t.callOnGC=function(t){let e=!1;const n=()=>{e||(e=!0,t())};return a.register(n,t,t),n},t.computed=jt,t.debounce=function(t){return c({method(e,n){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{e.apply(this,n),r=null},t)}}})},t.decorator=c,t.deprecated=Lt,t.describe=function(t){return(...e)=>n=>class extends n{constructor(...n){super(...n);for(const n of e)Object.defineProperty(this,n,{...Object.getOwnPropertyDescriptor(this,n),...t})}}},t.destructor=h,t.effect=dt,t.getAt=b,t.getState=q,t.immutables=pt,t.invalidateComputed=function(t,e=!0){wt?wt.push(t):e&&B.warn("Using `invalidateComputed` outside of a computed property")},t.isCached=function(t,e){return!!Object.getOwnPropertyDescriptor(t,e)},t.isConstructor=n,t.isNonReactive=yt,t.isReactive=function(t){return j.has(t)},t.legacyDecorator=s,t.modernDecorator=i,t.profileInfo=R,t.reactive=at,t.reactiveOptions=B,t.renamed=r,t.setAt=m,t.throttle=function(t){return c({method(e,n){let r=0,o=null;return function(...n){const s=Date.now();if(s-r>=t)return o&&(clearTimeout(o),o=null),r=s,e.apply(this,n);if(!o){const i=t-(s-r),c=[...n];o=setTimeout(()=>{r=Date.now(),e.apply(this,c),o=null},i)}}}})},t.unreactive=Et,t.untracked=lt,t.unwrap=ht,t.watch=function(t,e,n={}){return"function"==typeof t?function(t,e,{immediate:n=!1,deep:r=!1}={}){let o,s=xt;const i=dt($(i=>{const c=t(i);s!==c&&lt($(()=>{s===xt?n&&e(c):e(c,s),s=c,r&&(o&&o(),o=mt(c,$(t=>e(t,t),e)))},e))},t));return()=>{i(),o&&o()}}(t,e,n):"object"==typeof t?function(t,e,{immediate:n=!1,deep:r=!1}={}){return r?mt(t,e,{immediate:n}):dt($(()=>{H(t),n&&lt(()=>e(t)),n=!0},e))}(t,e,n):(()=>{throw new Error("watch: value must be a function or an object")})()},t.zip=function(...t){if(!t.length)return[];const e=Math.min(...t.map(t=>t.length)),n=[];for(let r=0;r<e;r++){const e=t.map(t=>t[r]);n.push(e)}return n}});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Mutts={})}(this,function(t){"use strict";const e=new Set([Object,Array,Date,Function,Set,Map,WeakMap,WeakSet,Promise,Error,TypeError,ReferenceError,SyntaxError,RangeError,URIError,EvalError,Reflect,Proxy,RegExp,String,Number,Boolean]);function n(t){return t&&(e.has(t)||t.toString?.().startsWith("class "))}function r(t,e){return Object.defineProperties(t,{name:{value:e}})}class o extends Error{constructor(t){super(t),this.name="DecoratorException"}}function s(t){return function(e,r,o,...s){if(void 0===r){if(n(e)){if(!("class"in t))throw new Error("Decorator cannot be applied to a class");return t.class?.(e)}}else if("object"==typeof e&&["string","symbol"].includes(typeof r)){if(!o)throw new Error("Decorator cannot be applied to a field");if("object"==typeof o&&"configurable"in o){if("get"in o||"set"in o){if(!("getter"in t)&&!("setter"in t))throw new Error("Decorator cannot be applied to a getter or setter");if("getter"in t){const e=t.getter?.(o.get,r);e&&(o.get=e)}if("setter"in t){const e=t.setter?.(o.set,r);e&&(o.set=e)}return o}if("function"==typeof o.value){if(!("method"in t))throw new Error("Decorator cannot be applied to a method");const e=t.method?.(o.value,r);return e&&(o.value=e),o}}}if(!("default"in t))throw new Error("Decorator do not have a default implementation");return t.default.call(this,e,r,o,...s)}}function i(t){return function(e,n,...r){if(!n?.kind||"string"!=typeof n.kind){if(!("default"in t))throw new Error("Decorator do not have a default implementation");return t.default.call(this,e,n,...r)}switch(n.kind){case"class":if(!("class"in t))throw new Error("Decorator cannot be applied to a class");return t.class?.(e);case"field":throw new Error("Decorator cannot be applied to a field");case"getter":if(!("getter"in t))throw new Error("Decorator cannot be applied to a getter");return t.getter?.(e,n.name);case"setter":if(!("setter"in t))throw new Error("Decorator cannot be applied to a setter");return t.setter?.(e,n.name);case"method":if(!("method"in t))throw new Error("Decorator cannot be applied to a method");return t.method?.(e,n.name);case"accessor":{if(!("getter"in t)&&!("setter"in t))throw new Error("Decorator cannot be applied to a getter or setter");const r={};if("getter"in t){const o=t.getter?.(e.get,n.name);o&&(r.get=o)}if("setter"in t){const o=t.setter?.(e.set,n.name);o&&(r.set=o)}return r}}}}const c=t=>(e,n,...r)=>{const o=function(t,e){return"object"==typeof e&&null!==e&&"string"==typeof e.kind?"modern":"legacy"}(0,n,r[0]);return"modern"===o?i(t)(e,n,...r):s(t)(e,n,...r)},a=new FinalizationRegistry(t=>t()),l=Symbol("destructor"),h=Symbol("allocated");class u extends Error{static throw(t){return()=>{throw new u(t)}}constructor(t){super(`Object is destroyed. ${t}`),this.name="DestroyedAccessError"}}const f={[Symbol.toStringTag]:"MutTs Destroyable",get:u.throw("Cannot access destroyed object"),set:u.throw("Cannot access destroyed object")};const d=c({setter:(t,e)=>function(n){return this[h][e]=n,t.call(this,n)}});function p(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}var y,g;"function"==typeof SuppressedError&&SuppressedError;y=new WeakMap,g=new WeakMap;const b=Symbol("getAt"),m=Symbol("setAt");function w(t,e){t&&"function"!=typeof t&&(e=t,t=void 0),t||(t=class{}),e||(e={get(t){if("function"!=typeof this[b])throw new Error("Indexable class must have an [getAt] method");return this[b](t)},set(t,e){if("function"!=typeof this[m])throw new Error("Indexable class has read-only numeric index access");this[m](t,e)}});class n extends t{}return Object.setPrototypeOf(n.prototype,new Proxy(t.prototype,{[Symbol.toStringTag]:"MutTs Indexable",get(t,n,r){if(n in t){const e=Object.getOwnPropertyDescriptor(t,n)?.get;return e?e.call(r):t[n]}if("string"==typeof n){if("length"===n&&e.getLength)return e.getLength.call(r);const t=Number(n);if(!Number.isNaN(t))return e.get.call(r,t)}},set(t,n,r,o){if(n in t){const e=Object.getOwnPropertyDescriptor(t,n)?.set;return e?e.call(o,r):t[n]=r,!0}if("string"==typeof n){if("length"===n&&e.setLength)return e.setLength.call(o,r),!0;const t=Number(n);if(!Number.isNaN(t)){if(!e.set)throw new Error("Indexable class has read-only numeric index access");return e.set.call(o,t,r),!0}}return Object.defineProperty(o,n,{value:r,writable:!0,enumerable:!0,configurable:!0}),!0}})),n}const v=new WeakMap,S=new WeakMap,j=new WeakMap,x=new WeakMap,O=new WeakSet,E=new WeakMap,k=new WeakMap,M=new WeakSet,D=Symbol("absent");function*R(t){let e=t.next();for(;!e.done;)yield ht(e.value),e=t.next()}function*W(t){let e=t.next();for(;!e.done;){const[n,r]=e.value;yield[ht(n),ht(r)],e=t.next()}}const P=new WeakMap,T={objectToProxy:S,proxyToObject:j,effectToReactiveObjects:v,watchers:P,objectParents:x,objectsWithDeepWatchers:O,deepWatchers:E,effectToDeepWatchedObjects:k,nonReactiveObjects:M},z=Symbol("native-reactive"),A=Symbol("non-reactive"),N=Symbol("unreactive-properties"),C=Symbol("prototype-forwarding"),I=Symbol("all-props"),$=Symbol("root-function");function L(t,e){return Object.defineProperty(t,$,{value:F(e),writable:!1})}function F(t){return t?.[$]||t}class B extends Error{constructor(t){super(t),this.name="ReactiveError"}}const K={enter:t=>{},leave:t=>{},chain:(t,e)=>{},maxEffectChain:100,maxDeepWatchDepth:100,instanceMembers:!0,warn:(...t)=>{}};function U(t,...e){for(const n of e)for(const e of n){const n=t.get(e);if(n)for(const t of Array.from(n))Z(t)}}function G(t,e,n){V(t,e,[n])}function V(t,e,n){!function(t,e){t=ut(t);const n={},r=H(t);r&&Object.assign(r,{evolution:e,next:n});q.set(t,n)}(t=ut(t),e);const r=P.get(t);r&&(n?U(r,[I],n):U(r,r.keys())),O.has(t)&&st(t)}const q=new WeakMap;function H(t){t=ut(t);let e=q.get(t);return e||(e={},q.set(t,e)),e}function J(t,e=I){if(t=ut(t),Q&&("symbol"!=typeof e||e===I)){let n=P.get(t);n||(n=new Map,P.set(t,n));let r=n.get(e);r||(r=new Set,n.set(e,r)),r.add(Q);let o=v.get(Q);o||(o=new Set,v.set(Q,o)),o.add(t)}}let Q,X,Y;function Z(t,e){const n=F(t);if(K?.chain(F(t),F(Q)),Y){if(Y.set(n,t),e)try{return t()}finally{Y.delete(n)}}else{const e=[];Y=new Map([[n,t]]);const r={};try{for(;Y.size;){if(e.length>K.maxEffectChain)throw new B("[reactive] Max effect chain reached");const[t,n]=Y.entries().next().value;e.push(t);const o=n();"value"in r||(r.value=o),Y.delete(t)}return r.value}finally{Y=void 0}}}const _=c({method:t=>function(...e){return Z(L(()=>t.apply(this,e),t),"immediate")},default:t=>function(...e){return Z(L(()=>t.apply(this,e),t),"immediate")}});function tt(t,e,n){if(F(t)===F(Q))return e();const r=Q,o=X;Q=t,n||(X=t);try{return e()}finally{Q=r,X=o}}function et(t,e,n){let r=x.get(t);r||(r=new Set,x.set(t,r)),r.add({parent:e,prop:n})}function nt(t,e,n){const r=x.get(t);r&&(r.delete({parent:e,prop:n}),0===r.size&&x.delete(t))}function rt(t){return O.has(t)||ot(t)}function ot(t){const e=x.get(t);if(!e)return!1;for(const{parent:t}of e){if(O.has(t))return!0;if(ot(t))return!0}return!1}function st(t,e){const n=x.get(t);if(n)for(const{parent:t}of n){const e=E.get(t);if(e)for(const t of e)Z(t);st(t)}}const it={[Symbol.toStringTag]:"MutTs Reactive",get(t,e,n){if(e===A)return!1;if(t[N]?.has(e)||"symbol"==typeof e)return Reflect.get(t,e,n);K.instanceMembers&&!Object.hasOwn(n,e)&&Reflect.has(n,e)||J(t,e);const r=Reflect.get(t,e,n);if("object"==typeof r&&null!==r){const n=ht(r);return rt(t)&&et(n,t,e),n}return r},set(t,e,n,r){if(t[N]?.has(e))return Reflect.set(t,e,n,r);const o=C in t&&t[C]instanceof Array&&(!Number.isNaN(Number(e))||"length"===e),s=ut(n);if(o)return t[e]=s,!0;const i=Reflect.has(r,e)?Reflect.get(t,e,r):D;return function(t,e,n,r){O.has(t)&&("object"==typeof n&&null!==n&&nt(n,t,e),"object"==typeof r&&null!==r)&&et(ht(r),t,e)}(t,e,i,s),i!==s&&(Reflect.set(t,e,s,r),G(t,{type:i!==D?"set":"add",prop:e},e)),!0},deleteProperty(t,e){if(!Object.hasOwn(t,e))return!1;const n=t[e];return O.has(t)&&"object"==typeof n&&null!==n&&nt(n,t,e),delete t[e],G(t,{type:"del",prop:e},e),O.has(t)&&st(t),!0},getPrototypeOf:t=>C in t?t[C]:Object.getPrototypeOf(t),setPrototypeOf:(t,e)=>!(C in t)&&(Object.setPrototypeOf(t,e),!0),ownKeys:t=>(J(t,I),Reflect.ownKeys(t))},ct=new WeakSet;class at{constructor(){return ct.has(new.target)?ht(this):this}}function lt(t){if(!t||"object"!=typeof t)return t;const e=t;if(j.has(e)||bt(e))return e;if(S.has(e))return S.get(e);const n=!(z in e)||e instanceof e[z]?e:new e[z](e);n!==e&&j.set(n,e);const r=new Proxy(n,it);return S.set(e,r),j.set(r,e),r}const ht=c({class(t){if(t.prototype instanceof at)return ct.add(t),t;class e extends t{constructor(...n){return super(...n),new.target===e||ct.has(new.target)||K.warn(`${t.name} has been inherited by ${this.constructor.name} that is not reactive.\n@reactive decorator must be applied to the leaf class OR classes have to extend ReactiveBase.`),ht(this)}}return Object.defineProperty(e,"name",{value:`Reactive<${t.name}>`}),e},get:t=>lt(t),default:lt});function ut(t){return j.get(t)??t}function ft(t){tt(void 0,t,!0)}const dt=new WeakMap,pt=new FinalizationRegistry(t=>t());function yt(t,...e){let n=null;const r=L(t=>tt(s,t),t);let o=!1;function s(){n?.(),K.enter(t);const i=tt(o?void 0:s,()=>t(r,...e));K.leave(t),n=()=>{n=null,i?.();const t=v.get(s);if(t){for(const e of t){const t=P.get(e);if(t){for(const[e,n]of t.entries())n.delete(s),0===n.size&&t.delete(e);0===t.size&&P.delete(e)}}v.delete(s)}}}L(s,t),Z(s,"immediate");const i=()=>{if(o)return;o=!0,n?.();const t=dt.get(s);if(t){for(const e of t)e();dt.delete(s)}pt.unregister(i)};if(!X){const t=()=>i();return pt.register(t,i,t),t}let c=dt.get(X);c||(c=new Set,dt.set(X,c));const a=X,l=()=>{c.delete(l),0===c.size&&dt.delete(a),i()};return c.add(l),l}const gt=new Set;function bt(t){return null===t||"object"!=typeof t||(!!M.has(t)||(!!t[A]||!!Array.from(gt).some(e=>e(t))))}function mt(...t){for(const e of t)e&&(e.prototype[A]=!0);return t[0]}function wt(t,e){t.prototype[z]=e,mt(e)}function vt(t,e,{immediate:n=!1}={}){if(null==t)return;if("object"!=typeof t)throw new Error("Target of deep watching must be an object");const r=L(()=>e(t),e);return yt(()=>{O.add(t);let o=k.get(r);o||(o=new Set,k.set(r,o)),o.add(t);const s=new WeakSet;return function t(e,n=0){if(!(s.has(e)||!function(t){return null!==t&&"object"==typeof t}(e)||n>K.maxDeepWatchDepth||bt(e))){s.add(e),O.add(e),o.add(e);for(const r in ut(e))if(Object.hasOwn(e,r)){const o=e[r];t("object"==typeof o&&null!==o?ht(o):o,n+1)}if(Array.isArray(e)||e instanceof Array){const r=e.length;for(let o=0;o<r;o++){const r=e[o];t("object"==typeof r&&null!==r?ht(r):r,n+1)}}else if(e instanceof Set)for(const r of e){t("object"==typeof r&&null!==r?ht(r):r,n+1)}else if(e instanceof Map)for(const[r,o]of e){t("object"==typeof o&&null!==o?ht(o):o,n+1)}}}(t),n&&e(t),n=!0,()=>{const t=k.get(r);if(t){for(const e of t){const t=E.get(e);t?(t.delete(r),0===t.size&&(E.delete(e),O.delete(e))):O.delete(e)}k.delete(r)}}})}let St;mt(Date,RegExp,Error,Promise,Function),"undefined"!=typeof window&&function(...t){for(const e of t){try{Object.defineProperty(e,A,{value:!0,writable:!1,enumerable:!1,configurable:!1})}catch{}A in e||M.add(e)}t[0]}(window,document),"undefined"!=typeof Element&&mt(Element,Node);const jt=new WeakMap;function xt(t){const e=F(t);let n=[];if(J(jt,e),jt.has(e))return jt.get(e);let r=!1;const o=yt(L(s=>{if(r)return;const i=St;if(jt.has(e)){for(const t of n)t();n=[],jt.delete(e),G(jt,{type:"invalidate",prop:e},e),o(),r=!0}else try{St=n,jt.set(e,t(s))}finally{St=i}},t));return jt.get(e)}const Ot=c({getter(t,e){const n=new WeakMap;return function(){return n.has(this)||n.set(this,r(()=>t.call(this),`${String(this.constructor.name)}.${String(e)}`)),xt(n.get(this))}},default:t=>xt(t)}),Et=Symbol("unset-yet");function kt(t){if(bt(t=ut(t)))return t;try{Object.defineProperty(t,A,{value:!0,writable:!1,enumerable:!1,configurable:!0})}catch{}A in t||M.add(t);for(const e in t)kt(t[e]);return t}const Mt=c({class(t){mt(t)},default:function(t,...e){return"object"==typeof t?kt(t):n=>{n.prototype[N]=new Set(n.prototype[N]||[]),n.prototype[N].add(t);for(const t of e)n.prototype[N].add(t);return n}}});Object.assign(T,{computedCache:jt});const Dt=Symbol("native"),Rt=Array.isArray;Array.isArray=t=>Rt(t)||t instanceof Array&&Dt in t;class Wt{}function*Pt(t,{length:e=!0}={}){yield t,e&&(yield"length")}function*Tt(t,e,{length:n=!1}={}){const r=Math.min(t,e),o=Math.max(t,e);for(let t=r;t<=o;t++)yield t;n&&(yield"length")}class zt extends(w(Wt,{get(t){return J(this[Dt],t),ht(this[Dt][t])},set(t,e){const n=t>=this[Dt].length;this[Dt][t]=e,V(this[Dt],{type:"bunch",method:"set"},Pt(t,{length:n}))},getLength(){return J(this[Dt],"length"),this[Dt].length},setLength(t){const e=this[Dt].length;try{this[Dt].length=t}finally{V(this[Dt],{type:"set",prop:"length"},Tt(e,t,{length:!0}))}}})){constructor(t){super(),Object.defineProperties(this,{[Dt]:{value:t},[C]:{value:t}})}at(t){const e=t<0?this[Dt].length+t:t;if(J(this,e),!(e<0||e>=this[Dt].length))return ht(this[Dt][e])}push(...t){const e=this[Dt].length;try{return this[Dt].push(...t)}finally{V(this,{type:"bunch",method:"push"},Tt(e,e+t.length-1,{length:!0}))}}pop(){if(0!==this[Dt].length)try{return ht(this[Dt].pop())}finally{V(this,{type:"bunch",method:"pop"},Pt(this[Dt].length))}}shift(){if(0!==this[Dt].length)try{return ht(this[Dt].shift())}finally{V(this,{type:"bunch",method:"shift"},Tt(0,this[Dt].length+1,{length:!0}))}}unshift(...t){try{return this[Dt].unshift(...t)}finally{V(this,{type:"bunch",method:"unshift"},Tt(0,this[Dt].length-t.length,{length:!0}))}}splice(t,e,...n){const r=this[Dt].length;void 0===e&&(e=r-t);try{return ht(void 0===e?this[Dt].splice(t):this[Dt].splice(t,e,...n))}finally{V(this,{type:"bunch",method:"splice"},e===n.length?Tt(t,t+e):Tt(t,r+Math.max(n.length-e,0),{length:!0}))}}reverse(){try{return this[Dt].reverse()}finally{V(this,{type:"bunch",method:"reverse"},Tt(0,this[Dt].length-1))}}sort(t){try{return this[Dt].sort(t)}finally{V(this,{type:"bunch",method:"sort"},Tt(0,this[Dt].length-1))}}fill(t,e,n){try{return void 0===e?this[Dt].fill(t):void 0===n?this[Dt].fill(t,e):this[Dt].fill(t,e,n)}finally{V(this,{type:"bunch",method:"fill"},Tt(0,this[Dt].length-1))}}copyWithin(t,e,n){try{return void 0===n?this[Dt].copyWithin(t,e):this[Dt].copyWithin(t,e,n)}finally{V(this,{type:"bunch",method:"copyWithin"},Tt(0,this[Dt].length-1))}}toReversed(){return J(this),ht(this[Dt].toReversed())}toSorted(t){return J(this),ht(this[Dt].toSorted(t))}toSpliced(t,e,...n){return J(this),void 0===e?this[Dt].toSpliced(t):this[Dt].toSpliced(t,e,...n)}with(t,e){return J(this),ht(this[Dt].with(t,e))}entries(){return J(this),W(this[Dt].entries())}keys(){return J(this),this[Dt].keys()}values(){return J(this),R(this[Dt].values())}[Symbol.iterator](){J(this);const t=this[Dt][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:ht(e.value),done:!1}}}}indexOf(t,e){return J(this),this[Dt].indexOf(t,e)}lastIndexOf(t,e){return J(this),this[Dt].lastIndexOf(t,e)}includes(t,e){return J(this),this[Dt].includes(t,e)}find(t,e){return J(this),ht(this[Dt].find(t,e))}findIndex(t,e){return J(this),this[Dt].findIndex(t,e)}flat(){return J(this),ht(this[Dt].flat())}flatMap(t,e){return J(this),ht(this[Dt].flatMap(t,e))}filter(t,e){return J(this),ht(this[Dt].filter(t,e))}map(t,e){return J(this),ht(this[Dt].map(t,e))}reduce(t,e){J(this);const n=void 0===e?this[Dt].reduce(t):this[Dt].reduce(t,e);return ht(n)}reduceRight(t,e){J(this);const n=void 0!==e?this[Dt].reduceRight(t,e):this[Dt].reduceRight(t);return ht(n)}slice(t,e){for(const n of Tt(t||0,e||this[Dt].length-1))J(this,n);return void 0===t?this[Dt].slice():void 0===e?this[Dt].slice(t):this[Dt].slice(t,e)}concat(...t){return J(this),ht(this[Dt].concat(...t))}join(t){return J(this),this[Dt].join(t)}forEach(t,e){J(this),this[Dt].forEach(t,e)}every(t,e){return J(this),this[Dt].every(t,e)}some(t,e){return J(this),this[Dt].some(t,e)}}const At=Symbol("native");class Nt{constructor(t){Object.defineProperties(this,{[At]:{value:t},[C]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveMap"}})}get size(){return J(this,"size"),this[At].size}clear(){const t=this[At].size>0;if(this[At].clear(),t){const t={type:"bunch",method:"clear"};G(this,t,"size"),V(this.content,t)}}entries(){return J(this.content),W(this[At].entries())}forEach(t,e){J(this.content),this[At].forEach(t,e)}keys(){return J(this.content),this[At].keys()}values(){return J(this.content),R(this[At].values())}[Symbol.iterator](){J(this.content);const t=this[At][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:[e.value[0],ht(e.value[1])],done:!1}}}}delete(t){const e=this[At].has(t),n=this[At].delete(t);if(e){const e={type:"del",prop:t};G(this.content,e,t),G(this,e,"size")}return n}get(t){return J(this.content,t),ht(this[At].get(t))}has(t){return J(this.content,t),this[At].has(t)}set(t,e){const n=this[At].has(t),r=this[At].get(t),o=ht(e);if(this[At].set(t,o),!n||r!==o){const e={type:n?"set":"add",prop:t};G(this.content,e,t),G(this,e,"size")}return this}}const Ct=Symbol("native");class It{constructor(t){Object.defineProperties(this,{[Ct]:{value:t},[C]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveSet"}})}get size(){return J(this,"size"),this[Ct].size}add(t){const e=this[Ct].has(t),n=ht(t);if(this[Ct].add(n),!e){const t={type:"add",prop:n};G(this.content,t,n),G(this,t,"size")}return this}clear(){const t=this[Ct].size>0;if(this[Ct].clear(),t){const t={type:"bunch",method:"clear"};G(this,t,"size"),V(this.content,t)}}delete(t){const e=this[Ct].has(t),n=this[Ct].delete(t);if(e){const e={type:"del",prop:t};G(this.content,e,t),G(this,e,"size")}return n}has(t){return J(this.content,t),this[Ct].has(t)}entries(){return J(this.content),W(this[Ct].entries())}forEach(t,e){J(this.content),this[Ct].forEach(t,e)}keys(){return J(this.content),R(this[Ct].keys())}values(){return J(this.content),R(this[Ct].values())}[Symbol.iterator](){J(this.content);const t=this[Ct][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:ht(e.value),done:!1}}}}}wt(WeakMap,class{constructor(t){Object.defineProperties(this,{[At]:{value:t},[C]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveWeakMap"}})}delete(t){const e=this[At].has(t),n=this[At].delete(t);return e&&G(this.content,{type:"del",prop:t},t),n}get(t){return J(this.content,t),ht(this[At].get(t))}has(t){return J(this.content,t),this[At].has(t)}set(t,e){return G(this.content,{type:this[At].has(t)?"set":"add",prop:t},t),this[At].set(t,e),this}}),wt(Map,Nt),wt(WeakSet,class{constructor(t){Object.defineProperties(this,{[Ct]:{value:t},[C]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveWeakSet"}})}add(t){const e=this[Ct].has(t);return this[Ct].add(t),e||G(this.content,{type:"add",prop:t},t),this}delete(t){const e=this[Ct].has(t),n=this[Ct].delete(t);return e&&G(this.content,{type:"del",prop:t},t),n}has(t){return J(this.content,t),this[Ct].has(t)}}),wt(Set,It),wt(Array,zt);const $t=[],Lt=c({getter:(t,e)=>function(){const n=$t.findIndex(t=>t.object===this&&t.prop===e);if(n>-1)throw new Error(`Circular dependency detected: ${$t.slice(n).map(t=>`${t.object.constructor.name}.${String(t.prop)}`).join(" -> ")} -> again`);$t.push({object:this,prop:e});try{const n=t.call(this);return Ft(this,e,n),n}finally{$t.pop()}}});function Ft(t,e,n){Object.defineProperty(t,e,{value:n})}const Bt=Object.assign(c({method:(t,e)=>function(...n){return Bt.warn(this,e),t.apply(this,n)},getter:(t,e)=>function(){return Bt.warn(this,e),t.call(this)},setter:(t,e)=>function(n){return Bt.warn(this,e),t.call(this,n)},class:t=>class extends t{constructor(...t){super(...t),Bt.warn(this,"constructor")}},default:t=>c({method:(e,n)=>function(...r){return Bt.warn(this,n,t),e.apply(this,r)},getter:(e,n)=>function(){return Bt.warn(this,n,t),e.call(this)},setter:(e,n)=>function(r){return Bt.warn(this,n,t),e.call(this,r)},class:e=>class extends e{constructor(...e){super(...e),Bt.warn(this,"constructor",t)}}})}),{warn:(t,e,n)=>{}});t.DecoratorError=o,t.Destroyable=function(t,e){var n;return t&&"function"!=typeof t&&(e=t,t=void 0),t||(t=class{}),n=class extends t{static destroy(t){const e=n.destructors.get(t);if(!e)return!1;a.unregister(t),n.destructors.delete(t),Object.setPrototypeOf(t,new Proxy({},f));for(const e of Object.getOwnPropertyNames(t))delete t[e];return e(),!0}static isDestroyable(t){return n.destructors.has(t)}constructor(...t){super(...t);const r={};this[h]=r;const o=e?.destructor??this[l];if(!o)throw new u("Destructor is not defined");function s(){o(r)}n.destructors.set(this,s),a.register(this,s,this)}},n.destructors=new WeakMap,n},t.DestructionError=u,t.Eventful=class{constructor(){y.set(this,new Map),g.set(this,[])}hook(t){return p(this,g,"f").includes(t)||p(this,g,"f").push(t),()=>{p(this,g,"f").splice(p(this,g,"f").indexOf(t),1)}}on(t,e){if("object"==typeof t)for(const e of Object.keys(t))this.on(e,t[e]);else if(void 0!==e){let n=p(this,y,"f").get(t);n||(n=[],p(this,y,"f").set(t,n)),n.push(e)}return()=>this.off(t,e)}off(t,e){if("object"==typeof t)for(const e of Object.keys(t))this.off(e,t[e]);else if(null!=e){const n=p(this,y,"f").get(t);n&&p(this,y,"f").set(t,n.filter(t=>t!==e))}else p(this,y,"f").delete(t)}emit(t,...e){const n=p(this,y,"f").get(t);if(n)for(const t of n)t.apply(this,e);for(const n of p(this,g,"f"))n.call(this,t,...e)}},t.Indexable=w,t.ReactiveBase=at,t.ReactiveError=B,t.allocated=d,t.allocatedValues=h,t.atomic=_,t.cache=Ft,t.cached=Lt,t.callOnGC=function(t){let e=!1;const n=()=>{e||(e=!0,t())};return a.register(n,t,t),n},t.computed=Ot,t.debounce=function(t){return c({method(e,n){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{e.apply(this,n),r=null},t)}}})},t.decorator=c,t.deprecated=Bt,t.describe=function(t){return(...e)=>n=>class extends n{constructor(...n){super(...n);for(const n of e)Object.defineProperty(this,n,{...Object.getOwnPropertyDescriptor(this,n),...t})}}},t.destructor=l,t.effect=yt,t.getAt=b,t.getState=H,t.immutables=gt,t.invalidateComputed=function(t,e=!0){St?St.push(t):e&&K.warn("Using `invalidateComputed` outside of a computed property")},t.isCached=function(t,e){return!!Object.getOwnPropertyDescriptor(t,e)},t.isConstructor=n,t.isNonReactive=bt,t.isReactive=function(t){return j.has(t)},t.legacyDecorator=s,t.modernDecorator=i,t.profileInfo=T,t.reactive=ht,t.reactiveOptions=K,t.renamed=r,t.setAt=m,t.throttle=function(t){return c({method(e,n){let r=0,o=null;return function(...n){const s=Date.now();if(s-r>=t)return o&&(clearTimeout(o),o=null),r=s,e.apply(this,n);if(!o){const i=t-(s-r),c=[...n];o=setTimeout(()=>{r=Date.now(),e.apply(this,c),o=null},i)}}}})},t.unreactive=Mt,t.untracked=ft,t.unwrap=ut,t.watch=function(t,e,n={}){return"function"==typeof t?function(t,e,{immediate:n=!1,deep:r=!1}={}){let o,s=Et;const i=yt(L(i=>{const c=t(i);s!==c&&ft(L(()=>{s===Et?n&&e(c):e(c,s),s=c,r&&(o&&o(),o=vt(c,L(t=>e(t,t),e)))},e))},t));return()=>{i(),o&&o()}}(t,e,n):"object"==typeof t?function(t,e,{immediate:n=!1,deep:r=!1}={}){return r?vt(t,e,{immediate:n}):yt(L(()=>{J(t),n&&ft(()=>e(t)),n=!0},e))}(t,e,n):(()=>{throw new Error("watch: value must be a function or an object")})()},t.zip=function(...t){if(!t.length)return[];const e=Math.min(...t.map(t=>t.length)),n=[];for(let r=0;r<e;r++){const e=t.map(t=>t[r]);n.push(e)}return n}});
2
2
  //# sourceMappingURL=mutts.umd.js.map