atom.io 0.14.0 â 0.14.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/data/dist/index.cjs +1473 -52
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.cts +315 -16
- package/data/dist/index.js +10 -267
- package/data/dist/index.js.map +1 -1
- package/data/package.json +5 -5
- package/data/src/join.ts +3 -3
- package/dist/chunk-5VJ77LZE.js +176 -0
- package/dist/chunk-5VJ77LZE.js.map +1 -0
- package/dist/chunk-CK7GNCU5.js +309 -0
- package/dist/chunk-CK7GNCU5.js.map +1 -0
- package/dist/chunk-KW7RA7IM.js +67 -0
- package/dist/chunk-KW7RA7IM.js.map +1 -0
- package/dist/chunk-LFXB7Y6M.js +68 -0
- package/dist/chunk-LFXB7Y6M.js.map +1 -0
- package/dist/chunk-NYCVSXQB.js +181 -0
- package/dist/chunk-NYCVSXQB.js.map +1 -0
- package/dist/chunk-TE3ZSTQ6.js +2516 -0
- package/dist/chunk-TE3ZSTQ6.js.map +1 -0
- package/dist/index.cjs +2244 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +268 -21
- package/dist/index.js +1 -152
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/internal/dist/index.cjs +208 -79
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +226 -27
- package/internal/dist/index.js +1 -2240
- package/internal/dist/index.js.map +1 -1
- package/internal/package.json +5 -5
- package/introspection/dist/index.cjs +1618 -46
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.cts +374 -4
- package/introspection/dist/index.js +2 -316
- package/introspection/dist/index.js.map +1 -1
- package/introspection/package.json +5 -5
- package/json/dist/index.cjs +1560 -8
- package/json/dist/index.cjs.map +1 -1
- package/json/dist/index.d.cts +371 -7
- package/json/dist/index.js +1 -76
- package/json/dist/index.js.map +1 -1
- package/json/package.json +5 -5
- package/package.json +5 -4
- package/react/dist/index.cjs +1604 -14
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.cts +375 -4
- package/react/dist/index.js +2 -68
- package/react/dist/index.js.map +1 -1
- package/react/package.json +5 -5
- package/react-devtools/dist/index.cjs +2268 -198
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.css +2 -2
- package/react-devtools/dist/index.d.cts +148 -24
- package/react-devtools/dist/index.js +57 -297
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/package.json +5 -5
- package/realtime-client/dist/index.cjs +1585 -35
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.cts +382 -12
- package/realtime-client/dist/index.js +2 -165
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/package.json +5 -5
- package/realtime-react/dist/index.cjs +1782 -35
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.cts +49 -9
- package/realtime-react/dist/index.js +4 -66
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/package.json +5 -5
- package/realtime-server/dist/index.cjs +1604 -58
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.cts +391 -11
- package/realtime-server/dist/index.js +27 -21
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/package.json +6 -6
- package/realtime-testing/dist/index.cjs +2352 -16
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.cts +486 -3
- package/realtime-testing/dist/index.js +10 -31
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/package.json +5 -5
- package/transceivers/set-rtx/dist/index.cjs +31 -10
- package/transceivers/set-rtx/dist/index.cjs.map +1 -1
- package/transceivers/set-rtx/dist/index.d.cts +29 -3
- package/transceivers/set-rtx/dist/index.js +2 -3
- package/transceivers/set-rtx/dist/index.js.map +1 -1
- package/transceivers/set-rtx/package.json +6 -6
- package/data/dist/index.d.ts +0 -158
- package/data/dist/metafile-cjs.json +0 -1
- package/data/dist/metafile-esm.json +0 -1
- package/dist/index.d.ts +0 -243
- package/dist/metafile-esm.json +0 -1
- package/internal/dist/index.d.ts +0 -421
- package/internal/dist/metafile-cjs.json +0 -1
- package/internal/dist/metafile-esm.json +0 -1
- package/introspection/dist/index.d.ts +0 -24
- package/introspection/dist/metafile-cjs.json +0 -1
- package/introspection/dist/metafile-esm.json +0 -1
- package/json/dist/index.d.ts +0 -51
- package/json/dist/metafile-cjs.json +0 -1
- package/json/dist/metafile-esm.json +0 -1
- package/react/dist/index.d.ts +0 -23
- package/react/dist/metafile-cjs.json +0 -1
- package/react/dist/metafile-esm.json +0 -1
- package/react-devtools/dist/index.d.ts +0 -341
- package/react-devtools/dist/metafile-cjs.json +0 -1
- package/react-devtools/dist/metafile-esm.json +0 -1
- package/realtime-client/dist/index.d.ts +0 -22
- package/realtime-client/dist/metafile-cjs.json +0 -1
- package/realtime-client/dist/metafile-esm.json +0 -1
- package/realtime-react/dist/index.d.ts +0 -27
- package/realtime-react/dist/metafile-cjs.json +0 -1
- package/realtime-react/dist/metafile-esm.json +0 -1
- package/realtime-server/dist/index.d.ts +0 -25
- package/realtime-server/dist/metafile-cjs.json +0 -1
- package/realtime-server/dist/metafile-esm.json +0 -1
- package/realtime-testing/dist/index.d.ts +0 -49
- package/realtime-testing/dist/metafile-cjs.json +0 -1
- package/realtime-testing/dist/metafile-esm.json +0 -1
- package/transceivers/set-rtx/dist/index.d.ts +0 -40
- package/transceivers/set-rtx/dist/metafile-cjs.json +0 -1
- package/transceivers/set-rtx/dist/metafile-esm.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../../__unstable__/web-effects/src/storage.ts","../../../anvl/src/function/pipe.ts","../../../anvl/src/function/index.ts","../../../anvl/src/array/venn.ts","../../../anvl/src/array/index.ts","../../../anvl/src/nullish/index.ts","../../../anvl/src/object/access.ts","../../../anvl/src/object/entries.ts","../../../anvl/src/object/mapObject.ts","../../../anvl/src/object/refinement.ts","../../../anvl/src/object/sprawl.ts","../../../anvl/src/object/index.ts","../../../anvl/src/refinement/refinery.ts","../../../anvl/src/tree/differ.ts","../src/AtomIODevtools.tsx","../src/StateIndex.tsx","../../../anvl/src/json/index.ts","../../../anvl/src/primitive/index.ts","../../../anvl/src/refinement/refine-json.ts","../src/Button.tsx","../src/StateEditor.tsx","../../../anvl/src/refinement/can-exist.ts","../../../anvl/src/refinement/cannot-exist.ts","../../../anvl/src/refinement/is-union.ts","../../../anvl/src/refinement/is-intersection.ts","../../../anvl/src/refinement/index.ts","../../../anvl/src/join/core-relation-data.ts","../../../anvl/src/join/get-related-ids.ts","../../../anvl/src/join/make-json-interface.ts","../../../anvl/src/join/relation-record.ts","../../../anvl/src/string/split.ts","../../../anvl/src/join/remove-relation.ts","../../../anvl/src/join/set-relation.ts","../../../anvl/src/join/relation-contents.ts","../../../anvl/src/join/index.ts","../../../hamr/src/react-elastic-input/ElasticInput.tsx","../../../hamr/src/react-elastic-input/NumberInput.tsx","../../../anvl/src/number/clamp.ts","../../../anvl/src/number/wrap.ts","../../../hamr/src/react-elastic-input/TextInput.tsx","../../../hamr/src/react-json-editor/editors-by-type/non-json.tsx","../../../hamr/src/react-json-editor/json-editor-internal.tsx","../../../hamr/src/react-json-editor/editors-by-type/utilities/array-elements.ts","../../../hamr/src/react-json-editor/editors-by-type/array-editor.tsx","../../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx","../../../anvl/src/json-schema/integer.ts","../../../anvl/src/json-schema/refs.ts","../../../anvl/src/json-schema/string-formats.ts","../../../anvl/src/json-schema/json-schema.ts","../../../anvl/src/json-schema/path-into.ts","../../../anvl/src/json-schema/find-sub-schema.ts","../../../anvl/src/json/cast-json.ts","../../../anvl/src/refinement/smart-cast-json.ts","../../../hamr/src/react-json-editor/editors-by-type/utilities/object-properties.ts","../../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx","../../../hamr/src/react-error-boundary/ReactErrorBoundary.tsx","../../../hamr/src/react-error-boundary/DefaultFallback.tsx","../../../hamr/src/react-json-editor/default-components.tsx","../../../hamr/src/react-json-editor/developer-interface.tsx","../../../hamr/src/react-json-editor/index.ts","../../../hamr/src/react-id/Id.tsx","../../../anvl/src/string/string-to-color.ts","../../../luum/src/constants/index.ts","../../../luum/src/constants/filters.ts","../../../luum/src/export/channelsToHex.ts","../../../luum/src/import/hueToRelativeChannels.ts","../../../luum/src/solveFor/hueFromChannels.ts","../../../luum/src/solveFor/lumFromChannels.ts","../../../luum/src/solveFor/maxSatForHueInFilter.ts","../../../luum/src/solveFor/satFromChannels.ts","../../../luum/src/solveFor/specificLumFromHue.ts","../../../luum/src/export/specToChannelsFixLimit.ts","../../../luum/src/export/specToHexFixLimit.ts","../../../luum/src/export/specToHex.ts","../../../luum/src/import/channelsToSpec.ts","../../../luum/src/import/normalizeHex.ts","../../../luum/src/import/hexToChannels.ts","../../../luum/src/import/hexToSpec.ts","../../../luum/src/mixers/lum.ts","../../../luum/src/mixers/contrast.ts","../../../luum/src/constants/luum-spec.ts","../../../luum/src/scheme/index.ts","../../../hamr/src/react-data-designer/RelationEditor.module.scss","../../../hamr/src/react-data-designer/RelationEditor.tsx","../src/TimelineIndex.tsx","../src/Updates.tsx","../src/TransactionIndex.tsx"],"names":["a","path","node","result","e","b","_a","useI","useO","useRef","isJson","isOpen","join","map","id","jsx","useState","jsxs","refMap","_","Fragment","round"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,MAAM,kBAAkB;AACjC,SAAS,iCAAiC;;;ACOnC,IAAM,cACZ,CAAI,YACJ,CAAC,EAAE,WAAW,MAAM,MACpB,CAAC,QACD,CAAC,EAAE,SAAS,MAAM,MAAM;AACvB,QAAM,aAAa,QAAQ,QAAQ,GAAG;AAEtC,MAAI,cAAc;AAAM,YAAQ,MAAM,UAAU,CAAC;AAEjD,QAAM,CAAC,EAAE,SAAS,MAAM;AACvB,QAAI,YAAY,MAAM;AACrB,cAAQ,WAAW,GAAG;AACtB;A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AC,uBAAuB,MAAM,eAAe,CAAC;AACjE,CAAC;AAEM,IAAM,oBAAoB,IAAI,SAAS;AAAA,EAC7C,QAAQ,CAAC,UAAoC,OAAO,UAAU;AAAA,EAC9D,QAAQ,CAAC,UAAoC,OAAO,UAAU;AAAA,EAC9D,SAAS,CAAC,UAAqC,OAAO,UAAU;AAAA,EAChE,MAAM,CAAC,UAAkC,UAAU;AACpD,CAAC;AAEM,IAAM,mBAAmB,IAAI,SAAS;AAAA,EAC5C,QAAQ;AAAA,EACR,OAAO,CAAC,UAAuC,MAAM,QAAQ,KAAK;AACnE,CAAC;AAEM,IAAM,aAAa,IAAI,OAAO,mBAAmB,kBAAkB;AAAA,EACzE,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM,OAAO,EAAE,SAAS,YAAY;AAAA,EACpC,QAAQ;AAAA,EACR,OAAO;AACR,CAAC","sourcesContent":["import { atom, atomFamily } from \"atom.io\"\nimport { attachIntrospectionStates } from \"atom.io/introspection\"\nimport { lazyLocalStorageEffect } from \"~/packages/atom.io/__unstable__/web-effects/src\"\n\nimport { isPlainObject } from \"~/packages/anvl/src/object\"\nimport { Refinery } from \"~/packages/anvl/src/refinement/refinery\"\nimport {\n\tDiffer,\n\tdiffArray,\n\tdiffBoolean,\n\tdiffNumber,\n\tdiffObject,\n\tdiffString,\n} from \"~/packages/anvl/src/tree/differ\"\n\nexport * from \"./AtomIODevtools\"\n\nexport const {\n\tatomIndex,\n\tselectorIndex,\n\ttransactionIndex,\n\tfindTransactionLogState,\n\ttimelineIndex,\n\tfindTimelineState,\n} = attachIntrospectionStates()\n\nexport const devtoolsAreOpenState = atom<boolean>({\n\tkey: `ðâðš Devtools Are Open`,\n\tdefault: true,\n\teffects: [lazyLocalStorageEffect(`ðâðš Devtools Are Open`)],\n})\n\ntype DevtoolsView = `atoms` | `selectors` | `timelines` | `transactions`\n\nexport const devtoolsViewSelectionState = atom<DevtoolsView>({\n\tkey: `ðâðš Devtools View Selection`,\n\tdefault: `atoms`,\n\teffects: [lazyLocalStorageEffect(`ðâðš Devtools View`)],\n})\n\nexport const devtoolsViewOptionsState = atom<DevtoolsView[]>({\n\tkey: `ðâðš Devtools View Options`,\n\tdefault: [`atoms`, `selectors`, `transactions`, `timelines`],\n\teffects: [lazyLocalStorageEffect(`ðâðš Devtools View Options`)],\n})\n\nexport const findViewIsOpenState = atomFamily<boolean, string>({\n\tkey: `ðâðš Devtools View Is Open`,\n\tdefault: false,\n\teffects: (key) => [lazyLocalStorageEffect(key + `:view-is-open`)],\n})\n\nexport const primitiveRefinery = new Refinery({\n\tnumber: (input: unknown): input is number => typeof input === `number`,\n\tstring: (input: unknown): input is string => typeof input === `string`,\n\tboolean: (input: unknown): input is boolean => typeof input === `boolean`,\n\tnull: (input: unknown): input is null => input === null,\n})\n\nexport const jsonTreeRefinery = new Refinery({\n\tobject: isPlainObject,\n\tarray: (input: unknown): input is unknown[] => Array.isArray(input),\n})\n\nexport const prettyJson = new Differ(primitiveRefinery, jsonTreeRefinery, {\n\tnumber: diffNumber,\n\tstring: diffString,\n\tboolean: diffBoolean,\n\tnull: () => ({ summary: `No Change` }),\n\tobject: diffObject,\n\tarray: diffArray,\n})\n","import type { AtomEffect } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\n\nexport type StringInterface<T> = {\n\tstringify: (t: T) => string\n\tparse: (s: string) => T\n}\n\nexport const persistAtom =\n\t<T>(storage: Storage) =>\n\t({ stringify, parse }: StringInterface<T>) =>\n\t(key: string): AtomEffect<T> =>\n\t({ setSelf, onSet }) => {\n\t\tconst savedValue = storage.getItem(key)\n\n\t\tif (savedValue != null) setSelf(parse(savedValue))\n\n\t\tonSet(({ newValue }) => {\n\t\t\tif (newValue == null) {\n\t\t\t\tstorage.removeItem(key)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tstorage.setItem(key, stringify(newValue))\n\t\t})\n\t}\n\nexport const lazyLocalStorageEffect: <J extends Json.Serializable>(\n\tkey: string,\n) => AtomEffect<J> = persistAtom(localStorage)(JSON)\n","/* â€ïž fp-ts */\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/* eslint-disable prefer-rest-params */\n/* eslint-disable @typescript-eslint/ban-types */\n\nexport function pipe<A>(a: A): A\nexport function pipe<A, B>(a: A, ab: (a: A) => B): B\nexport function pipe<A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C\nexport function pipe<A, B, C, D>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n): D\nexport function pipe<A, B, C, D, E>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n): E\nexport function pipe<A, B, C, D, E, F>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n): F\nexport function pipe<A, B, C, D, E, F, G>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n): G\nexport function pipe<A, B, C, D, E, F, G, H>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n): H\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n): I\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n): J\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n): K\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n): L\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n): M\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n): N\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n): O\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n): P\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n\tpq: (p: P) => Q,\n): Q\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n\tpq: (p: P) => Q,\n\tqr: (q: Q) => R,\n): R\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n\tpq: (p: P) => Q,\n\tqr: (q: Q) => R,\n\trs: (r: R) => S,\n): S\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n\tpq: (p: P) => Q,\n\tqr: (q: Q) => R,\n\trs: (r: R) => S,\n\tst: (s: S) => T,\n): T\nexport function pipe(\n\ta: unknown,\n\tab?: Function,\n\tbc?: Function,\n\tcd?: Function,\n\tde?: Function,\n\tef?: Function,\n\tfg?: Function,\n\tgh?: Function,\n\thi?: Function,\n): unknown {\n\t// biome-ignore lint/style/noArguments: <explanation>\n\tswitch (arguments.length) {\n\t\tcase 1:\n\t\t\treturn a\n\t\tcase 2:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn ab!(a)\n\t\tcase 3:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn bc!(ab!(a))\n\t\tcase 4:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn cd!(bc!(ab!(a)))\n\t\tcase 5:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn de!(cd!(bc!(ab!(a))))\n\t\tcase 6:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn ef!(de!(cd!(bc!(ab!(a)))))\n\t\tcase 7:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn fg!(ef!(de!(cd!(bc!(ab!(a))))))\n\t\tcase 8:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn gh!(fg!(ef!(de!(cd!(bc!(ab!(a)))))))\n\t\tcase 9:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn hi!(gh!(fg!(ef!(de!(cd!(bc!(ab!(a))))))))\n\t\tdefault: {\n\t\t\t// biome-ignore lint/style/noArguments: <explanation>\n\t\t\tlet ret = arguments[0]\n\t\t\t// biome-ignore lint/style/noArguments: <explanation>\n\t\t\tfor (let i = 1; i < arguments.length; i++) {\n\t\t\t\t// biome-ignore lint/style/noArguments: <explanation>\n\t\t\t\tret = arguments[i](ret)\n\t\t\t}\n\t\t\treturn ret\n\t\t}\n\t}\n}\n","import type { Refinement } from \"../refinement\"\n\nexport * from \"./curry\"\nexport * from \"./pipe\"\n\nexport type Æn = (...parameters: any[]) => any\n\nexport const doNothing = (): void => undefined\n\nexport const become =\n\t<T>(nextVersionOfThing: Modifier<T> | T) =>\n\t(originalThing: T | (() => T)): T =>\n\t\tnextVersionOfThing instanceof Function\n\t\t\t? nextVersionOfThing(\n\t\t\t\t\toriginalThing instanceof Function ? originalThing() : originalThing,\n\t\t\t )\n\t\t\t: nextVersionOfThing\n\nexport type Applicator<X, Y> = (next: Modifier<X> | X) => Modifier<Y>\nexport type Modifier<T> = (thing: T) => T\n\nexport type OneOrMany<T> = T | T[]\n\nexport const isModifier =\n\t<T>(validate: Refinement<unknown, T>) =>\n\t(sample: T): Refinement<unknown, Modifier<T>> => {\n\t\tconst sampleIsValid = validate(sample)\n\t\tif (!sampleIsValid) {\n\t\t\tthrow new Error(`Invalid test case: JSON.stringify(${sample})`)\n\t\t}\n\t\treturn (input: unknown): input is Modifier<T> => {\n\t\t\tif (typeof input !== `function`) return false\n\t\t\tconst testResult = input(sample)\n\t\t\treturn validate(testResult)\n\t\t}\n\t}\n\nexport const pass =\n\t<Params extends ReadonlyArray<any>, Out>(...params: Params) =>\n\t(fn: (...params: Params) => Out): Out =>\n\t\tfn(...params)\n\nexport const typeOf =\n\t<T>(input: unknown) =>\n\t(isType: Refinement<unknown, T>): boolean =>\n\t\tisType(input)\n\nexport const raiseError = (message: string): never => {\n\tthrow new Error(message)\n}\n\nexport type Encapsulate<T extends (...args: any[]) => any> = (\n\t...args: Parameters<T>\n) => void\n\nexport const attempt = (fn: () => void): boolean => {\n\ttry {\n\t\tfn()\n\t\treturn true\n\t} catch (_) {\n\t\treturn false\n\t}\n}\n\nexport const fallback = <T>(fn: () => T, fallbackValue: T): T => {\n\ttry {\n\t\treturn fn()\n\t} catch (_) {\n\t\treturn fallbackValue\n\t}\n}\n","export type VennCheck = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => boolean\n\nexport type VennTally = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => number\n\nexport const includesAll: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (!array.includes(item)) return false\n\t}\n\treturn true\n}\n\nexport const includesAny: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (array.includes(item)) return true\n\t}\n\treturn false\n}\n\nexport const excludesAll: VennCheck = (items) => (array) =>\n\t!includesAny(items)(array)\n\nexport const excludesAny: VennCheck = (items) => (array) =>\n\t!includesAll(items)(array)\n\nexport const comprises: VennCheck = (items) => (array) =>\n\tincludesAll(items)(array) && includesAll(array)(items)\n\nexport const overlaps: VennTally = (items) => (array) => {\n\tlet incidences = 0\n\tfor (const item of items) {\n\t\tif (array.includes(item)) incidences += 1\n\t}\n\treturn incidences\n}\n","import type { Refinement } from \"../refinement\"\n\nexport * from \"./match\"\nexport * from \"./venn\"\n\nexport const each =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T[] =>\n\t\tisType(input) ? [input] : Array.isArray(input) ? input.filter(isType) : []\n\nexport const lastOf = <T>(input: ReadonlyArray<T>): T | undefined =>\n\tinput[input.length - 1]\n\nexport const isArray =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T[] =>\n\t\tArray.isArray(input) && input.every((item) => isType(item))\n\nexport const at =\n\t<T>(index: number) =>\n\t(input: T[]): T | undefined =>\n\t\tinput.at(index)\n\nexport const content =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T | T[] =>\n\t\tisType(input) || isArray(isType)(input)\n\nexport const join =\n\t(separator?: string) =>\n\t(a: string[]): string =>\n\t\ta.join(separator)\n\nexport const map =\n\t<I, O>(f: (value: I, index: number, array: I[]) => O) =>\n\t(a: I[]): O[] =>\n\t\ta.map(f)\n\nexport const reduce =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduce(f, initial)\n\nexport const slice =\n\t(start: number, end?: number) =>\n\t<I>(a: I[]): I[] =>\n\t\ta.slice(start, end)\n\nexport const using =\n\t<I, O>(a: I[]) =>\n\t(f: (acc: O, value: I, index: number, array: I[]) => O) =>\n\t(initial: O): O =>\n\t\ta.reduce(f, initial)\n\nexport const reduceRight =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduceRight(f, initial)\n\nexport const reverse = <I>(a: I[]): I[] => a.reverse()\n\nexport const sort =\n\t<I>(a: I[]) =>\n\t(f?: (x: I, y: I) => number): I[] =>\n\t\tf ? a.sort(f) : a.sort()\n\nexport const sortBy =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(x) - f(y))\n\nexport const sortByDesc =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(y) - f(x))\n\nexport const every =\n\t<I>(f: (value: I, index: number, array: I[]) => boolean = Boolean) =>\n\t(a: I[]): boolean =>\n\t\ta.every(f)\n\nexport const allTrue = every((x: boolean) => x === true)\n\nexport const addTo =\n\t<I>(a: I[]) =>\n\t(x: I): I[] =>\n\t\ta.includes(x) ? a : [...a, x]\n\nexport const isEmptyArray = (input: unknown): input is [] =>\n\tArray.isArray(input) && input.length === 0\n\nexport const isOneOf =\n\t<T>(...args: ReadonlyArray<T>) =>\n\t(input: unknown): input is T =>\n\t\targs.includes(input as T)\n\nexport const filter =\n\t<I, O extends I>(f: (value: I, index: number, array: I[]) => value is O) =>\n\t(a: I[]): O[] =>\n\t\ta.filter(f)\n","import type { Refinement } from \"../refinement\"\n\nexport const isUndefined = (input: unknown): input is undefined =>\n\tinput === undefined\n\nexport const ifDefined = <T>(\n\tvalidate: Refinement<unknown, T>,\n): Refinement<unknown, T | undefined> =>\n\t((input) => isUndefined(input) || validate(input)) as Refinement<\n\t\tunknown,\n\t\tT | undefined\n\t>\n\nexport const isNull = (input: unknown): input is null => input === null\n\nexport const isNullish = (input: unknown): input is null | undefined =>\n\tisUndefined(input) || isNull(input)\n\nexport type NullSafeUnion<Base, Extension> = Extension extends null\n\t? Base\n\t: Base & Extension\n\nexport type NullSafeRest<MaybeArg, IfArg = MaybeArg> = MaybeArg extends null\n\t? [] | [undefined]\n\t: [IfArg]\n\nexport interface Discard {\n\treadonly _discard: unique symbol\n}\n\nexport const ifNullish =\n\t<X, Y>(alt: Y) =>\n\t(input: X): Exclude<X, null | undefined> | Y =>\n\t\t(input ?? alt) as Exclude<X, null | undefined> | Y\n","export const key =\n\t<T extends object>(k: keyof T) =>\n\t(obj: Exclude<object, null>): unknown =>\n\t\t(obj as Record<keyof any, any>)[k]\n\nexport const access = <V, T extends Record<keyof any, V>>(\n\tk: keyof any,\n): {\n\t(obj: T): T[keyof T] | undefined\n\tin: (obj: T) => T[keyof T] | undefined\n} =>\n\tObject.assign((obj: T) => obj[k as keyof T], {\n\t\tin: (obj: T) => obj[k as keyof T],\n\t})\n","export type Entries<K extends keyof any, V> = [key: K, value: V][]\n\nexport const recordToEntries = <K extends keyof any, V>(\n\tobj: Record<K, V>,\n): Entries<K, V> => Object.entries(obj) as Entries<K, V>\n\nexport const entriesToRecord = <K extends keyof any, V>(\n\tentries: Entries<K, V>,\n): Record<K, V> => Object.fromEntries(entries) as Record<K, V>\n","import { pipe } from \"../function\"\n\nimport { map } from \"../array\"\nimport { entriesToRecord, recordToEntries } from \"./entries\"\n\nexport const mapObject = <K extends keyof any, I, O>(\n\tobj: Record<K, I>,\n\tfn: (val: I, key: K) => O,\n): Record<K, O> =>\n\tpipe(\n\t\tobj,\n\t\trecordToEntries,\n\t\tmap(([key, val]) => [key, fn(val, key)] as const),\n\t\tentriesToRecord,\n\t)\n\nexport const mob =\n\t<K extends keyof any, I, O>(fn: (val: I, key: K) => O) =>\n\t(obj: Record<K, I>): Record<K, O> =>\n\t\tmapObject(obj, fn)\n","import { pipe } from \"../function\"\nimport type { Refinement } from \"../refinement\"\n\nimport { allTrue, every } from \"../array\"\nimport { pass } from \"../function\"\nimport { ifNullish } from \"../nullish\"\nimport { access } from \"./access\"\nimport { recordToEntries } from \"./entries\"\nimport { mob } from \"./mapObject\"\n\nexport type PlainObject = Record<keyof any, unknown>\nexport type EmptyObject = Record<keyof any, never>\n\nexport const isNonNullObject = (input: unknown): input is object =>\n\ttypeof input === `object` && input !== null\n\nexport const isPlainObject = (input: unknown): input is PlainObject =>\n\tisNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype\n\nexport const isEmptyObject = (input: unknown): input is EmptyObject =>\n\tisPlainObject(input) && Object.keys(input).length === 0\n\nexport const isRecord =\n\t<KEY extends keyof any, VAL>(\n\t\tisKey: Refinement<keyof any, KEY>,\n\t\tisValue: Refinement<unknown, VAL>,\n\t) =>\n\t(input: unknown): input is Record<KEY, VAL> =>\n\t\tisPlainObject(input) &&\n\t\tObject.entries(input).every(([k, v]) => isKey(k) && isValue(v))\n\nexport type HasPropertiesOptions = {\n\treadonly allowExtraProperties?: boolean\n}\nexport const hasProperties = <OBJ extends object>(\n\tisValue: {\n\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t},\n\toptions: HasPropertiesOptions = { allowExtraProperties: false },\n): Refinement<unknown, OBJ> => {\n\tconst name = `{${recordToEntries(\n\t\tisValue as Record<keyof any, Refinement<any, any>>,\n\t)\n\t\t.map(([k, v]) => String(k) + `:` + v.name)\n\t\t.join(`,`)}}`\n\n\tconst _ = {\n\t\t[name]: (input: unknown): input is OBJ =>\n\t\t\tisPlainObject(input) &&\n\t\t\tpipe(\n\t\t\t\tisValue,\n\t\t\t\tObject.entries,\n\t\t\t\tevery(([key, val]) => key in input || val(undefined)),\n\t\t\t) &&\n\t\t\tpipe(\n\t\t\t\tinput,\n\t\t\t\tmob((val, key) =>\n\t\t\t\t\tpipe(\n\t\t\t\t\t\tisValue,\n\t\t\t\t\t\taccess(key),\n\t\t\t\t\t\tifNullish(() => options.allowExtraProperties),\n\t\t\t\t\t\tpass(val),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tObject.values,\n\t\t\t\tallTrue,\n\t\t\t),\n\t}\n\treturn _[name]\n}\n\nexport const ALLOW_EXTENSION = { allowExtraProperties: true }\nexport const doesExtend = <OBJ extends object>(\n\tisValue: {\n\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t},\n): Refinement<unknown, OBJ> => hasProperties(isValue, ALLOW_EXTENSION)\n\nexport const DO_NOT_ALLOW_EXTENSION = { allowExtraProperties: false }\nexport const hasExactProperties = <OBJ extends object>(\n\tisValue: {\n\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t},\n): Refinement<unknown, OBJ> => hasProperties(isValue, DO_NOT_ALLOW_EXTENSION)\n","import { isPlainObject } from \"./refinement\"\n\n// if you found what you were looking for, return true and break\nexport type InspectionResult = Partial<{\n\tpathComplete: true\n\tjobComplete: true\n}>\nexport type InspectNode = (\n\tpath: string[],\n\tnode: unknown,\n) => InspectionResult | void\n\nexport const sprawl = (\n\ttree: Array<unknown> | object,\n\tinspector: InspectNode,\n): void => {\n\tconst walk = (path: string[], node: unknown): InspectionResult => {\n\t\tconst inspect = (path: string[], node: unknown): InspectionResult | null => {\n\t\t\t// console.log(parent)\n\t\t\tconst result = inspector(path, node)\n\t\t\tif (result) return result\n\t\t\treturn null\n\t\t}\n\t\tconst result = inspect(path, node)\n\t\tif (result?.jobComplete || result?.pathComplete) {\n\t\t\treturn result\n\t\t}\n\t\tconst childEntries = Array.isArray(node)\n\t\t\t? node.map((v, i) => [i, v])\n\t\t\t: isPlainObject(node)\n\t\t\t ? Object.entries(node)\n\t\t\t : []\n\t\tfor (const [k, v] of childEntries) {\n\t\t\tconst subResult = walk([...path, k], v)\n\t\t\tif (subResult?.jobComplete) {\n\t\t\t\treturn subResult\n\t\t\t}\n\t\t}\n\t\treturn {}\n\t}\n\twalk([], tree)\n}\n","import { pipe } from \"../function\"\nimport type { Refinement } from \"../refinement\"\n\nimport { filter, includesAny, reduce } from \"../array\"\nimport { isUndefined } from \"../nullish\"\nimport { deepMob } from \"./deepMob\"\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { isPlainObject } from \"./refinement\"\n\nexport * from \"./access\"\nexport * from \"./deepMob\"\nexport * from \"./entries\"\nexport * from \"./mapObject\"\nexport * from \"./modify\"\nexport * from \"./patch\"\nexport * from \"./refinement\"\nexport * from \"./sprawl\"\n\nexport const redact =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(obj: O): Omit<O, K> =>\n\t\treduce<K, O>((acc, key) => (delete acc[key], acc), obj)(args)\n\nexport type Redacted<Holder, RedactProp extends keyof any> = Omit<\n\t{\n\t\t[K in keyof Holder]: Holder[K] extends (infer Item)[]\n\t\t\t? Redacted<Item, RedactProp>[]\n\t\t\t: Redacted<Omit<Holder[K], RedactProp>, RedactProp>\n\t},\n\tRedactProp\n>\nexport const redactDeep =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(base: O): Redacted<O, K> =>\n\t\tdeepMob(base, (node, path) =>\n\t\t\tincludesAny(args)(path)\n\t\t\t\t? {\n\t\t\t\t\t\tmeta: { pathComplete: true },\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tdata: isPlainObject(node)\n\t\t\t\t\t\t\t? redact(...args)(node as Record<keyof any, any>)\n\t\t\t\t\t\t\t: node,\n\t\t\t\t },\n\t\t)\n\nexport const select =\n\t<Key extends keyof any>(...args: Key[]) =>\n\t<Obj extends object>(\n\t\tobj: Obj,\n\t): {\n\t\t// @ts-expect-error fuk u\n\t\t[K in keyof Pick<Obj, Key>]: any extends Pick<Obj, Key>[K]\n\t\t\t? undefined\n\t\t\t: // @ts-expect-error fuk u\n\t\t\t Pick<Obj, Key>[K]\n\t} =>\n\t\t// @ts-expect-error fuk u ts\n\t\treduce<Key, Pick<Obj, Key>>(\n\t\t\t// @ts-expect-error i will fite u\n\t\t\t(acc, key) => (key in obj ? (acc[key] = obj[key as keyof Obj]) : acc, acc),\n\t\t\t// @ts-expect-error fuk u\n\t\t\t{} as Pick<Obj, Key>,\n\t\t)(args)\n\nexport const treeShake =\n\t(shouldDiscard: (val: unknown, key: keyof any) => boolean = isUndefined) =>\n\t<T extends object>(\n\t\tobj: T,\n\t): T extends Record<keyof any, unknown> ? T : Partial<T> => {\n\t\tconst newObj = {} as T\n\t\tconst entries = Object.entries(obj) as [keyof T, any][]\n\t\tfor (const [key, val] of entries) {\n\t\t\tif (!shouldDiscard(val, key)) {\n\t\t\t\tnewObj[key] = val\n\t\t\t}\n\t\t}\n\t\treturn newObj as T extends Record<keyof any, unknown> ? T : Partial<T>\n\t}\n\nexport type KeysExtending<T, V> = keyof {\n\t[K in keyof T]: T[K] extends V ? K : never\n}\n\nconst a: never | null = null\n\nexport const filterProperties =\n\t<DiscardVal, DiscardKey extends keyof any>(\n\t\tshouldDiscardVal: Refinement<unknown, DiscardVal>,\n\t\tshouldDiscardKey: Refinement<unknown, DiscardKey>,\n\t) =>\n\t<P extends Record<keyof any, any>>(\n\t\tprops: P,\n\t): DiscardVal extends never\n\t\t? DiscardKey extends never\n\t\t\t? P\n\t\t\t: Omit<P, DiscardKey>\n\t\t: Omit<P, DiscardKey | KeysExtending<P, DiscardVal>> =>\n\t\t// @ts-expect-error oh well\n\t\tpipe(\n\t\t\tprops,\n\t\t\trecordToEntries,\n\t\t\tfilter(\n\t\t\t\t(\n\t\t\t\t\tentry,\n\t\t\t\t): entry is [\n\t\t\t\t\tExclude<keyof P, DiscardKey>,\n\t\t\t\t\tExclude<P[keyof P], DiscardVal>,\n\t\t\t\t] => !shouldDiscardKey(entry[0]) || !shouldDiscardVal(entry[1]),\n\t\t\t),\n\t\t\tentriesToRecord,\n\t\t)\n\nexport const delve = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n): Error | { found: unknown } => {\n\tconst found = path.reduce((acc, key) => acc?.[key], obj)\n\treturn found === undefined ? new Error(`Not found`) : { found }\n}\n\nexport const tweak = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n\tvalue: unknown,\n): void =>\n\tpath.reduce((acc, key, i) => {\n\t\tif (i === path.length - 1) {\n\t\t\tacc[key] = value\n\t\t}\n\t\tif (acc[key] === undefined) {\n\t\t\tacc[key] = typeof key === `number` ? [] : {}\n\t\t}\n\t\treturn acc[key]\n\t}, obj)\n\nexport type RequireAtLeastOne<T> = {\n\t[K in keyof T]-?: Partial<Pick<T, Exclude<keyof T, K>>> & Required<Pick<T, K>>\n}[keyof T]\n\nexport type RequireExactlyOne<T> = {\n\t[K in keyof T]-?: Required<Pick<T, K>>\n}[keyof T]\n","import type { Refinement } from \"../refinement\"\n\nimport { isPlainObject } from \"../object\"\nimport type { ClassSignature } from \"./is-class\"\n\nexport type RefinementStrategy = ClassSignature | Refinement<unknown, any>\n\nexport type Supported<Refine extends RefinementStrategy> =\n\tRefine extends Refinement<unknown, infer T>\n\t\t? T\n\t\t: Refine extends ClassSignature\n\t\t ? InstanceType<Refine>\n\t\t : never\n\nexport type RefinementSupport = Record<string, RefinementStrategy>\n\nexport class Refinery<SupportedTypes extends RefinementSupport> {\n\tpublic supported: SupportedTypes\n\n\tpublic constructor(supported: SupportedTypes) {\n\t\tthis.supported = supported\n\t}\n\n\tpublic refine(input: unknown):\n\t\t| {\n\t\t\t\t[K in keyof SupportedTypes]: {\n\t\t\t\t\ttype: K\n\t\t\t\t\tdata: Supported<SupportedTypes[K]>\n\t\t\t\t}\n\t\t }[keyof SupportedTypes]\n\t\t| null {\n\t\tfor (const [key, refiner] of Object.entries(this.supported)) {\n\t\t\ttry {\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error that's the point\n\t\t\t\t\trefiner(input) === true &&\n\t\t\t\t\trefiner !== Boolean\n\t\t\t\t) {\n\t\t\t\t\treturn { type: key, data: input } as any\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\ttry {\n\t\t\t\t\tif (input instanceof refiner) {\n\t\t\t\t\t\treturn { type: key, data: input } as any\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {}\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n\nconst jsonRefinery = new Refinery({\n\tnumber: (input: unknown): input is number => typeof input === `number`,\n\tstring: (input: unknown): input is string => typeof input === `string`,\n\tboolean: (input: unknown): input is boolean => typeof input === `boolean`,\n\tobject: isPlainObject,\n\tarray: (input: unknown): input is unknown[] => Array.isArray(input),\n\tnull: (input: unknown): input is null => input === null,\n})\n\nexport const discoverType = (input: unknown): string => {\n\tif (input === undefined) {\n\t\treturn `undefined`\n\t}\n\tconst refined = jsonRefinery.refine(input)\n\tif (refined) {\n\t\treturn refined.type\n\t}\n\treturn Object.getPrototypeOf(input).constructor.name\n}\n","import { sprawl } from \"../object\"\nimport type { Refinery, Supported } from \"../refinement/refinery\"\nimport { discoverType } from \"../refinement/refinery\"\n\nexport function diffNumber(a: number, b: number): Delta {\n\tconst sign = a < b ? `+` : `-`\n\treturn {\n\t\tsummary: `${sign}${Math.abs(a - b)} (${a} â ${b})`,\n\t}\n}\n\nexport function diffString(a: string, b: string): Delta {\n\tconst sign = a.length < b.length ? `+` : `-`\n\treturn {\n\t\tsummary: `${sign}${Math.abs(a.length - b.length)} (\"${a}\" â \"${b}\")`,\n\t}\n}\n\nexport function diffBoolean(a: boolean, b: boolean): Delta {\n\treturn {\n\t\tsummary: `${a} â ${b}`,\n\t}\n}\n\nexport function diffObject(\n\ta: Record<string, unknown>,\n\tb: Record<string, unknown>,\n\trecurse: Differ<any, any>[`diff`],\n): Delta {\n\tlet summary = ``\n\tconst added: Delta[`added`] = []\n\tconst removed: Delta[`removed`] = []\n\tconst changed: Delta[`changed`] = []\n\n\tsprawl(a, (path, nodeA) => {\n\t\tlet key: string\n\t\tfor (key of path) {\n\t\t\tconst nodeB = b[key]\n\t\t\tif (nodeB === undefined) {\n\t\t\t\tremoved.push([key, JSON.stringify(nodeA)])\n\t\t\t} else {\n\t\t\t\tconst delta = recurse(nodeA, nodeB)\n\t\t\t\tif (delta.summary !== `No Change`) {\n\t\t\t\t\tchanged.push([key, delta])\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\tsprawl(b, (path, nodeB) => {\n\t\tlet key: string\n\t\tfor (key of path) {\n\t\t\tconst nodeA = a[key]\n\t\t\tif (nodeA === undefined) {\n\t\t\t\tadded.push([key, JSON.stringify(nodeB)])\n\t\t\t}\n\t\t}\n\t})\n\n\tsummary = `ïœ${changed.length} ïŒ${added.length} ïŒ${removed.length}`\n\n\treturn {\n\t\tsummary,\n\t\tadded,\n\t\tremoved,\n\t\tchanged,\n\t}\n}\n\nexport function diffArray(\n\ta: unknown[],\n\tb: unknown[],\n\trecurse: Differ<any, any>[`diff`],\n): Delta {\n\treturn diffObject(a as any, b as any, recurse)\n}\n\ntype Delta = {\n\tsummary: string\n\tadded?: [path: string, addedStringifiedValue: string][]\n\tremoved?: [path: string, removedStringifiedValue: string][]\n\tchanged?: [path: string, delta: Delta][]\n}\n\ntype Diff<T> = (a: T, b: T) => Delta\ntype DiffTree<T> = (a: T, b: T, recurse: Differ<any, any>[`diff`]) => Delta\n\nexport class Differ<\n\tLeaf extends Record<string, any>,\n\tTree extends Record<string, any>,\n> {\n\tpublic leafRefinery: Refinery<Leaf>\n\tpublic treeRefinery: Refinery<Tree>\n\tpublic leafDiffers: { [KL in keyof Leaf]: Diff<Supported<Leaf[KL]>> }\n\tpublic treeDiffers: { [KT in keyof Tree]: DiffTree<Supported<Tree[KT]>> }\n\n\tpublic constructor(\n\t\tleafRefinery: Refinery<Leaf>,\n\t\ttreeRefinery: Refinery<Tree>,\n\t\tdiffFunctions: {\n\t\t\t[KT in keyof Tree]: DiffTree<Supported<Tree[KT]>>\n\t\t} & { [KL in keyof Leaf]: Diff<Supported<Leaf[KL]>> },\n\t) {\n\t\tthis.leafRefinery = leafRefinery\n\t\tthis.treeRefinery = treeRefinery\n\t\tthis.leafDiffers = {} as any\n\t\tthis.treeDiffers = {} as any\n\t\tfor (const key of Object.keys(leafRefinery.supported)) {\n\t\t\tconst diffFunction = diffFunctions[key]\n\t\t\tthis.leafDiffers[key as keyof Leaf] = diffFunction\n\t\t}\n\t\tfor (const key of Object.keys(treeRefinery.supported)) {\n\t\t\tconst diffFunction = diffFunctions[key]\n\t\t\tthis.treeDiffers[key as keyof Tree] = diffFunction\n\t\t}\n\t}\n\n\tpublic diff(a: unknown, b: unknown): Delta {\n\t\tif (a === b) {\n\t\t\treturn { summary: `No Change` }\n\t\t}\n\t\ttry {\n\t\t\tif (JSON.stringify(a) === JSON.stringify(b)) {\n\t\t\t\treturn { summary: `No Change` }\n\t\t\t}\n\t\t} catch (thrown) {\n\t\t\tconsole.error(`Error stringifying`, a, b)\n\t\t}\n\n\t\tconst aRefined = this.leafRefinery.refine(a) ?? this.treeRefinery.refine(a)\n\t\tconst bRefined = this.leafRefinery.refine(b) ?? this.treeRefinery.refine(b)\n\n\t\t// console.log({ leaf: this.leafRefinery, tree: this.treeRefinery })\n\t\t// console.log({ a, b })\n\t\t// console.log({ aRefined, bRefined })\n\n\t\tif (aRefined !== null && bRefined !== null) {\n\t\t\tif (aRefined.type === bRefined.type) {\n\t\t\t\tif (aRefined.type in this.leafDiffers) {\n\t\t\t\t\tconst delta = this.leafDiffers[aRefined.type](\n\t\t\t\t\t\taRefined.data,\n\t\t\t\t\t\tbRefined.data,\n\t\t\t\t\t)\n\t\t\t\t\treturn delta\n\t\t\t\t}\n\t\t\t\tif (aRefined.type in this.treeDiffers) {\n\t\t\t\t\tconst delta = this.treeDiffers[aRefined.type](\n\t\t\t\t\t\taRefined.data,\n\t\t\t\t\t\tbRefined.data,\n\t\t\t\t\t\t(x, y) => this.diff(x, y),\n\t\t\t\t\t)\n\t\t\t\t\treturn delta\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst typeA = discoverType(a)\n\t\tconst typeB = discoverType(b)\n\t\tif (typeA === typeB) {\n\t\t\treturn {\n\t\t\t\tsummary: `${typeA} â ${typeB}`,\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tsummary: `Type change: ${typeA} â ${typeB}`,\n\t\t}\n\t}\n}\n","import { useI, useO } from \"atom.io/react\"\nimport { LayoutGroup, motion, spring } from \"framer-motion\"\nimport { useRef } from \"react\"\n\nimport {\n\tatomIndex,\n\tdevtoolsAreOpenState,\n\tdevtoolsViewOptionsState,\n\tdevtoolsViewSelectionState,\n\tselectorIndex,\n} from \".\"\nimport { StateIndex } from \"./StateIndex\"\nimport { TimelineIndex } from \"./TimelineIndex\"\nimport { TransactionIndex } from \"./TransactionIndex\"\n\nimport \"./devtools.scss\"\n\nexport const AtomIODevtools = (): JSX.Element => {\n\tconst constraintsRef = useRef(null)\n\n\tconst setDevtoolsAreOpen = useI(devtoolsAreOpenState)\n\tconst devtoolsAreOpen = useO(devtoolsAreOpenState)\n\tconst setDevtoolsView = useI(devtoolsViewSelectionState)\n\tconst devtoolsView = useO(devtoolsViewSelectionState)\n\tconst devtoolsViewOptions = useO(devtoolsViewOptionsState)\n\n\tconst mouseHasMoved = useRef(false)\n\n\treturn (\n\t\t<>\n\t\t\t<motion.span\n\t\t\t\tref={constraintsRef}\n\t\t\t\tclassName=\"atom_io_devtools_zone\"\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: `fixed`,\n\t\t\t\t\ttop: 0,\n\t\t\t\t\tleft: 0,\n\t\t\t\t\tright: 0,\n\t\t\t\t\tbottom: 0,\n\t\t\t\t\tpointerEvents: `none`,\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<motion.main\n\t\t\t\tdrag\n\t\t\t\tdragConstraints={constraintsRef}\n\t\t\t\tclassName=\"atom_io_devtools\"\n\t\t\t\ttransition={spring}\n\t\t\t\tstyle={\n\t\t\t\t\tdevtoolsAreOpen\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tbackgroundColor: `#0000`,\n\t\t\t\t\t\t\t\tborderColor: `#0000`,\n\t\t\t\t\t\t\t\tmaxHeight: 28,\n\t\t\t\t\t\t\t\tmaxWidth: 33,\n\t\t\t\t\t\t }\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{devtoolsAreOpen ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<motion.header>\n\t\t\t\t\t\t\t<h1>atom.io</h1>\n\t\t\t\t\t\t\t<nav>\n\t\t\t\t\t\t\t\t{devtoolsViewOptions.map((viewOption) => (\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\tkey={viewOption}\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\tclassName={viewOption === devtoolsView ? `active` : ``}\n\t\t\t\t\t\t\t\t\t\tonClick={() => setDevtoolsView(viewOption)}\n\t\t\t\t\t\t\t\t\t\tdisabled={viewOption === devtoolsView}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{viewOption}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</nav>\n\t\t\t\t\t\t</motion.header>\n\t\t\t\t\t\t<motion.main>\n\t\t\t\t\t\t\t<LayoutGroup>\n\t\t\t\t\t\t\t\t{devtoolsView === `atoms` ? (\n\t\t\t\t\t\t\t\t\t<StateIndex tokenIndex={atomIndex} />\n\t\t\t\t\t\t\t\t) : devtoolsView === `selectors` ? (\n\t\t\t\t\t\t\t\t\t<StateIndex tokenIndex={selectorIndex} />\n\t\t\t\t\t\t\t\t) : devtoolsView === `transactions` ? (\n\t\t\t\t\t\t\t\t\t<TransactionIndex />\n\t\t\t\t\t\t\t\t) : devtoolsView === `timelines` ? (\n\t\t\t\t\t\t\t\t\t<TimelineIndex />\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t</LayoutGroup>\n\t\t\t\t\t\t</motion.main>\n\t\t\t\t\t</>\n\t\t\t\t) : null}\n\t\t\t\t<footer>\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonMouseDown={() => (mouseHasMoved.current = false)}\n\t\t\t\t\t\tonMouseMove={() => (mouseHasMoved.current = true)}\n\t\t\t\t\t\tonMouseUp={() => {\n\t\t\t\t\t\t\tif (!mouseHasMoved.current) {\n\t\t\t\t\t\t\t\tsetDevtoolsAreOpen((open) => !open)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\tðâðš\n\t\t\t\t\t</button>\n\t\t\t\t</footer>\n\t\t\t</motion.main>\n\t\t</>\n\t)\n}\n","import type { AtomToken, ReadonlySelectorToken, SelectorToken } from \"atom.io\"\nimport { getState, selectorFamily } from \"atom.io\"\nimport type { FamilyNode, StateTokenIndex } from \"atom.io/introspection\"\nimport { useI, useO } from \"atom.io/react\"\nimport type { FC } from \"react\"\n\nimport { recordToEntries } from \"~/packages/anvl/src/object\"\nimport {\n\tisJson,\n\trefineJsonType,\n} from \"~/packages/anvl/src/refinement/refine-json\"\n\nimport { findViewIsOpenState, primitiveRefinery } from \".\"\nimport { button } from \"./Button\"\nimport { StoreEditor } from \"./StateEditor\"\n\nconst findStateTypeState = selectorFamily<string, { key: string }>({\n\tkey: `ðâðš State Type`,\n\tget:\n\t\t(token) =>\n\t\t({ get }) => {\n\t\t\tlet state: unknown\n\t\t\ttry {\n\t\t\t\tstate = get(token as any)\n\t\t\t} catch (error) {\n\t\t\t\treturn `error`\n\t\t\t}\n\t\t\tif (state === undefined) return `undefined`\n\t\t\tif (isJson(state)) return refineJsonType(state).type\n\t\t\treturn Object.getPrototypeOf(state).constructor.name\n\t\t},\n})\n\nexport const StateIndexLeafNode: FC<{\n\tnode:\n\t\t| AtomToken<unknown>\n\t\t| ReadonlySelectorToken<unknown>\n\t\t| SelectorToken<unknown>\n\tisOpenState: AtomToken<boolean>\n\ttypeState: ReadonlySelectorToken<string>\n}> = ({ node, isOpenState, typeState }) => {\n\tconst setIsOpen = useI(isOpenState)\n\tconst isOpen = useO(isOpenState)\n\n\tconst state = useO(node)\n\tconst stateType = useO(typeState)\n\n\tconst isPrimitive = Boolean(primitiveRefinery.refine(state))\n\n\treturn (\n\t\t<>\n\t\t\t<header>\n\t\t\t\t<button.OpenClose\n\t\t\t\t\tisOpen={isOpen && !isPrimitive}\n\t\t\t\t\tsetIsOpen={setIsOpen}\n\t\t\t\t\tdisabled={isPrimitive}\n\t\t\t\t/>\n\t\t\t\t<label\n\t\t\t\t\tonClick={() => console.log(node, getState(node))}\n\t\t\t\t\tonKeyUp={() => console.log(node, getState(node))}\n\t\t\t\t>\n\t\t\t\t\t<h2>{node.family?.subKey ?? node.key}</h2>\n\t\t\t\t\t<span className=\"type detail\">({stateType})</span>\n\t\t\t\t</label>\n\t\t\t\t{isPrimitive ? <StoreEditor token={node} /> : null}\n\t\t\t</header>\n\t\t\t{isOpen && !isPrimitive ? (\n\t\t\t\t<main>\n\t\t\t\t\t<StoreEditor token={node} />\n\t\t\t\t</main>\n\t\t\t) : null}\n\t\t</>\n\t)\n}\nexport const StateIndexTreeNode: FC<{\n\tnode: FamilyNode<\n\t\tAtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>\n\t>\n\tisOpenState: AtomToken<boolean>\n}> = ({ node, isOpenState }) => {\n\tconst setIsOpen = useI(isOpenState)\n\tconst isOpen = useO(isOpenState)\n\tfor (const [key, childNode] of recordToEntries(node.familyMembers)) {\n\t\tfindViewIsOpenState(key)\n\t\tfindStateTypeState(childNode)\n\t}\n\treturn (\n\t\t<>\n\t\t\t<header>\n\t\t\t\t<button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />\n\t\t\t\t<label>\n\t\t\t\t\t<h2>{node.key}</h2>\n\t\t\t\t\t<span className=\"type detail\"> (family)</span>\n\t\t\t\t</label>\n\t\t\t</header>\n\t\t\t{isOpen\n\t\t\t\t? Object.entries(node.familyMembers).map(([key, childNode]) => (\n\t\t\t\t\t\t<StateIndexNode\n\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\tnode={childNode}\n\t\t\t\t\t\t\tisOpenState={findViewIsOpenState(childNode.key)}\n\t\t\t\t\t\t\ttypeState={findStateTypeState(childNode)}\n\t\t\t\t\t\t/>\n\t\t\t\t ))\n\t\t\t\t: null}\n\t\t</>\n\t)\n}\n\nexport const StateIndexNode: FC<{\n\tnode: StateTokenIndex<\n\t\tAtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>\n\t>[string]\n\tisOpenState: AtomToken<boolean>\n\ttypeState: ReadonlySelectorToken<string>\n}> = ({ node, isOpenState, typeState }) => {\n\tif (node.key.startsWith(`ðâðš`)) {\n\t\treturn null\n\t}\n\treturn (\n\t\t<section className=\"node state\">\n\t\t\t{`type` in node ? (\n\t\t\t\t<StateIndexLeafNode\n\t\t\t\t\tnode={node}\n\t\t\t\t\tisOpenState={isOpenState}\n\t\t\t\t\ttypeState={typeState}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<StateIndexTreeNode node={node} isOpenState={isOpenState} />\n\t\t\t)}\n\t\t</section>\n\t)\n}\n\nexport const StateIndex: FC<{\n\ttokenIndex: ReadonlySelectorToken<\n\t\tStateTokenIndex<\n\t\t\t| AtomToken<unknown>\n\t\t\t| ReadonlySelectorToken<unknown>\n\t\t\t| SelectorToken<unknown>\n\t\t>\n\t>\n}> = ({ tokenIndex }) => {\n\tconst tokenIds = useO(tokenIndex)\n\treturn (\n\t\t<article className=\"index state_index\">\n\t\t\t{Object.entries(tokenIds)\n\t\t\t\t.filter(([key]) => !key.startsWith(`ðâðš`))\n\t\t\t\t.sort()\n\t\t\t\t.map(([key, node]) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<StateIndexNode\n\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\tnode={node}\n\t\t\t\t\t\t\tisOpenState={findViewIsOpenState(node.key)}\n\t\t\t\t\t\t\ttypeState={findStateTypeState(node)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t</article>\n\t)\n}\n","export * from \"./json-interface\"\nimport type * as Json from \"./json\"\nexport { Json }\n\nexport const parseJson = <S extends Stringified<Json.Serializable>>(\n\tstr: S | string,\n): S extends Stringified<infer J> ? J : Json.Serializable => JSON.parse(str)\n\nexport type Stringified<J extends Json.Serializable> = string & { __json: J }\n\nexport const stringifyJson = <J extends Json.Serializable>(\n\tjson: J,\n): Stringified<J> => JSON.stringify(json) as Stringified<J>\n\nexport type Empty = Record<string, never>\n\nexport const JSON_TYPE_NAMES = [\n\t`array`,\n\t`boolean`,\n\t`null`,\n\t`number`,\n\t`object`,\n\t`string`,\n] as const\n\nexport type JsonTypeName = (typeof JSON_TYPE_NAMES)[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {\n\tarray: Json.Array\n\tboolean: boolean\n\tnull: null\n\tnumber: number\n\tobject: Json.Object\n\tstring: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n\tarray: [],\n\tboolean: false,\n\tnull: null,\n\tnumber: 0,\n\tobject: {},\n\tstring: ``,\n}\n","export type primitive = boolean | number | string | null\n\nexport const isString = (input: unknown): input is string => {\n\treturn typeof input === `string`\n}\n\nexport const isNumber = (input: unknown): input is number => {\n\treturn typeof input === `number`\n}\n\nexport const isBoolean = (input: unknown): input is boolean => {\n\treturn typeof input === `boolean`\n}\n\nexport const isNull = (input: unknown): input is null => {\n\treturn input === null\n}\n\nexport const isPrimitive = (input: unknown): input is primitive => {\n\treturn isString(input) || isNumber(input) || isBoolean(input) || isNull(input)\n}\n","import { attempt, raiseError } from \"../function\"\nimport { stringifyJson } from \"../json\"\nimport type { Json } from \"../json\"\nimport { isPlainObject } from \"../object\"\nimport { isBoolean, isNumber, isString } from \"../primitive\"\n\nconst JSON_PROTOTYPES = [\n\t`Array`,\n\t`Boolean`,\n\t`Number`,\n\t`Object`,\n\t`String`,\n] as const\n\nexport type RefinedJson =\n\t| { type: `array`; data: Json.Array }\n\t| { type: `boolean`; data: boolean }\n\t| { type: `null`; data: null }\n\t| { type: `number`; data: number }\n\t| { type: `object`; data: Json.Object }\n\t| { type: `string`; data: string }\n\nexport const refineJsonType = (data: Json.Serializable): RefinedJson =>\n\tdata === null\n\t\t? { type: `null`, data: null }\n\t\t: isBoolean(data)\n\t\t ? { type: `boolean`, data }\n\t\t : isNumber(data)\n\t\t\t ? { type: `number`, data }\n\t\t\t : isString(data)\n\t\t\t\t ? { type: `string`, data }\n\t\t\t\t : Array.isArray(data)\n\t\t\t\t\t ? { type: `array`, data }\n\t\t\t\t\t : isPlainObject(data)\n\t\t\t\t\t\t ? { type: `object`, data }\n\t\t\t\t\t\t : raiseError(\n\t\t\t\t\t\t\t\t\tdata === undefined\n\t\t\t\t\t\t\t\t\t\t? `undefined passed to refineJsonType. This is not valid JSON.`\n\t\t\t\t\t\t\t\t\t\t: `${stringifyJson(data)} with prototype \"${\n\t\t\t\t\t\t\t\t\t\t\t\tObject.getPrototypeOf(data).constructor.name\n\t\t\t\t\t\t\t\t\t\t }\" passed to refineJsonType. This is not valid JSON.`,\n\t\t\t\t\t\t\t )\nexport const isJson = (input: unknown): input is Json.Serializable => {\n\tif (input === null) return true\n\tif (input === undefined) return false\n\tconst prototype = Object.getPrototypeOf(input)?.constructor.name\n\tconst isJson = JSON_PROTOTYPES.includes(prototype)\n\treturn isJson\n}\n\nexport const isPlainJson = (input: unknown): input is Json.Serializable =>\n\tattempt(() => isJson(input) && refineJsonType(input))\n","import type { Modify } from \"atom.io/internal\"\nimport type { FC } from \"react\"\n\nexport const OpenClose: FC<{\n\tisOpen: boolean\n\tsetIsOpen: (next: Modify<boolean> | boolean) => void\n\tdisabled?: boolean\n}> = ({ isOpen, setIsOpen, disabled }) => {\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclassName={`carat ${isOpen ? `open` : `closed`}`}\n\t\t\tonClick={() => setIsOpen((isOpen) => !isOpen)}\n\t\t\tdisabled={disabled}\n\t\t>\n\t\t\tâ¶\n\t\t</button>\n\t)\n}\n\nexport const button = {\n\tOpenClose,\n}\n","import type { ReadonlySelectorToken, StateToken } from \"atom.io\"\nimport { useI, useO } from \"atom.io/react\"\nimport type { FC } from \"react\"\n\nimport { fallback } from \"~/packages/anvl/src/function\"\nimport { Join } from \"~/packages/anvl/src/join\"\nimport { isJson } from \"~/packages/anvl/src/refinement/refine-json\"\nimport { RelationEditor } from \"~/packages/hamr/src/react-data-designer\"\nimport { ElasticInput } from \"~/packages/hamr/src/react-elastic-input\"\nimport { JsonEditor } from \"~/packages/hamr/src/react-json-editor\"\n\nexport const StateEditor: FC<{\n\ttoken: StateToken<unknown>\n}> = ({ token }) => {\n\tconst set = useI(token)\n\tconst data = useO(token)\n\treturn isJson(data) ? (\n\t\t<JsonEditor data={data} set={set} schema={true} />\n\t) : data instanceof Join ? (\n\t\t<RelationEditor data={data} set={set} />\n\t) : (\n\t\t<div className=\"json_editor\">\n\t\t\t<ElasticInput\n\t\t\t\tvalue={\n\t\t\t\t\tdata instanceof Set\n\t\t\t\t\t\t? `Set { ${JSON.stringify([...data]).slice(1, -1)} }`\n\t\t\t\t\t\t: data instanceof Map\n\t\t\t\t\t\t ? `Map ` + JSON.stringify([...data])\n\t\t\t\t\t\t : Object.getPrototypeOf(data).constructor.name +\n\t\t\t\t\t\t\t ` ` +\n\t\t\t\t\t\t\t fallback(() => JSON.stringify(data), `?`)\n\t\t\t\t}\n\t\t\t\tdisabled={true}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n\nexport const ReadonlySelectorViewer: FC<{\n\ttoken: ReadonlySelectorToken<unknown>\n}> = ({ token }) => {\n\tconst data = useO(token)\n\treturn isJson(data) ? (\n\t\t<JsonEditor\n\t\t\tdata={data}\n\t\t\tset={() => null}\n\t\t\tschema={true}\n\t\t\tisReadonly={() => true}\n\t\t/>\n\t) : (\n\t\t<div className=\"json_editor\">\n\t\t\t<ElasticInput\n\t\t\t\tvalue={\n\t\t\t\t\tdata instanceof Set\n\t\t\t\t\t\t? `Set ` + JSON.stringify([...data])\n\t\t\t\t\t\t: data instanceof Map\n\t\t\t\t\t\t ? `Map ` + JSON.stringify([...data])\n\t\t\t\t\t\t : Object.getPrototypeOf(data).constructor.name +\n\t\t\t\t\t\t\t ` ` +\n\t\t\t\t\t\t\t JSON.stringify(data)\n\t\t\t\t}\n\t\t\t\tdisabled={true}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n\nexport const StoreEditor: FC<{\n\ttoken: ReadonlySelectorToken<unknown> | StateToken<unknown>\n}> = ({ token }) => {\n\tif (token.type === `readonly_selector`) {\n\t\treturn <ReadonlySelectorViewer token={token} />\n\t}\n\treturn <StateEditor token={token} />\n}\n","export const canExist = (_: unknown): _ is unknown => true\n","export const cannotExist = (_: unknown): _ is never => false\n","import { cannotExist } from \"./cannot-exist\"\nimport type { Refinement } from \"./refinement\"\n\nexport type ExtendsSome<A, B> = Refinement<unknown, A | B> & {\n\tor: <C>(isType: Refinement<unknown, C>) => ExtendsSome<unknown, A | B | C>\n}\nexport const mustSatisfyOneOfTheFollowing = <A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n} => {\n\tconst name = `(${refinements.map((r) => r?.name || `anon`).join(` | `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.some(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` | `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name ?? `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n\t} = Object.assign(_[name], {\n\t\tor: <B>(isTypeB: Refinement<unknown, B>): ExtendsSome<A, B> =>\n\t\t\tmustSatisfyOneOfTheFollowing(isTypeB, logging, [...refinements, isTypeB]),\n\t})\n\treturn checkTypes\n}\n\nexport const isUnion = mustSatisfyOneOfTheFollowing(cannotExist)\n","import { canExist } from \"./can-exist\"\nimport type { Refinement } from \"./refinement\"\n\nexport type ExtendsAll<A, B> = Refinement<unknown, A & B> & {\n\tand: <C>(isType: Refinement<unknown, C>) => ExtendsAll<A & B, C>\n}\nexport function mustSatisfyAllOfTheFollowing<A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n} {\n\tconst name = `(${refinements.map((r) => r?.name || `anon`).join(` & `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.every(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` & `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name || `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n\t} = Object.assign(_[name], {\n\t\tand: <B>(isTypeB: Refinement<unknown, B>): ExtendsAll<A, B> =>\n\t\t\tmustSatisfyAllOfTheFollowing(isTypeB, logging, [\n\t\t\t\t...refinements,\n\t\t\t\tisTypeB,\n\t\t\t]) as ExtendsAll<A, B>,\n\t})\n\treturn checkTypes\n}\n\nexport const isIntersection = mustSatisfyAllOfTheFollowing(canExist)\n","import type { Refinement } from \"../refinement\"\n\nexport * from \"./refined\"\nexport * from \"./refinery\"\nexport * from \"./refinement\"\n\nexport * from \"./can-exist\"\nexport * from \"./cannot-exist\"\n\nexport * from \"./is-class\"\nexport * from \"./is-union\"\nexport * from \"./is-intersection\"\n\nexport const isLiteral =\n\t<T extends boolean | number | string>(value: T): Refinement<unknown, T> =>\n\t(input: unknown): input is T =>\n\t\tinput === value\n\nexport const isWithin =\n\t<Options extends ReadonlyArray<any>>(args: Options) =>\n\t(input: unknown): input is Options[number] =>\n\t\targs.includes(input as Options[number])\n\nexport const ensure =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T => {\n\t\tif (!isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to be of type ${isType.name}`)\n\t\t}\n\t\treturn input as T\n\t}\n\nexport const ensureAgainst =\n\t<A, B>(isType: Refinement<unknown, A>) =>\n\t(input: A | B): Exclude<A | B, A> => {\n\t\tif (isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to not be of type ${isType.name}`)\n\t\t}\n\t\treturn input as Exclude<A | B, A>\n\t}\n","import { isArray } from \"../array\"\nimport type { Json } from \"../json\"\nimport { hasExactProperties, isRecord } from \"../object/refinement\"\nimport { isString } from \"../primitive\"\nimport { isLiteral } from \"../refinement\"\n\nexport const RELATION_TYPES = [`1:1`, `1:n`, `n:n`] as const\n\nexport type RelationType = (typeof RELATION_TYPES)[number]\n\nexport const isRelationType = (x: unknown): x is RelationType =>\n\tRELATION_TYPES.includes(x as RelationType)\n\nexport type RelationData<\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tcontents: Json.Object<string, CONTENT>\n\trelations: Json.Object<string, string[]>\n\trelationType: RelationType\n\ta: A\n\tb: B\n}\n\nexport const EMPTY_RELATION_DATA: RelationData = {\n\tcontents: {},\n\trelations: {},\n\trelationType: `n:n`,\n\ta: `from`,\n\tb: `to`,\n}\n\nexport type IsRelationDataOptions<\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tfrom?: A\n\tto?: B\n\tisContent?: (json: Json.Serializable) => json is CONTENT\n}\nexport const isRelationData =\n\t<\n\t\tCONTENT extends Json.Object | null = null,\n\t\tA extends string = `from`,\n\t\tB extends string = `to`,\n\t>({\n\t\tfrom: a = `from` as A,\n\t\tto: b = `to` as B,\n\t\tisContent,\n\t}: IsRelationDataOptions<CONTENT, A, B> = {}) =>\n\t(input: unknown): input is RelationData<CONTENT, A, B> => {\n\t\treturn hasExactProperties<RelationData<CONTENT, A, B>>({\n\t\t\tcontents: isContent\n\t\t\t\t? isRecord(isString, isContent)\n\t\t\t\t: hasExactProperties({}),\n\t\t\trelations: isRecord(isString, isArray(isString)),\n\t\t\trelationType: isRelationType,\n\t\t\ta: isLiteral(a),\n\t\t\tb: isLiteral(b),\n\t\t})(input)\n\t}\n","import type { Json } from \"../json\"\nimport type { RelationData } from \"./core-relation-data\"\n\nexport const getRelatedIds = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string[] => relationMap.relations[id] ?? []\n\nexport const getRelatedId = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string | undefined => {\n\tconst relations = getRelatedIds(relationMap, id)\n\tif (relations.length > 1) {\n\t\tconsole.warn(\n\t\t\t`entry with id ${id} was not expected to have multiple relations`,\n\t\t)\n\t}\n\treturn relations[0]\n}\n","import { Join } from \".\"\nimport type { Json, JsonInterface } from \"../json\"\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\n\nexport const makeJsonInterface = <\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n>(\n\tjoin: Join<CONTENT, A, B>,\n\t...params: CONTENT extends null ? [] : [(x: Json.Serializable) => x is CONTENT]\n): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\tconst isContent = params[0] as (x: Json.Serializable) => x is CONTENT\n\tconst { a, b } = join\n\tconst options: IsRelationDataOptions<CONTENT, A, B> = {\n\t\tfrom: a,\n\t\tto: b,\n\t\tisContent,\n\t}\n\treturn {\n\t\ttoJson: (join) => join.toJSON(),\n\t\tfromJson: (json) => Join.fromJSON(json, options),\n\t}\n}\n","import type { Json } from \"../json\"\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getContent } from \"./relation-contents\"\n\nexport const getRelationEntries = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n): [string, CONTENT][] =>\n\tgetRelatedIds(relationMap, idA).map((idB) => [\n\t\tidB,\n\t\tgetContent(relationMap, idA, idB) as CONTENT,\n\t])\n\nexport const getRelationRecord = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): Record<string, CONTENT> =>\n\tObject.fromEntries(getRelationEntries(relationMap, id))\n","export const split =\n\t(separator: string) =>\n\t(str: string): string[] =>\n\t\tstr.split(separator)\n","import { isString } from \"../primitive\"\n\nimport { isEmptyArray, isOneOf, map } from \"../array\"\nimport { comprises } from \"../array/venn\"\nimport { pipe } from \"../function\"\nimport type { Json } from \"../json\"\nimport { treeShake as removeProperties } from \"../object\"\nimport { entriesToRecord, recordToEntries } from \"../object/entries\"\nimport { split } from \"../string/split\"\nimport type { RelationData } from \"./core-relation-data\"\n\nexport const removeSpecific = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): RelationData<CONTENT, A, B> => {\n\tconst isIdForRemoval = isOneOf(idA, idB)\n\treturn {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\tisIdForRemoval(id)\n\t\t\t\t\t? relations.filter((relation) => !isIdForRemoval(relation))\n\t\t\t\t\t: relations,\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties(isEmptyArray),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) =>\n\t\t\t\t\tisString(key) && pipe(key, split(`/`), comprises([idA, idB])),\n\t\t\t),\n\t\t),\n\t}\n}\n\nexport const removeAll = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidToRemove: string,\n): RelationData<CONTENT, A, B> => {\n\tconst next: RelationData<CONTENT, A, B> = {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\trelations.filter((relation) => relation !== idToRemove),\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties((val, key) => key === idToRemove || isEmptyArray(val)),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) => isString(key) && key.split(`/`).includes(idToRemove),\n\t\t\t),\n\t\t),\n\t}\n\treturn next\n}\n\nexport const removeRelation = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Partial<Record<A | B, string>>,\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (relation as { [K in A | B]: string })[\n\t\tcurrent.a\n\t]\n\tconst idB: string | undefined = (relation as { [Key in A | B]: string })[\n\t\tcurrent.b\n\t]\n\treturn idB ? removeSpecific(current, idA, idB) : removeAll(current, idA)\n}\n","import { addTo, isEmptyArray } from \"../array\"\nimport type { Json } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\nimport { treeShake as removeProperties } from \"../object\"\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedId } from \"./get-related-ids\"\nimport { setContent } from \"./relation-contents\"\n\nexport const setManyToMany = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst next = {\n\t\t...map,\n\t\trelations: {\n\t\t\t...map.relations,\n\t\t\t[idA]: addTo(map.relations[idA] ?? [])(idB),\n\t\t\t[idB]: addTo(map.relations[idB] ?? [])(idA),\n\t\t},\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, idA, idB, content) : next\n}\n\nconst removeEmpties = removeProperties(isEmptyArray)\n\nexport const set1ToMany = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tleaderId: string,\n\tfollowerId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst relations = { ...current.relations }\n\tconst prevLeaderId = getRelatedId(current, followerId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...relations,\n\t\t\t...(prevLeaderId &&\n\t\t\t\tprevLeaderId !== leaderId && {\n\t\t\t\t\t[prevLeaderId]: relations[prevLeaderId].filter(\n\t\t\t\t\t\t(id) => id !== followerId,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t[followerId]: [leaderId],\n\t\t\t[leaderId]: addTo(relations[leaderId] ?? [])(followerId),\n\t\t}),\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, leaderId, followerId, content) : next\n}\n\nexport const set1To1 = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\twifeId: string,\n\thusbandId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst prevWifeId = getRelatedId(current, husbandId)\n\tconst prevHusbandId = getRelatedId(current, wifeId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...current.relations,\n\t\t\t...(prevWifeId && { [prevWifeId]: [] }),\n\t\t\t...(prevHusbandId && { [prevHusbandId]: [] }),\n\t\t\t[wifeId]: [husbandId],\n\t\t\t[husbandId]: [wifeId],\n\t\t}),\n\t}\n\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, wifeId, husbandId, content) : next\n}\n\nexport const setRelationWithContent = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Record<A | B, string>,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst { [current.a]: idA, [current.b]: idB } = relation\n\tswitch (current.relationType) {\n\t\tcase `1:1`:\n\t\t\treturn set1To1(current, idA, idB, ...rest)\n\t\tcase `1:n`:\n\t\t\treturn set1ToMany(current, idA, idB, ...rest)\n\t\tcase `n:n`:\n\t\t\treturn setManyToMany(current, idA, idB, ...rest)\n\t}\n}\n","import { pipe } from \"../function\"\nimport type { Identified } from \"../id/identified\"\nimport type { Json } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\nimport { isEmptyObject } from \"../object/refinement\"\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getRelationEntries } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\n\nexport const makeContentId = (idA: string, idB: string): string =>\n\t[idA, idB].sort().join(`/`)\n\nexport const getContent = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): CONTENT | undefined => relationMap.contents[makeContentId(idA, idB)]\n\nexport const setContent = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\tcontent: CONTENT,\n): RelationData<CONTENT, A, B> => ({\n\t...map,\n\tcontents: {\n\t\t...map.contents,\n\t\t[makeContentId(idA, idB)]: content,\n\t},\n})\n\nexport const getRelations = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): (CONTENT extends null ? Identified : CONTENT & Identified)[] =>\n\tgetRelationEntries(relationMap, id).map(\n\t\t([id, content]) =>\n\t\t\t({\n\t\t\t\tid,\n\t\t\t\t...content,\n\t\t\t}) as CONTENT extends null ? Identified : CONTENT & Identified,\n\t)\n\nexport const setRelations = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tsubject: { [from in A]: string } | { [to in B]: string },\n\trelations: (CONTENT extends null ? Identified : CONTENT & Identified)[],\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (subject as { [from in A]: string })[current.a]\n\tconst idB: string | undefined = (subject as { [to in B]: string })[current.b]\n\treturn pipe(\n\t\tcurrent,\n\t\t(relationData) => {\n\t\t\tconst relatedIds = getRelatedIds(current, idA)\n\t\t\tconst removedIds = relatedIds.filter(\n\t\t\t\t(id) => !relations.some((r) => r.id === id),\n\t\t\t)\n\t\t\tlet step = relationData\n\t\t\tfor (const id of removedIds) {\n\t\t\t\tconst remove = {\n\t\t\t\t\t[current.a]: idA ?? id,\n\t\t\t\t\t[current.b]: idB ?? id,\n\t\t\t\t} as Record<A | B, string>\n\t\t\t\tstep = removeRelation(step, remove)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tlet step = relationData\n\t\t\tfor (const { id, ...rest } of relations) {\n\t\t\t\tconst content = isEmptyObject(rest) ? undefined : rest\n\t\t\t\tstep = setRelationWithContent(\n\t\t\t\t\tstep,\n\t\t\t\t\t{ [current.a]: idA ?? id, [current.b]: idB ?? id } as Record<\n\t\t\t\t\t\tA | B,\n\t\t\t\t\t\tstring\n\t\t\t\t\t>,\n\t\t\t\t\t// @ts-expect-error hacky\n\t\t\t\t\tcontent as NullSafeRest<CONTENT>,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tconst newlyOrderedIds = relations.map((r) => r.id)\n\t\t\treturn {\n\t\t\t\t...relationData,\n\t\t\t\trelations: {\n\t\t\t\t\t...relationData.relations,\n\t\t\t\t\t[idA ?? idB]: newlyOrderedIds,\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t)\n}\n","import type { Identified } from \"../id\"\n\nimport type { Json, JsonInterface } from \"../json\"\nimport type { NullSafeRest, NullSafeUnion } from \"../nullish\"\nimport type { Refinement } from \"../refinement\"\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\nimport { EMPTY_RELATION_DATA, isRelationData } from \"./core-relation-data\"\nimport { getRelatedId, getRelatedIds } from \"./get-related-ids\"\nimport { makeJsonInterface } from \"./make-json-interface\"\nimport { getContent, getRelations, setRelations } from \"./relation-contents\"\nimport { getRelationEntries, getRelationRecord } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\n\nexport class Join<\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> implements RelationData<CONTENT, A, B>\n{\n\tpublic readonly relationType: `1:1` | `1:n` | `n:n`\n\tpublic readonly a: A = `from` as A\n\tpublic readonly b: B = `to` as B\n\tpublic readonly relations: Record<string, string[]>\n\tpublic readonly contents: Record<string, CONTENT>\n\tpublic constructor(json?: Partial<RelationData<CONTENT, A, B>>) {\n\t\tObject.assign(this, {\n\t\t\t...EMPTY_RELATION_DATA,\n\t\t\t...json,\n\t\t\tmakeJsonInterface: this.makeJsonInterface,\n\t\t})\n\t}\n\tpublic toJSON(): RelationData<CONTENT, A, B> {\n\t\treturn {\n\t\t\trelationType: this.relationType,\n\t\t\trelations: this.relations,\n\t\t\tcontents: this.contents,\n\t\t\ta: this.a,\n\t\t\tb: this.b,\n\t\t}\n\t}\n\tpublic static fromJSON<\n\t\tCONTENT extends Json.Object | null,\n\t\tA extends string,\n\t\tB extends string,\n\t>(\n\t\tjson: Json.Serializable,\n\t\toptions?: IsRelationDataOptions<CONTENT, A, B>,\n\t): Join<CONTENT, A, B> {\n\t\tconst isValid = isRelationData<CONTENT, A, B>(options)(json)\n\t\tif (isValid) {\n\t\t\treturn new Join<CONTENT, A, B>(json)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Saved JSON for this Join is invalid: ${JSON.stringify(json)}`,\n\t\t)\n\t}\n\n\tpublic from<AA extends string>(newA: AA): Join<CONTENT, AA, B> {\n\t\treturn new Join({ ...this, a: newA })\n\t}\n\n\tpublic to<BB extends string>(newB: BB): Join<CONTENT, A, BB> {\n\t\treturn new Join({ ...this, b: newB })\n\t}\n\n\tpublic makeJsonInterface = (\n\t\t...params: CONTENT extends null ? [] : [Refinement<unknown, CONTENT>]\n\t): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\t\treturn makeJsonInterface<CONTENT, A, B>(this, ...params)\n\t}\n\n\tpublic getRelatedId(id: string): string | undefined {\n\t\treturn getRelatedId(this, id)\n\t}\n\tpublic getRelatedIds(id: string): string[] {\n\t\treturn getRelatedIds(this, id)\n\t}\n\tpublic getContent(idA: string, idB: string): CONTENT | undefined {\n\t\treturn getContent(this, idA, idB)\n\t}\n\tpublic getRelationEntries(id: string): [string, CONTENT][] {\n\t\treturn getRelationEntries(this, id)\n\t}\n\tpublic getRelationRecord(id: string): Record<string, CONTENT> {\n\t\treturn getRelationRecord(this, id)\n\t}\n\tpublic getRelation(\n\t\tid: string,\n\t): NullSafeUnion<Identified, CONTENT> | undefined {\n\t\treturn getRelations(this, id)[0]\n\t}\n\tpublic getRelations(id: string): NullSafeUnion<Identified, CONTENT>[] {\n\t\treturn getRelations(this, id)\n\t}\n\tpublic setRelations(\n\t\tsubject: { [from in A]: string } | { [to in B]: string },\n\t\trelations: NullSafeUnion<Identified, CONTENT>[],\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelations(this, subject, relations))\n\t}\n\tpublic set(\n\t\trelation: { [key in A | B]: string },\n\t\t...rest: NullSafeRest<CONTENT>\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelationWithContent(this, relation, ...rest))\n\t}\n\tpublic remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B> {\n\t\treturn new Join(\n\t\t\tremoveRelation(this, relation as Partial<Record<A | B, string>>),\n\t\t)\n\t}\n}\n","import type { DetailedHTMLProps, InputHTMLAttributes } from \"react\"\nimport {\n\tforwardRef,\n\tuseImperativeHandle,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from \"react\"\n\nexport const ElasticInput = forwardRef<\n\tHTMLInputElement,\n\tDetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> & {\n\t\twidthPadding?: number\n\t}\n>(function ElasticInputFC(props, ref) {\n\tconst inputRef = useRef<HTMLInputElement>(null)\n\tconst spanRef = useRef<HTMLSpanElement>(null)\n\tconst [inputWidth, setInputWidth] = useState(`auto`)\n\n\tuseImperativeHandle<Partial<HTMLInputElement>, Partial<HTMLInputElement>>(\n\t\tref,\n\t\t() => ({\n\t\t\tfocus: () => {\n\t\t\t\tinputRef.current?.focus()\n\t\t\t},\n\t\t}),\n\t)\n\n\tconst extraWidth = props.type === `number` ? 15 : 0\n\n\tuseLayoutEffect(() => {\n\t\tif (spanRef.current) {\n\t\t\tsetInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`)\n\t\t\tconst interval = setInterval(() => {\n\t\t\t\tif (spanRef.current) {\n\t\t\t\t\tsetInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`)\n\t\t\t\t}\n\t\t\t}, 1000)\n\t\t\treturn () => clearInterval(interval)\n\t\t}\n\t}, [inputRef.current?.value, props.value])\n\n\treturn (\n\t\t<div style={{ display: `inline-block`, position: `relative` }}>\n\t\t\t<input\n\t\t\t\t{...props}\n\t\t\t\tref={inputRef}\n\t\t\t\tstyle={{\n\t\t\t\t\tpadding: 0,\n\t\t\t\t\tborderRadius: 0,\n\t\t\t\t\tborder: `none`,\n\t\t\t\t\tfontFamily: `inherit`,\n\t\t\t\t\tfontSize: `inherit`,\n\t\t\t\t\twidth: inputWidth,\n\t\t\t\t\t...props.style,\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<span\n\t\t\t\tref={spanRef}\n\t\t\t\tstyle={{\n\t\t\t\t\tpadding: props.style?.padding,\n\t\t\t\t\tposition: `absolute`,\n\t\t\t\t\tvisibility: `hidden`,\n\t\t\t\t\t// color: `red`,\n\t\t\t\t\twhiteSpace: `pre`,\n\t\t\t\t\tfontFamily: props.style?.fontFamily || `inherit`,\n\t\t\t\t\tfontSize: props.style?.fontSize || `inherit`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{props.value}\n\t\t\t</span>\n\t\t</div>\n\t)\n})\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC } from \"react\"\nimport { useId, useRef, useState } from \"react\"\n\nimport { clampInto } from \"~/packages/anvl/src/number\"\n\nimport { pipe } from \"~/packages/anvl/src/function\"\nimport { ElasticInput } from \".\"\n\nfunction round(value: number, decimalPlaces?: number): number {\n\tif (decimalPlaces === undefined) return value\n\tconst factor = 10 ** decimalPlaces\n\treturn Math.round(value * factor) / factor\n}\nfunction roundAndPad(value: number, decimalPlaces?: number): string {\n\tconst roundedValue = round(value, decimalPlaces)\n\tconst paddedString = roundedValue.toFixed(decimalPlaces)\n\treturn paddedString\n}\n\nexport const VALID_NON_NUMBERS = [``, `-`, `.`, `-.`] as const\nexport type ValidNonNumber = (typeof VALID_NON_NUMBERS)[number]\nexport const isValidNonNumber = (input: string): input is ValidNonNumber =>\n\tVALID_NON_NUMBERS.includes(input as ValidNonNumber)\nexport const VALID_NON_NUMBER_INTERPRETATIONS: Readonly<\n\tRecord<ValidNonNumber, number | null>\n> = {\n\t\"\": null,\n\t\"-\": 0,\n\t\".\": 0,\n\t\"-.\": 0,\n} as const\nexport type DecimalInProgress = `${number | ``}.${number}`\nexport const isDecimalInProgress = (input: string): input is DecimalInProgress =>\n\tinput === `0` || (!Number.isNaN(Number(input)) && input.includes(`.`))\n\nconst textToValue = (input: string, allowDecimal: boolean): number | null => {\n\tif (isValidNonNumber(input)) return VALID_NON_NUMBER_INTERPRETATIONS[input]\n\treturn allowDecimal ? parseFloat(input) : Math.round(parseFloat(input))\n}\n\nexport type NumberConstraints = {\n\tmax: number\n\tmin: number\n\tdecimalPlaces: number\n\tnullable: boolean\n}\nexport const DEFAULT_NUMBER_CONSTRAINTS: NumberConstraints = {\n\tmax: Infinity,\n\tmin: -Infinity,\n\tdecimalPlaces: 100,\n\tnullable: true,\n}\n\nconst initRefinery =\n\t<Constraints extends NumberConstraints>(\n\t\tconstraints: { [K in keyof Constraints]?: Constraints[K] | undefined },\n\t) =>\n\t(\n\t\tinput: number | null,\n\t): Constraints extends { nullable: true | undefined }\n\t\t? number | null\n\t\t: number => {\n\t\tif (input === null && constraints.nullable === true) {\n\t\t\treturn null as Constraints extends { nullable: true }\n\t\t\t\t? number | null\n\t\t\t\t: number\n\t\t}\n\t\tconst { max, min, decimalPlaces } = {\n\t\t\t...DEFAULT_NUMBER_CONSTRAINTS,\n\t\t\t...constraints,\n\t\t}\n\t\tconst constrained = pipe(input ?? 0, clampInto(min, max), (n) =>\n\t\t\tdecimalPlaces ? round(n, decimalPlaces) : n,\n\t\t)\n\t\treturn constrained\n\t}\n\nconst valueToText = (numericValue: number | null): string => {\n\tif (numericValue === null || numericValue === undefined) {\n\t\treturn ``\n\t}\n\treturn numericValue.toString()\n}\n\ntype NumberInputProps = Partial<NumberConstraints> & {\n\tautoSize?: boolean\n\tcustomCss?: SerializedStyles\n\tdisabled?: boolean\n\tid?: string\n\tlabel?: string\n\tname?: string\n\tonChange?: (e: React.ChangeEvent<HTMLInputElement>) => void\n\tonClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void\n\tplaceholder?: string\n\tset?: ((newValue: number | null) => void) | undefined\n\ttestId?: string\n\tvalue?: number | null\n}\n\nexport const NumberInput: FC<NumberInputProps> = ({\n\tautoSize = false,\n\tcustomCss,\n\tdecimalPlaces,\n\tdisabled = false,\n\tlabel,\n\tmax,\n\tmin,\n\tname,\n\tonChange,\n\tonClick,\n\tplaceholder = ``,\n\tset = () => null,\n\ttestId,\n\tvalue = null,\n}) => {\n\tconst id = useId()\n\tconst [temporaryEntry, setTemporaryEntry] = useState<\n\t\tDecimalInProgress | ValidNonNumber | null\n\t>(null)\n\tconst userHasMadeDeliberateChange = useRef<boolean>(false)\n\n\tconst refine = initRefinery({ max, min, decimalPlaces, nullable: true })\n\n\tconst allowDecimal = decimalPlaces === undefined || decimalPlaces > 0\n\n\tconst handleBlur = () => {\n\t\tif (userHasMadeDeliberateChange.current) {\n\t\t\tset(refine(value ?? null))\n\t\t\tsetTemporaryEntry(null)\n\t\t}\n\t\tuserHasMadeDeliberateChange.current = false\n\t}\n\n\tconst handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\tif (onChange) onChange(event)\n\t\tif (set === undefined) return\n\t\tuserHasMadeDeliberateChange.current = true\n\t\tconst input = event.target.value\n\t\tif (isValidNonNumber(input) || isDecimalInProgress(input)) {\n\t\t\tsetTemporaryEntry(input)\n\t\t\tconst textInterpretation = isDecimalInProgress(input)\n\t\t\t\t? input\n\t\t\t\t: min?.toString() ?? `0`\n\t\t\tconst newValue = textToValue(textInterpretation, allowDecimal)\n\t\t\tset(refine(newValue))\n\t\t\treturn\n\t\t}\n\t\tsetTemporaryEntry(null)\n\t\tconst inputIsNumeric =\n\t\t\t(!Number.isNaN(Number(input)) && !input.includes(` `)) ||\n\t\t\t(allowDecimal && input === `.`) ||\n\t\t\t(allowDecimal && input === `-.`) ||\n\t\t\tinput === `` ||\n\t\t\tinput === `-`\n\t\tconst numericValue = textToValue(input, allowDecimal)\n\n\t\tif (inputIsNumeric) {\n\t\t\tset(refine(numericValue))\n\t\t}\n\t}\n\n\tconst displayValue =\n\t\ttemporaryEntry ?? valueToText(value ? refine(value) : value)\n\n\treturn (\n\t\t<span css={customCss}>\n\t\t\t{label && <label htmlFor={id}>{label}</label>}\n\t\t\t{autoSize ? (\n\t\t\t\t<ElasticInput\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tvalue={displayValue}\n\t\t\t\t\tplaceholder={placeholder ?? `-`}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tonBlur={handleBlur}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tname={name ?? id}\n\t\t\t\t\tid={id}\n\t\t\t\t\tonClick={onClick}\n\t\t\t\t\tdata-testid={`number-input-${testId ?? id}`}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<input\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tvalue={displayValue}\n\t\t\t\t\tplaceholder={placeholder ?? `-`}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tonBlur={handleBlur}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tname={name ?? id}\n\t\t\t\t\tid={id}\n\t\t\t\t\tonClick={onClick}\n\t\t\t\t\tdata-testid={`number-input-${testId ?? id}`}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</span>\n\t)\n}\n","import type { Modifier } from \"../function\"\n\nexport const clampInto =\n\t(min: number, max: number): Modifier<number> =>\n\t(value) =>\n\t\tvalue < min ? min : value > max ? max : value\n","import type { Modifier } from \"../function\"\n\nexport const wrapInto =\n\t(min: number, max: number): Modifier<number> =>\n\t(value) =>\n\t\tvalue < min\n\t\t\t? max - ((min - value) % (max - min))\n\t\t\t: min + ((value - min) % (max - min))\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC } from \"react\"\n\nimport { ElasticInput } from \".\"\n\nexport type TextInputProps = {\n\tvalue: string\n\tset?: ((value: string) => void) | undefined\n\tlabel?: string\n\tplaceholder?: string\n\tcustomCss?: SerializedStyles\n\tautoSize?: boolean\n\treadOnly?: boolean\n}\n\nexport const TextInput: FC<TextInputProps> = ({\n\tvalue,\n\tset,\n\tlabel,\n\tplaceholder,\n\tcustomCss,\n\tautoSize = false,\n}) => {\n\treturn (\n\t\t<span css={customCss}>\n\t\t\t<label>{label}</label>\n\t\t\t{autoSize ? (\n\t\t\t\t<ElasticInput\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={(e) => set?.(e.target.value)}\n\t\t\t\t\tdisabled={set === undefined}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<input\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={(e) => set?.(e.target.value)}\n\t\t\t\t\tdisabled={set === undefined}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</span>\n\t)\n}\n","import { ElasticInput } from \"../../react-elastic-input\"\nimport type { JsonEditorProps } from \"../developer-interface\"\n\nexport const NonJsonEditor: React.FC<JsonEditorProps<never>> = ({ data }) => {\n\treturn data === undefined ? (\n\t\t<ElasticInput disabled value=\"undefined\" />\n\t) : (\n\t\t<ElasticInput\n\t\t\tdisabled\n\t\t\tvalue={\n\t\t\t\tObject.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data)\n\t\t\t}\n\t\t/>\n\t)\n}\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC, ReactElement } from \"react\"\nimport type { SetterOrUpdater } from \"recoil\"\n\nimport { doNothing } from \"~/packages/anvl/src/function\"\nimport type { Json, JsonTypes } from \"~/packages/anvl/src/json\"\nimport type { JsonSchema } from \"~/packages/anvl/src/json-schema/json-schema\"\nimport {\n\tisJson,\n\trefineJsonType,\n} from \"~/packages/anvl/src/refinement/refine-json\"\n\nimport { SubEditors } from \".\"\nimport { ElasticInput } from \"../react-elastic-input\"\nimport type { JsonEditorComponents } from \"./default-components\"\nimport { NonJsonEditor } from \"./editors-by-type/non-json\"\n\nexport type JsonEditorProps_INTERNAL<T extends Json.Serializable> = {\n\tdata: T\n\tset: SetterOrUpdater<T>\n\tname?: string | undefined\n\trename?: ((newKey: string) => void) | undefined\n\tremove?: (() => void) | undefined\n\trecast?: (newType: keyof JsonTypes) => void\n\tschema?: JsonSchema | undefined\n\tpath?: ReadonlyArray<number | string>\n\tisReadonly?: (path: ReadonlyArray<number | string>) => boolean\n\tisHidden?: (path: ReadonlyArray<number | string>) => boolean\n\tclassName?: string | undefined\n\tcustomCss?: SerializedStyles | undefined\n\tHeader?: FC<{ data: T; schema?: JsonSchema | undefined }> | undefined\n\tComponents: JsonEditorComponents\n}\n\nexport const JsonEditor_INTERNAL = <T extends Json.Serializable>({\n\tdata,\n\tset,\n\tschema,\n\tname,\n\trename,\n\tremove,\n\trecast,\n\tpath = [],\n\tisReadonly = () => false,\n\tisHidden = () => false,\n\tclassName,\n\tcustomCss,\n\tHeader: HeaderDisplay,\n\tComponents,\n}: JsonEditorProps_INTERNAL<T>): ReactElement | null => {\n\tconst dataIsJson = isJson(data)\n\tconst refined = dataIsJson ? refineJsonType(data) : { type: `non-json`, data }\n\tconst SubEditor = dataIsJson ? SubEditors[refined.type] : NonJsonEditor\n\n\tconst disabled = isReadonly(path)\n\n\treturn isHidden(path) ? null : (\n\t\t<Components.ErrorBoundary>\n\t\t\t<Components.EditorWrapper className={className} customCss={customCss}>\n\t\t\t\t{remove && (\n\t\t\t\t\t<Components.Button\n\t\t\t\t\t\tonClick={disabled ? doNothing : remove}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Components.DeleteIcon />\n\t\t\t\t\t</Components.Button>\n\t\t\t\t)}\n\t\t\t\t{HeaderDisplay && <HeaderDisplay data={data} schema={schema} />}\n\t\t\t\t{rename && (\n\t\t\t\t\t<Components.KeyWrapper>\n\t\t\t\t\t\t<ElasticInput\n\t\t\t\t\t\t\tvalue={name}\n\t\t\t\t\t\t\tonChange={disabled ? doNothing : (e) => rename(e.target.value)}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Components.KeyWrapper>\n\t\t\t\t)}\n\t\t\t\t<SubEditor\n\t\t\t\t\tdata={refined.data}\n\t\t\t\t\tset={set}\n\t\t\t\t\tschema={schema}\n\t\t\t\t\tremove={remove}\n\t\t\t\t\trename={rename}\n\t\t\t\t\tpath={path}\n\t\t\t\t\tisReadonly={isReadonly}\n\t\t\t\t\tisHidden={isHidden}\n\t\t\t\t\tComponents={Components}\n\t\t\t\t/>\n\t\t\t\t{recast && dataIsJson ? (\n\t\t\t\t\t<select\n\t\t\t\t\t\tonChange={\n\t\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\t\t? doNothing\n\t\t\t\t\t\t\t\t: (e) => recast(e.target.value as keyof JsonTypes)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={refined.type}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t>\n\t\t\t\t\t\t{Object.keys(SubEditors).map((type) => (\n\t\t\t\t\t\t\t<option key={type} value={type}>\n\t\t\t\t\t\t\t\t{type}\n\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</select>\n\t\t\t\t) : null}\n\t\t\t</Components.EditorWrapper>\n\t\t</Components.ErrorBoundary>\n\t)\n}\n","import type { SetterOrUpdater } from \"recoil\"\n\nimport { become } from \"~/packages/anvl/src/function\"\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nexport const makeElementSetters = <T extends Json.Array>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n): SetterOrUpdater<T[number]>[] =>\n\tdata.map(\n\t\t(value, index) => (newValue) =>\n\t\t\tset((): T => {\n\t\t\t\tconst newData = [...data]\n\t\t\t\tnewData[index] = become(newValue)(value)\n\t\t\t\treturn newData as unknown as T\n\t\t\t}),\n\t)\n","import type { ReactElement } from \"react\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport type { JsonEditorProps_INTERNAL } from \"../json-editor-internal\"\nimport { JsonEditor_INTERNAL } from \"../json-editor-internal\"\nimport { makeElementSetters } from \"./utilities/array-elements\"\n\nexport const ArrayEditor = <_ extends Json.Array>({\n\tpath = [],\n\tisReadonly = () => false,\n\tisHidden = () => false,\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<Json.Array>): ReactElement => {\n\tconst setElement = makeElementSetters(data, set)\n\treturn (\n\t\t<>\n\t\t\t{data.map((element, index) => {\n\t\t\t\tconst newPath = [...path, index]\n\t\t\t\treturn (\n\t\t\t\t\t<JsonEditor_INTERNAL\n\t\t\t\t\t\tkey={newPath.join(``)}\n\t\t\t\t\t\tpath={newPath}\n\t\t\t\t\t\tisReadonly={isReadonly}\n\t\t\t\t\t\tisHidden={isHidden}\n\t\t\t\t\t\tdata={element}\n\t\t\t\t\t\tset={setElement[index]}\n\t\t\t\t\t\tComponents={Components}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t})}\n\t\t</>\n\t)\n}\n","import { useRef } from \"react\"\nimport type { FC, ReactElement } from \"react\"\n\nimport { doNothing } from \"~/packages/anvl/src/function\"\nimport type { Json } from \"~/packages/anvl/src/json\"\nimport { findSubSchema } from \"~/packages/anvl/src/json-schema/find-sub-schema\"\nimport { isObjectSchema } from \"~/packages/anvl/src/json-schema/json-schema\"\nimport { isPlainObject } from \"~/packages/anvl/src/object/refinement\"\nimport { isLiteral } from \"~/packages/anvl/src/refinement\"\n\nimport { ElasticInput } from \"../../react-elastic-input\"\nimport type { JsonEditorComponents } from \"../default-components\"\nimport type { JsonEditorProps_INTERNAL } from \"../json-editor-internal\"\nimport { JsonEditor_INTERNAL } from \"../json-editor-internal\"\nimport {\n\tmakePropertyCreationInterface,\n\tmakePropertyRecasters,\n\tmakePropertyRemovers,\n\tmakePropertyRenamers,\n\tmakePropertySetters,\n\tmakePropertySorter,\n} from \"./utilities/object-properties\"\n\nexport type PropertyAdderProps = {\n\taddProperty: () => void\n\tdisabled: boolean\n\tpropertyKey: string\n\tComponents: JsonEditorComponents\n}\n\nexport const PropertyAdder: FC<PropertyAdderProps> = ({\n\taddProperty,\n\tdisabled,\n\tpropertyKey,\n\tComponents,\n}) => (\n\t<Components.MissingPropertyWrapper>\n\t\t<ElasticInput disabled defaultValue={propertyKey} />\n\t\t{` `}\n\t\t<ElasticInput disabled defaultValue=\"is missing\" />\n\t\t<Components.Button onClick={() => addProperty()} disabled={disabled}>\n\t\t\t+\n\t\t</Components.Button>\n\t</Components.MissingPropertyWrapper>\n)\n\nexport const ObjectEditor = <T extends Json.Object>({\n\tschema,\n\tpath = [],\n\tisReadonly = () => false,\n\tisHidden = () => false,\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<T>): ReactElement => {\n\tconst disabled = isReadonly(path)\n\n\tconst stableKeyMap = useRef<Record<keyof T, keyof T>>(\n\t\tObject.keys(data).reduce(\n\t\t\t(acc, key: keyof T) => {\n\t\t\t\tacc[key] = key\n\t\t\t\treturn acc\n\t\t\t},\n\t\t\t{} as Record<keyof T, keyof T>,\n\t\t),\n\t)\n\n\tconst setProperty = makePropertySetters(data, set)\n\tconst renameProperty = makePropertyRenamers(data, set, stableKeyMap)\n\tconst removeProperty = makePropertyRemovers(data, set)\n\tconst recastProperty = makePropertyRecasters(data, set)\n\tconst sortProperties = makePropertySorter(data, set)\n\tconst makePropertyAdder = makePropertyCreationInterface(data, set)\n\n\tconst subSchema = isPlainObject(schema) ? findSubSchema(schema)(path) : true\n\tconst schemaKeys: ReadonlyArray<string> | true = isLiteral(true)(subSchema)\n\t\t? true\n\t\t: isObjectSchema(subSchema)\n\t\t ? Object.keys(subSchema.properties ?? {})\n\t\t : []\n\tconst dataKeys: ReadonlyArray<string> = Object.keys(data)\n\tconst [unofficialKeys, officialKeys] = dataKeys.reduce(\n\t\t([unofficial, official], key) => {\n\t\t\tconst isOfficial = schemaKeys === true || schemaKeys.includes(key)\n\t\t\treturn isOfficial\n\t\t\t\t? [unofficial, [...official, key]]\n\t\t\t\t: [[...unofficial, key], official]\n\t\t},\n\t\t[[], []] as [string[], string[]],\n\t)\n\tconst missingKeys: ReadonlyArray<string> =\n\t\tschemaKeys === true\n\t\t\t? []\n\t\t\t: schemaKeys.filter((key) => !dataKeys.includes(key))\n\n\treturn (\n\t\t<>\n\t\t\t<Components.Button onClick={() => sortProperties()} disabled={disabled}>\n\t\t\t\tSort\n\t\t\t</Components.Button>\n\t\t\t<Components.ObjectWrapper>\n\t\t\t\t<div className=\"json_editor_properties\">\n\t\t\t\t\t{[...missingKeys, ...officialKeys, ...unofficialKeys].map((key) => {\n\t\t\t\t\t\tconst originalKey = stableKeyMap.current[key]\n\t\t\t\t\t\tconst newPath = [...path, key]\n\t\t\t\t\t\tconst originalPath = [...path, originalKey]\n\t\t\t\t\t\tconst isOfficial = schemaKeys === true || schemaKeys.includes(key)\n\t\t\t\t\t\tconst isMissing = missingKeys.includes(key)\n\n\t\t\t\t\t\treturn isMissing ? (\n\t\t\t\t\t\t\t<PropertyAdder\n\t\t\t\t\t\t\t\tkey={key + `IsMissing`}\n\t\t\t\t\t\t\t\tpropertyKey={key}\n\t\t\t\t\t\t\t\taddProperty={makePropertyAdder(key, `string`)}\n\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\tComponents={Components}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<JsonEditor_INTERNAL\n\t\t\t\t\t\t\t\tkey={originalPath.join(`.`)}\n\t\t\t\t\t\t\t\tschema={schema}\n\t\t\t\t\t\t\t\tpath={newPath}\n\t\t\t\t\t\t\t\tname={key}\n\t\t\t\t\t\t\t\tisReadonly={isReadonly}\n\t\t\t\t\t\t\t\tisHidden={isHidden}\n\t\t\t\t\t\t\t\tdata={data[key as keyof T]}\n\t\t\t\t\t\t\t\tset={setProperty[key as keyof T]}\n\t\t\t\t\t\t\t\trename={renameProperty[key as keyof T]}\n\t\t\t\t\t\t\t\tremove={removeProperty[key as keyof T]}\n\t\t\t\t\t\t\t\trecast={recastProperty[key as keyof T]}\n\t\t\t\t\t\t\t\tclassName={`json_editor_property ${\n\t\t\t\t\t\t\t\t\tisOfficial ? `json_editor_official` : `json_editor_unofficial`\n\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\tComponents={Components}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t\t<Components.Button\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\t? doNothing\n\t\t\t\t\t\t\t: () => makePropertyAdder(`new_property`, `string`)()\n\t\t\t\t\t}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t>\n\t\t\t\t\t+\n\t\t\t\t</Components.Button>\n\t\t\t</Components.ObjectWrapper>\n\t\t</>\n\t)\n}\n","import { pipe } from \"../function\"\n\nexport type IntegerBrand = { readonly integer: unique symbol /* virtual */ }\nexport type integer = IntegerBrand & number\nexport const isInteger = (input: unknown): input is integer =>\n\tNumber.isInteger(input as number)\n\nexport const parseInteger = (input: unknown): integer => {\n\tif (isInteger(input)) return input\n\tthrow new IntegerParseError(input)\n}\n\nexport class Fraction extends Number {\n\tpublic readonly numerator: integer\n\tpublic readonly denominator: integer\n\n\tpublic constructor(n: integer | number, d: integer | number) {\n\t\tsuper(n / d)\n\t\tif (d === 0) {\n\t\t\tthrow new Error(`Denominator cannot be zero`)\n\t\t}\n\t\tthis.numerator = parseInteger(n)\n\t\tthis.denominator = parseInteger(d)\n\t}\n\tpublic readonly [Symbol.toPrimitive]: () => number = () =>\n\t\tthis.numerator / this.denominator\n}\n\nexport const Frac = (n: integer | number, d: integer | number): Fraction =>\n\tnew Fraction(n, d)\n\nexport const isFraction = (input: unknown): input is Fraction =>\n\tinput instanceof Fraction\n\nexport class IntegerParseError extends Error {\n\tpublic constructor(value: unknown) {\n\t\tsuper(`Could not parse integer from ${JSON.stringify(value)}`)\n\t}\n}\n\nexport type IntegerParseResult =\n\t| {\n\t\t\tvalue: integer\n\t\t\terror: null\n\t\t\tround: null\n\t\t\tupper: null\n\t\t\tlower: null\n\t\t\tratio: null\n\t }\n\t| {\n\t\t\tvalue: null\n\t\t\terror: IntegerParseError\n\t\t\tround: integer\n\t\t\tupper: integer\n\t\t\tlower: integer\n\t\t\tratio: Fraction | null\n\t }\n\nexport const Int = Object.assign((input: unknown) => parseInteger(input), {\n\tfrom: (input: unknown): IntegerParseResult =>\n\t\tpipe(input, String, parseFloat, (num) =>\n\t\t\tisInteger(num)\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: num,\n\t\t\t\t\t\terror: null,\n\t\t\t\t\t\tround: null,\n\t\t\t\t\t\tupper: null,\n\t\t\t\t\t\tlower: null,\n\t\t\t\t\t\tratio: null,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: null,\n\t\t\t\t\t\terror: new IntegerParseError(input),\n\t\t\t\t\t\tround: Math.round(num) as integer,\n\t\t\t\t\t\tupper: Math.ceil(num) as integer,\n\t\t\t\t\t\tlower: Math.floor(num) as integer,\n\t\t\t\t\t\tratio: null,\n\t\t\t\t },\n\t\t),\n\n\tformula: <\n\t\tI extends Record<\n\t\t\tkeyof any,\n\t\t\tFraction | Fraction[] | integer | integer[] | number[] | number\n\t\t>,\n\t\tO extends Record<\n\t\t\tkeyof any,\n\t\t\tFraction | Fraction[] | integer | integer[] | number[] | number\n\t\t>,\n\t>(\n\t\tfm: (\n\t\t\tinput: {\n\t\t\t\t[K in keyof I]: I[K] extends (Fraction | integer)[] ? number[] : number\n\t\t\t},\n\t\t) => O,\n\t) => {\n\t\treturn (input: I): O => {\n\t\t\treturn fm(\n\t\t\t\tinput as {\n\t\t\t\t\t[K in keyof I]: I[K] extends (Fraction | integer)[] ? number[] : number\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t},\n})\n\nexport function asNumber(input: Fraction | integer | number): number\nexport function asNumber(input: Fraction[] | integer[] | number[]): number[]\nexport function asNumber<\n\tR extends Record<\n\t\tkeyof any,\n\t\tFraction | Fraction[] | integer | integer[] | number[] | number\n\t>,\n>(input: R): {\n\t[K in keyof R]: R[K] extends Fraction | integer | number ? number : number[]\n}\nexport function asNumber(input: unknown): unknown {\n\treturn input as any\n}\n\nexport const a = asNumber(new Fraction(1, 2))\nexport const b = asNumber([new Fraction(1, 2)])\nexport const c = asNumber({ a: new Fraction(1, 2) })\n","import { isString } from \"../primitive\"\nimport type { Substitute } from \"../tree/substitute\"\n\nimport { delve } from \"../object\"\nimport { doesExtend } from \"../object/refinement\"\nimport { Int } from \"./integer\"\nimport type { JsonSchema } from \"./json-schema\"\nimport { isJsonSchema } from \"./json-schema\"\n\nexport type JsonSchemaRef = {\n\t$ref: string\n}\nexport function isJsonSchemaRef(input: unknown): input is JsonSchemaRef {\n\treturn doesExtend({\n\t\t$ref: isString,\n\t})(input)\n}\n\nexport type ReffedJsonSchema = Substitute<\n\tJsonSchema,\n\tJsonSchema,\n\tJsonSchema | JsonSchemaRef\n>\n\nexport const colorPalette: ReffedJsonSchema = {\n\t$defs: {\n\t\tcolorChannel: {\n\t\t\ttype: `integer`,\n\t\t\tminimum: Int(0),\n\t\t\tmaximum: Int(255),\n\t\t},\n\t\tcolor: {\n\t\t\ttype: `object`,\n\t\t\tproperties: {\n\t\t\t\tred: { $ref: `#/$defs/colorChannel` },\n\t\t\t\tgreen: { $ref: `#/$defs/colorChannel` },\n\t\t\t\tblue: { $ref: `#/$defs/colorChannel` },\n\t\t\t},\n\t\t},\n\t},\n\ttype: `array`,\n\titems: {\n\t\t$ref: `#/$defs/color`,\n\t},\n} as const\n\ntype RetrieveRefOptions = {\n\trefNode: JsonSchemaRef\n\trefMap?: Record<string, JsonSchema> | undefined\n\troot: ReffedJsonSchema\n}\ntype RetrieveRefResult = {\n\tnode: JsonSchema\n\trefMap: Record<string, JsonSchema>\n}\n\nexport const retrieveRef = ({\n\trefNode: { $ref },\n\trefMap = {},\n\troot,\n}: RetrieveRefOptions): RetrieveRefResult => {\n\tif (typeof root === `boolean`) {\n\t\tthrow new TypeError(`The root is a boolean and cannot be indexed`)\n\t}\n\tif ($ref in refMap) return { node: refMap[$ref], refMap }\n\tconst [_, ...refPath] = $ref.split(`/`)\n\tconst discovery = delve(root, refPath)\n\tif (discovery instanceof Error) throw discovery\n\tlet node = discovery.found\n\twhile (isJsonSchemaRef(node)) {\n\t\tconst result = retrieveRef({ refNode: node, refMap, root })\n\t\tnode = result.node\n\t\trefMap = result.refMap\n\t}\n\tif (isJsonSchema(node)) {\n\t\treturn { node, refMap: { ...refMap, [$ref]: node } }\n\t}\n\tthrow new TypeError(`The refNode is not a JsonSchema`)\n}\n","import { attempt } from \"../function\"\nimport { isString } from \"../primitive\"\n\nexport const JSON_SCHEMA_STRING_FORMATS = [\n\t`date-time`,\n\t`date`,\n\t`email`,\n\t`hostname`,\n\t`ipv4`,\n\t`ipv6`,\n\t`regex`,\n\t`time`,\n\t`uri-reference`,\n\t`uri-template`,\n\t`uri`,\n\t`uuid`,\n] as const\n\nexport type JsonSchemaStringFormat = (typeof JSON_SCHEMA_STRING_FORMATS)[number]\n\nexport type date_time = string & { readonly date_time: unique symbol }\nexport type date = string & { readonly date: unique symbol }\nexport type email = string & { readonly email: unique symbol }\nexport type hostname = string & { readonly hostname: unique symbol }\nexport type ipv4 = string & { readonly ipv4: unique symbol }\nexport type ipv6 = string & { readonly ipv6: unique symbol }\nexport type regex = string & { readonly regex: unique symbol }\nexport type time = string & { readonly time: unique symbol }\nexport type uri_reference = string & { readonly uri_reference: unique symbol }\nexport type uri_template = string & { readonly uri_template: unique symbol }\nexport type uri = string & { readonly uri: unique symbol }\nexport type uuid = string & { readonly uuid: unique symbol }\n\nexport const isDateTime = (input: unknown): input is date_time =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^([+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24:?00)([.,]\\d+(?!:))?)?(\\17[0-5]\\d([.,]\\d+)?)?([zZ]|([+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$/,\n\t)?.length === 1\n\nexport const isDate = (input: unknown): input is date =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^([+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6]))))?$/,\n\t)?.length === 1\n\nexport const isEmail = (input: unknown): input is email =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n\t)?.length === 1\n\nexport const isHostname = (input: unknown): input is hostname =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^(?=.{1,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\\.)+[a-zA-Z]{2,63}$)/,\n\t)?.length === 1\n\nexport const isIpv4 = (input: unknown): input is ipv4 =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,\n\t)?.length === 1\n\nexport const isIpv6 = (input: unknown): input is ipv6 => isString(input) // && net.isIPv6(input)\n\nexport const isRegex = (input: unknown): input is regex =>\n\tisString(input) && attempt(() => new RegExp(input))\n\nexport const isTime = (input: unknown): input is time =>\n\tisString(input) &&\n\tinput.match(/^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\\.\\d+)?$/)\n\t\t?.length === 1\n\nexport const isUriReference = (input: unknown): input is uri_reference =>\n\tisString(input) &&\n\tinput.match(/^(([^:/?#]+):)?(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/)\n\t\t?.length === 1\n\nexport const isUriTemplate = (input: unknown): input is uri_template =>\n\tisString(input) &&\n\tinput.match(/^(([^:/?#]+):)?(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/)\n\t\t?.length === 1\n\nexport const isUri = (input: unknown): input is uri =>\n\tisString(input) &&\n\tinput.match(/^(([^:/?#]+):)?(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/)\n\t\t?.length === 1\n\nexport const isUuid = (input: unknown): input is uuid =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,\n\t)?.length === 1\n","import { isArray } from \"../array\"\nimport { JSON_TYPE_NAMES } from \"../json\"\nimport { ifDefined } from \"../nullish\"\nimport { doesExtend, isRecord } from \"../object/refinement\"\nimport { isBoolean, isNumber, isString } from \"../primitive\"\nimport type { Refinement } from \"../refinement\"\nimport {\n\tisIntersection,\n\tisLiteral,\n\tisUnion,\n\tisWithin,\n\tmustSatisfyOneOfTheFollowing,\n} from \"../refinement\"\nimport type { Refined } from \"../refinement/refined\"\nimport type { integer } from \"./integer\"\nimport { isInteger } from \"./integer\"\nimport type { JsonSchemaRef } from \"./refs\"\nimport { isJsonSchemaRef } from \"./refs\"\nimport type { JsonSchemaStringFormat } from \"./string-formats\"\nimport { JSON_SCHEMA_STRING_FORMATS } from \"./string-formats\"\n\n/* eslint-disable max-lines */\n\nexport const JSON_SCHEMA_TYPE_NAMES = [...JSON_TYPE_NAMES, `integer`] as const\nexport type JsonSchemaTypeName = (typeof JSON_SCHEMA_TYPE_NAMES)[number]\n\nexport const JSON_SCHEMA_META_TYPE_NAMES = [\n\t...JSON_SCHEMA_TYPE_NAMES,\n\t`any`,\n\t`never`,\n] as const\nexport type JsonSchemaMetaTypeName = (typeof JSON_SCHEMA_META_TYPE_NAMES)[number]\n\nexport const JSON_SCHEMA_LOGIC_MODES = [\n\t`union`,\n\t`exclusive`,\n\t`intersection`,\n\t`negation`,\n\t`conditional`,\n] as const\nexport type JsonSchemaLogicMode = (typeof JSON_SCHEMA_LOGIC_MODES)[number]\n\nexport interface JsonSchemaSystem\n\textends Record<JsonSchemaLogicMode & JsonSchemaMetaTypeName, any> {\n\tarray: ArraySchema\n\tboolean: BooleanSchema\n\tinteger: IntegerSchema\n\tnull: NullSchema\n\tnumber: NumberSchema\n\tobject: ObjectSchema\n\tstring: StringSchema\n\tany: true\n\tnever: false\n\tunion: UnionSchema\n\texclusive: ExclusiveSchema\n\tintersection: IntersectionSchema\n\tnegation: NegationSchema\n\tconditional: ConditionalSchema\n}\n\n// export const JSON_SCHEMA_SYSTEM: JsonSchemaSystem = {\n// array: { type: `array` },\n// boolean: { type: `boolean` },\n// integer: { type: `integer` },\n// null: { type: `null` },\n// number: { type: `number` },\n// object: { type: `object` },\n// string: { type: `string` },\n// any: true,\n// never: false,\n// union: { anyOf: [true] },\n// exclusive: { oneOf: [true] },\n// intersection: { allOf: [true] },\n// negation: { not: false },\n// conditional: { if: true, then: true, else: false },\n// } as const\n\nexport const JSON_SCHEMA_REFINERY: {\n\t[K in JsonSchemaLogicMode & JsonSchemaMetaTypeName]: Refinement<\n\t\tunknown,\n\t\tJsonSchemaSystem[K]\n\t>\n} = {\n\tarray: isArraySchema,\n\tboolean: isBooleanSchema,\n\tinteger: isIntegerSchema,\n\tnull: isNullSchema,\n\tnumber: isNumberSchema,\n\tobject: isObjectSchema,\n\tstring: isStringSchema,\n\tany: isLiteral(true),\n\tnever: isLiteral(false),\n\tunion: isUnionSchema,\n\tintersection: isIntersectionSchema,\n\tnegation: isNegationSchema,\n\tconditional: isConditionalSchema,\n}\n\nexport type StringSchema = {\n\ttype: `string`\n\tenum?: string[]\n\tminLength?: integer\n\tmaxLength?: integer\n\tpattern?: string\n\tformat?: JsonSchemaStringFormat\n}\nexport const stringSchemaStructure = {\n\ttype: isLiteral(`string`),\n\tenum: ifDefined(isArray(isString)),\n\tminLength: ifDefined(isInteger),\n\tmaxLength: ifDefined(isInteger),\n\tpattern: ifDefined(isString),\n\tformat: ifDefined(isWithin(JSON_SCHEMA_STRING_FORMATS)),\n}\nexport function isStringSchema(input: unknown): input is StringSchema {\n\treturn doesExtend(stringSchemaStructure)(input)\n}\n\nexport const numberSchemaStructure = {\n\ttype: isLiteral(`number`),\n\tenum: ifDefined(isArray(isNumber)),\n\tminimum: ifDefined(isNumber),\n\tmaximum: ifDefined(isNumber),\n\texclusiveMinimum: ifDefined(isNumber),\n\texclusiveMaximum: ifDefined(isNumber),\n\tmultipleOf: ifDefined(isNumber),\n}\nexport type NumberSchema = Refined<typeof numberSchemaStructure>\nexport function isNumberSchema(input: unknown): input is NumberSchema {\n\treturn doesExtend(numberSchemaStructure)(input)\n}\n\nexport const integerSchemaStructure = {\n\ttype: isLiteral(`integer`),\n\tenum: ifDefined(isArray(isInteger)),\n\tminimum: ifDefined(isInteger),\n\tmaximum: ifDefined(isInteger),\n\texclusiveMinimum: ifDefined(isInteger),\n\texclusiveMaximum: ifDefined(isInteger),\n\tmultipleOf: ifDefined(isInteger),\n}\nexport type IntegerSchema = Refined<typeof integerSchemaStructure>\nexport function isIntegerSchema(input: unknown): input is IntegerSchema {\n\treturn doesExtend(integerSchemaStructure)(input)\n}\n\nexport const booleanSchemaStructure = {\n\ttype: isLiteral(`boolean`),\n\tenum: ifDefined(isArray(isBoolean)),\n}\nexport type BooleanSchema = Refined<typeof booleanSchemaStructure>\nexport function isBooleanSchema(input: unknown): input is BooleanSchema {\n\treturn doesExtend(booleanSchemaStructure)(input)\n}\n\nexport const nullSchemaStructure = {\n\ttype: isLiteral(`null`),\n}\nexport type NullSchema = Refined<typeof nullSchemaStructure>\nexport function isNullSchema(input: unknown): input is NullSchema {\n\treturn doesExtend(nullSchemaStructure)(input)\n}\n\nexport type ObjectSchema = {\n\ttype: `object`\n\tproperties?: Record<string, JsonSchema>\n\tpatternProperties?: Record<string, JsonSchema>\n\trequired?: string[]\n\tadditionalProperties?: JsonSchema\n\tpropertyNames?: JsonSchema\n\tminProperties?: integer\n\tmaxProperties?: integer\n\tdependentSchemas?: Record<string, JsonSchema>\n}\nexport const objectSchemaStructure = {\n\ttype: isLiteral(`object`),\n\tproperties: ifDefined(isRecord(isString, isJsonSchema)),\n\trequired: ifDefined(isArray(isString)),\n\tadditionalProperties: ifDefined(isJsonSchema),\n\tpropertyNames: ifDefined(isStringSchema),\n\tminProperties: ifDefined(isInteger),\n\tmaxProperties: ifDefined(isInteger),\n\tdependentSchemas: ifDefined(isRecord(isString, isJsonSchema)),\n}\nexport function isObjectSchema(input: unknown): input is ObjectSchema {\n\treturn doesExtend(objectSchemaStructure)(input)\n}\n\nexport type ArraySchema = {\n\ttype: `array`\n\titems?: JsonSchema | JsonSchema[]\n\tminItems?: integer\n\tmaxItems?: integer\n\tuniqueItems?: boolean\n}\nexport const arraySchemaStructure = {\n\ttype: isLiteral(`array`),\n\titems: ifDefined(\n\t\tmustSatisfyOneOfTheFollowing(isJsonSchema).or(isArray(isJsonSchema)),\n\t),\n\tminItems: ifDefined(isInteger),\n\tmaxItems: ifDefined(isInteger),\n\tuniqueItems: ifDefined(isBoolean),\n}\nexport function isArraySchema(input: unknown): input is ArraySchema {\n\treturn doesExtend(arraySchemaStructure)(input)\n}\n\nexport type UnionSchema = { anyOf: JsonSchema[] }\nexport const unionSchemaStructure = { anyOf: isArray(isJsonSchema) }\nexport function isUnionSchema(input: unknown): input is UnionSchema {\n\treturn doesExtend(unionSchemaStructure)(input)\n}\nexport type IntersectionSchema = {\n\tallOf: JsonSchema[] | ReadonlyArray<JsonSchema>\n}\nexport type ExclusiveSchema = {\n\toneOf: JsonSchema[] | ReadonlyArray<JsonSchema>\n}\nexport const exclusiveSchemaStructure = { oneOf: isArray(isJsonSchema) }\nexport function isExclusiveSchema(input: unknown): input is ExclusiveSchema {\n\treturn doesExtend(exclusiveSchemaStructure)(input)\n}\n\nexport const intersectionSchemaStructure = { allOf: isArray(isJsonSchema) }\nexport function isIntersectionSchema(\n\tinput: unknown,\n): input is IntersectionSchema {\n\treturn doesExtend(intersectionSchemaStructure)(input)\n}\n\nexport type ConditionalSchema = {\n\tif: JsonSchema\n\tthen?: JsonSchema\n\telse?: JsonSchema\n}\nexport const conditionalSchemaStructure = {\n\tif: isJsonSchema,\n\tthen: ifDefined(isJsonSchema),\n\telse: ifDefined(isJsonSchema),\n}\nexport function isConditionalSchema(input: unknown): input is ConditionalSchema {\n\treturn doesExtend(conditionalSchemaStructure)(input)\n}\n\nexport type NegationSchema = { not: JsonSchema }\nexport const negationSchemaStructure = { not: isJsonSchema }\nexport function isNegationSchema(input: unknown): input is NegationSchema {\n\treturn doesExtend(negationSchemaStructure)(input)\n}\n\nexport type MixedSchema = Partial<\n\tOmit<ArraySchema, `type`> &\n\t\tOmit<BooleanSchema, `enum` | `type`> &\n\t\tOmit<IntegerSchema, `enum` | `type`> &\n\t\tOmit<NullSchema, `type`> &\n\t\tOmit<NumberSchema, `enum` | `type`> &\n\t\tOmit<ObjectSchema, `type`> &\n\t\tOmit<StringSchema, `enum` | `type`>\n> & {\n\ttype: ReadonlyArray<JsonSchemaTypeName>\n\tenum?: ReadonlyArray<integer | boolean | number | string>\n}\nexport const mixedSchemaStructure = {\n\t...arraySchemaStructure,\n\t...booleanSchemaStructure,\n\t...integerSchemaStructure,\n\t...nullSchemaStructure,\n\t...numberSchemaStructure,\n\t...objectSchemaStructure,\n\t...stringSchemaStructure,\n\ttype: isArray(isWithin(JSON_SCHEMA_TYPE_NAMES)),\n\tenum: ifDefined(\n\t\tisArray(isUnion.or(isInteger).or(isBoolean).or(isNumber).or(isString)),\n\t),\n}\nexport function isMixedSchema(input: unknown): input is MixedSchema {\n\treturn doesExtend(mixedSchemaStructure)(input)\n}\n\nexport type JsonSchemaCore =\n\t| ArraySchema\n\t| BooleanSchema\n\t| ConditionalSchema\n\t| ExclusiveSchema\n\t| IntegerSchema\n\t| IntersectionSchema\n\t| MixedSchema\n\t| NegationSchema\n\t| NullSchema\n\t| NumberSchema\n\t| ObjectSchema\n\t| StringSchema\n\t| UnionSchema\n\nexport const isJsonSchemaCore = isUnion\n\t.or(isArraySchema)\n\t.or(isBooleanSchema)\n\t.or(isConditionalSchema)\n\t.or(isExclusiveSchema)\n\t.or(isIntegerSchema)\n\t.or(isIntersectionSchema)\n\t.or(isMixedSchema)\n\t.or(isNegationSchema)\n\t.or(isNullSchema)\n\t.or(isNumberSchema)\n\t.or(isObjectSchema)\n\t.or(isStringSchema)\n\t.or(isUnionSchema)\n\nexport type JsonSchemaLeaf =\n\t| BooleanSchema\n\t| IntegerSchema\n\t| NullSchema\n\t| NumberSchema\n\t| StringSchema\nexport function isJsonSchemaLeaf(input: unknown): input is JsonSchemaLeaf {\n\treturn isUnion\n\t\t.or(isBooleanSchema)\n\t\t.or(isIntegerSchema)\n\t\t.or(isNullSchema)\n\t\t.or(isNumberSchema)\n\t\t.or(isStringSchema)(input)\n}\n\nexport type JsonSchemaTree =\n\t| ArraySchema\n\t| ConditionalSchema\n\t| ExclusiveSchema\n\t| IntersectionSchema\n\t| MixedSchema\n\t| NegationSchema\n\t| ObjectSchema\n\t| UnionSchema\nexport function isJsonSchemaTree(input: unknown): input is JsonSchemaTree {\n\treturn isUnion\n\t\t.or(isArraySchema)\n\t\t.or(isMixedSchema)\n\t\t.or(isObjectSchema)\n\t\t.or(isUnionSchema)\n\t\t.or(isIntersectionSchema)\n\t\t.or(isExclusiveSchema)\n\t\t.or(isConditionalSchema)\n\t\t.or(isNegationSchema)(input)\n}\n\nexport type JsonSchemaRoot = {\n\t$id?: string\n\t$schema?: string\n\t$defs?: Record<string, JsonSchema>\n\tdefinitions?: Record<string, JsonSchema>\n}\n\nexport const isJsonSchemaRoot = doesExtend({\n\t$id: ifDefined(isString),\n\t$schema: ifDefined(isString),\n})\n\n/* prettier-ignore */\nexport type JsonSchemaObject = JsonSchemaCore & JsonSchemaRoot\nexport const isJsonSchemaObject = isIntersection\n\t.and(isJsonSchemaCore)\n\t.and(isJsonSchemaRoot)\n\nexport type JsonSchema = JsonSchemaObject | JsonSchemaRef | boolean\nexport function isJsonSchema(input: unknown): input is JsonSchema {\n\treturn mustSatisfyOneOfTheFollowing(isBoolean)\n\t\t.or(isJsonSchemaObject)\n\t\t.or(isJsonSchemaRef)(input)\n}\n","export const expandPathForSchema = (\n\tpath: (keyof any)[],\n): (number | string)[] | Error => {\n\ttry {\n\t\treturn path.flatMap((key) => {\n\t\t\tswitch (typeof key) {\n\t\t\t\tcase `string`:\n\t\t\t\t\treturn [`properties`, key]\n\t\t\t\tcase `number`:\n\t\t\t\t\treturn [`items`, key]\n\t\t\t\tcase `symbol`:\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`The key ${String(\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)} is not a valid JSON key; expected string or number, got symbol`,\n\t\t\t\t\t)\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`The key ${key} is not a valid JSON key; expected string or number, got ${typeof key}`,\n\t\t\t\t\t)\n\t\t\t}\n\t\t})\n\t} catch (caught) {\n\t\tif (caught instanceof TypeError) return caught\n\t\tthrow caught\n\t}\n}\n","import { isJsonSchema } from \"./json-schema\"\nimport { expandPathForSchema } from \"./path-into\"\nimport { isJsonSchemaRef, retrieveRef } from \"./refs\"\nimport type { ReffedJsonSchema } from \"./refs\"\n\nexport const findSubSchema = (\n\tschema: ReffedJsonSchema,\n): ((\n\tpath: (number | string)[] | ReadonlyArray<number | string>,\n) => Error | ReffedJsonSchema) => {\n\tif (typeof schema === `boolean`) {\n\t\tthrow new Error(`The schema does not contain subSchemas`)\n\t}\n\treturn (path: string[]) => {\n\t\tconst pathIntoSchema = expandPathForSchema(path)\n\t\tif (pathIntoSchema instanceof Error) return pathIntoSchema\n\t\tif (typeof schema === `boolean`) {\n\t\t\treturn new TypeError(`The schema is not a JsonSchema`)\n\t\t}\n\t\tconst { node, refMap } = pathIntoSchema.reduce(\n\t\t\t({ node, refMap = undefined }, key) => (\n\t\t\t\tconsole.log({ node, key }),\n\t\t\t\tisJsonSchemaRef(node)\n\t\t\t\t\t? retrieveRef({ refNode: node, root: schema, refMap })\n\t\t\t\t\t: { node: node[key], refMap }\n\t\t\t),\n\t\t\t{ node: schema, refMap: undefined },\n\t\t)\n\t\tif (node instanceof Error) throw node\n\n\t\tlet subSchema = node\n\t\twhile (isJsonSchemaRef(subSchema)) {\n\t\t\tconsole.log({ subSchema })\n\t\t\tsubSchema = retrieveRef({ refNode: subSchema, root: schema, refMap }).node\n\t\t}\n\t\tconsole.log({ subSchema })\n\n\t\tif (isJsonSchema(subSchema)) {\n\t\t\treturn subSchema\n\t\t}\n\t\tthrow new TypeError(`The subSchema is not a JsonSchema`)\n\t}\n}\n","import type * as Json from \"./json\"\n\nexport const stringToBoolean = (str: string): boolean => str === `true`\nexport const stringToNumber = (str: string): number => Number(str)\nexport const stringToArray = (str: string): string[] => str.split(`,`)\nexport const stringToObject = (str: string): Json.Object => {\n\ttry {\n\t\treturn JSON.parse(str)\n\t} catch (e) {\n\t\treturn { [str]: str }\n\t}\n}\n\nexport const objectToString = (obj: Json.Object): string => JSON.stringify(obj)\nexport const objectToBoolean = (obj: Json.Object): boolean => obj.true === true\nexport const objectToNumber = (obj: Json.Object): number =>\n\tNumber(obj.number ?? obj.size ?? obj.count ?? 0)\nexport const objectToArray = <T extends Json.Serializable>(\n\tobj: Json.Object<string, T>,\n): [key: string, value: T][] => Object.entries(obj)\n\nexport const booleanToString = (bool: boolean): string => bool.toString()\nexport const booleanToNumber = (bool: boolean): number => +bool\nexport const booleanToObject = (bool: boolean): Json.Object => ({\n\t[bool.toString()]: bool,\n})\nexport const booleanToArray = (bool: boolean): boolean[] => [bool]\n\nexport const numberToString = (num: number): string => num.toString()\nexport const numberToBoolean = (num: number): boolean => num === 1\nexport const numberToObject = (num: number): Json.Object => ({\n\tnumber: num,\n})\nexport const numberToArray = (num: number): null[] => Array(num).fill(null)\n\nexport const arrayToString = (arr: Json.Array): string => arr.join(`,`)\nexport const arrayToNumber = (arr: Json.Array): number => arr.length\nexport const arrayToBoolean = (arr: Json.Array): boolean =>\n\ttypeof arr[0] === `boolean` ? arr[0] : arr.length > 0\nexport const arrayToObject = <T extends Json.Serializable>(\n\tarr: Json.Array<T>,\n): Json.Object<`${number}`, T> =>\n\tarr.reduce(\n\t\t(acc, cur, idx) => {\n\t\t\tacc[`${idx}`] = cur\n\t\t\treturn acc\n\t\t},\n\t\t{} as Json.Object<`${number}`, T>,\n\t)\n\nexport const nullToString = (): string => ``\nexport const nullToNumber = (): number => 0\nexport const nullToBoolean = (): boolean => false\nexport const nullToArray = (): Json.Array => []\nexport const nullToObject = (): Json.Object => ({})\n","import type { Json } from \"../json\"\nimport * as Cast from \"../json/cast-json\"\nimport { refineJsonType } from \"./refine-json\"\n\nexport const castToJson = (\n\tinput: Json.Serializable,\n): {\n\tto: {\n\t\tarray: () => Json.Array\n\t\tboolean: () => boolean\n\t\tnumber: () => number\n\t\tobject: () => Json.Object\n\t\tstring: () => string\n\t\tnull: () => null\n\t}\n} => {\n\tconst json = refineJsonType(input)\n\treturn {\n\t\tto: {\n\t\t\tarray: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn Cast.objectToArray(json.data)\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn Cast.stringToArray(json.data)\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn Cast.booleanToArray(json.data)\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn Cast.numberToArray(json.data)\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToArray()\n\t\t\t\t}\n\t\t\t},\n\t\t\tboolean: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn Cast.arrayToBoolean(json.data)\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn Cast.objectToBoolean(json.data)\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn Cast.stringToBoolean(json.data)\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn Cast.numberToBoolean(json.data)\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToBoolean()\n\t\t\t\t}\n\t\t\t},\n\t\t\tnumber: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn Cast.arrayToNumber(json.data)\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn Cast.objectToNumber(json.data)\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn Cast.stringToNumber(json.data)\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn Cast.booleanToNumber(json.data)\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToNumber()\n\t\t\t\t}\n\t\t\t},\n\t\t\tobject: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn Cast.arrayToObject(json.data)\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn Cast.stringToObject(json.data)\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn Cast.booleanToObject(json.data)\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn Cast.numberToObject(json.data)\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToObject()\n\t\t\t\t}\n\t\t\t},\n\t\t\tstring: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn Cast.arrayToString(json.data)\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn Cast.objectToString(json.data)\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn Cast.booleanToString(json.data)\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn Cast.numberToString(json.data)\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToString()\n\t\t\t\t}\n\t\t\t},\n\t\t\tnull: () => null,\n\t\t},\n\t}\n}\n","import type { MutableRefObject } from \"react\"\nimport type { SetterOrUpdater } from \"recoil\"\n\nimport { become } from \"~/packages/anvl/src/function\"\nimport { JSON_DEFAULTS } from \"~/packages/anvl/src/json\"\nimport type { Json, JsonTypeName } from \"~/packages/anvl/src/json\"\nimport { mapObject } from \"~/packages/anvl/src/object\"\nimport { castToJson } from \"~/packages/anvl/src/refinement/smart-cast-json\"\n\nexport const makePropertySetters = <T extends Json.Object>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n): { [K in keyof T]: SetterOrUpdater<T[K]> } =>\n\tmapObject<keyof T, any, SetterOrUpdater<any>>(\n\t\tdata,\n\t\t(value, key) => (newValue) =>\n\t\t\tset({ ...data, [key]: become(newValue)(value[key]) }),\n\t)\n\nexport const makePropertyRenamers = <T extends Json.Object>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n\tstableKeyMapRef: MutableRefObject<{ [Key in keyof T]: keyof T }>,\n): { [K in keyof T]: (newKey: string) => void } =>\n\tmapObject<keyof T, any, (newKey: string) => void>(\n\t\tdata,\n\t\t(value, key) => (newKey) =>\n\t\t\tObject.hasOwn(data, newKey)\n\t\t\t\t? null\n\t\t\t\t: set(() => {\n\t\t\t\t\t\tconst entries = Object.entries(data)\n\t\t\t\t\t\tconst index = entries.findIndex(([k]) => k === key)\n\t\t\t\t\t\tentries[index] = [newKey, value]\n\t\t\t\t\t\tconst stableKeyMap = stableKeyMapRef.current\n\t\t\t\t\t\tstableKeyMapRef.current = {\n\t\t\t\t\t\t\t...stableKeyMap,\n\t\t\t\t\t\t\t[newKey]: stableKeyMap[key],\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn Object.fromEntries(entries) as T\n\t\t\t\t }),\n\t)\n\nexport const makePropertyRemovers = <T extends Json.Object>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n): { [K in keyof T]: () => void } =>\n\tmapObject<keyof T, any, () => void>(\n\t\tdata,\n\t\t(_, key) => () =>\n\t\t\tset(() => {\n\t\t\t\tconst { [key]: _, ...rest } = data\n\t\t\t\treturn rest as T\n\t\t\t}),\n\t)\n\nexport const makePropertyRecasters = <T extends Json.Object>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n): { [K in keyof T]: (newType: JsonTypeName) => void } =>\n\tmapObject<keyof T, any, (newType: JsonTypeName) => void>(\n\t\tdata,\n\t\t(value, key) => (newType) =>\n\t\t\tset(() => ({\n\t\t\t\t...data,\n\t\t\t\t[key]: castToJson(value).to[newType](),\n\t\t\t})),\n\t)\n\nexport const makePropertyCreationInterface =\n\t<T extends Json.Object>(\n\t\tdata: T,\n\t\tset: SetterOrUpdater<T>,\n\t): ((\n\t\tkey: string,\n\t\ttype: JsonTypeName,\n\t) => (value?: Json.Serializable) => void) =>\n\t(key, type) =>\n\t(value) =>\n\t\tset({ ...data, [key]: value ?? JSON_DEFAULTS[type] })\n\nexport const makePropertySorter =\n\t<T extends Json.Object>(\n\t\tdata: T,\n\t\tset: SetterOrUpdater<T>,\n\t\tsortFn?: (a: string, b: string) => number,\n\t): (() => void) =>\n\t() => {\n\t\tconst sortedKeys = Object.keys(data).sort(sortFn)\n\t\tconst sortedObj = {} as Record<string, unknown>\n\t\tfor (const key of sortedKeys) {\n\t\t\tsortedObj[key] = data[key]\n\t\t}\n\t\tset(sortedObj as T)\n\t}\n\n// export const sortPropertiesAlphabetically = <T extends Json.Object>(data: T): T =>\n// sortProperties(data, (a, b) => a.localeCompare(b))\n\nexport const deleteProperty =\n\t<T extends Json.Object>(\n\t\tdata: T,\n\t\tset: SetterOrUpdater<T>,\n\t): ((key: keyof T) => void) =>\n\t(key) => {\n\t\tconst { [key]: _, ...rest } = data\n\t\tset(rest as T)\n\t}\n\nexport const addProperty =\n\t<T extends Json.Object>(\n\t\tdata: T,\n\t\tset: SetterOrUpdater<T>,\n\t): ((key?: string, value?: Json.Serializable) => void) =>\n\t(key, value) => {\n\t\tconst newKey = key ?? `newProperty`\n\t\tconst newValue = value ?? ``\n\t\tset({ ...data, [newKey]: newValue })\n\t}\n","import type { ReactElement } from \"react\"\n\nimport { NumberInput, TextInput } from \"../../react-elastic-input\"\nimport type { JsonEditorProps_INTERNAL } from \"../json-editor-internal\"\n\nexport const BooleanEditor = ({\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<boolean>): ReactElement => (\n\t<Components.BooleanWrapper>\n\t\t<input\n\t\t\ttype=\"checkbox\"\n\t\t\tchecked={data}\n\t\t\tonChange={(event) => set(event.target.checked)}\n\t\t/>\n\t</Components.BooleanWrapper>\n)\n\nexport const NullEditor = ({\n\tComponents,\n}: JsonEditorProps_INTERNAL<null>): ReactElement => (\n\t<Components.NullWrapper>\" \"</Components.NullWrapper>\n)\n\nexport const NumberEditor = ({\n\tpath = [],\n\tisReadonly = () => false,\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<number>): ReactElement => (\n\t<Components.NumberWrapper>\n\t\t<NumberInput\n\t\t\tvalue={data}\n\t\t\tset={isReadonly(path) ? undefined : (newValue) => set(Number(newValue))}\n\t\t\tautoSize={true}\n\t\t/>\n\t</Components.NumberWrapper>\n)\n\nexport const StringEditor = ({\n\tpath = [],\n\tisReadonly = () => false,\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<string>): ReactElement => {\n\treturn (\n\t\t<Components.StringWrapper>\n\t\t\t<TextInput\n\t\t\t\tvalue={data}\n\t\t\t\tset={isReadonly(path) ? undefined : set}\n\t\t\t\tautoSize={true}\n\t\t\t/>\n\t\t</Components.StringWrapper>\n\t)\n}\n","import type { ErrorInfo, FC, ReactNode } from \"react\"\nimport { Component, useState } from \"react\"\n\nimport type { FallbackProps } from \"./DefaultFallback\"\nimport { DefaultFallback } from \"./DefaultFallback\"\n\nexport type ErrorBoundaryState = {\n\terror?: Error | string\n\terrorInfo?: ErrorInfo\n}\n\nexport type ErrorBoundaryProps = {\n\tchildren: ReactNode\n\tonError?: ((error: Error | string, errorInfo: ErrorInfo) => void) | undefined\n\tFallback?: FC<FallbackProps> | undefined\n\tuseResetErrorState?: () => () => void\n\tuseErrorState?: () => [\n\t\tErrorBoundaryState,\n\t\t(\n\t\t\tnewState:\n\t\t\t\t| ErrorBoundaryState\n\t\t\t\t| ((currState: ErrorBoundaryState) => ErrorBoundaryState),\n\t\t) => void,\n\t]\n}\n\nexport class ErrorBoundary extends Component<\n\tErrorBoundaryProps,\n\tErrorBoundaryState\n> {\n\tpublic constructor(props: ErrorBoundaryProps) {\n\t\tsuper(props)\n\t\tthis.state = {}\n\t\t// We can filter or add information\n\t\t// to airbrake notifications here:\n\t}\n\n\tpublic override componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n\t\tthis.props.onError?.(error, errorInfo)\n\t\tthis.setState({\n\t\t\terror,\n\t\t\terrorInfo,\n\t\t})\n\t}\n\n\tpublic override render(): ReactNode {\n\t\tconst { error, errorInfo } = this.state\n\t\tconst { children, Fallback = DefaultFallback } = this.props\n\n\t\treturn errorInfo ? (\n\t\t\t<Fallback error={error} errorInfo={errorInfo} />\n\t\t) : (\n\t\t\t(children as ReactNode)\n\t\t)\n\t}\n}\n\nexport const RecoverableErrorBoundary: FC<ErrorBoundaryProps> = ({\n\tchildren,\n\tFallback = DefaultFallback,\n\tuseErrorState = () => useState<ErrorBoundaryState>({}),\n\tuseResetErrorState,\n}) => {\n\tconst [{ error }, setError] = useErrorState()\n\tconst resetError = useResetErrorState\n\t\t? useResetErrorState()\n\t\t: () => setError({})\n\tconst hasError = Boolean(error)\n\n\treturn hasError ? (\n\t\t<div>\n\t\t\t<button type=\"button\" onClick={resetError}>\n\t\t\t\tReset\n\t\t\t</button>\n\t\t\t<ErrorBoundary Fallback={Fallback}>{children}</ErrorBoundary>\n\t\t</div>\n\t) : (\n\t\t<ErrorBoundary\n\t\t\tFallback={Fallback}\n\t\t\tonError={(newError, newErrorInfo) =>\n\t\t\t\tsetError({ error: newError, errorInfo: newErrorInfo })\n\t\t\t}\n\t\t>\n\t\t\t{children}\n\t\t</ErrorBoundary>\n\t)\n}\n","import type { ErrorInfo, FC } from \"react\"\n\nexport type FallbackProps = {\n\terror?: Error | string | undefined\n\terrorInfo?: ErrorInfo | undefined\n}\n\nexport const DefaultFallback: FC<FallbackProps> = ({ error, errorInfo }) => {\n\tconst component = errorInfo?.componentStack?.split(` `).filter(Boolean)[2]\n\tconst message =\n\t\terror?.toString() ?? errorInfo?.componentStack ?? `Unknown error`\n\treturn (\n\t\t<div\n\t\t\tdata-testid=\"error-boundary\"\n\t\t\tstyle={{\n\t\t\t\tflex: `1`,\n\t\t\t\tbackground: `black`,\n\t\t\t\tbackgroundImage: `url(./src/assets/kablooey.gif)`,\n\t\t\t\tbackgroundPosition: `center`,\n\t\t\t\t// backgroundRepeat: `no-repeat`,\n\t\t\t\tbackgroundSize: `overlay`,\n\t\t\t}}\n\t\t>\n\t\t\t{/* <img src=\"./src/assets/kablooey.gif\" alt=\"error\" /> */}\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tmargin: `50px`,\n\t\t\t\t\tmarginTop: `0`,\n\t\t\t\t\tpadding: `50px`,\n\t\t\t\t\tborder: `1px solid dashed`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<span\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackground: `black`,\n\t\t\t\t\t\tcolor: `white`,\n\t\t\t\t\t\tpadding: 10,\n\t\t\t\t\t\tpaddingTop: 5,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{`â ïž `}\n\t\t\t\t\t<span style={{ color: `#fc0`, fontWeight: 700 }}>{component}</span>\n\t\t\t\t\t{` â ïž `}\n\t\t\t\t\t{message}\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC, ReactNode } from \"react\"\n\nimport { ErrorBoundary } from \"../react-error-boundary\"\n\nexport type Dict<T> = Record<string, T>\n\nexport type WrapperComponent<T extends Dict<unknown> = Dict<unknown>> = FC<\n\tT & { children: ReactNode }\n>\n\nexport type WC<T extends Dict<unknown> = Dict<unknown>> = WrapperComponent<T>\n\nexport type JsonEditorComponents = {\n\tErrorBoundary: WC\n\n\tButton: WC<{ onClick: () => void; disabled: boolean }>\n\tDeleteIcon: FC\n\n\tEditorLayout: FC<{\n\t\tDeleteButton?: FC\n\t\tHeader?: FC\n\t\tKeyInput?: FC\n\t\tTypeSelect?: FC\n\t\tValueEditor: FC\n\t\tWrapper: WC\n\t}>\n\tEditorWrapper: WC<{\n\t\tcustomCss?: SerializedStyles | undefined\n\t\tclassName?: string | undefined\n\t}>\n\n\tArrayWrapper: WC\n\tObjectWrapper: WC\n\tStringWrapper: WC\n\tNumberWrapper: WC\n\tBooleanWrapper: WC\n\tNullWrapper: WC\n\n\tMiscastPropertyWrapper: WC\n\tMissingPropertyWrapper: WC\n\tOfficialPropertyWrapper: WC\n\tUnofficialPropertyWrapper: WC\n\tIllegalPropertyWrapper: WC\n\tKeyWrapper: WC\n}\n\nexport const DEFAULT_JSON_EDITOR_COMPONENTS: JsonEditorComponents = {\n\tErrorBoundary: ({ children }) => <ErrorBoundary>{children}</ErrorBoundary>,\n\tButton: ({ onClick, children, disabled }) => (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclassName=\"json_editor_button\"\n\t\t\tonClick={onClick}\n\t\t\tdisabled={disabled}\n\t\t>\n\t\t\t{children}\n\t\t</button>\n\t),\n\tEditorWrapper: ({ children, customCss, className }) => (\n\t\t<div className={`json_editor` + ` ` + className ?? ``} css={customCss}>\n\t\t\t{children}\n\t\t</div>\n\t),\n\tEditorLayout: ({\n\t\tDeleteButton,\n\t\tHeader,\n\t\tKeyInput,\n\t\tTypeSelect,\n\t\tValueEditor,\n\t\tWrapper,\n\t}) => {\n\t\treturn (\n\t\t\t<Wrapper>\n\t\t\t\t{DeleteButton && <DeleteButton />}\n\t\t\t\t{Header && <Header />}\n\t\t\t\t{KeyInput && <KeyInput />}\n\t\t\t\t{TypeSelect && <TypeSelect />}\n\t\t\t\t<ValueEditor />\n\t\t\t</Wrapper>\n\t\t)\n\t},\n\tArrayWrapper: ({ children }) => (\n\t\t<div className=\"json_editor_array\">{children}</div>\n\t),\n\tObjectWrapper: ({ children }) => (\n\t\t<div className=\"json_editor_object\">{children}</div>\n\t),\n\tStringWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_string\">{children}</span>\n\t),\n\tNumberWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_number\">{children}</span>\n\t),\n\tBooleanWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_boolean\">{children}</span>\n\t),\n\tNullWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_null\">{children}</span>\n\t),\n\tMissingPropertyWrapper: ({ children }) => (\n\t\t<div className=\"json_editor_property json_editor_missing\">{children}</div>\n\t),\n\tMiscastPropertyWrapper: ({ children }) => (\n\t\t<div className=\"json_editor_property json_editor_miscast\">{children}</div>\n\t),\n\tIllegalPropertyWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_property json_editor_illegal\">{children}</span>\n\t),\n\tOfficialPropertyWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_property json_editor_official\">{children}</span>\n\t),\n\tUnofficialPropertyWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_property json_editor_unofficial\">\n\t\t\t{children}\n\t\t</span>\n\t),\n\tDeleteIcon: () => (\n\t\t<span className=\"json_editor_icon json_editor_delete\">x</span>\n\t),\n\tKeyWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_key\">{children}</span>\n\t),\n}\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC, ReactElement } from \"react\"\nimport { useMemo } from \"react\"\n\nimport type { Json, JsonTypes } from \"~/packages/anvl/src/json\"\nimport type { JsonSchema } from \"~/packages/anvl/src/json-schema/json-schema\"\n\nimport type { JsonEditorComponents } from \"./default-components\"\nimport { DEFAULT_JSON_EDITOR_COMPONENTS } from \"./default-components\"\nimport { ArrayEditor } from \"./editors-by-type/array-editor\"\nimport { ObjectEditor } from \"./editors-by-type/object-editor\"\nimport {\n\tBooleanEditor,\n\tNullEditor,\n\tNumberEditor,\n\tStringEditor,\n} from \"./editors-by-type/primitive-editors\"\nimport type { JsonEditorProps_INTERNAL } from \"./json-editor-internal\"\nimport { JsonEditor_INTERNAL } from \"./json-editor-internal\"\n\nexport const SubEditors: Record<\n\tkeyof JsonTypes,\n\tFC<JsonEditorProps_INTERNAL<any>>\n> = {\n\tarray: ArrayEditor,\n\tboolean: BooleanEditor,\n\tnull: NullEditor,\n\tnumber: NumberEditor,\n\tobject: ObjectEditor,\n\tstring: StringEditor,\n}\n\nexport type JsonEditorProps<T extends Json.Serializable> = {\n\tdata: T\n\tset: (valOrUpdater: T | ((currVal: T) => T)) => void\n\tname?: string | undefined\n\trename?: ((newKey: string) => void) | undefined\n\tremove?: () => void\n\tschema?: JsonSchema\n\tpath?: ReadonlyArray<number | string>\n\tisReadonly?: (path: ReadonlyArray<number | string>) => boolean\n\tisHidden?: (path: ReadonlyArray<number | string>) => boolean\n\tclassName?: string\n\tcustomCss?: SerializedStyles\n\tHeader?: FC<{ data: T; schema?: JsonSchema }>\n\tComponents?: Partial<JsonEditorComponents>\n}\n\nexport const JsonEditor = <T extends Json.Serializable>({\n\tdata,\n\tset,\n\tschema = true,\n\tname,\n\trename,\n\tremove,\n\tisReadonly = () => false,\n\tisHidden = () => false,\n\t// isIllegal = () => false,\n\tclassName,\n\tcustomCss,\n\tHeader,\n\tComponents: CustomComponents = {},\n}: JsonEditorProps<T>): ReactElement => {\n\tconst Components = {\n\t\t...DEFAULT_JSON_EDITOR_COMPONENTS,\n\t\t...CustomComponents,\n\t}\n\n\treturn (\n\t\t<JsonEditor_INTERNAL\n\t\t\tdata={data}\n\t\t\tset={set}\n\t\t\tname={name}\n\t\t\tschema={schema}\n\t\t\trename={rename}\n\t\t\tremove={remove}\n\t\t\tpath={[]}\n\t\t\tisReadonly={isReadonly}\n\t\t\tisHidden={isHidden}\n\t\t\tclassName={className}\n\t\t\tcustomCss={customCss}\n\t\t\tHeader={Header}\n\t\t\tComponents={Components}\n\t\t/>\n\t)\n}\n","import type { FC } from \"react\"\n\nimport type { JsonTypes } from \"~/packages/anvl/src/json\"\n\nimport { ArrayEditor } from \"./editors-by-type/array-editor\"\nimport { ObjectEditor } from \"./editors-by-type/object-editor\"\nimport {\n\tBooleanEditor,\n\tNullEditor,\n\tNumberEditor,\n\tStringEditor,\n} from \"./editors-by-type/primitive-editors\"\nimport type { JsonEditorProps_INTERNAL } from \"./json-editor-internal\"\n\nexport * from \"./default-components\"\nexport * from \"./developer-interface\"\n\nexport const SubEditors: Record<\n\tkeyof JsonTypes,\n\tFC<JsonEditorProps_INTERNAL<any>>\n> = {\n\tarray: ArrayEditor,\n\tboolean: BooleanEditor,\n\tnull: NullEditor,\n\tnumber: NumberEditor,\n\tobject: ObjectEditor,\n\tstring: StringEditor,\n}\n","import {\n\tFloatingPortal,\n\tuseClick,\n\tuseFloating,\n\tuseInteractions,\n} from \"@floating-ui/react\"\nimport * as React from \"react\"\nimport { pipe } from \"~/packages/anvl/src/function\"\n\nimport { stringToColor } from \"~/packages/anvl/src/string/string-to-color\"\nimport { contrastMax, hexToSpec, offset, specToHex } from \"~/packages/luum/src\"\n\nexport const Id: React.FC<{ id: string }> = ({ id }) => {\n\tconst [isOpen, setIsOpen] = React.useState(false)\n\tconst { refs, floatingStyles, context } = useFloating({\n\t\topen: isOpen,\n\t\tonOpenChange: setIsOpen,\n\t\tplacement: `bottom-start`,\n\t})\n\n\tconst click = useClick(context)\n\tconst { getReferenceProps, getFloatingProps } = useInteractions([click])\n\n\tconst bgColor = stringToColor(id)\n\tconst contrastColor = pipe(bgColor, hexToSpec, contrastMax, specToHex)\n\tconst offsetColor = pipe(bgColor, hexToSpec, offset(0.25), specToHex)\n\tconst contrastOffsetColor = pipe(\n\t\toffsetColor,\n\t\thexToSpec,\n\t\tcontrastMax,\n\t\tspecToHex,\n\t)\n\n\treturn (\n\t\t<>\n\t\t\t<span\n\t\t\t\trole=\"content\"\n\t\t\t\tref={refs.setReference}\n\t\t\t\t{...getReferenceProps()}\n\t\t\t\tstyle={{\n\t\t\t\t\tbackground: bgColor,\n\t\t\t\t\tcursor: `pointer`,\n\t\t\t\t\tpadding: `0px 4px`,\n\t\t\t\t\tcolor: contrastColor,\n\t\t\t\t\tuserSelect: `none`,\n\t\t\t\t\twhiteSpace: `nowrap`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{id.substring(0, 3)}\n\t\t\t</span>\n\t\t\t{isOpen && (\n\t\t\t\t<FloatingPortal>\n\t\t\t\t\t<span\n\t\t\t\t\t\trole=\"popup\"\n\t\t\t\t\t\tref={refs.setFloating}\n\t\t\t\t\t\t{...getFloatingProps()}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t...floatingStyles,\n\t\t\t\t\t\t\tcolor: contrastOffsetColor,\n\t\t\t\t\t\t\tbackground: offsetColor,\n\t\t\t\t\t\t\tpadding: `0px 4px`,\n\t\t\t\t\t\t\tboxShadow: `0px 2px 10px rgba(0, 0, 0, 0.1)`,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{id}\n\t\t\t\t\t</span>\n\t\t\t\t</FloatingPortal>\n\t\t\t)}\n\t\t</>\n\t)\n}\n","export function stringToColor(input: string): string {\n\tlet hash = 0\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst char = input.charCodeAt(i)\n\t\thash = (hash << 5) - hash + char\n\t\thash |= 0 // Convert to 32-bit integer\n\t}\n\tlet hexColor = (hash & 0xffffff).toString(16) // Reduce to 24-bit\n\t// Pad with zeros to ensure it's 6 digits long (24-bit)\n\twhile (hexColor.length < 6) {\n\t\thexColor = `0` + hexColor\n\t}\n\treturn `#${hexColor}`\n}\n","export const HUE_STRUCTURES = {\n\tnone: [],\n\tpolar: [180],\n\tsplit: [150, 210],\n\ttrine: [120, 240],\n\tsquare: [90, 180, 270],\n}\nexport const CHANNEL_SPECIFIC_LUM = {\n\tR: 0.3,\n\tG: 0.5,\n\tB: 0.2,\n}\n/*\nconst I'M_WONDERING_IF_THIS_IS_NOT_VERY_ACCURATE = {\n R: 0.2126,\n G: 0.7152,\n B: 0.0722,\n}\n*/\n","import type { Filter } from \"~/packages/luum/src\"\n\nexport const unfiltered: Filter = [\n\t{ sat: 255, hue: 0 },\n\t{ sat: 255, hue: 360 },\n]\nexport const CMYK: Filter = [\n\t{ sat: 255, hue: 55 },\n\t{ sat: 127, hue: 120 },\n\t{ sat: 255, hue: 200 },\n\t{ sat: 255, hue: 205 },\n\t{ sat: 170, hue: 240 },\n\t{ sat: 230, hue: 270 },\n\t{ sat: 210, hue: 300 },\n\t{ sat: 255, hue: 320 },\n]\n","import type { ChannelObject, Hex } from \"~/packages/luum/src\"\n\nconst channelsToHex = (channels: ChannelObject): Hex =>\n\t`#${Object.values(channels)\n\t\t.map((channel) => {\n\t\t\tlet channelHex = channel.toString(16)\n\t\t\tif (channelHex.length === 1) channelHex = 0 + channelHex\n\t\t\treturn channelHex\n\t\t})\n\t\t.join(``)}`\n\nexport default channelsToHex\n","import { wrapInto } from \"~/packages/anvl/src/number\"\n\nimport type { Degree, Fraction } from \"..\"\n\n/**\n * Gives us the relative values of the channels,\n * irrespective of the white light beneath them.\n * @param {number} hue - in degrees. Gets safely wrapped around first thing.\n *\n * Digital Red 0 -> 0\n *\n * Sunlight 50 -> 50\n *\n * Digital Yellow 60 -> 60\n *\n * Citron 70 -> 70\n *\n * Turquoise 510 -> 150\n *\n * @const {number} hueReduced - hue 0-359.9 is now a floating point 0-5.999.\n *\n * Digital Red 0 -> 0 ~ 0.000\n *\n * Sunlight 50 -> 5/6 ~ 0.833\n *\n * Digital Yellow 60 -> 1 ~ 1.000\n *\n * Citron 70 -> 7/6 ~ 1.167\n *\n * Turquoise 150 -> 5/2 ~ 2.500\n *\n * @const {number} hueInteger - from 1-6. Tells us what color region we are in.\n *\n * Digital Red 0.000 -> 0\n * : red-into-yellow region\n *\n * Sunlight 0.833 -> 0\n * : red-into-yellow region\n *\n * Digital Yellow 1.000 -> 1\n * : yellow-into-green region\n *\n * Citron 1.167 -> 1\n * : yellow-into-green region\n *\n * Turquoise 2.500 -> 2\n * : green-into-cyan region\n *\n * hueInteger is the 'whole number' piece of hueReduced.\n * FYI, the six color regions are bounded by red, yellow, green, cyan, blue, magenta.\n *\n * @const {number} hueDecimal - tells where we are in this region.\n *\n * Digital Red 0.000 -> 0.000\n * : at the very beginning\n *\n * Sunlight 0.833 -> 0.833\n * : near the end\n *\n * Digital Yellow 1.000 -> 0.000\n * : at the very beginning\n *\n * Citron 1.167 -> 0.167\n * : near the beginning\n *\n * Turquoise 2.500 -> 0.500\n * : at the halfway point\n *\n * hueDecimal is the 'fraction' piece of hueReduced.\n * we are going to use this number to determine the value of the in-between channel.\n *\n * @const {number} x - used in primary-secondary transitions like Red into Yellow\n * @const {number} y - used in secondary-primary transitions like Yellow into Green\n * To understand the function of x and y, take the difference between\n *\n * Sunlight (hue 50),\n * Citron (hue 70),\n * Digital Yellow (hue 60),\n *\n * as an instructive case. These colors are all basically yellow.\n *\n * Sunlight is hue 50, which puts it near the end of the red-into-yellow region.\n *\n * This means its Red channel is full, and its Green channel is almost full.\n * The fullness of its Green channel is directly proportional to its\n * hueDecimal, the distance from the beginning of this region: 0.833\n *\n * Citron is hue 70, which puts it near the beginning of the yellow-into-green region.\n *\n * This means its Red channel is ALMOST FULL, and its Green channel is FULL.\n * So the fullness of its Red channel is INVERSELY proportional to its\n * hueDecimal, the distance from the beginning of this region: 1 - 0.167 = 0.833\n *\n * Digital Yellow is hue 60, which puts it at the very beginning of the yellow-into-green region.\n *\n * This means its Red Channel and its Green channel must both be full.\n * Like Citron, the fullness of Digital Yellow's Red channel is inversely proportional to its\n * hueDecimal, which is 0. Therefore Digital Yellow's Red channel has a fullness of 1.\n *\n * @returns array of values reflecting the spread between channels\n *\n * Digital Red case 0: [ R ===== 1 G = x = 0.000 B ===== 0 ]\n *\n * Sunlight case 0: [ R ===== 1 G = x = 0.833 B ===== 0 ]\n *\n * DigitalYellow case 1: [ R = y = 1.000 G ===== 1 B ===== 0 ]\n *\n * Citron case 1: [ R = y = 0.833 G ===== 1 B ===== 0 ]\n *\n * Turquoise case 2: [ R ===== 0 G ===== 1 B = x = 0.500 ]\n *\n * here we see detailed breakdowns of the function's final output for our running examples.\n */\nexport default (hue: Degree): [r: Fraction, g: Fraction, b: Fraction] => {\n\tconst hueWrapped = wrapInto(0, 360)(hue)\n\tconst hueReduced = hueWrapped / 60\n\tconst hueInteger = Math.floor(hueReduced)\n\tconst hueDecimal = hueReduced - hueInteger\n\tconst x = hueDecimal\n\tconst y = 1 - hueDecimal\n\tswitch (hueInteger) {\n\t\tcase 0:\n\t\t\treturn [1, x, 0]\n\t\tcase 1:\n\t\t\treturn [y, 1, 0]\n\t\tcase 2:\n\t\t\treturn [0, 1, x]\n\t\tcase 3:\n\t\t\treturn [0, y, 1]\n\t\tcase 4:\n\t\t\treturn [x, 0, 1]\n\t\tcase 5:\n\t\t\treturn [1, 0, y]\n\t\tdefault:\n\t\t\tthrow new Error(`invalid hue served: ${hue}`)\n\t}\n}\n","import type { ChannelObject } from \"~/packages/luum/src\"\n\nconst hueFromChannels = ({ R, G, B }: ChannelObject): number => {\n\tlet hue = 0\n\tif (R > G && G >= B) hue = 60 * (0 + (G - B) / (R - B))\n\tif (G >= R && R > B) hue = 60 * (2 - (R - B) / (G - B))\n\tif (G > B && B >= R) hue = 60 * (2 + (B - R) / (G - R))\n\tif (B >= G && G > R) hue = 60 * (4 - (G - R) / (B - R))\n\tif (B > R && R >= G) hue = 60 * (4 + (R - G) / (B - G))\n\tif (R >= B && B > G) hue = 60 * (6 - (B - G) / (R - G))\n\treturn hue\n}\n\nexport default hueFromChannels\n","import type { ChannelObject } from \"~/packages/luum/src\"\n\nimport { CHANNEL_SPECIFIC_LUM } from \"../constants\"\n\nconst lumFromChannels = ({ R, G, B }: ChannelObject): number => {\n\tconst lum =\n\t\t(CHANNEL_SPECIFIC_LUM.R * R) / 255 +\n\t\t(CHANNEL_SPECIFIC_LUM.G * G) / 255 +\n\t\t(CHANNEL_SPECIFIC_LUM.B * B) / 255\n\t// console.log('||| found lum', lum)\n\treturn lum\n}\n\nexport default lumFromChannels\n","import { wrapInto } from \"~/packages/anvl/src/number\"\nimport type { Degree, Filter } from \"~/packages/luum/src\"\n\nexport default (hue: Degree, filter: Filter): number => {\n\t// 430\n\tlet maxSat = 255\n\tconst hueWrapped = wrapInto(0, 360)(hue) // 70\n\tfor (let a = -1, b = 0; b < filter.length; a++, b++) {\n\t\ta = wrapInto(0, filter.length)(a)\n\t\t// console.log('||| a =', a, 'b =', b)\n\t\tconst hueDoubleWrapped = a > b ? wrapInto(-180, 180)(hueWrapped) : undefined // undef\n\t\tconst tuningPointA = filter[a]\n\t\tconst tuningPointB = filter[b]\n\t\tconst hueA = a > b ? wrapInto(-180, 180)(tuningPointA.hue) : tuningPointA.hue\n\t\tconst hueB = tuningPointB.hue\n\t\tif (\n\t\t\t(hueDoubleWrapped || hueWrapped) >= hueA &&\n\t\t\t(hueDoubleWrapped || hueWrapped) < hueB\n\t\t) {\n\t\t\t// console.log(\n\t\t\t// '||| hue', hue, 'between', tuningPointA.hue, 'and', tuningPointB.hue\n\t\t\t// )\n\t\t\tlet $ = hueDoubleWrapped || hueWrapped // 70\n\t\t\t$ -= hueA // 70 - 50 = 20 //\n\t\t\t$ /= hueB - hueA // 20 / (120 - 50) = 2/7\n\t\t\t$ *= tuningPointB.sat - tuningPointA.sat // -128 * 2 / 7 = -256 / 7 ~= -37\n\t\t\t$ += tuningPointA.sat\n\t\t\tMath.round($)\n\t\t\t// console.log('||| _', _)\n\t\t\tmaxSat = $\n\t\t}\n\t}\n\t// console.log('--- maxSat', maxSat)\n\treturn maxSat\n}\n","import type { ChannelObject } from \"~/packages/luum/src\"\n\nconst satFromChannels = ({ R, G, B }: ChannelObject): number => {\n\tconst sat = Math.max(R, G, B) - Math.min(R, G, B)\n\t// console.log('||| found sat', sat)\n\treturn sat\n}\n\nexport default satFromChannels\n","import { CHANNEL_SPECIFIC_LUM } from \"../constants\"\nimport hueToRelativeChannels from \"../import/hueToRelativeChannels\"\n\nexport default (hue: number): number => {\n\tconst [factorR, factorG, factorB] = hueToRelativeChannels(hue)\n\n\tconst lumR = CHANNEL_SPECIFIC_LUM.R * factorR\n\tconst lumG = CHANNEL_SPECIFIC_LUM.G * factorG\n\tconst lumB = CHANNEL_SPECIFIC_LUM.B * factorB\n\n\tconst specificLum = lumR + lumG + lumB\n\n\treturn specificLum\n}\n","import { clampInto } from \"~/packages/anvl/src/number\"\nimport type {\n\tChannelObject,\n\tDegree,\n\tFilter,\n\tFraction,\n\tLuumSpec,\n\tOutOf255,\n\tRange,\n} from \"~/packages/luum/src\"\n\nimport { unfiltered } from \"../constants/filters\"\nimport hueToRelativeChannels from \"../import/hueToRelativeChannels\"\nimport {\n\tlumFromChannels,\n\tmaxSatForHueInFilter,\n\tspecificLumFromHue,\n} from \"../solveFor\"\n\nconst minChannelsForSaturationFromHue = (hue: Degree) => {\n\tconst relativeChannels = hueToRelativeChannels(hue)\n\tconst channelSpreader = (trueSaturation: OutOf255): ChannelObject => {\n\t\tconst makeMinChannel = (idx: number) =>\n\t\t\tMath.round(relativeChannels[idx] * trueSaturation)\n\t\treturn {\n\t\t\tR: makeMinChannel(0),\n\t\t\tG: makeMinChannel(1),\n\t\t\tB: makeMinChannel(2),\n\t\t}\n\t}\n\treturn channelSpreader\n}\n\ntype IlluminationObj = {\n\tminChannels: ChannelObject\n\ttrueLuminosity: number\n\tminLum: number\n}\n\nconst channelsFromIlluminationObj = ({\n\tminChannels,\n\ttrueLuminosity,\n\tminLum,\n}: IlluminationObj): ChannelObject => {\n\tconst { max, round } = Math\n\tconst maxWhite = 255 - max(...Object.values(minChannels))\n\tconst white = clampInto(0, maxWhite)(round((trueLuminosity - minLum) * 255))\n\tconst channels = {\n\t\tR: minChannels.R + white,\n\t\tG: minChannels.G + white,\n\t\tB: minChannels.B + white,\n\t}\n\treturn channels\n}\n\ntype SpecToChannelsFixLimit = (\n\tspec: LuumSpec,\n\tfilter?: Filter,\n) => {\n\tchannels: ChannelObject\n\tfix: { sat: number; lum: number }\n\tlimit: { sat: Range; lum: Range }\n}\n\nconst specToChannelsFixLimit: SpecToChannelsFixLimit = (\n\t{ hue, sat, lum, prefer = `lum` },\n\tfilter = unfiltered,\n) => {\n\tconst minChannelsForSaturation = minChannelsForSaturationFromHue(hue)\n\n\tlet trueSaturation: OutOf255\n\tlet trueLuminosity: Fraction\n\tlet minChannels: ChannelObject\n\tlet maxChannels: ChannelObject\n\tlet specificLum: Fraction\n\tlet minLum = 0\n\tlet maxLum = 1\n\tlet maxSat = maxSatForHueInFilter(hue, filter)\n\n\tswitch (prefer) {\n\t\tcase `sat`:\n\t\t\ttrueSaturation = clampInto(0, 255)(Math.min(sat, maxSat))\n\t\t\tminChannels = minChannelsForSaturation(trueSaturation)\n\t\t\tmaxChannels = {\n\t\t\t\tR: minChannels.R + 255 - trueSaturation,\n\t\t\t\tG: minChannels.G + 255 - trueSaturation,\n\t\t\t\tB: minChannels.B + 255 - trueSaturation,\n\t\t\t}\n\t\t\tminLum = lumFromChannels(minChannels)\n\t\t\tmaxLum = lumFromChannels(maxChannels)\n\t\t\ttrueLuminosity = clampInto(minLum, maxLum)(lum)\n\n\t\t\tbreak\n\t\tcase `lum`:\n\t\t\ttrueLuminosity = clampInto(0, 1)(lum)\n\t\t\tspecificLum = specificLumFromHue(hue)\n\t\t\tmaxSat = Math.min(\n\t\t\t\tmaxSat,\n\t\t\t\tMath.round(\n\t\t\t\t\ttrueLuminosity <= specificLum\n\t\t\t\t\t\t? 255 * (trueLuminosity / specificLum)\n\t\t\t\t\t\t: (255 * (1 - trueLuminosity)) / (1 - specificLum),\n\t\t\t\t),\n\t\t\t)\n\t\t\ttrueSaturation = Math.min(sat, maxSat)\n\t\t\tminChannels = minChannelsForSaturation(trueSaturation)\n\t\t\tminLum = lumFromChannels(minChannels)\n\t\t\tbreak\n\t}\n\n\tconst channels = channelsFromIlluminationObj({\n\t\tminChannels,\n\t\ttrueLuminosity,\n\t\tminLum,\n\t})\n\n\treturn {\n\t\tchannels,\n\t\tfix: {\n\t\t\tsat: trueSaturation,\n\t\t\tlum: trueLuminosity,\n\t\t},\n\t\tlimit: {\n\t\t\tsat: [0, maxSat],\n\t\t\tlum: [prefer === `lum` ? 0 : minLum, maxLum],\n\t\t},\n\t}\n}\n\nexport default specToChannelsFixLimit\n","import type {\n\tFilter,\n\tHex,\n\tLuumFix,\n\tLuumLimit,\n\tLuumSpec,\n} from \"~/packages/luum/src\"\n\nimport channelsToHex from \"./channelsToHex\"\nimport specToChannels from \"./specToChannelsFixLimit\"\n\ntype SpecToHexFixLimit = (\n\tspec: LuumSpec,\n\tfilter?: Filter,\n) => {\n\thex: Hex\n\tfix: LuumFix\n\tlimit: LuumLimit\n}\n\nconst specToHexFixLimit: SpecToHexFixLimit = (\n\t{ hue, sat, lum, prefer },\n\tfilter,\n) => {\n\tconst { channels, fix, limit } = specToChannels(\n\t\t{\n\t\t\thue,\n\t\t\tsat,\n\t\t\tlum,\n\t\t\tprefer,\n\t\t},\n\t\tfilter,\n\t)\n\tconst { R, G, B } = channels\n\tconst hex = channelsToHex({ R, G, B })\n\n\t// console.log('--- newHex', hex)\n\n\treturn { hex, fix, limit }\n}\n\nexport default specToHexFixLimit\n","import type { Filter, Hex, LuumSpec } from \"~/packages/luum/src\"\n\nimport specToHexFixLimit from \"./specToHexFixLimit\"\n\nconst specToHex = (\n\t{ hue, sat, lum, prefer }: LuumSpec,\n\tfilter?: Filter,\n): Hex => {\n\tconst { hex } = specToHexFixLimit({ hue, sat, lum, prefer }, filter)\n\treturn hex\n}\n\nexport default specToHex\n","import type { ChannelObject, HSL } from \"~/packages/luum/src\"\n\nimport { hueFromChannels, lumFromChannels, satFromChannels } from \"../solveFor\"\n\nconst channelsToSpec = ({ R, G, B }: ChannelObject): HSL => {\n\tconst hue = hueFromChannels({ R, G, B })\n\tconst sat = satFromChannels({ R, G, B })\n\tconst lum = lumFromChannels({ R, G, B })\n\treturn { hue, sat, lum }\n}\n\nexport default channelsToSpec\n","import type { Hex } from \"..\"\n\nconst BASE_16_CHAR_SET = `[a-fA-F0-9]+`\n\nconst miniHexToHex = (miniHex: string): Hex => {\n\tconst miniHexArray = miniHex.split(``)\n\tconst hexTemplate = [0, 0, 1, 1, 2, 2]\n\treturn hexTemplate.map((idx) => miniHexArray[idx]).join(``)\n}\n\nconst normalizeHex = (maybeHex: string): Hex => {\n\tconst hex = maybeHex.replace(/^#/, ``)\n\tconst hexIsCorrectLength = hex.length === 6 || hex.length === 3\n\tconst hexIsCorrectCharSet =\n\t\thex.match(new RegExp(`^${BASE_16_CHAR_SET}$`)) !== null\n\tconst hexIsValid = hexIsCorrectLength && hexIsCorrectCharSet\n\tif (!hexIsValid) {\n\t\tthrow new Error(`${maybeHex} is not a valid hex code`)\n\t}\n\tif (hex.length === 3) {\n\t\treturn miniHexToHex(hex)\n\t}\n\treturn hex\n}\n\nexport default normalizeHex\n","import type { ChannelObject } from \"..\"\nimport normalizeHex from \"./normalizeHex\"\n\nexport default (maybeHex: string): ChannelObject => {\n\tconst hex = normalizeHex(maybeHex)\n\n\treturn {\n\t\tR: parseInt(hex.slice(0, 2), 16),\n\t\tG: parseInt(hex.slice(2, 4), 16),\n\t\tB: parseInt(hex.slice(4, 6), 16),\n\t}\n}\n","import type { HSL } from \"..\"\nimport channelsToSpec from \"./channelsToSpec\"\nimport hexToChannels from \"./hexToChannels\"\n\nconst hexToSpec = (hex: string): HSL => {\n\tconst { R, G, B } = hexToChannels(hex)\n\tconst { hue, sat, lum } = channelsToSpec({ R, G, B })\n\treturn { hue, sat, lum }\n}\n\nexport default hexToSpec\n","import type { Modifier } from \"~/packages/anvl/src/function\"\nimport { become, pipe } from \"~/packages/anvl/src/function\"\nimport { clampInto } from \"~/packages/anvl/src/number/clamp\"\nimport type { HSL, LuumSpec } from \"~/packages/luum/src\"\n\nimport type { LuumApplicator } from \".\"\nimport { hexToSpec, specToHex } from \"..\"\n\nexport const resetColor = (color: LuumSpec): LuumSpec =>\n\tpipe(color, specToHex, hexToSpec, (hsl: HSL) => ({\n\t\t...hsl,\n\t\tprefer: color.prefer,\n\t}))\n\nexport const setLum: LuumApplicator<number> = (newLum) => (currentColor) => {\n\tconst newColor = {\n\t\t...currentColor,\n\t\tlum: pipe(currentColor.lum, become(newLum), clampInto(0, 1)),\n\t}\n\treturn newColor\n}\nexport const tintBy =\n\t(tintAmount: number): Modifier<LuumSpec> =>\n\t(color) =>\n\t\tsetLum((lum) => (lum * 100 + tintAmount) / 100)(resetColor(color))\n\nexport const shadeBy =\n\t(shadeAmount: number): Modifier<LuumSpec> =>\n\t(color) =>\n\t\tsetLum((lum) => (lum * 100 - shadeAmount) / 100)(resetColor(color))\n\nexport const tint = (color: LuumSpec, tintAmount: number): LuumSpec =>\n\ttintBy(tintAmount)(color)\n\nexport const shade = (color: LuumSpec, shadeAmount: number): LuumSpec =>\n\tshadeBy(shadeAmount)(color)\n","import type { Modifier } from \"~/packages/anvl/src/function\"\nimport type { HSL, LuumSpec } from \"~/packages/luum/src\"\n\nexport const contrastMax: Modifier<LuumSpec> = (color) => ({\n\t...color,\n\tlum: color.lum > 0.666 ? 0 : 1,\n})\n\nexport const contrastStrong: Modifier<LuumSpec> = (color) => ({\n\t...color,\n\tlum: color.lum > 0.666 ? 0.05 : 0.95,\n})\n\nexport const contrastSoft: Modifier<LuumSpec> = (color) =>\n\tcolor.lum > 0.75\n\t\t? { ...color, lum: color.lum / 2 }\n\t\t: color.lum < 0.25\n\t\t ? { ...color, lum: color.lum + (1 - color.lum) / 2 }\n\t\t : { ...color, lum: color.lum > 0.666 ? 1 : 0 }\n\nexport const offset =\n\t(offsetAmount: number): Modifier<HSL> =>\n\t(color) => ({\n\t\t...color,\n\t\tlum: color.lum > 0.666 ? color.lum - offsetAmount : color.lum + offsetAmount,\n\t})\n","import type { LuumSpec } from \"~/packages/luum/src\"\n\nexport const defaultSpec: LuumSpec = {\n\thue: 0,\n\tlum: 0,\n\tsat: 0,\n\tprefer: `lum`,\n}\n","import { content, each, isArray, join, map } from \"~/packages/anvl/src/array\"\nimport { isModifier, pipe } from \"~/packages/anvl/src/function\"\nimport type { Modifier, OneOrMany } from \"~/packages/anvl/src/function\"\nimport { isUndefined } from \"~/packages/anvl/src/nullish\"\nimport { key } from \"~/packages/anvl/src/object/access\"\nimport { isString } from \"~/packages/anvl/src/primitive\"\nimport type { Refinement } from \"~/packages/anvl/src/refinement\"\nimport { specToHex } from \"~/packages/luum/src\"\nimport type { Filter, FilterPoint, LuumSpec } from \"~/packages/luum/src\"\nimport { defaultSpec } from \"~/packages/luum/src/constants/luum-spec\"\nimport { shadeBy } from \"~/packages/luum/src/mixers/lum\"\n\n/* eslint-disable max-lines */\n\n// export type InteractiveStates = `active` | `base` | `disabled` | `hover`\n\n// export const HTML_ELEMENT_NAMES = [\n// `a`,\n// `abbr`,\n// `address`,\n// `area`,\n// `article`,\n// `aside`,\n// `audio`,\n// `b`,\n// `base`,\n// `bdi`,\n// `bdo`,\n// `big`,\n// `blockquote`,\n// `body`,\n// `br`,\n// `button`,\n// `canvas`,\n// `caption`,\n// `cite`,\n// `code`,\n// `col`,\n// `colgroup`,\n// `data`,\n// `datalist`,\n// `dd`,\n// `del`,\n// `details`,\n// `dfn`,\n// `dialog`,\n// `div`,\n// `dl`,\n// `dt`,\n// `em`,\n// `embed`,\n// `fieldset`,\n// `figcaption`,\n// `figure`,\n// `footer`,\n// `form`,\n// `h1`,\n// `h2`,\n// `h3`,\n// `h4`,\n// `h5`,\n// `h6`,\n// `head`,\n// `header`,\n// `hgroup`,\n// `hr`,\n// `html`,\n// `i`,\n// `iframe`,\n// `img`,\n// `input`,\n// `ins`,\n// `kbd`,\n// `keygen`,\n// `label`,\n// `legend`,\n// `li`,\n// `link`,\n// `main`,\n// `map`,\n// `mark`,\n// `menu`,\n// `menuitem`,\n// `meta`,\n// `meter`,\n// `nav`,\n// `noscript`,\n// `object`,\n// `ol`,\n// `optgroup`,\n// `option`,\n// `output`,\n// `p`,\n// `param`,\n// `picture`,\n// `pre`,\n// `progress`,\n// `q`,\n// `rp`,\n// `rt`,\n// `ruby`,\n// `s`,\n// `samp`,\n// `script`,\n// `section`,\n// `select`,\n// `small`,\n// `source`,\n// `span`,\n// `strong`,\n// `style`,\n// `sub`,\n// `summary`,\n// `sup`,\n// `table`,\n// `tbody`,\n// `td`,\n// `textarea`,\n// `tfoot`,\n// `th`,\n// `thead`,\n// `time`,\n// `title`,\n// `tr`,\n// `track`,\n// `u`,\n// `ul`,\n// `var`,\n// `video`,\n// `wbr`,\n// ] as const\n\n// export type HTMLElementName = typeof HTML_ELEMENT_NAMES[number]\n\n// export type UniversalSelector = `*`\n\n// export type TypeSelector = HTMLElementName | `body` | `html`\n\n// export type ClassSelector = `.${string}`\n\n// export type IdSelector = `#${string}`\n\n// export type ParentSelector = `&`\n\n// export type AttributeSelector = `[\"${string}\"=\"${string}\"]`\n\n// export type CssSelectorCore =\n// | AttributeSelector\n// | ClassSelector\n// | IdSelector\n// | ParentSelector\n// | TypeSelector\n// | UniversalSelector\n\n// export type CssCombinator = ` ` | ` + ` | ` > ` | ` ~ `\n\nexport const CSS_PSEUDO_CLASSES = [\n\t`:active`,\n\t`:checked`,\n\t`:disabled`,\n\t`:enabled`,\n\t`:focus`,\n\t`:hover`,\n\t`:indeterminate`,\n\t`:visited`,\n] as const\n\nexport type CssPseudoClass = (typeof CSS_PSEUDO_CLASSES)[number]\n\nexport const isCssPseudoClass = (s: unknown): s is CssPseudoClass =>\n\tCSS_PSEUDO_CLASSES.includes(s as CssPseudoClass)\n\n// export type CssPseudoElement =\n// | `::after`\n// | `::backdrop`\n// | `::before`\n// | `::first-letter`\n// | `::first-line`\n// | `::placeholder`\n// | `::selection`\n\n// export type CssSelectorExtension =\n// | AttributeSelector\n// | ClassSelector\n// | CssPseudoClass\n// | CssPseudoElement\n// | `${CssCombinator}${CssSelectorCore}`\n\n// export type CssSelector =\n// | CssSelectorCore\n// | `${CssSelectorCore}${CssSelectorExtension}`\n\nexport const CSS_COLOR_PROPERTY_KEYS = [\n\t`background-color`,\n\t`background`,\n\t`border-bottom-color`,\n\t`border-color`,\n\t`border-left-color`,\n\t`border-right-color`,\n\t`border-top-color`,\n\t`border`,\n\t`box-shadow`,\n\t`caret-color`,\n\t`color`,\n\t`column-rule-color`,\n\t`column-rule`,\n\t`filter`,\n\t`opacity`,\n\t`outline-color`,\n\t`outline`,\n\t`text-decoration-color`,\n\t`text-decoration`,\n\t`text-shadow`,\n\n\t`fill`,\n\t`stroke`,\n] as const\n\nexport type CssVariable = `--${string}`\n\nexport type CssColorPropertyKey =\n\t| (typeof CSS_COLOR_PROPERTY_KEYS)[number]\n\t| CssVariable\n\nexport const isCssColorPropertyKey = (\n\tinput: unknown,\n): input is CssColorPropertyKey =>\n\ttypeof input === `string` &&\n\t(CSS_COLOR_PROPERTY_KEYS.includes(\n\t\tinput as (typeof CSS_COLOR_PROPERTY_KEYS)[number],\n\t) ||\n\t\tinput.startsWith(`--`))\n\nexport const isFilterPoint = (input: unknown): input is FilterPoint =>\n\ttypeof input === `object` &&\n\ttypeof (input as FilterPoint).hue === `number` &&\n\ttypeof (input as FilterPoint).sat === `number`\n\nexport const isFilter = (input: unknown): input is Filter =>\n\tisArray(isFilterPoint)(input)\n\nexport const maybe =\n\t<T>(validate: Refinement<unknown, T>) =>\n\t(input: unknown): input is T | undefined =>\n\t\tisUndefined(input) || validate(input)\n\nexport const isLuumSpec = (input: unknown): input is LuumSpec =>\n\ttypeof input === `object` &&\n\tinput !== null &&\n\ttypeof (input as LuumSpec).hue === `number` &&\n\ttypeof (input as LuumSpec).sat === `number` &&\n\ttypeof (input as LuumSpec).lum === `number` &&\n\t[`sat`, `lum`].includes((input as LuumSpec).prefer)\n\nexport const isLuumSpecModifier: Refinement<\n\tunknown,\n\tModifier<LuumSpec>\n> = isModifier(isLuumSpec)(defaultSpec)\n\nexport type LuumCssAttribute = [\n\tkeys: OneOrMany<CssColorPropertyKey>,\n\ttransformers: OneOrMany<Modifier<LuumSpec>>,\n]\nexport const isLuumCssAttribute = (input: unknown): input is LuumCssAttribute =>\n\tArray.isArray(input) &&\n\tinput.length === 2 &&\n\tcontent(isCssColorPropertyKey)(input[0]) &&\n\tcontent(isLuumSpecModifier)(input[1])\n\nexport type LuumScssPseudoClassRule = [\n\tselectors: OneOrMany<CssPseudoClass>,\n\tattributes: OneOrMany<LuumCssAttribute>,\n]\n\nexport const isLuumScssPseudoClassRule = (\n\tinput: unknown,\n): input is LuumScssPseudoClassRule =>\n\tArray.isArray(input) &&\n\tinput.length === 2 &&\n\tcontent(isCssPseudoClass)(input[0]) &&\n\tcontent(isLuumCssAttribute)(input[1])\n\nexport type LuumScssNestedRule = [\n\tselectors: OneOrMany<string>,\n\tattributes: OneOrMany<LuumCssAttribute>,\n]\n\nexport const isLuumScssNestedRule = (\n\tinput: unknown,\n): input is LuumScssNestedRule =>\n\tArray.isArray(input) &&\n\tinput.length === 2 &&\n\tcontent(isString)(input[0]) &&\n\tcontent(isLuumCssAttribute)(input[1])\n\nexport type LuumCssRule = {\n\trootSelectors?: OneOrMany<string>\n\troot: LuumSpec\n\tattributes: OneOrMany<LuumCssAttribute>\n\tfilter?: Filter\n}\n\nexport const isLuumCssRule = (input: unknown): input is LuumCssRule =>\n\ttypeof input === `object` &&\n\tinput !== null &&\n\tisLuumSpec((input as LuumCssRule).root) &&\n\tcontent(isLuumCssAttribute)(key<LuumCssRule>(`attributes`)(input)) &&\n\tmaybe(content(isString))(key<LuumCssRule>(`rootSelectors`)(input)) &&\n\tmaybe(isFilter)(key<LuumCssRule>(`filter`)(input))\n\nexport type LuumScssRule = LuumCssRule & {\n\tstates?: OneOrMany<LuumScssPseudoClassRule>\n\tchildren?: OneOrMany<LuumScssNestedRule>\n}\n\nexport const isLuumScssRule = (input: unknown): input is LuumScssRule =>\n\tisLuumCssRule(input) &&\n\tmaybe(content(isLuumScssPseudoClassRule))(\n\t\tkey<LuumScssRule>(`states`)(input),\n\t) &&\n\tmaybe(content(isLuumScssNestedRule))(key<LuumScssRule>(`children`)(input))\n\nexport const RED: LuumSpec = {\n\thue: 0,\n\tsat: 255,\n\tlum: 0.5,\n\tprefer: `sat`,\n}\n\nexport const WAYFORGE_CORE_COLOR_NAMES = [\n\t`Red`,\n\t`Orange`,\n\t`Yellow`,\n\t`Lime`,\n\t`Green`,\n\t`Teal`,\n\t`Cyan`,\n\t`Blue`,\n\t`Indigo`,\n\t`Violet`,\n\t`Magenta`,\n\t`Pink`,\n] as const\n\nexport type WayforgeCoreColorName = (typeof WAYFORGE_CORE_COLOR_NAMES)[number]\n\nexport const WAYFORGE_CORE_COLORS: Readonly<\n\tRecord<WayforgeCoreColorName, LuumSpec>\n> = WAYFORGE_CORE_COLOR_NAMES.reduce(\n\t(acc, name, idx) => {\n\t\tacc[name] = {\n\t\t\thue: idx * 30,\n\t\t\tsat: 255,\n\t\t\tlum: 0.5,\n\t\t\tprefer: `sat`,\n\t\t}\n\t\treturn acc\n\t},\n\t{} as Record<WayforgeCoreColorName, LuumSpec>,\n)\n\nexport const PAINT_MY_WAGON_RED: LuumScssRule = {\n\trootSelectors: [`.wagon`],\n\troot: RED,\n\tattributes: [`background-color`, shadeBy(5)],\n\tstates: [\n\t\t[\n\t\t\t[`:hover`, `:focus`],\n\t\t\t[`background-color`, shadeBy(10)],\n\t\t],\n\t\t[`:active`, [`background-color`, shadeBy(15)]],\n\t],\n}\n\nconst LF = `\\n`\n\nexport const luumToCss = (rule: LuumCssRule): string => {\n\tconst {\n\t\tattributes: oneOrManyAttributes,\n\t\troot,\n\t\trootSelectors: maybeOneOrManyRootSelectors,\n\t\tfilter: maybeFilter,\n\t} = rule\n\tconst rootSelectors = pipe(\n\t\tmaybeOneOrManyRootSelectors,\n\t\teach(isString),\n\t\tjoin(`, ` + LF),\n\t\t(s) => (s ? s + ` {` + LF : ``),\n\t)\n\tconst attributes = pipe(\n\t\toneOrManyAttributes,\n\t\teach(isLuumCssAttribute),\n\t\tmap(([oneOrManyKeys, oneOrManyModifiers]) => {\n\t\t\tconst modifiers = each(isLuumSpecModifier)(oneOrManyModifiers)\n\t\t\tconst modifiedSpec = modifiers.reduce((last, modify) => modify(last), root)\n\t\t\tconst hex = specToHex(modifiedSpec, maybeFilter)\n\t\t\treturn pipe(\n\t\t\t\toneOrManyKeys,\n\t\t\t\teach(isCssColorPropertyKey),\n\t\t\t\tmap((key) => `${key}: ${hex}`),\n\t\t\t\tjoin(`; ` + LF),\n\t\t\t)\n\t\t}),\n\t\tjoin(`; ` + LF),\n\t)\n\treturn rootSelectors ? join(LF)([rootSelectors, attributes, `}`]) : attributes\n}\n\n// export const luumToScss = (rule: LuumScssRule): string => {\n// const {\n// rootSelectors: maybeOneOrManyRootSelectors,\n// root,\n// attributes: oneOrManyAttributes,\n// filter,\n// states: maybeOneOrManyStates,\n// children: maybeOneOrManyChildren,\n// } = rule\n// const rootSelectors = pipe(\n// maybeOneOrManyRootSelectors,\n// each(isString),\n// join(`, ` + LF)\n// )\n// return ``\n// }\n\n// export const luumToScss = (rule: LuumScssRule): string => {\n// const { rootSelector, root, filter, attributes, states, children } = rule\n// let scss = ``\n// const depth = 0\n// if (rootSelector) scss += `${rootSelector} {`\n// return ``\n// }\n",".class {\n display: flex;\n flex-flow: row wrap;\n gap: 4px;\n section {\n display: flex;\n flex-flow: row;\n margin-bottom: 1rem;\n border: 1px solid #ccc;\n padding: 2px;\n margin: 0;\n span {\n display: flex;\n }\n }\n}\n","import type { Join } from \"~/packages/anvl/src/join\"\n\nimport { Id } from \"../react-id\"\nimport type { DataDesigner } from \"./DataDesigner\"\nimport scss from \"./RelationEditor.module.scss\"\n\nexport const RelationEditor: DataDesigner<Join, `Tree`> = (props) => {\n\tconst seen = new Set()\n\tconst data = Object.entries(props.data.relations)\n\t\t.sort(([_, a], [__, b]) => b.length - a.length)\n\t\t.filter(([head, tail]) => {\n\t\t\tif (seen.has(head)) return false\n\t\t\tseen.add(head)\n\t\t\tfor (const tailElement of tail) {\n\t\t\t\tseen.add(tailElement)\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\n\treturn (\n\t\t<article className={scss.class}>\n\t\t\t{/* <span>{props.data.relationType}</span> */}\n\t\t\t{data.map(([head, tail]) => (\n\t\t\t\t<section>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t<Id id={head} />\n\t\t\t\t\t</span>\n\t\t\t\t\t:\n\t\t\t\t\t<span>\n\t\t\t\t\t\t{tail.map((child) => (\n\t\t\t\t\t\t\t<Id id={child} />\n\t\t\t\t\t\t))}\n\t\t\t\t\t</span>\n\t\t\t\t</section>\n\t\t\t))}\n\t\t</article>\n\t)\n}\n","import type { AtomToken, ReadonlySelectorToken, TimelineToken } from \"atom.io\"\nimport { redo, undo } from \"atom.io\"\nimport type { Timeline } from \"atom.io/internal\"\nimport { useI, useO } from \"atom.io/react\"\nimport { type FC, Fragment } from \"react\"\n\nimport { findTimelineState, findViewIsOpenState, timelineIndex } from \".\"\nimport { button } from \"./Button\"\nimport { article } from \"./Updates\"\n\nexport const YouAreHere: FC = () => {\n\treturn <span className=\"you_are_here\">you are here</span>\n}\n\nexport const TimelineLog: FC<{\n\ttoken: TimelineToken\n\tisOpenState: AtomToken<boolean>\n\ttimelineState: ReadonlySelectorToken<Timeline>\n}> = ({ token, isOpenState, timelineState }) => {\n\tconst timeline = useO(timelineState)\n\tconst isOpen = useO(isOpenState)\n\tconst setIsOpen = useI(isOpenState)\n\n\treturn (\n\t\t<section className=\"node timeline_log\">\n\t\t\t<header>\n\t\t\t\t<button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />\n\t\t\t\t<label>\n\t\t\t\t\t<h2>{token.key}</h2>\n\t\t\t\t\t<span className=\"detail length\">\n\t\t\t\t\t\t({timeline.at}/{timeline.history.length})\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"gap\" />\n\t\t\t\t\t<nav>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tonClick={() => undo(token)}\n\t\t\t\t\t\t\tdisabled={timeline.at === 0}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tundo\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tonClick={() => redo(token)}\n\t\t\t\t\t\t\tdisabled={timeline.at === timeline.history.length}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tredo\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</nav>\n\t\t\t\t</label>\n\t\t\t</header>\n\t\t\t{isOpen ? (\n\t\t\t\t<main>\n\t\t\t\t\t{timeline.history.map((update, index) => (\n\t\t\t\t\t\t<Fragment key={update.key + index + timeline.at}>\n\t\t\t\t\t\t\t{index === timeline.at ? <YouAreHere /> : null}\n\t\t\t\t\t\t\t<article.TimelineUpdate timelineUpdate={update} />\n\t\t\t\t\t\t\t{index === timeline.history.length - 1 &&\n\t\t\t\t\t\t\ttimeline.at === timeline.history.length ? (\n\t\t\t\t\t\t\t\t<YouAreHere />\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t))}\n\t\t\t\t</main>\n\t\t\t) : null}\n\t\t</section>\n\t)\n}\n\nexport const TimelineIndex: FC = () => {\n\tconst tokenIds = useO(timelineIndex)\n\treturn (\n\t\t<article className=\"index timeline_index\">\n\t\t\t{tokenIds\n\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t.map((token) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TimelineLog\n\t\t\t\t\t\t\tkey={token.key}\n\t\t\t\t\t\t\ttoken={token}\n\t\t\t\t\t\t\tisOpenState={findViewIsOpenState(token.key)}\n\t\t\t\t\t\t\ttimelineState={findTimelineState(token.key)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t</article>\n\t)\n}\n","import type {\n\tKeyedStateUpdate,\n\tTimelineUpdate,\n\tTransactionUpdate,\n\tÆn,\n} from \"atom.io\"\nimport * as React from \"react\"\n\nimport { discoverType } from \"~/packages/anvl/src/refinement/refinery\"\n\nimport { prettyJson } from \".\"\n\nconst AtomUpdateFC: React.FC<{\n\tserialNumber: number\n\tatomUpdate: KeyedStateUpdate<unknown>\n}> = ({ atomUpdate }) => {\n\treturn (\n\t\t<article\n\t\t\tkey={atomUpdate.key}\n\t\t\tclassName=\"node atom_update\"\n\t\t\tonClick={() => console.log(atomUpdate)}\n\t\t\tonKeyUp={() => console.log(atomUpdate)}\n\t\t>\n\t\t\t<span className=\"detail\">{atomUpdate.key}: </span>\n\t\t\t<span>\n\t\t\t\t<span className=\"summary\">\n\t\t\t\t\t{prettyJson.diff(atomUpdate.oldValue, atomUpdate.newValue).summary}\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</article>\n\t)\n}\n\nconst TransactionUpdateFC: React.FC<{\n\tserialNumber: number\n\ttransactionUpdate: TransactionUpdate<Æn>\n}> = ({ serialNumber, transactionUpdate }) => {\n\treturn (\n\t\t<article className=\"node transaction_update\">\n\t\t\t<header>\n\t\t\t\t<h4>{serialNumber}</h4>\n\t\t\t</header>\n\t\t\t<main>\n\t\t\t\t<section className=\"transaction_params\">\n\t\t\t\t\t<span className=\"detail\">params: </span>\n\t\t\t\t\t{transactionUpdate.params.map((param, index) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<article\n\t\t\t\t\t\t\t\tkey={`param` + index}\n\t\t\t\t\t\t\t\tclassName=\"node transaction_param\"\n\t\t\t\t\t\t\t\tonClick={() => console.log(transactionUpdate)}\n\t\t\t\t\t\t\t\tonKeyUp={() => console.log(transactionUpdate)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span className=\"detail\">{discoverType(param)}: </span>\n\t\t\t\t\t\t\t\t<span className=\"summary\">\n\t\t\t\t\t\t\t\t\t{typeof param === `object` &&\n\t\t\t\t\t\t\t\t\tparam !== null &&\n\t\t\t\t\t\t\t\t\t`type` in param &&\n\t\t\t\t\t\t\t\t\t`target` in param ? (\n\t\t\t\t\t\t\t\t\t\t<>{JSON.stringify(param.type)}</>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<>{JSON.stringify(param)}</>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</article>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</section>\n\t\t\t\t<section className=\"node transaction_output\">\n\t\t\t\t\t<span className=\"detail\">output: </span>\n\t\t\t\t\t<span className=\"detail\">\n\t\t\t\t\t\t{discoverType(transactionUpdate.output)}\n\t\t\t\t\t</span>\n\t\t\t\t\t{transactionUpdate.output ? (\n\t\t\t\t\t\t<span className=\"summary\">\n\t\t\t\t\t\t\t: {JSON.stringify(transactionUpdate.output)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null}\n\t\t\t\t</section>\n\t\t\t\t<section className=\"transaction_impact\">\n\t\t\t\t\t<span className=\"detail\">impact: </span>\n\t\t\t\t\t{transactionUpdate.updates\n\t\t\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t\t\t.map((update, index) => {\n\t\t\t\t\t\t\treturn `newValue` in update ? (\n\t\t\t\t\t\t\t\t<article.AtomUpdate\n\t\t\t\t\t\t\t\t\tkey={`${transactionUpdate.key}:${index}:${update.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\tatomUpdate={update}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<TransactionUpdateFC\n\t\t\t\t\t\t\t\t\tkey={`${transactionUpdate.key}:${index}:${update.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\ttransactionUpdate={update}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})}\n\t\t\t\t</section>\n\t\t\t</main>\n\t\t</article>\n\t)\n}\n\nexport const TimelineUpdateFC: React.FC<{\n\ttimelineUpdate: TimelineUpdate\n}> = ({ timelineUpdate }) => {\n\treturn (\n\t\t<article className=\"node timeline_update\">\n\t\t\t<header>\n\t\t\t\t<h4>\n\t\t\t\t\t{timelineUpdate.timestamp}: {timelineUpdate.type} ({timelineUpdate.key}\n\t\t\t\t\t)\n\t\t\t\t</h4>\n\t\t\t</header>\n\t\t\t<main>\n\t\t\t\t{timelineUpdate.type === `transaction_update` ? (\n\t\t\t\t\ttimelineUpdate.updates\n\t\t\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t\t\t.map((update, index) => {\n\t\t\t\t\t\t\treturn `newValue` in update ? (\n\t\t\t\t\t\t\t\t<article.AtomUpdate\n\t\t\t\t\t\t\t\t\tkey={`${timelineUpdate.key}:${index}:${update.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\tatomUpdate={update}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<TransactionUpdateFC\n\t\t\t\t\t\t\t\t\tkey={`${timelineUpdate.key}:${index}:${update.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\ttransactionUpdate={update}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})\n\t\t\t\t) : timelineUpdate.type === `selector_update` ? (\n\t\t\t\t\ttimelineUpdate.atomUpdates\n\t\t\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t\t\t.map((atomUpdate, index) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<article.AtomUpdate\n\t\t\t\t\t\t\t\t\tkey={`${timelineUpdate.key}:${index}:${atomUpdate.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\tatomUpdate={atomUpdate}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})\n\t\t\t\t) : timelineUpdate.type === `atom_update` ? (\n\t\t\t\t\t<article.AtomUpdate\n\t\t\t\t\t\tserialNumber={timelineUpdate.timestamp}\n\t\t\t\t\t\tatomUpdate={timelineUpdate}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</main>\n\t\t</article>\n\t)\n}\n\nexport const article = {\n\tAtomUpdate: AtomUpdateFC,\n\tTransactionUpdate: TransactionUpdateFC,\n\tTimelineUpdate: TimelineUpdateFC,\n}\n","import type {\n\tAtomToken,\n\tReadonlySelectorToken,\n\tTransactionToken,\n\tTransactionUpdate,\n\tÆn,\n} from \"atom.io\"\nimport { useI, useO } from \"atom.io/react\"\nimport type { FC } from \"react\"\n\nimport {\n\tfindTransactionLogState,\n\tfindViewIsOpenState,\n\ttransactionIndex,\n} from \".\"\nimport { button } from \"./Button\"\nimport { article } from \"./Updates\"\n\nexport const TransactionLog: FC<{\n\ttoken: TransactionToken<Æn>\n\tisOpenState: AtomToken<boolean>\n\tlogState: ReadonlySelectorToken<TransactionUpdate<Æn>[]>\n}> = ({ token, isOpenState, logState }) => {\n\tconst log = useO(logState)\n\tconst isOpen = useO(isOpenState)\n\tconst setIsOpen = useI(isOpenState)\n\n\treturn (\n\t\t<section className=\"node transaction_log\">\n\t\t\t<header>\n\t\t\t\t<button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />\n\t\t\t\t<label>\n\t\t\t\t\t<h2>{token.key}</h2>\n\t\t\t\t\t<span className=\"detail length\">({log.length})</span>\n\t\t\t\t</label>\n\t\t\t</header>\n\t\t\t{isOpen ? (\n\t\t\t\t<main>\n\t\t\t\t\t{log.map((update, index) => (\n\t\t\t\t\t\t<article.TransactionUpdate\n\t\t\t\t\t\t\tkey={update.key + index}\n\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\ttransactionUpdate={update}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</main>\n\t\t\t) : null}\n\t\t</section>\n\t)\n}\n\nexport const TransactionIndex: FC = () => {\n\tconst tokenIds = useO(transactionIndex)\n\treturn (\n\t\t<article className=\"index transaction_index\">\n\t\t\t{tokenIds\n\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t.map((token) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TransactionLog\n\t\t\t\t\t\t\tkey={token.key}\n\t\t\t\t\t\t\ttoken={token}\n\t\t\t\t\t\t\tisOpenState={findViewIsOpenState(token.key)}\n\t\t\t\t\t\t\tlogState={findTransactionLogState(token.key)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t</article>\n\t)\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../internal/src/future.ts","../../internal/src/lineage.ts","../../internal/src/caching.ts","../../../anvl/src/json/index.ts","../../../anvl/src/primitive/index.ts","../../json/src/select-json.ts","../../json/src/select-json-family.ts","../../internal/src/read-or-compute-value.ts","../../internal/src/operation.ts","../../internal/src/set-state/become.ts","../../internal/src/subject.ts","../../internal/src/set-state/copy-mutable-if-needed.ts","../../internal/src/set-state/copy-mutable-in-transaction.ts","../../internal/src/set-state/emit-update.ts","../../internal/src/set-state/evict-downstream.ts","../../internal/src/set-state/stow-update.ts","../../internal/src/set-state/set-atom.ts","../../internal/src/set-state/set-atom-or-selector.ts","../../internal/src/store/deposit.ts","../../../rel8/junction/src/junction.ts","../../internal/src/store/store.ts","../../internal/src/store/withdraw.ts","../../internal/src/store/withdraw-new-family-member.ts","../../internal/src/keys.ts","../../internal/src/selector/get-selector-dependency-keys.ts","../../internal/src/selector/trace-selector-atoms.ts","../../internal/src/selector/update-selector-atoms.ts","../../internal/src/selector/register-selector.ts","../../internal/src/selector/create-read-write-selector.ts","../../internal/src/selector/create-readonly-selector.ts","../../internal/src/selector/create-selector.ts","../../internal/src/selector/delete-selector.ts","../../internal/src/subscribe/recall-state.ts","../../internal/src/subscribe/subscribe-to-root-atoms.ts","../../internal/src/subscribe/subscribe-to-state.ts","../../internal/src/subscribe/subscribe-to-timeline.ts","../../internal/src/mutable/tracker.ts","../../internal/src/mutable/create-mutable-atom.ts","../../internal/src/families/create-atom-family.ts","../../internal/src/families/create-readonly-selector-family.ts","../../internal/src/families/create-selector-family.ts","../../internal/src/mutable/tracker-family.ts","../../internal/src/mutable/create-mutable-atom-family.ts","../../internal/src/mutable/transceiver.ts","../../internal/src/atom/is-default.ts","../../internal/src/atom/create-atom.ts","../../internal/src/atom/delete-atom.ts","../../internal/src/not-found-error.ts","../../internal/src/timeline/time-travel.ts","../../src/atom.ts","../../src/get-state.ts","../../src/logger.ts","../../src/selector.ts","../../src/set-state.ts","../../src/timeline.ts","../../introspection/src/attach-atom-index.ts","../../introspection/src/attach-selector-index.ts","../../introspection/src/attach-timeline-family.ts","../../introspection/src/attach-timeline-index.ts","../../introspection/src/attach-transaction-index.ts","../../introspection/src/attach-transaction-logs.ts","../../introspection/src/attach-introspection-states.ts","../../__unstable__/web-effects/src/storage.ts","../../../anvl/src/function/pipe.ts","../../../anvl/src/function/index.ts","../../../anvl/src/array/venn.ts","../../../anvl/src/array/index.ts","../../../anvl/src/nullish/index.ts","../../../anvl/src/object/access.ts","../../../anvl/src/object/entries.ts","../../../anvl/src/object/mapObject.ts","../../../anvl/src/object/refinement.ts","../../../anvl/src/object/sprawl.ts","../../../anvl/src/object/index.ts","../../../anvl/src/refinement/refinery.ts","../../../anvl/src/tree/differ.ts","../../react/src/store-context.tsx","../../react/src/store-hooks.ts","../src/AtomIODevtools.tsx","../../../anvl/src/refinement/refine-json.ts","../src/Button.tsx","../../../anvl/src/refinement/can-exist.ts","../../../anvl/src/refinement/cannot-exist.ts","../../../anvl/src/refinement/is-union.ts","../../../anvl/src/refinement/is-intersection.ts","../../../anvl/src/refinement/index.ts","../../../anvl/src/join/core-relation-data.ts","../../../anvl/src/join/get-related-ids.ts","../../../anvl/src/join/make-json-interface.ts","../../../anvl/src/join/relation-record.ts","../../../anvl/src/string/split.ts","../../../anvl/src/join/remove-relation.ts","../../../anvl/src/join/set-relation.ts","../../../anvl/src/join/relation-contents.ts","../../../anvl/src/join/index.ts","../../../hamr/src/react-elastic-input/ElasticInput.tsx","../../../hamr/src/react-elastic-input/NumberInput.tsx","../../../anvl/src/number/clamp.ts","../../../anvl/src/number/wrap.ts","../../../hamr/src/react-elastic-input/TextInput.tsx","../../../hamr/src/react-json-editor/editors-by-type/non-json.tsx","../../../hamr/src/react-json-editor/json-editor-internal.tsx","../../../hamr/src/react-json-editor/editors-by-type/utilities/array-elements.ts","../../../hamr/src/react-json-editor/editors-by-type/array-editor.tsx","../../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx","../../../anvl/src/json-schema/integer.ts","../../../anvl/src/json-schema/refs.ts","../../../anvl/src/json-schema/string-formats.ts","../../../anvl/src/json-schema/json-schema.ts","../../../anvl/src/json-schema/path-into.ts","../../../anvl/src/json-schema/find-sub-schema.ts","../../../anvl/src/json/cast-json.ts","../../../anvl/src/refinement/smart-cast-json.ts","../../../hamr/src/react-json-editor/editors-by-type/utilities/object-properties.ts","../../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx","../../../hamr/src/react-error-boundary/ReactErrorBoundary.tsx","../../../hamr/src/react-error-boundary/DefaultFallback.tsx","../../../hamr/src/react-json-editor/default-components.tsx","../../../hamr/src/react-json-editor/developer-interface.tsx","../../../hamr/src/react-json-editor/index.ts","../../../hamr/src/react-id/Id.tsx","../../../anvl/src/string/string-to-color.ts","../../../luum/src/constants/index.ts","../../../luum/src/constants/filters.ts","../../../luum/src/export/channelsToHex.ts","../../../luum/src/import/hueToRelativeChannels.ts","../../../luum/src/solveFor/hueFromChannels.ts","../../../luum/src/solveFor/lumFromChannels.ts","../../../luum/src/solveFor/maxSatForHueInFilter.ts","../../../luum/src/solveFor/satFromChannels.ts","../../../luum/src/solveFor/specificLumFromHue.ts","../../../luum/src/export/specToChannelsFixLimit.ts","../../../luum/src/export/specToHexFixLimit.ts","../../../luum/src/export/specToHex.ts","../../../luum/src/import/channelsToSpec.ts","../../../luum/src/import/normalizeHex.ts","../../../luum/src/import/hexToChannels.ts","../../../luum/src/import/hexToSpec.ts","../../../luum/src/mixers/lum.ts","../../../luum/src/mixers/contrast.ts","../../../luum/src/constants/luum-spec.ts","../../../luum/src/scheme/index.ts","../../../hamr/src/react-data-designer/RelationEditor.module.scss","../../../hamr/src/react-data-designer/RelationEditor.tsx","../src/StateEditor.tsx","../src/StateIndex.tsx","../src/TimelineIndex.tsx","../src/Updates.tsx","../src/TransactionIndex.tsx","../src/index.ts"],"names":["pass","atom","atomFamily","fallback","a","b","_a","target","update","unsubscribe","selectorFamily","store","become","path","node","result","e","React","useRef","isJson","jsx","isOpen","join","map","id","useId","useState","jsxs","refMap","_","Fragment","round"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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AAEM,IAAM,2BAA2B,KAAqB;AAAA,EAC5D,KAAK;AAAA,EACL,SAAS,CAAC,SAAS,aAAa,gBAAgB,WAAW;AAAA,EAC3D,SAAS,CAAC,uBAAuB,gDAA6B,CAAC;AAChE,CAAC;AAEM,IAAM,sBAAsB,WAA4B;AAAA,EAC9D,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS,CAAC,QAAQ,CAAC,uBAAuB,MAAM,eAAe,CAAC;AACjE,CAAC;AAEM,IAAM,oBAAoB,IAAI,SAAS;AAAA,EAC7C,QAAQ,CAAC,UAAoC,OAAO,UAAU;AAAA,EAC9D,QAAQ,CAAC,UAAoC,OAAO,UAAU;AAAA,EAC9D,SAAS,CAAC,UAAqC,OAAO,UAAU;AAAA,EAChE,MAAM,CAAC,UAAkC,UAAU;AACpD,CAAC;AAEM,IAAM,mBAAmB,IAAI,SAAS;AAAA,EAC5C,QAAQ;AAAA,EACR,OAAO,CAAC,UAAuC,MAAM,QAAQ,KAAK;AACnE,CAAC;AAEM,IAAM,aAAa,IAAI,OAAO,mBAAmB,kBAAkB;AAAA,EACzE,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM,OAAO,EAAE,SAAS,YAAY;AAAA,EACpC,QAAQ;AAAA,EACR,OAAO;AACR,CAAC","sourcesContent":["/**\n * A Promise that can be canceled.\n * @internal\n * @private\n * @typeParam T The type of the value that the promise will resolve to.\n *\n * @remarks\n * Can be constructed like a Promise, or from an existing Promise.\n */\nexport class Future<T> extends Promise<T> {\n\tpublic isCanceled = false\n\n\tpublic constructor(\n\t\texecutor:\n\t\t\t| Promise<T>\n\t\t\t| ((resolve: (value: T) => void, reject: (reason?: any) => void) => void),\n\t) {\n\t\tsuper((resolve, reject) => {\n\t\t\tconst pass = (value: T) =>\n\t\t\t\tthis.isCanceled ? reject(`canceled`) : resolve(value)\n\t\t\tconst fail = (reason: any) =>\n\t\t\t\tthis.isCanceled ? reject(`canceled`) : reject(reason)\n\t\t\tif (typeof executor === `function`) {\n\t\t\t\texecutor(pass, fail)\n\t\t\t} else {\n\t\t\t\texecutor.then(pass, fail)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic cancel(): void {\n\t\tthis.isCanceled = true\n\t}\n}\n","export interface Lineage {\n\tparent: typeof this | null\n\tchild: typeof this | null\n}\n\nexport function newest<T extends Lineage>(scion: T): T {\n\twhile (scion.child !== null) {\n\t\tscion = scion.child\n\t}\n\treturn scion\n}\n\nexport function eldest<T extends Lineage>(scion: T): T {\n\twhile (scion.parent !== null) {\n\t\tscion = scion.parent\n\t}\n\treturn scion\n}\n","import type { StateUpdate } from \"atom.io\"\nimport { Future } from \"./future\"\nimport { newest } from \"./lineage\"\nimport type { Store } from \"./store\"\nimport type { Subject } from \"./subject\"\n\nexport function cacheValue<T>(\n\tkey: string,\n\tvalue: T,\n\tsubject: Subject<StateUpdate<unknown>>,\n\tstore: Store,\n): T\nexport function cacheValue<T extends Promise<any>>(\n\tkey: string,\n\tvalue: T,\n\tsubject: Subject<StateUpdate<unknown>>,\n\tstore: Store,\n): Future<T>\nexport function cacheValue<T>(\n\tkey: string,\n\tvalue: T,\n\tsubject: Subject<StateUpdate<unknown>>,\n\tstore: Store,\n): Future<T> | T {\n\tconst target = newest(store)\n\tconst currentValue = target.valueMap.get(key)\n\tif (currentValue instanceof Future) {\n\t\tcurrentValue.cancel()\n\t}\n\tif (value instanceof Promise) {\n\t\tconst future = new Future<T>(value)\n\t\tnewest(store).valueMap.set(key, future)\n\t\tfuture\n\t\t\t.then((resolved) => {\n\t\t\t\tif (future.isCanceled) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tcacheValue(key, resolved, subject, store)\n\t\t\t\tsubject.next({ newValue: resolved, oldValue: future })\n\t\t\t})\n\t\t\t.catch((thrown) => {\n\t\t\t\tif (thrown !== `canceled`) {\n\t\t\t\t\tstore.logger.error(`ð¥`, `state`, key, `rejected:`, thrown)\n\t\t\t\t}\n\t\t\t})\n\t\treturn future\n\t}\n\ttarget.valueMap.set(key, value)\n\treturn value\n}\n\nexport const readCachedValue = <T>(key: string, store: Store): T => {\n\treturn newest(store).valueMap.get(key) as T\n}\nexport const isValueCached = (key: string, store: Store): boolean => {\n\treturn newest(store).valueMap.has(key)\n}\n\nexport const evictCachedValue = (key: string, store: Store): void => {\n\tconst core = newest(store)\n\tconst currentValue = core.valueMap.get(key)\n\tif (currentValue instanceof Future) {\n\t\tcurrentValue.cancel()\n\t}\n\tif (core.operation.open) {\n\t\tcore.operation.prev.set(key, currentValue)\n\t}\n\tcore.valueMap.delete(key)\n\tstore.logger.info(`ð`, `state`, key, `evicted`)\n}\n","export * from \"./json-interface\"\nimport type * as Json from \"./json\"\nexport { Json }\n\nexport const parseJson = <S extends Stringified<Json.Serializable>>(\n\tstr: S | string,\n): S extends Stringified<infer J> ? J : Json.Serializable => JSON.parse(str)\n\nexport type Stringified<J extends Json.Serializable> = string & { __json: J }\n\nexport const stringifyJson = <J extends Json.Serializable>(\n\tjson: J,\n): Stringified<J> => JSON.stringify(json) as Stringified<J>\n\nexport type Empty = Record<string, never>\n\nexport const JSON_TYPE_NAMES = [\n\t`array`,\n\t`boolean`,\n\t`null`,\n\t`number`,\n\t`object`,\n\t`string`,\n] as const\n\nexport type JsonTypeName = (typeof JSON_TYPE_NAMES)[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {\n\tarray: Json.Array\n\tboolean: boolean\n\tnull: null\n\tnumber: number\n\tobject: Json.Object\n\tstring: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n\tarray: [],\n\tboolean: false,\n\tnull: null,\n\tnumber: 0,\n\tobject: {},\n\tstring: ``,\n}\n","export type primitive = boolean | number | string | null\n\nexport const isString = (input: unknown): input is string => {\n\treturn typeof input === `string`\n}\n\nexport const isNumber = (input: unknown): input is number => {\n\treturn typeof input === `number`\n}\n\nexport const isBoolean = (input: unknown): input is boolean => {\n\treturn typeof input === `boolean`\n}\n\nexport const isNull = (input: unknown): input is null => {\n\treturn input === null\n}\n\nexport const isPrimitive = (input: unknown): input is primitive => {\n\treturn isString(input) || isNumber(input) || isBoolean(input) || isNull(input)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT } from \"atom.io/internal\"\n\nimport { createSelector } from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \".\"\n\nexport const selectJson = <T, J extends Json.Serializable>(\n\tatom: AtomIO.AtomToken<T>,\n\ttransform: JsonInterface<T, J>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomIO.SelectorToken<J> => {\n\treturn createSelector(\n\t\t{\n\t\t\tkey: `${atom.key}:JSON`,\n\t\t\tget: ({ get }) => transform.toJson(get(atom)),\n\t\t\tset: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createSelectorFamily } from \"atom.io/internal\"\n\nimport type { Json, JsonInterface } from \".\"\nimport { parseJson } from \".\"\n\nexport const selectJsonFamily = <\n\tT,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n>(\n\tatomFamily: AtomIO.AtomFamily<T, K>,\n\ttransform: JsonInterface<T, J>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomIO.SelectorFamily<J, K> => {\n\tconst jsonFamily = createSelectorFamily<J, K>(\n\t\t{\n\t\t\tkey: `${atomFamily.key}:JSON`,\n\t\t\tget:\n\t\t\t\t(key) =>\n\t\t\t\t({ get }) =>\n\t\t\t\t\ttransform.toJson(get(atomFamily(key))),\n\t\t\tset:\n\t\t\t\t(key) =>\n\t\t\t\t({ set }, newValue) =>\n\t\t\t\t\tset(atomFamily(key), transform.fromJson(newValue)),\n\t\t},\n\t\tstore,\n\t)\n\tatomFamily.subject.subscribe(\n\t\t`store=${store.config.name}::json-selector-family`,\n\t\t(token) => {\n\t\t\tif (token.family) {\n\t\t\t\tjsonFamily(parseJson(token.family.subKey) as K)\n\t\t\t}\n\t\t},\n\t)\n\treturn jsonFamily\n}\n","import type { Atom } from \"./atom\"\nimport { isValueCached, readCachedValue } from \"./caching\"\nimport type { ReadonlySelector, Selector } from \"./selector\"\nimport type { Store } from \"./store\"\n\nexport const readOrComputeValue = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store,\n): T => {\n\tif (isValueCached(state.key, store)) {\n\t\tstore.logger.info(`ð`, state.type, state.key, `reading cached value`)\n\t\treturn readCachedValue(state.key, store)\n\t}\n\tif (state.type !== `atom`) {\n\t\tstore.logger.info(`ð§®`, state.type, state.key, `computing value`)\n\t\treturn state.get()\n\t}\n\tconst fallback =\n\t\tstate.default instanceof Function ? state.default() : state.default\n\tstore.logger.info(\n\t\t`ð`,\n\t\t`atom`,\n\t\tstate.key,\n\t\t`could not find cached value; using default`,\n\t\tfallback,\n\t)\n\treturn state.default instanceof Function ? state.default() : state.default\n}\n","import type { StateToken } from \"atom.io\"\n\nimport { newest } from \"./lineage\"\nimport type { Store } from \"./store\"\n\nexport type OperationProgress =\n\t| {\n\t\t\topen: false\n\t }\n\t| {\n\t\t\topen: true\n\t\t\tdone: Set<string>\n\t\t\tprev: Map<string, any>\n\t\t\ttime: number\n\t\t\ttoken: StateToken<any>\n\t }\n\nexport const openOperation = (\n\ttoken: StateToken<any>,\n\tstore: Store,\n): `rejection` | undefined => {\n\tconst target = newest(store)\n\tif (target.operation.open) {\n\t\tstore.logger.error(\n\t\t\t`â`,\n\t\t\ttoken.type,\n\t\t\ttoken.key,\n\t\t\t`failed to setState during a setState for \"${target.operation.token.key}\"`,\n\t\t)\n\t\treturn `rejection`\n\t}\n\ttarget.operation = {\n\t\topen: true,\n\t\tdone: new Set(),\n\t\tprev: new Map(),\n\t\ttime: Date.now(),\n\t\ttoken,\n\t}\n\tstore.logger.info(\n\t\t`â`,\n\t\ttoken.type,\n\t\ttoken.key,\n\t\t`operation start in store \"${store.config.name}\"${\n\t\t\ttarget.transactionMeta === null\n\t\t\t\t? ``\n\t\t\t\t: ` ${target.transactionMeta.phase} \"${target.transactionMeta.update.key}\"`\n\t\t}`,\n\t)\n}\nexport const closeOperation = (store: Store): void => {\n\tconst target = newest(store)\n\tif (target.operation.open) {\n\t\tstore.logger.info(\n\t\t\t`ðŽ`,\n\t\t\ttarget.operation.token.type,\n\t\t\ttarget.operation.token.key,\n\t\t\t`operation done in store \"${store.config.name}\"`,\n\t\t)\n\t}\n\ttarget.operation = { open: false }\n\tstore.subject.operationStatus.next(target.operation)\n}\n\nexport const isDone = (key: string, store: Store): boolean => {\n\tconst target = newest(store)\n\tif (!target.operation.open) {\n\t\tstore.logger.warn(\n\t\t\t`ð`,\n\t\t\t`unknown`,\n\t\t\tkey,\n\t\t\t`isDone called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn true\n\t}\n\treturn target.operation.done.has(key)\n}\nexport const markDone = (key: string, store: Store): void => {\n\tconst target = newest(store)\n\tif (!target.operation.open) {\n\t\tstore.logger.warn(\n\t\t\t`ð`,\n\t\t\t`unknown`,\n\t\t\tkey,\n\t\t\t`markDone called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\ttarget.operation.done.add(key)\n}\n","export type Modify<T> = (thing: T) => T\n\nexport const become =\n\t<T>(nextVersionOfThing: Modify<T> | T) =>\n\t(originalThing: T): T =>\n\t\tnextVersionOfThing instanceof Function\n\t\t\t? nextVersionOfThing(\n\t\t\t\t\toriginalThing instanceof Function ? originalThing() : originalThing,\n\t\t\t )\n\t\t\t: nextVersionOfThing\n","export class Subject<T> {\n\tpublic Subscriber: (value: T) => void\n\n\tpublic subscribers: Map<string, this[`Subscriber`]> = new Map()\n\n\tpublic subscribe(key: string, subscriber: this[`Subscriber`]): () => void {\n\t\tthis.subscribers.set(key, subscriber)\n\t\tconst unsubscribe = () => this.unsubscribe(key)\n\t\treturn unsubscribe\n\t}\n\n\tprivate unsubscribe(key: string) {\n\t\tthis.subscribers.delete(key)\n\t}\n\n\tpublic next(value: T): void {\n\t\tfor (const subscriber of this.subscribers.values()) {\n\t\t\tsubscriber(value)\n\t\t}\n\t}\n}\n\nexport class StatefulSubject<T> extends Subject<T> {\n\tpublic state: T\n\n\tpublic constructor(initialState: T) {\n\t\tsuper()\n\t\tthis.state = initialState\n\t}\n\n\tpublic next(value: T): void {\n\t\tthis.state = value\n\t\tsuper.next(value)\n\t}\n}\n","import type { JsonInterface } from \"atom.io/json\"\n\nimport type { Atom } from \"../atom\"\nimport { Tracker } from \"../mutable\"\nimport type { Store } from \"../store\"\n\nexport function copyMutableIfNeeded<T>(\n\tatom: Atom<T>,\n\ttransform: JsonInterface<T>,\n\torigin: Store,\n\ttarget: Store,\n): T {\n\tconst originValue = origin.valueMap.get(atom.key)\n\tconst targetValue = target.valueMap.get(atom.key)\n\tif (originValue === targetValue) {\n\t\torigin.logger.info(`ð`, `atom`, `${atom.key}`, `copying`)\n\t\tconst jsonValue = transform.toJson(originValue)\n\t\tconst copiedValue = transform.fromJson(jsonValue)\n\t\ttarget.valueMap.set(atom.key, copiedValue)\n\t\tnew Tracker(atom, origin)\n\t\treturn copiedValue\n\t}\n\treturn targetValue\n}\n","import type { AtomFamily } from \"atom.io\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\nimport { newest } from \"..\"\nimport type { Store } from \"..\"\nimport type { Atom } from \"../atom\"\nimport { copyMutableIfNeeded } from \"./copy-mutable-if-needed\"\n\nexport function copyMutableIfWithinTransaction<T>(\n\toldValue: T,\n\tatom: Atom<T> | (Atom<T> & JsonInterface<T, Json.Serializable>),\n\tstore: Store,\n): T {\n\tconst target = newest(store)\n\tconst parent = target.parent\n\tif (parent !== null) {\n\t\tif (`toJson` in atom && `fromJson` in atom) {\n\t\t\tconst copiedValue = copyMutableIfNeeded(atom, atom, parent, target)\n\t\t\treturn copiedValue\n\t\t}\n\t\tif (`family` in atom) {\n\t\t\tconst family = parent.families.get(atom.family.key)\n\t\t\tif (family && family.type === `atom_family`) {\n\t\t\t\tconst result = copyMutableFamilyMemberWithinTransaction<T>(\n\t\t\t\t\tatom,\n\t\t\t\t\tfamily,\n\t\t\t\t\tparent,\n\t\t\t\t\ttarget,\n\t\t\t\t)\n\t\t\t\tif (result) {\n\t\t\t\t\treturn result\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn oldValue\n}\n\nexport function copyMutableFamilyMemberWithinTransaction<T>(\n\tatom: Atom<T>,\n\tfamily:\n\t\t| AtomFamily<T, any>\n\t\t| (AtomFamily<T, any> & JsonInterface<T, Json.Serializable>),\n\torigin: Store,\n\ttarget: Store,\n): T | null {\n\tif (`toJson` in family && `fromJson` in family) {\n\t\tconst copyCreated = copyMutableIfNeeded(atom, family, origin, target)\n\t\treturn copyCreated\n\t}\n\treturn null\n}\n","import type { StateUpdate } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\n\nimport type { Atom } from \"../atom\"\nimport type { ReadonlySelector, Selector } from \"../selector\"\n\nexport const emitUpdate = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tupdate: StateUpdate<T>,\n\tstore: Store,\n): void => {\n\tstore.logger.info(\n\t\t`ð¢`,\n\t\tstate.type,\n\t\tstate.key,\n\t\t`went (`,\n\t\tupdate.oldValue,\n\t\t`->`,\n\t\tupdate.newValue,\n\t\t`) subscribers:`,\n\t\tstate.subject.subscribers,\n\t)\n\tstate.subject.next(update)\n}\n","import type { Atom } from \"../atom\"\nimport { evictCachedValue } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport { isDone, markDone } from \"../operation\"\nimport type { Store } from \"../store\"\n\nexport const evictDownStream = <T>(atom: Atom<T>, store: Store): void => {\n\tconst target = newest(store)\n\tconst downstreamKeys = target.selectorAtoms.getRelatedKeys(atom.key)\n\tstore.logger.info(\n\t\t`ð§¹`,\n\t\tatom.type,\n\t\tatom.key,\n\t\tdownstreamKeys\n\t\t\t? `evicting ${downstreamKeys.size} states downstream:`\n\t\t\t: `no downstream states`,\n\t\tdownstreamKeys ?? `to evict`,\n\t)\n\tif (downstreamKeys) {\n\t\tif (target.operation.open) {\n\t\t\tstore.logger.info(\n\t\t\t\t`ð§¹`,\n\t\t\t\tatom.type,\n\t\t\t\tatom.key,\n\t\t\t\t`[ ${[...target.operation.done].join(`, `)} ] already done`,\n\t\t\t)\n\t\t}\n\t\tfor (const key of downstreamKeys) {\n\t\t\tif (isDone(key, store)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tevictCachedValue(key, store)\n\t\t\tmarkDone(key, store)\n\t\t}\n\t}\n}\n","import type { KeyedStateUpdate, StateUpdate } from \"atom.io\"\n\nimport type { Atom } from \"../atom\"\nimport { newest } from \"../lineage\"\nimport { isTransceiver } from \"../mutable\"\nimport type { Store } from \"../store\"\n\nfunction shouldUpdateBeStowed(key: string, update: StateUpdate<any>): boolean {\n\t// do not stow updates that aren't json, unless they're not equal by reference\n\tif (isTransceiver(update.newValue)) {\n\t\treturn false\n\t}\n\t// do not stow updates where the key contains ðâðš\n\tif (key.includes(`ðâðš`)) {\n\t\treturn false\n\t}\n\treturn true\n}\n\nexport const stowUpdate = <T>(\n\tstate: Atom<T>,\n\tupdate: StateUpdate<T>,\n\tstore: Store,\n): void => {\n\tconst { key } = state\n\tconst target = newest(store)\n\tif (\n\t\ttarget.transactionMeta === null ||\n\t\ttarget.transactionMeta.phase !== `building`\n\t) {\n\t\tstore.logger.error(\n\t\t\t`ð`,\n\t\t\t`atom`,\n\t\t\tkey,\n\t\t\t`stowUpdate called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tconst shouldStow = shouldUpdateBeStowed(key, update)\n\tif (!shouldStow) {\n\t\treturn\n\t}\n\tconst atomUpdate: KeyedStateUpdate<T> = { key, ...update }\n\tif (state.family) {\n\t\tatomUpdate.family = state.family\n\t}\n\ttarget.transactionMeta.update.updates.push(atomUpdate)\n\tstore.logger.info(\n\t\t`ð`,\n\t\t`atom`,\n\t\tkey,\n\t\t`stowed (`,\n\t\tupdate.oldValue,\n\t\t`->`,\n\t\tupdate.newValue,\n\t\t`)`,\n\t)\n}\n","import type { Atom } from \"../atom\"\nimport { isAtomDefault, markAtomAsNotDefault } from \"../atom\"\nimport { cacheValue } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport { markDone } from \"../operation\"\nimport { readOrComputeValue } from \"../read-or-compute-value\"\nimport type { Store } from \"../store\"\nimport { become } from \"./become\"\nimport { copyMutableIfWithinTransaction } from \"./copy-mutable-in-transaction\"\nimport { emitUpdate } from \"./emit-update\"\nimport { evictDownStream } from \"./evict-downstream\"\nimport { stowUpdate } from \"./stow-update\"\n\nexport const setAtom = <T>(\n\tatom: Atom<T>,\n\tnext: T | ((oldValue: T) => T),\n\tstore: Store,\n): void => {\n\tconst target = newest(store)\n\tconst oldValue = readOrComputeValue(atom, store)\n\tlet newValue = copyMutableIfWithinTransaction(oldValue, atom, store)\n\tnewValue = become(next)(newValue)\n\tstore.logger.info(`ð`, `atom`, atom.key, `set to`, newValue)\n\tnewValue = cacheValue(atom.key, newValue, atom.subject, store)\n\tif (isAtomDefault(atom.key, store)) {\n\t\tmarkAtomAsNotDefault(atom.key, store)\n\t}\n\tmarkDone(atom.key, store)\n\tevictDownStream(atom, store)\n\tconst update = { oldValue, newValue }\n\tif (\n\t\ttarget.transactionMeta === null ||\n\t\ttarget.transactionMeta.phase === `applying`\n\t) {\n\t\temitUpdate(atom, update, store)\n\t} else {\n\t\tstowUpdate(atom, update, store)\n\t}\n}\n","import type { Atom } from \"../atom\"\nimport type { Selector } from \"../selector\"\nimport type { Store } from \"../store\"\nimport { setAtom } from \"./set-atom\"\n\nexport const setAtomOrSelector = <T>(\n\tstate: Atom<T> | Selector<T>,\n\tvalue: T | ((oldValue: T) => T),\n\tstore: Store,\n): void => {\n\tif (state.type === `selector`) {\n\t\tstate.set(value)\n\t} else {\n\t\tsetAtom(state, value, store)\n\t}\n}\n","import type {\n\tAtomToken,\n\tReadonlySelectorToken,\n\tSelectorToken,\n\tStateToken,\n\tTransactionToken,\n\tÆn,\n} from \"atom.io\"\n\nimport type { Atom } from \"../atom\"\nimport type { ReadonlySelector, Selector } from \"../selector\"\nimport type { Transaction } from \"../transaction\"\n\nexport function deposit<T>(state: Atom<T>): AtomToken<T>\nexport function deposit<T>(state: Selector<T>): SelectorToken<T>\nexport function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>\nexport function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>\nexport function deposit<T>(\n\tstate: Transaction<T extends Æn ? T : never>,\n): TransactionToken<T>\nexport function deposit<T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n): ReadonlySelectorToken<T> | StateToken<T>\nexport function deposit<T>(\n\tstate:\n\t\t| Atom<T>\n\t\t| ReadonlySelector<T>\n\t\t| Selector<T>\n\t\t| Transaction<T extends Æn ? T : never>,\n):\n\t| AtomToken<T>\n\t| ReadonlySelectorToken<T>\n\t| SelectorToken<T>\n\t| TransactionToken<T> {\n\tconst token = {\n\t\tkey: state.key,\n\t\ttype: state.type,\n\t} as any\n\tif (`family` in state) {\n\t\ttoken.family = state.family\n\t}\n\treturn token\n}\n","import type { Cardinality, Json, Refinement } from \"rel8\"\n\nexport interface JunctionEntries<Content extends Json.Object | null>\n\textends Json.Object {\n\treadonly relations: [string, string[]][]\n\treadonly contents: [string, Content][]\n}\nexport interface JunctionSchema<ASide extends string, BSide extends string>\n\textends Json.Object {\n\treadonly between: [a: ASide, b: BSide]\n\treadonly cardinality: Cardinality\n}\n\nexport type BaseExternalStoreConfiguration = {\n\taddRelation: (a: string, b: string) => void\n\tdeleteRelation: (a: string, b: string) => void\n\treplaceRelationsSafely: (a: string, bs: string[]) => void\n\treplaceRelationsUnsafely: (a: string, bs: string[]) => void\n\tgetRelatedKeys: (key: string) => Set<string> | undefined\n\thas: (a: string, b?: string) => boolean\n}\n\nexport type ExternalStoreWithContentConfiguration<Content extends Json.Object> =\n\t{\n\t\tgetContent: (contentKey: string) => Content | undefined\n\t\tsetContent: (contentKey: string, content: Content) => void\n\t\tdeleteContent: (contentKey: string) => void\n\t}\n\nexport type Empty<Obj extends object> = {\n\t[Key in keyof Obj]?: undefined\n}\n\nexport type ExternalStoreConfiguration<Content extends Json.Object | null> =\n\tContent extends Json.Object\n\t\t? BaseExternalStoreConfiguration &\n\t\t\t\tExternalStoreWithContentConfiguration<Content>\n\t\t: BaseExternalStoreConfiguration &\n\t\t\t\tEmpty<ExternalStoreWithContentConfiguration<Json.Object>>\n\nexport type JunctionAdvancedConfiguration<Content extends Json.Object | null> = {\n\texternalStore?: ExternalStoreConfiguration<Content>\n\tisContent?: Refinement<unknown, Content>\n\tmakeContentKey?: (a: string, b: string) => string\n}\n\nexport type JunctionJSON<\n\tASide extends string,\n\tBSide extends string,\n\tContent extends Json.Object | null,\n> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>\n\nexport class Junction<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Content extends Json.Object | null = null,\n> {\n\tpublic readonly a: ASide\n\tpublic readonly b: BSide\n\tpublic readonly cardinality: Cardinality\n\tpublic readonly relations = new Map<string, Set<string>>()\n\tpublic readonly contents = new Map<string, Content>()\n\n\tpublic isContent: Refinement<unknown, Content> | null\n\tpublic makeContentKey = (a: string, b: string): string => `${a}:${b}`\n\n\tpublic getRelatedKeys(key: string): Set<string> | undefined {\n\t\treturn this.relations.get(key)\n\t}\n\tprotected addRelation(a: string, b: string): void {\n\t\tlet aRelations = this.relations.get(a)\n\t\tlet bRelations = this.relations.get(b)\n\t\tif (aRelations) {\n\t\t\taRelations.add(b)\n\t\t} else {\n\t\t\taRelations = new Set([b])\n\t\t\tthis.relations.set(a, aRelations)\n\t\t}\n\t\tif (bRelations) {\n\t\t\tbRelations.add(a)\n\t\t} else {\n\t\t\tbRelations = new Set([a])\n\t\t\tthis.relations.set(b, bRelations)\n\t\t}\n\t}\n\tprotected deleteRelation(a: string, b: string): void {\n\t\tconst aRelations = this.relations.get(a)\n\t\tif (aRelations) {\n\t\t\taRelations.delete(b)\n\t\t\tif (aRelations.size === 0) {\n\t\t\t\tthis.relations.delete(a)\n\t\t\t}\n\t\t\tconst bRelations = this.relations.get(b)\n\t\t\tif (bRelations) {\n\t\t\t\tbRelations.delete(a)\n\t\t\t\tif (bRelations.size === 0) {\n\t\t\t\t\tthis.relations.delete(b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected replaceRelationsUnsafely(a: string, bs: string[]): void {\n\t\tthis.relations.set(a, new Set(bs))\n\t\tfor (const b of bs) {\n\t\t\tconst bRelations = new Set([a])\n\t\t\tthis.relations.set(b, bRelations)\n\t\t}\n\t}\n\tprotected replaceRelationsSafely(a: string, bs: string[]): void {\n\t\tconst aRelationsPrev = this.relations.get(a)\n\t\tif (aRelationsPrev) {\n\t\t\tfor (const b of aRelationsPrev) {\n\t\t\t\tconst bRelations = this.relations.get(b)\n\t\t\t\tif (bRelations) {\n\t\t\t\t\tif (bRelations.size === 1) {\n\t\t\t\t\t\tthis.relations.delete(b)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbRelations.delete(a)\n\t\t\t\t\t}\n\t\t\t\t\tthis.contents.delete(this.makeContentKey(a, b))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.relations.set(a, new Set(bs))\n\t\tfor (const b of bs) {\n\t\t\tlet bRelations = this.relations.get(b)\n\t\t\tif (bRelations) {\n\t\t\t\tbRelations.add(a)\n\t\t\t} else {\n\t\t\t\tbRelations = new Set([a])\n\t\t\t\tthis.relations.set(b, bRelations)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected getContentInternal(contentKey: string): Content | undefined {\n\t\treturn this.contents.get(contentKey)\n\t}\n\tprotected setContent(contentKey: string, content: Content): void {\n\t\tthis.contents.set(contentKey, content)\n\t}\n\tprotected deleteContent(contentKey: string): void {\n\t\tthis.contents.delete(contentKey)\n\t}\n\n\tpublic constructor(\n\t\tdata: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>,\n\t\tconfig?: JunctionAdvancedConfiguration<Content>,\n\t) {\n\t\tthis.a = data.between[0]\n\t\tthis.b = data.between[1]\n\n\t\tthis.cardinality = data.cardinality\n\t\tif (!config?.externalStore) {\n\t\t\tthis.relations = new Map(data.relations?.map(([a, b]) => [a, new Set(b)]))\n\t\t\tthis.contents = new Map(data.contents)\n\t\t}\n\t\tthis.isContent = config?.isContent ?? null\n\t\tif (config?.makeContentKey) {\n\t\t\tthis.makeContentKey = config.makeContentKey\n\t\t}\n\t\tif (config?.externalStore) {\n\t\t\tconst externalStore = config.externalStore\n\t\t\tthis.has = (a, b) => externalStore.has(a, b)\n\t\t\tthis.addRelation = (a, b) => {\n\t\t\t\texternalStore.addRelation(a, b)\n\t\t\t}\n\t\t\tthis.deleteRelation = (a, b) => {\n\t\t\t\texternalStore.deleteRelation(a, b)\n\t\t\t}\n\t\t\tthis.replaceRelationsSafely = (a, bs) => {\n\t\t\t\texternalStore.replaceRelationsSafely(a, bs)\n\t\t\t}\n\t\t\tthis.replaceRelationsUnsafely = (a, bs) => {\n\t\t\t\texternalStore.replaceRelationsUnsafely(a, bs)\n\t\t\t}\n\t\t\tthis.getRelatedKeys = (key) => externalStore.getRelatedKeys(key)\n\t\t\tif (externalStore.getContent) {\n\t\t\t\tthis.getContentInternal = (contentKey) => {\n\t\t\t\t\treturn externalStore.getContent(contentKey) as any\n\t\t\t\t}\n\t\t\t\tthis.setContent = (contentKey, content) => {\n\t\t\t\t\texternalStore.setContent(contentKey, content as any)\n\t\t\t\t}\n\t\t\t\tthis.deleteContent = (contentKey) => {\n\t\t\t\t\texternalStore.deleteContent(contentKey)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [x, ys] of data.relations ?? []) {\n\t\t\t\tfor (const y of ys) this.addRelation(x, y)\n\t\t\t}\n\t\t\tfor (const [contentKey, content] of data.contents ?? []) {\n\t\t\t\tthis.setContent(contentKey, content)\n\t\t\t}\n\t\t}\n\t}\n\tpublic toJSON(): JunctionJSON<ASide, BSide, Content> {\n\t\treturn {\n\t\t\tbetween: [this.a, this.b],\n\t\t\tcardinality: this.cardinality,\n\t\t\trelations: [...this.relations.entries()].map(([a, b]) => [a, [...b]]),\n\t\t\tcontents: [...this.contents.entries()],\n\t\t}\n\t}\n\n\tpublic set(\n\t\ta: string,\n\t\t...rest: Content extends null ? [b: string] : [b: string, content: Content]\n\t): this\n\tpublic set(\n\t\trelation: { [Key in ASide | BSide]: string },\n\t\t...rest: Content extends null ? [] | [b?: undefined] : [content: Content]\n\t): this\n\tpublic set(\n\t\ta: string | { [Key in ASide | BSide]: string },\n\t\t...rest: Content extends null\n\t\t\t? [] | [b?: string | undefined]\n\t\t\t: [b: string, content: Content] | [content: Content]\n\t): this {\n\t\tconst b: string =\n\t\t\ttypeof rest[0] === `string`\n\t\t\t\t? rest[0]\n\t\t\t\t: (a[this.b as keyof typeof a] as string)\n\t\tconst content: Content | undefined =\n\t\t\trest[1] ?? typeof rest[0] === `string` ? undefined : (rest[0] as Content)\n\t\ta = typeof a === `string` ? a : a[this.a]\n\t\tswitch (this.cardinality) {\n\t\t\t// biome-ignore lint/suspicious/noFallthroughSwitchClause: perfect here\n\t\t\tcase `1:1`: {\n\t\t\t\tconst bPrev = this.getRelatedKey(a)\n\t\t\t\tif (bPrev && bPrev !== b) this.delete(bPrev, a)\n\t\t\t}\n\t\t\tcase `1:n`: {\n\t\t\t\tconst aPrev = this.getRelatedKey(b)\n\t\t\t\tif (aPrev && aPrev !== a) this.delete(aPrev, b)\n\t\t\t}\n\t\t}\n\t\tif (content) {\n\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\tthis.setContent(contentKey, content)\n\t\t}\n\t\tthis.addRelation(a, b)\n\t\treturn this\n\t}\n\n\tpublic delete(a: string, b?: string): this\n\tpublic delete(\n\t\trelation:\n\t\t\t| Record<ASide | BSide, string>\n\t\t\t| Record<ASide, string>\n\t\t\t| Record<BSide, string>,\n\t\tb?: undefined,\n\t): this\n\tpublic delete(\n\t\tx:\n\t\t\t| Record<ASide | BSide, string>\n\t\t\t| Record<ASide, string>\n\t\t\t| Record<BSide, string>\n\t\t\t| string,\n\t\tb?: string | undefined,\n\t): this {\n\t\t// @ts-expect-error we deduce that this.b may index x\n\t\tb = typeof b === `string` ? b : (x[this.b] as string | undefined)\n\t\t// @ts-expect-error we deduce that this.a may index x\n\t\tconst a = typeof x === `string` ? x : (x[this.a] as string | undefined)\n\n\t\tif (a === undefined && typeof b === `string`) {\n\t\t\tconst bRelations = this.getRelatedKeys(b)\n\t\t\tif (bRelations) {\n\t\t\t\tfor (const a of bRelations) {\n\t\t\t\t\tthis.delete(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (typeof a === `string` && b === undefined) {\n\t\t\tconst aRelations = this.getRelatedKeys(a)\n\t\t\tif (aRelations) {\n\t\t\t\tfor (const b of aRelations) {\n\t\t\t\t\tthis.delete(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (typeof a === `string` && typeof b === `string`) {\n\t\t\tthis.deleteRelation(a, b)\n\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\tthis.deleteContent(contentKey)\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getRelatedKey(key: string): string | undefined {\n\t\tconst relations = this.getRelatedKeys(key)\n\t\tif (relations) {\n\t\t\tif (relations.size > 1) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${relations.size} related keys were found for key \"${key}\": (${[\n\t\t\t\t\t\t...relations,\n\t\t\t\t\t]\n\t\t\t\t\t\t.map((k) => `\"${k}\"`)\n\t\t\t\t\t\t.join(`, `)}). Only one related key was expected.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tfor (const relation of relations) {\n\t\t\t\treturn relation\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic replaceRelations(\n\t\ta: string,\n\t\trelations: Content extends null ? string[] : Record<string, Content>,\n\t\tconfig?: { reckless: boolean },\n\t): this {\n\t\tconst hasContent = !Array.isArray(relations)\n\t\tconst bs = hasContent ? Object.keys(relations) : relations\n\t\tif (config?.reckless) {\n\t\t\tthis.replaceRelationsUnsafely(a, bs)\n\t\t} else {\n\t\t\tthis.replaceRelationsSafely(a, bs)\n\t\t}\n\t\tif (hasContent) {\n\t\t\tfor (const b of bs) {\n\t\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\t\tconst content = relations[b] as Content\n\t\t\t\tthis.setContent(contentKey, content)\n\t\t\t}\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getContent(a: string, b: string): Content | undefined {\n\t\tconst contentKey = this.makeContentKey(a, b)\n\t\treturn this.getContentInternal(contentKey)\n\t}\n\n\tpublic getRelationEntries(\n\t\tinput: Record<ASide, string> | Record<BSide, string>,\n\t): [string, Content][] {\n\t\tconst a: string | undefined = (input as any)[this.a]\n\t\tconst b: string | undefined = (input as any)[this.b]\n\t\tif (a !== undefined && b === undefined) {\n\t\t\tconst aRelations = this.getRelatedKeys(a)\n\t\t\tif (aRelations) {\n\t\t\t\treturn [...aRelations].map((b) => {\n\t\t\t\t\treturn [b, this.getContent(a, b) ?? (null as Content)]\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (a === undefined && b !== undefined) {\n\t\t\tconst bRelations = this.getRelatedKeys(b)\n\t\t\tif (bRelations) {\n\t\t\t\treturn [...bRelations].map((a) => {\n\t\t\t\t\treturn [a, this.getContent(a, b) ?? (null as Content)]\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn []\n\t}\n\n\tpublic has(a: string, b?: string): boolean {\n\t\tif (b) {\n\t\t\tconst setA = this.getRelatedKeys(a)\n\t\t\treturn setA?.has(b) ?? false\n\t\t}\n\t\treturn this.relations.has(a)\n\t}\n}\n","import { AtomIOLogger } from \"atom.io\"\nimport type {\n\tAtomFamily,\n\tAtomToken,\n\tLogger,\n\tReadonlySelectorFamily,\n\tReadonlySelectorToken,\n\tSelectorFamily,\n\tSelectorToken,\n\tTimelineToken,\n\tTransactionToken,\n\tÆn,\n} from \"atom.io\"\n\nimport { Junction } from \"~/packages/rel8/junction/src\"\n\nimport type { Atom } from \"../atom\"\nimport type { Lineage } from \"../lineage\"\nimport type { MutableAtom, Tracker, Transceiver } from \"../mutable\"\nimport type { OperationProgress } from \"../operation\"\nimport type { ReadonlySelector, Selector } from \"../selector\"\nimport { StatefulSubject, Subject } from \"../subject\"\nimport type { Timeline } from \"../timeline\"\nimport type { Transaction, TransactionMeta } from \"../transaction\"\n\n// export type StoreCore = Pick<\n// \tStore,\n// \t| `atoms`\n// \t| `atomsThatAreDefault`\n// \t| `families`\n// \t| `operation`\n// \t| `readonlySelectors`\n// \t| `selectorAtoms`\n// \t| `selectorGraph`\n// \t| `selectors`\n// \t| `timelineAtoms`\n// \t| `timelines`\n// \t| `trackers`\n// \t| `transactions`\n// \t| `valueMap`\n// >\n\nexport class Store implements Lineage {\n\tpublic parent: Store | null = null\n\tpublic child: Store | null = null\n\n\tpublic valueMap = new Map<string, any>()\n\n\tpublic atoms = new Map<string, Atom<any> | MutableAtom<any>>()\n\tpublic selectors = new Map<string, Selector<any>>()\n\tpublic readonlySelectors = new Map<string, ReadonlySelector<any>>()\n\n\tpublic trackers = new Map<string, Tracker<Transceiver<any>>>()\n\tpublic families = new Map<\n\t\tstring,\n\t\t| AtomFamily<any, any>\n\t\t| ReadonlySelectorFamily<any, any>\n\t\t| SelectorFamily<any, any>\n\t>()\n\n\tpublic timelines = new Map<string, Timeline>()\n\tpublic transactions = new Map<string, Transaction<Æn>>()\n\n\tpublic atomsThatAreDefault = new Set<string>()\n\n\tpublic timelineAtoms = new Junction({\n\t\tbetween: [`timelineKey`, `atomKey`],\n\t\tcardinality: `1:n`,\n\t})\n\tpublic selectorAtoms = new Junction({\n\t\tbetween: [`selectorKey`, `atomKey`],\n\t\tcardinality: `n:n`,\n\t})\n\tpublic selectorGraph = new Junction<\n\t\t`upstreamSelectorKey`,\n\t\t`downstreamSelectorKey`,\n\t\t{ source: string }\n\t>(\n\t\t{\n\t\t\tbetween: [`upstreamSelectorKey`, `downstreamSelectorKey`],\n\t\t\tcardinality: `n:n`,\n\t\t},\n\t\t{\n\t\t\tmakeContentKey: (...keys) => keys.sort().join(`:`),\n\t\t},\n\t)\n\n\tpublic subject = {\n\t\tatomCreation: new Subject<AtomToken<unknown>>(),\n\t\tselectorCreation: new Subject<\n\t\t\tReadonlySelectorToken<unknown> | SelectorToken<unknown>\n\t\t>(),\n\t\ttransactionCreation: new Subject<TransactionToken<Æn>>(),\n\t\ttimelineCreation: new Subject<TimelineToken>(),\n\t\ttransactionApplying: new StatefulSubject<TransactionMeta<Æn> | null>(null),\n\t\toperationStatus: new Subject<OperationProgress>(),\n\t}\n\tpublic operation: OperationProgress = { open: false }\n\tpublic transactionMeta: TransactionMeta<Æn> | null = null\n\n\tpublic config: {\n\t\tname: string\n\t} = {\n\t\tname: `IMPLICIT_STORE`,\n\t}\n\n\tpublic loggers: AtomIOLogger[] = [\n\t\tnew AtomIOLogger(`warn`, (_, __, key) => !key.includes(`ðâðš`)),\n\t]\n\tpublic logger: Logger = {\n\t\terror: (...messages) => {\n\t\t\tfor (const logger of this.loggers) logger.error(...messages)\n\t\t},\n\t\tinfo: (...messages) => {\n\t\t\tfor (const logger of this.loggers) logger.info(...messages)\n\t\t},\n\t\twarn: (...messages) => {\n\t\t\tfor (const logger of this.loggers) logger.warn(...messages)\n\t\t},\n\t}\n\n\tpublic constructor(name: string, store: Store | null = null) {\n\t\tif (store !== null) {\n\t\t\tthis.valueMap = new Map(store?.valueMap)\n\t\t\tthis.operation = { ...store?.operation }\n\t\t\tthis.transactionMeta = store?.transactionMeta\n\t\t\t\t? { ...store?.transactionMeta }\n\t\t\t\t: null\n\t\t\tthis.config = {\n\t\t\t\t...store?.config,\n\t\t\t\tname,\n\t\t\t}\n\n\t\t\tfor (const [, atom] of store.atoms) {\n\t\t\t\tatom.install(this)\n\t\t\t}\n\t\t\tfor (const [, selector] of store.readonlySelectors) {\n\t\t\t\tselector.install(this)\n\t\t\t}\n\t\t\tfor (const [, selector] of store.selectors) {\n\t\t\t\tselector.install(this)\n\t\t\t}\n\t\t\tfor (const [, tx] of store.transactions) {\n\t\t\t\ttx.install(this)\n\t\t\t}\n\t\t\tfor (const [, timeline] of store.timelines) {\n\t\t\t\ttimeline.install(this)\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport const IMPLICIT = {\n\tSTORE_INTERNAL: undefined as Store | undefined,\n\tget STORE(): Store {\n\t\treturn (\n\t\t\tthis.STORE_INTERNAL ?? (this.STORE_INTERNAL = new Store(`IMPLICIT_STORE`))\n\t\t)\n\t},\n}\n\nexport const clearStore = (store: Store): void => {\n\tconst { config } = store\n\tObject.assign(store, new Store(config.name))\n\tstore.config = config\n}\n","import type {\n\tAtomToken,\n\tReadonlySelectorToken,\n\tSelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTransactionToken,\n\tÆn,\n} from \"atom.io\"\n\nimport type { Atom } from \"../atom\"\nimport { newest } from \"../lineage\"\nimport type { ReadonlySelector, Selector } from \"../selector\"\nimport type { Timeline } from \"../timeline\"\nimport type { Transaction } from \"../transaction\"\nimport type { Store } from \"./store\"\n\nexport function withdraw<T>(\n\ttoken: AtomToken<T>,\n\tstore: Store,\n): Atom<T> | undefined\nexport function withdraw<T>(\n\ttoken: SelectorToken<T>,\n\tstore: Store,\n): Selector<T> | undefined\nexport function withdraw<T>(\n\ttoken: StateToken<T>,\n\tstore: Store,\n): Atom<T> | Selector<T> | undefined\nexport function withdraw<T>(\n\ttoken: ReadonlySelectorToken<T>,\n\tstore: Store,\n): ReadonlySelector<T> | undefined\nexport function withdraw<T>(\n\ttoken: TransactionToken<T>,\n\tstore: Store,\n): Transaction<T extends Æn ? T : never> | undefined\nexport function withdraw<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Store,\n): Atom<T> | ReadonlySelector<T> | Selector<T> | undefined\nexport function withdraw<T>(\n\ttoken: TimelineToken,\n\tstore: Store,\n): Timeline | undefined\nexport function withdraw<T>(\n\ttoken:\n\t\t| ReadonlySelectorToken<T>\n\t\t| StateToken<T>\n\t\t| TimelineToken\n\t\t| TransactionToken<T>,\n\tstore: Store,\n):\n\t| Atom<T>\n\t| ReadonlySelector<T>\n\t| Selector<T>\n\t| Timeline\n\t| Transaction<T extends Æn ? T : never>\n\t| undefined {\n\tconst target = newest(store)\n\tconst state =\n\t\ttarget.atoms.get(token.key) ??\n\t\ttarget.selectors.get(token.key) ??\n\t\ttarget.readonlySelectors.get(token.key) ??\n\t\ttarget.transactions.get(token.key) ??\n\t\ttarget.timelines.get(token.key)\n\tif (state) {\n\t\treturn state\n\t}\n\t// if (target.transactionMeta?.phase === `applying`) {\n\n\t// \tstate =\n\t// \t\ttarget.atoms.get(token.key) ??\n\t// \t\tcore.selectors.get(token.key) ??\n\t// \t\tcore.readonlySelectors.get(token.key) ??\n\t// \t\tcore.transactions.get(token.key) ??\n\t// \t\tcore.timelines.get(token.key)\n\n\t// \tif (state) {\n\t// \t\tstore.logger.info(\n\t// \t\t\t`ð ïž`,\n\t// \t\t\ttoken.type,\n\t// \t\t\ttoken.key,\n\t// \t\t\t`add ${token.type} \"${token.key}\"`,\n\t// \t\t)\n\t// \t\tswitch (state.type) {\n\t// \t\t\tcase `atom`: {\n\t// \t\t\t\tstore.atoms.set(token.key, state)\n\t// \t\t\t\tstore.valueMap.set(token.key, state.default)\n\t// \t\t\t\tconst stateKey = state.key\n\t// \t\t\t\tconst familyKey = state.family?.key\n\t// \t\t\t\tlet timelineKey = core.timelineAtoms.getRelatedKey(stateKey)\n\t// \t\t\t\tif (timelineKey === undefined && typeof familyKey === `string`) {\n\t// \t\t\t\t\ttimelineKey = core.timelineAtoms.getRelatedKey(familyKey)\n\t// \t\t\t\t}\n\t// \t\t\t\tconst timeline =\n\t// \t\t\t\t\ttypeof timelineKey === `string`\n\t// \t\t\t\t\t\t? store.timelines.get(timelineKey)\n\t// \t\t\t\t\t\t: undefined\n\n\t// \t\t\t\tif (timeline) {\n\t// \t\t\t\t\taddAtomToTimeline(state, timeline, store)\n\t// \t\t\t\t}\n\t// \t\t\t\tbreak\n\t// \t\t\t}\n\t// \t\t\tcase `selector`:\n\t// \t\t\t\tcore.selectors.set(token.key, state)\n\t// \t\t\t\tbreak\n\t// \t\t\tcase `readonly_selector`:\n\t// \t\t\t\tcore.readonlySelectors.set(token.key, state)\n\t// \t\t\t\tbreak\n\t// \t\t\tcase `transaction`:\n\t// \t\t\t\tcore.transactions.set(token.key, state)\n\t// \t\t\t\tbreak\n\t// \t\t\tcase `timeline`:\n\t// \t\t\t\tcore.timelines.set(token.key, state)\n\t// \t\t\t\tbreak\n\t// \t\t}\n\t// \t\treturn state\n\t// \t}\n\t// }\n\treturn undefined\n}\n","import type {\n\tAtomToken,\n\tReadonlySelectorToken,\n\tSelectorToken,\n\tStateToken,\n} from \"atom.io\"\nimport type { Atom, ReadonlySelector, Selector, Store } from \"..\"\nimport { newest, withdraw } from \"..\"\n\nexport function withdrawNewFamilyMember<T>(\n\ttoken: AtomToken<T>,\n\tstore: Store,\n): Atom<T> | undefined\nexport function withdrawNewFamilyMember<T>(\n\ttoken: SelectorToken<T>,\n\tstore: Store,\n): Selector<T> | undefined\nexport function withdrawNewFamilyMember<T>(\n\ttoken: ReadonlySelectorToken<T>,\n\tstore: Store,\n): ReadonlySelector<T> | undefined\nexport function withdrawNewFamilyMember<T>(\n\ttoken: StateToken<T>,\n\tstore: Store,\n): Atom<T> | Selector<T> | undefined\nexport function withdrawNewFamilyMember<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Store,\n): Atom<T> | ReadonlySelector<T> | Selector<T> | undefined\nexport function withdrawNewFamilyMember<T>(\n\ttoken:\n\t\t| AtomToken<T>\n\t\t| ReadonlySelectorToken<T>\n\t\t| SelectorToken<T>\n\t\t| StateToken<T>,\n\tstore: Store,\n): Atom<T> | ReadonlySelector<T> | Selector<T> | undefined {\n\tif (token.family) {\n\t\tstore.logger.info(\n\t\t\t`ðª`,\n\t\t\ttoken.type,\n\t\t\ttoken.key,\n\t\t\t`creating new family member in store \"${store.config.name}\"`,\n\t\t)\n\t\tconst target = newest(store)\n\t\tconst family = target.families.get(token.family.key)\n\t\tif (family) {\n\t\t\tconst jsonSubKey = JSON.parse(token.family.subKey)\n\t\t\tfamily(jsonSubKey)\n\t\t\tconst state = withdraw(token, store)\n\t\t\treturn state\n\t\t}\n\t}\n\treturn undefined\n}\n","import { newest } from \"./lineage\"\nimport type { Store } from \"./store\"\n\nexport type AtomKey<T> = string & { __atomKey?: never; __brand?: T }\nexport type SelectorKey<T> = string & { __selectorKey?: never; __brand?: T }\nexport type ReadonlySelectorKey<T> = string & {\n\t__readonlySelectorKey?: never\n\t__brand?: T\n}\n\nexport const isAtomKey = (key: string, store: Store): key is AtomKey<unknown> =>\n\tnewest(store).atoms.has(key)\nexport const isSelectorKey = (\n\tkey: string,\n\tstore: Store,\n): key is SelectorKey<unknown> => newest(store).selectors.has(key)\nexport const isReadonlySelectorKey = (\n\tkey: string,\n\tstore: Store,\n): key is ReadonlySelectorKey<unknown> =>\n\tnewest(store).readonlySelectors.has(key)\n\nexport type StateKey<T> = AtomKey<T> | ReadonlySelectorKey<T> | SelectorKey<T>\nexport const isStateKey = (\n\tkey: string,\n\tstore: Store,\n): key is StateKey<unknown> =>\n\tisAtomKey(key, store) ||\n\tisSelectorKey(key, store) ||\n\tisReadonlySelectorKey(key, store)\n","import type { AtomKey, ReadonlySelectorKey, SelectorKey } from \"../keys\"\nimport { isStateKey } from \"../keys\"\nimport { newest } from \"../lineage\"\nimport type { Store } from \"../store\"\n\nexport const getSelectorDependencyKeys = (\n\tkey: string,\n\tstore: Store,\n): (\n\t| AtomKey<unknown>\n\t| ReadonlySelectorKey<unknown>\n\t| SelectorKey<unknown>\n)[] => {\n\tconst sources = newest(store)\n\t\t.selectorGraph.getRelationEntries({ downstreamSelectorKey: key })\n\t\t.filter(([_, { source }]) => source !== key)\n\t\t.map(([_, { source }]) => source)\n\t\t.filter((source) => isStateKey(source, store))\n\treturn sources\n}\n","import type { Store } from \"..\"\nimport type { AtomKey, StateKey } from \"../keys\"\nimport { isAtomKey } from \"../keys\"\nimport { getSelectorDependencyKeys } from \"./get-selector-dependency-keys\"\n\nexport const traceSelectorAtoms = (\n\tselectorKey: string,\n\tdirectDependencyKey: StateKey<unknown>,\n\tstore: Store,\n): AtomKey<unknown>[] => {\n\tconst rootKeys: AtomKey<unknown>[] = []\n\n\tconst indirectDependencyKeys = getSelectorDependencyKeys(\n\t\tdirectDependencyKey,\n\t\tstore,\n\t)\n\tlet depth = 0\n\twhile (indirectDependencyKeys.length > 0) {\n\t\t// biome-ignore lint/style/noNonNullAssertion: just checked length ^^^\n\t\tconst indirectDependencyKey = indirectDependencyKeys.shift()!\n\t\t++depth\n\t\tif (depth > 99999) {\n\t\t\tthrow new Error(\n\t\t\t\t`Maximum selector dependency depth exceeded (> 99999) in selector \"${selectorKey}\". This is likely due to a circular dependency.`,\n\t\t\t)\n\t\t}\n\n\t\tif (!isAtomKey(indirectDependencyKey, store)) {\n\t\t\tindirectDependencyKeys.push(\n\t\t\t\t...getSelectorDependencyKeys(indirectDependencyKey, store),\n\t\t\t)\n\t\t} else if (!rootKeys.includes(indirectDependencyKey)) {\n\t\t\trootKeys.push(indirectDependencyKey)\n\t\t}\n\t}\n\n\treturn rootKeys\n}\n\nexport const traceAllSelectorAtoms = (\n\tselectorKey: string,\n\tstore: Store,\n): AtomKey<unknown>[] => {\n\tconst directDependencyKeys = getSelectorDependencyKeys(selectorKey, store)\n\treturn directDependencyKeys.flatMap((depKey) =>\n\t\tisAtomKey(depKey, store)\n\t\t\t? depKey\n\t\t\t: traceSelectorAtoms(selectorKey, depKey, store),\n\t)\n}\n","import type { ReadonlySelectorToken, StateToken } from \"atom.io\"\n\nimport { newest } from \"../lineage\"\nimport type { Store } from \"../store\"\nimport { traceSelectorAtoms } from \"./trace-selector-atoms\"\n\nexport const updateSelectorAtoms = (\n\tselectorKey: string,\n\tdependency: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store,\n): void => {\n\tconst target = newest(store)\n\tif (dependency.type === `atom`) {\n\t\ttarget.selectorAtoms.set({\n\t\t\tselectorKey,\n\t\t\tatomKey: dependency.key,\n\t\t})\n\t\tstore.logger.info(\n\t\t\t`ð`,\n\t\t\t`selector`,\n\t\t\tselectorKey,\n\t\t\t`discovers root atom \"${dependency.key}\"`,\n\t\t)\n\t} else {\n\t\tconst rootKeys = traceSelectorAtoms(selectorKey, dependency.key, store)\n\t\tstore.logger.info(\n\t\t\t`ð`,\n\t\t\t`selector`,\n\t\t\tselectorKey,\n\t\t\t`discovers root atoms: [ ${rootKeys\n\t\t\t\t.map((key) => `\"${key}\"`)\n\t\t\t\t.join(`, `)} ]`,\n\t\t)\n\t\tfor (const atomKey of rootKeys) {\n\t\t\ttarget.selectorAtoms = target.selectorAtoms.set({\n\t\t\t\tselectorKey,\n\t\t\t\tatomKey,\n\t\t\t})\n\t\t}\n\t}\n}\n","import type { Transactors } from \"atom.io\"\n\nimport { newest } from \"../lineage\"\nimport { readOrComputeValue } from \"../read-or-compute-value\"\nimport { setAtomOrSelector } from \"../set-state\"\nimport type { Store } from \"../store\"\nimport { withdraw } from \"../store\"\nimport { updateSelectorAtoms } from \"./update-selector-atoms\"\n\nexport const registerSelector = (\n\tselectorKey: string,\n\tstore: Store,\n): Transactors => ({\n\tget: (dependency) => {\n\t\tconst target = newest(store)\n\t\tconst alreadyRegistered = target.selectorGraph\n\t\t\t.getRelationEntries({ downstreamSelectorKey: selectorKey })\n\t\t\t.some(([_, { source }]) => source === dependency.key)\n\n\t\tconst dependencyState = withdraw(dependency, store)\n\t\tif (dependencyState === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${dependency.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t\t)\n\t\t}\n\t\tconst dependencyValue = readOrComputeValue(dependencyState, store)\n\n\t\tstore.logger.info(\n\t\t\t`ð`,\n\t\t\t`selector`,\n\t\t\tselectorKey,\n\t\t\t`registers dependency ( \"${dependency.key}\" =`,\n\t\t\tdependencyValue,\n\t\t\t`)`,\n\t\t)\n\n\t\tif (!alreadyRegistered) {\n\t\t\ttarget.selectorGraph.set(\n\t\t\t\t{\n\t\t\t\t\tupstreamSelectorKey: dependency.key,\n\t\t\t\t\tdownstreamSelectorKey: selectorKey,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tsource: dependency.key,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tupdateSelectorAtoms(selectorKey, dependency, store)\n\t\treturn dependencyValue\n\t},\n\tset: (stateToken, newValue) => {\n\t\tconst state = withdraw(stateToken, store)\n\t\tif (state === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${stateToken.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t\t)\n\t\t}\n\t\tsetAtomOrSelector(state, newValue, store)\n\t},\n})\n","import type { FamilyMetadata, SelectorOptions, SelectorToken } from \"atom.io\"\n\nimport { cacheValue } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport { markDone } from \"../operation\"\nimport { become } from \"../set-state/become\"\nimport type { Store } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { Selector } from \"./create-selector\"\nimport { createSelector } from \"./create-selector\"\nimport { registerSelector } from \"./register-selector\"\n\nexport const createReadWriteSelector = <T>(\n\toptions: SelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n): SelectorToken<T> => {\n\tconst target = newest(store)\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\n\tconst { get, set } = registerSelector(options.key, store)\n\tconst getSelf = () => {\n\t\tconst value = options.get({ get })\n\t\tcacheValue(options.key, value, subject, store)\n\t\treturn value\n\t}\n\n\tconst setSelf = (next: T | ((oldValue: T) => T)): void => {\n\t\tconst oldValue = getSelf()\n\t\tconst newValue = become(next)(oldValue)\n\t\t// store.logger.info(`ð set \"${options.key}\" (`, oldValue, `->`, newValue, `)`)\n\t\tstore.logger.info(\n\t\t\t`ð`,\n\t\t\t`selector`,\n\t\t\toptions.key,\n\t\t\t`set (`,\n\t\t\toldValue,\n\t\t\t`->`,\n\t\t\tnewValue,\n\t\t\t`)`,\n\t\t)\n\t\tcacheValue(options.key, newValue, subject, store)\n\t\tmarkDone(options.key, store)\n\t\tif (target.transactionMeta === null) {\n\t\t\tsubject.next({ newValue, oldValue })\n\t\t}\n\t\toptions.set({ get, set }, newValue)\n\t}\n\tconst mySelector: Selector<T> = {\n\t\t...options,\n\t\tsubject,\n\t\tinstall: (s: Store) => createSelector(options, family, s),\n\t\tget: getSelf,\n\t\tset: setSelf,\n\t\ttype: `selector`,\n\t\t...(family && { family }),\n\t}\n\ttarget.selectors.set(options.key, mySelector) // â\n\tconst initialValue = getSelf()\n\tstore.logger.info(`âš`, mySelector.type, mySelector.key, `=`, initialValue)\n\tconst token: SelectorToken<T> = {\n\t\tkey: options.key,\n\t\ttype: `selector`,\n\t}\n\tif (family) {\n\t\ttoken.family = family\n\t}\n\tstore.subject.selectorCreation.next(token)\n\treturn token\n}\n","import type {\n\tFamilyMetadata,\n\tReadonlySelectorOptions,\n\tReadonlySelectorToken,\n} from \"atom.io\"\n\nimport { cacheValue } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport type { Store } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { ReadonlySelector } from \"./create-selector\"\nimport { createSelector } from \"./create-selector\"\nimport { registerSelector } from \"./register-selector\"\n\nexport const createReadonlySelector = <T>(\n\toptions: ReadonlySelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n): ReadonlySelectorToken<T> => {\n\tconst target = newest(store)\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\n\tconst { get } = registerSelector(options.key, store)\n\tconst getSelf = () => {\n\t\tconst value = options.get({ get })\n\t\tcacheValue(options.key, value, subject, store)\n\t\treturn value\n\t}\n\n\tconst readonlySelector: ReadonlySelector<T> = {\n\t\t...options,\n\t\tsubject,\n\t\tinstall: (s: Store) => createSelector(options, family, s),\n\t\tget: getSelf,\n\t\ttype: `readonly_selector`,\n\t\t...(family && { family }),\n\t}\n\ttarget.readonlySelectors.set(options.key, readonlySelector)\n\tconst initialValue = getSelf()\n\tstore.logger.info(\n\t\t`âš`,\n\t\treadonlySelector.type,\n\t\treadonlySelector.key,\n\t\t`=`,\n\t\tinitialValue,\n\t)\n\tconst token: ReadonlySelectorToken<T> = {\n\t\tkey: options.key,\n\t\ttype: `readonly_selector`,\n\t}\n\tif (family) {\n\t\ttoken.family = family\n\t}\n\tstore.subject.selectorCreation.next(token)\n\treturn token\n}\n","import type {\n\tFamilyMetadata,\n\tReadonlySelectorOptions,\n\tReadonlySelectorToken,\n\tSelectorOptions,\n\tSelectorToken,\n} from \"atom.io\"\n\nimport { newest } from \"../lineage\"\nimport type { Store } from \"../store\"\nimport type { Subject } from \"../subject\"\nimport { createReadWriteSelector } from \"./create-read-write-selector\"\nimport { createReadonlySelector } from \"./create-readonly-selector\"\n\nexport type Selector<T> = {\n\tkey: string\n\ttype: `selector`\n\tfamily?: FamilyMetadata\n\tinstall: (store: Store) => void\n\tsubject: Subject<{ newValue: T; oldValue: T }>\n\tget: () => T\n\tset: (newValue: T | ((oldValue: T) => T)) => void\n}\nexport type ReadonlySelector<T> = {\n\tkey: string\n\ttype: `readonly_selector`\n\tfamily?: FamilyMetadata\n\tinstall: (store: Store) => void\n\tsubject: Subject<{ newValue: T; oldValue: T }>\n\tget: () => T\n}\n\nexport function createSelector<T>(\n\toptions: SelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n): SelectorToken<T>\nexport function createSelector<T>(\n\toptions: ReadonlySelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n): ReadonlySelectorToken<T>\nexport function createSelector<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\tconst target = newest(store)\n\tconst existingWritable = target.selectors.get(options.key)\n\tconst existingReadonly = target.readonlySelectors.get(options.key)\n\n\tif (existingWritable || existingReadonly) {\n\t\tstore.logger.error(\n\t\t\t`â`,\n\t\t\texistingReadonly ? `readonly_selector` : `selector`,\n\t\t\toptions.key,\n\t\t\t`Tried to create selector, but it already exists in the store. (Ignore if you are in development using hot module replacement.)`,\n\t\t)\n\t}\n\n\tif (`set` in options) {\n\t\treturn createReadWriteSelector(options, family, store)\n\t}\n\treturn createReadonlySelector(options, family, store)\n}\n","import type { ReadonlySelectorToken, SelectorToken } from \"atom.io\"\n\nimport { newest } from \"..\"\nimport type { Store } from \"..\"\n\nexport function deleteSelector(\n\tselectorToken: ReadonlySelectorToken<unknown> | SelectorToken<unknown>,\n\tstore: Store,\n): void {\n\tconst target = newest(store)\n\tconst { key } = selectorToken\n\tswitch (selectorToken.type) {\n\t\tcase `selector`:\n\t\t\ttarget.selectors.delete(key)\n\t\t\tbreak\n\t\tcase `readonly_selector`:\n\t\t\ttarget.readonlySelectors.delete(key)\n\t\t\tbreak\n\t}\n\ttarget.valueMap.delete(key)\n\ttarget.selectorAtoms.delete(key)\n\tconst downstreamTokens = target.selectorGraph\n\t\t.getRelationEntries({ upstreamSelectorKey: key })\n\t\t.filter(([_, { source }]) => source === key)\n\t\t.map(\n\t\t\t([downstreamSelectorKey]) =>\n\t\t\t\ttarget.selectors.get(downstreamSelectorKey) ??\n\t\t\t\ttarget.readonlySelectors.get(downstreamSelectorKey),\n\t\t)\n\tfor (const downstreamToken of downstreamTokens) {\n\t\tif (downstreamToken) {\n\t\t\tdeleteSelector(downstreamToken, store)\n\t\t}\n\t}\n\ttarget.selectorGraph.delete(key)\n\tstore.logger.info(`ð¥`, selectorToken.type, `${key}`, `deleted`)\n}\n","import type { Atom } from \"../atom\"\nimport { newest } from \"../lineage\"\nimport type { ReadonlySelector, Selector } from \"../selector\"\nimport type { Store } from \"../store\"\n\nexport const recallState = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store,\n): T => {\n\tconst target = newest(store)\n\tif (!target.operation.open) {\n\t\treturn target.valueMap.get(state.key)\n\t}\n\treturn target.operation.prev.get(state.key)\n}\n","import { readOrComputeValue } from \"../read-or-compute-value\"\nimport type { ReadonlySelector, Selector } from \"../selector\"\nimport { traceAllSelectorAtoms } from \"../selector\"\nimport type { Store } from \"../store\"\nimport { recallState } from \"./recall-state\"\n\nexport const subscribeToRootAtoms = <T>(\n\tstate: ReadonlySelector<T> | Selector<T>,\n\tstore: Store,\n): (() => void)[] | null => {\n\tconst dependencySubscriptions =\n\t\t`default` in state\n\t\t\t? null\n\t\t\t: traceAllSelectorAtoms(state.key, store).map((atomKey) => {\n\t\t\t\t\tconst atom = store.atoms.get(atomKey)\n\t\t\t\t\tif (atom === undefined) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Atom \"${atomKey}\", a dependency of selector \"${state.key}\", not found in store \"${store.config.name}\".`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn atom.subject.subscribe(\n\t\t\t\t\t\t`${state.type}:${state.key}`,\n\t\t\t\t\t\t(atomChange) => {\n\t\t\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t\t\t`ð¢`,\n\t\t\t\t\t\t\t\tstate.type,\n\t\t\t\t\t\t\t\tstate.key,\n\t\t\t\t\t\t\t\t`root`,\n\t\t\t\t\t\t\t\tatomKey,\n\t\t\t\t\t\t\t\t`went`,\n\t\t\t\t\t\t\t\tatomChange.oldValue,\n\t\t\t\t\t\t\t\t`->`,\n\t\t\t\t\t\t\t\tatomChange.newValue,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tconst oldValue = recallState(state, store)\n\t\t\t\t\t\t\t// â this retrieves a stale cached value when applying a transaction on the server\n\t\t\t\t\t\t\tconst newValue = readOrComputeValue(state, store)\n\t\t\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t\t\t`âš`,\n\t\t\t\t\t\t\t\tstate.type,\n\t\t\t\t\t\t\t\tstate.key,\n\t\t\t\t\t\t\t\t`went`,\n\t\t\t\t\t\t\t\toldValue,\n\t\t\t\t\t\t\t\t`->`,\n\t\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tstate.subject.next({ newValue, oldValue })\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t })\n\treturn dependencySubscriptions\n}\n","import type { ReadonlySelectorToken, StateToken, UpdateHandler } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { subscribeToRootAtoms, withdraw } from \"atom.io/internal\"\n\nexport function subscribeToState<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tkey: string,\n\tstore: Store,\n): () => void {\n\tconst state = withdraw<T>(token, store)\n\tif (state === undefined) {\n\t\tthrow new Error(\n\t\t\t`State \"${token.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t)\n\t}\n\tconst unsubFunction = state.subject.subscribe(key, handleUpdate)\n\tstore.logger.info(`ð`, state.type, state.key, `Adding subscription \"${key}\"`)\n\tconst dependencyUnsubFunctions =\n\t\tstate.type !== `atom` ? subscribeToRootAtoms(state, store) : null\n\n\tconst unsubscribe =\n\t\tdependencyUnsubFunctions === null\n\t\t\t? () => {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`ð`,\n\t\t\t\t\t\tstate.type,\n\t\t\t\t\t\tstate.key,\n\t\t\t\t\t\t`Removing subscription \"${key}\"`,\n\t\t\t\t\t)\n\t\t\t\t\tunsubFunction()\n\t\t\t }\n\t\t\t: () => {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`ð`,\n\t\t\t\t\t\tstate.type,\n\t\t\t\t\t\tstate.key,\n\t\t\t\t\t\t`Removing subscription \"${key}\"`,\n\t\t\t\t\t)\n\t\t\t\t\tunsubFunction()\n\t\t\t\t\tfor (const unsubFromDependency of dependencyUnsubFunctions) {\n\t\t\t\t\t\tunsubFromDependency()\n\t\t\t\t\t}\n\t\t\t }\n\n\treturn unsubscribe\n}\n","import type { TimelineToken, TimelineUpdate } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { withdraw } from \"atom.io/internal\"\n\nexport const subscribeToTimeline = (\n\ttoken: TimelineToken,\n\thandleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void,\n\tkey: string,\n\tstore: Store,\n): (() => void) => {\n\tconst tl = withdraw(token, store)\n\tif (tl === undefined) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to timeline \"${token.key}\": timeline not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.logger.info(`ð`, `timeline`, token.key, `Adding subscription \"${key}\"`)\n\tconst unsubscribe = tl.subject.subscribe(key, handleUpdate)\n\treturn () => {\n\t\tstore.logger.info(\n\t\t\t`ð`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Removing subscription \"${key}\" from timeline`,\n\t\t)\n\t\tunsubscribe()\n\t}\n}\n","import type { AtomToken, FamilyMetadata, MutableAtomToken } from \"atom.io\"\nimport { getState, setState } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { Store } from \"..\"\nimport { newest, subscribeToState, subscribeToTimeline } from \"..\"\nimport { createAtom, deleteAtom } from \"../atom\"\nimport type { Transceiver } from \"./transceiver\"\n\n/**\n * @internal Give the tracker a transceiver state and a store, and it will\n * subscribe to the transceiver's inner value. When the inner value changes,\n * the tracker will update its own state to reflect the change.\n */\nexport class Tracker<Mutable extends Transceiver<any>> {\n\tprivate Update: Mutable extends Transceiver<infer Signal> ? Signal : never\n\n\tprivate initializeState(\n\t\tmutableState: MutableAtomToken<Mutable, Json.Serializable>,\n\t\tstore: Store,\n\t): AtomToken<typeof this.Update | null> {\n\t\tconst latestUpdateStateKey = `*${mutableState.key}`\n\t\tdeleteAtom({ type: `atom`, key: latestUpdateStateKey }, store)\n\t\tconst familyMetaData: FamilyMetadata | undefined = mutableState.family\n\t\t\t? {\n\t\t\t\t\tkey: `*${mutableState.family.key}`,\n\t\t\t\t\tsubKey: mutableState.family.subKey,\n\t\t\t }\n\t\t\t: undefined\n\t\tconst latestUpdateState = createAtom<\n\t\t\t(Mutable extends Transceiver<infer Signal> ? Signal : never) | null\n\t\t>(\n\t\t\t{\n\t\t\t\tkey: latestUpdateStateKey,\n\t\t\t\tdefault: null,\n\t\t\t},\n\t\t\tfamilyMetaData,\n\t\t\tstore,\n\t\t)\n\n\t\treturn latestUpdateState\n\t}\n\n\tprivate unsubscribeFromInnerValue: (() => void) | null = null\n\tprivate observeCore(\n\t\tmutableState: MutableAtomToken<Mutable, Json.Serializable>,\n\t\tlatestUpdateState: AtomToken<typeof this.Update | null>,\n\t\tstore: Store,\n\t): void {\n\t\tconst originalInnerValue = getState(mutableState, store)\n\t\tconst target = newest(store)\n\t\tthis.unsubscribeFromInnerValue = originalInnerValue.subscribe(\n\t\t\t`tracker:${store.config.name}:${\n\t\t\t\ttarget.transactionMeta === null\n\t\t\t\t\t? `main`\n\t\t\t\t\t: target.transactionMeta.update.key\n\t\t\t}`,\n\t\t\t(update) => {\n\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\tmutableState.key,\n\t\t\t\t\t() => {\n\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\tsetState(latestUpdateState, update, store)\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t},\n\t\t)\n\t\tsubscribeToState(\n\t\t\tmutableState,\n\t\t\t(update) => {\n\t\t\t\tif (update.newValue !== update.oldValue) {\n\t\t\t\t\tthis.unsubscribeFromInnerValue?.()\n\t\t\t\t\tconst target = newest(store)\n\t\t\t\t\tthis.unsubscribeFromInnerValue = update.newValue.subscribe(\n\t\t\t\t\t\t`tracker:${store.config.name}:${\n\t\t\t\t\t\t\ttarget.transactionMeta === null\n\t\t\t\t\t\t\t\t? `main`\n\t\t\t\t\t\t\t\t: target.transactionMeta.update.key\n\t\t\t\t\t\t}`,\n\t\t\t\t\t\t(update) => {\n\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\tmutableState.key,\n\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\tsetState(latestUpdateState, update, store)\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t\t`${store.config.name}: tracker observing inner value`,\n\t\t\tstore,\n\t\t)\n\t}\n\n\tprivate updateCore<Core extends Transceiver<any>>(\n\t\tmutableState: MutableAtomToken<Core, Json.Serializable>,\n\t\tlatestUpdateState: AtomToken<typeof this.Update | null>,\n\t\tstore: Store,\n\t): void {\n\t\tsubscribeToState(\n\t\t\tlatestUpdateState,\n\t\t\t({ newValue, oldValue }) => {\n\t\t\t\tconst timelineId = store.timelineAtoms.getRelatedKey(\n\t\t\t\t\tlatestUpdateState.key,\n\t\t\t\t)\n\t\t\t\tif (timelineId) {\n\t\t\t\t\tconst timelineData = store.timelines.get(timelineId)\n\t\t\t\t\tif (timelineData?.timeTraveling) {\n\t\t\t\t\t\tconst unsubscribe = subscribeToTimeline(\n\t\t\t\t\t\t\t{ key: timelineId, type: `timeline` },\n\t\t\t\t\t\t\t(update) => {\n\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\tsetState(\n\t\t\t\t\t\t\t\t\tmutableState,\n\t\t\t\t\t\t\t\t\t(transceiver) => {\n\t\t\t\t\t\t\t\t\t\tif (update === `redo` && newValue) {\n\t\t\t\t\t\t\t\t\t\t\ttransceiver.do(newValue)\n\t\t\t\t\t\t\t\t\t\t} else if (update === `undo` && oldValue) {\n\t\t\t\t\t\t\t\t\t\t\ttransceiver.undo(oldValue)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn transceiver\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t`${mutableState.key}: tracker observing timeline`,\n\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\tlatestUpdateState.key,\n\t\t\t\t\t() => {\n\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\tconst mutable = getState(mutableState, store)\n\t\t\t\t\t\tconst updateNumber = mutable.getUpdateNumber(newValue)\n\t\t\t\t\t\tconst eventOffset = updateNumber - mutable.cacheUpdateNumber\n\t\t\t\t\t\tif (newValue && eventOffset === 1) {\n\t\t\t\t\t\t\t// â new:\"0=add:\\\"myHand\\\"\",old:\"0=add:\\\"deckId\\\"\"\n\t\t\t\t\t\t\tsetState(\n\t\t\t\t\t\t\t\tmutableState,\n\t\t\t\t\t\t\t\t(transceiver) => (transceiver.do(newValue), transceiver),\n\t\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t},\n\t\t\t`${store.config.name}: tracker observing latest update`,\n\t\t\tstore,\n\t\t)\n\t}\n\n\tpublic mutableState: MutableAtomToken<Mutable, Json.Serializable>\n\tpublic latestUpdateState: AtomToken<typeof this.Update | null>\n\n\tpublic constructor(\n\t\tmutableState: MutableAtomToken<Mutable, Json.Serializable>,\n\t\tstore: Store,\n\t) {\n\t\tthis.mutableState = mutableState\n\t\tconst target = newest(store)\n\t\tthis.latestUpdateState = this.initializeState(mutableState, target)\n\t\tthis.observeCore(mutableState, this.latestUpdateState, target)\n\t\tthis.updateCore(mutableState, this.latestUpdateState, target)\n\t\ttarget.trackers.set(mutableState.key, this)\n\t}\n}\n","import type { MutableAtomOptions, MutableAtomToken } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { selectJson } from \"atom.io/json\"\n\nimport { createAtom } from \"../atom\"\nimport { newest } from \"../lineage\"\nimport type { Store } from \"../store\"\nimport { subscribeToState } from \"../subscribe\"\nimport { Tracker } from \"./tracker\"\nimport type { Transceiver } from \"./transceiver\"\n\nexport function createMutableAtom<\n\tCore extends Transceiver<any>,\n\tSerializableCore extends Json.Serializable,\n>(\n\toptions: MutableAtomOptions<Core, SerializableCore>,\n\tstore: Store,\n): MutableAtomToken<Core, SerializableCore> {\n\tstore.logger.info(\n\t\t`ð§`,\n\t\t`atom`,\n\t\toptions.key,\n\t\t`creating in store \"${store.config.name}\"`,\n\t)\n\tconst coreState = createAtom<Core>(options, undefined, store)\n\tnew Tracker(coreState, store)\n\tconst jsonState = selectJson(coreState, options, store)\n\tconst target = newest(store)\n\tsubscribeToState(\n\t\tjsonState,\n\t\t() => {\n\t\t\tconst trackerHasBeenInitialized = newest(store).trackers.has(coreState.key)\n\t\t\tif (!trackerHasBeenInitialized) {\n\t\t\t\tnew Tracker(coreState, store)\n\t\t\t}\n\t\t},\n\t\t`tracker-initializer:${store?.config.name}:${\n\t\t\ttarget.transactionMeta === null\n\t\t\t\t? `main`\n\t\t\t\t: `${target.transactionMeta.update.key}`\n\t\t}`,\n\t\tstore,\n\t)\n\treturn coreState as MutableAtomToken<Core, SerializableCore>\n}\n","import type {\n\tAtomFamily,\n\tAtomFamilyOptions,\n\tAtomOptions,\n\tAtomToken,\n\tFamilyMetadata,\n} from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { createAtom } from \"../atom\"\nimport { newest } from \"../lineage\"\nimport { deposit, withdraw } from \"../store\"\nimport type { Store } from \"../store\"\nimport { Subject } from \"../subject\"\n\nexport function createAtomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n\tstore: Store,\n): AtomFamily<T, K> {\n\tconst subject = new Subject<AtomToken<T>>()\n\tconst atomFamily = Object.assign(\n\t\t(key: K): AtomToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = withdraw({ key: fullKey, type: `atom` }, store)\n\t\t\tlet token: AtomToken<any>\n\t\t\tif (existing) {\n\t\t\t\ttoken = deposit(existing)\n\t\t\t} else {\n\t\t\t\tconst individualOptions: AtomOptions<any> = {\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tdefault:\n\t\t\t\t\t\toptions.default instanceof Function\n\t\t\t\t\t\t\t? options.default(key)\n\t\t\t\t\t\t\t: options.default,\n\t\t\t\t}\n\t\t\t\tif (options.effects) {\n\t\t\t\t\tindividualOptions.effects = options.effects(key)\n\t\t\t\t}\n\t\t\t\t// if (`toJson` in options && `fromJson` in options) {\n\t\t\t\t// \tindividualOptions.toJson = options.toJson\n\t\t\t\t// \tindividualOptions.fromJson\n\t\t\t\t// }\n\t\t\t\ttoken = createAtom<T>(individualOptions, family, store)\n\t\t\t\tsubject.next(token)\n\t\t\t}\n\t\t\treturn token\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `atom_family`,\n\t\t\tsubject,\n\t\t} as const,\n\t)\n\tconst target = newest(store)\n\ttarget.families.set(options.key, atomFamily)\n\treturn atomFamily\n}\n","import type {\n\tFamilyMetadata,\n\tReadonlySelectorFamily,\n\tReadonlySelectorFamilyOptions,\n\tReadonlySelectorToken,\n} from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { newest } from \"../lineage\"\nimport { createSelector } from \"../selector\"\nimport { type Store, deposit } from \"../store\"\nimport { Subject } from \"../subject\"\n\nexport function createReadonlySelectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n\tstore: Store,\n): ReadonlySelectorFamily<T, K> {\n\tconst subject = new Subject<ReadonlySelectorToken<T>>()\n\treturn Object.assign(\n\t\t(key: K): ReadonlySelectorToken<T> => {\n\t\t\tconst target = newest(store)\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = target.readonlySelectors.get(fullKey)\n\t\t\tif (existing) {\n\t\t\t\treturn deposit(existing)\n\t\t\t}\n\t\t\treturn createSelector<T>(\n\t\t\t\t{\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tget: options.get(key),\n\t\t\t\t},\n\t\t\t\tfamily,\n\t\t\t\tstore,\n\t\t\t) as ReadonlySelectorToken<T>\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `readonly_selector_family`,\n\t\t\tsubject,\n\t\t} as const,\n\t) as ReadonlySelectorFamily<T, K>\n}\n","import type {\n\tFamilyMetadata,\n\tReadonlySelectorFamily,\n\tReadonlySelectorFamilyOptions,\n\tSelectorFamily,\n\tSelectorFamilyOptions,\n\tSelectorToken,\n} from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { newest } from \"../lineage\"\nimport { createSelector } from \"../selector\"\nimport type { Store } from \"../store\"\nimport { deposit } from \"../store\"\nimport { Subject } from \"../subject\"\nimport { createReadonlySelectorFamily } from \"./create-readonly-selector-family\"\n\nexport function createSelectorFamily<T, K extends Json.Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n\tstore: Store,\n): SelectorFamily<T, K>\nexport function createSelectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n\tstore: Store,\n): ReadonlySelectorFamily<T, K>\nexport function createSelectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n\tstore: Store,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\tconst isReadonly = !(`set` in options)\n\n\tif (isReadonly) {\n\t\treturn createReadonlySelectorFamily(options, store)\n\t}\n\tconst target = newest(store)\n\tconst subject = new Subject<SelectorToken<T>>()\n\n\tconst selectorFamily = Object.assign(\n\t\t(key: K): SelectorToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = target.selectors.get(fullKey)\n\t\t\tif (existing) {\n\t\t\t\treturn deposit(existing)\n\t\t\t}\n\t\t\tconst token = createSelector<T>(\n\t\t\t\t{\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tget: options.get(key),\n\t\t\t\t\tset: options.set(key),\n\t\t\t\t},\n\t\t\t\tfamily,\n\t\t\t\tstore,\n\t\t\t)\n\t\t\tsubject.next(token)\n\t\t\treturn token\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `selector_family`,\n\t\t} as const,\n\t) as SelectorFamily<T, K>\n\ttarget.families.set(options.key, selectorFamily)\n\treturn selectorFamily\n}\n","import type { AtomFamily } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { parseJson } from \"atom.io/json\"\n\nimport { createAtomFamily } from \"../families\"\nimport type { Store } from \"../store\"\nimport { Tracker } from \"./tracker\"\nimport type { Transceiver } from \"./transceiver\"\n\nexport class FamilyTracker<\n\tCore extends Transceiver<any>,\n\tFamilyMemberKey extends Json.Serializable,\n> {\n\tprivate readonly Update: Core extends Transceiver<infer Signal>\n\t\t? Signal\n\t\t: never\n\n\tpublic readonly findLatestUpdateState: AtomFamily<\n\t\ttypeof this.Update | null,\n\t\tFamilyMemberKey\n\t>\n\tpublic readonly findMutableState: AtomFamily<Core, FamilyMemberKey>\n\n\tpublic constructor(\n\t\tfindMutableState: AtomFamily<Core, FamilyMemberKey>,\n\t\tstore: Store,\n\t) {\n\t\tthis.findLatestUpdateState = createAtomFamily<\n\t\t\ttypeof this.Update | null,\n\t\t\tFamilyMemberKey\n\t\t>(\n\t\t\t{\n\t\t\t\tkey: `*${findMutableState.key}`,\n\t\t\t\tdefault: null,\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\t\tthis.findMutableState = findMutableState\n\t\tthis.findMutableState.subject.subscribe(\n\t\t\t`store=${store.config.name}::tracker-atom-family`,\n\t\t\t(atomToken) => {\n\t\t\t\tif (atomToken.family) {\n\t\t\t\t\tconst key = parseJson(atomToken.family.subKey) as FamilyMemberKey\n\t\t\t\t\tthis.findLatestUpdateState(key)\n\t\t\t\t\tnew Tracker<Core>(atomToken, store)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tthis.findLatestUpdateState.subject.subscribe(\n\t\t\t`store=${store.config.name}::tracker-atom-family`,\n\t\t\t(atomToken) => {\n\t\t\t\tif (atomToken.family) {\n\t\t\t\t\tconst key = parseJson(atomToken.family.subKey) as FamilyMemberKey\n\t\t\t\t\tconst mutableAtomToken = this.findMutableState(key)\n\t\t\t\t\tnew Tracker<Core>(mutableAtomToken, store)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t}\n}\n","import type { MutableAtomFamily, MutableAtomFamilyOptions } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { selectJsonFamily } from \"atom.io/json\"\n\nimport type { Store } from \"..\"\nimport { createAtomFamily } from \"..\"\nimport { FamilyTracker } from \"./tracker-family\"\nimport type { Transceiver } from \"./transceiver\"\n\nexport function createMutableAtomFamily<\n\tCore extends Transceiver<any>,\n\tSerializableCore extends Json.Serializable,\n\tKey extends string,\n>(\n\toptions: MutableAtomFamilyOptions<Core, SerializableCore, Key>,\n\tstore: Store,\n): MutableAtomFamily<Core, SerializableCore, Key> {\n\tconst coreFamily = Object.assign(\n\t\tcreateAtomFamily<Core, Key>(options, store),\n\t\toptions,\n\t) as MutableAtomFamily<Core, SerializableCore, Key>\n\tselectJsonFamily(coreFamily, options)\n\tnew FamilyTracker(coreFamily, store)\n\treturn coreFamily\n}\n","import type { Json } from \"atom.io/json\"\n\nexport interface Transceiver<Signal extends Json.Serializable> {\n\tdo: (update: Signal) => void\n\tundo: (update: Signal) => void\n\tsubscribe: (key: string, fn: (update: Signal) => void) => () => void\n\tcacheUpdateNumber: number\n\tgetUpdateNumber: (update: Signal) => number\n}\n\nexport function isTransceiver(\n\tvalue: unknown,\n): value is Transceiver<Json.Serializable> {\n\treturn (\n\t\ttypeof value === `object` &&\n\t\tvalue !== null &&\n\t\t`do` in value &&\n\t\t`undo` in value &&\n\t\t`subscribe` in value\n\t)\n}\n\nexport type TransceiverMode = `playback` | `record` | `transaction`\n\nexport type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<\n\tinfer Signal\n>\n\t? Signal\n\t: never\n\n/*\nA transceiver may also keep a list of updates that have been applied to it.\nThis is useful for undo/redo functionality, especially in the context of\nrevising history. It is a good idea to accept a cache limit in your \nconstructor, and overwrite old updates. Here's an example of how we \nmight set that up:\n\nmyTransceiver = Transceiver {\n\tcacheUpdateNumber: number = 27\n\tcacheIdx: number = 1\n\tcacheLimit: number = 3\n\tcache: Array<Update> = [\n\t\t26=add:\"x\"\n\t\t27=del:\"x\" (current)\n\t\t25=add:\"y\"\n\t]\n}\n\nCONFIRM/NO-OP\nUpdate `27=del:\"x\"` is passed to myTransceiver.do:\n- [updateNumber = 27, update = `del:\"x\"`]\t\n- updateOffset = updateNumber - cacheUpdateNumber // 0\n- eventOffset < 1 // true (we're validating the past)\n- |eventOffset| < cacheLimit // true (we remember this update)\n- eventIdx = cacheIdx + updateOffset // 1\n- update === cache.get(eventIdx) // true\n- return null // ð\n\nEXPECTED UPDATE\nUpdate `28=add:\"x\"` is passed to myTransceiver.do:\n- [updateNumber = 28, update = `add:\"x\"`]\n- updateOffset = updateNumber - cacheUpdateNumber // 1\n- eventOffset < 1 // false (we're in the future)\n- eventOffset === 1 // true (we're ready to apply this update)\n- cacheIdx += eventOffset // 2\n- cacheIdx %= cacheLimit // 2\n- cache[cacheIdx] = update // cache = <{ 0 => add:\"x\" }>\n- return null // ð\n\nUNEXPECTED UPDATE\nUpdate `29=del:\"x\"` is passed to myTransceiver.do:\n- [updateNumber = 29, update = `del:\"x\"`]\n- updateOffset = updateNumber - cacheUpdateNumber // 2\n- eventOffset < 1 // false (we're in the future)\n- eventOffset === 1 // false (we're NOT ready to apply this update)\n- updateIdx := cacheIdx + updateOffset // 3\n- updateIdx %= cacheLimit // 0\n- cache[updateIdx] = update // cache = <{ 0 => del:\"x\" }> \n- expectedUpdateNumber = cacheUpdateNumber + 1 // 28\n- return expectedUpdateNumber // ð€šð\n\nSUCCESSFUL ROLLBACK UPDATE\nUpdate `25=add:\"z\"` is passed to myTransceiver.do:\n- [updateNumber = 25, update = `add:\"z\"`]\n- updateOffset = updateNumber - cacheUpdateNumber // -2\n- eventOffset < 1 // true (we're validating the past)\n- |eventOffset| < cacheLimit // true (we remember this update)\n- eventIdx = cacheIdx + updateOffset // -1\n- eventIdx %= cacheLimit // 2\n- update === cache[eventIdx] // false (we're rolling back)\n- done := false\n- update := cache[cacheIdx] // update = `del:\"x\"`\n- undo(update) // myTransceiver.undo(`del:\"x\"`)\n- while (!done) {\n- \tcacheIdx -= 1 // 0, -1\n- \tcacheIdx %= cacheLimit // 0, 2\n- \tupdate = cache[cacheIdx] // update = `add:\"y\"`, `add:\"x\"`\n- \tundo(update) // myTransceiver.undo(`add:\"y\"`), myTransceiver.undo(`add:\"x\"`)\n- \tdone = cacheIdx === eventIdx // false, true\n- }\n- do(update) // myTransceiver.do(`add:\"z\"`)\n- return null // ð\n\nUNSUCCESSFUL ROLLBACK UPDATE\nUpdate `24=add:\"z\"` is passed to myTransceiver.do:\n- [updateNumber = 24, update = `add:\"z\"`]\n- updateOffset = updateNumber - cacheUpdateNumber // -3\n- eventOffset < 1 // true (we're validating the past)\n- |eventOffset| < cacheLimit // 3 < 3 // false (we don't remember this update)\n- return `OUT_OF_RANGE` // ðµâð«ð\n\n*/\n","import { newest } from \"../lineage\"\nimport { traceAllSelectorAtoms } from \"../selector\"\nimport type { Store } from \"../store\"\n\nexport const isAtomDefault = (key: string, store: Store): boolean => {\n\tconst core = newest(store)\n\treturn core.atomsThatAreDefault.has(key)\n}\n\nexport const markAtomAsDefault = (key: string, store: Store): void => {\n\tconst core = newest(store)\n\tcore.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key)\n}\n\nexport const markAtomAsNotDefault = (key: string, store: Store): void => {\n\tconst core = newest(store)\n\tcore.atomsThatAreDefault = new Set(newest(store).atomsThatAreDefault)\n\tcore.atomsThatAreDefault.delete(key)\n}\n\nexport const isSelectorDefault = (key: string, store: Store): boolean => {\n\tconst rootKeys = traceAllSelectorAtoms(key, store)\n\treturn rootKeys.every((rootKey) => isAtomDefault(rootKey, store))\n}\n","import type {\n\tAtomOptions,\n\tAtomToken,\n\tFamilyMetadata,\n\tMutableAtomOptions,\n\tUpdateHandler,\n} from \"atom.io\"\nimport { setState } from \"atom.io\"\n\nimport { cacheValue } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport { createMutableAtom } from \"../mutable\"\nimport type { Store } from \"../store\"\nimport { deposit } from \"../store\"\nimport { Subject } from \"../subject\"\nimport { subscribeToState } from \"../subscribe\"\nimport { markAtomAsDefault } from \"./is-default\"\n\nexport type Atom<T> = {\n\tkey: string\n\ttype: `atom`\n\tfamily?: FamilyMetadata\n\tinstall: (store: Store) => void\n\tsubject: Subject<{ newValue: T; oldValue: T }>\n\tdefault: T | (() => T)\n\tcleanup?: () => void\n}\n\nexport function createAtom<T>(\n\toptions: AtomOptions<T> | MutableAtomOptions<any, any>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n): AtomToken<T> {\n\tstore.logger.info(\n\t\t`ðš`,\n\t\t`atom`,\n\t\toptions.key,\n\t\t`creating in store \"${store.config.name}\"`,\n\t)\n\tconst target = newest(store)\n\tconst existing = target.atoms.get(options.key)\n\tif (existing) {\n\t\tstore.logger.error(\n\t\t\t`â`,\n\t\t\t`atom`,\n\t\t\toptions.key,\n\t\t\t`Tried to create atom, but it already exists in the store.`,\n\t\t\t`(Ignore if you are in development using hot module replacement.)`,\n\t\t)\n\t\treturn deposit(existing)\n\t}\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\tconst newAtom: Atom<T> = {\n\t\t...options,\n\t\ttype: `atom`,\n\t\tinstall: (store: Store) => {\n\t\t\tstore.logger.info(\n\t\t\t\t`ð ïž`,\n\t\t\t\t`atom`,\n\t\t\t\toptions.key,\n\t\t\t\t`installing in store \"${store.config.name}\"`,\n\t\t\t)\n\t\t\treturn `mutable` in options\n\t\t\t\t? createMutableAtom(options, store)\n\t\t\t\t: createAtom(options, undefined, store)\n\t\t},\n\t\tsubject,\n\t\t...(family && { family }),\n\t} as const\n\tlet initialValue = options.default\n\tif (options.default instanceof Function) {\n\t\tinitialValue = options.default()\n\t}\n\ttarget.atoms.set(newAtom.key, newAtom)\n\tmarkAtomAsDefault(options.key, store)\n\tcacheValue(options.key, initialValue, subject, store)\n\tconst token = deposit(newAtom)\n\tif (options.effects) {\n\t\tlet effectIndex = 0\n\t\tconst cleanupFunctions: (() => void)[] = []\n\t\tfor (const effect of options.effects) {\n\t\t\tconst cleanup = effect({\n\t\t\t\tsetSelf: (next) => setState(token, next, store),\n\t\t\t\tonSet: (handle: UpdateHandler<T>) =>\n\t\t\t\t\tsubscribeToState(token, handle, `effect[${effectIndex}]`, store),\n\t\t\t})\n\t\t\tif (cleanup) {\n\t\t\t\tcleanupFunctions.push(cleanup)\n\t\t\t}\n\t\t\t++effectIndex\n\t\t}\n\t\tnewAtom.cleanup = () => {\n\t\t\tfor (const cleanup of cleanupFunctions) {\n\t\t\t\tcleanup()\n\t\t\t}\n\t\t}\n\t}\n\tstore.subject.atomCreation.next(token)\n\treturn token as AtomToken<T>\n}\n","import type { AtomToken } from \"atom.io\"\n\nimport type { Store } from \"..\"\nimport { deleteSelector, newest } from \"..\"\n\nexport function deleteAtom(atomToken: AtomToken<unknown>, store: Store): void {\n\tconst target = newest(store)\n\tconst { key } = atomToken\n\tconst atom = target.atoms.get(key)\n\tif (!atom) {\n\t\tstore.logger.error(\n\t\t\t`â`,\n\t\t\t`atom`,\n\t\t\t`${key}`,\n\t\t\t`Tried to delete atom, but it does not exist in the store.`,\n\t\t)\n\t}\n\tatom?.cleanup?.()\n\ttarget.atoms.delete(key)\n\ttarget.valueMap.delete(key)\n\tconst selectorKeys = target.selectorAtoms.getRelatedKeys(key)\n\tif (selectorKeys) {\n\t\tfor (const selectorKey of selectorKeys) {\n\t\t\tconst token =\n\t\t\t\ttarget.selectors.get(selectorKey) ??\n\t\t\t\ttarget.readonlySelectors.get(selectorKey)\n\t\t\tif (token) {\n\t\t\t\tdeleteSelector(token, store)\n\t\t\t}\n\t\t}\n\t}\n\ttarget.selectorAtoms.delete(key)\n\ttarget.atomsThatAreDefault.delete(key)\n\ttarget.timelineAtoms.delete(key)\n\tstore.logger.info(`ð¥`, `atom`, `${key}`, `deleted`)\n}\n","import type { ReadonlySelectorToken, StateToken } from \"atom.io\"\n\nimport type { Store } from \"./store\"\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\n\nfunction prettyPrintTokenType(\n\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n) {\n\tif (token.type === `readonly_selector`) {\n\t\treturn `Readonly Selector`\n\t}\n\treturn capitalize(token.type)\n}\n\nexport class NotFoundError extends Error {\n\tpublic constructor(\n\t\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n\t\tstore: Store,\n\t) {\n\t\tsuper(\n\t\t\t`${prettyPrintTokenType(token)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\n}\n","import type { KeyedStateUpdate, TimelineToken, TransactionUpdate } from \"atom.io\"\nimport { setState } from \"atom.io\"\n\nimport type { Store } from \"../store\"\n\nexport const timeTravel = (\n\tdirection: `backward` | `forward`,\n\ttoken: TimelineToken,\n\tstore: Store,\n): void => {\n\tconst action = direction === `forward` ? `redo` : `undo`\n\tstore.logger.info(\n\t\tdirection === `forward` ? `â©` : `âª`,\n\t\t`timeline`,\n\t\ttoken.key,\n\t\taction,\n\t)\n\n\tconst timelineData = store.timelines.get(token.key)\n\tif (!timelineData) {\n\t\tstore.logger.error(\n\t\t\t`ð`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Failed to ${action}. This timeline has not been initialized.`,\n\t\t)\n\t\treturn\n\t}\n\n\tif (\n\t\t(direction === `forward` &&\n\t\t\ttimelineData.at === timelineData.history.length) ||\n\t\t(direction === `backward` && timelineData.at === 0)\n\t) {\n\t\tstore.logger.warn(\n\t\t\t`ð`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Failed to ${action} at the ${\n\t\t\t\tdirection === `forward` ? `end` : `beginning`\n\t\t\t} of timeline \"${token.key}\". There is nothing to ${action}.`,\n\t\t)\n\t\treturn\n\t}\n\n\ttimelineData.timeTraveling =\n\t\tdirection === `forward` ? `into_future` : `into_past`\n\tif (direction === `backward`) {\n\t\t--timelineData.at\n\t}\n\n\tconst update = timelineData.history[timelineData.at]\n\tconst updateValues = (atomUpdate: KeyedStateUpdate<any>) => {\n\t\tconst { key, newValue, oldValue } = atomUpdate\n\t\tconst value = direction === `forward` ? newValue : oldValue\n\t\tsetState({ key, type: `atom` }, value, store)\n\t}\n\tconst updateValuesFromTransactionUpdate = (\n\t\ttransactionUpdate: TransactionUpdate<any>,\n\t) => {\n\t\tconst updates =\n\t\t\tdirection === `forward`\n\t\t\t\t? transactionUpdate.updates\n\t\t\t\t: [...transactionUpdate.updates].reverse()\n\t\tfor (const updateFromTransaction of updates) {\n\t\t\tif (`newValue` in updateFromTransaction) {\n\t\t\t\tupdateValues(updateFromTransaction)\n\t\t\t} else {\n\t\t\t\tupdateValuesFromTransactionUpdate(updateFromTransaction)\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch (update.type) {\n\t\tcase `atom_update`: {\n\t\t\tupdateValues(update)\n\t\t\tbreak\n\t\t}\n\t\tcase `selector_update`: {\n\t\t\tconst updates =\n\t\t\t\tdirection === `forward`\n\t\t\t\t\t? update.atomUpdates\n\t\t\t\t\t: [...update.atomUpdates].reverse()\n\t\t\tfor (const atomUpdate of updates) {\n\t\t\t\tupdateValues(atomUpdate)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase `transaction_update`: {\n\t\t\tupdateValuesFromTransactionUpdate(update)\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (direction === `forward`) {\n\t\t++timelineData.at\n\t}\n\n\ttimelineData.subject.next(action)\n\ttimelineData.timeTraveling = null\n\tstore.logger.info(\n\t\t`â¹ïž`,\n\t\t`timeline`,\n\t\ttoken.key,\n\t\t`\"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`,\n\t)\n}\n","import type { Subject, Transceiver } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n} from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\n\nimport type { AtomToken, MutableAtomToken } from \".\"\n\nexport type Effectors<T> = {\n\tsetSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void\n\tonSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void\n}\n\nexport type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void\n\nexport type AtomOptions<T> = {\n\tkey: string\n\tdefault: T | (() => T)\n\teffects?: AtomEffect<T>[]\n}\n// biome-ignore format: complex intersection\nexport type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = \n\t& JsonInterface<T, J>\n\t& Omit<AtomOptions<T>, `default`> \n\t& { \n\t\t\tdefault: ()\t=> T\n\t\t\tmutable: true\n\t\t}\n\nexport function atom<T extends Transceiver<any>, J extends Json.Serializable>(\n\toptions: MutableAtomOptions<T, J>,\n): MutableAtomToken<T, J>\nexport function atom<T>(options: AtomOptions<T>): AtomToken<T>\nexport function atom<T>(\n\toptions: AtomOptions<any> | MutableAtomOptions<any, any>,\n): AtomToken<any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtom(options, IMPLICIT.STORE)\n\t}\n\treturn createAtom<T>(options, undefined, IMPLICIT.STORE)\n}\n\nexport type AtomFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tdefault: T | ((key: K) => T)\n\teffects?: (key: K) => AtomEffect<T>[]\n}\n\nexport type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((\n\tkey: K,\n) => AtomToken<T>) & {\n\tkey: string\n\ttype: `atom_family`\n\tsubject: Subject<AtomToken<T>>\n}\n// biome-ignore format: intersection\nexport type MutableAtomFamilyOptions<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n> = \n\t& AtomFamilyOptions<T, K>\n\t& JsonInterface<T, J>\n\t& { mutable: true }\n\n// biome-ignore format: intersection\nexport type MutableAtomFamily<\n\tCore extends Transceiver<any>,\n\tSerializableCore extends Json.Serializable,\n\tKey extends Json.Serializable,\n> = \n\t& JsonInterface<Core, SerializableCore>\n\t& ((key: Key) => MutableAtomToken<Core, SerializableCore>) \n\t& {\n\t\t\tkey: `${string}::mutable`\n\t\t\ttype: `atom_family`\n\t\t\tsubject: Subject<MutableAtomToken<Core, SerializableCore>>\n\t\t}\n\nexport function atomFamily<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n): AtomFamily<T, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K> | MutableAtomFamilyOptions<any, any, any>,\n): AtomFamily<T, K> | MutableAtomFamily<any, any, any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtomFamily(options, IMPLICIT.STORE)\n\t}\n\treturn createAtomFamily<T, K>(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport function getState<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): T {\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\treturn Internal.readOrComputeValue(state, store)\n}\n","const LoggerIconDictionary = {\n\t\"â\": `Timeline event fully captured`,\n\t\"â©\": `Timeline redo`,\n\t\"âª\": `Timeline undo`,\n\t\"âïž\": `Transaction redo`,\n\t\"â®ïž\": `Transaction undo`,\n\t\"â³\": `Timeline event partially captured`,\n\t\"â¹ïž\": `Time-travel complete`,\n\t\"ð\": `Notice`,\n\t\"ð\": `Realtime transaction synchronized`,\n\t\"â
\": `Realtime transaction success`,\n\t\"âš\": `Computation complete`,\n\t\"â\": `Conflict prevents attempted action`,\n\t\"â\": `Operation start`,\n\t\"ð\": `Possible bug in AtomIO`,\n\t\"ð\": `Subscription added`,\n\t\"ðª\": `Family member added`,\n\t\"ð\": `Stow update`,\n\t\"ð\": `Copy mutable`,\n\t\"ð\": `Read state`,\n\t\"ð\": `Write state`,\n\t\"ð¢\": `Notify subscribers`,\n\t\"ð\": `Register dependency`,\n\t\"ð\": `Discover root`,\n\t\"ð¥\": `Delete state`,\n\t\"ð§\": `Create mutable atom`,\n\t\"ðš\": `Create immutable atom`,\n\t\"ðŽ\": `Operation complete`,\n\t\"ð\": `Evict cached value`,\n\t\"ð¥\": `Caught`,\n\t\"ð\": `Subscription canceled`,\n\t\"ð\": `Apply transaction`,\n\t\"ð ïž\": `Install atom into store`,\n\t\"ð«\": `Begin transaction`,\n\t\"ð¬\": `Complete transaction`,\n\t\"ð§®\": `Computing selector`,\n\t\"ð§¹\": `Prepare to evict`,\n\t\"ðª\": `Abort transaction`,\n} as const\nexport type LoggerIcon = keyof typeof LoggerIconDictionary\n\nexport const LOG_LEVELS = [`info`, `warn`, `error`] as const\nexport type LogLevel = (typeof LOG_LEVELS)[number]\n\nexport type LogFn = (\n\ticon: LoggerIcon,\n\ttokenType:\n\t\t| `atom`\n\t\t| `readonly_selector`\n\t\t| `selector`\n\t\t| `state`\n\t\t| `timeline`\n\t\t| `transaction`\n\t\t| `unknown`,\n\ttokenKey: string,\n\tmessage: string,\n\t...rest: unknown[]\n) => void\nexport type LogFilter = (...params: Parameters<LogFn>) => boolean\n\nexport type Logger = Record<LogLevel, LogFn>\n\nexport const simpleLog =\n\t(logLevel: keyof Logger): LogFn =>\n\t(icon, tokenType, tokenKey, message, ...rest) => {\n\t\tconsole[logLevel](`${icon} ${tokenType} \"${tokenKey}\" ${message}`, ...rest)\n\t}\nexport const simpleLogger: Logger = {\n\terror: simpleLog(`error`),\n\tinfo: simpleLog(`info`),\n\twarn: simpleLog(`warn`),\n}\n\nexport class AtomIOLogger implements Logger {\n\tpublic constructor(\n\t\tpublic logLevel: `error` | `info` | `warn` | null,\n\t\tprivate readonly filter?: LogFilter,\n\t\tprivate readonly logger: Logger = simpleLogger,\n\t) {}\n\n\tpublic error: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel !== null) {\n\t\t\tthis.logger.error(...args)\n\t\t}\n\t}\n\tpublic info: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel === `info`) {\n\t\t\tthis.logger.info(...args)\n\t\t}\n\t}\n\tpublic warn: LogFn = (...args) => {\n\t\tif (\n\t\t\t(this.filter?.(...args) ?? true) &&\n\t\t\tthis.logLevel !== `error` &&\n\t\t\tthis.logLevel !== null\n\t\t) {\n\t\t\tthis.logger.warn(...args)\n\t\t}\n\t}\n}\n","import type { Subject } from \"atom.io/internal\"\nimport { IMPLICIT, createSelector, createSelectorFamily } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ReadonlySelectorToken, SelectorToken } from \".\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type SelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n\tset: Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n}\n\nexport function selector<T>(options: SelectorOptions<T>): SelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T>,\n): ReadonlySelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\treturn createSelector(options, undefined, IMPLICIT.STORE)\n}\n\nexport type SelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n\tset: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n}\n\nexport type SelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => SelectorToken<T>) & {\n\tkey: string\n\ttype: `selector_family`\n\tsubject: Subject<SelectorToken<T>>\n}\n\nexport type ReadonlySelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => ReadonlySelectorToken<T>) & {\n\tkey: string\n\ttype: `readonly_selector_family`\n\tsubject: Subject<ReadonlySelectorToken<T>>\n}\n\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n): SelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\treturn createSelectorFamily(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { StateToken } from \".\"\n\nexport function setState<T, New extends T>(\n\ttoken: StateToken<T>,\n\tvalue: New | ((oldValue: T) => New),\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): void {\n\tconst rejection = Internal.openOperation(token, store)\n\tif (rejection) {\n\t\treturn\n\t}\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\tInternal.setAtomOrSelector(state, value, store)\n\tInternal.closeOperation(store)\n}\n","import type {\n\tTimeline,\n\tTimelineAtomUpdate,\n\tTimelineSelectorUpdate,\n\tTimelineTransactionUpdate,\n} from \"atom.io/internal\"\nimport { IMPLICIT, createTimeline, timeTravel } from \"atom.io/internal\"\n\nimport type { AtomFamily, AtomToken } from \".\"\n\nexport type TimelineToken = {\n\tkey: string\n\ttype: `timeline`\n}\n\nexport type TimelineOptions = {\n\tkey: string\n\tatoms: (AtomFamily<any, any> | AtomToken<any>)[]\n\tshouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean\n}\n\nexport type TimelineUpdate =\n\t| TimelineAtomUpdate\n\t| TimelineSelectorUpdate\n\t| TimelineTransactionUpdate\n\nexport const timeline = (options: TimelineOptions): TimelineToken => {\n\treturn createTimeline(options, IMPLICIT.STORE)\n}\n\nexport const redo = (timeline: TimelineToken): void => {\n\ttimeTravel(`forward`, timeline, IMPLICIT.STORE)\n}\n\nexport const undo = (timeline: TimelineToken): void => {\n\ttimeTravel(`backward`, timeline, IMPLICIT.STORE)\n}\n","import type { AtomToken, ReadonlySelectorToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector, newest } from \"atom.io/internal\"\n\nimport type { StateTokenIndex } from \".\"\n\nexport type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>\n\nexport const attachAtomIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<AtomTokenIndex> => {\n\tconst atomTokenIndexState__INTERNAL = createAtom<AtomTokenIndex>(\n\t\t{\n\t\t\tkey: `ðâðš Atom Token Index (Internal)`,\n\t\t\tdefault: () => {\n\t\t\t\tconst defaultAtomIndex = [...store.atoms]\n\t\t\t\t\t.filter(([key]) => !key.includes(`ðâðš`))\n\t\t\t\t\t.reduce<AtomTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\tacc[key] = { key, type: `atom` }\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t}, {})\n\t\t\t\treturn defaultAtomIndex\n\t\t\t},\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.atomCreation.subscribe(`introspection`, (atomToken) => {\n\t\t\t\t\t\tif (atomToken.key.includes(`ðâðš`)) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst set = () =>\n\t\t\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\t\t\tconst { key, family } = atomToken\n\t\t\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[subKey]: atomToken,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t[key]: atomToken,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\tif (newest(store).operation.open) {\n\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t`introspection: waiting to update atom index`,\n\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn createSelector(\n\t\t{\n\t\t\tkey: `ðâðš Atom Token Index`,\n\t\t\tget: ({ get }) => get(atomTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n}\n","import type { ReadonlySelectorToken, SelectorToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector, newest } from \"atom.io/internal\"\n\nimport type { StateTokenIndex } from \".\"\n\nexport type SelectorTokenIndex = StateTokenIndex<\n\tReadonlySelectorToken<unknown> | SelectorToken<unknown>\n>\n\nexport const attachSelectorIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<SelectorTokenIndex> => {\n\tconst readonlySelectorTokenIndexState__INTERNAL =\n\t\tcreateAtom<SelectorTokenIndex>(\n\t\t\t{\n\t\t\t\tkey: `ðâðš Selector Token Index (Internal)`,\n\t\t\t\tdefault: () =>\n\t\t\t\t\tObject.assign(\n\t\t\t\t\t\t[...store.readonlySelectors]\n\t\t\t\t\t\t\t.filter(([key]) => !key.includes(`ðâðš`))\n\t\t\t\t\t\t\t.reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\t\t\tacc[key] = { key, type: `readonly_selector` }\n\t\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\t[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\t\tacc[key] = { key, type: `selector` }\n\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\t\t),\n\t\t\t\teffects: [\n\t\t\t\t\t({ setSelf }) => {\n\t\t\t\t\t\tstore.subject.selectorCreation.subscribe(\n\t\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t\t(selectorToken) => {\n\t\t\t\t\t\t\t\tif (selectorToken.key.includes(`ðâðš`)) {\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst set = () =>\n\t\t\t\t\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\t\t\t\t\tconst { key, family } = selectorToken\n\t\t\t\t\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[subKey]: selectorToken,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t[key]: selectorToken,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\tif (newest(store).operation.open) {\n\t\t\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t\t\t`introspection: waiting to update selector index`,\n\t\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tundefined,\n\t\t\tstore,\n\t\t)\n\treturn createSelector(\n\t\t{\n\t\t\tkey: `ðâðš Selector Token Index`,\n\t\t\tget: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tIMPLICIT.STORE,\n\t)\n}\n","import type { ReadonlySelectorFamily } from \"atom.io\"\nimport type { Store, Timeline } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tSubject,\n\tcreateAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nexport const attachTimelineFamily = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorFamily<Timeline> => {\n\tconst findTimelineLogState__INTERNAL = createAtomFamily<Timeline, string>(\n\t\t{\n\t\t\tkey: `ðâðš Timeline Update Log (Internal)`,\n\t\t\tdefault: (key) =>\n\t\t\t\tstore.timelines.get(key) ?? {\n\t\t\t\t\ttype: `timeline`,\n\t\t\t\t\tkey: ``,\n\t\t\t\t\tat: 0,\n\t\t\t\t\ttimeTraveling: null,\n\t\t\t\t\thistory: [],\n\t\t\t\t\tselectorTime: null,\n\t\t\t\t\ttransactionKey: null,\n\t\t\t\t\tinstall: () => {},\n\t\t\t\t\tsubject: new Subject(),\n\t\t\t\t},\n\t\t\teffects: (key) => [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tconst tl = store.timelines.get(key)\n\t\t\t\t\ttl?.subject.subscribe(`introspection`, (_) => {\n\t\t\t\t\t\tif (store.operation.open === true) {\n\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t\t\t(operationStatus) => {\n\t\t\t\t\t\t\t\t\tif (operationStatus.open === false) {\n\t\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\t\tsetSelf({ ...tl })\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsetSelf({ ...tl })\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tstore,\n\t)\n\tconst findTimelineLogState = createSelectorFamily<Timeline, string>(\n\t\t{\n\t\t\tkey: `ðâðš Timeline Update Log`,\n\t\t\tget:\n\t\t\t\t(key) =>\n\t\t\t\t({ get }) =>\n\t\t\t\t\tget(findTimelineLogState__INTERNAL(key)),\n\t\t},\n\t\tstore,\n\t)\n\treturn findTimelineLogState\n}\n","import type { ReadonlySelectorToken, TimelineToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector } from \"atom.io/internal\"\n\nexport const attachTimelineIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<TimelineToken[]> => {\n\tconst timelineTokenIndexState__INTERNAL = createAtom<TimelineToken[]>(\n\t\t{\n\t\t\tkey: `ðâðš Timeline Token Index (Internal)`,\n\t\t\tdefault: () =>\n\t\t\t\t[...store.timelines].map(([key]): TimelineToken => {\n\t\t\t\t\treturn { key, type: `timeline` }\n\t\t\t\t}),\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.timelineCreation.subscribe(\n\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t(timelineToken) => {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, timelineToken])\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\tconst timelineTokenIndex = createSelector(\n\t\t{\n\t\t\tkey: `ðâðš Timeline Token Index`,\n\t\t\tget: ({ get }) => get(timelineTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn timelineTokenIndex\n}\n","import type { ReadonlySelectorToken, TransactionToken, Æn } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector } from \"atom.io/internal\"\n\nexport const attachTransactionIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<TransactionToken<Æn>[]> => {\n\tconst transactionTokenIndexState__INTERNAL = createAtom<\n\t\tTransactionToken<Æn>[]\n\t>(\n\t\t{\n\t\t\tkey: `ðâðš Transaction Token Index (Internal)`,\n\t\t\tdefault: () =>\n\t\t\t\t[...store.transactions].map(([key]): TransactionToken<Æn> => {\n\t\t\t\t\treturn { key, type: `transaction` }\n\t\t\t\t}),\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.transactionCreation.subscribe(\n\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t(transactionToken) => {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, transactionToken])\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\tconst transactionTokenIndex = createSelector(\n\t\t{\n\t\t\tkey: `ðâðš Transaction Token Index`,\n\t\t\tget: ({ get }) => get(transactionTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn transactionTokenIndex\n}\n","import type { ReadonlySelectorFamily, TransactionUpdate, Æn } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nexport const attachTransactionLogs = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorFamily<TransactionUpdate<Æn>[]> => {\n\tconst findTransactionUpdateLog = createAtomFamily<\n\t\tTransactionUpdate<Æn>[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `ðâðš Transaction Update Log (Internal)`,\n\t\t\tdefault: () => [],\n\t\t\teffects: (key) => [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tconst tx = store.transactions.get(key)\n\t\t\t\t\ttx?.subject.subscribe(`introspection`, (transactionUpdate) => {\n\t\t\t\t\t\tif (transactionUpdate.key === key) {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, transactionUpdate])\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tstore,\n\t)\n\tconst findTransactionUpdateLogState = createSelectorFamily<\n\t\tTransactionUpdate<Æn>[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `ðâðš Transaction Update Log`,\n\t\t\tget:\n\t\t\t\t(key) =>\n\t\t\t\t({ get }) =>\n\t\t\t\t\tget(findTransactionUpdateLog(key)),\n\t\t},\n\t\tstore,\n\t)\n\treturn findTransactionUpdateLogState\n}\n","import type {\n\tReadonlySelectorFamily,\n\tReadonlySelectorToken,\n\tTimelineToken,\n\tTransactionToken,\n\tTransactionUpdate,\n\tÆn,\n} from \"atom.io\"\nimport * as Internal from \"atom.io/internal\"\nimport type { Timeline } from \"atom.io/internal\"\n\nimport { type AtomTokenIndex, attachAtomIndex } from \"./attach-atom-index\"\nimport type { SelectorTokenIndex } from \"./attach-selector-index\"\nimport { attachSelectorIndex } from \"./attach-selector-index\"\nimport { attachTimelineFamily } from \"./attach-timeline-family\"\nimport { attachTimelineIndex } from \"./attach-timeline-index\"\nimport { attachTransactionIndex } from \"./attach-transaction-index\"\nimport { attachTransactionLogs } from \"./attach-transaction-logs\"\n\nexport const attachIntrospectionStates = (\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): {\n\tatomIndex: ReadonlySelectorToken<AtomTokenIndex>\n\tselectorIndex: ReadonlySelectorToken<SelectorTokenIndex>\n\ttransactionIndex: ReadonlySelectorToken<TransactionToken<Æn>[]>\n\tfindTransactionLogState: ReadonlySelectorFamily<TransactionUpdate<Æn>[]>\n\ttimelineIndex: ReadonlySelectorToken<TimelineToken[]>\n\tfindTimelineState: ReadonlySelectorFamily<Timeline>\n} => {\n\treturn {\n\t\tatomIndex: attachAtomIndex(store),\n\t\tselectorIndex: attachSelectorIndex(store),\n\t\ttransactionIndex: attachTransactionIndex(store),\n\t\tfindTransactionLogState: attachTransactionLogs(store),\n\t\ttimelineIndex: attachTimelineIndex(store),\n\t\tfindTimelineState: attachTimelineFamily(store),\n\t}\n}\n","import type { AtomEffect } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\n\nexport type StringInterface<T> = {\n\tstringify: (t: T) => string\n\tparse: (s: string) => T\n}\n\nexport const persistAtom =\n\t<T>(storage: Storage) =>\n\t({ stringify, parse }: StringInterface<T>) =>\n\t(key: string): AtomEffect<T> =>\n\t({ setSelf, onSet }) => {\n\t\tconst savedValue = storage.getItem(key)\n\n\t\tif (savedValue != null) setSelf(parse(savedValue))\n\n\t\tonSet(({ newValue }) => {\n\t\t\tif (newValue == null) {\n\t\t\t\tstorage.removeItem(key)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tstorage.setItem(key, stringify(newValue))\n\t\t})\n\t}\n\nexport const lazyLocalStorageEffect: <J extends Json.Serializable>(\n\tkey: string,\n) => AtomEffect<J> = persistAtom(localStorage)(JSON)\n","/* â€ïž fp-ts */\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/* eslint-disable prefer-rest-params */\n/* eslint-disable @typescript-eslint/ban-types */\n\nexport function pipe<A>(a: A): A\nexport function pipe<A, B>(a: A, ab: (a: A) => B): B\nexport function pipe<A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C\nexport function pipe<A, B, C, D>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n): D\nexport function pipe<A, B, C, D, E>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n): E\nexport function pipe<A, B, C, D, E, F>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n): F\nexport function pipe<A, B, C, D, E, F, G>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n): G\nexport function pipe<A, B, C, D, E, F, G, H>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n): H\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n): I\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n): J\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n): K\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n): L\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n): M\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n): N\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n): O\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n): P\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n\tpq: (p: P) => Q,\n): Q\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n\tpq: (p: P) => Q,\n\tqr: (q: Q) => R,\n): R\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n\tpq: (p: P) => Q,\n\tqr: (q: Q) => R,\n\trs: (r: R) => S,\n): S\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(\n\ta: A,\n\tab: (a: A) => B,\n\tbc: (b: B) => C,\n\tcd: (c: C) => D,\n\tde: (d: D) => E,\n\tef: (e: E) => F,\n\tfg: (f: F) => G,\n\tgh: (g: G) => H,\n\thi: (h: H) => I,\n\tij: (i: I) => J,\n\tjk: (j: J) => K,\n\tkl: (k: K) => L,\n\tlm: (l: L) => M,\n\tmn: (m: M) => N,\n\tno: (n: N) => O,\n\top: (o: O) => P,\n\tpq: (p: P) => Q,\n\tqr: (q: Q) => R,\n\trs: (r: R) => S,\n\tst: (s: S) => T,\n): T\nexport function pipe(\n\ta: unknown,\n\tab?: Function,\n\tbc?: Function,\n\tcd?: Function,\n\tde?: Function,\n\tef?: Function,\n\tfg?: Function,\n\tgh?: Function,\n\thi?: Function,\n): unknown {\n\t// biome-ignore lint/style/noArguments: <explanation>\n\tswitch (arguments.length) {\n\t\tcase 1:\n\t\t\treturn a\n\t\tcase 2:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn ab!(a)\n\t\tcase 3:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn bc!(ab!(a))\n\t\tcase 4:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn cd!(bc!(ab!(a)))\n\t\tcase 5:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn de!(cd!(bc!(ab!(a))))\n\t\tcase 6:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn ef!(de!(cd!(bc!(ab!(a)))))\n\t\tcase 7:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn fg!(ef!(de!(cd!(bc!(ab!(a))))))\n\t\tcase 8:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn gh!(fg!(ef!(de!(cd!(bc!(ab!(a)))))))\n\t\tcase 9:\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\treturn hi!(gh!(fg!(ef!(de!(cd!(bc!(ab!(a))))))))\n\t\tdefault: {\n\t\t\t// biome-ignore lint/style/noArguments: <explanation>\n\t\t\tlet ret = arguments[0]\n\t\t\t// biome-ignore lint/style/noArguments: <explanation>\n\t\t\tfor (let i = 1; i < arguments.length; i++) {\n\t\t\t\t// biome-ignore lint/style/noArguments: <explanation>\n\t\t\t\tret = arguments[i](ret)\n\t\t\t}\n\t\t\treturn ret\n\t\t}\n\t}\n}\n","import type { Refinement } from \"../refinement\"\n\nexport * from \"./curry\"\nexport * from \"./pipe\"\n\nexport type Æn = (...parameters: any[]) => any\n\nexport const doNothing = (): void => undefined\n\nexport const become =\n\t<T>(nextVersionOfThing: Modifier<T> | T) =>\n\t(originalThing: T | (() => T)): T =>\n\t\tnextVersionOfThing instanceof Function\n\t\t\t? nextVersionOfThing(\n\t\t\t\t\toriginalThing instanceof Function ? originalThing() : originalThing,\n\t\t\t )\n\t\t\t: nextVersionOfThing\n\nexport type Applicator<X, Y> = (next: Modifier<X> | X) => Modifier<Y>\nexport type Modifier<T> = (thing: T) => T\n\nexport type OneOrMany<T> = T | T[]\n\nexport const isModifier =\n\t<T>(validate: Refinement<unknown, T>) =>\n\t(sample: T): Refinement<unknown, Modifier<T>> => {\n\t\tconst sampleIsValid = validate(sample)\n\t\tif (!sampleIsValid) {\n\t\t\tthrow new Error(`Invalid test case: JSON.stringify(${sample})`)\n\t\t}\n\t\treturn (input: unknown): input is Modifier<T> => {\n\t\t\tif (typeof input !== `function`) return false\n\t\t\tconst testResult = input(sample)\n\t\t\treturn validate(testResult)\n\t\t}\n\t}\n\nexport const pass =\n\t<Params extends ReadonlyArray<any>, Out>(...params: Params) =>\n\t(fn: (...params: Params) => Out): Out =>\n\t\tfn(...params)\n\nexport const typeOf =\n\t<T>(input: unknown) =>\n\t(isType: Refinement<unknown, T>): boolean =>\n\t\tisType(input)\n\nexport const raiseError = (message: string): never => {\n\tthrow new Error(message)\n}\n\nexport type Encapsulate<T extends (...args: any[]) => any> = (\n\t...args: Parameters<T>\n) => void\n\nexport const attempt = (fn: () => void): boolean => {\n\ttry {\n\t\tfn()\n\t\treturn true\n\t} catch (_) {\n\t\treturn false\n\t}\n}\n\nexport const fallback = <T>(fn: () => T, fallbackValue: T): T => {\n\ttry {\n\t\treturn fn()\n\t} catch (_) {\n\t\treturn fallbackValue\n\t}\n}\n","export type VennCheck = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => boolean\n\nexport type VennTally = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => number\n\nexport const includesAll: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (!array.includes(item)) return false\n\t}\n\treturn true\n}\n\nexport const includesAny: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (array.includes(item)) return true\n\t}\n\treturn false\n}\n\nexport const excludesAll: VennCheck = (items) => (array) =>\n\t!includesAny(items)(array)\n\nexport const excludesAny: VennCheck = (items) => (array) =>\n\t!includesAll(items)(array)\n\nexport const comprises: VennCheck = (items) => (array) =>\n\tincludesAll(items)(array) && includesAll(array)(items)\n\nexport const overlaps: VennTally = (items) => (array) => {\n\tlet incidences = 0\n\tfor (const item of items) {\n\t\tif (array.includes(item)) incidences += 1\n\t}\n\treturn incidences\n}\n","import type { Refinement } from \"../refinement\"\n\nexport * from \"./match\"\nexport * from \"./venn\"\n\nexport const each =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T[] =>\n\t\tisType(input) ? [input] : Array.isArray(input) ? input.filter(isType) : []\n\nexport const lastOf = <T>(input: ReadonlyArray<T>): T | undefined =>\n\tinput[input.length - 1]\n\nexport const isArray =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T[] =>\n\t\tArray.isArray(input) && input.every((item) => isType(item))\n\nexport const at =\n\t<T>(index: number) =>\n\t(input: T[]): T | undefined =>\n\t\tinput.at(index)\n\nexport const content =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T | T[] =>\n\t\tisType(input) || isArray(isType)(input)\n\nexport const join =\n\t(separator?: string) =>\n\t(a: string[]): string =>\n\t\ta.join(separator)\n\nexport const map =\n\t<I, O>(f: (value: I, index: number, array: I[]) => O) =>\n\t(a: I[]): O[] =>\n\t\ta.map(f)\n\nexport const reduce =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduce(f, initial)\n\nexport const slice =\n\t(start: number, end?: number) =>\n\t<I>(a: I[]): I[] =>\n\t\ta.slice(start, end)\n\nexport const using =\n\t<I, O>(a: I[]) =>\n\t(f: (acc: O, value: I, index: number, array: I[]) => O) =>\n\t(initial: O): O =>\n\t\ta.reduce(f, initial)\n\nexport const reduceRight =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduceRight(f, initial)\n\nexport const reverse = <I>(a: I[]): I[] => a.reverse()\n\nexport const sort =\n\t<I>(a: I[]) =>\n\t(f?: (x: I, y: I) => number): I[] =>\n\t\tf ? a.sort(f) : a.sort()\n\nexport const sortBy =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(x) - f(y))\n\nexport const sortByDesc =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(y) - f(x))\n\nexport const every =\n\t<I>(f: (value: I, index: number, array: I[]) => boolean = Boolean) =>\n\t(a: I[]): boolean =>\n\t\ta.every(f)\n\nexport const allTrue = every((x: boolean) => x === true)\n\nexport const addTo =\n\t<I>(a: I[]) =>\n\t(x: I): I[] =>\n\t\ta.includes(x) ? a : [...a, x]\n\nexport const isEmptyArray = (input: unknown): input is [] =>\n\tArray.isArray(input) && input.length === 0\n\nexport const isOneOf =\n\t<T>(...args: ReadonlyArray<T>) =>\n\t(input: unknown): input is T =>\n\t\targs.includes(input as T)\n\nexport const filter =\n\t<I, O extends I>(f: (value: I, index: number, array: I[]) => value is O) =>\n\t(a: I[]): O[] =>\n\t\ta.filter(f)\n","import type { Refinement } from \"../refinement\"\n\nexport const isUndefined = (input: unknown): input is undefined =>\n\tinput === undefined\n\nexport const ifDefined = <T>(\n\tvalidate: Refinement<unknown, T>,\n): Refinement<unknown, T | undefined> =>\n\t((input) => isUndefined(input) || validate(input)) as Refinement<\n\t\tunknown,\n\t\tT | undefined\n\t>\n\nexport const isNull = (input: unknown): input is null => input === null\n\nexport const isNullish = (input: unknown): input is null | undefined =>\n\tisUndefined(input) || isNull(input)\n\nexport type NullSafeUnion<Base, Extension> = Extension extends null\n\t? Base\n\t: Base & Extension\n\nexport type NullSafeRest<MaybeArg, IfArg = MaybeArg> = MaybeArg extends null\n\t? [] | [undefined]\n\t: [IfArg]\n\nexport interface Discard {\n\treadonly _discard: unique symbol\n}\n\nexport const ifNullish =\n\t<X, Y>(alt: Y) =>\n\t(input: X): Exclude<X, null | undefined> | Y =>\n\t\t(input ?? alt) as Exclude<X, null | undefined> | Y\n","export const key =\n\t<T extends object>(k: keyof T) =>\n\t(obj: Exclude<object, null>): unknown =>\n\t\t(obj as Record<keyof any, any>)[k]\n\nexport const access = <V, T extends Record<keyof any, V>>(\n\tk: keyof any,\n): {\n\t(obj: T): T[keyof T] | undefined\n\tin: (obj: T) => T[keyof T] | undefined\n} =>\n\tObject.assign((obj: T) => obj[k as keyof T], {\n\t\tin: (obj: T) => obj[k as keyof T],\n\t})\n","export type Entries<K extends keyof any, V> = [key: K, value: V][]\n\nexport const recordToEntries = <K extends keyof any, V>(\n\tobj: Record<K, V>,\n): Entries<K, V> => Object.entries(obj) as Entries<K, V>\n\nexport const entriesToRecord = <K extends keyof any, V>(\n\tentries: Entries<K, V>,\n): Record<K, V> => Object.fromEntries(entries) as Record<K, V>\n","import { pipe } from \"../function\"\n\nimport { map } from \"../array\"\nimport { entriesToRecord, recordToEntries } from \"./entries\"\n\nexport const mapObject = <K extends keyof any, I, O>(\n\tobj: Record<K, I>,\n\tfn: (val: I, key: K) => O,\n): Record<K, O> =>\n\tpipe(\n\t\tobj,\n\t\trecordToEntries,\n\t\tmap(([key, val]) => [key, fn(val, key)] as const),\n\t\tentriesToRecord,\n\t)\n\nexport const mob =\n\t<K extends keyof any, I, O>(fn: (val: I, key: K) => O) =>\n\t(obj: Record<K, I>): Record<K, O> =>\n\t\tmapObject(obj, fn)\n","import { pipe } from \"../function\"\nimport type { Refinement } from \"../refinement\"\n\nimport { allTrue, every } from \"../array\"\nimport { pass } from \"../function\"\nimport { ifNullish } from \"../nullish\"\nimport { access } from \"./access\"\nimport { recordToEntries } from \"./entries\"\nimport { mob } from \"./mapObject\"\n\nexport type PlainObject = Record<keyof any, unknown>\nexport type EmptyObject = Record<keyof any, never>\n\nexport const isNonNullObject = (input: unknown): input is object =>\n\ttypeof input === `object` && input !== null\n\nexport const isPlainObject = (input: unknown): input is PlainObject =>\n\tisNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype\n\nexport const isEmptyObject = (input: unknown): input is EmptyObject =>\n\tisPlainObject(input) && Object.keys(input).length === 0\n\nexport const isRecord =\n\t<KEY extends keyof any, VAL>(\n\t\tisKey: Refinement<keyof any, KEY>,\n\t\tisValue: Refinement<unknown, VAL>,\n\t) =>\n\t(input: unknown): input is Record<KEY, VAL> =>\n\t\tisPlainObject(input) &&\n\t\tObject.entries(input).every(([k, v]) => isKey(k) && isValue(v))\n\nexport type HasPropertiesOptions = {\n\treadonly allowExtraProperties?: boolean\n}\nexport const hasProperties = <OBJ extends object>(\n\tisValue: {\n\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t},\n\toptions: HasPropertiesOptions = { allowExtraProperties: false },\n): Refinement<unknown, OBJ> => {\n\tconst name = `{${recordToEntries(\n\t\tisValue as Record<keyof any, Refinement<any, any>>,\n\t)\n\t\t.map(([k, v]) => String(k) + `:` + v.name)\n\t\t.join(`,`)}}`\n\n\tconst _ = {\n\t\t[name]: (input: unknown): input is OBJ =>\n\t\t\tisPlainObject(input) &&\n\t\t\tpipe(\n\t\t\t\tisValue,\n\t\t\t\tObject.entries,\n\t\t\t\tevery(([key, val]) => key in input || val(undefined)),\n\t\t\t) &&\n\t\t\tpipe(\n\t\t\t\tinput,\n\t\t\t\tmob((val, key) =>\n\t\t\t\t\tpipe(\n\t\t\t\t\t\tisValue,\n\t\t\t\t\t\taccess(key),\n\t\t\t\t\t\tifNullish(() => options.allowExtraProperties),\n\t\t\t\t\t\tpass(val),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tObject.values,\n\t\t\t\tallTrue,\n\t\t\t),\n\t}\n\treturn _[name]\n}\n\nexport const ALLOW_EXTENSION = { allowExtraProperties: true }\nexport const doesExtend = <OBJ extends object>(\n\tisValue: {\n\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t},\n): Refinement<unknown, OBJ> => hasProperties(isValue, ALLOW_EXTENSION)\n\nexport const DO_NOT_ALLOW_EXTENSION = { allowExtraProperties: false }\nexport const hasExactProperties = <OBJ extends object>(\n\tisValue: {\n\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t},\n): Refinement<unknown, OBJ> => hasProperties(isValue, DO_NOT_ALLOW_EXTENSION)\n","import { isPlainObject } from \"./refinement\"\n\n// if you found what you were looking for, return true and break\nexport type InspectionResult = Partial<{\n\tpathComplete: true\n\tjobComplete: true\n}>\nexport type InspectNode = (\n\tpath: string[],\n\tnode: unknown,\n) => InspectionResult | void\n\nexport const sprawl = (\n\ttree: Array<unknown> | object,\n\tinspector: InspectNode,\n): void => {\n\tconst walk = (path: string[], node: unknown): InspectionResult => {\n\t\tconst inspect = (path: string[], node: unknown): InspectionResult | null => {\n\t\t\t// console.log(parent)\n\t\t\tconst result = inspector(path, node)\n\t\t\tif (result) return result\n\t\t\treturn null\n\t\t}\n\t\tconst result = inspect(path, node)\n\t\tif (result?.jobComplete || result?.pathComplete) {\n\t\t\treturn result\n\t\t}\n\t\tconst childEntries = Array.isArray(node)\n\t\t\t? node.map((v, i) => [i, v])\n\t\t\t: isPlainObject(node)\n\t\t\t ? Object.entries(node)\n\t\t\t : []\n\t\tfor (const [k, v] of childEntries) {\n\t\t\tconst subResult = walk([...path, k], v)\n\t\t\tif (subResult?.jobComplete) {\n\t\t\t\treturn subResult\n\t\t\t}\n\t\t}\n\t\treturn {}\n\t}\n\twalk([], tree)\n}\n","import { pipe } from \"../function\"\nimport type { Refinement } from \"../refinement\"\n\nimport { filter, includesAny, reduce } from \"../array\"\nimport { isUndefined } from \"../nullish\"\nimport { deepMob } from \"./deepMob\"\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { isPlainObject } from \"./refinement\"\n\nexport * from \"./access\"\nexport * from \"./deepMob\"\nexport * from \"./entries\"\nexport * from \"./mapObject\"\nexport * from \"./modify\"\nexport * from \"./patch\"\nexport * from \"./refinement\"\nexport * from \"./sprawl\"\n\nexport const redact =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(obj: O): Omit<O, K> =>\n\t\treduce<K, O>((acc, key) => (delete acc[key], acc), obj)(args)\n\nexport type Redacted<Holder, RedactProp extends keyof any> = Omit<\n\t{\n\t\t[K in keyof Holder]: Holder[K] extends (infer Item)[]\n\t\t\t? Redacted<Item, RedactProp>[]\n\t\t\t: Redacted<Omit<Holder[K], RedactProp>, RedactProp>\n\t},\n\tRedactProp\n>\nexport const redactDeep =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(base: O): Redacted<O, K> =>\n\t\tdeepMob(base, (node, path) =>\n\t\t\tincludesAny(args)(path)\n\t\t\t\t? {\n\t\t\t\t\t\tmeta: { pathComplete: true },\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tdata: isPlainObject(node)\n\t\t\t\t\t\t\t? redact(...args)(node as Record<keyof any, any>)\n\t\t\t\t\t\t\t: node,\n\t\t\t\t },\n\t\t)\n\nexport const select =\n\t<Key extends keyof any>(...args: Key[]) =>\n\t<Obj extends object>(\n\t\tobj: Obj,\n\t): {\n\t\t// @ts-expect-error fuk u\n\t\t[K in keyof Pick<Obj, Key>]: any extends Pick<Obj, Key>[K]\n\t\t\t? undefined\n\t\t\t: // @ts-expect-error fuk u\n\t\t\t Pick<Obj, Key>[K]\n\t} =>\n\t\t// @ts-expect-error fuk u ts\n\t\treduce<Key, Pick<Obj, Key>>(\n\t\t\t// @ts-expect-error i will fite u\n\t\t\t(acc, key) => (key in obj ? (acc[key] = obj[key as keyof Obj]) : acc, acc),\n\t\t\t// @ts-expect-error fuk u\n\t\t\t{} as Pick<Obj, Key>,\n\t\t)(args)\n\nexport const treeShake =\n\t(shouldDiscard: (val: unknown, key: keyof any) => boolean = isUndefined) =>\n\t<T extends object>(\n\t\tobj: T,\n\t): T extends Record<keyof any, unknown> ? T : Partial<T> => {\n\t\tconst newObj = {} as T\n\t\tconst entries = Object.entries(obj) as [keyof T, any][]\n\t\tfor (const [key, val] of entries) {\n\t\t\tif (!shouldDiscard(val, key)) {\n\t\t\t\tnewObj[key] = val\n\t\t\t}\n\t\t}\n\t\treturn newObj as T extends Record<keyof any, unknown> ? T : Partial<T>\n\t}\n\nexport type KeysExtending<T, V> = keyof {\n\t[K in keyof T]: T[K] extends V ? K : never\n}\n\nconst a: never | null = null\n\nexport const filterProperties =\n\t<DiscardVal, DiscardKey extends keyof any>(\n\t\tshouldDiscardVal: Refinement<unknown, DiscardVal>,\n\t\tshouldDiscardKey: Refinement<unknown, DiscardKey>,\n\t) =>\n\t<P extends Record<keyof any, any>>(\n\t\tprops: P,\n\t): DiscardVal extends never\n\t\t? DiscardKey extends never\n\t\t\t? P\n\t\t\t: Omit<P, DiscardKey>\n\t\t: Omit<P, DiscardKey | KeysExtending<P, DiscardVal>> =>\n\t\t// @ts-expect-error oh well\n\t\tpipe(\n\t\t\tprops,\n\t\t\trecordToEntries,\n\t\t\tfilter(\n\t\t\t\t(\n\t\t\t\t\tentry,\n\t\t\t\t): entry is [\n\t\t\t\t\tExclude<keyof P, DiscardKey>,\n\t\t\t\t\tExclude<P[keyof P], DiscardVal>,\n\t\t\t\t] => !shouldDiscardKey(entry[0]) || !shouldDiscardVal(entry[1]),\n\t\t\t),\n\t\t\tentriesToRecord,\n\t\t)\n\nexport const delve = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n): Error | { found: unknown } => {\n\tconst found = path.reduce((acc, key) => acc?.[key], obj)\n\treturn found === undefined ? new Error(`Not found`) : { found }\n}\n\nexport const tweak = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n\tvalue: unknown,\n): void =>\n\tpath.reduce((acc, key, i) => {\n\t\tif (i === path.length - 1) {\n\t\t\tacc[key] = value\n\t\t}\n\t\tif (acc[key] === undefined) {\n\t\t\tacc[key] = typeof key === `number` ? [] : {}\n\t\t}\n\t\treturn acc[key]\n\t}, obj)\n\nexport type RequireAtLeastOne<T> = {\n\t[K in keyof T]-?: Partial<Pick<T, Exclude<keyof T, K>>> & Required<Pick<T, K>>\n}[keyof T]\n\nexport type RequireExactlyOne<T> = {\n\t[K in keyof T]-?: Required<Pick<T, K>>\n}[keyof T]\n","import type { Refinement } from \"../refinement\"\n\nimport { isPlainObject } from \"../object\"\nimport type { ClassSignature } from \"./is-class\"\n\nexport type RefinementStrategy = ClassSignature | Refinement<unknown, any>\n\nexport type Supported<Refine extends RefinementStrategy> =\n\tRefine extends Refinement<unknown, infer T>\n\t\t? T\n\t\t: Refine extends ClassSignature\n\t\t ? InstanceType<Refine>\n\t\t : never\n\nexport type RefinementSupport = Record<string, RefinementStrategy>\n\nexport class Refinery<SupportedTypes extends RefinementSupport> {\n\tpublic supported: SupportedTypes\n\n\tpublic constructor(supported: SupportedTypes) {\n\t\tthis.supported = supported\n\t}\n\n\tpublic refine(input: unknown):\n\t\t| {\n\t\t\t\t[K in keyof SupportedTypes]: {\n\t\t\t\t\ttype: K\n\t\t\t\t\tdata: Supported<SupportedTypes[K]>\n\t\t\t\t}\n\t\t }[keyof SupportedTypes]\n\t\t| null {\n\t\tfor (const [key, refiner] of Object.entries(this.supported)) {\n\t\t\ttry {\n\t\t\t\tif (\n\t\t\t\t\t// @ts-expect-error that's the point\n\t\t\t\t\trefiner(input) === true &&\n\t\t\t\t\trefiner !== Boolean\n\t\t\t\t) {\n\t\t\t\t\treturn { type: key, data: input } as any\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\ttry {\n\t\t\t\t\tif (input instanceof refiner) {\n\t\t\t\t\t\treturn { type: key, data: input } as any\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {}\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n\nconst jsonRefinery = new Refinery({\n\tnumber: (input: unknown): input is number => typeof input === `number`,\n\tstring: (input: unknown): input is string => typeof input === `string`,\n\tboolean: (input: unknown): input is boolean => typeof input === `boolean`,\n\tobject: isPlainObject,\n\tarray: (input: unknown): input is unknown[] => Array.isArray(input),\n\tnull: (input: unknown): input is null => input === null,\n})\n\nexport const discoverType = (input: unknown): string => {\n\tif (input === undefined) {\n\t\treturn `undefined`\n\t}\n\tconst refined = jsonRefinery.refine(input)\n\tif (refined) {\n\t\treturn refined.type\n\t}\n\treturn Object.getPrototypeOf(input).constructor.name\n}\n","import { sprawl } from \"../object\"\nimport type { Refinery, Supported } from \"../refinement/refinery\"\nimport { discoverType } from \"../refinement/refinery\"\n\nexport function diffNumber(a: number, b: number): Delta {\n\tconst sign = a < b ? `+` : `-`\n\treturn {\n\t\tsummary: `${sign}${Math.abs(a - b)} (${a} â ${b})`,\n\t}\n}\n\nexport function diffString(a: string, b: string): Delta {\n\tconst sign = a.length < b.length ? `+` : `-`\n\treturn {\n\t\tsummary: `${sign}${Math.abs(a.length - b.length)} (\"${a}\" â \"${b}\")`,\n\t}\n}\n\nexport function diffBoolean(a: boolean, b: boolean): Delta {\n\treturn {\n\t\tsummary: `${a} â ${b}`,\n\t}\n}\n\nexport function diffObject(\n\ta: Record<string, unknown>,\n\tb: Record<string, unknown>,\n\trecurse: Differ<any, any>[`diff`],\n): Delta {\n\tlet summary = ``\n\tconst added: Delta[`added`] = []\n\tconst removed: Delta[`removed`] = []\n\tconst changed: Delta[`changed`] = []\n\n\tsprawl(a, (path, nodeA) => {\n\t\tlet key: string\n\t\tfor (key of path) {\n\t\t\tconst nodeB = b[key]\n\t\t\tif (nodeB === undefined) {\n\t\t\t\tremoved.push([key, JSON.stringify(nodeA)])\n\t\t\t} else {\n\t\t\t\tconst delta = recurse(nodeA, nodeB)\n\t\t\t\tif (delta.summary !== `No Change`) {\n\t\t\t\t\tchanged.push([key, delta])\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\tsprawl(b, (path, nodeB) => {\n\t\tlet key: string\n\t\tfor (key of path) {\n\t\t\tconst nodeA = a[key]\n\t\t\tif (nodeA === undefined) {\n\t\t\t\tadded.push([key, JSON.stringify(nodeB)])\n\t\t\t}\n\t\t}\n\t})\n\n\tsummary = `ïœ${changed.length} ïŒ${added.length} ïŒ${removed.length}`\n\n\treturn {\n\t\tsummary,\n\t\tadded,\n\t\tremoved,\n\t\tchanged,\n\t}\n}\n\nexport function diffArray(\n\ta: unknown[],\n\tb: unknown[],\n\trecurse: Differ<any, any>[`diff`],\n): Delta {\n\treturn diffObject(a as any, b as any, recurse)\n}\n\ntype Delta = {\n\tsummary: string\n\tadded?: [path: string, addedStringifiedValue: string][]\n\tremoved?: [path: string, removedStringifiedValue: string][]\n\tchanged?: [path: string, delta: Delta][]\n}\n\ntype Diff<T> = (a: T, b: T) => Delta\ntype DiffTree<T> = (a: T, b: T, recurse: Differ<any, any>[`diff`]) => Delta\n\nexport class Differ<\n\tLeaf extends Record<string, any>,\n\tTree extends Record<string, any>,\n> {\n\tpublic leafRefinery: Refinery<Leaf>\n\tpublic treeRefinery: Refinery<Tree>\n\tpublic leafDiffers: { [KL in keyof Leaf]: Diff<Supported<Leaf[KL]>> }\n\tpublic treeDiffers: { [KT in keyof Tree]: DiffTree<Supported<Tree[KT]>> }\n\n\tpublic constructor(\n\t\tleafRefinery: Refinery<Leaf>,\n\t\ttreeRefinery: Refinery<Tree>,\n\t\tdiffFunctions: {\n\t\t\t[KT in keyof Tree]: DiffTree<Supported<Tree[KT]>>\n\t\t} & { [KL in keyof Leaf]: Diff<Supported<Leaf[KL]>> },\n\t) {\n\t\tthis.leafRefinery = leafRefinery\n\t\tthis.treeRefinery = treeRefinery\n\t\tthis.leafDiffers = {} as any\n\t\tthis.treeDiffers = {} as any\n\t\tfor (const key of Object.keys(leafRefinery.supported)) {\n\t\t\tconst diffFunction = diffFunctions[key]\n\t\t\tthis.leafDiffers[key as keyof Leaf] = diffFunction\n\t\t}\n\t\tfor (const key of Object.keys(treeRefinery.supported)) {\n\t\t\tconst diffFunction = diffFunctions[key]\n\t\t\tthis.treeDiffers[key as keyof Tree] = diffFunction\n\t\t}\n\t}\n\n\tpublic diff(a: unknown, b: unknown): Delta {\n\t\tif (a === b) {\n\t\t\treturn { summary: `No Change` }\n\t\t}\n\t\ttry {\n\t\t\tif (JSON.stringify(a) === JSON.stringify(b)) {\n\t\t\t\treturn { summary: `No Change` }\n\t\t\t}\n\t\t} catch (thrown) {\n\t\t\tconsole.error(`Error stringifying`, a, b)\n\t\t}\n\n\t\tconst aRefined = this.leafRefinery.refine(a) ?? this.treeRefinery.refine(a)\n\t\tconst bRefined = this.leafRefinery.refine(b) ?? this.treeRefinery.refine(b)\n\n\t\t// console.log({ leaf: this.leafRefinery, tree: this.treeRefinery })\n\t\t// console.log({ a, b })\n\t\t// console.log({ aRefined, bRefined })\n\n\t\tif (aRefined !== null && bRefined !== null) {\n\t\t\tif (aRefined.type === bRefined.type) {\n\t\t\t\tif (aRefined.type in this.leafDiffers) {\n\t\t\t\t\tconst delta = this.leafDiffers[aRefined.type](\n\t\t\t\t\t\taRefined.data,\n\t\t\t\t\t\tbRefined.data,\n\t\t\t\t\t)\n\t\t\t\t\treturn delta\n\t\t\t\t}\n\t\t\t\tif (aRefined.type in this.treeDiffers) {\n\t\t\t\t\tconst delta = this.treeDiffers[aRefined.type](\n\t\t\t\t\t\taRefined.data,\n\t\t\t\t\t\tbRefined.data,\n\t\t\t\t\t\t(x, y) => this.diff(x, y),\n\t\t\t\t\t)\n\t\t\t\t\treturn delta\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst typeA = discoverType(a)\n\t\tconst typeB = discoverType(b)\n\t\tif (typeA === typeB) {\n\t\t\treturn {\n\t\t\t\tsummary: `${typeA} â ${typeB}`,\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tsummary: `Type change: ${typeA} â ${typeB}`,\n\t\t}\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT } from \"atom.io/internal\"\nimport * as React from \"react\"\n\nexport const StoreContext = React.createContext<Store>(IMPLICIT.STORE)\n\nexport const StoreProvider: React.FC<{\n\tchildren: React.ReactNode\n\tstore?: Store\n}> = ({ children, store = IMPLICIT.STORE }) => (\n\t<StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n)\n","import * as React from \"react\"\n\nimport { getState, redo, setState, undo } from \"atom.io\"\nimport type {\n\tMutableAtomToken,\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n} from \"atom.io\"\n\nimport {\n\tgetJsonToken,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\twithdraw,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"./store-context\"\n\nexport function useI<T>(\n\ttoken: StateToken<T>,\n): <New extends T>(next: New | ((old: T) => New)) => void {\n\tconst store = React.useContext(StoreContext)\n\tconst setter: React.MutableRefObject<\n\t\t(<New extends T>(next: New | ((old: T) => New)) => void) | null\n\t> = React.useRef(null)\n\tif (setter.current === null) {\n\t\tsetter.current = (next) => setState(token, next, store)\n\t}\n\treturn setter.current\n}\n\nexport function useO<T>(token: ReadonlySelectorToken<T> | StateToken<T>): T {\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\treturn React.useSyncExternalStore<T>(\n\t\t(dispatch) => subscribeToState(token, dispatch, `use-o:${id}`, store),\n\t\t() => getState(token, store),\n\t\t() => getState(token, store),\n\t)\n}\n\nexport function useJSON<Serializable extends Json.Serializable>(\n\ttoken: MutableAtomToken<any, Serializable>,\n): Serializable {\n\tconst jsonToken = getJsonToken(token)\n\treturn useO(jsonToken)\n}\n\nexport type TimelineMeta = {\n\tat: number\n\tlength: number\n\tundo: () => void\n\tredo: () => void\n}\n\nexport function useTL(token: TimelineToken): TimelineMeta {\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\tconst timeline = withdraw(token, store)\n\tif (timeline === undefined) {\n\t\tstore.logger.error(\n\t\t\t`â`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Failed to use timeline because it does not exist`,\n\t\t)\n\t\treturn {\n\t\t\tat: NaN,\n\t\t\tlength: NaN,\n\t\t\tundo: () => {},\n\t\t\tredo: () => {},\n\t\t}\n\t}\n\tconst meta = React.useRef<TimelineMeta>({\n\t\tat: timeline.at,\n\t\tlength: timeline.history.length,\n\t\tundo: () => undo(token),\n\t\tredo: () => redo(token),\n\t})\n\tconst retrieve = React.useCallback(() => {\n\t\tmeta.current.at = timeline.at\n\t\tmeta.current.length = timeline.history.length\n\t\treturn meta.current\n\t}, [meta])\n\treturn React.useSyncExternalStore<TimelineMeta>(\n\t\t(dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),\n\t\tretrieve,\n\t\tretrieve,\n\t)\n}\n","import { useI, useO } from \"atom.io/react\"\nimport { LayoutGroup, motion, spring } from \"framer-motion\"\nimport { useRef } from \"react\"\n\nimport {\n\tatomIndex,\n\tdevtoolsAreOpenState,\n\tdevtoolsViewOptionsState,\n\tdevtoolsViewSelectionState,\n\tselectorIndex,\n} from \".\"\nimport { StateIndex } from \"./StateIndex\"\nimport { TimelineIndex } from \"./TimelineIndex\"\nimport { TransactionIndex } from \"./TransactionIndex\"\n\nimport \"./devtools.scss\"\n\nexport const AtomIODevtools = (): JSX.Element => {\n\tconst constraintsRef = useRef(null)\n\n\tconst setDevtoolsAreOpen = useI(devtoolsAreOpenState)\n\tconst devtoolsAreOpen = useO(devtoolsAreOpenState)\n\tconst setDevtoolsView = useI(devtoolsViewSelectionState)\n\tconst devtoolsView = useO(devtoolsViewSelectionState)\n\tconst devtoolsViewOptions = useO(devtoolsViewOptionsState)\n\n\tconst mouseHasMoved = useRef(false)\n\n\treturn (\n\t\t<>\n\t\t\t<motion.span\n\t\t\t\tref={constraintsRef}\n\t\t\t\tclassName=\"atom_io_devtools_zone\"\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: `fixed`,\n\t\t\t\t\ttop: 0,\n\t\t\t\t\tleft: 0,\n\t\t\t\t\tright: 0,\n\t\t\t\t\tbottom: 0,\n\t\t\t\t\tpointerEvents: `none`,\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<motion.main\n\t\t\t\tdrag\n\t\t\t\tdragConstraints={constraintsRef}\n\t\t\t\tclassName=\"atom_io_devtools\"\n\t\t\t\ttransition={spring}\n\t\t\t\tstyle={\n\t\t\t\t\tdevtoolsAreOpen\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tbackgroundColor: `#0000`,\n\t\t\t\t\t\t\t\tborderColor: `#0000`,\n\t\t\t\t\t\t\t\tmaxHeight: 28,\n\t\t\t\t\t\t\t\tmaxWidth: 33,\n\t\t\t\t\t\t }\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{devtoolsAreOpen ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<motion.header>\n\t\t\t\t\t\t\t<h1>atom.io</h1>\n\t\t\t\t\t\t\t<nav>\n\t\t\t\t\t\t\t\t{devtoolsViewOptions.map((viewOption) => (\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\tkey={viewOption}\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\tclassName={viewOption === devtoolsView ? `active` : ``}\n\t\t\t\t\t\t\t\t\t\tonClick={() => setDevtoolsView(viewOption)}\n\t\t\t\t\t\t\t\t\t\tdisabled={viewOption === devtoolsView}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{viewOption}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</nav>\n\t\t\t\t\t\t</motion.header>\n\t\t\t\t\t\t<motion.main>\n\t\t\t\t\t\t\t<LayoutGroup>\n\t\t\t\t\t\t\t\t{devtoolsView === `atoms` ? (\n\t\t\t\t\t\t\t\t\t<StateIndex tokenIndex={atomIndex} />\n\t\t\t\t\t\t\t\t) : devtoolsView === `selectors` ? (\n\t\t\t\t\t\t\t\t\t<StateIndex tokenIndex={selectorIndex} />\n\t\t\t\t\t\t\t\t) : devtoolsView === `transactions` ? (\n\t\t\t\t\t\t\t\t\t<TransactionIndex />\n\t\t\t\t\t\t\t\t) : devtoolsView === `timelines` ? (\n\t\t\t\t\t\t\t\t\t<TimelineIndex />\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t</LayoutGroup>\n\t\t\t\t\t\t</motion.main>\n\t\t\t\t\t</>\n\t\t\t\t) : null}\n\t\t\t\t<footer>\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonMouseDown={() => (mouseHasMoved.current = false)}\n\t\t\t\t\t\tonMouseMove={() => (mouseHasMoved.current = true)}\n\t\t\t\t\t\tonMouseUp={() => {\n\t\t\t\t\t\t\tif (!mouseHasMoved.current) {\n\t\t\t\t\t\t\t\tsetDevtoolsAreOpen((open) => !open)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\tðâðš\n\t\t\t\t\t</button>\n\t\t\t\t</footer>\n\t\t\t</motion.main>\n\t\t</>\n\t)\n}\n","import { attempt, raiseError } from \"../function\"\nimport { stringifyJson } from \"../json\"\nimport type { Json } from \"../json\"\nimport { isPlainObject } from \"../object\"\nimport { isBoolean, isNumber, isString } from \"../primitive\"\n\nconst JSON_PROTOTYPES = [\n\t`Array`,\n\t`Boolean`,\n\t`Number`,\n\t`Object`,\n\t`String`,\n] as const\n\nexport type RefinedJson =\n\t| { type: `array`; data: Json.Array }\n\t| { type: `boolean`; data: boolean }\n\t| { type: `null`; data: null }\n\t| { type: `number`; data: number }\n\t| { type: `object`; data: Json.Object }\n\t| { type: `string`; data: string }\n\nexport const refineJsonType = (data: Json.Serializable): RefinedJson =>\n\tdata === null\n\t\t? { type: `null`, data: null }\n\t\t: isBoolean(data)\n\t\t ? { type: `boolean`, data }\n\t\t : isNumber(data)\n\t\t\t ? { type: `number`, data }\n\t\t\t : isString(data)\n\t\t\t\t ? { type: `string`, data }\n\t\t\t\t : Array.isArray(data)\n\t\t\t\t\t ? { type: `array`, data }\n\t\t\t\t\t : isPlainObject(data)\n\t\t\t\t\t\t ? { type: `object`, data }\n\t\t\t\t\t\t : raiseError(\n\t\t\t\t\t\t\t\t\tdata === undefined\n\t\t\t\t\t\t\t\t\t\t? `undefined passed to refineJsonType. This is not valid JSON.`\n\t\t\t\t\t\t\t\t\t\t: `${stringifyJson(data)} with prototype \"${\n\t\t\t\t\t\t\t\t\t\t\t\tObject.getPrototypeOf(data).constructor.name\n\t\t\t\t\t\t\t\t\t\t }\" passed to refineJsonType. This is not valid JSON.`,\n\t\t\t\t\t\t\t )\nexport const isJson = (input: unknown): input is Json.Serializable => {\n\tif (input === null) return true\n\tif (input === undefined) return false\n\tconst prototype = Object.getPrototypeOf(input)?.constructor.name\n\tconst isJson = JSON_PROTOTYPES.includes(prototype)\n\treturn isJson\n}\n\nexport const isPlainJson = (input: unknown): input is Json.Serializable =>\n\tattempt(() => isJson(input) && refineJsonType(input))\n","import type { Modify } from \"atom.io/internal\"\nimport type { FC } from \"react\"\n\nexport const OpenClose: FC<{\n\tisOpen: boolean\n\tsetIsOpen: (next: Modify<boolean> | boolean) => void\n\tdisabled?: boolean\n}> = ({ isOpen, setIsOpen, disabled }) => {\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclassName={`carat ${isOpen ? `open` : `closed`}`}\n\t\t\tonClick={() => setIsOpen((isOpen) => !isOpen)}\n\t\t\tdisabled={disabled}\n\t\t>\n\t\t\tâ¶\n\t\t</button>\n\t)\n}\n\nexport const button = {\n\tOpenClose,\n}\n","export const canExist = (_: unknown): _ is unknown => true\n","export const cannotExist = (_: unknown): _ is never => false\n","import { cannotExist } from \"./cannot-exist\"\nimport type { Refinement } from \"./refinement\"\n\nexport type ExtendsSome<A, B> = Refinement<unknown, A | B> & {\n\tor: <C>(isType: Refinement<unknown, C>) => ExtendsSome<unknown, A | B | C>\n}\nexport const mustSatisfyOneOfTheFollowing = <A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n} => {\n\tconst name = `(${refinements.map((r) => r?.name || `anon`).join(` | `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.some(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` | `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name ?? `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n\t} = Object.assign(_[name], {\n\t\tor: <B>(isTypeB: Refinement<unknown, B>): ExtendsSome<A, B> =>\n\t\t\tmustSatisfyOneOfTheFollowing(isTypeB, logging, [...refinements, isTypeB]),\n\t})\n\treturn checkTypes\n}\n\nexport const isUnion = mustSatisfyOneOfTheFollowing(cannotExist)\n","import { canExist } from \"./can-exist\"\nimport type { Refinement } from \"./refinement\"\n\nexport type ExtendsAll<A, B> = Refinement<unknown, A & B> & {\n\tand: <C>(isType: Refinement<unknown, C>) => ExtendsAll<A & B, C>\n}\nexport function mustSatisfyAllOfTheFollowing<A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n} {\n\tconst name = `(${refinements.map((r) => r?.name || `anon`).join(` & `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.every(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` & `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name || `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n\t} = Object.assign(_[name], {\n\t\tand: <B>(isTypeB: Refinement<unknown, B>): ExtendsAll<A, B> =>\n\t\t\tmustSatisfyAllOfTheFollowing(isTypeB, logging, [\n\t\t\t\t...refinements,\n\t\t\t\tisTypeB,\n\t\t\t]) as ExtendsAll<A, B>,\n\t})\n\treturn checkTypes\n}\n\nexport const isIntersection = mustSatisfyAllOfTheFollowing(canExist)\n","import type { Refinement } from \"../refinement\"\n\nexport * from \"./refined\"\nexport * from \"./refinery\"\nexport * from \"./refinement\"\n\nexport * from \"./can-exist\"\nexport * from \"./cannot-exist\"\n\nexport * from \"./is-class\"\nexport * from \"./is-union\"\nexport * from \"./is-intersection\"\n\nexport const isLiteral =\n\t<T extends boolean | number | string>(value: T): Refinement<unknown, T> =>\n\t(input: unknown): input is T =>\n\t\tinput === value\n\nexport const isWithin =\n\t<Options extends ReadonlyArray<any>>(args: Options) =>\n\t(input: unknown): input is Options[number] =>\n\t\targs.includes(input as Options[number])\n\nexport const ensure =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T => {\n\t\tif (!isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to be of type ${isType.name}`)\n\t\t}\n\t\treturn input as T\n\t}\n\nexport const ensureAgainst =\n\t<A, B>(isType: Refinement<unknown, A>) =>\n\t(input: A | B): Exclude<A | B, A> => {\n\t\tif (isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to not be of type ${isType.name}`)\n\t\t}\n\t\treturn input as Exclude<A | B, A>\n\t}\n","import { isArray } from \"../array\"\nimport type { Json } from \"../json\"\nimport { hasExactProperties, isRecord } from \"../object/refinement\"\nimport { isString } from \"../primitive\"\nimport { isLiteral } from \"../refinement\"\n\nexport const RELATION_TYPES = [`1:1`, `1:n`, `n:n`] as const\n\nexport type RelationType = (typeof RELATION_TYPES)[number]\n\nexport const isRelationType = (x: unknown): x is RelationType =>\n\tRELATION_TYPES.includes(x as RelationType)\n\nexport type RelationData<\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tcontents: Json.Object<string, CONTENT>\n\trelations: Json.Object<string, string[]>\n\trelationType: RelationType\n\ta: A\n\tb: B\n}\n\nexport const EMPTY_RELATION_DATA: RelationData = {\n\tcontents: {},\n\trelations: {},\n\trelationType: `n:n`,\n\ta: `from`,\n\tb: `to`,\n}\n\nexport type IsRelationDataOptions<\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tfrom?: A\n\tto?: B\n\tisContent?: (json: Json.Serializable) => json is CONTENT\n}\nexport const isRelationData =\n\t<\n\t\tCONTENT extends Json.Object | null = null,\n\t\tA extends string = `from`,\n\t\tB extends string = `to`,\n\t>({\n\t\tfrom: a = `from` as A,\n\t\tto: b = `to` as B,\n\t\tisContent,\n\t}: IsRelationDataOptions<CONTENT, A, B> = {}) =>\n\t(input: unknown): input is RelationData<CONTENT, A, B> => {\n\t\treturn hasExactProperties<RelationData<CONTENT, A, B>>({\n\t\t\tcontents: isContent\n\t\t\t\t? isRecord(isString, isContent)\n\t\t\t\t: hasExactProperties({}),\n\t\t\trelations: isRecord(isString, isArray(isString)),\n\t\t\trelationType: isRelationType,\n\t\t\ta: isLiteral(a),\n\t\t\tb: isLiteral(b),\n\t\t})(input)\n\t}\n","import type { Json } from \"../json\"\nimport type { RelationData } from \"./core-relation-data\"\n\nexport const getRelatedIds = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string[] => relationMap.relations[id] ?? []\n\nexport const getRelatedId = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string | undefined => {\n\tconst relations = getRelatedIds(relationMap, id)\n\tif (relations.length > 1) {\n\t\tconsole.warn(\n\t\t\t`entry with id ${id} was not expected to have multiple relations`,\n\t\t)\n\t}\n\treturn relations[0]\n}\n","import { Join } from \".\"\nimport type { Json, JsonInterface } from \"../json\"\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\n\nexport const makeJsonInterface = <\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n>(\n\tjoin: Join<CONTENT, A, B>,\n\t...params: CONTENT extends null ? [] : [(x: Json.Serializable) => x is CONTENT]\n): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\tconst isContent = params[0] as (x: Json.Serializable) => x is CONTENT\n\tconst { a, b } = join\n\tconst options: IsRelationDataOptions<CONTENT, A, B> = {\n\t\tfrom: a,\n\t\tto: b,\n\t\tisContent,\n\t}\n\treturn {\n\t\ttoJson: (join) => join.toJSON(),\n\t\tfromJson: (json) => Join.fromJSON(json, options),\n\t}\n}\n","import type { Json } from \"../json\"\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getContent } from \"./relation-contents\"\n\nexport const getRelationEntries = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n): [string, CONTENT][] =>\n\tgetRelatedIds(relationMap, idA).map((idB) => [\n\t\tidB,\n\t\tgetContent(relationMap, idA, idB) as CONTENT,\n\t])\n\nexport const getRelationRecord = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): Record<string, CONTENT> =>\n\tObject.fromEntries(getRelationEntries(relationMap, id))\n","export const split =\n\t(separator: string) =>\n\t(str: string): string[] =>\n\t\tstr.split(separator)\n","import { isString } from \"../primitive\"\n\nimport { isEmptyArray, isOneOf, map } from \"../array\"\nimport { comprises } from \"../array/venn\"\nimport { pipe } from \"../function\"\nimport type { Json } from \"../json\"\nimport { treeShake as removeProperties } from \"../object\"\nimport { entriesToRecord, recordToEntries } from \"../object/entries\"\nimport { split } from \"../string/split\"\nimport type { RelationData } from \"./core-relation-data\"\n\nexport const removeSpecific = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): RelationData<CONTENT, A, B> => {\n\tconst isIdForRemoval = isOneOf(idA, idB)\n\treturn {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\tisIdForRemoval(id)\n\t\t\t\t\t? relations.filter((relation) => !isIdForRemoval(relation))\n\t\t\t\t\t: relations,\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties(isEmptyArray),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) =>\n\t\t\t\t\tisString(key) && pipe(key, split(`/`), comprises([idA, idB])),\n\t\t\t),\n\t\t),\n\t}\n}\n\nexport const removeAll = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidToRemove: string,\n): RelationData<CONTENT, A, B> => {\n\tconst next: RelationData<CONTENT, A, B> = {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\trelations.filter((relation) => relation !== idToRemove),\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties((val, key) => key === idToRemove || isEmptyArray(val)),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) => isString(key) && key.split(`/`).includes(idToRemove),\n\t\t\t),\n\t\t),\n\t}\n\treturn next\n}\n\nexport const removeRelation = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Partial<Record<A | B, string>>,\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (relation as { [K in A | B]: string })[\n\t\tcurrent.a\n\t]\n\tconst idB: string | undefined = (relation as { [Key in A | B]: string })[\n\t\tcurrent.b\n\t]\n\treturn idB ? removeSpecific(current, idA, idB) : removeAll(current, idA)\n}\n","import { addTo, isEmptyArray } from \"../array\"\nimport type { Json } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\nimport { treeShake as removeProperties } from \"../object\"\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedId } from \"./get-related-ids\"\nimport { setContent } from \"./relation-contents\"\n\nexport const setManyToMany = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst next = {\n\t\t...map,\n\t\trelations: {\n\t\t\t...map.relations,\n\t\t\t[idA]: addTo(map.relations[idA] ?? [])(idB),\n\t\t\t[idB]: addTo(map.relations[idB] ?? [])(idA),\n\t\t},\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, idA, idB, content) : next\n}\n\nconst removeEmpties = removeProperties(isEmptyArray)\n\nexport const set1ToMany = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tleaderId: string,\n\tfollowerId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst relations = { ...current.relations }\n\tconst prevLeaderId = getRelatedId(current, followerId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...relations,\n\t\t\t...(prevLeaderId &&\n\t\t\t\tprevLeaderId !== leaderId && {\n\t\t\t\t\t[prevLeaderId]: relations[prevLeaderId].filter(\n\t\t\t\t\t\t(id) => id !== followerId,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t[followerId]: [leaderId],\n\t\t\t[leaderId]: addTo(relations[leaderId] ?? [])(followerId),\n\t\t}),\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, leaderId, followerId, content) : next\n}\n\nexport const set1To1 = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\twifeId: string,\n\thusbandId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst prevWifeId = getRelatedId(current, husbandId)\n\tconst prevHusbandId = getRelatedId(current, wifeId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...current.relations,\n\t\t\t...(prevWifeId && { [prevWifeId]: [] }),\n\t\t\t...(prevHusbandId && { [prevHusbandId]: [] }),\n\t\t\t[wifeId]: [husbandId],\n\t\t\t[husbandId]: [wifeId],\n\t\t}),\n\t}\n\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, wifeId, husbandId, content) : next\n}\n\nexport const setRelationWithContent = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Record<A | B, string>,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst { [current.a]: idA, [current.b]: idB } = relation\n\tswitch (current.relationType) {\n\t\tcase `1:1`:\n\t\t\treturn set1To1(current, idA, idB, ...rest)\n\t\tcase `1:n`:\n\t\t\treturn set1ToMany(current, idA, idB, ...rest)\n\t\tcase `n:n`:\n\t\t\treturn setManyToMany(current, idA, idB, ...rest)\n\t}\n}\n","import { pipe } from \"../function\"\nimport type { Identified } from \"../id/identified\"\nimport type { Json } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\nimport { isEmptyObject } from \"../object/refinement\"\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getRelationEntries } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\n\nexport const makeContentId = (idA: string, idB: string): string =>\n\t[idA, idB].sort().join(`/`)\n\nexport const getContent = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): CONTENT | undefined => relationMap.contents[makeContentId(idA, idB)]\n\nexport const setContent = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\tcontent: CONTENT,\n): RelationData<CONTENT, A, B> => ({\n\t...map,\n\tcontents: {\n\t\t...map.contents,\n\t\t[makeContentId(idA, idB)]: content,\n\t},\n})\n\nexport const getRelations = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): (CONTENT extends null ? Identified : CONTENT & Identified)[] =>\n\tgetRelationEntries(relationMap, id).map(\n\t\t([id, content]) =>\n\t\t\t({\n\t\t\t\tid,\n\t\t\t\t...content,\n\t\t\t}) as CONTENT extends null ? Identified : CONTENT & Identified,\n\t)\n\nexport const setRelations = <\n\tCONTENT extends Json.Object | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tsubject: { [from in A]: string } | { [to in B]: string },\n\trelations: (CONTENT extends null ? Identified : CONTENT & Identified)[],\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (subject as { [from in A]: string })[current.a]\n\tconst idB: string | undefined = (subject as { [to in B]: string })[current.b]\n\treturn pipe(\n\t\tcurrent,\n\t\t(relationData) => {\n\t\t\tconst relatedIds = getRelatedIds(current, idA)\n\t\t\tconst removedIds = relatedIds.filter(\n\t\t\t\t(id) => !relations.some((r) => r.id === id),\n\t\t\t)\n\t\t\tlet step = relationData\n\t\t\tfor (const id of removedIds) {\n\t\t\t\tconst remove = {\n\t\t\t\t\t[current.a]: idA ?? id,\n\t\t\t\t\t[current.b]: idB ?? id,\n\t\t\t\t} as Record<A | B, string>\n\t\t\t\tstep = removeRelation(step, remove)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tlet step = relationData\n\t\t\tfor (const { id, ...rest } of relations) {\n\t\t\t\tconst content = isEmptyObject(rest) ? undefined : rest\n\t\t\t\tstep = setRelationWithContent(\n\t\t\t\t\tstep,\n\t\t\t\t\t{ [current.a]: idA ?? id, [current.b]: idB ?? id } as Record<\n\t\t\t\t\t\tA | B,\n\t\t\t\t\t\tstring\n\t\t\t\t\t>,\n\t\t\t\t\t// @ts-expect-error hacky\n\t\t\t\t\tcontent as NullSafeRest<CONTENT>,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tconst newlyOrderedIds = relations.map((r) => r.id)\n\t\t\treturn {\n\t\t\t\t...relationData,\n\t\t\t\trelations: {\n\t\t\t\t\t...relationData.relations,\n\t\t\t\t\t[idA ?? idB]: newlyOrderedIds,\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t)\n}\n","import type { Identified } from \"../id\"\n\nimport type { Json, JsonInterface } from \"../json\"\nimport type { NullSafeRest, NullSafeUnion } from \"../nullish\"\nimport type { Refinement } from \"../refinement\"\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\nimport { EMPTY_RELATION_DATA, isRelationData } from \"./core-relation-data\"\nimport { getRelatedId, getRelatedIds } from \"./get-related-ids\"\nimport { makeJsonInterface } from \"./make-json-interface\"\nimport { getContent, getRelations, setRelations } from \"./relation-contents\"\nimport { getRelationEntries, getRelationRecord } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\n\nexport class Join<\n\tCONTENT extends Json.Object | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> implements RelationData<CONTENT, A, B>\n{\n\tpublic readonly relationType: `1:1` | `1:n` | `n:n`\n\tpublic readonly a: A = `from` as A\n\tpublic readonly b: B = `to` as B\n\tpublic readonly relations: Record<string, string[]>\n\tpublic readonly contents: Record<string, CONTENT>\n\tpublic constructor(json?: Partial<RelationData<CONTENT, A, B>>) {\n\t\tObject.assign(this, {\n\t\t\t...EMPTY_RELATION_DATA,\n\t\t\t...json,\n\t\t\tmakeJsonInterface: this.makeJsonInterface,\n\t\t})\n\t}\n\tpublic toJSON(): RelationData<CONTENT, A, B> {\n\t\treturn {\n\t\t\trelationType: this.relationType,\n\t\t\trelations: this.relations,\n\t\t\tcontents: this.contents,\n\t\t\ta: this.a,\n\t\t\tb: this.b,\n\t\t}\n\t}\n\tpublic static fromJSON<\n\t\tCONTENT extends Json.Object | null,\n\t\tA extends string,\n\t\tB extends string,\n\t>(\n\t\tjson: Json.Serializable,\n\t\toptions?: IsRelationDataOptions<CONTENT, A, B>,\n\t): Join<CONTENT, A, B> {\n\t\tconst isValid = isRelationData<CONTENT, A, B>(options)(json)\n\t\tif (isValid) {\n\t\t\treturn new Join<CONTENT, A, B>(json)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Saved JSON for this Join is invalid: ${JSON.stringify(json)}`,\n\t\t)\n\t}\n\n\tpublic from<AA extends string>(newA: AA): Join<CONTENT, AA, B> {\n\t\treturn new Join({ ...this, a: newA })\n\t}\n\n\tpublic to<BB extends string>(newB: BB): Join<CONTENT, A, BB> {\n\t\treturn new Join({ ...this, b: newB })\n\t}\n\n\tpublic makeJsonInterface = (\n\t\t...params: CONTENT extends null ? [] : [Refinement<unknown, CONTENT>]\n\t): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\t\treturn makeJsonInterface<CONTENT, A, B>(this, ...params)\n\t}\n\n\tpublic getRelatedId(id: string): string | undefined {\n\t\treturn getRelatedId(this, id)\n\t}\n\tpublic getRelatedIds(id: string): string[] {\n\t\treturn getRelatedIds(this, id)\n\t}\n\tpublic getContent(idA: string, idB: string): CONTENT | undefined {\n\t\treturn getContent(this, idA, idB)\n\t}\n\tpublic getRelationEntries(id: string): [string, CONTENT][] {\n\t\treturn getRelationEntries(this, id)\n\t}\n\tpublic getRelationRecord(id: string): Record<string, CONTENT> {\n\t\treturn getRelationRecord(this, id)\n\t}\n\tpublic getRelation(\n\t\tid: string,\n\t): NullSafeUnion<Identified, CONTENT> | undefined {\n\t\treturn getRelations(this, id)[0]\n\t}\n\tpublic getRelations(id: string): NullSafeUnion<Identified, CONTENT>[] {\n\t\treturn getRelations(this, id)\n\t}\n\tpublic setRelations(\n\t\tsubject: { [from in A]: string } | { [to in B]: string },\n\t\trelations: NullSafeUnion<Identified, CONTENT>[],\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelations(this, subject, relations))\n\t}\n\tpublic set(\n\t\trelation: { [key in A | B]: string },\n\t\t...rest: NullSafeRest<CONTENT>\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelationWithContent(this, relation, ...rest))\n\t}\n\tpublic remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B> {\n\t\treturn new Join(\n\t\t\tremoveRelation(this, relation as Partial<Record<A | B, string>>),\n\t\t)\n\t}\n}\n","import type {\n\tDetailedHTMLProps,\n\tForwardRefExoticComponent,\n\tInputHTMLAttributes,\n} from \"react\"\nimport {\n\tforwardRef,\n\tuseImperativeHandle,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from \"react\"\n\nexport type ElasticInputProps = DetailedHTMLProps<\n\tInputHTMLAttributes<HTMLInputElement>,\n\tHTMLInputElement\n> & {\n\twidthPadding?: number\n}\n\nexport const ElasticInput: ForwardRefExoticComponent<\n\tDetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> & {\n\t\twidthPadding?: number\n\t}\n> = forwardRef(function ElasticInputFC(props, ref) {\n\tconst inputRef = useRef<HTMLInputElement>(null)\n\tconst spanRef = useRef<HTMLSpanElement>(null)\n\tconst [inputWidth, setInputWidth] = useState(`auto`)\n\n\tuseImperativeHandle<Partial<HTMLInputElement>, Partial<HTMLInputElement>>(\n\t\tref,\n\t\t() => ({\n\t\t\tfocus: () => {\n\t\t\t\tinputRef.current?.focus()\n\t\t\t},\n\t\t}),\n\t)\n\n\tconst extraWidth = props.type === `number` ? 15 : 0\n\n\tuseLayoutEffect(() => {\n\t\tif (spanRef.current) {\n\t\t\tsetInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`)\n\t\t\tconst interval = setInterval(() => {\n\t\t\t\tif (spanRef.current) {\n\t\t\t\t\tsetInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`)\n\t\t\t\t}\n\t\t\t}, 1000)\n\t\t\treturn () => clearInterval(interval)\n\t\t}\n\t}, [inputRef.current?.value, props.value])\n\n\treturn (\n\t\t<div style={{ display: `inline-block`, position: `relative` }}>\n\t\t\t<input\n\t\t\t\t{...props}\n\t\t\t\tref={inputRef}\n\t\t\t\tstyle={{\n\t\t\t\t\tpadding: 0,\n\t\t\t\t\tborderRadius: 0,\n\t\t\t\t\tborder: `none`,\n\t\t\t\t\tfontFamily: `inherit`,\n\t\t\t\t\tfontSize: `inherit`,\n\t\t\t\t\twidth: inputWidth,\n\t\t\t\t\t...props.style,\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<span\n\t\t\t\tref={spanRef}\n\t\t\t\tstyle={{\n\t\t\t\t\tpadding: props.style?.padding,\n\t\t\t\t\tposition: `absolute`,\n\t\t\t\t\tvisibility: `hidden`,\n\t\t\t\t\t// color: `red`,\n\t\t\t\t\twhiteSpace: `pre`,\n\t\t\t\t\tfontFamily: props.style?.fontFamily || `inherit`,\n\t\t\t\t\tfontSize: props.style?.fontSize || `inherit`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{props.value}\n\t\t\t</span>\n\t\t</div>\n\t)\n})\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC } from \"react\"\nimport { useId, useRef, useState } from \"react\"\n\nimport { clampInto } from \"~/packages/anvl/src/number\"\n\nimport { pipe } from \"~/packages/anvl/src/function\"\nimport { ElasticInput } from \".\"\n\nfunction round(value: number, decimalPlaces?: number): number {\n\tif (decimalPlaces === undefined) return value\n\tconst factor = 10 ** decimalPlaces\n\treturn Math.round(value * factor) / factor\n}\nfunction roundAndPad(value: number, decimalPlaces?: number): string {\n\tconst roundedValue = round(value, decimalPlaces)\n\tconst paddedString = roundedValue.toFixed(decimalPlaces)\n\treturn paddedString\n}\n\nexport const VALID_NON_NUMBERS = [``, `-`, `.`, `-.`] as const\nexport type ValidNonNumber = (typeof VALID_NON_NUMBERS)[number]\nexport const isValidNonNumber = (input: string): input is ValidNonNumber =>\n\tVALID_NON_NUMBERS.includes(input as ValidNonNumber)\nexport const VALID_NON_NUMBER_INTERPRETATIONS: Readonly<\n\tRecord<ValidNonNumber, number | null>\n> = {\n\t\"\": null,\n\t\"-\": 0,\n\t\".\": 0,\n\t\"-.\": 0,\n} as const\nexport type DecimalInProgress = `${number | ``}.${number}`\nexport const isDecimalInProgress = (input: string): input is DecimalInProgress =>\n\tinput === `0` || (!Number.isNaN(Number(input)) && input.includes(`.`))\n\nconst textToValue = (input: string, allowDecimal: boolean): number | null => {\n\tif (isValidNonNumber(input)) return VALID_NON_NUMBER_INTERPRETATIONS[input]\n\treturn allowDecimal ? parseFloat(input) : Math.round(parseFloat(input))\n}\n\nexport type NumberConstraints = {\n\tmax: number\n\tmin: number\n\tdecimalPlaces: number\n\tnullable: boolean\n}\nexport const DEFAULT_NUMBER_CONSTRAINTS: NumberConstraints = {\n\tmax: Infinity,\n\tmin: -Infinity,\n\tdecimalPlaces: 100,\n\tnullable: true,\n}\n\nconst initRefinery =\n\t<Constraints extends NumberConstraints>(\n\t\tconstraints: { [K in keyof Constraints]?: Constraints[K] | undefined },\n\t) =>\n\t(\n\t\tinput: number | null,\n\t): Constraints extends { nullable: true | undefined }\n\t\t? number | null\n\t\t: number => {\n\t\tif (input === null && constraints.nullable === true) {\n\t\t\treturn null as Constraints extends { nullable: true }\n\t\t\t\t? number | null\n\t\t\t\t: number\n\t\t}\n\t\tconst { max, min, decimalPlaces } = {\n\t\t\t...DEFAULT_NUMBER_CONSTRAINTS,\n\t\t\t...constraints,\n\t\t}\n\t\tconst constrained = pipe(input ?? 0, clampInto(min, max), (n) =>\n\t\t\tdecimalPlaces ? round(n, decimalPlaces) : n,\n\t\t)\n\t\treturn constrained\n\t}\n\nconst valueToText = (numericValue: number | null): string => {\n\tif (numericValue === null || numericValue === undefined) {\n\t\treturn ``\n\t}\n\treturn numericValue.toString()\n}\n\ntype NumberInputProps = Partial<NumberConstraints> & {\n\tautoSize?: boolean\n\tcustomCss?: SerializedStyles\n\tdisabled?: boolean\n\tid?: string\n\tlabel?: string\n\tname?: string\n\tonChange?: (e: React.ChangeEvent<HTMLInputElement>) => void\n\tonClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void\n\tplaceholder?: string\n\tset?: ((newValue: number | null) => void) | undefined\n\ttestId?: string\n\tvalue?: number | null\n}\n\nexport const NumberInput: FC<NumberInputProps> = ({\n\tautoSize = false,\n\tcustomCss,\n\tdecimalPlaces,\n\tdisabled = false,\n\tlabel,\n\tmax,\n\tmin,\n\tname,\n\tonChange,\n\tonClick,\n\tplaceholder = ``,\n\tset = () => null,\n\ttestId,\n\tvalue = null,\n}) => {\n\tconst id = useId()\n\tconst [temporaryEntry, setTemporaryEntry] = useState<\n\t\tDecimalInProgress | ValidNonNumber | null\n\t>(null)\n\tconst userHasMadeDeliberateChange = useRef<boolean>(false)\n\n\tconst refine = initRefinery({ max, min, decimalPlaces, nullable: true })\n\n\tconst allowDecimal = decimalPlaces === undefined || decimalPlaces > 0\n\n\tconst handleBlur = () => {\n\t\tif (userHasMadeDeliberateChange.current) {\n\t\t\tset(refine(value ?? null))\n\t\t\tsetTemporaryEntry(null)\n\t\t}\n\t\tuserHasMadeDeliberateChange.current = false\n\t}\n\n\tconst handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\tif (onChange) onChange(event)\n\t\tif (set === undefined) return\n\t\tuserHasMadeDeliberateChange.current = true\n\t\tconst input = event.target.value\n\t\tif (isValidNonNumber(input) || isDecimalInProgress(input)) {\n\t\t\tsetTemporaryEntry(input)\n\t\t\tconst textInterpretation = isDecimalInProgress(input)\n\t\t\t\t? input\n\t\t\t\t: min?.toString() ?? `0`\n\t\t\tconst newValue = textToValue(textInterpretation, allowDecimal)\n\t\t\tset(refine(newValue))\n\t\t\treturn\n\t\t}\n\t\tsetTemporaryEntry(null)\n\t\tconst inputIsNumeric =\n\t\t\t(!Number.isNaN(Number(input)) && !input.includes(` `)) ||\n\t\t\t(allowDecimal && input === `.`) ||\n\t\t\t(allowDecimal && input === `-.`) ||\n\t\t\tinput === `` ||\n\t\t\tinput === `-`\n\t\tconst numericValue = textToValue(input, allowDecimal)\n\n\t\tif (inputIsNumeric) {\n\t\t\tset(refine(numericValue))\n\t\t}\n\t}\n\n\tconst displayValue =\n\t\ttemporaryEntry ?? valueToText(value ? refine(value) : value)\n\n\treturn (\n\t\t<span css={customCss}>\n\t\t\t{label && <label htmlFor={id}>{label}</label>}\n\t\t\t{autoSize ? (\n\t\t\t\t<ElasticInput\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tvalue={displayValue}\n\t\t\t\t\tplaceholder={placeholder ?? `-`}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tonBlur={handleBlur}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tname={name ?? id}\n\t\t\t\t\tid={id}\n\t\t\t\t\tonClick={onClick}\n\t\t\t\t\tdata-testid={`number-input-${testId ?? id}`}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<input\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tvalue={displayValue}\n\t\t\t\t\tplaceholder={placeholder ?? `-`}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tonBlur={handleBlur}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tname={name ?? id}\n\t\t\t\t\tid={id}\n\t\t\t\t\tonClick={onClick}\n\t\t\t\t\tdata-testid={`number-input-${testId ?? id}`}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</span>\n\t)\n}\n","import type { Modifier } from \"../function\"\n\nexport const clampInto =\n\t(min: number, max: number): Modifier<number> =>\n\t(value) =>\n\t\tvalue < min ? min : value > max ? max : value\n","import type { Modifier } from \"../function\"\n\nexport const wrapInto =\n\t(min: number, max: number): Modifier<number> =>\n\t(value) =>\n\t\tvalue < min\n\t\t\t? max - ((min - value) % (max - min))\n\t\t\t: min + ((value - min) % (max - min))\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC } from \"react\"\n\nimport { ElasticInput } from \".\"\n\nexport type TextInputProps = {\n\tvalue: string\n\tset?: ((value: string) => void) | undefined\n\tlabel?: string\n\tplaceholder?: string\n\tcustomCss?: SerializedStyles\n\tautoSize?: boolean\n\treadOnly?: boolean\n}\n\nexport const TextInput: FC<TextInputProps> = ({\n\tvalue,\n\tset,\n\tlabel,\n\tplaceholder,\n\tcustomCss,\n\tautoSize = false,\n}) => {\n\treturn (\n\t\t<span css={customCss}>\n\t\t\t<label>{label}</label>\n\t\t\t{autoSize ? (\n\t\t\t\t<ElasticInput\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={(e) => set?.(e.target.value)}\n\t\t\t\t\tdisabled={set === undefined}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<input\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={(e) => set?.(e.target.value)}\n\t\t\t\t\tdisabled={set === undefined}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</span>\n\t)\n}\n","import { ElasticInput } from \"../../react-elastic-input\"\nimport type { JsonEditorProps } from \"../developer-interface\"\n\nexport const NonJsonEditor: React.FC<JsonEditorProps<never>> = ({ data }) => {\n\treturn data === undefined ? (\n\t\t<ElasticInput disabled value=\"undefined\" />\n\t) : (\n\t\t<ElasticInput\n\t\t\tdisabled\n\t\t\tvalue={\n\t\t\t\tObject.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data)\n\t\t\t}\n\t\t/>\n\t)\n}\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC, ReactElement } from \"react\"\nimport type { SetterOrUpdater } from \"recoil\"\n\nimport { doNothing } from \"~/packages/anvl/src/function\"\nimport type { Json, JsonTypes } from \"~/packages/anvl/src/json\"\nimport type { JsonSchema } from \"~/packages/anvl/src/json-schema/json-schema\"\nimport {\n\tisJson,\n\trefineJsonType,\n} from \"~/packages/anvl/src/refinement/refine-json\"\n\nimport { SubEditors } from \".\"\nimport { ElasticInput } from \"../react-elastic-input\"\nimport type { JsonEditorComponents } from \"./default-components\"\nimport { NonJsonEditor } from \"./editors-by-type/non-json\"\n\nexport type JsonEditorProps_INTERNAL<T extends Json.Serializable> = {\n\tdata: T\n\tset: SetterOrUpdater<T>\n\tname?: string | undefined\n\trename?: ((newKey: string) => void) | undefined\n\tremove?: (() => void) | undefined\n\trecast?: (newType: keyof JsonTypes) => void\n\tschema?: JsonSchema | undefined\n\tpath?: ReadonlyArray<number | string>\n\tisReadonly?: (path: ReadonlyArray<number | string>) => boolean\n\tisHidden?: (path: ReadonlyArray<number | string>) => boolean\n\tclassName?: string | undefined\n\tcustomCss?: SerializedStyles | undefined\n\tHeader?: FC<{ data: T; schema?: JsonSchema | undefined }> | undefined\n\tComponents: JsonEditorComponents\n}\n\nexport const JsonEditor_INTERNAL = <T extends Json.Serializable>({\n\tdata,\n\tset,\n\tschema,\n\tname,\n\trename,\n\tremove,\n\trecast,\n\tpath = [],\n\tisReadonly = () => false,\n\tisHidden = () => false,\n\tclassName,\n\tcustomCss,\n\tHeader: HeaderDisplay,\n\tComponents,\n}: JsonEditorProps_INTERNAL<T>): ReactElement | null => {\n\tconst dataIsJson = isJson(data)\n\tconst refined = dataIsJson ? refineJsonType(data) : { type: `non-json`, data }\n\tconst SubEditor = dataIsJson ? SubEditors[refined.type] : NonJsonEditor\n\n\tconst disabled = isReadonly(path)\n\n\treturn isHidden(path) ? null : (\n\t\t<Components.ErrorBoundary>\n\t\t\t<Components.EditorWrapper className={className} customCss={customCss}>\n\t\t\t\t{remove && (\n\t\t\t\t\t<Components.Button\n\t\t\t\t\t\tonClick={disabled ? doNothing : remove}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Components.DeleteIcon />\n\t\t\t\t\t</Components.Button>\n\t\t\t\t)}\n\t\t\t\t{HeaderDisplay && <HeaderDisplay data={data} schema={schema} />}\n\t\t\t\t{rename && (\n\t\t\t\t\t<Components.KeyWrapper>\n\t\t\t\t\t\t<ElasticInput\n\t\t\t\t\t\t\tvalue={name}\n\t\t\t\t\t\t\tonChange={disabled ? doNothing : (e) => rename(e.target.value)}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Components.KeyWrapper>\n\t\t\t\t)}\n\t\t\t\t<SubEditor\n\t\t\t\t\tdata={refined.data}\n\t\t\t\t\tset={set}\n\t\t\t\t\tschema={schema}\n\t\t\t\t\tremove={remove}\n\t\t\t\t\trename={rename}\n\t\t\t\t\tpath={path}\n\t\t\t\t\tisReadonly={isReadonly}\n\t\t\t\t\tisHidden={isHidden}\n\t\t\t\t\tComponents={Components}\n\t\t\t\t/>\n\t\t\t\t{recast && dataIsJson ? (\n\t\t\t\t\t<select\n\t\t\t\t\t\tonChange={\n\t\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\t\t? doNothing\n\t\t\t\t\t\t\t\t: (e) => recast(e.target.value as keyof JsonTypes)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={refined.type}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t>\n\t\t\t\t\t\t{Object.keys(SubEditors).map((type) => (\n\t\t\t\t\t\t\t<option key={type} value={type}>\n\t\t\t\t\t\t\t\t{type}\n\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</select>\n\t\t\t\t) : null}\n\t\t\t</Components.EditorWrapper>\n\t\t</Components.ErrorBoundary>\n\t)\n}\n","import type { SetterOrUpdater } from \"recoil\"\n\nimport { become } from \"~/packages/anvl/src/function\"\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nexport const makeElementSetters = <T extends Json.Array>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n): SetterOrUpdater<T[number]>[] =>\n\tdata.map(\n\t\t(value, index) => (newValue) =>\n\t\t\tset((): T => {\n\t\t\t\tconst newData = [...data]\n\t\t\t\tnewData[index] = become(newValue)(value)\n\t\t\t\treturn newData as unknown as T\n\t\t\t}),\n\t)\n","import type { ReactElement } from \"react\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport type { JsonEditorProps_INTERNAL } from \"../json-editor-internal\"\nimport { JsonEditor_INTERNAL } from \"../json-editor-internal\"\nimport { makeElementSetters } from \"./utilities/array-elements\"\n\nexport const ArrayEditor = <_ extends Json.Array>({\n\tpath = [],\n\tisReadonly = () => false,\n\tisHidden = () => false,\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<Json.Array>): ReactElement => {\n\tconst setElement = makeElementSetters(data, set)\n\treturn (\n\t\t<>\n\t\t\t{data.map((element, index) => {\n\t\t\t\tconst newPath = [...path, index]\n\t\t\t\treturn (\n\t\t\t\t\t<JsonEditor_INTERNAL\n\t\t\t\t\t\tkey={newPath.join(``)}\n\t\t\t\t\t\tpath={newPath}\n\t\t\t\t\t\tisReadonly={isReadonly}\n\t\t\t\t\t\tisHidden={isHidden}\n\t\t\t\t\t\tdata={element}\n\t\t\t\t\t\tset={setElement[index]}\n\t\t\t\t\t\tComponents={Components}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t})}\n\t\t</>\n\t)\n}\n","import { useRef } from \"react\"\nimport type { FC, ReactElement } from \"react\"\n\nimport { doNothing } from \"~/packages/anvl/src/function\"\nimport type { Json } from \"~/packages/anvl/src/json\"\nimport { findSubSchema } from \"~/packages/anvl/src/json-schema/find-sub-schema\"\nimport { isObjectSchema } from \"~/packages/anvl/src/json-schema/json-schema\"\nimport { isPlainObject } from \"~/packages/anvl/src/object/refinement\"\nimport { isLiteral } from \"~/packages/anvl/src/refinement\"\n\nimport { ElasticInput } from \"../../react-elastic-input\"\nimport type { JsonEditorComponents } from \"../default-components\"\nimport type { JsonEditorProps_INTERNAL } from \"../json-editor-internal\"\nimport { JsonEditor_INTERNAL } from \"../json-editor-internal\"\nimport {\n\tmakePropertyCreationInterface,\n\tmakePropertyRecasters,\n\tmakePropertyRemovers,\n\tmakePropertyRenamers,\n\tmakePropertySetters,\n\tmakePropertySorter,\n} from \"./utilities/object-properties\"\n\nexport type PropertyAdderProps = {\n\taddProperty: () => void\n\tdisabled: boolean\n\tpropertyKey: string\n\tComponents: JsonEditorComponents\n}\n\nexport const PropertyAdder: FC<PropertyAdderProps> = ({\n\taddProperty,\n\tdisabled,\n\tpropertyKey,\n\tComponents,\n}) => (\n\t<Components.MissingPropertyWrapper>\n\t\t<ElasticInput disabled defaultValue={propertyKey} />\n\t\t{` `}\n\t\t<ElasticInput disabled defaultValue=\"is missing\" />\n\t\t<Components.Button onClick={() => addProperty()} disabled={disabled}>\n\t\t\t+\n\t\t</Components.Button>\n\t</Components.MissingPropertyWrapper>\n)\n\nexport const ObjectEditor = <T extends Json.Object>({\n\tschema,\n\tpath = [],\n\tisReadonly = () => false,\n\tisHidden = () => false,\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<T>): ReactElement => {\n\tconst disabled = isReadonly(path)\n\n\tconst stableKeyMap = useRef<Record<keyof T, keyof T>>(\n\t\tObject.keys(data).reduce(\n\t\t\t(acc, key: keyof T) => {\n\t\t\t\tacc[key] = key\n\t\t\t\treturn acc\n\t\t\t},\n\t\t\t{} as Record<keyof T, keyof T>,\n\t\t),\n\t)\n\n\tconst setProperty = makePropertySetters(data, set)\n\tconst renameProperty = makePropertyRenamers(data, set, stableKeyMap)\n\tconst removeProperty = makePropertyRemovers(data, set)\n\tconst recastProperty = makePropertyRecasters(data, set)\n\tconst sortProperties = makePropertySorter(data, set)\n\tconst makePropertyAdder = makePropertyCreationInterface(data, set)\n\n\tconst subSchema = isPlainObject(schema) ? findSubSchema(schema)(path) : true\n\tconst schemaKeys: ReadonlyArray<string> | true = isLiteral(true)(subSchema)\n\t\t? true\n\t\t: isObjectSchema(subSchema)\n\t\t ? Object.keys(subSchema.properties ?? {})\n\t\t : []\n\tconst dataKeys: ReadonlyArray<string> = Object.keys(data)\n\tconst [unofficialKeys, officialKeys] = dataKeys.reduce(\n\t\t([unofficial, official], key) => {\n\t\t\tconst isOfficial = schemaKeys === true || schemaKeys.includes(key)\n\t\t\treturn isOfficial\n\t\t\t\t? [unofficial, [...official, key]]\n\t\t\t\t: [[...unofficial, key], official]\n\t\t},\n\t\t[[], []] as [string[], string[]],\n\t)\n\tconst missingKeys: ReadonlyArray<string> =\n\t\tschemaKeys === true\n\t\t\t? []\n\t\t\t: schemaKeys.filter((key) => !dataKeys.includes(key))\n\n\treturn (\n\t\t<>\n\t\t\t<Components.Button onClick={() => sortProperties()} disabled={disabled}>\n\t\t\t\tSort\n\t\t\t</Components.Button>\n\t\t\t<Components.ObjectWrapper>\n\t\t\t\t<div className=\"json_editor_properties\">\n\t\t\t\t\t{[...missingKeys, ...officialKeys, ...unofficialKeys].map((key) => {\n\t\t\t\t\t\tconst originalKey = stableKeyMap.current[key]\n\t\t\t\t\t\tconst newPath = [...path, key]\n\t\t\t\t\t\tconst originalPath = [...path, originalKey]\n\t\t\t\t\t\tconst isOfficial = schemaKeys === true || schemaKeys.includes(key)\n\t\t\t\t\t\tconst isMissing = missingKeys.includes(key)\n\n\t\t\t\t\t\treturn isMissing ? (\n\t\t\t\t\t\t\t<PropertyAdder\n\t\t\t\t\t\t\t\tkey={key + `IsMissing`}\n\t\t\t\t\t\t\t\tpropertyKey={key}\n\t\t\t\t\t\t\t\taddProperty={makePropertyAdder(key, `string`)}\n\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\tComponents={Components}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<JsonEditor_INTERNAL\n\t\t\t\t\t\t\t\tkey={originalPath.join(`.`)}\n\t\t\t\t\t\t\t\tschema={schema}\n\t\t\t\t\t\t\t\tpath={newPath}\n\t\t\t\t\t\t\t\tname={key}\n\t\t\t\t\t\t\t\tisReadonly={isReadonly}\n\t\t\t\t\t\t\t\tisHidden={isHidden}\n\t\t\t\t\t\t\t\tdata={data[key as keyof T]}\n\t\t\t\t\t\t\t\tset={setProperty[key as keyof T]}\n\t\t\t\t\t\t\t\trename={renameProperty[key as keyof T]}\n\t\t\t\t\t\t\t\tremove={removeProperty[key as keyof T]}\n\t\t\t\t\t\t\t\trecast={recastProperty[key as keyof T]}\n\t\t\t\t\t\t\t\tclassName={`json_editor_property ${\n\t\t\t\t\t\t\t\t\tisOfficial ? `json_editor_official` : `json_editor_unofficial`\n\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\tComponents={Components}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t\t<Components.Button\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\t? doNothing\n\t\t\t\t\t\t\t: () => makePropertyAdder(`new_property`, `string`)()\n\t\t\t\t\t}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t>\n\t\t\t\t\t+\n\t\t\t\t</Components.Button>\n\t\t\t</Components.ObjectWrapper>\n\t\t</>\n\t)\n}\n","import { pipe } from \"../function\"\n\nexport type IntegerBrand = { readonly integer: unique symbol /* virtual */ }\nexport type integer = IntegerBrand & number\nexport const isInteger = (input: unknown): input is integer =>\n\tNumber.isInteger(input as number)\n\nexport const parseInteger = (input: unknown): integer => {\n\tif (isInteger(input)) return input\n\tthrow new IntegerParseError(input)\n}\n\nexport class Fraction extends Number {\n\tpublic readonly numerator: integer\n\tpublic readonly denominator: integer\n\n\tpublic constructor(n: integer | number, d: integer | number) {\n\t\tsuper(n / d)\n\t\tif (d === 0) {\n\t\t\tthrow new Error(`Denominator cannot be zero`)\n\t\t}\n\t\tthis.numerator = parseInteger(n)\n\t\tthis.denominator = parseInteger(d)\n\t}\n\tpublic readonly [Symbol.toPrimitive]: () => number = () =>\n\t\tthis.numerator / this.denominator\n}\n\nexport const Frac = (n: integer | number, d: integer | number): Fraction =>\n\tnew Fraction(n, d)\n\nexport const isFraction = (input: unknown): input is Fraction =>\n\tinput instanceof Fraction\n\nexport class IntegerParseError extends Error {\n\tpublic constructor(value: unknown) {\n\t\tsuper(`Could not parse integer from ${JSON.stringify(value)}`)\n\t}\n}\n\nexport type IntegerParseResult =\n\t| {\n\t\t\tvalue: integer\n\t\t\terror: null\n\t\t\tround: null\n\t\t\tupper: null\n\t\t\tlower: null\n\t\t\tratio: null\n\t }\n\t| {\n\t\t\tvalue: null\n\t\t\terror: IntegerParseError\n\t\t\tround: integer\n\t\t\tupper: integer\n\t\t\tlower: integer\n\t\t\tratio: Fraction | null\n\t }\n\nexport const Int = Object.assign((input: unknown) => parseInteger(input), {\n\tfrom: (input: unknown): IntegerParseResult =>\n\t\tpipe(input, String, parseFloat, (num) =>\n\t\t\tisInteger(num)\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: num,\n\t\t\t\t\t\terror: null,\n\t\t\t\t\t\tround: null,\n\t\t\t\t\t\tupper: null,\n\t\t\t\t\t\tlower: null,\n\t\t\t\t\t\tratio: null,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: null,\n\t\t\t\t\t\terror: new IntegerParseError(input),\n\t\t\t\t\t\tround: Math.round(num) as integer,\n\t\t\t\t\t\tupper: Math.ceil(num) as integer,\n\t\t\t\t\t\tlower: Math.floor(num) as integer,\n\t\t\t\t\t\tratio: null,\n\t\t\t\t },\n\t\t),\n\n\tformula: <\n\t\tI extends Record<\n\t\t\tkeyof any,\n\t\t\tFraction | Fraction[] | integer | integer[] | number[] | number\n\t\t>,\n\t\tO extends Record<\n\t\t\tkeyof any,\n\t\t\tFraction | Fraction[] | integer | integer[] | number[] | number\n\t\t>,\n\t>(\n\t\tfm: (\n\t\t\tinput: {\n\t\t\t\t[K in keyof I]: I[K] extends (Fraction | integer)[] ? number[] : number\n\t\t\t},\n\t\t) => O,\n\t) => {\n\t\treturn (input: I): O => {\n\t\t\treturn fm(\n\t\t\t\tinput as {\n\t\t\t\t\t[K in keyof I]: I[K] extends (Fraction | integer)[] ? number[] : number\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t},\n})\n\nexport function asNumber(input: Fraction | integer | number): number\nexport function asNumber(input: Fraction[] | integer[] | number[]): number[]\nexport function asNumber<\n\tR extends Record<\n\t\tkeyof any,\n\t\tFraction | Fraction[] | integer | integer[] | number[] | number\n\t>,\n>(input: R): {\n\t[K in keyof R]: R[K] extends Fraction | integer | number ? number : number[]\n}\nexport function asNumber(input: unknown): unknown {\n\treturn input as any\n}\n\nexport const a = asNumber(new Fraction(1, 2))\nexport const b = asNumber([new Fraction(1, 2)])\nexport const c = asNumber({ a: new Fraction(1, 2) })\n","import { isString } from \"../primitive\"\nimport type { Substitute } from \"../tree/substitute\"\n\nimport { delve } from \"../object\"\nimport { doesExtend } from \"../object/refinement\"\nimport { Int } from \"./integer\"\nimport type { JsonSchema } from \"./json-schema\"\nimport { isJsonSchema } from \"./json-schema\"\n\nexport type JsonSchemaRef = {\n\t$ref: string\n}\nexport function isJsonSchemaRef(input: unknown): input is JsonSchemaRef {\n\treturn doesExtend({\n\t\t$ref: isString,\n\t})(input)\n}\n\nexport type ReffedJsonSchema = Substitute<\n\tJsonSchema,\n\tJsonSchema,\n\tJsonSchema | JsonSchemaRef\n>\n\nexport const colorPalette: ReffedJsonSchema = {\n\t$defs: {\n\t\tcolorChannel: {\n\t\t\ttype: `integer`,\n\t\t\tminimum: Int(0),\n\t\t\tmaximum: Int(255),\n\t\t},\n\t\tcolor: {\n\t\t\ttype: `object`,\n\t\t\tproperties: {\n\t\t\t\tred: { $ref: `#/$defs/colorChannel` },\n\t\t\t\tgreen: { $ref: `#/$defs/colorChannel` },\n\t\t\t\tblue: { $ref: `#/$defs/colorChannel` },\n\t\t\t},\n\t\t},\n\t},\n\ttype: `array`,\n\titems: {\n\t\t$ref: `#/$defs/color`,\n\t},\n} as const\n\ntype RetrieveRefOptions = {\n\trefNode: JsonSchemaRef\n\trefMap?: Record<string, JsonSchema> | undefined\n\troot: ReffedJsonSchema\n}\ntype RetrieveRefResult = {\n\tnode: JsonSchema\n\trefMap: Record<string, JsonSchema>\n}\n\nexport const retrieveRef = ({\n\trefNode: { $ref },\n\trefMap = {},\n\troot,\n}: RetrieveRefOptions): RetrieveRefResult => {\n\tif (typeof root === `boolean`) {\n\t\tthrow new TypeError(`The root is a boolean and cannot be indexed`)\n\t}\n\tif ($ref in refMap) return { node: refMap[$ref], refMap }\n\tconst [_, ...refPath] = $ref.split(`/`)\n\tconst discovery = delve(root, refPath)\n\tif (discovery instanceof Error) throw discovery\n\tlet node = discovery.found\n\twhile (isJsonSchemaRef(node)) {\n\t\tconst result = retrieveRef({ refNode: node, refMap, root })\n\t\tnode = result.node\n\t\trefMap = result.refMap\n\t}\n\tif (isJsonSchema(node)) {\n\t\treturn { node, refMap: { ...refMap, [$ref]: node } }\n\t}\n\tthrow new TypeError(`The refNode is not a JsonSchema`)\n}\n","import { attempt } from \"../function\"\nimport { isString } from \"../primitive\"\n\nexport const JSON_SCHEMA_STRING_FORMATS = [\n\t`date-time`,\n\t`date`,\n\t`email`,\n\t`hostname`,\n\t`ipv4`,\n\t`ipv6`,\n\t`regex`,\n\t`time`,\n\t`uri-reference`,\n\t`uri-template`,\n\t`uri`,\n\t`uuid`,\n] as const\n\nexport type JsonSchemaStringFormat = (typeof JSON_SCHEMA_STRING_FORMATS)[number]\n\nexport type date_time = string & { readonly date_time: unique symbol }\nexport type date = string & { readonly date: unique symbol }\nexport type email = string & { readonly email: unique symbol }\nexport type hostname = string & { readonly hostname: unique symbol }\nexport type ipv4 = string & { readonly ipv4: unique symbol }\nexport type ipv6 = string & { readonly ipv6: unique symbol }\nexport type regex = string & { readonly regex: unique symbol }\nexport type time = string & { readonly time: unique symbol }\nexport type uri_reference = string & { readonly uri_reference: unique symbol }\nexport type uri_template = string & { readonly uri_template: unique symbol }\nexport type uri = string & { readonly uri: unique symbol }\nexport type uuid = string & { readonly uuid: unique symbol }\n\nexport const isDateTime = (input: unknown): input is date_time =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^([+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24:?00)([.,]\\d+(?!:))?)?(\\17[0-5]\\d([.,]\\d+)?)?([zZ]|([+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$/,\n\t)?.length === 1\n\nexport const isDate = (input: unknown): input is date =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^([+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6]))))?$/,\n\t)?.length === 1\n\nexport const isEmail = (input: unknown): input is email =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n\t)?.length === 1\n\nexport const isHostname = (input: unknown): input is hostname =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^(?=.{1,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\\.)+[a-zA-Z]{2,63}$)/,\n\t)?.length === 1\n\nexport const isIpv4 = (input: unknown): input is ipv4 =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,\n\t)?.length === 1\n\nexport const isIpv6 = (input: unknown): input is ipv6 => isString(input) // && net.isIPv6(input)\n\nexport const isRegex = (input: unknown): input is regex =>\n\tisString(input) && attempt(() => new RegExp(input))\n\nexport const isTime = (input: unknown): input is time =>\n\tisString(input) &&\n\tinput.match(/^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\\.\\d+)?$/)\n\t\t?.length === 1\n\nexport const isUriReference = (input: unknown): input is uri_reference =>\n\tisString(input) &&\n\tinput.match(/^(([^:/?#]+):)?(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/)\n\t\t?.length === 1\n\nexport const isUriTemplate = (input: unknown): input is uri_template =>\n\tisString(input) &&\n\tinput.match(/^(([^:/?#]+):)?(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/)\n\t\t?.length === 1\n\nexport const isUri = (input: unknown): input is uri =>\n\tisString(input) &&\n\tinput.match(/^(([^:/?#]+):)?(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/)\n\t\t?.length === 1\n\nexport const isUuid = (input: unknown): input is uuid =>\n\tisString(input) &&\n\tinput.match(\n\t\t/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,\n\t)?.length === 1\n","import { isArray } from \"../array\"\nimport { JSON_TYPE_NAMES } from \"../json\"\nimport { ifDefined } from \"../nullish\"\nimport { doesExtend, isRecord } from \"../object/refinement\"\nimport { isBoolean, isNumber, isString } from \"../primitive\"\nimport type { Refinement } from \"../refinement\"\nimport {\n\tisIntersection,\n\tisLiteral,\n\tisUnion,\n\tisWithin,\n\tmustSatisfyOneOfTheFollowing,\n} from \"../refinement\"\nimport type { Refined } from \"../refinement/refined\"\nimport type { integer } from \"./integer\"\nimport { isInteger } from \"./integer\"\nimport type { JsonSchemaRef } from \"./refs\"\nimport { isJsonSchemaRef } from \"./refs\"\nimport type { JsonSchemaStringFormat } from \"./string-formats\"\nimport { JSON_SCHEMA_STRING_FORMATS } from \"./string-formats\"\n\n/* eslint-disable max-lines */\n\nexport const JSON_SCHEMA_TYPE_NAMES = [...JSON_TYPE_NAMES, `integer`] as const\nexport type JsonSchemaTypeName = (typeof JSON_SCHEMA_TYPE_NAMES)[number]\n\nexport const JSON_SCHEMA_META_TYPE_NAMES = [\n\t...JSON_SCHEMA_TYPE_NAMES,\n\t`any`,\n\t`never`,\n] as const\nexport type JsonSchemaMetaTypeName = (typeof JSON_SCHEMA_META_TYPE_NAMES)[number]\n\nexport const JSON_SCHEMA_LOGIC_MODES = [\n\t`union`,\n\t`exclusive`,\n\t`intersection`,\n\t`negation`,\n\t`conditional`,\n] as const\nexport type JsonSchemaLogicMode = (typeof JSON_SCHEMA_LOGIC_MODES)[number]\n\nexport interface JsonSchemaSystem\n\textends Record<JsonSchemaLogicMode & JsonSchemaMetaTypeName, any> {\n\tarray: ArraySchema\n\tboolean: BooleanSchema\n\tinteger: IntegerSchema\n\tnull: NullSchema\n\tnumber: NumberSchema\n\tobject: ObjectSchema\n\tstring: StringSchema\n\tany: true\n\tnever: false\n\tunion: UnionSchema\n\texclusive: ExclusiveSchema\n\tintersection: IntersectionSchema\n\tnegation: NegationSchema\n\tconditional: ConditionalSchema\n}\n\n// export const JSON_SCHEMA_SYSTEM: JsonSchemaSystem = {\n// array: { type: `array` },\n// boolean: { type: `boolean` },\n// integer: { type: `integer` },\n// null: { type: `null` },\n// number: { type: `number` },\n// object: { type: `object` },\n// string: { type: `string` },\n// any: true,\n// never: false,\n// union: { anyOf: [true] },\n// exclusive: { oneOf: [true] },\n// intersection: { allOf: [true] },\n// negation: { not: false },\n// conditional: { if: true, then: true, else: false },\n// } as const\n\nexport const JSON_SCHEMA_REFINERY: {\n\t[K in JsonSchemaLogicMode & JsonSchemaMetaTypeName]: Refinement<\n\t\tunknown,\n\t\tJsonSchemaSystem[K]\n\t>\n} = {\n\tarray: isArraySchema,\n\tboolean: isBooleanSchema,\n\tinteger: isIntegerSchema,\n\tnull: isNullSchema,\n\tnumber: isNumberSchema,\n\tobject: isObjectSchema,\n\tstring: isStringSchema,\n\tany: isLiteral(true),\n\tnever: isLiteral(false),\n\tunion: isUnionSchema,\n\tintersection: isIntersectionSchema,\n\tnegation: isNegationSchema,\n\tconditional: isConditionalSchema,\n}\n\nexport type StringSchema = {\n\ttype: `string`\n\tenum?: string[]\n\tminLength?: integer\n\tmaxLength?: integer\n\tpattern?: string\n\tformat?: JsonSchemaStringFormat\n}\nexport const stringSchemaStructure = {\n\ttype: isLiteral(`string`),\n\tenum: ifDefined(isArray(isString)),\n\tminLength: ifDefined(isInteger),\n\tmaxLength: ifDefined(isInteger),\n\tpattern: ifDefined(isString),\n\tformat: ifDefined(isWithin(JSON_SCHEMA_STRING_FORMATS)),\n}\nexport function isStringSchema(input: unknown): input is StringSchema {\n\treturn doesExtend(stringSchemaStructure)(input)\n}\n\nexport const numberSchemaStructure = {\n\ttype: isLiteral(`number`),\n\tenum: ifDefined(isArray(isNumber)),\n\tminimum: ifDefined(isNumber),\n\tmaximum: ifDefined(isNumber),\n\texclusiveMinimum: ifDefined(isNumber),\n\texclusiveMaximum: ifDefined(isNumber),\n\tmultipleOf: ifDefined(isNumber),\n}\nexport type NumberSchema = Refined<typeof numberSchemaStructure>\nexport function isNumberSchema(input: unknown): input is NumberSchema {\n\treturn doesExtend(numberSchemaStructure)(input)\n}\n\nexport const integerSchemaStructure = {\n\ttype: isLiteral(`integer`),\n\tenum: ifDefined(isArray(isInteger)),\n\tminimum: ifDefined(isInteger),\n\tmaximum: ifDefined(isInteger),\n\texclusiveMinimum: ifDefined(isInteger),\n\texclusiveMaximum: ifDefined(isInteger),\n\tmultipleOf: ifDefined(isInteger),\n}\nexport type IntegerSchema = Refined<typeof integerSchemaStructure>\nexport function isIntegerSchema(input: unknown): input is IntegerSchema {\n\treturn doesExtend(integerSchemaStructure)(input)\n}\n\nexport const booleanSchemaStructure = {\n\ttype: isLiteral(`boolean`),\n\tenum: ifDefined(isArray(isBoolean)),\n}\nexport type BooleanSchema = Refined<typeof booleanSchemaStructure>\nexport function isBooleanSchema(input: unknown): input is BooleanSchema {\n\treturn doesExtend(booleanSchemaStructure)(input)\n}\n\nexport const nullSchemaStructure = {\n\ttype: isLiteral(`null`),\n}\nexport type NullSchema = Refined<typeof nullSchemaStructure>\nexport function isNullSchema(input: unknown): input is NullSchema {\n\treturn doesExtend(nullSchemaStructure)(input)\n}\n\nexport type ObjectSchema = {\n\ttype: `object`\n\tproperties?: Record<string, JsonSchema>\n\tpatternProperties?: Record<string, JsonSchema>\n\trequired?: string[]\n\tadditionalProperties?: JsonSchema\n\tpropertyNames?: JsonSchema\n\tminProperties?: integer\n\tmaxProperties?: integer\n\tdependentSchemas?: Record<string, JsonSchema>\n}\nexport const objectSchemaStructure = {\n\ttype: isLiteral(`object`),\n\tproperties: ifDefined(isRecord(isString, isJsonSchema)),\n\trequired: ifDefined(isArray(isString)),\n\tadditionalProperties: ifDefined(isJsonSchema),\n\tpropertyNames: ifDefined(isStringSchema),\n\tminProperties: ifDefined(isInteger),\n\tmaxProperties: ifDefined(isInteger),\n\tdependentSchemas: ifDefined(isRecord(isString, isJsonSchema)),\n}\nexport function isObjectSchema(input: unknown): input is ObjectSchema {\n\treturn doesExtend(objectSchemaStructure)(input)\n}\n\nexport type ArraySchema = {\n\ttype: `array`\n\titems?: JsonSchema | JsonSchema[]\n\tminItems?: integer\n\tmaxItems?: integer\n\tuniqueItems?: boolean\n}\nexport const arraySchemaStructure = {\n\ttype: isLiteral(`array`),\n\titems: ifDefined(\n\t\tmustSatisfyOneOfTheFollowing(isJsonSchema).or(isArray(isJsonSchema)),\n\t),\n\tminItems: ifDefined(isInteger),\n\tmaxItems: ifDefined(isInteger),\n\tuniqueItems: ifDefined(isBoolean),\n}\nexport function isArraySchema(input: unknown): input is ArraySchema {\n\treturn doesExtend(arraySchemaStructure)(input)\n}\n\nexport type UnionSchema = { anyOf: JsonSchema[] }\nexport const unionSchemaStructure = { anyOf: isArray(isJsonSchema) }\nexport function isUnionSchema(input: unknown): input is UnionSchema {\n\treturn doesExtend(unionSchemaStructure)(input)\n}\nexport type IntersectionSchema = {\n\tallOf: JsonSchema[] | ReadonlyArray<JsonSchema>\n}\nexport type ExclusiveSchema = {\n\toneOf: JsonSchema[] | ReadonlyArray<JsonSchema>\n}\nexport const exclusiveSchemaStructure = { oneOf: isArray(isJsonSchema) }\nexport function isExclusiveSchema(input: unknown): input is ExclusiveSchema {\n\treturn doesExtend(exclusiveSchemaStructure)(input)\n}\n\nexport const intersectionSchemaStructure = { allOf: isArray(isJsonSchema) }\nexport function isIntersectionSchema(\n\tinput: unknown,\n): input is IntersectionSchema {\n\treturn doesExtend(intersectionSchemaStructure)(input)\n}\n\nexport type ConditionalSchema = {\n\tif: JsonSchema\n\tthen?: JsonSchema\n\telse?: JsonSchema\n}\nexport const conditionalSchemaStructure = {\n\tif: isJsonSchema,\n\tthen: ifDefined(isJsonSchema),\n\telse: ifDefined(isJsonSchema),\n}\nexport function isConditionalSchema(input: unknown): input is ConditionalSchema {\n\treturn doesExtend(conditionalSchemaStructure)(input)\n}\n\nexport type NegationSchema = { not: JsonSchema }\nexport const negationSchemaStructure = { not: isJsonSchema }\nexport function isNegationSchema(input: unknown): input is NegationSchema {\n\treturn doesExtend(negationSchemaStructure)(input)\n}\n\nexport type MixedSchema = Partial<\n\tOmit<ArraySchema, `type`> &\n\t\tOmit<BooleanSchema, `enum` | `type`> &\n\t\tOmit<IntegerSchema, `enum` | `type`> &\n\t\tOmit<NullSchema, `type`> &\n\t\tOmit<NumberSchema, `enum` | `type`> &\n\t\tOmit<ObjectSchema, `type`> &\n\t\tOmit<StringSchema, `enum` | `type`>\n> & {\n\ttype: ReadonlyArray<JsonSchemaTypeName>\n\tenum?: ReadonlyArray<integer | boolean | number | string>\n}\nexport const mixedSchemaStructure = {\n\t...arraySchemaStructure,\n\t...booleanSchemaStructure,\n\t...integerSchemaStructure,\n\t...nullSchemaStructure,\n\t...numberSchemaStructure,\n\t...objectSchemaStructure,\n\t...stringSchemaStructure,\n\ttype: isArray(isWithin(JSON_SCHEMA_TYPE_NAMES)),\n\tenum: ifDefined(\n\t\tisArray(isUnion.or(isInteger).or(isBoolean).or(isNumber).or(isString)),\n\t),\n}\nexport function isMixedSchema(input: unknown): input is MixedSchema {\n\treturn doesExtend(mixedSchemaStructure)(input)\n}\n\nexport type JsonSchemaCore =\n\t| ArraySchema\n\t| BooleanSchema\n\t| ConditionalSchema\n\t| ExclusiveSchema\n\t| IntegerSchema\n\t| IntersectionSchema\n\t| MixedSchema\n\t| NegationSchema\n\t| NullSchema\n\t| NumberSchema\n\t| ObjectSchema\n\t| StringSchema\n\t| UnionSchema\n\nexport const isJsonSchemaCore = isUnion\n\t.or(isArraySchema)\n\t.or(isBooleanSchema)\n\t.or(isConditionalSchema)\n\t.or(isExclusiveSchema)\n\t.or(isIntegerSchema)\n\t.or(isIntersectionSchema)\n\t.or(isMixedSchema)\n\t.or(isNegationSchema)\n\t.or(isNullSchema)\n\t.or(isNumberSchema)\n\t.or(isObjectSchema)\n\t.or(isStringSchema)\n\t.or(isUnionSchema)\n\nexport type JsonSchemaLeaf =\n\t| BooleanSchema\n\t| IntegerSchema\n\t| NullSchema\n\t| NumberSchema\n\t| StringSchema\nexport function isJsonSchemaLeaf(input: unknown): input is JsonSchemaLeaf {\n\treturn isUnion\n\t\t.or(isBooleanSchema)\n\t\t.or(isIntegerSchema)\n\t\t.or(isNullSchema)\n\t\t.or(isNumberSchema)\n\t\t.or(isStringSchema)(input)\n}\n\nexport type JsonSchemaTree =\n\t| ArraySchema\n\t| ConditionalSchema\n\t| ExclusiveSchema\n\t| IntersectionSchema\n\t| MixedSchema\n\t| NegationSchema\n\t| ObjectSchema\n\t| UnionSchema\nexport function isJsonSchemaTree(input: unknown): input is JsonSchemaTree {\n\treturn isUnion\n\t\t.or(isArraySchema)\n\t\t.or(isMixedSchema)\n\t\t.or(isObjectSchema)\n\t\t.or(isUnionSchema)\n\t\t.or(isIntersectionSchema)\n\t\t.or(isExclusiveSchema)\n\t\t.or(isConditionalSchema)\n\t\t.or(isNegationSchema)(input)\n}\n\nexport type JsonSchemaRoot = {\n\t$id?: string\n\t$schema?: string\n\t$defs?: Record<string, JsonSchema>\n\tdefinitions?: Record<string, JsonSchema>\n}\n\nexport const isJsonSchemaRoot = doesExtend({\n\t$id: ifDefined(isString),\n\t$schema: ifDefined(isString),\n})\n\n/* prettier-ignore */\nexport type JsonSchemaObject = JsonSchemaCore & JsonSchemaRoot\nexport const isJsonSchemaObject = isIntersection\n\t.and(isJsonSchemaCore)\n\t.and(isJsonSchemaRoot)\n\nexport type JsonSchema = JsonSchemaObject | JsonSchemaRef | boolean\nexport function isJsonSchema(input: unknown): input is JsonSchema {\n\treturn mustSatisfyOneOfTheFollowing(isBoolean)\n\t\t.or(isJsonSchemaObject)\n\t\t.or(isJsonSchemaRef)(input)\n}\n","export const expandPathForSchema = (\n\tpath: (keyof any)[],\n): (number | string)[] | Error => {\n\ttry {\n\t\treturn path.flatMap((key) => {\n\t\t\tswitch (typeof key) {\n\t\t\t\tcase `string`:\n\t\t\t\t\treturn [`properties`, key]\n\t\t\t\tcase `number`:\n\t\t\t\t\treturn [`items`, key]\n\t\t\t\tcase `symbol`:\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`The key ${String(\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)} is not a valid JSON key; expected string or number, got symbol`,\n\t\t\t\t\t)\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`The key ${key} is not a valid JSON key; expected string or number, got ${typeof key}`,\n\t\t\t\t\t)\n\t\t\t}\n\t\t})\n\t} catch (caught) {\n\t\tif (caught instanceof TypeError) return caught\n\t\tthrow caught\n\t}\n}\n","import { isJsonSchema } from \"./json-schema\"\nimport { expandPathForSchema } from \"./path-into\"\nimport { isJsonSchemaRef, retrieveRef } from \"./refs\"\nimport type { ReffedJsonSchema } from \"./refs\"\n\nexport const findSubSchema = (\n\tschema: ReffedJsonSchema,\n): ((\n\tpath: (number | string)[] | ReadonlyArray<number | string>,\n) => Error | ReffedJsonSchema) => {\n\tif (typeof schema === `boolean`) {\n\t\tthrow new Error(`The schema does not contain subSchemas`)\n\t}\n\treturn (path: string[]) => {\n\t\tconst pathIntoSchema = expandPathForSchema(path)\n\t\tif (pathIntoSchema instanceof Error) return pathIntoSchema\n\t\tif (typeof schema === `boolean`) {\n\t\t\treturn new TypeError(`The schema is not a JsonSchema`)\n\t\t}\n\t\tconst { node, refMap } = pathIntoSchema.reduce(\n\t\t\t({ node, refMap = undefined }, key) => (\n\t\t\t\tconsole.log({ node, key }),\n\t\t\t\tisJsonSchemaRef(node)\n\t\t\t\t\t? retrieveRef({ refNode: node, root: schema, refMap })\n\t\t\t\t\t: { node: node[key], refMap }\n\t\t\t),\n\t\t\t{ node: schema, refMap: undefined },\n\t\t)\n\t\tif (node instanceof Error) throw node\n\n\t\tlet subSchema = node\n\t\twhile (isJsonSchemaRef(subSchema)) {\n\t\t\tconsole.log({ subSchema })\n\t\t\tsubSchema = retrieveRef({ refNode: subSchema, root: schema, refMap }).node\n\t\t}\n\t\tconsole.log({ subSchema })\n\n\t\tif (isJsonSchema(subSchema)) {\n\t\t\treturn subSchema\n\t\t}\n\t\tthrow new TypeError(`The subSchema is not a JsonSchema`)\n\t}\n}\n","import type * as Json from \"./json\"\n\nexport const stringToBoolean = (str: string): boolean => str === `true`\nexport const stringToNumber = (str: string): number => Number(str)\nexport const stringToArray = (str: string): string[] => str.split(`,`)\nexport const stringToObject = (str: string): Json.Object => {\n\ttry {\n\t\treturn JSON.parse(str)\n\t} catch (e) {\n\t\treturn { [str]: str }\n\t}\n}\n\nexport const objectToString = (obj: Json.Object): string => JSON.stringify(obj)\nexport const objectToBoolean = (obj: Json.Object): boolean => obj.true === true\nexport const objectToNumber = (obj: Json.Object): number =>\n\tNumber(obj.number ?? obj.size ?? obj.count ?? 0)\nexport const objectToArray = <T extends Json.Serializable>(\n\tobj: Json.Object<string, T>,\n): [key: string, value: T][] => Object.entries(obj)\n\nexport const booleanToString = (bool: boolean): string => bool.toString()\nexport const booleanToNumber = (bool: boolean): number => +bool\nexport const booleanToObject = (bool: boolean): Json.Object => ({\n\t[bool.toString()]: bool,\n})\nexport const booleanToArray = (bool: boolean): boolean[] => [bool]\n\nexport const numberToString = (num: number): string => num.toString()\nexport const numberToBoolean = (num: number): boolean => num === 1\nexport const numberToObject = (num: number): Json.Object => ({\n\tnumber: num,\n})\nexport const numberToArray = (num: number): null[] => Array(num).fill(null)\n\nexport const arrayToString = (arr: Json.Array): string => arr.join(`,`)\nexport const arrayToNumber = (arr: Json.Array): number => arr.length\nexport const arrayToBoolean = (arr: Json.Array): boolean =>\n\ttypeof arr[0] === `boolean` ? arr[0] : arr.length > 0\nexport const arrayToObject = <T extends Json.Serializable>(\n\tarr: Json.Array<T>,\n): Json.Object<`${number}`, T> =>\n\tarr.reduce(\n\t\t(acc, cur, idx) => {\n\t\t\tacc[`${idx}`] = cur\n\t\t\treturn acc\n\t\t},\n\t\t{} as Json.Object<`${number}`, T>,\n\t)\n\nexport const nullToString = (): string => ``\nexport const nullToNumber = (): number => 0\nexport const nullToBoolean = (): boolean => false\nexport const nullToArray = (): Json.Array => []\nexport const nullToObject = (): Json.Object => ({})\n","import type { Json } from \"../json\"\nimport * as Cast from \"../json/cast-json\"\nimport { refineJsonType } from \"./refine-json\"\n\nexport const castToJson = (\n\tinput: Json.Serializable,\n): {\n\tto: {\n\t\tarray: () => Json.Array\n\t\tboolean: () => boolean\n\t\tnumber: () => number\n\t\tobject: () => Json.Object\n\t\tstring: () => string\n\t\tnull: () => null\n\t}\n} => {\n\tconst json = refineJsonType(input)\n\treturn {\n\t\tto: {\n\t\t\tarray: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn Cast.objectToArray(json.data)\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn Cast.stringToArray(json.data)\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn Cast.booleanToArray(json.data)\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn Cast.numberToArray(json.data)\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToArray()\n\t\t\t\t}\n\t\t\t},\n\t\t\tboolean: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn Cast.arrayToBoolean(json.data)\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn Cast.objectToBoolean(json.data)\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn Cast.stringToBoolean(json.data)\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn Cast.numberToBoolean(json.data)\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToBoolean()\n\t\t\t\t}\n\t\t\t},\n\t\t\tnumber: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn Cast.arrayToNumber(json.data)\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn Cast.objectToNumber(json.data)\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn Cast.stringToNumber(json.data)\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn Cast.booleanToNumber(json.data)\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToNumber()\n\t\t\t\t}\n\t\t\t},\n\t\t\tobject: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn Cast.arrayToObject(json.data)\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn Cast.stringToObject(json.data)\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn Cast.booleanToObject(json.data)\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn Cast.numberToObject(json.data)\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToObject()\n\t\t\t\t}\n\t\t\t},\n\t\t\tstring: () => {\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase `array`:\n\t\t\t\t\t\treturn Cast.arrayToString(json.data)\n\t\t\t\t\tcase `object`:\n\t\t\t\t\t\treturn Cast.objectToString(json.data)\n\t\t\t\t\tcase `string`:\n\t\t\t\t\t\treturn json.data\n\t\t\t\t\tcase `boolean`:\n\t\t\t\t\t\treturn Cast.booleanToString(json.data)\n\t\t\t\t\tcase `number`:\n\t\t\t\t\t\treturn Cast.numberToString(json.data)\n\t\t\t\t\tcase `null`:\n\t\t\t\t\t\treturn Cast.nullToString()\n\t\t\t\t}\n\t\t\t},\n\t\t\tnull: () => null,\n\t\t},\n\t}\n}\n","import type { MutableRefObject } from \"react\"\nimport type { SetterOrUpdater } from \"recoil\"\n\nimport { become } from \"~/packages/anvl/src/function\"\nimport { JSON_DEFAULTS } from \"~/packages/anvl/src/json\"\nimport type { Json, JsonTypeName } from \"~/packages/anvl/src/json\"\nimport { mapObject } from \"~/packages/anvl/src/object\"\nimport { castToJson } from \"~/packages/anvl/src/refinement/smart-cast-json\"\n\nexport const makePropertySetters = <T extends Json.Object>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n): { [K in keyof T]: SetterOrUpdater<T[K]> } =>\n\tmapObject<keyof T, any, SetterOrUpdater<any>>(\n\t\tdata,\n\t\t(value, key) => (newValue) =>\n\t\t\tset({ ...data, [key]: become(newValue)(value[key]) }),\n\t)\n\nexport const makePropertyRenamers = <T extends Json.Object>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n\tstableKeyMapRef: MutableRefObject<{ [Key in keyof T]: keyof T }>,\n): { [K in keyof T]: (newKey: string) => void } =>\n\tmapObject<keyof T, any, (newKey: string) => void>(\n\t\tdata,\n\t\t(value, key) => (newKey) =>\n\t\t\tObject.hasOwn(data, newKey)\n\t\t\t\t? null\n\t\t\t\t: set(() => {\n\t\t\t\t\t\tconst entries = Object.entries(data)\n\t\t\t\t\t\tconst index = entries.findIndex(([k]) => k === key)\n\t\t\t\t\t\tentries[index] = [newKey, value]\n\t\t\t\t\t\tconst stableKeyMap = stableKeyMapRef.current\n\t\t\t\t\t\tstableKeyMapRef.current = {\n\t\t\t\t\t\t\t...stableKeyMap,\n\t\t\t\t\t\t\t[newKey]: stableKeyMap[key],\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn Object.fromEntries(entries) as T\n\t\t\t\t }),\n\t)\n\nexport const makePropertyRemovers = <T extends Json.Object>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n): { [K in keyof T]: () => void } =>\n\tmapObject<keyof T, any, () => void>(\n\t\tdata,\n\t\t(_, key) => () =>\n\t\t\tset(() => {\n\t\t\t\tconst { [key]: _, ...rest } = data\n\t\t\t\treturn rest as T\n\t\t\t}),\n\t)\n\nexport const makePropertyRecasters = <T extends Json.Object>(\n\tdata: T,\n\tset: SetterOrUpdater<T>,\n): { [K in keyof T]: (newType: JsonTypeName) => void } =>\n\tmapObject<keyof T, any, (newType: JsonTypeName) => void>(\n\t\tdata,\n\t\t(value, key) => (newType) =>\n\t\t\tset(() => ({\n\t\t\t\t...data,\n\t\t\t\t[key]: castToJson(value).to[newType](),\n\t\t\t})),\n\t)\n\nexport const makePropertyCreationInterface =\n\t<T extends Json.Object>(\n\t\tdata: T,\n\t\tset: SetterOrUpdater<T>,\n\t): ((\n\t\tkey: string,\n\t\ttype: JsonTypeName,\n\t) => (value?: Json.Serializable) => void) =>\n\t(key, type) =>\n\t(value) =>\n\t\tset({ ...data, [key]: value ?? JSON_DEFAULTS[type] })\n\nexport const makePropertySorter =\n\t<T extends Json.Object>(\n\t\tdata: T,\n\t\tset: SetterOrUpdater<T>,\n\t\tsortFn?: (a: string, b: string) => number,\n\t): (() => void) =>\n\t() => {\n\t\tconst sortedKeys = Object.keys(data).sort(sortFn)\n\t\tconst sortedObj = {} as Record<string, unknown>\n\t\tfor (const key of sortedKeys) {\n\t\t\tsortedObj[key] = data[key]\n\t\t}\n\t\tset(sortedObj as T)\n\t}\n\n// export const sortPropertiesAlphabetically = <T extends Json.Object>(data: T): T =>\n// sortProperties(data, (a, b) => a.localeCompare(b))\n\nexport const deleteProperty =\n\t<T extends Json.Object>(\n\t\tdata: T,\n\t\tset: SetterOrUpdater<T>,\n\t): ((key: keyof T) => void) =>\n\t(key) => {\n\t\tconst { [key]: _, ...rest } = data\n\t\tset(rest as T)\n\t}\n\nexport const addProperty =\n\t<T extends Json.Object>(\n\t\tdata: T,\n\t\tset: SetterOrUpdater<T>,\n\t): ((key?: string, value?: Json.Serializable) => void) =>\n\t(key, value) => {\n\t\tconst newKey = key ?? `newProperty`\n\t\tconst newValue = value ?? ``\n\t\tset({ ...data, [newKey]: newValue })\n\t}\n","import type { ReactElement } from \"react\"\n\nimport { NumberInput, TextInput } from \"../../react-elastic-input\"\nimport type { JsonEditorProps_INTERNAL } from \"../json-editor-internal\"\n\nexport const BooleanEditor = ({\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<boolean>): ReactElement => (\n\t<Components.BooleanWrapper>\n\t\t<input\n\t\t\ttype=\"checkbox\"\n\t\t\tchecked={data}\n\t\t\tonChange={(event) => set(event.target.checked)}\n\t\t/>\n\t</Components.BooleanWrapper>\n)\n\nexport const NullEditor = ({\n\tComponents,\n}: JsonEditorProps_INTERNAL<null>): ReactElement => (\n\t<Components.NullWrapper>\" \"</Components.NullWrapper>\n)\n\nexport const NumberEditor = ({\n\tpath = [],\n\tisReadonly = () => false,\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<number>): ReactElement => (\n\t<Components.NumberWrapper>\n\t\t<NumberInput\n\t\t\tvalue={data}\n\t\t\tset={isReadonly(path) ? undefined : (newValue) => set(Number(newValue))}\n\t\t\tautoSize={true}\n\t\t/>\n\t</Components.NumberWrapper>\n)\n\nexport const StringEditor = ({\n\tpath = [],\n\tisReadonly = () => false,\n\tdata,\n\tset,\n\tComponents,\n}: JsonEditorProps_INTERNAL<string>): ReactElement => {\n\treturn (\n\t\t<Components.StringWrapper>\n\t\t\t<TextInput\n\t\t\t\tvalue={data}\n\t\t\t\tset={isReadonly(path) ? undefined : set}\n\t\t\t\tautoSize={true}\n\t\t\t/>\n\t\t</Components.StringWrapper>\n\t)\n}\n","import type { ErrorInfo, FC, ReactNode } from \"react\"\nimport { Component, useState } from \"react\"\n\nimport type { FallbackProps } from \"./DefaultFallback\"\nimport { DefaultFallback } from \"./DefaultFallback\"\n\nexport type ErrorBoundaryState = {\n\terror?: Error | string\n\terrorInfo?: ErrorInfo\n}\n\nexport type ErrorBoundaryProps = {\n\tchildren: ReactNode\n\tonError?: ((error: Error | string, errorInfo: ErrorInfo) => void) | undefined\n\tFallback?: FC<FallbackProps> | undefined\n\tuseResetErrorState?: () => () => void\n\tuseErrorState?: () => [\n\t\tErrorBoundaryState,\n\t\t(\n\t\t\tnewState:\n\t\t\t\t| ErrorBoundaryState\n\t\t\t\t| ((currState: ErrorBoundaryState) => ErrorBoundaryState),\n\t\t) => void,\n\t]\n}\n\nexport class ErrorBoundary extends Component<\n\tErrorBoundaryProps,\n\tErrorBoundaryState\n> {\n\tpublic constructor(props: ErrorBoundaryProps) {\n\t\tsuper(props)\n\t\tthis.state = {}\n\t\t// We can filter or add information\n\t\t// to airbrake notifications here:\n\t}\n\n\tpublic override componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n\t\tthis.props.onError?.(error, errorInfo)\n\t\tthis.setState({\n\t\t\terror,\n\t\t\terrorInfo,\n\t\t})\n\t}\n\n\tpublic override render(): ReactNode {\n\t\tconst { error, errorInfo } = this.state\n\t\tconst { children, Fallback = DefaultFallback } = this.props\n\n\t\treturn errorInfo ? (\n\t\t\t<Fallback error={error} errorInfo={errorInfo} />\n\t\t) : (\n\t\t\t(children as ReactNode)\n\t\t)\n\t}\n}\n\nexport const RecoverableErrorBoundary: FC<ErrorBoundaryProps> = ({\n\tchildren,\n\tFallback = DefaultFallback,\n\tuseErrorState = () => useState<ErrorBoundaryState>({}),\n\tuseResetErrorState,\n}) => {\n\tconst [{ error }, setError] = useErrorState()\n\tconst resetError = useResetErrorState\n\t\t? useResetErrorState()\n\t\t: () => setError({})\n\tconst hasError = Boolean(error)\n\n\treturn hasError ? (\n\t\t<div>\n\t\t\t<button type=\"button\" onClick={resetError}>\n\t\t\t\tReset\n\t\t\t</button>\n\t\t\t<ErrorBoundary Fallback={Fallback}>{children}</ErrorBoundary>\n\t\t</div>\n\t) : (\n\t\t<ErrorBoundary\n\t\t\tFallback={Fallback}\n\t\t\tonError={(newError, newErrorInfo) =>\n\t\t\t\tsetError({ error: newError, errorInfo: newErrorInfo })\n\t\t\t}\n\t\t>\n\t\t\t{children}\n\t\t</ErrorBoundary>\n\t)\n}\n","import type { ErrorInfo, FC } from \"react\"\n\nexport type FallbackProps = {\n\terror?: Error | string | undefined\n\terrorInfo?: ErrorInfo | undefined\n}\n\nexport const DefaultFallback: FC<FallbackProps> = ({ error, errorInfo }) => {\n\tconst component = errorInfo?.componentStack?.split(` `).filter(Boolean)[2]\n\tconst message =\n\t\terror?.toString() ?? errorInfo?.componentStack ?? `Unknown error`\n\treturn (\n\t\t<div\n\t\t\tdata-testid=\"error-boundary\"\n\t\t\tstyle={{\n\t\t\t\tflex: `1`,\n\t\t\t\tbackground: `black`,\n\t\t\t\tbackgroundImage: `url(./src/assets/kablooey.gif)`,\n\t\t\t\tbackgroundPosition: `center`,\n\t\t\t\t// backgroundRepeat: `no-repeat`,\n\t\t\t\tbackgroundSize: `overlay`,\n\t\t\t}}\n\t\t>\n\t\t\t{/* <img src=\"./src/assets/kablooey.gif\" alt=\"error\" /> */}\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tmargin: `50px`,\n\t\t\t\t\tmarginTop: `0`,\n\t\t\t\t\tpadding: `50px`,\n\t\t\t\t\tborder: `1px solid dashed`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<span\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackground: `black`,\n\t\t\t\t\t\tcolor: `white`,\n\t\t\t\t\t\tpadding: 10,\n\t\t\t\t\t\tpaddingTop: 5,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{`â ïž `}\n\t\t\t\t\t<span style={{ color: `#fc0`, fontWeight: 700 }}>{component}</span>\n\t\t\t\t\t{` â ïž `}\n\t\t\t\t\t{message}\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC, ReactNode } from \"react\"\n\nimport { ErrorBoundary } from \"../react-error-boundary\"\n\nexport type Dict<T> = Record<string, T>\n\nexport type WrapperComponent<T extends Dict<unknown> = Dict<unknown>> = FC<\n\tT & { children: ReactNode }\n>\n\nexport type WC<T extends Dict<unknown> = Dict<unknown>> = WrapperComponent<T>\n\nexport type JsonEditorComponents = {\n\tErrorBoundary: WC\n\n\tButton: WC<{ onClick: () => void; disabled: boolean }>\n\tDeleteIcon: FC\n\n\tEditorLayout: FC<{\n\t\tDeleteButton?: FC\n\t\tHeader?: FC\n\t\tKeyInput?: FC\n\t\tTypeSelect?: FC\n\t\tValueEditor: FC\n\t\tWrapper: WC\n\t}>\n\tEditorWrapper: WC<{\n\t\tcustomCss?: SerializedStyles | undefined\n\t\tclassName?: string | undefined\n\t}>\n\n\tArrayWrapper: WC\n\tObjectWrapper: WC\n\tStringWrapper: WC\n\tNumberWrapper: WC\n\tBooleanWrapper: WC\n\tNullWrapper: WC\n\n\tMiscastPropertyWrapper: WC\n\tMissingPropertyWrapper: WC\n\tOfficialPropertyWrapper: WC\n\tUnofficialPropertyWrapper: WC\n\tIllegalPropertyWrapper: WC\n\tKeyWrapper: WC\n}\n\nexport const DEFAULT_JSON_EDITOR_COMPONENTS: JsonEditorComponents = {\n\tErrorBoundary: ({ children }) => <ErrorBoundary>{children}</ErrorBoundary>,\n\tButton: ({ onClick, children, disabled }) => (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclassName=\"json_editor_button\"\n\t\t\tonClick={onClick}\n\t\t\tdisabled={disabled}\n\t\t>\n\t\t\t{children}\n\t\t</button>\n\t),\n\tEditorWrapper: ({ children, customCss, className }) => (\n\t\t<div className={`json_editor` + ` ` + className ?? ``} css={customCss}>\n\t\t\t{children}\n\t\t</div>\n\t),\n\tEditorLayout: ({\n\t\tDeleteButton,\n\t\tHeader,\n\t\tKeyInput,\n\t\tTypeSelect,\n\t\tValueEditor,\n\t\tWrapper,\n\t}) => {\n\t\treturn (\n\t\t\t<Wrapper>\n\t\t\t\t{DeleteButton && <DeleteButton />}\n\t\t\t\t{Header && <Header />}\n\t\t\t\t{KeyInput && <KeyInput />}\n\t\t\t\t{TypeSelect && <TypeSelect />}\n\t\t\t\t<ValueEditor />\n\t\t\t</Wrapper>\n\t\t)\n\t},\n\tArrayWrapper: ({ children }) => (\n\t\t<div className=\"json_editor_array\">{children}</div>\n\t),\n\tObjectWrapper: ({ children }) => (\n\t\t<div className=\"json_editor_object\">{children}</div>\n\t),\n\tStringWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_string\">{children}</span>\n\t),\n\tNumberWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_number\">{children}</span>\n\t),\n\tBooleanWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_boolean\">{children}</span>\n\t),\n\tNullWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_null\">{children}</span>\n\t),\n\tMissingPropertyWrapper: ({ children }) => (\n\t\t<div className=\"json_editor_property json_editor_missing\">{children}</div>\n\t),\n\tMiscastPropertyWrapper: ({ children }) => (\n\t\t<div className=\"json_editor_property json_editor_miscast\">{children}</div>\n\t),\n\tIllegalPropertyWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_property json_editor_illegal\">{children}</span>\n\t),\n\tOfficialPropertyWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_property json_editor_official\">{children}</span>\n\t),\n\tUnofficialPropertyWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_property json_editor_unofficial\">\n\t\t\t{children}\n\t\t</span>\n\t),\n\tDeleteIcon: () => (\n\t\t<span className=\"json_editor_icon json_editor_delete\">x</span>\n\t),\n\tKeyWrapper: ({ children }) => (\n\t\t<span className=\"json_editor_key\">{children}</span>\n\t),\n}\n","import type { SerializedStyles } from \"@emotion/react\"\nimport type { FC, ReactElement } from \"react\"\nimport { useMemo } from \"react\"\n\nimport type { Json, JsonTypes } from \"~/packages/anvl/src/json\"\nimport type { JsonSchema } from \"~/packages/anvl/src/json-schema/json-schema\"\n\nimport type { JsonEditorComponents } from \"./default-components\"\nimport { DEFAULT_JSON_EDITOR_COMPONENTS } from \"./default-components\"\nimport { ArrayEditor } from \"./editors-by-type/array-editor\"\nimport { ObjectEditor } from \"./editors-by-type/object-editor\"\nimport {\n\tBooleanEditor,\n\tNullEditor,\n\tNumberEditor,\n\tStringEditor,\n} from \"./editors-by-type/primitive-editors\"\nimport type { JsonEditorProps_INTERNAL } from \"./json-editor-internal\"\nimport { JsonEditor_INTERNAL } from \"./json-editor-internal\"\n\nexport const SubEditors: Record<\n\tkeyof JsonTypes,\n\tFC<JsonEditorProps_INTERNAL<any>>\n> = {\n\tarray: ArrayEditor,\n\tboolean: BooleanEditor,\n\tnull: NullEditor,\n\tnumber: NumberEditor,\n\tobject: ObjectEditor,\n\tstring: StringEditor,\n}\n\nexport type JsonEditorProps<T extends Json.Serializable> = {\n\tdata: T\n\tset: (valOrUpdater: T | ((currVal: T) => T)) => void\n\tname?: string | undefined\n\trename?: ((newKey: string) => void) | undefined\n\tremove?: () => void\n\tschema?: JsonSchema\n\tpath?: ReadonlyArray<number | string>\n\tisReadonly?: (path: ReadonlyArray<number | string>) => boolean\n\tisHidden?: (path: ReadonlyArray<number | string>) => boolean\n\tclassName?: string\n\tcustomCss?: SerializedStyles\n\tHeader?: FC<{ data: T; schema?: JsonSchema }>\n\tComponents?: Partial<JsonEditorComponents>\n}\n\nexport const JsonEditor = <T extends Json.Serializable>({\n\tdata,\n\tset,\n\tschema = true,\n\tname,\n\trename,\n\tremove,\n\tisReadonly = () => false,\n\tisHidden = () => false,\n\t// isIllegal = () => false,\n\tclassName,\n\tcustomCss,\n\tHeader,\n\tComponents: CustomComponents = {},\n}: JsonEditorProps<T>): ReactElement => {\n\tconst Components = {\n\t\t...DEFAULT_JSON_EDITOR_COMPONENTS,\n\t\t...CustomComponents,\n\t}\n\n\treturn (\n\t\t<JsonEditor_INTERNAL\n\t\t\tdata={data}\n\t\t\tset={set}\n\t\t\tname={name}\n\t\t\tschema={schema}\n\t\t\trename={rename}\n\t\t\tremove={remove}\n\t\t\tpath={[]}\n\t\t\tisReadonly={isReadonly}\n\t\t\tisHidden={isHidden}\n\t\t\tclassName={className}\n\t\t\tcustomCss={customCss}\n\t\t\tHeader={Header}\n\t\t\tComponents={Components}\n\t\t/>\n\t)\n}\n","import type { FC } from \"react\"\n\nimport type { JsonTypes } from \"~/packages/anvl/src/json\"\n\nimport { ArrayEditor } from \"./editors-by-type/array-editor\"\nimport { ObjectEditor } from \"./editors-by-type/object-editor\"\nimport {\n\tBooleanEditor,\n\tNullEditor,\n\tNumberEditor,\n\tStringEditor,\n} from \"./editors-by-type/primitive-editors\"\nimport type { JsonEditorProps_INTERNAL } from \"./json-editor-internal\"\n\nexport * from \"./default-components\"\nexport * from \"./developer-interface\"\n\nexport const SubEditors: Record<\n\tkeyof JsonTypes,\n\tFC<JsonEditorProps_INTERNAL<any>>\n> = {\n\tarray: ArrayEditor,\n\tboolean: BooleanEditor,\n\tnull: NullEditor,\n\tnumber: NumberEditor,\n\tobject: ObjectEditor,\n\tstring: StringEditor,\n}\n","import {\n\tFloatingPortal,\n\tuseClick,\n\tuseFloating,\n\tuseInteractions,\n} from \"@floating-ui/react\"\nimport * as React from \"react\"\nimport { pipe } from \"~/packages/anvl/src/function\"\n\nimport { stringToColor } from \"~/packages/anvl/src/string/string-to-color\"\nimport { contrastMax, hexToSpec, offset, specToHex } from \"~/packages/luum/src\"\n\nexport const Id: React.FC<{ id: string }> = ({ id }) => {\n\tconst [isOpen, setIsOpen] = React.useState(false)\n\tconst { refs, floatingStyles, context } = useFloating({\n\t\topen: isOpen,\n\t\tonOpenChange: setIsOpen,\n\t\tplacement: `bottom-start`,\n\t})\n\n\tconst click = useClick(context)\n\tconst { getReferenceProps, getFloatingProps } = useInteractions([click])\n\n\tconst bgColor = stringToColor(id)\n\tconst contrastColor = pipe(bgColor, hexToSpec, contrastMax, specToHex)\n\tconst offsetColor = pipe(bgColor, hexToSpec, offset(0.25), specToHex)\n\tconst contrastOffsetColor = pipe(\n\t\toffsetColor,\n\t\thexToSpec,\n\t\tcontrastMax,\n\t\tspecToHex,\n\t)\n\n\treturn (\n\t\t<>\n\t\t\t<span\n\t\t\t\trole=\"content\"\n\t\t\t\tref={refs.setReference}\n\t\t\t\t{...getReferenceProps()}\n\t\t\t\tstyle={{\n\t\t\t\t\tbackground: bgColor,\n\t\t\t\t\tcursor: `pointer`,\n\t\t\t\t\tpadding: `0px 4px`,\n\t\t\t\t\tcolor: contrastColor,\n\t\t\t\t\tuserSelect: `none`,\n\t\t\t\t\twhiteSpace: `nowrap`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{id.substring(0, 3)}\n\t\t\t</span>\n\t\t\t{isOpen && (\n\t\t\t\t<FloatingPortal>\n\t\t\t\t\t<span\n\t\t\t\t\t\trole=\"popup\"\n\t\t\t\t\t\tref={refs.setFloating}\n\t\t\t\t\t\t{...getFloatingProps()}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t...floatingStyles,\n\t\t\t\t\t\t\tcolor: contrastOffsetColor,\n\t\t\t\t\t\t\tbackground: offsetColor,\n\t\t\t\t\t\t\tpadding: `0px 4px`,\n\t\t\t\t\t\t\tboxShadow: `0px 2px 10px rgba(0, 0, 0, 0.1)`,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{id}\n\t\t\t\t\t</span>\n\t\t\t\t</FloatingPortal>\n\t\t\t)}\n\t\t</>\n\t)\n}\n","export function stringToColor(input: string): string {\n\tlet hash = 0\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst char = input.charCodeAt(i)\n\t\thash = (hash << 5) - hash + char\n\t\thash |= 0 // Convert to 32-bit integer\n\t}\n\tlet hexColor = (hash & 0xffffff).toString(16) // Reduce to 24-bit\n\t// Pad with zeros to ensure it's 6 digits long (24-bit)\n\twhile (hexColor.length < 6) {\n\t\thexColor = `0` + hexColor\n\t}\n\treturn `#${hexColor}`\n}\n","export const HUE_STRUCTURES = {\n\tnone: [],\n\tpolar: [180],\n\tsplit: [150, 210],\n\ttrine: [120, 240],\n\tsquare: [90, 180, 270],\n}\nexport const CHANNEL_SPECIFIC_LUM = {\n\tR: 0.3,\n\tG: 0.5,\n\tB: 0.2,\n}\n/*\nconst I'M_WONDERING_IF_THIS_IS_NOT_VERY_ACCURATE = {\n R: 0.2126,\n G: 0.7152,\n B: 0.0722,\n}\n*/\n","import type { Filter } from \"~/packages/luum/src\"\n\nexport const unfiltered: Filter = [\n\t{ sat: 255, hue: 0 },\n\t{ sat: 255, hue: 360 },\n]\nexport const CMYK: Filter = [\n\t{ sat: 255, hue: 55 },\n\t{ sat: 127, hue: 120 },\n\t{ sat: 255, hue: 200 },\n\t{ sat: 255, hue: 205 },\n\t{ sat: 170, hue: 240 },\n\t{ sat: 230, hue: 270 },\n\t{ sat: 210, hue: 300 },\n\t{ sat: 255, hue: 320 },\n]\n","import type { ChannelObject, Hex } from \"~/packages/luum/src\"\n\nconst channelsToHex = (channels: ChannelObject): Hex =>\n\t`#${Object.values(channels)\n\t\t.map((channel) => {\n\t\t\tlet channelHex = channel.toString(16)\n\t\t\tif (channelHex.length === 1) channelHex = 0 + channelHex\n\t\t\treturn channelHex\n\t\t})\n\t\t.join(``)}`\n\nexport default channelsToHex\n","import { wrapInto } from \"~/packages/anvl/src/number\"\n\nimport type { Degree, Fraction } from \"..\"\n\n/**\n * Gives us the relative values of the channels,\n * irrespective of the white light beneath them.\n * @param {number} hue - in degrees. Gets safely wrapped around first thing.\n *\n * Digital Red 0 -> 0\n *\n * Sunlight 50 -> 50\n *\n * Digital Yellow 60 -> 60\n *\n * Citron 70 -> 70\n *\n * Turquoise 510 -> 150\n *\n * @const {number} hueReduced - hue 0-359.9 is now a floating point 0-5.999.\n *\n * Digital Red 0 -> 0 ~ 0.000\n *\n * Sunlight 50 -> 5/6 ~ 0.833\n *\n * Digital Yellow 60 -> 1 ~ 1.000\n *\n * Citron 70 -> 7/6 ~ 1.167\n *\n * Turquoise 150 -> 5/2 ~ 2.500\n *\n * @const {number} hueInteger - from 1-6. Tells us what color region we are in.\n *\n * Digital Red 0.000 -> 0\n * : red-into-yellow region\n *\n * Sunlight 0.833 -> 0\n * : red-into-yellow region\n *\n * Digital Yellow 1.000 -> 1\n * : yellow-into-green region\n *\n * Citron 1.167 -> 1\n * : yellow-into-green region\n *\n * Turquoise 2.500 -> 2\n * : green-into-cyan region\n *\n * hueInteger is the 'whole number' piece of hueReduced.\n * FYI, the six color regions are bounded by red, yellow, green, cyan, blue, magenta.\n *\n * @const {number} hueDecimal - tells where we are in this region.\n *\n * Digital Red 0.000 -> 0.000\n * : at the very beginning\n *\n * Sunlight 0.833 -> 0.833\n * : near the end\n *\n * Digital Yellow 1.000 -> 0.000\n * : at the very beginning\n *\n * Citron 1.167 -> 0.167\n * : near the beginning\n *\n * Turquoise 2.500 -> 0.500\n * : at the halfway point\n *\n * hueDecimal is the 'fraction' piece of hueReduced.\n * we are going to use this number to determine the value of the in-between channel.\n *\n * @const {number} x - used in primary-secondary transitions like Red into Yellow\n * @const {number} y - used in secondary-primary transitions like Yellow into Green\n * To understand the function of x and y, take the difference between\n *\n * Sunlight (hue 50),\n * Citron (hue 70),\n * Digital Yellow (hue 60),\n *\n * as an instructive case. These colors are all basically yellow.\n *\n * Sunlight is hue 50, which puts it near the end of the red-into-yellow region.\n *\n * This means its Red channel is full, and its Green channel is almost full.\n * The fullness of its Green channel is directly proportional to its\n * hueDecimal, the distance from the beginning of this region: 0.833\n *\n * Citron is hue 70, which puts it near the beginning of the yellow-into-green region.\n *\n * This means its Red channel is ALMOST FULL, and its Green channel is FULL.\n * So the fullness of its Red channel is INVERSELY proportional to its\n * hueDecimal, the distance from the beginning of this region: 1 - 0.167 = 0.833\n *\n * Digital Yellow is hue 60, which puts it at the very beginning of the yellow-into-green region.\n *\n * This means its Red Channel and its Green channel must both be full.\n * Like Citron, the fullness of Digital Yellow's Red channel is inversely proportional to its\n * hueDecimal, which is 0. Therefore Digital Yellow's Red channel has a fullness of 1.\n *\n * @returns array of values reflecting the spread between channels\n *\n * Digital Red case 0: [ R ===== 1 G = x = 0.000 B ===== 0 ]\n *\n * Sunlight case 0: [ R ===== 1 G = x = 0.833 B ===== 0 ]\n *\n * DigitalYellow case 1: [ R = y = 1.000 G ===== 1 B ===== 0 ]\n *\n * Citron case 1: [ R = y = 0.833 G ===== 1 B ===== 0 ]\n *\n * Turquoise case 2: [ R ===== 0 G ===== 1 B = x = 0.500 ]\n *\n * here we see detailed breakdowns of the function's final output for our running examples.\n */\nexport default (hue: Degree): [r: Fraction, g: Fraction, b: Fraction] => {\n\tconst hueWrapped = wrapInto(0, 360)(hue)\n\tconst hueReduced = hueWrapped / 60\n\tconst hueInteger = Math.floor(hueReduced)\n\tconst hueDecimal = hueReduced - hueInteger\n\tconst x = hueDecimal\n\tconst y = 1 - hueDecimal\n\tswitch (hueInteger) {\n\t\tcase 0:\n\t\t\treturn [1, x, 0]\n\t\tcase 1:\n\t\t\treturn [y, 1, 0]\n\t\tcase 2:\n\t\t\treturn [0, 1, x]\n\t\tcase 3:\n\t\t\treturn [0, y, 1]\n\t\tcase 4:\n\t\t\treturn [x, 0, 1]\n\t\tcase 5:\n\t\t\treturn [1, 0, y]\n\t\tdefault:\n\t\t\tthrow new Error(`invalid hue served: ${hue}`)\n\t}\n}\n","import type { ChannelObject } from \"~/packages/luum/src\"\n\nconst hueFromChannels = ({ R, G, B }: ChannelObject): number => {\n\tlet hue = 0\n\tif (R > G && G >= B) hue = 60 * (0 + (G - B) / (R - B))\n\tif (G >= R && R > B) hue = 60 * (2 - (R - B) / (G - B))\n\tif (G > B && B >= R) hue = 60 * (2 + (B - R) / (G - R))\n\tif (B >= G && G > R) hue = 60 * (4 - (G - R) / (B - R))\n\tif (B > R && R >= G) hue = 60 * (4 + (R - G) / (B - G))\n\tif (R >= B && B > G) hue = 60 * (6 - (B - G) / (R - G))\n\treturn hue\n}\n\nexport default hueFromChannels\n","import type { ChannelObject } from \"~/packages/luum/src\"\n\nimport { CHANNEL_SPECIFIC_LUM } from \"../constants\"\n\nconst lumFromChannels = ({ R, G, B }: ChannelObject): number => {\n\tconst lum =\n\t\t(CHANNEL_SPECIFIC_LUM.R * R) / 255 +\n\t\t(CHANNEL_SPECIFIC_LUM.G * G) / 255 +\n\t\t(CHANNEL_SPECIFIC_LUM.B * B) / 255\n\t// console.log('||| found lum', lum)\n\treturn lum\n}\n\nexport default lumFromChannels\n","import { wrapInto } from \"~/packages/anvl/src/number\"\nimport type { Degree, Filter } from \"~/packages/luum/src\"\n\nexport default (hue: Degree, filter: Filter): number => {\n\t// 430\n\tlet maxSat = 255\n\tconst hueWrapped = wrapInto(0, 360)(hue) // 70\n\tfor (let a = -1, b = 0; b < filter.length; a++, b++) {\n\t\ta = wrapInto(0, filter.length)(a)\n\t\t// console.log('||| a =', a, 'b =', b)\n\t\tconst hueDoubleWrapped = a > b ? wrapInto(-180, 180)(hueWrapped) : undefined // undef\n\t\tconst tuningPointA = filter[a]\n\t\tconst tuningPointB = filter[b]\n\t\tconst hueA = a > b ? wrapInto(-180, 180)(tuningPointA.hue) : tuningPointA.hue\n\t\tconst hueB = tuningPointB.hue\n\t\tif (\n\t\t\t(hueDoubleWrapped || hueWrapped) >= hueA &&\n\t\t\t(hueDoubleWrapped || hueWrapped) < hueB\n\t\t) {\n\t\t\t// console.log(\n\t\t\t// '||| hue', hue, 'between', tuningPointA.hue, 'and', tuningPointB.hue\n\t\t\t// )\n\t\t\tlet $ = hueDoubleWrapped || hueWrapped // 70\n\t\t\t$ -= hueA // 70 - 50 = 20 //\n\t\t\t$ /= hueB - hueA // 20 / (120 - 50) = 2/7\n\t\t\t$ *= tuningPointB.sat - tuningPointA.sat // -128 * 2 / 7 = -256 / 7 ~= -37\n\t\t\t$ += tuningPointA.sat\n\t\t\tMath.round($)\n\t\t\t// console.log('||| _', _)\n\t\t\tmaxSat = $\n\t\t}\n\t}\n\t// console.log('--- maxSat', maxSat)\n\treturn maxSat\n}\n","import type { ChannelObject } from \"~/packages/luum/src\"\n\nconst satFromChannels = ({ R, G, B }: ChannelObject): number => {\n\tconst sat = Math.max(R, G, B) - Math.min(R, G, B)\n\t// console.log('||| found sat', sat)\n\treturn sat\n}\n\nexport default satFromChannels\n","import { CHANNEL_SPECIFIC_LUM } from \"../constants\"\nimport hueToRelativeChannels from \"../import/hueToRelativeChannels\"\n\nexport default (hue: number): number => {\n\tconst [factorR, factorG, factorB] = hueToRelativeChannels(hue)\n\n\tconst lumR = CHANNEL_SPECIFIC_LUM.R * factorR\n\tconst lumG = CHANNEL_SPECIFIC_LUM.G * factorG\n\tconst lumB = CHANNEL_SPECIFIC_LUM.B * factorB\n\n\tconst specificLum = lumR + lumG + lumB\n\n\treturn specificLum\n}\n","import { clampInto } from \"~/packages/anvl/src/number\"\nimport type {\n\tChannelObject,\n\tDegree,\n\tFilter,\n\tFraction,\n\tLuumSpec,\n\tOutOf255,\n\tRange,\n} from \"~/packages/luum/src\"\n\nimport { unfiltered } from \"../constants/filters\"\nimport hueToRelativeChannels from \"../import/hueToRelativeChannels\"\nimport {\n\tlumFromChannels,\n\tmaxSatForHueInFilter,\n\tspecificLumFromHue,\n} from \"../solveFor\"\n\nconst minChannelsForSaturationFromHue = (hue: Degree) => {\n\tconst relativeChannels = hueToRelativeChannels(hue)\n\tconst channelSpreader = (trueSaturation: OutOf255): ChannelObject => {\n\t\tconst makeMinChannel = (idx: number) =>\n\t\t\tMath.round(relativeChannels[idx] * trueSaturation)\n\t\treturn {\n\t\t\tR: makeMinChannel(0),\n\t\t\tG: makeMinChannel(1),\n\t\t\tB: makeMinChannel(2),\n\t\t}\n\t}\n\treturn channelSpreader\n}\n\ntype IlluminationObj = {\n\tminChannels: ChannelObject\n\ttrueLuminosity: number\n\tminLum: number\n}\n\nconst channelsFromIlluminationObj = ({\n\tminChannels,\n\ttrueLuminosity,\n\tminLum,\n}: IlluminationObj): ChannelObject => {\n\tconst { max, round } = Math\n\tconst maxWhite = 255 - max(...Object.values(minChannels))\n\tconst white = clampInto(0, maxWhite)(round((trueLuminosity - minLum) * 255))\n\tconst channels = {\n\t\tR: minChannels.R + white,\n\t\tG: minChannels.G + white,\n\t\tB: minChannels.B + white,\n\t}\n\treturn channels\n}\n\ntype SpecToChannelsFixLimit = (\n\tspec: LuumSpec,\n\tfilter?: Filter,\n) => {\n\tchannels: ChannelObject\n\tfix: { sat: number; lum: number }\n\tlimit: { sat: Range; lum: Range }\n}\n\nconst specToChannelsFixLimit: SpecToChannelsFixLimit = (\n\t{ hue, sat, lum, prefer = `lum` },\n\tfilter = unfiltered,\n) => {\n\tconst minChannelsForSaturation = minChannelsForSaturationFromHue(hue)\n\n\tlet trueSaturation: OutOf255\n\tlet trueLuminosity: Fraction\n\tlet minChannels: ChannelObject\n\tlet maxChannels: ChannelObject\n\tlet specificLum: Fraction\n\tlet minLum = 0\n\tlet maxLum = 1\n\tlet maxSat = maxSatForHueInFilter(hue, filter)\n\n\tswitch (prefer) {\n\t\tcase `sat`:\n\t\t\ttrueSaturation = clampInto(0, 255)(Math.min(sat, maxSat))\n\t\t\tminChannels = minChannelsForSaturation(trueSaturation)\n\t\t\tmaxChannels = {\n\t\t\t\tR: minChannels.R + 255 - trueSaturation,\n\t\t\t\tG: minChannels.G + 255 - trueSaturation,\n\t\t\t\tB: minChannels.B + 255 - trueSaturation,\n\t\t\t}\n\t\t\tminLum = lumFromChannels(minChannels)\n\t\t\tmaxLum = lumFromChannels(maxChannels)\n\t\t\ttrueLuminosity = clampInto(minLum, maxLum)(lum)\n\n\t\t\tbreak\n\t\tcase `lum`:\n\t\t\ttrueLuminosity = clampInto(0, 1)(lum)\n\t\t\tspecificLum = specificLumFromHue(hue)\n\t\t\tmaxSat = Math.min(\n\t\t\t\tmaxSat,\n\t\t\t\tMath.round(\n\t\t\t\t\ttrueLuminosity <= specificLum\n\t\t\t\t\t\t? 255 * (trueLuminosity / specificLum)\n\t\t\t\t\t\t: (255 * (1 - trueLuminosity)) / (1 - specificLum),\n\t\t\t\t),\n\t\t\t)\n\t\t\ttrueSaturation = Math.min(sat, maxSat)\n\t\t\tminChannels = minChannelsForSaturation(trueSaturation)\n\t\t\tminLum = lumFromChannels(minChannels)\n\t\t\tbreak\n\t}\n\n\tconst channels = channelsFromIlluminationObj({\n\t\tminChannels,\n\t\ttrueLuminosity,\n\t\tminLum,\n\t})\n\n\treturn {\n\t\tchannels,\n\t\tfix: {\n\t\t\tsat: trueSaturation,\n\t\t\tlum: trueLuminosity,\n\t\t},\n\t\tlimit: {\n\t\t\tsat: [0, maxSat],\n\t\t\tlum: [prefer === `lum` ? 0 : minLum, maxLum],\n\t\t},\n\t}\n}\n\nexport default specToChannelsFixLimit\n","import type {\n\tFilter,\n\tHex,\n\tLuumFix,\n\tLuumLimit,\n\tLuumSpec,\n} from \"~/packages/luum/src\"\n\nimport channelsToHex from \"./channelsToHex\"\nimport specToChannels from \"./specToChannelsFixLimit\"\n\ntype SpecToHexFixLimit = (\n\tspec: LuumSpec,\n\tfilter?: Filter,\n) => {\n\thex: Hex\n\tfix: LuumFix\n\tlimit: LuumLimit\n}\n\nconst specToHexFixLimit: SpecToHexFixLimit = (\n\t{ hue, sat, lum, prefer },\n\tfilter,\n) => {\n\tconst { channels, fix, limit } = specToChannels(\n\t\t{\n\t\t\thue,\n\t\t\tsat,\n\t\t\tlum,\n\t\t\tprefer,\n\t\t},\n\t\tfilter,\n\t)\n\tconst { R, G, B } = channels\n\tconst hex = channelsToHex({ R, G, B })\n\n\t// console.log('--- newHex', hex)\n\n\treturn { hex, fix, limit }\n}\n\nexport default specToHexFixLimit\n","import type { Filter, Hex, LuumSpec } from \"~/packages/luum/src\"\n\nimport specToHexFixLimit from \"./specToHexFixLimit\"\n\nconst specToHex = (\n\t{ hue, sat, lum, prefer }: LuumSpec,\n\tfilter?: Filter,\n): Hex => {\n\tconst { hex } = specToHexFixLimit({ hue, sat, lum, prefer }, filter)\n\treturn hex\n}\n\nexport default specToHex\n","import type { ChannelObject, HSL } from \"~/packages/luum/src\"\n\nimport { hueFromChannels, lumFromChannels, satFromChannels } from \"../solveFor\"\n\nconst channelsToSpec = ({ R, G, B }: ChannelObject): HSL => {\n\tconst hue = hueFromChannels({ R, G, B })\n\tconst sat = satFromChannels({ R, G, B })\n\tconst lum = lumFromChannels({ R, G, B })\n\treturn { hue, sat, lum }\n}\n\nexport default channelsToSpec\n","import type { Hex } from \"..\"\n\nconst BASE_16_CHAR_SET = `[a-fA-F0-9]+`\n\nconst miniHexToHex = (miniHex: string): Hex => {\n\tconst miniHexArray = miniHex.split(``)\n\tconst hexTemplate = [0, 0, 1, 1, 2, 2]\n\treturn hexTemplate.map((idx) => miniHexArray[idx]).join(``)\n}\n\nconst normalizeHex = (maybeHex: string): Hex => {\n\tconst hex = maybeHex.replace(/^#/, ``)\n\tconst hexIsCorrectLength = hex.length === 6 || hex.length === 3\n\tconst hexIsCorrectCharSet =\n\t\thex.match(new RegExp(`^${BASE_16_CHAR_SET}$`)) !== null\n\tconst hexIsValid = hexIsCorrectLength && hexIsCorrectCharSet\n\tif (!hexIsValid) {\n\t\tthrow new Error(`${maybeHex} is not a valid hex code`)\n\t}\n\tif (hex.length === 3) {\n\t\treturn miniHexToHex(hex)\n\t}\n\treturn hex\n}\n\nexport default normalizeHex\n","import type { ChannelObject } from \"..\"\nimport normalizeHex from \"./normalizeHex\"\n\nexport default (maybeHex: string): ChannelObject => {\n\tconst hex = normalizeHex(maybeHex)\n\n\treturn {\n\t\tR: parseInt(hex.slice(0, 2), 16),\n\t\tG: parseInt(hex.slice(2, 4), 16),\n\t\tB: parseInt(hex.slice(4, 6), 16),\n\t}\n}\n","import type { HSL } from \"..\"\nimport channelsToSpec from \"./channelsToSpec\"\nimport hexToChannels from \"./hexToChannels\"\n\nconst hexToSpec = (hex: string): HSL => {\n\tconst { R, G, B } = hexToChannels(hex)\n\tconst { hue, sat, lum } = channelsToSpec({ R, G, B })\n\treturn { hue, sat, lum }\n}\n\nexport default hexToSpec\n","import type { Modifier } from \"~/packages/anvl/src/function\"\nimport { become, pipe } from \"~/packages/anvl/src/function\"\nimport { clampInto } from \"~/packages/anvl/src/number/clamp\"\nimport type { HSL, LuumSpec } from \"~/packages/luum/src\"\n\nimport type { LuumApplicator } from \".\"\nimport { hexToSpec, specToHex } from \"..\"\n\nexport const resetColor = (color: LuumSpec): LuumSpec =>\n\tpipe(color, specToHex, hexToSpec, (hsl: HSL) => ({\n\t\t...hsl,\n\t\tprefer: color.prefer,\n\t}))\n\nexport const setLum: LuumApplicator<number> = (newLum) => (currentColor) => {\n\tconst newColor = {\n\t\t...currentColor,\n\t\tlum: pipe(currentColor.lum, become(newLum), clampInto(0, 1)),\n\t}\n\treturn newColor\n}\nexport const tintBy =\n\t(tintAmount: number): Modifier<LuumSpec> =>\n\t(color) =>\n\t\tsetLum((lum) => (lum * 100 + tintAmount) / 100)(resetColor(color))\n\nexport const shadeBy =\n\t(shadeAmount: number): Modifier<LuumSpec> =>\n\t(color) =>\n\t\tsetLum((lum) => (lum * 100 - shadeAmount) / 100)(resetColor(color))\n\nexport const tint = (color: LuumSpec, tintAmount: number): LuumSpec =>\n\ttintBy(tintAmount)(color)\n\nexport const shade = (color: LuumSpec, shadeAmount: number): LuumSpec =>\n\tshadeBy(shadeAmount)(color)\n","import type { Modifier } from \"~/packages/anvl/src/function\"\nimport type { HSL, LuumSpec } from \"~/packages/luum/src\"\n\nexport const contrastMax: Modifier<LuumSpec> = (color) => ({\n\t...color,\n\tlum: color.lum > 0.666 ? 0 : 1,\n})\n\nexport const contrastStrong: Modifier<LuumSpec> = (color) => ({\n\t...color,\n\tlum: color.lum > 0.666 ? 0.05 : 0.95,\n})\n\nexport const contrastSoft: Modifier<LuumSpec> = (color) =>\n\tcolor.lum > 0.75\n\t\t? { ...color, lum: color.lum / 2 }\n\t\t: color.lum < 0.25\n\t\t ? { ...color, lum: color.lum + (1 - color.lum) / 2 }\n\t\t : { ...color, lum: color.lum > 0.666 ? 1 : 0 }\n\nexport const offset =\n\t(offsetAmount: number): Modifier<HSL> =>\n\t(color) => ({\n\t\t...color,\n\t\tlum: color.lum > 0.666 ? color.lum - offsetAmount : color.lum + offsetAmount,\n\t})\n","import type { LuumSpec } from \"~/packages/luum/src\"\n\nexport const defaultSpec: LuumSpec = {\n\thue: 0,\n\tlum: 0,\n\tsat: 0,\n\tprefer: `lum`,\n}\n","import { content, each, isArray, join, map } from \"~/packages/anvl/src/array\"\nimport { isModifier, pipe } from \"~/packages/anvl/src/function\"\nimport type { Modifier, OneOrMany } from \"~/packages/anvl/src/function\"\nimport { isUndefined } from \"~/packages/anvl/src/nullish\"\nimport { key } from \"~/packages/anvl/src/object/access\"\nimport { isString } from \"~/packages/anvl/src/primitive\"\nimport type { Refinement } from \"~/packages/anvl/src/refinement\"\nimport { specToHex } from \"~/packages/luum/src\"\nimport type { Filter, FilterPoint, LuumSpec } from \"~/packages/luum/src\"\nimport { defaultSpec } from \"~/packages/luum/src/constants/luum-spec\"\nimport { shadeBy } from \"~/packages/luum/src/mixers/lum\"\n\n/* eslint-disable max-lines */\n\n// export type InteractiveStates = `active` | `base` | `disabled` | `hover`\n\n// export const HTML_ELEMENT_NAMES = [\n// `a`,\n// `abbr`,\n// `address`,\n// `area`,\n// `article`,\n// `aside`,\n// `audio`,\n// `b`,\n// `base`,\n// `bdi`,\n// `bdo`,\n// `big`,\n// `blockquote`,\n// `body`,\n// `br`,\n// `button`,\n// `canvas`,\n// `caption`,\n// `cite`,\n// `code`,\n// `col`,\n// `colgroup`,\n// `data`,\n// `datalist`,\n// `dd`,\n// `del`,\n// `details`,\n// `dfn`,\n// `dialog`,\n// `div`,\n// `dl`,\n// `dt`,\n// `em`,\n// `embed`,\n// `fieldset`,\n// `figcaption`,\n// `figure`,\n// `footer`,\n// `form`,\n// `h1`,\n// `h2`,\n// `h3`,\n// `h4`,\n// `h5`,\n// `h6`,\n// `head`,\n// `header`,\n// `hgroup`,\n// `hr`,\n// `html`,\n// `i`,\n// `iframe`,\n// `img`,\n// `input`,\n// `ins`,\n// `kbd`,\n// `keygen`,\n// `label`,\n// `legend`,\n// `li`,\n// `link`,\n// `main`,\n// `map`,\n// `mark`,\n// `menu`,\n// `menuitem`,\n// `meta`,\n// `meter`,\n// `nav`,\n// `noscript`,\n// `object`,\n// `ol`,\n// `optgroup`,\n// `option`,\n// `output`,\n// `p`,\n// `param`,\n// `picture`,\n// `pre`,\n// `progress`,\n// `q`,\n// `rp`,\n// `rt`,\n// `ruby`,\n// `s`,\n// `samp`,\n// `script`,\n// `section`,\n// `select`,\n// `small`,\n// `source`,\n// `span`,\n// `strong`,\n// `style`,\n// `sub`,\n// `summary`,\n// `sup`,\n// `table`,\n// `tbody`,\n// `td`,\n// `textarea`,\n// `tfoot`,\n// `th`,\n// `thead`,\n// `time`,\n// `title`,\n// `tr`,\n// `track`,\n// `u`,\n// `ul`,\n// `var`,\n// `video`,\n// `wbr`,\n// ] as const\n\n// export type HTMLElementName = typeof HTML_ELEMENT_NAMES[number]\n\n// export type UniversalSelector = `*`\n\n// export type TypeSelector = HTMLElementName | `body` | `html`\n\n// export type ClassSelector = `.${string}`\n\n// export type IdSelector = `#${string}`\n\n// export type ParentSelector = `&`\n\n// export type AttributeSelector = `[\"${string}\"=\"${string}\"]`\n\n// export type CssSelectorCore =\n// | AttributeSelector\n// | ClassSelector\n// | IdSelector\n// | ParentSelector\n// | TypeSelector\n// | UniversalSelector\n\n// export type CssCombinator = ` ` | ` + ` | ` > ` | ` ~ `\n\nexport const CSS_PSEUDO_CLASSES = [\n\t`:active`,\n\t`:checked`,\n\t`:disabled`,\n\t`:enabled`,\n\t`:focus`,\n\t`:hover`,\n\t`:indeterminate`,\n\t`:visited`,\n] as const\n\nexport type CssPseudoClass = (typeof CSS_PSEUDO_CLASSES)[number]\n\nexport const isCssPseudoClass = (s: unknown): s is CssPseudoClass =>\n\tCSS_PSEUDO_CLASSES.includes(s as CssPseudoClass)\n\n// export type CssPseudoElement =\n// | `::after`\n// | `::backdrop`\n// | `::before`\n// | `::first-letter`\n// | `::first-line`\n// | `::placeholder`\n// | `::selection`\n\n// export type CssSelectorExtension =\n// | AttributeSelector\n// | ClassSelector\n// | CssPseudoClass\n// | CssPseudoElement\n// | `${CssCombinator}${CssSelectorCore}`\n\n// export type CssSelector =\n// | CssSelectorCore\n// | `${CssSelectorCore}${CssSelectorExtension}`\n\nexport const CSS_COLOR_PROPERTY_KEYS = [\n\t`background-color`,\n\t`background`,\n\t`border-bottom-color`,\n\t`border-color`,\n\t`border-left-color`,\n\t`border-right-color`,\n\t`border-top-color`,\n\t`border`,\n\t`box-shadow`,\n\t`caret-color`,\n\t`color`,\n\t`column-rule-color`,\n\t`column-rule`,\n\t`filter`,\n\t`opacity`,\n\t`outline-color`,\n\t`outline`,\n\t`text-decoration-color`,\n\t`text-decoration`,\n\t`text-shadow`,\n\n\t`fill`,\n\t`stroke`,\n] as const\n\nexport type CssVariable = `--${string}`\n\nexport type CssColorPropertyKey =\n\t| (typeof CSS_COLOR_PROPERTY_KEYS)[number]\n\t| CssVariable\n\nexport const isCssColorPropertyKey = (\n\tinput: unknown,\n): input is CssColorPropertyKey =>\n\ttypeof input === `string` &&\n\t(CSS_COLOR_PROPERTY_KEYS.includes(\n\t\tinput as (typeof CSS_COLOR_PROPERTY_KEYS)[number],\n\t) ||\n\t\tinput.startsWith(`--`))\n\nexport const isFilterPoint = (input: unknown): input is FilterPoint =>\n\ttypeof input === `object` &&\n\ttypeof (input as FilterPoint).hue === `number` &&\n\ttypeof (input as FilterPoint).sat === `number`\n\nexport const isFilter = (input: unknown): input is Filter =>\n\tisArray(isFilterPoint)(input)\n\nexport const maybe =\n\t<T>(validate: Refinement<unknown, T>) =>\n\t(input: unknown): input is T | undefined =>\n\t\tisUndefined(input) || validate(input)\n\nexport const isLuumSpec = (input: unknown): input is LuumSpec =>\n\ttypeof input === `object` &&\n\tinput !== null &&\n\ttypeof (input as LuumSpec).hue === `number` &&\n\ttypeof (input as LuumSpec).sat === `number` &&\n\ttypeof (input as LuumSpec).lum === `number` &&\n\t[`sat`, `lum`].includes((input as LuumSpec).prefer)\n\nexport const isLuumSpecModifier: Refinement<\n\tunknown,\n\tModifier<LuumSpec>\n> = isModifier(isLuumSpec)(defaultSpec)\n\nexport type LuumCssAttribute = [\n\tkeys: OneOrMany<CssColorPropertyKey>,\n\ttransformers: OneOrMany<Modifier<LuumSpec>>,\n]\nexport const isLuumCssAttribute = (input: unknown): input is LuumCssAttribute =>\n\tArray.isArray(input) &&\n\tinput.length === 2 &&\n\tcontent(isCssColorPropertyKey)(input[0]) &&\n\tcontent(isLuumSpecModifier)(input[1])\n\nexport type LuumScssPseudoClassRule = [\n\tselectors: OneOrMany<CssPseudoClass>,\n\tattributes: OneOrMany<LuumCssAttribute>,\n]\n\nexport const isLuumScssPseudoClassRule = (\n\tinput: unknown,\n): input is LuumScssPseudoClassRule =>\n\tArray.isArray(input) &&\n\tinput.length === 2 &&\n\tcontent(isCssPseudoClass)(input[0]) &&\n\tcontent(isLuumCssAttribute)(input[1])\n\nexport type LuumScssNestedRule = [\n\tselectors: OneOrMany<string>,\n\tattributes: OneOrMany<LuumCssAttribute>,\n]\n\nexport const isLuumScssNestedRule = (\n\tinput: unknown,\n): input is LuumScssNestedRule =>\n\tArray.isArray(input) &&\n\tinput.length === 2 &&\n\tcontent(isString)(input[0]) &&\n\tcontent(isLuumCssAttribute)(input[1])\n\nexport type LuumCssRule = {\n\trootSelectors?: OneOrMany<string>\n\troot: LuumSpec\n\tattributes: OneOrMany<LuumCssAttribute>\n\tfilter?: Filter\n}\n\nexport const isLuumCssRule = (input: unknown): input is LuumCssRule =>\n\ttypeof input === `object` &&\n\tinput !== null &&\n\tisLuumSpec((input as LuumCssRule).root) &&\n\tcontent(isLuumCssAttribute)(key<LuumCssRule>(`attributes`)(input)) &&\n\tmaybe(content(isString))(key<LuumCssRule>(`rootSelectors`)(input)) &&\n\tmaybe(isFilter)(key<LuumCssRule>(`filter`)(input))\n\nexport type LuumScssRule = LuumCssRule & {\n\tstates?: OneOrMany<LuumScssPseudoClassRule>\n\tchildren?: OneOrMany<LuumScssNestedRule>\n}\n\nexport const isLuumScssRule = (input: unknown): input is LuumScssRule =>\n\tisLuumCssRule(input) &&\n\tmaybe(content(isLuumScssPseudoClassRule))(\n\t\tkey<LuumScssRule>(`states`)(input),\n\t) &&\n\tmaybe(content(isLuumScssNestedRule))(key<LuumScssRule>(`children`)(input))\n\nexport const RED: LuumSpec = {\n\thue: 0,\n\tsat: 255,\n\tlum: 0.5,\n\tprefer: `sat`,\n}\n\nexport const WAYFORGE_CORE_COLOR_NAMES = [\n\t`Red`,\n\t`Orange`,\n\t`Yellow`,\n\t`Lime`,\n\t`Green`,\n\t`Teal`,\n\t`Cyan`,\n\t`Blue`,\n\t`Indigo`,\n\t`Violet`,\n\t`Magenta`,\n\t`Pink`,\n] as const\n\nexport type WayforgeCoreColorName = (typeof WAYFORGE_CORE_COLOR_NAMES)[number]\n\nexport const WAYFORGE_CORE_COLORS: Readonly<\n\tRecord<WayforgeCoreColorName, LuumSpec>\n> = WAYFORGE_CORE_COLOR_NAMES.reduce(\n\t(acc, name, idx) => {\n\t\tacc[name] = {\n\t\t\thue: idx * 30,\n\t\t\tsat: 255,\n\t\t\tlum: 0.5,\n\t\t\tprefer: `sat`,\n\t\t}\n\t\treturn acc\n\t},\n\t{} as Record<WayforgeCoreColorName, LuumSpec>,\n)\n\nexport const PAINT_MY_WAGON_RED: LuumScssRule = {\n\trootSelectors: [`.wagon`],\n\troot: RED,\n\tattributes: [`background-color`, shadeBy(5)],\n\tstates: [\n\t\t[\n\t\t\t[`:hover`, `:focus`],\n\t\t\t[`background-color`, shadeBy(10)],\n\t\t],\n\t\t[`:active`, [`background-color`, shadeBy(15)]],\n\t],\n}\n\nconst LF = `\\n`\n\nexport const luumToCss = (rule: LuumCssRule): string => {\n\tconst {\n\t\tattributes: oneOrManyAttributes,\n\t\troot,\n\t\trootSelectors: maybeOneOrManyRootSelectors,\n\t\tfilter: maybeFilter,\n\t} = rule\n\tconst rootSelectors = pipe(\n\t\tmaybeOneOrManyRootSelectors,\n\t\teach(isString),\n\t\tjoin(`, ` + LF),\n\t\t(s) => (s ? s + ` {` + LF : ``),\n\t)\n\tconst attributes = pipe(\n\t\toneOrManyAttributes,\n\t\teach(isLuumCssAttribute),\n\t\tmap(([oneOrManyKeys, oneOrManyModifiers]) => {\n\t\t\tconst modifiers = each(isLuumSpecModifier)(oneOrManyModifiers)\n\t\t\tconst modifiedSpec = modifiers.reduce((last, modify) => modify(last), root)\n\t\t\tconst hex = specToHex(modifiedSpec, maybeFilter)\n\t\t\treturn pipe(\n\t\t\t\toneOrManyKeys,\n\t\t\t\teach(isCssColorPropertyKey),\n\t\t\t\tmap((key) => `${key}: ${hex}`),\n\t\t\t\tjoin(`; ` + LF),\n\t\t\t)\n\t\t}),\n\t\tjoin(`; ` + LF),\n\t)\n\treturn rootSelectors ? join(LF)([rootSelectors, attributes, `}`]) : attributes\n}\n\n// export const luumToScss = (rule: LuumScssRule): string => {\n// const {\n// rootSelectors: maybeOneOrManyRootSelectors,\n// root,\n// attributes: oneOrManyAttributes,\n// filter,\n// states: maybeOneOrManyStates,\n// children: maybeOneOrManyChildren,\n// } = rule\n// const rootSelectors = pipe(\n// maybeOneOrManyRootSelectors,\n// each(isString),\n// join(`, ` + LF)\n// )\n// return ``\n// }\n\n// export const luumToScss = (rule: LuumScssRule): string => {\n// const { rootSelector, root, filter, attributes, states, children } = rule\n// let scss = ``\n// const depth = 0\n// if (rootSelector) scss += `${rootSelector} {`\n// return ``\n// }\n",".class {\n display: flex;\n flex-flow: row wrap;\n gap: 4px;\n section {\n display: flex;\n flex-flow: row;\n margin-bottom: 1rem;\n border: 1px solid #ccc;\n padding: 2px;\n margin: 0;\n span {\n display: flex;\n }\n }\n}\n","import type { Join } from \"~/packages/anvl/src/join\"\n\nimport { Id } from \"../react-id\"\nimport type { DataDesigner } from \"./DataDesigner\"\nimport scss from \"./RelationEditor.module.scss\"\n\nexport const RelationEditor: DataDesigner<Join, `Tree`> = (props) => {\n\tconst seen = new Set()\n\tconst data = Object.entries(props.data.relations)\n\t\t.sort(([_, a], [__, b]) => b.length - a.length)\n\t\t.filter(([head, tail]) => {\n\t\t\tif (seen.has(head)) return false\n\t\t\tseen.add(head)\n\t\t\tfor (const tailElement of tail) {\n\t\t\t\tseen.add(tailElement)\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\n\treturn (\n\t\t<article className={scss.class}>\n\t\t\t{/* <span>{props.data.relationType}</span> */}\n\t\t\t{data.map(([head, tail]) => (\n\t\t\t\t<section>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t<Id id={head} />\n\t\t\t\t\t</span>\n\t\t\t\t\t:\n\t\t\t\t\t<span>\n\t\t\t\t\t\t{tail.map((child) => (\n\t\t\t\t\t\t\t<Id id={child} />\n\t\t\t\t\t\t))}\n\t\t\t\t\t</span>\n\t\t\t\t</section>\n\t\t\t))}\n\t\t</article>\n\t)\n}\n","import type { ReadonlySelectorToken, StateToken } from \"atom.io\"\nimport { useI, useO } from \"atom.io/react\"\nimport type { FC } from \"react\"\n\nimport { fallback } from \"~/packages/anvl/src/function\"\nimport { Join } from \"~/packages/anvl/src/join\"\nimport { isJson } from \"~/packages/anvl/src/refinement/refine-json\"\nimport { RelationEditor } from \"~/packages/hamr/src/react-data-designer\"\nimport { ElasticInput } from \"~/packages/hamr/src/react-elastic-input\"\nimport { JsonEditor } from \"~/packages/hamr/src/react-json-editor\"\n\nexport const StateEditor: FC<{\n\ttoken: StateToken<unknown>\n}> = ({ token }) => {\n\tconst set = useI(token)\n\tconst data = useO(token)\n\treturn isJson(data) ? (\n\t\t<JsonEditor data={data} set={set} schema={true} />\n\t) : data instanceof Join ? (\n\t\t<RelationEditor data={data} set={set} />\n\t) : (\n\t\t<div className=\"json_editor\">\n\t\t\t<ElasticInput\n\t\t\t\tvalue={\n\t\t\t\t\tdata instanceof Set\n\t\t\t\t\t\t? `Set { ${JSON.stringify([...data]).slice(1, -1)} }`\n\t\t\t\t\t\t: data instanceof Map\n\t\t\t\t\t\t ? `Map ` + JSON.stringify([...data])\n\t\t\t\t\t\t : Object.getPrototypeOf(data).constructor.name +\n\t\t\t\t\t\t\t ` ` +\n\t\t\t\t\t\t\t fallback(() => JSON.stringify(data), `?`)\n\t\t\t\t}\n\t\t\t\tdisabled={true}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n\nexport const ReadonlySelectorViewer: FC<{\n\ttoken: ReadonlySelectorToken<unknown>\n}> = ({ token }) => {\n\tconst data = useO(token)\n\treturn isJson(data) ? (\n\t\t<JsonEditor\n\t\t\tdata={data}\n\t\t\tset={() => null}\n\t\t\tschema={true}\n\t\t\tisReadonly={() => true}\n\t\t/>\n\t) : (\n\t\t<div className=\"json_editor\">\n\t\t\t<ElasticInput\n\t\t\t\tvalue={\n\t\t\t\t\tdata instanceof Set\n\t\t\t\t\t\t? `Set ` + JSON.stringify([...data])\n\t\t\t\t\t\t: data instanceof Map\n\t\t\t\t\t\t ? `Map ` + JSON.stringify([...data])\n\t\t\t\t\t\t : Object.getPrototypeOf(data).constructor.name +\n\t\t\t\t\t\t\t ` ` +\n\t\t\t\t\t\t\t JSON.stringify(data)\n\t\t\t\t}\n\t\t\t\tdisabled={true}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n\nexport const StoreEditor: FC<{\n\ttoken: ReadonlySelectorToken<unknown> | StateToken<unknown>\n}> = ({ token }) => {\n\tif (token.type === `readonly_selector`) {\n\t\treturn <ReadonlySelectorViewer token={token} />\n\t}\n\treturn <StateEditor token={token} />\n}\n","import type { AtomToken, ReadonlySelectorToken, SelectorToken } from \"atom.io\"\nimport { getState, selectorFamily } from \"atom.io\"\nimport type { FamilyNode, StateTokenIndex } from \"atom.io/introspection\"\nimport { useI, useO } from \"atom.io/react\"\nimport type { FC } from \"react\"\n\nimport { recordToEntries } from \"~/packages/anvl/src/object\"\nimport {\n\tisJson,\n\trefineJsonType,\n} from \"~/packages/anvl/src/refinement/refine-json\"\n\nimport { findViewIsOpenState, primitiveRefinery } from \".\"\nimport { button } from \"./Button\"\nimport { StoreEditor } from \"./StateEditor\"\n\nconst findStateTypeState = selectorFamily<string, { key: string }>({\n\tkey: `ðâðš State Type`,\n\tget:\n\t\t(token) =>\n\t\t({ get }) => {\n\t\t\tlet state: unknown\n\t\t\ttry {\n\t\t\t\tstate = get(token as any)\n\t\t\t} catch (error) {\n\t\t\t\treturn `error`\n\t\t\t}\n\t\t\tif (state === undefined) return `undefined`\n\t\t\tif (isJson(state)) return refineJsonType(state).type\n\t\t\treturn Object.getPrototypeOf(state).constructor.name\n\t\t},\n})\n\nexport const StateIndexLeafNode: FC<{\n\tnode:\n\t\t| AtomToken<unknown>\n\t\t| ReadonlySelectorToken<unknown>\n\t\t| SelectorToken<unknown>\n\tisOpenState: AtomToken<boolean>\n\ttypeState: ReadonlySelectorToken<string>\n}> = ({ node, isOpenState, typeState }) => {\n\tconst setIsOpen = useI(isOpenState)\n\tconst isOpen = useO(isOpenState)\n\n\tconst state = useO(node)\n\tconst stateType = useO(typeState)\n\n\tconst isPrimitive = Boolean(primitiveRefinery.refine(state))\n\n\treturn (\n\t\t<>\n\t\t\t<header>\n\t\t\t\t<button.OpenClose\n\t\t\t\t\tisOpen={isOpen && !isPrimitive}\n\t\t\t\t\tsetIsOpen={setIsOpen}\n\t\t\t\t\tdisabled={isPrimitive}\n\t\t\t\t/>\n\t\t\t\t<label\n\t\t\t\t\tonClick={() => console.log(node, getState(node))}\n\t\t\t\t\tonKeyUp={() => console.log(node, getState(node))}\n\t\t\t\t>\n\t\t\t\t\t<h2>{node.family?.subKey ?? node.key}</h2>\n\t\t\t\t\t<span className=\"type detail\">({stateType})</span>\n\t\t\t\t</label>\n\t\t\t\t{isPrimitive ? <StoreEditor token={node} /> : null}\n\t\t\t</header>\n\t\t\t{isOpen && !isPrimitive ? (\n\t\t\t\t<main>\n\t\t\t\t\t<StoreEditor token={node} />\n\t\t\t\t</main>\n\t\t\t) : null}\n\t\t</>\n\t)\n}\nexport const StateIndexTreeNode: FC<{\n\tnode: FamilyNode<\n\t\tAtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>\n\t>\n\tisOpenState: AtomToken<boolean>\n}> = ({ node, isOpenState }) => {\n\tconst setIsOpen = useI(isOpenState)\n\tconst isOpen = useO(isOpenState)\n\tfor (const [key, childNode] of recordToEntries(node.familyMembers)) {\n\t\tfindViewIsOpenState(key)\n\t\tfindStateTypeState(childNode)\n\t}\n\treturn (\n\t\t<>\n\t\t\t<header>\n\t\t\t\t<button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />\n\t\t\t\t<label>\n\t\t\t\t\t<h2>{node.key}</h2>\n\t\t\t\t\t<span className=\"type detail\"> (family)</span>\n\t\t\t\t</label>\n\t\t\t</header>\n\t\t\t{isOpen\n\t\t\t\t? Object.entries(node.familyMembers).map(([key, childNode]) => (\n\t\t\t\t\t\t<StateIndexNode\n\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\tnode={childNode}\n\t\t\t\t\t\t\tisOpenState={findViewIsOpenState(childNode.key)}\n\t\t\t\t\t\t\ttypeState={findStateTypeState(childNode)}\n\t\t\t\t\t\t/>\n\t\t\t\t ))\n\t\t\t\t: null}\n\t\t</>\n\t)\n}\n\nexport const StateIndexNode: FC<{\n\tnode: StateTokenIndex<\n\t\tAtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>\n\t>[string]\n\tisOpenState: AtomToken<boolean>\n\ttypeState: ReadonlySelectorToken<string>\n}> = ({ node, isOpenState, typeState }) => {\n\tif (node.key.startsWith(`ðâðš`)) {\n\t\treturn null\n\t}\n\treturn (\n\t\t<section className=\"node state\">\n\t\t\t{`type` in node ? (\n\t\t\t\t<StateIndexLeafNode\n\t\t\t\t\tnode={node}\n\t\t\t\t\tisOpenState={isOpenState}\n\t\t\t\t\ttypeState={typeState}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<StateIndexTreeNode node={node} isOpenState={isOpenState} />\n\t\t\t)}\n\t\t</section>\n\t)\n}\n\nexport const StateIndex: FC<{\n\ttokenIndex: ReadonlySelectorToken<\n\t\tStateTokenIndex<\n\t\t\t| AtomToken<unknown>\n\t\t\t| ReadonlySelectorToken<unknown>\n\t\t\t| SelectorToken<unknown>\n\t\t>\n\t>\n}> = ({ tokenIndex }) => {\n\tconst tokenIds = useO(tokenIndex)\n\treturn (\n\t\t<article className=\"index state_index\">\n\t\t\t{Object.entries(tokenIds)\n\t\t\t\t.filter(([key]) => !key.startsWith(`ðâðš`))\n\t\t\t\t.sort()\n\t\t\t\t.map(([key, node]) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<StateIndexNode\n\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\tnode={node}\n\t\t\t\t\t\t\tisOpenState={findViewIsOpenState(node.key)}\n\t\t\t\t\t\t\ttypeState={findStateTypeState(node)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t</article>\n\t)\n}\n","import type { AtomToken, ReadonlySelectorToken, TimelineToken } from \"atom.io\"\nimport { redo, undo } from \"atom.io\"\nimport type { Timeline } from \"atom.io/internal\"\nimport { useI, useO } from \"atom.io/react\"\nimport { type FC, Fragment } from \"react\"\n\nimport { findTimelineState, findViewIsOpenState, timelineIndex } from \".\"\nimport { button } from \"./Button\"\nimport { article } from \"./Updates\"\n\nexport const YouAreHere: FC = () => {\n\treturn <span className=\"you_are_here\">you are here</span>\n}\n\nexport const TimelineLog: FC<{\n\ttoken: TimelineToken\n\tisOpenState: AtomToken<boolean>\n\ttimelineState: ReadonlySelectorToken<Timeline>\n}> = ({ token, isOpenState, timelineState }) => {\n\tconst timeline = useO(timelineState)\n\tconst isOpen = useO(isOpenState)\n\tconst setIsOpen = useI(isOpenState)\n\n\treturn (\n\t\t<section className=\"node timeline_log\">\n\t\t\t<header>\n\t\t\t\t<button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />\n\t\t\t\t<label>\n\t\t\t\t\t<h2>{token.key}</h2>\n\t\t\t\t\t<span className=\"detail length\">\n\t\t\t\t\t\t({timeline.at}/{timeline.history.length})\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"gap\" />\n\t\t\t\t\t<nav>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tonClick={() => undo(token)}\n\t\t\t\t\t\t\tdisabled={timeline.at === 0}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tundo\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tonClick={() => redo(token)}\n\t\t\t\t\t\t\tdisabled={timeline.at === timeline.history.length}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tredo\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</nav>\n\t\t\t\t</label>\n\t\t\t</header>\n\t\t\t{isOpen ? (\n\t\t\t\t<main>\n\t\t\t\t\t{timeline.history.map((update, index) => (\n\t\t\t\t\t\t<Fragment key={update.key + index + timeline.at}>\n\t\t\t\t\t\t\t{index === timeline.at ? <YouAreHere /> : null}\n\t\t\t\t\t\t\t<article.TimelineUpdate timelineUpdate={update} />\n\t\t\t\t\t\t\t{index === timeline.history.length - 1 &&\n\t\t\t\t\t\t\ttimeline.at === timeline.history.length ? (\n\t\t\t\t\t\t\t\t<YouAreHere />\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t))}\n\t\t\t\t</main>\n\t\t\t) : null}\n\t\t</section>\n\t)\n}\n\nexport const TimelineIndex: FC = () => {\n\tconst tokenIds = useO(timelineIndex)\n\treturn (\n\t\t<article className=\"index timeline_index\">\n\t\t\t{tokenIds\n\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t.map((token) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TimelineLog\n\t\t\t\t\t\t\tkey={token.key}\n\t\t\t\t\t\t\ttoken={token}\n\t\t\t\t\t\t\tisOpenState={findViewIsOpenState(token.key)}\n\t\t\t\t\t\t\ttimelineState={findTimelineState(token.key)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t</article>\n\t)\n}\n","import type {\n\tKeyedStateUpdate,\n\tTimelineUpdate,\n\tTransactionUpdate,\n\tÆn,\n} from \"atom.io\"\nimport * as React from \"react\"\n\nimport { discoverType } from \"~/packages/anvl/src/refinement/refinery\"\n\nimport { prettyJson } from \".\"\n\nconst AtomUpdateFC: React.FC<{\n\tserialNumber: number\n\tatomUpdate: KeyedStateUpdate<unknown>\n}> = ({ atomUpdate }) => {\n\treturn (\n\t\t<article\n\t\t\tkey={atomUpdate.key}\n\t\t\tclassName=\"node atom_update\"\n\t\t\tonClick={() => console.log(atomUpdate)}\n\t\t\tonKeyUp={() => console.log(atomUpdate)}\n\t\t>\n\t\t\t<span className=\"detail\">{atomUpdate.key}: </span>\n\t\t\t<span>\n\t\t\t\t<span className=\"summary\">\n\t\t\t\t\t{prettyJson.diff(atomUpdate.oldValue, atomUpdate.newValue).summary}\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</article>\n\t)\n}\n\nconst TransactionUpdateFC: React.FC<{\n\tserialNumber: number\n\ttransactionUpdate: TransactionUpdate<Æn>\n}> = ({ serialNumber, transactionUpdate }) => {\n\treturn (\n\t\t<article className=\"node transaction_update\">\n\t\t\t<header>\n\t\t\t\t<h4>{serialNumber}</h4>\n\t\t\t</header>\n\t\t\t<main>\n\t\t\t\t<section className=\"transaction_params\">\n\t\t\t\t\t<span className=\"detail\">params: </span>\n\t\t\t\t\t{transactionUpdate.params.map((param, index) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<article\n\t\t\t\t\t\t\t\tkey={`param` + index}\n\t\t\t\t\t\t\t\tclassName=\"node transaction_param\"\n\t\t\t\t\t\t\t\tonClick={() => console.log(transactionUpdate)}\n\t\t\t\t\t\t\t\tonKeyUp={() => console.log(transactionUpdate)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span className=\"detail\">{discoverType(param)}: </span>\n\t\t\t\t\t\t\t\t<span className=\"summary\">\n\t\t\t\t\t\t\t\t\t{typeof param === `object` &&\n\t\t\t\t\t\t\t\t\tparam !== null &&\n\t\t\t\t\t\t\t\t\t`type` in param &&\n\t\t\t\t\t\t\t\t\t`target` in param ? (\n\t\t\t\t\t\t\t\t\t\t<>{JSON.stringify(param.type)}</>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<>{JSON.stringify(param)}</>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</article>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</section>\n\t\t\t\t<section className=\"node transaction_output\">\n\t\t\t\t\t<span className=\"detail\">output: </span>\n\t\t\t\t\t<span className=\"detail\">\n\t\t\t\t\t\t{discoverType(transactionUpdate.output)}\n\t\t\t\t\t</span>\n\t\t\t\t\t{transactionUpdate.output ? (\n\t\t\t\t\t\t<span className=\"summary\">\n\t\t\t\t\t\t\t: {JSON.stringify(transactionUpdate.output)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null}\n\t\t\t\t</section>\n\t\t\t\t<section className=\"transaction_impact\">\n\t\t\t\t\t<span className=\"detail\">impact: </span>\n\t\t\t\t\t{transactionUpdate.updates\n\t\t\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t\t\t.map((update, index) => {\n\t\t\t\t\t\t\treturn `newValue` in update ? (\n\t\t\t\t\t\t\t\t<article.AtomUpdate\n\t\t\t\t\t\t\t\t\tkey={`${transactionUpdate.key}:${index}:${update.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\tatomUpdate={update}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<TransactionUpdateFC\n\t\t\t\t\t\t\t\t\tkey={`${transactionUpdate.key}:${index}:${update.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\ttransactionUpdate={update}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})}\n\t\t\t\t</section>\n\t\t\t</main>\n\t\t</article>\n\t)\n}\n\nexport const TimelineUpdateFC: React.FC<{\n\ttimelineUpdate: TimelineUpdate\n}> = ({ timelineUpdate }) => {\n\treturn (\n\t\t<article className=\"node timeline_update\">\n\t\t\t<header>\n\t\t\t\t<h4>\n\t\t\t\t\t{timelineUpdate.timestamp}: {timelineUpdate.type} ({timelineUpdate.key}\n\t\t\t\t\t)\n\t\t\t\t</h4>\n\t\t\t</header>\n\t\t\t<main>\n\t\t\t\t{timelineUpdate.type === `transaction_update` ? (\n\t\t\t\t\ttimelineUpdate.updates\n\t\t\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t\t\t.map((update, index) => {\n\t\t\t\t\t\t\treturn `newValue` in update ? (\n\t\t\t\t\t\t\t\t<article.AtomUpdate\n\t\t\t\t\t\t\t\t\tkey={`${timelineUpdate.key}:${index}:${update.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\tatomUpdate={update}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<TransactionUpdateFC\n\t\t\t\t\t\t\t\t\tkey={`${timelineUpdate.key}:${index}:${update.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\ttransactionUpdate={update}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})\n\t\t\t\t) : timelineUpdate.type === `selector_update` ? (\n\t\t\t\t\ttimelineUpdate.atomUpdates\n\t\t\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t\t\t.map((atomUpdate, index) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<article.AtomUpdate\n\t\t\t\t\t\t\t\t\tkey={`${timelineUpdate.key}:${index}:${atomUpdate.key}`}\n\t\t\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\t\t\tatomUpdate={atomUpdate}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})\n\t\t\t\t) : timelineUpdate.type === `atom_update` ? (\n\t\t\t\t\t<article.AtomUpdate\n\t\t\t\t\t\tserialNumber={timelineUpdate.timestamp}\n\t\t\t\t\t\tatomUpdate={timelineUpdate}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</main>\n\t\t</article>\n\t)\n}\n\nexport const article = {\n\tAtomUpdate: AtomUpdateFC,\n\tTransactionUpdate: TransactionUpdateFC,\n\tTimelineUpdate: TimelineUpdateFC,\n}\n","import type {\n\tAtomToken,\n\tReadonlySelectorToken,\n\tTransactionToken,\n\tTransactionUpdate,\n\tÆn,\n} from \"atom.io\"\nimport { useI, useO } from \"atom.io/react\"\nimport type { FC } from \"react\"\n\nimport {\n\tfindTransactionLogState,\n\tfindViewIsOpenState,\n\ttransactionIndex,\n} from \".\"\nimport { button } from \"./Button\"\nimport { article } from \"./Updates\"\n\nexport const TransactionLog: FC<{\n\ttoken: TransactionToken<Æn>\n\tisOpenState: AtomToken<boolean>\n\tlogState: ReadonlySelectorToken<TransactionUpdate<Æn>[]>\n}> = ({ token, isOpenState, logState }) => {\n\tconst log = useO(logState)\n\tconst isOpen = useO(isOpenState)\n\tconst setIsOpen = useI(isOpenState)\n\n\treturn (\n\t\t<section className=\"node transaction_log\">\n\t\t\t<header>\n\t\t\t\t<button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />\n\t\t\t\t<label>\n\t\t\t\t\t<h2>{token.key}</h2>\n\t\t\t\t\t<span className=\"detail length\">({log.length})</span>\n\t\t\t\t</label>\n\t\t\t</header>\n\t\t\t{isOpen ? (\n\t\t\t\t<main>\n\t\t\t\t\t{log.map((update, index) => (\n\t\t\t\t\t\t<article.TransactionUpdate\n\t\t\t\t\t\t\tkey={update.key + index}\n\t\t\t\t\t\t\tserialNumber={index}\n\t\t\t\t\t\t\ttransactionUpdate={update}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</main>\n\t\t\t) : null}\n\t\t</section>\n\t)\n}\n\nexport const TransactionIndex: FC = () => {\n\tconst tokenIds = useO(transactionIndex)\n\treturn (\n\t\t<article className=\"index transaction_index\">\n\t\t\t{tokenIds\n\t\t\t\t.filter((token) => !token.key.startsWith(`ðâðš`))\n\t\t\t\t.map((token) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TransactionLog\n\t\t\t\t\t\t\tkey={token.key}\n\t\t\t\t\t\t\ttoken={token}\n\t\t\t\t\t\t\tisOpenState={findViewIsOpenState(token.key)}\n\t\t\t\t\t\t\tlogState={findTransactionLogState(token.key)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t</article>\n\t)\n}\n","import { atom, atomFamily } from \"atom.io\"\nimport { attachIntrospectionStates } from \"atom.io/introspection\"\nimport { lazyLocalStorageEffect } from \"~/packages/atom.io/__unstable__/web-effects/src\"\n\nimport { isPlainObject } from \"~/packages/anvl/src/object\"\nimport { Refinery } from \"~/packages/anvl/src/refinement/refinery\"\nimport {\n\tDiffer,\n\tdiffArray,\n\tdiffBoolean,\n\tdiffNumber,\n\tdiffObject,\n\tdiffString,\n} from \"~/packages/anvl/src/tree/differ\"\n\nexport * from \"./AtomIODevtools\"\n\nexport const {\n\tatomIndex,\n\tselectorIndex,\n\ttransactionIndex,\n\tfindTransactionLogState,\n\ttimelineIndex,\n\tfindTimelineState,\n} = attachIntrospectionStates()\n\nexport const devtoolsAreOpenState = atom<boolean>({\n\tkey: `ðâðš Devtools Are Open`,\n\tdefault: true,\n\teffects: [lazyLocalStorageEffect(`ðâðš Devtools Are Open`)],\n})\n\ntype DevtoolsView = `atoms` | `selectors` | `timelines` | `transactions`\n\nexport const devtoolsViewSelectionState = atom<DevtoolsView>({\n\tkey: `ðâðš Devtools View Selection`,\n\tdefault: `atoms`,\n\teffects: [lazyLocalStorageEffect(`ðâðš Devtools View`)],\n})\n\nexport const devtoolsViewOptionsState = atom<DevtoolsView[]>({\n\tkey: `ðâðš Devtools View Options`,\n\tdefault: [`atoms`, `selectors`, `transactions`, `timelines`],\n\teffects: [lazyLocalStorageEffect(`ðâðš Devtools View Options`)],\n})\n\nexport const findViewIsOpenState = atomFamily<boolean, string>({\n\tkey: `ðâðš Devtools View Is Open`,\n\tdefault: false,\n\teffects: (key) => [lazyLocalStorageEffect(key + `:view-is-open`)],\n})\n\nexport const primitiveRefinery = new Refinery({\n\tnumber: (input: unknown): input is number => typeof input === `number`,\n\tstring: (input: unknown): input is string => typeof input === `string`,\n\tboolean: (input: unknown): input is boolean => typeof input === `boolean`,\n\tnull: (input: unknown): input is null => input === null,\n})\n\nexport const jsonTreeRefinery = new Refinery({\n\tobject: isPlainObject,\n\tarray: (input: unknown): input is unknown[] => Array.isArray(input),\n})\n\nexport const prettyJson = new Differ(primitiveRefinery, jsonTreeRefinery, {\n\tnumber: diffNumber,\n\tstring: diffString,\n\tboolean: diffBoolean,\n\tnull: () => ({ summary: `No Change` }),\n\tobject: diffObject,\n\tarray: diffArray,\n})\n"]}
|