atom.io 0.16.3 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/data/dist/index.cjs +62 -40
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.ts +8 -2
  4. package/data/dist/index.js +64 -42
  5. package/data/dist/index.js.map +1 -1
  6. package/data/src/dict.ts +8 -4
  7. package/data/src/join.ts +74 -33
  8. package/data/src/struct-family.ts +18 -17
  9. package/dist/chunk-OEVFAUPE.js +289 -0
  10. package/dist/chunk-OEVFAUPE.js.map +1 -0
  11. package/dist/index.cjs +36 -57
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts +64 -53
  14. package/dist/index.js +15 -36
  15. package/dist/index.js.map +1 -1
  16. package/internal/dist/index.cjs +211 -81
  17. package/internal/dist/index.cjs.map +1 -1
  18. package/internal/dist/index.d.ts +100 -72
  19. package/internal/dist/index.js +200 -75
  20. package/internal/dist/index.js.map +1 -1
  21. package/internal/src/arbitrary.ts +3 -0
  22. package/internal/src/atom/create-regular-atom.ts +2 -3
  23. package/internal/src/caching.ts +8 -6
  24. package/internal/src/families/find-in-store.ts +16 -0
  25. package/internal/src/get-environment-data.ts +4 -7
  26. package/internal/src/get-state/get-from-store.ts +14 -0
  27. package/internal/src/get-state/index.ts +2 -0
  28. package/internal/src/{read-or-compute-value.ts → get-state/read-or-compute-value.ts} +3 -3
  29. package/internal/src/index.ts +7 -6
  30. package/internal/src/ingest-updates/ingest-atom-update.ts +2 -2
  31. package/internal/src/ingest-updates/ingest-transaction-update.ts +0 -1
  32. package/internal/src/mutable/create-mutable-atom.ts +3 -4
  33. package/internal/src/mutable/tracker.ts +18 -13
  34. package/internal/src/selector/create-standalone-selector.ts +0 -2
  35. package/internal/src/selector/register-selector.ts +1 -1
  36. package/internal/src/set-state/index.ts +1 -0
  37. package/internal/src/set-state/set-atom.ts +15 -19
  38. package/internal/src/set-state/set-into-store.ts +24 -0
  39. package/internal/src/store/store.ts +14 -2
  40. package/internal/src/store/withdraw.ts +72 -2
  41. package/internal/src/subscribe/subscribe-to-root-atoms.ts +1 -1
  42. package/internal/src/subscribe/subscribe-to-timeline.ts +2 -2
  43. package/internal/src/subscribe/subscribe-to-transaction.ts +2 -2
  44. package/internal/src/timeline/create-timeline.ts +12 -1
  45. package/internal/src/transaction/act-upon-store.ts +19 -0
  46. package/internal/src/transaction/apply-transaction.ts +7 -1
  47. package/internal/src/transaction/assign-transaction-to-continuity.ts +18 -0
  48. package/internal/src/transaction/build-transaction.ts +11 -8
  49. package/internal/src/transaction/create-transaction.ts +1 -1
  50. package/internal/src/transaction/get-epoch-number.ts +40 -0
  51. package/internal/src/transaction/index.ts +10 -1
  52. package/internal/src/transaction/set-epoch-number.ts +31 -0
  53. package/introspection/dist/index.cjs.map +1 -1
  54. package/introspection/dist/index.d.ts +3 -3
  55. package/introspection/dist/index.js.map +1 -1
  56. package/introspection/src/attach-introspection-states.ts +6 -2
  57. package/introspection/src/attach-timeline-family.ts +5 -2
  58. package/introspection/src/attach-transaction-logs.ts +2 -2
  59. package/json/dist/index.d.ts +3 -1
  60. package/json/src/index.ts +6 -2
  61. package/package.json +24 -13
  62. package/react/dist/index.cjs +3 -3
  63. package/react/dist/index.cjs.map +1 -1
  64. package/react/dist/index.d.ts +1 -1
  65. package/react/dist/index.js +5 -5
  66. package/react/dist/index.js.map +1 -1
  67. package/react/src/use-i.ts +2 -3
  68. package/react/src/use-json.ts +1 -1
  69. package/react/src/use-o.ts +3 -4
  70. package/react-devtools/dist/index.cjs +131 -134
  71. package/react-devtools/dist/index.cjs.map +1 -1
  72. package/react-devtools/dist/index.css +2 -2
  73. package/react-devtools/dist/index.css.map +1 -1
  74. package/react-devtools/dist/index.d.ts +3 -3
  75. package/react-devtools/dist/index.js +103 -106
  76. package/react-devtools/dist/index.js.map +1 -1
  77. package/react-devtools/src/StateEditor.tsx +6 -6
  78. package/react-devtools/src/StateIndex.tsx +2 -5
  79. package/react-devtools/src/TimelineIndex.tsx +3 -3
  80. package/react-devtools/src/TransactionIndex.tsx +9 -8
  81. package/react-devtools/src/Updates.tsx +1 -1
  82. package/react-devtools/src/index.ts +4 -4
  83. package/realtime/dist/index.cjs +72 -0
  84. package/realtime/dist/index.cjs.map +1 -0
  85. package/realtime/dist/index.d.ts +39 -0
  86. package/realtime/dist/index.js +68 -0
  87. package/realtime/dist/index.js.map +1 -0
  88. package/realtime/package.json +16 -0
  89. package/realtime/src/index.ts +1 -0
  90. package/realtime/src/realtime-continuity.ts +152 -0
  91. package/realtime-client/dist/index.cjs +403 -59
  92. package/realtime-client/dist/index.cjs.map +1 -1
  93. package/realtime-client/dist/index.d.ts +16 -9
  94. package/realtime-client/dist/index.js +114 -48
  95. package/realtime-client/dist/index.js.map +1 -1
  96. package/realtime-client/src/index.ts +8 -5
  97. package/realtime-client/src/{pull-family-member.ts → pull-atom-family-member.ts} +5 -5
  98. package/realtime-client/src/{pull-state.ts → pull-atom.ts} +5 -5
  99. package/realtime-client/src/{pull-mutable-family-member.ts → pull-mutable-atom-family-member.ts} +5 -5
  100. package/realtime-client/src/{pull-mutable.ts → pull-mutable-atom.ts} +5 -5
  101. package/realtime-client/src/pull-selector-family-member.ts +42 -0
  102. package/realtime-client/src/pull-selector.ts +38 -0
  103. package/realtime-client/src/realtime-client-stores/client-main-store.ts +2 -2
  104. package/realtime-client/src/realtime-client-stores/client-sync-store.ts +7 -7
  105. package/realtime-client/src/sync-continuity.ts +321 -0
  106. package/realtime-client/src/sync-server-action.ts +22 -21
  107. package/realtime-client/src/sync-state.ts +3 -3
  108. package/realtime-react/dist/index.cjs +330 -15
  109. package/realtime-react/dist/index.cjs.map +1 -1
  110. package/realtime-react/dist/index.d.ts +26 -6
  111. package/realtime-react/dist/index.js +43 -12
  112. package/realtime-react/dist/index.js.map +1 -1
  113. package/realtime-react/src/index.ts +6 -3
  114. package/realtime-react/src/use-pull-atom-family-member.ts +21 -0
  115. package/realtime-react/src/{use-pull.ts → use-pull-atom.ts} +6 -5
  116. package/realtime-react/src/{use-pull-mutable.ts → use-pull-mutable-atom.ts} +4 -3
  117. package/realtime-react/src/use-pull-mutable-family-member.ts +9 -4
  118. package/realtime-react/src/use-pull-selector-family-member.ts +21 -0
  119. package/realtime-react/src/{use-pull-family-member.ts → use-pull-selector.ts} +7 -5
  120. package/realtime-react/src/use-push.ts +3 -2
  121. package/realtime-react/src/use-server-action.ts +3 -2
  122. package/realtime-react/src/use-sync-continuity.ts +12 -0
  123. package/realtime-react/src/use-sync-server-action.ts +3 -2
  124. package/realtime-server/dist/index.cjs +582 -256
  125. package/realtime-server/dist/index.cjs.map +1 -1
  126. package/realtime-server/dist/index.d.ts +124 -49
  127. package/realtime-server/dist/index.js +566 -249
  128. package/realtime-server/dist/index.js.map +1 -1
  129. package/realtime-server/src/index.ts +18 -2
  130. package/realtime-server/src/ipc-socket.ts +230 -0
  131. package/realtime-server/src/realtime-action-receiver.ts +8 -5
  132. package/realtime-server/src/realtime-action-synchronizer.ts +53 -35
  133. package/realtime-server/src/realtime-continuity-synchronizer.ts +247 -0
  134. package/realtime-server/src/realtime-family-provider.ts +37 -73
  135. package/realtime-server/src/realtime-mutable-family-provider.ts +26 -87
  136. package/realtime-server/src/realtime-mutable-provider.ts +3 -2
  137. package/realtime-server/src/realtime-server-stores/index.ts +3 -1
  138. package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +90 -0
  139. package/realtime-server/src/realtime-server-stores/server-room-store.ts +97 -0
  140. package/realtime-server/src/realtime-server-stores/server-sync-store.ts +2 -72
  141. package/realtime-server/src/realtime-server-stores/server-user-store.ts +14 -29
  142. package/realtime-server/src/realtime-state-provider.ts +3 -3
  143. package/realtime-server/src/realtime-state-receiver.ts +2 -3
  144. package/realtime-server/src/realtime-state-synchronizer.ts +3 -3
  145. package/realtime-testing/dist/index.cjs +28 -28
  146. package/realtime-testing/dist/index.cjs.map +1 -1
  147. package/realtime-testing/dist/index.js +28 -27
  148. package/realtime-testing/dist/index.js.map +1 -1
  149. package/realtime-testing/src/setup-realtime-test.tsx +38 -28
  150. package/src/atom.ts +49 -31
  151. package/src/get-state.ts +2 -11
  152. package/src/logger.ts +10 -5
  153. package/src/selector.ts +44 -25
  154. package/src/set-state.ts +1 -13
  155. package/src/silo.ts +7 -3
  156. package/src/subscribe.ts +2 -1
  157. package/src/timeline.ts +4 -4
  158. package/src/transaction.ts +13 -17
  159. package/src/validators.ts +15 -9
  160. package/dist/chunk-H4Q5FTPZ.js +0 -11
  161. package/dist/chunk-H4Q5FTPZ.js.map +0 -1
  162. package/internal/src/set-state/copy-mutable-in-transaction.ts +0 -19
@@ -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;AAAA,IACD;AACA,YAAQ,QAAQ,KAAK,UAAU,QAAQ,CAAC;AAAA,EACzC,CAAC;AACF;AAEM,IAAM,yBAEQ,YAAY,YAAY,EAAE,IAAI;;;AC+N5C,SAAS,KACfA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACU;AAEV,UAAQ,UAAU,QAAQ;AAAA,IACzB,KAAK;AACJ,aAAOA;AAAA,IACR,KAAK;AAEJ,aAAO,GAAIA,EAAC;AAAA,IACb,KAAK;AAEJ,aAAO,GAAI,GAAIA,EAAC,CAAC;AAAA,IAClB,KAAK;AAEJ,aAAO,GAAI,GAAI,GAAIA,EAAC,CAAC,CAAC;AAAA,IACvB,KAAK;AAEJ,aAAO,GAAI,GAAI,GAAI,GAAIA,EAAC,CAAC,CAAC,CAAC;AAAA,IAC5B,KAAK;AAEJ,aAAO,GAAI,GAAI,GAAI,GAAI,GAAIA,EAA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;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,IAAI,0BAA0B;AAEvB,IAAM,uBAAuB,KAAc;AAAA,EACjD,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS,CAAC,uBAAuB,4CAAyB,CAAC;AAC5D,CAAC;AAIM,IAAM,6BAA6B,KAAmB;AAAA,EAC5D,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS,CAAC,uBAAuB,wCAAqB,CAAC;AACxD,CAAC;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":["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 {\n\tReadonlySelectorToken,\n\tRegularAtomToken,\n\tWritableSelectorToken,\n} from \"atom.io\"\nimport { getState, selectorFamily } from \"atom.io\"\nimport type { FamilyNode, WritableTokenIndex } 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| ReadonlySelectorToken<unknown>\n\t\t| RegularAtomToken<unknown>\n\t\t| WritableSelectorToken<unknown>\n\tisOpenState: RegularAtomToken<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\t| ReadonlySelectorToken<unknown>\n\t\t| RegularAtomToken<unknown>\n\t\t| WritableSelectorToken<unknown>\n\t>\n\tisOpenState: RegularAtomToken<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: WritableTokenIndex<\n\t\t| ReadonlySelectorToken<unknown>\n\t\t| RegularAtomToken<unknown>\n\t\t| WritableSelectorToken<unknown>\n\t>[string]\n\tisOpenState: RegularAtomToken<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\tWritableTokenIndex<\n\t\t\t| ReadonlySelectorToken<unknown>\n\t\t\t| RegularAtomToken<unknown>\n\t\t\t| WritableSelectorToken<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, WritableToken } 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: WritableToken<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> | WritableToken<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 {\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 { 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\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\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>\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 { 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\tautoSize?: boolean\n\treadOnly?: boolean\n}\n\nexport const TextInput: FC<TextInputProps> = ({\n\tvalue,\n\tset,\n\tlabel,\n\tplaceholder,\n\tautoSize = false,\n}) => {\n\treturn (\n\t\t<span>\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 { CSSProperties, 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\tstyle?: CSSProperties | 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\tstyle,\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} style={style}>\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>(\n\tinput: R,\n): {\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 { CSSProperties, 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\tstyle?: CSSProperties | 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, className }) => (\n\t\t<div className={`json_editor` + ` ` + className ?? ``}>{children}</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 { CSSProperties, FC, ReactElement } 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\tstyle?: CSSProperties\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\tHeader,\n\tstyle,\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\tHeader={Header}\n\t\t\tstyle={style}\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\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\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 {\n\tReadonlySelectorToken,\n\tRegularAtomToken,\n\tTimelineToken,\n} 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<any>\n\tisOpenState: RegularAtomToken<boolean>\n\ttimelineState: ReadonlySelectorToken<Timeline<any>>\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<any>\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\tReadonlySelectorToken,\n\tRegularAtomToken,\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: RegularAtomToken<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":["../src/index.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/json/index.ts","../../../anvl/src/primitive/index.ts","../../../anvl/src/refinement/refine-json.ts","../../../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/tree/differ.ts","../../__unstable__/web-effects/src/storage.ts","../src/AtomIODevtools.tsx","../src/StateIndex.tsx","../src/Button.tsx","../src/StateEditor.tsx","../../../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/react-elastic-input/src/ElasticInput.tsx","../../../hamr/react-elastic-input/src/NumberInput.tsx","../../../anvl/src/number/clamp.ts","../../../anvl/src/number/wrap.ts","../../../hamr/react-elastic-input/src/TextInput.tsx","../../../hamr/react-json-editor/src/editors-by-type/non-json.tsx","../../../hamr/react-json-editor/src/json-editor-internal.tsx","../../../hamr/react-json-editor/src/editors-by-type/utilities/array-elements.ts","../../../hamr/react-json-editor/src/editors-by-type/array-editor.tsx","../../../hamr/react-json-editor/src/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/react-json-editor/src/editors-by-type/utilities/object-properties.ts","../../../hamr/react-json-editor/src/editors-by-type/primitive-editors.tsx","../../../hamr/react-error-boundary/src/ReactErrorBoundary.tsx","../../../hamr/react-error-boundary/src/DefaultFallback.tsx","../../../hamr/react-json-editor/src/default-components.tsx","../../../hamr/react-json-editor/src/developer-interface.tsx","../../../hamr/react-json-editor/src/index.ts","../../../hamr/react-data-designer/src/DataDesigner.tsx","../../../hamr/react-id/src/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/react-data-designer/src/RelationEditor.tsx","../src/TimelineIndex.tsx","../src/Updates.tsx","../src/TransactionIndex.tsx"],"names":["a","path","node","result","e","_a","isJson","b","useI","useO","useRef","isOpen","join","map","id","jsx","useState","jsxs","refMap","_","Fragment","round","findState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,MAAM,kBAAkB;AACjC,SAAS,iCAAiC;;;AC0PnC,SAAS,KACfA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACU;AAEV,UAAQ,UAAU,QAAQ;AAAA,IACzB,KAAK;AACJ,aAAOA;AAAA,IACR,KAAK;AAEJ,aAAO,GAAIA,EAAC;AAAA,IACb,KAAK;AAEJ,aAAO,GAAI,GAAIA,EAAC,CAAC;AAAA,IAClB,KAAK;AAEJ,aAAO,GAAI,GAAI,GAAIA,EAAC,CAAC,CAAC;AAAA,IACvB,KAAK;AAEJ,aAAO,GAAI,GAAI,GAAI,GAAIA,EAAC,CAAC,CAAC,CAAC;AAAA,IAC5B,KAAK;AAEJ,aAAO,GAAI,GAAI,GAAI,GAAI,GAAIA,EAAC,CAAC,CAAC,CAAC,CAAC;AAAA,IACjC,KAAK;AAEJ,aAAO,GAAI,GAAI,GAAI,GAAI,GAAI,GAAIA,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAAA,IACtC,KAAK;AAEJ,aAAO,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAIA,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAAA,IAC3C,KAAK;AAEJ,aAAO,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAIA,EAAC,CAAC,CAA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E,SAAS,YAAY;AAAA,EACpC,QAAQ;AAAA,EACR,OAAO;AACR,CAAC","sourcesContent":["import { atom, atomFamily } from \"atom.io\"\nimport { attachIntrospectionStates } from \"atom.io/introspection\"\n\nimport { isPlainObject } from \"anvl/object\"\nimport { Refinery } from \"anvl/refinement\"\nimport {\n\tDiffer,\n\tdiffArray,\n\tdiffBoolean,\n\tdiffNumber,\n\tdiffObject,\n\tdiffString,\n} from \"anvl/tree/differ\"\nimport { lazyLocalStorageEffect } from \"~/packages/atom.io/__unstable__/web-effects/src\"\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","/* ❤️ 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","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","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\"\nexport * from \"./refine-json\"\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 { 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 { 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","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 {\n\tReadonlySelectorToken,\n\tRegularAtomToken,\n\tWritableSelectorToken,\n} from \"atom.io\"\nimport { getState, selectorFamily } from \"atom.io\"\nimport type { FamilyNode, WritableTokenIndex } from \"atom.io/introspection\"\nimport { useI, useO } from \"atom.io/react\"\nimport type { FC } from \"react\"\n\nimport { recordToEntries } from \"anvl/object\"\nimport { isJson, refineJsonType } from \"anvl/refinement\"\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| ReadonlySelectorToken<unknown>\n\t\t| RegularAtomToken<unknown>\n\t\t| WritableSelectorToken<unknown>\n\tisOpenState: RegularAtomToken<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\t| ReadonlySelectorToken<unknown>\n\t\t| RegularAtomToken<unknown>\n\t\t| WritableSelectorToken<unknown>\n\t>\n\tisOpenState: RegularAtomToken<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: WritableTokenIndex<\n\t\t| ReadonlySelectorToken<unknown>\n\t\t| RegularAtomToken<unknown>\n\t\t| WritableSelectorToken<unknown>\n\t>[string]\n\tisOpenState: RegularAtomToken<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\tWritableTokenIndex<\n\t\t\t| ReadonlySelectorToken<unknown>\n\t\t\t| RegularAtomToken<unknown>\n\t\t\t| WritableSelectorToken<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 { 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, WritableToken } from \"atom.io\"\nimport { useI, useO } from \"atom.io/react\"\nimport type { FC } from \"react\"\n\nimport { fallback } from \"anvl/function\"\nimport { Join } from \"anvl/join\"\nimport { isJson } from \"anvl/refinement\"\nimport { RelationEditor } from \"hamr/react-data-designer\"\nimport { ElasticInput } from \"hamr/react-elastic-input\"\nimport { JsonEditor } from \"hamr/react-json-editor\"\n\nexport const StateEditor: FC<{\n\ttoken: WritableToken<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> | WritableToken<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 { 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 { 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\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\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>\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 { 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\tautoSize?: boolean\n\treadOnly?: boolean\n}\n\nexport const TextInput: FC<TextInputProps> = ({\n\tvalue,\n\tset,\n\tlabel,\n\tplaceholder,\n\tautoSize = false,\n}) => {\n\treturn (\n\t\t<span>\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 \"hamr/react-elastic-input\"\n\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 { ElasticInput } from \"hamr/react-elastic-input\"\n\nimport type { CSSProperties, 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 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\tstyle?: CSSProperties | 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\tstyle,\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} style={style}>\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 { ElasticInput } from \"hamr/react-elastic-input\"\n\nimport { 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 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>(\n\tinput: R,\n): {\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 { NumberInput, TextInput } from \"hamr/react-elastic-input\"\n\nimport type { ReactElement } from \"react\"\n\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 { ErrorBoundary } from \"hamr/react-error-boundary\"\n\nimport type { CSSProperties, FC, ReactNode } from \"react\"\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\tstyle?: CSSProperties | 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, className }) => (\n\t\t<div className={`json_editor` + ` ` + className ?? ``}>{children}</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 { CSSProperties, FC, ReactElement } 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\tstyle?: CSSProperties\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\tHeader,\n\tstyle,\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\tHeader={Header}\n\t\t\tstyle={style}\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 { JsonEditor } from \"hamr/react-json-editor\"\n\nimport * as React from \"react\"\n\nexport type Next<X> = X | ((oldValue: X) => X)\n\nexport type DeriveChildren<Data> = (data: Data) => ReadonlyArray<unknown>\n\nexport type DataContext = {\n\tgetDesigner: (input: unknown) => DataDesigner<any, any> | undefined\n\tgetChildren: DeriveChildren<any>\n}\n\nexport type TreeNodeType = `Leaf` | `Tree`\n\nexport type DDCoreProps<Data, _ extends TreeNodeType> = {\n\tdata: Data\n\tset: (next: Next<Data>) => void\n}\n\nexport type DataDesignerProps<Data, NodeType extends TreeNodeType> = DDCoreProps<\n\tData,\n\tNodeType\n> & {\n\t// hierarchical\n\tpath?: ReadonlyArray<number | string>\n\tname?: string\n\trename?: (newKey: string) => void\n\tremove?: () => void\n\n\t// meta\n\tisValid?: (data: Data) => boolean\n\tisHidden?: (path: ReadonlyArray<number | string>) => boolean\n\tisReadonly?: (path: ReadonlyArray<number | string>) => boolean\n}\n\nexport type DataDesigner<Data, NodeType extends TreeNodeType> = React.FC<\n\tDataDesignerProps<Data, NodeType>\n>\n\nexport const Stub: DataDesigner<any, any> = (props) => {\n\treturn (\n\t\t<>\n\t\t\t<JsonEditor {...props} />\n\t\t</>\n\t)\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\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\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","import { Id } from \"hamr/react-id\"\n\nimport type { Join } from \"~/packages/anvl/src/join\"\n\nimport type { DataDesigner } from \"./DataDesigner\"\n\nimport \"./relation-editor-styles.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=\"relation-editor-0123456789\">\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 {\n\tReadonlySelectorToken,\n\tRegularAtomToken,\n\tTimelineToken,\n} from \"atom.io\"\nimport { findState, 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<any>\n\tisOpenState: RegularAtomToken<boolean>\n\ttimelineState: ReadonlySelectorToken<Timeline<any>>\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={findState(findViewIsOpenState, token.key)}\n\t\t\t\t\t\t\ttimelineState={findState(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 \"anvl/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<any>\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 {\n\ttype ReadonlySelectorToken,\n\ttype RegularAtomToken,\n\ttype TransactionToken,\n\ttype TransactionUpdate,\n\tfindState,\n\ttype ƒ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: RegularAtomToken<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={findState(findViewIsOpenState, token.key)}\n\t\t\t\t\t\t\tlogState={findState(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"]}