atom.io 0.6.9 → 0.8.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 (170) hide show
  1. package/README.md +21 -2
  2. package/dist/index.d.mts +34 -421
  3. package/dist/index.d.ts +34 -421
  4. package/dist/index.js +248 -23
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +209 -4
  7. package/dist/index.mjs.map +1 -1
  8. package/internal/dist/index.d.mts +364 -0
  9. package/internal/dist/index.d.ts +364 -0
  10. package/internal/dist/index.js +1906 -0
  11. package/internal/dist/index.js.map +1 -0
  12. package/internal/dist/index.mjs +1830 -0
  13. package/internal/dist/index.mjs.map +1 -0
  14. package/internal/package.json +15 -0
  15. package/internal/src/atom/create-atom.ts +75 -0
  16. package/internal/src/atom/delete-atom.ts +10 -0
  17. package/internal/src/atom/index.ts +3 -0
  18. package/internal/src/atom/is-default.ts +37 -0
  19. package/internal/src/caching.ts +38 -0
  20. package/internal/src/families/create-atom-family.ts +59 -0
  21. package/internal/src/families/create-readonly-selector-family.ts +45 -0
  22. package/internal/src/families/create-selector-family.ts +67 -0
  23. package/internal/src/families/index.ts +3 -0
  24. package/internal/src/future.ts +39 -0
  25. package/internal/src/get-state-internal.ts +23 -0
  26. package/internal/src/index.ts +14 -0
  27. package/internal/src/mutable/create-mutable-atom-family.ts +25 -0
  28. package/internal/src/mutable/create-mutable-atom.ts +49 -0
  29. package/internal/src/mutable/get-json-token.ts +22 -0
  30. package/internal/src/mutable/get-update-token.ts +20 -0
  31. package/internal/src/mutable/index.ts +17 -0
  32. package/internal/src/mutable/is-atom-token-mutable.ts +7 -0
  33. package/internal/src/mutable/tracker-family.ts +61 -0
  34. package/internal/src/mutable/tracker.ts +164 -0
  35. package/internal/src/mutable/transceiver.ts +110 -0
  36. package/internal/src/operation.ts +68 -0
  37. package/internal/src/selector/create-read-write-selector.ts +65 -0
  38. package/internal/src/selector/create-readonly-selector.ts +49 -0
  39. package/internal/src/selector/create-selector.ts +65 -0
  40. package/internal/src/selector/index.ts +5 -0
  41. package/internal/src/selector/lookup-selector-sources.ts +20 -0
  42. package/internal/src/selector/register-selector.ts +61 -0
  43. package/internal/src/selector/trace-selector-atoms.ts +45 -0
  44. package/internal/src/selector/update-selector-atoms.ts +34 -0
  45. package/internal/src/set-state/become.ts +10 -0
  46. package/internal/src/set-state/copy-mutable-if-needed.ts +23 -0
  47. package/internal/src/set-state/copy-mutable-in-transaction.ts +59 -0
  48. package/internal/src/set-state/copy-mutable-into-new-store.ts +34 -0
  49. package/internal/src/set-state/emit-update.ts +23 -0
  50. package/internal/src/set-state/evict-downstream.ts +39 -0
  51. package/internal/src/set-state/index.ts +2 -0
  52. package/internal/src/set-state/set-atom-state.ts +38 -0
  53. package/internal/src/set-state/set-selector-state.ts +19 -0
  54. package/internal/src/set-state/set-state-internal.ts +18 -0
  55. package/internal/src/set-state/stow-update.ts +42 -0
  56. package/internal/src/store/deposit.ts +43 -0
  57. package/internal/src/store/index.ts +5 -0
  58. package/internal/src/store/lookup.ts +26 -0
  59. package/internal/src/store/store.ts +154 -0
  60. package/internal/src/store/withdraw-new-family-member.ts +53 -0
  61. package/internal/src/store/withdraw.ts +113 -0
  62. package/internal/src/subject.ts +21 -0
  63. package/internal/src/subscribe/index.ts +1 -0
  64. package/internal/src/subscribe/recall-state.ts +19 -0
  65. package/internal/src/subscribe/subscribe-to-root-atoms.ts +47 -0
  66. package/internal/src/timeline/add-atom-to-timeline.ts +189 -0
  67. package/internal/src/timeline/index.ts +3 -0
  68. package/internal/src/timeline/time-travel-internal.ts +91 -0
  69. package/internal/src/timeline/timeline-internal.ts +115 -0
  70. package/internal/src/transaction/abort-transaction.ts +12 -0
  71. package/internal/src/transaction/apply-transaction.ts +64 -0
  72. package/internal/src/transaction/build-transaction.ts +39 -0
  73. package/internal/src/transaction/index.ts +26 -0
  74. package/internal/src/transaction/redo-transaction.ts +22 -0
  75. package/internal/src/transaction/transaction-internal.ts +64 -0
  76. package/internal/src/transaction/undo-transaction.ts +22 -0
  77. package/introspection/dist/index.d.mts +3 -197
  78. package/introspection/dist/index.d.ts +3 -197
  79. package/introspection/dist/index.js +329 -4
  80. package/introspection/dist/index.js.map +1 -1
  81. package/introspection/dist/index.mjs +310 -4
  82. package/introspection/dist/index.mjs.map +1 -1
  83. package/introspection/src/attach-atom-index.ts +84 -0
  84. package/introspection/src/attach-introspection-states.ts +38 -0
  85. package/introspection/src/attach-selector-index.ts +90 -0
  86. package/introspection/src/attach-timeline-family.ts +59 -0
  87. package/introspection/src/attach-timeline-index.ts +38 -0
  88. package/introspection/src/attach-transaction-index.ts +40 -0
  89. package/introspection/src/attach-transaction-logs.ts +43 -0
  90. package/introspection/src/index.ts +20 -0
  91. package/json/dist/index.d.mts +10 -2
  92. package/json/dist/index.d.ts +10 -2
  93. package/json/dist/index.js +83 -26
  94. package/json/dist/index.js.map +1 -1
  95. package/json/dist/index.mjs +74 -3
  96. package/json/dist/index.mjs.map +1 -1
  97. package/json/src/index.ts +5 -0
  98. package/json/src/select-json-family.ts +35 -0
  99. package/json/src/select-json.ts +22 -0
  100. package/package.json +103 -63
  101. package/react/dist/index.d.mts +9 -17
  102. package/react/dist/index.d.ts +9 -17
  103. package/react/dist/index.js +44 -27
  104. package/react/dist/index.js.map +1 -1
  105. package/react/dist/index.mjs +24 -4
  106. package/react/dist/index.mjs.map +1 -1
  107. package/react/src/index.ts +2 -0
  108. package/react/src/store-context.tsx +12 -0
  109. package/react/src/store-hooks.ts +36 -0
  110. package/react-devtools/dist/index.css +50 -1
  111. package/react-devtools/dist/index.css.map +1 -1
  112. package/react-devtools/dist/index.d.mts +104 -71
  113. package/react-devtools/dist/index.d.ts +104 -71
  114. package/react-devtools/dist/index.js +2821 -45
  115. package/react-devtools/dist/index.js.map +1 -1
  116. package/react-devtools/dist/index.mjs +2790 -11
  117. package/react-devtools/dist/index.mjs.map +1 -1
  118. package/react-devtools/src/AtomIODevtools.tsx +109 -0
  119. package/react-devtools/src/Button.tsx +23 -0
  120. package/react-devtools/src/StateEditor.tsx +75 -0
  121. package/react-devtools/src/StateIndex.tsx +159 -0
  122. package/react-devtools/src/TimelineIndex.tsx +88 -0
  123. package/react-devtools/src/TransactionIndex.tsx +70 -0
  124. package/react-devtools/src/Updates.tsx +150 -0
  125. package/react-devtools/src/devtools.scss +310 -0
  126. package/react-devtools/src/index.ts +72 -0
  127. package/realtime-react/dist/index.d.mts +8 -22
  128. package/realtime-react/dist/index.d.ts +8 -22
  129. package/realtime-react/dist/index.js +87 -32
  130. package/realtime-react/dist/index.js.map +1 -1
  131. package/realtime-react/dist/index.mjs +62 -6
  132. package/realtime-react/dist/index.mjs.map +1 -1
  133. package/realtime-react/src/index.ts +7 -0
  134. package/realtime-react/src/realtime-context.tsx +29 -0
  135. package/realtime-react/src/use-pull-family-member.ts +15 -0
  136. package/realtime-react/src/use-pull-mutable-family-member.ts +20 -0
  137. package/realtime-react/src/use-pull-mutable.ts +17 -0
  138. package/realtime-react/src/use-pull.ts +15 -0
  139. package/realtime-react/src/use-push.ts +19 -0
  140. package/realtime-react/src/use-server-action.ts +18 -0
  141. package/realtime-testing/dist/index.d.mts +49 -0
  142. package/realtime-testing/dist/index.d.ts +49 -0
  143. package/realtime-testing/dist/index.js +147 -0
  144. package/realtime-testing/dist/index.js.map +1 -0
  145. package/realtime-testing/dist/index.mjs +116 -0
  146. package/realtime-testing/dist/index.mjs.map +1 -0
  147. package/realtime-testing/src/index.ts +1 -0
  148. package/realtime-testing/src/setup-realtime-test.tsx +161 -0
  149. package/src/atom.ts +64 -9
  150. package/src/index.ts +29 -31
  151. package/src/logger.ts +3 -3
  152. package/src/selector.ts +3 -3
  153. package/src/silo.ts +29 -20
  154. package/src/subscribe.ts +3 -3
  155. package/src/timeline.ts +2 -2
  156. package/transceivers/set-rtx/dist/index.d.mts +39 -0
  157. package/transceivers/set-rtx/dist/index.d.ts +39 -0
  158. package/transceivers/set-rtx/dist/index.js +213 -0
  159. package/transceivers/set-rtx/dist/index.js.map +1 -0
  160. package/transceivers/set-rtx/dist/index.mjs +211 -0
  161. package/transceivers/set-rtx/dist/index.mjs.map +1 -0
  162. package/{realtime → transceivers/set-rtx}/package.json +1 -1
  163. package/transceivers/set-rtx/src/index.ts +1 -0
  164. package/transceivers/set-rtx/src/set-rtx.ts +242 -0
  165. package/realtime/dist/index.d.mts +0 -23
  166. package/realtime/dist/index.d.ts +0 -23
  167. package/realtime/dist/index.js +0 -32
  168. package/realtime/dist/index.js.map +0 -1
  169. package/realtime/dist/index.mjs +0 -7
  170. package/realtime/dist/index.mjs.map +0 -1
@@ -1,20 +1,2799 @@
1
1
  import { selectorFamily, atom, atomFamily, undo, redo, getState } from 'atom.io';
2
2
  import { attachIntrospectionStates } from 'atom.io/introspection';
3
- import { lazyLocalStorageEffect } from 'atom.io/web-effects';
4
- import { pipe } from 'fp-ts/function';
5
- import { useIO, useO } from 'atom.io/react';
3
+ import { useI, useO } from 'atom.io/react';
6
4
  import { motion, spring, LayoutGroup } from 'framer-motion';
7
- import * as Wo from 'react';
8
- import { forwardRef, useRef, useState, useImperativeHandle, useLayoutEffect, Fragment as Fragment$1, useMemo, Component, useId } from 'react';
9
- import { isBoolean } from 'fp-ts/boolean';
10
- import { isNumber } from 'fp-ts/number';
11
- import { isString } from 'fp-ts/string';
5
+ import * as React from 'react';
6
+ import { forwardRef, useRef, useState, useImperativeHandle, useLayoutEffect, Fragment as Fragment$1, Component, useId } from 'react';
12
7
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
- import Rs from 'ajv';
14
8
  import { useFloating, useClick, useInteractions, FloatingPortal } from '@floating-ui/react';
15
9
 
16
- var br=Object.defineProperty,xr=Object.defineProperties;var gr=Object.getOwnPropertyDescriptors;var Je=Object.getOwnPropertySymbols;var Lt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var jt=(e,t,n)=>t in e?br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))Lt.call(t,n)&&jt(e,n,t[n]);if(Je)for(var n of Je(t))_t.call(t,n)&&jt(e,n,t[n]);return e},u=(e,t)=>xr(e,gr(t));var Pt=e=>typeof e=="symbol"?e:e+"",ve=(e,t)=>{var n={};for(var o in e)Lt.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&Je)for(var o of Je(e))t.indexOf(o)<0&&_t.call(e,o)&&(n[o]=e[o]);return n};var Bt=e=>t=>{for(let n of e)if(!t.includes(n))return !1;return !0};var Ft=e=>t=>Bt(e)(t)&&Bt(t)(e);var w=e=>t=>Array.isArray(t)&&t.every(n=>e(n));var Te=e=>t=>t.map(e);var Xe=(e=Boolean)=>t=>t.every(e),Mt=Xe(e=>e===!0),Ie=e=>t=>e.includes(t)?e:[...e,t],Se=e=>Array.isArray(e)&&e.length===0,Dt=(...e)=>t=>e.includes(t);var Ge=e=>e===void 0,f=e=>t=>Ge(t)||e(t);var Kt=e=>t=>t!=null?t:e;var se=()=>{},ie=e=>t=>e instanceof Function?e(t instanceof Function?t():t):e,Wt=e=>t=>{if(!e(t))throw new Error(`Invalid test case: JSON.stringify(${t})`);return o=>{if(typeof o!="function")return !1;let r=o(t);return e(r)}},Ht=(...e)=>t=>t(...e);var $t=e=>{throw new Error(e)};var Vt=(e,t)=>{try{return e()}catch(n){return t}};var Ut=e=>Object.assign(t=>t[e],{in:t=>t[e]});var z=e=>Object.entries(e),Oe=e=>Object.fromEntries(e);var ae=(e,t)=>pipe(e,z,Te(([n,o])=>[n,t(o,n)]),Oe),zt=e=>t=>ae(t,e);var Tr=e=>typeof e=="object"&&e!==null,v=e=>Tr(e)&&Object.getPrototypeOf(e)===Object.prototype,Yt=e=>v(e)&&Object.keys(e).length===0,pe=(e,t)=>n=>v(n)&&Object.entries(n).every(([o,r])=>e(o)&&t(r)),qt=(e,t={allowExtraProperties:!1})=>{let n=`{${z(e).map(([r,s])=>String(r)+":"+s.name).join(",")}}`;return {[n]:r=>v(r)&&pipe(e,Object.entries,Xe(([s,i])=>s in r||i(void 0)))&&pipe(r,zt((s,i)=>pipe(e,Ut(i),Kt(()=>t.allowExtraProperties),Ht(s))),Object.values,Mt)}[n]},T=e=>qt(e,{allowExtraProperties:!0}),Qe=e=>qt(e,{allowExtraProperties:!1});var et=(e,t)=>{let n=(o,r)=>{let i=((p,l)=>{let m=t(p,l);return m||null})(o,r);if(i!=null&&i.jobComplete||i!=null&&i.pathComplete)return i;let a=Array.isArray(r)?r.map((p,l)=>[l,p]):v(r)?Object.entries(r):[];for(let[p,l]of a){let m=n([...o,p],l);if(m!=null&&m.jobComplete)return m}return {}};n([],e);};var Y=(e=Ge)=>t=>{let n={};return Object.entries(t).forEach(([r,s])=>e(s,r)?null:n[r]=s),n};var Xt=(e,t)=>{let n=t.reduce((o,r)=>o==null?void 0:o[r],e);return n===void 0?new Error("Not found"):{found:n}};var le=class{constructor(t){this.supported=t;}refine(t){for(let[n,o]of Object.entries(this.supported))try{if(o(t)===!0&&o!==Boolean)return {type:n,data:t}}catch(r){try{if(t instanceof o)return {type:n,data:t}}catch(s){}}return null}},Sr=new le({number:e=>typeof e=="number",string:e=>typeof e=="string",boolean:e=>typeof e=="boolean",object:v,array:e=>Array.isArray(e),null:e=>e===null}),ce=e=>{if(e===void 0)return "undefined";let t=Sr.refine(e);return t?t.type:Object.getPrototypeOf(e).constructor.name};function Gt(e,t){return {summary:`${e<t?"+":"-"}${Math.abs(e-t)} (${e} \u2192 ${t})`}}function Zt(e,t){return {summary:`${e.length<t.length?"+":"-"}${Math.abs(e.length-t.length)} ("${e}" \u2192 "${t}")`}}function Qt(e,t){return {summary:`${e} \u2192 ${t}`}}function tt(e,t,n){let o="",r=[],s=[],i=[];return et(e,(a,p)=>{let l;for(l of a){let m=t[l];if(m===void 0)s.push([l,JSON.stringify(p)]);else {let d=n(p,m);d.summary!=="No Change"&&i.push([l,d]);}}}),et(t,(a,p)=>{let l;for(l of a)e[l]===void 0&&r.push([l,JSON.stringify(p)]);}),o=`\uFF5E${i.length} \uFF0B${r.length} \uFF0D${s.length}`,{summary:o,added:r,removed:s,changed:i}}function en(e,t,n){return tt(e,t,n)}var je=class{constructor(t,n,o){this.leafRefinery=t,this.treeRefinery=n,this.leafDiffers={},this.treeDiffers={};for(let r of Object.keys(t.supported)){let s=o[r];this.leafDiffers[r]=s;}for(let r of Object.keys(n.supported)){let s=o[r];this.treeDiffers[r]=s;}}diff(t,n){var a,p;if(t===n)return {summary:"No Change"};try{if(JSON.stringify(t)===JSON.stringify(n))return {summary:"No Change"}}catch(l){console.error("Error stringifying",t,n);}let o=(a=this.leafRefinery.refine(t))!=null?a:this.treeRefinery.refine(t),r=(p=this.leafRefinery.refine(n))!=null?p:this.treeRefinery.refine(n);if(o!==null&&r!==null&&o.type===r.type){if(o.type in this.leafDiffers)return this.leafDiffers[o.type](o.data,r.data);if(o.type in this.treeDiffers)return this.treeDiffers[o.type](o.data,r.data,(m,d)=>this.diff(m,d))}let s=ce(t),i=ce(n);return s===i?{summary:`${s} \u2192 ${i}`}:{summary:`Type change: ${s} \u2192 ${i}`}}};var tn=e=>JSON.stringify(e),nn=["array","boolean","null","number","object","string"],on={array:[],boolean:!1,null:null,number:0,object:{},string:""};var Rr=["Array","Boolean","Number","Object","String"],me=e=>e===null?{type:"null",data:null}:isBoolean(e)?{type:"boolean",data:e}:isNumber(e)?{type:"number",data:e}:isString(e)?{type:"string",data:e}:Array.isArray(e)?{type:"array",data:e}:v(e)?{type:"object",data:e}:$t(e===void 0?"undefined passed to refineJsonType. This is not valid JSON.":`${tn(e)} with prototype "${Object.getPrototypeOf(e).constructor.name}" passed to refineJsonType. This is not valid JSON.`),q=e=>{var o;if(e===null)return !0;if(e===void 0)return !1;let t=(o=Object.getPrototypeOf(e))==null?void 0:o.constructor.name;return Rr.includes(t)};var Cr=({isOpen:e,setIsOpen:t,disabled:n})=>jsx("button",{type:"button",className:`carat ${e?"open":"closed"}`,onClick:()=>t(o=>!o),disabled:n,children:"\u25B6"}),X={OpenClose:Cr};var wr=e=>!0,Ar=e=>!1,R=e=>t=>t===e,nt=e=>t=>e.includes(t);var Ne=(e,t=!1,n=[e])=>{let o=`(${n.map(i=>i.name||"anon").join(" | ")})`,r={[o]:i=>n.some(a=>{var p;return t&&console.log(n.map(l=>l.name||"anon").join(" | "),">",(p=a.name)!=null?p:"anon",":",a(i)),a(i)})};return Object.assign(r[o],{or:i=>Ne(i,t,[...n,i])})},ot=Ne(Ar),rn=(e,t=!1,n=[e])=>{let o=`(${n.map(i=>i.name||"anon").join(" & ")})`,r={[o]:i=>n.every(a=>(t&&console.log(n.map(p=>p.name||"anon").join(" & "),">",a.name||"anon",":",a(i)),a(i)))};return Object.assign(r[o],{and:i=>rn(i,t,[...n,i])})},sn=rn(wr);var Jr=["1:1","1:n","n:n"],vr=e=>Jr.includes(e),an={contents:{},relations:{},relationType:"n:n",a:"from",b:"to"},pn=({from:e="from",to:t="to",isContent:n}={})=>o=>Qe({contents:n?pe(isString,n):Qe({}),relations:pe(isString,w(isString)),relationType:vr,a:R(e),b:R(t)})(o);var G=(e,t)=>{var n;return (n=e.relations[t])!=null?n:[]},ue=(e,t)=>{let n=G(e,t);return n.length>1&&console.warn(`entry with id ${t} was not expected to have multiple relations`),n[0]};var ln=(e,...t)=>{let n=t[0],{a:o,b:r}=e,s={from:o,to:r,isContent:n};return {toJson:i=>i.toJSON(),fromJson:i=>de.fromJSON(i,s)}};var ke=(e,t)=>G(e,t).map(n=>[n,Le(e,t,n)]),cn=(e,t)=>Object.fromEntries(ke(e,t));var mn=e=>t=>t.split(e);var Ir=(e,t,n)=>{let o=Dt(t,n);return u(c({},e),{relations:pipe(e.relations,z,Te(([r,s])=>[r,o(r)?s.filter(i=>!o(i)):s]),Oe,Y(Se)),contents:pipe(e.contents,Y((r,s)=>isString(s)&&pipe(s,mn("/"),Ft([t,n]))))})},jr=(e,t)=>u(c({},e),{relations:pipe(e.relations,z,Te(([o,r])=>[o,r.filter(s=>s!==t)]),Oe,Y((o,r)=>r===t||Se(o))),contents:pipe(e.contents,Y((o,r)=>isString(r)&&r.split("/").includes(t)))}),_e=(e,t)=>{let n=t[e.a],o=t[e.b];return o?Ir(e,n,o):jr(e,n)};var Lr=(e,t,n,...o)=>{var i,a;let r=u(c({},e),{relations:u(c({},e.relations),{[t]:Ie((i=e.relations[t])!=null?i:[])(n),[n]:Ie((a=e.relations[n])!=null?a:[])(t)})}),s=o[0];return s?Be(r,t,n,s):r},dn=Y(Se),_r=(e,t,n,...o)=>{var p;let r=c({},e.relations),s=ue(e,n),i=u(c({},e),{relations:dn(u(c(c({},r),s&&s!==t&&{[s]:r[s].filter(l=>l!==n)}),{[n]:[t],[t]:Ie((p=r[t])!=null?p:[])(n)}))}),a=o[0];return a?Be(i,t,n,a):i},Pr=(e,t,n,...o)=>{let r=ue(e,n),s=ue(e,t),i=u(c({},e),{relations:dn(u(c(c(c({},e.relations),r&&{[r]:[]}),s&&{[s]:[]}),{[t]:[n],[n]:[t]}))}),a=o[0];return a?Be(i,t,n,a):i},Pe=(e,t,...n)=>{let{[e.a]:o,[e.b]:r}=t;switch(e.relationType){case"1:1":return Pr(e,o,r,...n);case"1:n":return _r(e,o,r,...n);case"n:n":return Lr(e,o,r,...n)}};var fn=(e,t)=>[e,t].sort().join("/"),Le=(e,t,n)=>e.contents[fn(t,n)],Be=(e,t,n,o)=>u(c({},e),{contents:u(c({},e.contents),{[fn(t,n)]:o})}),st=(e,t)=>ke(e,t).map(([n,o])=>c({id:n},o)),yn=(e,t,n)=>{let o=t[e.a],r=t[e.b];return pipe(e,s=>{let a=G(e,o).filter(l=>!n.some(m=>m.id===l)),p=s;for(let l of a){let m={[e.a]:o!=null?o:l,[e.b]:r!=null?r:l};p=_e(p,m);}return p},s=>{let i=s;for(let a of n){let p=a,{id:l}=p,m=ve(p,["id"]);let d=Yt(m)?void 0:m;i=Pe(i,{[e.a]:o!=null?o:l,[e.b]:r!=null?r:l},d);}return i},s=>{let i=n.map(a=>a.id);return u(c({},s),{relations:u(c({},s.relations),{[o!=null?o:r]:i})})})};var de=class e{constructor(t){this.a="from";this.b="to";this.makeJsonInterface=(...t)=>ln(this,...t);Object.assign(this,u(c(c({},an),t),{makeJsonInterface:this.makeJsonInterface}));}toJSON(){return {relationType:this.relationType,relations:this.relations,contents:this.contents,a:this.a,b:this.b}}static fromJSON(t,n){if(pn(n)(t))return new e(t);throw new Error(`Saved JSON for this Join is invalid: ${JSON.stringify(t)}`)}from(t){return new e(u(c({},this),{a:t}))}to(t){return new e(u(c({},this),{b:t}))}getRelatedId(t){return ue(this,t)}getRelatedIds(t){return G(this,t)}getContent(t,n){return Le(this,t,n)}getRelationEntries(t){return ke(this,t)}getRelationRecord(t){return cn(this,t)}getRelation(t){return st(this,t)[0]}getRelations(t){return st(this,t)}setRelations(t,n){return new e(yn(this,t,n))}set(t,...n){return new e(Pe(this,t,...n))}remove(t){return new e(_e(this,t))}};var C=forwardRef(function(t,n){var p,l,m,d;let o=useRef(null),r=useRef(null),[s,i]=useState("auto");useImperativeHandle(n,()=>({focus:()=>{var y;(y=o.current)==null||y.focus();}}));let a=t.type==="number"?15:0;return useLayoutEffect(()=>{if(r.current){i(`${r.current.offsetWidth+a}px`);let y=setInterval(()=>{r.current&&i(`${r.current.offsetWidth+a}px`);},1e3);return ()=>clearInterval(y)}},[(p=o.current)==null?void 0:p.value,t.value]),jsxs("div",{style:{display:"inline-block",position:"relative"},children:[jsx("input",u(c({},t),{ref:o,style:c({padding:0,borderRadius:0,border:"none",fontFamily:"inherit",fontSize:"inherit",width:s},t.style)})),jsx("span",{ref:r,style:{padding:(l=t.style)==null?void 0:l.padding,position:"absolute",visibility:"hidden",whiteSpace:"pre",fontFamily:((m=t.style)==null?void 0:m.fontFamily)||"inherit",fontSize:((d=t.style)==null?void 0:d.fontSize)||"inherit"},children:t.value})]})});var F=(e,t)=>n=>n<e?e:n>t?t:n;var Z=(e,t)=>n=>n<e?t-(e-n)%(t-e):e+(n-e)%(t-e);function zr(e,t){if(t===void 0)return e;let n=10**t;return Math.round(e*n)/n}var Yr=["","-",".","-."],Tn=e=>Yr.includes(e),qr={"":null,"-":0,".":0,"-.":0},gn=e=>e==="0"||!isNaN(Number(e))&&e.includes("."),hn=(e,t)=>Tn(e)?qr[e]:t?parseFloat(e):Math.round(parseFloat(e)),Xr={max:1/0,min:-1/0,decimalPlaces:100,nullable:!0},Gr=e=>t=>{if(t===null&&e.nullable===!0)return null;let{max:n,min:o,decimalPlaces:r}=c(c({},Xr),e);return pipe(t!=null?t:0,F(o,n),i=>r?zr(i,r):i)},Zr=e=>e==null?"":e.toString(),Sn=({autoSize:e=!1,customCss:t,decimalPlaces:n,disabled:o=!1,label:r,max:s,min:i,name:a,onChange:p,onClick:l,placeholder:m="",set:d=()=>null,testId:y,value:x=null})=>{let O=useId(),[I,j]=useState(null),J=useRef(!1),E=Gr({max:s,min:i,decimalPlaces:n,nullable:!0}),re=n===void 0||n>0,ge=()=>{J.current&&(d(E(x!=null?x:null)),j(null)),J.current=!1;},he=B=>{var qe;if(p&&p(B),d===void 0)return;J.current=!0;let h=B.target.value;if(Tn(h)||gn(h)){j(h);let fr=gn(h)?h:(qe=i==null?void 0:i.toString())!=null?qe:"0",yr=hn(fr,re);d(E(yr));return}j(null);let Ae=!isNaN(Number(h))&&!h.includes(" ")||re&&h==="."||re&&h==="-."||h===""||h==="-",Ye=hn(h,re);Ae&&d(E(Ye));},b=I!=null?I:Zr(x&&E(x));return jsxs("span",{css:t,children:[r&&jsx("label",{htmlFor:O,children:r}),e?jsx(C,{type:"text",value:b,placeholder:m!=null?m:"-",onChange:he,onBlur:ge,disabled:o,name:a!=null?a:O,id:O,onClick:l,"data-testid":`number-input-${y!=null?y:O}`}):jsx("input",{type:"text",value:b,placeholder:m!=null?m:"-",onChange:he,onBlur:ge,disabled:o,name:a!=null?a:O,id:O,onClick:l,"data-testid":`number-input-${y!=null?y:O}`})]})};var On=({value:e,set:t,label:n,placeholder:o,customCss:r,autoSize:s=!1})=>jsxs("span",{css:r,children:[jsx("label",{children:n}),s?jsx(C,{type:"text",value:e,onChange:i=>t==null?void 0:t(i.target.value),disabled:t===void 0,placeholder:o}):jsx("input",{type:"text",value:e,onChange:i=>t==null?void 0:t(i.target.value),disabled:t===void 0,placeholder:o})]});var kn=({data:e})=>e===void 0?jsx(C,{disabled:!0,value:"undefined"}):jsx(C,{disabled:!0,value:Object.getPrototypeOf(e).constructor.name+" "+JSON.stringify(e)});var fe=({data:e,set:t,schema:n,name:o,rename:r,remove:s,recast:i,path:a=[],isReadonly:p=()=>!1,isHidden:l=()=>!1,className:m,customCss:d,Header:y,Components:x})=>{let O=q(e),I=O?me(e):{type:"non-json",data:e},j=O?pt[I.type]:kn,J=p(a);return l(a)?null:jsx(x.ErrorBoundary,{children:jsxs(x.EditorWrapper,{className:m,customCss:d,children:[s&&jsx(x.Button,{onClick:J?se:s,disabled:J,children:jsx(x.DeleteIcon,{})}),y&&jsx(y,{data:e,schema:n}),r&&jsx(x.KeyWrapper,{children:jsx(C,{value:o,onChange:J?se:E=>r(E.target.value),disabled:J})}),jsx(j,{data:I.data,set:t,schema:n,remove:s,rename:r,path:a,isReadonly:p,isHidden:l,Components:x}),i&&O?jsx("select",{onChange:J?se:E=>i(E.target.value),value:I.type,disabled:J,children:Object.keys(pt).map(E=>jsx("option",{value:E,children:E},E))}):null]})})};var Rn=(e,t)=>e.map((n,o)=>r=>t(()=>{let s=[...e];return s[o]=ie(r)(n),s}));var En=({path:e=[],isReadonly:t=()=>!1,isHidden:n=()=>!1,data:o,set:r,Components:s})=>{let i=Rn(o,r);return jsx(Fragment,{children:o.map((a,p)=>{let l=[...e,p];return jsx(fe,{path:l,isReadonly:t,isHidden:n,data:a,set:i[p],Components:s},l.join(""))})})};var N=e=>Number.isInteger(e),lt=e=>{if(N(e))return e;throw new Fe(e)},rs,Ce=class extends Number{constructor(n,o){super(n/o);this[rs]=()=>this.numerator/this.denominator;if(o===0)throw new Error("Denominator cannot be zero");this.numerator=lt(n),this.denominator=lt(o);}};rs=Symbol.toPrimitive;var Fe=class extends Error{constructor(t){super(`Could not parse integer from ${JSON.stringify(t)}`);}},ct=Object.assign(e=>lt(e),{from:e=>pipe(e,String,parseFloat,t=>N(t)?{value:t,error:null,round:null,upper:null,lower:null,ratio:null}:{value:null,error:new Fe(e),round:Math.round(t),upper:Math.ceil(t),lower:Math.floor(t),ratio:null}),formula:e=>t=>e(t)});new Ce(1,2);[new Ce(1,2)];({a:new Ce(1,2)});function ye(e){return T({$ref:isString})(e)}({$defs:{colorChannel:{type:"integer",minimum:ct(0),maximum:ct(255)},color:{type:"object",properties:{red:{$ref:"#/$defs/colorChannel"},green:{$ref:"#/$defs/colorChannel"},blue:{$ref:"#/$defs/colorChannel"}}}},type:"array",items:{$ref:"#/$defs/color"}});var Me=({refNode:{$ref:e},refMap:t={},root:n})=>{if(typeof n=="boolean")throw new TypeError("The root is a boolean and cannot be indexed");if(e in t)return {node:t[e],refMap:t};let[o,...r]=e.split("/"),s=Xt(n,r);if(s instanceof Error)throw s;let i=s.found;for(;ye(i);){let a=Me({refNode:i,refMap:t,root:n});i=a.node,t=a.refMap;}if(k(i))return {node:i,refMap:u(c({},t),{[e]:i})};throw new TypeError("The refNode is not a JsonSchema")};var wn=["date-time","date","email","hostname","ipv4","ipv6","regex","time","uri-reference","uri-template","uri","uuid"];var An=[...nn,"integer"];[...An,"any","never"];var Jn={type:R("string"),enum:f(w(isString)),minLength:f(N),maxLength:f(N),pattern:f(isString),format:f(nt(wn))};function mt(e){return T(Jn)(e)}var vn={type:R("number"),enum:f(w(isNumber)),minimum:f(isNumber),maximum:f(isNumber),exclusiveMinimum:f(isNumber),exclusiveMaximum:f(isNumber),multipleOf:f(isNumber)};function In(e){return T(vn)(e)}var jn={type:R("integer"),enum:f(w(N)),minimum:f(N),maximum:f(N),exclusiveMinimum:f(N),exclusiveMaximum:f(N),multipleOf:f(N)};function Ln(e){return T(jn)(e)}var _n={type:R("boolean"),enum:f(w(isBoolean))};function Pn(e){return T(_n)(e)}var Bn={type:R("null")};function Fn(e){return T(Bn)(e)}var Mn={type:R("object"),properties:f(pe(isString,k)),required:f(w(isString)),additionalProperties:f(k),propertyNames:f(mt),minProperties:f(N),maxProperties:f(N),dependentSchemas:f(pe(isString,k))};function Ke(e){return T(Mn)(e)}var Dn={type:R("array"),items:f(Ne(k).or(w(k))),minItems:f(N),maxItems:f(N),uniqueItems:f(isBoolean)};function Kn(e){return T(Dn)(e)}var is={anyOf:w(k)};function Wn(e){return T(is)(e)}var as={oneOf:w(k)};function ps(e){return T(as)(e)}var ls={allOf:w(k)};function Hn(e){return T(ls)(e)}var cs={if:k,then:f(k),else:f(k)};function $n(e){return T(cs)(e)}var ms={not:k};function Vn(e){return T(ms)(e)}var us=u(c(c(c(c(c(c(c({},Dn),_n),jn),Bn),vn),Mn),Jn),{type:w(nt(An)),enum:f(w(ot.or(N).or(isBoolean).or(isNumber).or(isString)))});function ds(e){return T(us)(e)}var fs=ot.or(Kn).or(Pn).or($n).or(ps).or(Ln).or(Hn).or(ds).or(Vn).or(Fn).or(In).or(Ke).or(mt).or(Wn);var ys=T({$id:f(isString),$schema:f(isString)}),bs=sn.and(fs).and(ys);function k(e){return Ne(bs).or(isBoolean).or(ye)(e)}var Un=e=>{try{return e.flatMap(t=>{switch(typeof t){case"string":return ["properties",t];case"number":return ["items",t];case"symbol":throw new TypeError(`The key ${String(t)} is not a valid JSON key; expected string or number, got symbol`);default:throw new TypeError(`The key ${t} is not a valid JSON key; expected string or number, got ${typeof t}`)}})}catch(t){if(t instanceof TypeError)return t;throw t}};var zn=e=>{if(typeof e=="boolean")throw new Error("The schema does not contain subSchemas");return t=>{let n=Un(t);if(n instanceof Error)return n;if(typeof e=="boolean")return new TypeError("The schema is not a JsonSchema");let{node:o,refMap:r}=n.reduce(({node:i,refMap:a=void 0},p)=>(console.log({node:i,key:p}),ye(i)?Me({refNode:i,root:e,refMap:a}):{node:i[p],refMap:a}),{node:e,refMap:void 0});if(o instanceof Error)throw o;let s=o;for(;ye(s);)console.log({subSchema:s}),s=Me({refNode:s,root:e,refMap:r}).node;if(console.log({subSchema:s}),k(s))return s;throw new TypeError("The subSchema is not a JsonSchema")}};var Yn=e=>e==="true",qn=e=>Number(e),Xn=e=>e.split(","),Gn=e=>{try{return JSON.parse(e)}catch(t){return {[e]:e}}},Zn=e=>JSON.stringify(e),Qn=e=>e.true===!0,eo=e=>{var t,n,o;return Number((o=(n=(t=e.number)!=null?t:e.size)!=null?n:e.count)!=null?o:0)},to=e=>Object.entries(e),no=e=>e.toString(),oo=e=>+e,ro=e=>({[e.toString()]:e}),so=e=>[e],io=e=>e.toString(),ao=e=>e===1,po=e=>({number:e}),lo=e=>Array(e).fill(null),co=e=>e.join(","),mo=e=>e.length,uo=e=>typeof e[0]=="boolean"?e[0]:e.length>0,fo=e=>e.reduce((t,n,o)=>(t[`${o}`]=n,t),{}),yo=()=>"",bo=()=>0,xo=()=>!1,go=()=>[],ho=()=>({});var To=e=>{let t=me(e);return {to:{array:()=>{switch(t.type){case"array":return t.data;case"object":return to(t.data);case"string":return Xn(t.data);case"boolean":return so(t.data);case"number":return lo(t.data);case"null":return go()}},boolean:()=>{switch(t.type){case"array":return uo(t.data);case"object":return Qn(t.data);case"string":return Yn(t.data);case"boolean":return t.data;case"number":return ao(t.data);case"null":return xo()}},number:()=>{switch(t.type){case"array":return mo(t.data);case"object":return eo(t.data);case"string":return qn(t.data);case"boolean":return oo(t.data);case"number":return t.data;case"null":return bo()}},object:()=>{switch(t.type){case"array":return fo(t.data);case"object":return t.data;case"string":return Gn(t.data);case"boolean":return ro(t.data);case"number":return po(t.data);case"null":return ho()}},string:()=>{switch(t.type){case"array":return co(t.data);case"object":return Zn(t.data);case"string":return t.data;case"boolean":return no(t.data);case"number":return io(t.data);case"null":return yo()}},null:()=>null}}};var So=(e,t)=>ae(e,(n,o)=>r=>t(u(c({},e),{[o]:ie(r)(n[o])}))),Oo=(e,t,n)=>ae(e,(o,r)=>s=>Object.hasOwn(e,s)?null:t(()=>{let i=Object.entries(e),a=i.findIndex(([l])=>l===r);i[a]=[s,o];let p=n.current;return n.current=u(c({},p),{[s]:p[r]}),Object.fromEntries(i)})),No=(e,t)=>ae(e,(n,o)=>()=>t(()=>{let i=e;return ve(i,[Pt(o)])})),ko=(e,t)=>ae(e,(n,o)=>r=>t(()=>u(c({},e),{[o]:To(n).to[r]()}))),Ro=(e,t)=>(n,o)=>r=>t(u(c({},e),{[n]:r!=null?r:on[o]})),Co=(e,t,n)=>()=>{let o=Object.keys(e).sort(n),r={};o.forEach(s=>r[s]=e[s]),t(r);};var hs=({addProperty:e,disabled:t,propertyKey:n,Components:o})=>jsxs(o.MissingPropertyWrapper,{children:[jsx(C,{disabled:!0,defaultValue:n})," ",jsx(C,{disabled:!0,defaultValue:"is missing"}),jsx(o.Button,{onClick:()=>e(),disabled:t,children:"+"})]}),Eo=({schema:e,path:t=[],isReadonly:n=()=>!1,isHidden:o=()=>!1,data:r,set:s,Components:i})=>{var he;let a=n(t),p=useRef(Object.keys(r).reduce((b,B)=>(b[B]=B,b),{})),l=So(r,s),m=Oo(r,s,p),d=No(r,s),y=ko(r,s),x=Co(r,s),O=Ro(r,s),I=v(e)?zn(e)(t):!0,j=R(!0)(I)?!0:Ke(I)?Object.keys((he=I.properties)!=null?he:{}):[],J=Object.keys(r),[E,re]=J.reduce(([b,B],h)=>j===!0||j.includes(h)?[b,[...B,h]]:[[...b,h],B],[[],[]]),ge=j===!0?[]:j.filter(b=>!J.includes(b));return jsxs(Fragment,{children:[jsx(i.Button,{onClick:()=>x(),disabled:a,children:"Sort"}),jsxs(i.ObjectWrapper,{children:[jsx("div",{className:"json_editor_properties",children:[...ge,...re,...E].map(b=>{let B=p.current[b],h=[...t,b],Ae=[...t,B],Ye=j===!0||j.includes(b);return ge.includes(b)?jsx(hs,{propertyKey:b,addProperty:O(b,"string"),disabled:a,Components:i},b+"IsMissing"):jsx(fe,{schema:e,path:h,name:b,isReadonly:n,isHidden:o,data:r[b],set:l[b],rename:m[b],remove:d[b],recast:y[b],className:`json_editor_property ${Ye?"json_editor_official":"json_editor_unofficial"}`,Components:i},Ae.join("."))})}),jsx(i.Button,{onClick:a?se:()=>O("new_property","string")(),disabled:a,children:"+"})]})]})};var wo=({data:e,set:t,Components:n})=>jsx(n.BooleanWrapper,{children:jsx("input",{type:"checkbox",checked:e,onChange:o=>t(o.target.checked)})}),Ao=({Components:e})=>jsx(e.NullWrapper,{children:'" "'}),Jo=({path:e=[],isReadonly:t=()=>!1,data:n,set:o,Components:r})=>jsx(r.NumberWrapper,{children:jsx(Sn,{value:n,set:t(e)?void 0:s=>o(Number(s)),autoSize:!0})}),vo=({path:e=[],isReadonly:t=()=>!1,data:n,set:o,Components:r})=>jsx(r.StringWrapper,{children:jsx(On,{value:n,set:t(e)?void 0:o,autoSize:!0})});var Io=({error:e,errorInfo:t})=>{var r,s;let n=t==null?void 0:t.componentStack.split(" ").filter(Boolean)[2],o=(s=(r=e==null?void 0:e.toString())!=null?r:t==null?void 0:t.componentStack)!=null?s:"Unknown error";return jsx("div",{"data-testid":"error-boundary",style:{flex:"1",background:"black",backgroundImage:"url(./src/assets/kablooey.gif)",backgroundPosition:"center",backgroundSize:"overlay"},children:jsx("div",{style:{margin:"50px",marginTop:"0",padding:"50px",border:"1px solid dashed"},children:jsxs("span",{style:{background:"black",color:"white",padding:10,paddingTop:5},children:["\u26A0\uFE0F ",jsx("span",{style:{color:"#fc0",fontWeight:700},children:n})," \u26A0\uFE0F ",o]})})})};var We=class extends Component{constructor(t){super(t),this.state={};}componentDidCatch(t,n){var o,r;(r=(o=this.props).onError)==null||r.call(o,t,n),this.setState({error:t,errorInfo:n});}render(){let{error:t,errorInfo:n}=this.state,{children:o,Fallback:r=Io}=this.props;return n?jsx(r,{error:t,errorInfo:n}):o}};var jo={ErrorBoundary:({children:e})=>jsx(We,{children:e}),Button:({onClick:e,children:t,disabled:n})=>jsx("button",{type:"button",className:"json_editor_button",onClick:e,disabled:n,children:t}),EditorWrapper:({children:e,customCss:t,className:n})=>jsx("div",{className:"json_editor "+n,css:t,children:e}),EditorLayout:({DeleteButton:e,Header:t,KeyInput:n,TypeSelect:o,ValueEditor:r,Wrapper:s})=>jsxs(s,{children:[e&&jsx(e,{}),t&&jsx(t,{}),n&&jsx(n,{}),o&&jsx(o,{}),jsx(r,{})]}),ArrayWrapper:({children:e})=>jsx("div",{className:"json_editor_array",children:e}),ObjectWrapper:({children:e})=>jsx("div",{className:"json_editor_object",children:e}),StringWrapper:({children:e})=>jsx("span",{className:"json_editor_string",children:e}),NumberWrapper:({children:e})=>jsx("span",{className:"json_editor_number",children:e}),BooleanWrapper:({children:e})=>jsx("span",{className:"json_editor_boolean",children:e}),NullWrapper:({children:e})=>jsx("span",{className:"json_editor_null",children:e}),MissingPropertyWrapper:({children:e})=>jsx("div",{className:"json_editor_property json_editor_missing",children:e}),MiscastPropertyWrapper:({children:e})=>jsx("div",{className:"json_editor_property json_editor_miscast",children:e}),IllegalPropertyWrapper:({children:e})=>jsx("span",{className:"json_editor_property json_editor_illegal",children:e}),OfficialPropertyWrapper:({children:e})=>jsx("span",{className:"json_editor_property json_editor_official",children:e}),UnofficialPropertyWrapper:({children:e})=>jsx("span",{className:"json_editor_property json_editor_unofficial",children:e}),DeleteIcon:()=>jsx("span",{className:"json_editor_icon json_editor_delete",children:"x"}),KeyWrapper:({children:e})=>jsx("span",{className:"json_editor_key",children:e})};var ft=({data:e,set:t,schema:n=!0,name:o,rename:r,remove:s,isReadonly:i=()=>!1,isHidden:a=()=>!1,className:p,customCss:l,Header:m,Components:d={}})=>{let y=c(c({},jo),d),x=new Rs({allErrors:!0,verbose:!0});useMemo(()=>x.compile(n),[n])(e);return jsx(fe,{data:e,set:t,name:o,schema:n,rename:r,remove:s,path:[],isReadonly:i,isHidden:a,className:p,customCss:l,Header:m,Components:y})};var pt={array:En,boolean:wo,null:Ao,number:Jo,object:Eo,string:vo};function Lo(e){let t=0;for(let o=0;o<e.length;o++){let r=e.charCodeAt(o);t=(t<<5)-t+r,t|=0;}let n=(t&16777215).toString(16);for(;n.length<6;)n="0"+n;return `#${n}`}var $={R:.3,G:.5,B:.2};var _o=[{sat:255,hue:0},{sat:255,hue:360}];var ws=e=>`#${Object.values(e).map(t=>{let n=t.toString(16);return n.length===1&&(n=0+n),n}).join("")}`,Po=ws;var Ee=e=>{let n=Z(0,360)(e)/60,o=Math.floor(n),r=n-o,s=r,i=1-r;switch(o){case 0:return [1,s,0];case 1:return [i,1,0];case 2:return [0,1,s];case 3:return [0,i,1];case 4:return [s,0,1];case 5:return [1,0,i];default:throw new Error(`invalid hue served: ${e}`)}};var As=({R:e,G:t,B:n})=>{let o=0;return e>t&&t>=n&&(o=60*(0+(t-n)/(e-n))),t>=e&&e>n&&(o=60*(2-(e-n)/(t-n))),t>n&&n>=e&&(o=60*(2+(n-e)/(t-e))),n>=t&&t>e&&(o=60*(4-(t-e)/(n-e))),n>e&&e>=t&&(o=60*(4+(e-t)/(n-t))),e>=n&&n>t&&(o=60*(6-(n-t)/(e-t))),o},yt=As;var Js=({R:e,G:t,B:n})=>$.R*e/255+$.G*t/255+$.B*n/255,te=Js;var bt=(e,t)=>{let n=255,o=Z(0,360)(e);for(let r=-1,s=0;s<t.length;r++,s++){r=Z(0,t.length)(r);let i=r>s?Z(-180,180)(o):void 0,a=t[r],p=t[s],l=r>s?Z(-180,180)(a.hue):a.hue,m=p.hue;if((i||o)>=l&&(i||o)<m){let d=i||o;d-=l,d/=m-l,d*=p.sat-a.sat,d+=a.sat,n=d;}}return n};var vs=({R:e,G:t,B:n})=>Math.max(e,t,n)-Math.min(e,t,n),xt=vs;var gt=e=>{let[t,n,o]=Ee(e),r=$.R*t,s=$.G*n,i=$.B*o;return r+s+i};var Is=e=>{let t=Ee(e);return o=>{let r=s=>Math.round(t[s]*o);return {R:r(0),G:r(1),B:r(2)}}},js=({minChannels:e,trueLuminosity:t,minLum:n})=>{let{max:o,round:r}=Math,s=255-o(...Object.values(e)),i=F(0,s)(r((t-n)*255));return {R:e.R+i,G:e.G+i,B:e.B+i}},Ls=({hue:e,sat:t,lum:n,prefer:o="lum"},r=_o)=>{let s=Is(e),i,a,p,l,m,d=0,y=1,x=bt(e,r);switch(o){case"sat":i=F(0,255)(Math.min(t,x)),p=s(i),l={R:p.R+255-i,G:p.G+255-i,B:p.B+255-i},d=te(p),y=te(l),a=F(d,y)(n);break;case"lum":a=F(0,1)(n),m=gt(e),x=Math.min(x,Math.round(a<=m?255*(a/m):255*(1-a)/(1-m))),i=Math.min(t,x),p=s(i),d=te(p);break}return {channels:js({minChannels:p,trueLuminosity:a,minLum:d}),fix:{sat:i,lum:a},limit:{sat:[0,x],lum:[o==="lum"?0:d,y]}}},Bo=Ls;var _s=({hue:e,sat:t,lum:n,prefer:o},r)=>{let{channels:s,fix:i,limit:a}=Bo({hue:e,sat:t,lum:n,prefer:o},r),{R:p,G:l,B:m}=s;return {hex:Po({R:p,G:l,B:m}),fix:i,limit:a}},ht=_s;var Ps=({hue:e,sat:t,lum:n,prefer:o},r)=>{let{hex:s}=ht({hue:e,sat:t,lum:n,prefer:o},r);return s},D=Ps;var Bs=({R:e,G:t,B:n})=>{let o=yt({R:e,G:t,B:n}),r=xt({R:e,G:t,B:n}),s=te({R:e,G:t,B:n});return {hue:o,sat:r,lum:s}},Tt=Bs;var Fs="[a-fA-F0-9]+",Ms=e=>{let t=e.split("");return [0,0,1,1,2,2].map(o=>t[o]).join("")},Ds=e=>{let t=e.replace(/^#/,""),n=t.length===6||t.length===3,o=t.match(new RegExp(`^${Fs}$`))!==null;if(!(n&&o))throw new Error(`${e} is not a valid hex code`);return t.length===3?Ms(t):t},St=Ds;var Ot=e=>{let t=St(e);return {R:parseInt(t.slice(0,2),16),G:parseInt(t.slice(2,4),16),B:parseInt(t.slice(4,6),16)}};var Ks=e=>{let{R:t,G:n,B:o}=Ot(e),{hue:r,sat:s,lum:i}=Tt({R:t,G:n,B:o});return {hue:r,sat:s,lum:i}},ne=Ks;var Nt=e=>u(c({},e),{lum:e.lum>.666?0:1});var Do=e=>t=>u(c({},t),{lum:t.lum>.666?t.lum-e:t.lum+e});var Ko={hue:0,lum:0,sat:0,prefer:"lum"};var Mo=e=>typeof e=="object"&&e!==null&&typeof e.hue=="number"&&typeof e.sat=="number"&&typeof e.lum=="number"&&["sat","lum"].includes(e.prefer);Wt(Mo)(Ko);var Vs=["Red","Orange","Yellow","Lime","Green","Teal","Cyan","Blue","Indigo","Violet","Magenta","Pink"];Vs.reduce((e,t,n)=>(e[t]={hue:n*30,sat:255,lum:.5,prefer:"sat"},e),{});var Ct=({id:e})=>{let[t,n]=Wo.useState(!1),{refs:o,floatingStyles:r,context:s}=useFloating({open:t,onOpenChange:n,placement:"bottom-start"}),i=useClick(s),{getReferenceProps:a,getFloatingProps:p}=useInteractions([i]),l=Lo(e),m=pipe(l,ne,Nt,D),d=pipe(l,ne,Do(.25),D),y=pipe(d,ne,Nt,D);return jsxs(Fragment,{children:[jsx("span",u(c({role:"content",ref:o.setReference},a()),{style:{background:l,cursor:"pointer",padding:"0px 4px",color:m,userSelect:"none",whiteSpace:"nowrap"},children:e.substring(0,3)})),t&&jsx(FloatingPortal,{children:jsx("span",u(c({role:"popup",ref:o.setFloating},p()),{style:u(c({},r),{color:y,background:d,padding:"0px 4px",boxShadow:"0px 2px 10px rgba(0, 0, 0, 0.1)"}),children:e}))})]})};var Ho={};var $o=e=>{let t=new Set,n=Object.entries(e.data.relations).sort(([o,r],[s,i])=>i.length-r.length).filter(([o,r])=>{if(t.has(o))return !1;t.add(o);for(let s of r)t.add(s);return !0});return jsx("article",{className:Ho.class,children:n.map(([o,r])=>jsxs("section",{children:[jsx("span",{children:jsx(Ct,{id:o})}),":",jsx("span",{children:r.map(s=>jsx(Ct,{id:s}))})]}))})};var ni=({token:e})=>{let[t,n]=useIO(e);return q(t)?jsx(ft,{data:t,set:n,schema:!0}):t instanceof de?jsx($o,{data:t,set:n}):jsx("div",{className:"json_editor",children:jsx(C,{value:t instanceof Set?`Set { ${JSON.stringify([...t]).slice(1,-1)} }`:t instanceof Map?"Map "+JSON.stringify([...t]):Object.getPrototypeOf(t).constructor.name+" "+Vt(()=>JSON.stringify(t),"?"),disabled:!0})})},oi=({token:e})=>{let t=useO(e);return q(t)?jsx(ft,{data:t,set:()=>null,schema:!0,isReadonly:()=>!0}):jsx("div",{className:"json_editor",children:jsx(C,{value:t instanceof Set?"Set "+JSON.stringify([...t]):t instanceof Map?"Map "+JSON.stringify([...t]):Object.getPrototypeOf(t).constructor.name+" "+JSON.stringify(t),disabled:!0})})},Et=({token:e})=>e.type==="readonly_selector"?jsx(oi,{token:e}):jsx(ni,{token:e});var At=selectorFamily({key:"\u{1F441}\u200D\u{1F5E8} State Type",get:e=>({get:t})=>{let n;try{n=t(e);}catch(o){return "error"}return n===void 0?"undefined":q(n)?me(n).type:Object.getPrototypeOf(n).constructor.name}}),si=({node:e,isOpenState:t,typeState:n})=>{var p,l;let[o,r]=useIO(t),s=useO(e),i=useO(n),a=!!vt.refine(s);return jsxs(Fragment,{children:[jsxs("header",{children:[jsx(X.OpenClose,{isOpen:o&&!a,setIsOpen:r,disabled:a}),jsxs("label",{onClick:()=>console.log(e,getState(e)),onKeyUp:()=>console.log(e,getState(e)),children:[jsx("h2",{children:(l=(p=e.family)==null?void 0:p.subKey)!=null?l:e.key}),jsxs("span",{className:"type detail",children:["(",i,")"]})]}),a?jsx(Et,{token:e}):null]}),o&&!a?jsx("main",{children:jsx(Et,{token:e})}):null]})},ii=({node:e,isOpenState:t})=>{let[n,o]=useIO(t);return Object.entries(e.familyMembers).forEach(([r,s])=>{V(r),At(s);}),jsxs(Fragment,{children:[jsxs("header",{children:[jsx(X.OpenClose,{isOpen:n,setIsOpen:o}),jsxs("label",{children:[jsx("h2",{children:e.key}),jsx("span",{className:"type detail",children:" (family)"})]})]}),n?Object.entries(e.familyMembers).map(([r,s])=>jsx(zo,{node:s,isOpenState:V(s.key),typeState:At(s)},r)):null]})},zo=({node:e,isOpenState:t,typeState:n})=>e.key.startsWith("\u{1F441}\u200D\u{1F5E8}")?null:jsx("section",{className:"node state",children:"type"in e?jsx(si,{node:e,isOpenState:t,typeState:n}):jsx(ii,{node:e,isOpenState:t})}),Jt=({tokenIndex:e})=>{let t=useO(e);return jsx("article",{className:"index state_index",children:Object.entries(t).filter(([n])=>!n.startsWith("\u{1F441}\u200D\u{1F5E8}")).sort().map(([n,o])=>jsx(zo,{node:o,isOpenState:V(o.key),typeState:At(o)},n))})};var ai=({atomUpdate:e})=>jsxs("article",{className:"node atom_update",onClick:()=>console.log(e),onKeyUp:()=>console.log(e),children:[jsxs("span",{className:"detail",children:[e.key,": "]}),jsx("span",{children:jsx("span",{className:"summary",children:Xo.diff(e.oldValue,e.newValue).summary})})]},e.key),pi=({serialNumber:e,transactionUpdate:t})=>jsxs("article",{className:"node transaction_update",children:[jsx("header",{children:jsx("h4",{children:e})}),jsxs("main",{children:[jsxs("section",{className:"transaction_params",children:[jsx("span",{className:"detail",children:"params: "}),t.params.map((n,o)=>jsxs("article",{className:"node transaction_param",onClick:()=>console.log(t),onKeyUp:()=>console.log(t),children:[jsxs("span",{className:"detail",children:[ce(n),": "]}),jsx("span",{className:"summary",children:typeof n=="object"&&n!==null&&"type"in n&&"target"in n?jsx(Fragment,{children:JSON.stringify(n.type)}):jsx(Fragment,{children:JSON.stringify(n)})})]},"param"+o))]}),jsxs("section",{className:"node transaction_output",children:[jsx("span",{className:"detail",children:"output: "}),jsx("span",{className:"detail",children:ce(t.output)}),t.output?jsxs("span",{className:"summary",children:[": ",JSON.stringify(t.output)]}):null]}),jsxs("section",{className:"transaction_impact",children:[jsx("span",{className:"detail",children:"impact: "}),t.atomUpdates.filter(n=>!n.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map((n,o)=>jsx(U.AtomUpdate,{serialNumber:o,atomUpdate:n},`${t.key}:${o}:${n.key}`))]})]})]}),li=({timelineUpdate:e})=>jsxs("article",{className:"node timeline_update",children:[jsx("header",{children:jsxs("h4",{children:[e.timestamp,": ",e.type," (",e.key,")"]})}),jsx("main",{children:e.type==="transaction_update"?e.atomUpdates.filter(t=>!t.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map((t,n)=>jsx(U.AtomUpdate,{serialNumber:n,atomUpdate:t},`${e.key}:${n}:${t.key}`)):e.type==="selector_update"?e.atomUpdates.filter(t=>!t.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map((t,n)=>jsx(U.AtomUpdate,{serialNumber:n,atomUpdate:t},`${e.key}:${n}:${t.key}`)):e.type==="atom_update"?jsx(U.AtomUpdate,{serialNumber:e.timestamp,atomUpdate:e}):null})]}),U={AtomUpdate:ai,TransactionUpdate:pi,TimelineUpdate:li};var Go=()=>jsx("span",{className:"you_are_here",children:"you are here"}),fi=({token:e,isOpenState:t,timelineState:n})=>{let o=useO(n),[r,s]=useIO(t);return jsxs("section",{className:"node timeline_log",children:[jsxs("header",{children:[jsx(X.OpenClose,{isOpen:r,setIsOpen:s}),jsxs("label",{children:[jsx("h2",{children:e.key}),jsxs("span",{className:"detail length",children:["(",o.at,"/",o.history.length,")"]}),jsx("span",{className:"gap"}),jsxs("nav",{children:[jsx("button",{type:"button",onClick:()=>undo(e),disabled:o.at===0,children:"undo"}),jsx("button",{type:"button",onClick:()=>redo(e),disabled:o.at===o.history.length,children:"redo"})]})]})]}),r?jsx("main",{children:o.history.map((i,a)=>jsxs(Fragment$1,{children:[a===o.at?jsx(Go,{}):null,jsx(U.TimelineUpdate,{timelineUpdate:i}),a===o.history.length-1&&o.at===o.history.length?jsx(Go,{}):null]},i.key+a+o.at))}):null]})},Qo=()=>{let e=useO(er);return jsx("article",{className:"index timeline_index",children:e.filter(t=>!t.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map(t=>jsx(fi,{token:t,isOpenState:V(t.key),timelineState:tr(t.key)},t.key))})};var bi=({token:e,isOpenState:t,logState:n})=>{let o=useO(n),[r,s]=useIO(t);return jsxs("section",{className:"node transaction_log",children:[jsxs("header",{children:[jsx(X.OpenClose,{isOpen:r,setIsOpen:s}),jsxs("label",{children:[jsx("h2",{children:e.key}),jsxs("span",{className:"detail length",children:["(",o.length,")"]})]})]}),r?jsx("main",{children:o.map((i,a)=>jsx(U.TransactionUpdate,{serialNumber:a,transactionUpdate:i},i.key+a))}):null]})},or=()=>{let e=useO(rr);return jsx("article",{className:"index transaction_index",children:e.filter(t=>!t.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map(t=>jsx(bi,{token:t,isOpenState:V(t.key),logState:sr(t.key)},t.key))})};var Ed=()=>{let e=useRef(null),[t,n]=useIO(mr),[o,r]=useIO(ur),s=useO(dr),i=useRef(!1);return jsxs(Fragment,{children:[jsx(motion.span,{ref:e,className:"atom_io_devtools_zone",style:{position:"fixed",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}),jsxs(motion.main,{drag:!0,dragConstraints:e,className:"atom_io_devtools",transition:spring,style:t?{}:{backgroundColor:"#0000",borderColor:"#0000",maxHeight:28,maxWidth:33},children:[t?jsxs(Fragment,{children:[jsxs(motion.header,{children:[jsx("h1",{children:"atom.io"}),jsx("nav",{children:s.map(a=>jsx("button",{type:"button",className:a===o?"active":"",onClick:()=>r(a),disabled:a===o,children:a},a))})]}),jsx(motion.main,{children:jsx(LayoutGroup,{children:o==="atoms"?jsx(Jt,{tokenIndex:lr}):o==="selectors"?jsx(Jt,{tokenIndex:cr}):o==="transactions"?jsx(or,{}):o==="timelines"?jsx(Qo,{}):null})})]}):null,jsx("footer",{children:jsx("button",{type:"button",onMouseDown:()=>i.current=!1,onMouseMove:()=>i.current=!0,onMouseUp:()=>{i.current||n(a=>!a);},children:"\u{1F441}\u200D\u{1F5E8}"})})]})]})};var {atomIndex:lr,selectorIndex:cr,transactionIndex:rr,findTransactionLogState:sr,timelineIndex:er,findTimelineState:tr}=attachIntrospectionStates(),mr=atom({key:"\u{1F441}\u200D\u{1F5E8} Devtools Are Open",default:!0,effects:[lazyLocalStorageEffect("\u{1F441}\u200D\u{1F5E8} Devtools Are Open")]}),ur=atom({key:"\u{1F441}\u200D\u{1F5E8} Devtools View Selection",default:"atoms",effects:[lazyLocalStorageEffect("\u{1F441}\u200D\u{1F5E8} Devtools View")]}),dr=atom({key:"\u{1F441}\u200D\u{1F5E8} Devtools View Options",default:["atoms","selectors","transactions","timelines"],effects:[lazyLocalStorageEffect("\u{1F441}\u200D\u{1F5E8} Devtools View Options")]}),V=atomFamily({key:"\u{1F441}\u200D\u{1F5E8} Devtools View Is Open",default:!1,effects:e=>[lazyLocalStorageEffect(e+":view-is-open")]}),vt=new le({number:e=>typeof e=="number",string:e=>typeof e=="string",boolean:e=>typeof e=="boolean",null:e=>e===null}),Oi=new le({object:v,array:e=>Array.isArray(e)}),Xo=new je(vt,Oi,{number:Gt,string:Zt,boolean:Qt,null:()=>({summary:"No Change"}),object:tt,array:en});
10
+ var __defProp = Object.defineProperty;
11
+ var __defProps = Object.defineProperties;
12
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
13
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
14
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
16
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
+ var __spreadValues = (a2, b2) => {
18
+ for (var prop in b2 || (b2 = {}))
19
+ if (__hasOwnProp.call(b2, prop))
20
+ __defNormalProp(a2, prop, b2[prop]);
21
+ if (__getOwnPropSymbols)
22
+ for (var prop of __getOwnPropSymbols(b2)) {
23
+ if (__propIsEnum.call(b2, prop))
24
+ __defNormalProp(a2, prop, b2[prop]);
25
+ }
26
+ return a2;
27
+ };
28
+ var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
29
+ var __restKey = (key) => typeof key === "symbol" ? key : key + "";
30
+ var __objRest = (source, exclude) => {
31
+ var target = {};
32
+ for (var prop in source)
33
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
34
+ target[prop] = source[prop];
35
+ if (source != null && __getOwnPropSymbols)
36
+ for (var prop of __getOwnPropSymbols(source)) {
37
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
38
+ target[prop] = source[prop];
39
+ }
40
+ return target;
41
+ };
17
42
 
18
- export { Ed as AtomIODevtools, lr as atomIndex, mr as devtoolsAreOpenState, dr as devtoolsViewOptionsState, ur as devtoolsViewSelectionState, tr as findTimelineState, sr as findTransactionLogState, V as findViewIsOpenState, Oi as jsonTreeRefinery, Xo as prettyJson, vt as primitiveRefinery, cr as selectorIndex, er as timelineIndex, rr as transactionIndex };
43
+ // ../__unstable__/web-effects/src/storage.ts
44
+ var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, onSet }) => {
45
+ const savedValue = storage.getItem(key);
46
+ if (savedValue != null)
47
+ setSelf(parse(savedValue));
48
+ onSet(({ newValue }) => {
49
+ if (newValue == null) {
50
+ storage.removeItem(key);
51
+ return;
52
+ }
53
+ storage.setItem(key, stringify(newValue));
54
+ });
55
+ };
56
+ var lazyLocalStorageEffect = persistAtom(localStorage)(JSON);
57
+
58
+ // ../../anvl/src/function/pipe.ts
59
+ function pipe(a2, ab, bc, cd, de, ef, fg, gh, hi) {
60
+ switch (arguments.length) {
61
+ case 1:
62
+ return a2;
63
+ case 2:
64
+ return ab(a2);
65
+ case 3:
66
+ return bc(ab(a2));
67
+ case 4:
68
+ return cd(bc(ab(a2)));
69
+ case 5:
70
+ return de(cd(bc(ab(a2))));
71
+ case 6:
72
+ return ef(de(cd(bc(ab(a2)))));
73
+ case 7:
74
+ return fg(ef(de(cd(bc(ab(a2))))));
75
+ case 8:
76
+ return gh(fg(ef(de(cd(bc(ab(a2)))))));
77
+ case 9:
78
+ return hi(gh(fg(ef(de(cd(bc(ab(a2))))))));
79
+ default: {
80
+ let ret = arguments[0];
81
+ for (let i = 1; i < arguments.length; i++) {
82
+ ret = arguments[i](ret);
83
+ }
84
+ return ret;
85
+ }
86
+ }
87
+ }
88
+
89
+ // ../../anvl/src/function/index.ts
90
+ var doNothing = () => void 0;
91
+ var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
92
+ originalThing instanceof Function ? originalThing() : originalThing
93
+ ) : nextVersionOfThing;
94
+ var isModifier = (validate) => (sample) => {
95
+ const sampleIsValid = validate(sample);
96
+ if (!sampleIsValid) {
97
+ throw new Error(`Invalid test case: JSON.stringify(${sample})`);
98
+ }
99
+ return (input) => {
100
+ if (typeof input !== `function`)
101
+ return false;
102
+ const testResult = input(sample);
103
+ return validate(testResult);
104
+ };
105
+ };
106
+ var pass = (...params) => (fn) => fn(...params);
107
+ var raiseError = (message) => {
108
+ throw new Error(message);
109
+ };
110
+ var fallback = (fn, fallbackValue) => {
111
+ try {
112
+ return fn();
113
+ } catch (_) {
114
+ return fallbackValue;
115
+ }
116
+ };
117
+
118
+ // ../../anvl/src/array/venn.ts
119
+ var includesAll = (items) => (array) => {
120
+ for (const item of items) {
121
+ if (!array.includes(item))
122
+ return false;
123
+ }
124
+ return true;
125
+ };
126
+ var comprises = (items) => (array) => includesAll(items)(array) && includesAll(array)(items);
127
+
128
+ // ../../anvl/src/array/index.ts
129
+ var isArray = (isType) => (input) => Array.isArray(input) && input.every((item) => isType(item));
130
+ var map = (f) => (a2) => a2.map(f);
131
+ var every = (f = Boolean) => (a2) => a2.every(f);
132
+ var allTrue = every((x) => x === true);
133
+ var addTo = (a2) => (x) => a2.includes(x) ? a2 : [...a2, x];
134
+ var isEmptyArray = (input) => Array.isArray(input) && input.length === 0;
135
+ var isOneOf = (...args) => (input) => args.includes(input);
136
+
137
+ // ../../anvl/src/nullish/index.ts
138
+ var isUndefined = (input) => input === void 0;
139
+ var ifDefined = (validate) => (input) => isUndefined(input) || validate(input);
140
+ var ifNullish = (alt) => (input) => input != null ? input : alt;
141
+
142
+ // ../../anvl/src/object/access.ts
143
+ var access = (k) => Object.assign((obj) => obj[k], {
144
+ in: (obj) => obj[k]
145
+ });
146
+
147
+ // ../../anvl/src/object/entries.ts
148
+ var recordToEntries = (obj) => Object.entries(obj);
149
+ var entriesToRecord = (entries) => Object.fromEntries(entries);
150
+
151
+ // ../../anvl/src/object/mapObject.ts
152
+ var mapObject = (obj, fn) => pipe(
153
+ obj,
154
+ recordToEntries,
155
+ map(([key, val]) => [key, fn(val, key)]),
156
+ entriesToRecord
157
+ );
158
+ var mob = (fn) => (obj) => mapObject(obj, fn);
159
+
160
+ // ../../anvl/src/object/refinement.ts
161
+ var isNonNullObject = (input) => typeof input === `object` && input !== null;
162
+ var isPlainObject = (input) => isNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype;
163
+ var isEmptyObject = (input) => isPlainObject(input) && Object.keys(input).length === 0;
164
+ var isRecord = (isKey, isValue) => (input) => isPlainObject(input) && Object.entries(input).every(([k, v]) => isKey(k) && isValue(v));
165
+ var hasProperties = (isValue, options = { allowExtraProperties: false }) => {
166
+ const name = `{${recordToEntries(
167
+ isValue
168
+ ).map(([k, v]) => String(k) + `:` + v.name).join(`,`)}}`;
169
+ const _ = {
170
+ [name]: (input) => isPlainObject(input) && pipe(
171
+ isValue,
172
+ Object.entries,
173
+ every(([key, val]) => key in input || val(void 0))
174
+ ) && pipe(
175
+ input,
176
+ mob(
177
+ (val, key) => pipe(
178
+ isValue,
179
+ access(key),
180
+ ifNullish(() => options.allowExtraProperties),
181
+ pass(val)
182
+ )
183
+ ),
184
+ Object.values,
185
+ allTrue
186
+ )
187
+ };
188
+ return _[name];
189
+ };
190
+ var ALLOW_EXTENSION = { allowExtraProperties: true };
191
+ var doesExtend = (isValue) => hasProperties(isValue, ALLOW_EXTENSION);
192
+ var DO_NOT_ALLOW_EXTENSION = { allowExtraProperties: false };
193
+ var hasExactProperties = (isValue) => hasProperties(isValue, DO_NOT_ALLOW_EXTENSION);
194
+
195
+ // ../../anvl/src/object/sprawl.ts
196
+ var sprawl = (tree, inspector) => {
197
+ const walk = (path, node) => {
198
+ const inspect = (path2, node2) => {
199
+ const result2 = inspector(path2, node2);
200
+ if (result2)
201
+ return result2;
202
+ return null;
203
+ };
204
+ const result = inspect(path, node);
205
+ if ((result == null ? void 0 : result.jobComplete) || (result == null ? void 0 : result.pathComplete)) {
206
+ return result;
207
+ }
208
+ const childEntries = Array.isArray(node) ? node.map((v, i) => [i, v]) : isPlainObject(node) ? Object.entries(node) : [];
209
+ for (const [k, v] of childEntries) {
210
+ const subResult = walk([...path, k], v);
211
+ if (subResult == null ? void 0 : subResult.jobComplete) {
212
+ return subResult;
213
+ }
214
+ }
215
+ return {};
216
+ };
217
+ walk([], tree);
218
+ };
219
+
220
+ // ../../anvl/src/object/index.ts
221
+ var treeShake = (shouldDiscard = isUndefined) => (obj) => {
222
+ const newObj = {};
223
+ const entries = Object.entries(obj);
224
+ entries.forEach(
225
+ ([key, val]) => !shouldDiscard(val, key) ? newObj[key] = val : null
226
+ );
227
+ return newObj;
228
+ };
229
+ var delve = (obj, path) => {
230
+ const found = path.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
231
+ return found === void 0 ? new Error(`Not found`) : { found };
232
+ };
233
+
234
+ // ../../anvl/src/refinement/refinery.ts
235
+ var Refinery = class {
236
+ constructor(supported) {
237
+ this.supported = supported;
238
+ }
239
+ refine(input) {
240
+ for (const [key, refiner] of Object.entries(this.supported)) {
241
+ try {
242
+ if (
243
+ // @ts-expect-error that's the point
244
+ refiner(input) === true && refiner !== Boolean
245
+ ) {
246
+ return { type: key, data: input };
247
+ }
248
+ } catch (e) {
249
+ try {
250
+ if (input instanceof refiner) {
251
+ return { type: key, data: input };
252
+ }
253
+ } catch (e2) {
254
+ }
255
+ }
256
+ }
257
+ return null;
258
+ }
259
+ };
260
+ var jsonRefinery = new Refinery({
261
+ number: (input) => typeof input === `number`,
262
+ string: (input) => typeof input === `string`,
263
+ boolean: (input) => typeof input === `boolean`,
264
+ object: isPlainObject,
265
+ array: (input) => Array.isArray(input),
266
+ null: (input) => input === null
267
+ });
268
+ var discoverType = (input) => {
269
+ if (input === void 0) {
270
+ return `undefined`;
271
+ }
272
+ const refined = jsonRefinery.refine(input);
273
+ if (refined) {
274
+ return refined.type;
275
+ }
276
+ return Object.getPrototypeOf(input).constructor.name;
277
+ };
278
+
279
+ // ../../anvl/src/tree/differ.ts
280
+ function diffNumber(a2, b2) {
281
+ const sign = a2 < b2 ? `+` : `-`;
282
+ return {
283
+ summary: `${sign}${Math.abs(a2 - b2)} (${a2} \u2192 ${b2})`
284
+ };
285
+ }
286
+ function diffString(a2, b2) {
287
+ const sign = a2.length < b2.length ? `+` : `-`;
288
+ return {
289
+ summary: `${sign}${Math.abs(a2.length - b2.length)} ("${a2}" \u2192 "${b2}")`
290
+ };
291
+ }
292
+ function diffBoolean(a2, b2) {
293
+ return {
294
+ summary: `${a2} \u2192 ${b2}`
295
+ };
296
+ }
297
+ function diffObject(a2, b2, recurse) {
298
+ let summary = ``;
299
+ const added = [];
300
+ const removed = [];
301
+ const changed = [];
302
+ sprawl(a2, (path, nodeA) => {
303
+ let key;
304
+ for (key of path) {
305
+ const nodeB = b2[key];
306
+ if (nodeB === void 0) {
307
+ removed.push([key, JSON.stringify(nodeA)]);
308
+ } else {
309
+ const delta = recurse(nodeA, nodeB);
310
+ if (delta.summary !== `No Change`) {
311
+ changed.push([key, delta]);
312
+ }
313
+ }
314
+ }
315
+ });
316
+ sprawl(b2, (path, nodeB) => {
317
+ let key;
318
+ for (key of path) {
319
+ const nodeA = a2[key];
320
+ if (nodeA === void 0) {
321
+ added.push([key, JSON.stringify(nodeB)]);
322
+ }
323
+ }
324
+ });
325
+ summary = `\uFF5E${changed.length} \uFF0B${added.length} \uFF0D${removed.length}`;
326
+ return {
327
+ summary,
328
+ added,
329
+ removed,
330
+ changed
331
+ };
332
+ }
333
+ function diffArray(a2, b2, recurse) {
334
+ return diffObject(a2, b2, recurse);
335
+ }
336
+ var Differ = class {
337
+ constructor(leafRefinery, treeRefinery, diffFunctions) {
338
+ this.leafRefinery = leafRefinery;
339
+ this.treeRefinery = treeRefinery;
340
+ this.leafDiffers = {};
341
+ this.treeDiffers = {};
342
+ for (const key of Object.keys(leafRefinery.supported)) {
343
+ const diffFunction = diffFunctions[key];
344
+ this.leafDiffers[key] = diffFunction;
345
+ }
346
+ for (const key of Object.keys(treeRefinery.supported)) {
347
+ const diffFunction = diffFunctions[key];
348
+ this.treeDiffers[key] = diffFunction;
349
+ }
350
+ }
351
+ diff(a2, b2) {
352
+ var _a2, _b;
353
+ if (a2 === b2) {
354
+ return { summary: `No Change` };
355
+ }
356
+ try {
357
+ if (JSON.stringify(a2) === JSON.stringify(b2)) {
358
+ return { summary: `No Change` };
359
+ }
360
+ } catch (thrown) {
361
+ console.error(`Error stringifying`, a2, b2);
362
+ }
363
+ const aRefined = (_a2 = this.leafRefinery.refine(a2)) != null ? _a2 : this.treeRefinery.refine(a2);
364
+ const bRefined = (_b = this.leafRefinery.refine(b2)) != null ? _b : this.treeRefinery.refine(b2);
365
+ if (aRefined !== null && bRefined !== null) {
366
+ if (aRefined.type === bRefined.type) {
367
+ if (aRefined.type in this.leafDiffers) {
368
+ const delta = this.leafDiffers[aRefined.type](
369
+ aRefined.data,
370
+ bRefined.data
371
+ );
372
+ return delta;
373
+ }
374
+ if (aRefined.type in this.treeDiffers) {
375
+ const delta = this.treeDiffers[aRefined.type](
376
+ aRefined.data,
377
+ bRefined.data,
378
+ (x, y) => this.diff(x, y)
379
+ );
380
+ return delta;
381
+ }
382
+ }
383
+ }
384
+ const typeA = discoverType(a2);
385
+ const typeB = discoverType(b2);
386
+ if (typeA === typeB) {
387
+ return {
388
+ summary: `${typeA} \u2192 ${typeB}`
389
+ };
390
+ }
391
+ return {
392
+ summary: `Type change: ${typeA} \u2192 ${typeB}`
393
+ };
394
+ }
395
+ };
396
+
397
+ // ../../anvl/src/json/index.ts
398
+ var stringifyJson = (json) => JSON.stringify(json);
399
+ var JSON_TYPE_NAMES = [
400
+ `array`,
401
+ `boolean`,
402
+ `null`,
403
+ `number`,
404
+ `object`,
405
+ `string`
406
+ ];
407
+ var JSON_DEFAULTS = {
408
+ array: [],
409
+ boolean: false,
410
+ null: null,
411
+ number: 0,
412
+ object: {},
413
+ string: ``
414
+ };
415
+
416
+ // ../../anvl/src/primitive/index.ts
417
+ var isString = (input) => {
418
+ return typeof input === `string`;
419
+ };
420
+ var isNumber = (input) => {
421
+ return typeof input === `number`;
422
+ };
423
+ var isBoolean = (input) => {
424
+ return typeof input === `boolean`;
425
+ };
426
+
427
+ // ../../anvl/src/refinement/refine-json.ts
428
+ var JSON_PROTOTYPES = [
429
+ `Array`,
430
+ `Boolean`,
431
+ `Number`,
432
+ `Object`,
433
+ `String`
434
+ ];
435
+ var refineJsonType = (data) => data === null ? { type: `null`, data: null } : isBoolean(data) ? { type: `boolean`, data } : isNumber(data) ? { type: `number`, data } : isString(data) ? { type: `string`, data } : Array.isArray(data) ? { type: `array`, data } : isPlainObject(data) ? { type: `object`, data } : raiseError(
436
+ data === void 0 ? `undefined passed to refineJsonType. This is not valid JSON.` : `${stringifyJson(data)} with prototype "${Object.getPrototypeOf(data).constructor.name}" passed to refineJsonType. This is not valid JSON.`
437
+ );
438
+ var isJson = (input) => {
439
+ var _a2;
440
+ if (input === null)
441
+ return true;
442
+ if (input === void 0)
443
+ return false;
444
+ const prototype = (_a2 = Object.getPrototypeOf(input)) == null ? void 0 : _a2.constructor.name;
445
+ const isJson2 = JSON_PROTOTYPES.includes(prototype);
446
+ return isJson2;
447
+ };
448
+ var OpenClose = ({ isOpen, setIsOpen, disabled }) => {
449
+ return /* @__PURE__ */ jsx(
450
+ "button",
451
+ {
452
+ type: "button",
453
+ className: `carat ${isOpen ? `open` : `closed`}`,
454
+ onClick: () => setIsOpen((isOpen2) => !isOpen2),
455
+ disabled,
456
+ children: "\u25B6"
457
+ }
458
+ );
459
+ };
460
+ var button = {
461
+ OpenClose
462
+ };
463
+
464
+ // ../../anvl/src/refinement/can-exist.ts
465
+ var canExist = (_) => true;
466
+
467
+ // ../../anvl/src/refinement/cannot-exist.ts
468
+ var cannotExist = (_) => false;
469
+
470
+ // ../../anvl/src/refinement/is-union.ts
471
+ var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isTypeA]) => {
472
+ const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` | `)})`;
473
+ const _ = {
474
+ [name]: (input) => refinements.some(
475
+ (refinement) => {
476
+ var _a2;
477
+ return logging && console.log(
478
+ refinements.map((r) => r.name || `anon`).join(` | `),
479
+ `>`,
480
+ (_a2 = refinement.name) != null ? _a2 : `anon`,
481
+ `:`,
482
+ refinement(input)
483
+ ), refinement(input);
484
+ }
485
+ )
486
+ };
487
+ const checkTypes = Object.assign(_[name], {
488
+ or: (isTypeB) => mustSatisfyOneOfTheFollowing(isTypeB, logging, [...refinements, isTypeB])
489
+ });
490
+ return checkTypes;
491
+ };
492
+ var isUnion = mustSatisfyOneOfTheFollowing(cannotExist);
493
+
494
+ // ../../anvl/src/refinement/is-intersection.ts
495
+ function mustSatisfyAllOfTheFollowing(isTypeA, logging = false, refinements = [isTypeA]) {
496
+ const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` & `)})`;
497
+ const _ = {
498
+ [name]: (input) => refinements.every(
499
+ (refinement) => (logging && console.log(
500
+ refinements.map((r) => r.name || `anon`).join(` & `),
501
+ `>`,
502
+ refinement.name || `anon`,
503
+ `:`,
504
+ refinement(input)
505
+ ), refinement(input))
506
+ )
507
+ };
508
+ const checkTypes = Object.assign(_[name], {
509
+ and: (isTypeB) => mustSatisfyAllOfTheFollowing(isTypeB, logging, [
510
+ ...refinements,
511
+ isTypeB
512
+ ])
513
+ });
514
+ return checkTypes;
515
+ }
516
+ var isIntersection = mustSatisfyAllOfTheFollowing(canExist);
517
+
518
+ // ../../anvl/src/refinement/index.ts
519
+ var isLiteral = (value) => (input) => input === value;
520
+ var isWithin = (args) => (input) => args.includes(input);
521
+
522
+ // ../../anvl/src/join/core-relation-data.ts
523
+ var RELATION_TYPES = [`1:1`, `1:n`, `n:n`];
524
+ var isRelationType = (x) => RELATION_TYPES.includes(x);
525
+ var EMPTY_RELATION_DATA = {
526
+ contents: {},
527
+ relations: {},
528
+ relationType: `n:n`,
529
+ a: `from`,
530
+ b: `to`
531
+ };
532
+ var isRelationData = ({
533
+ from: a2 = `from`,
534
+ to: b2 = `to`,
535
+ isContent
536
+ } = {}) => (input) => {
537
+ return hasExactProperties({
538
+ contents: isContent ? isRecord(isString, isContent) : hasExactProperties({}),
539
+ relations: isRecord(isString, isArray(isString)),
540
+ relationType: isRelationType,
541
+ a: isLiteral(a2),
542
+ b: isLiteral(b2)
543
+ })(input);
544
+ };
545
+
546
+ // ../../anvl/src/join/get-related-ids.ts
547
+ var getRelatedIds = (relationMap, id) => {
548
+ var _a2;
549
+ return (_a2 = relationMap.relations[id]) != null ? _a2 : [];
550
+ };
551
+ var getRelatedId = (relationMap, id) => {
552
+ const relations = getRelatedIds(relationMap, id);
553
+ if (relations.length > 1) {
554
+ console.warn(
555
+ `entry with id ${id} was not expected to have multiple relations`
556
+ );
557
+ }
558
+ return relations[0];
559
+ };
560
+
561
+ // ../../anvl/src/join/make-json-interface.ts
562
+ var makeJsonInterface = (join, ...params) => {
563
+ const isContent = params[0];
564
+ const { a: a2, b: b2 } = join;
565
+ const options = {
566
+ from: a2,
567
+ to: b2,
568
+ isContent
569
+ };
570
+ return {
571
+ toJson: (join2) => join2.toJSON(),
572
+ fromJson: (json) => Join.fromJSON(json, options)
573
+ };
574
+ };
575
+
576
+ // ../../anvl/src/join/relation-record.ts
577
+ var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).map((idB) => [
578
+ idB,
579
+ getContent(relationMap, idA, idB)
580
+ ]);
581
+ var getRelationRecord = (relationMap, id) => Object.fromEntries(getRelationEntries(relationMap, id));
582
+
583
+ // ../../anvl/src/string/split.ts
584
+ var split = (separator) => (str) => str.split(separator);
585
+
586
+ // ../../anvl/src/join/remove-relation.ts
587
+ var removeSpecific = (current, idA, idB) => {
588
+ const isIdForRemoval = isOneOf(idA, idB);
589
+ return __spreadProps(__spreadValues({}, current), {
590
+ relations: pipe(
591
+ current.relations,
592
+ recordToEntries,
593
+ map(([id, relations]) => [
594
+ id,
595
+ isIdForRemoval(id) ? relations.filter((relation) => !isIdForRemoval(relation)) : relations
596
+ ]),
597
+ entriesToRecord,
598
+ treeShake(isEmptyArray)
599
+ ),
600
+ contents: pipe(
601
+ current.contents,
602
+ treeShake(
603
+ (_, key) => isString(key) && pipe(key, split(`/`), comprises([idA, idB]))
604
+ )
605
+ )
606
+ });
607
+ };
608
+ var removeAll = (current, idToRemove) => {
609
+ const next = __spreadProps(__spreadValues({}, current), {
610
+ relations: pipe(
611
+ current.relations,
612
+ recordToEntries,
613
+ map(([id, relations]) => [
614
+ id,
615
+ relations.filter((relation) => relation !== idToRemove)
616
+ ]),
617
+ entriesToRecord,
618
+ treeShake((val, key) => key === idToRemove || isEmptyArray(val))
619
+ ),
620
+ contents: pipe(
621
+ current.contents,
622
+ treeShake(
623
+ (_, key) => isString(key) && key.split(`/`).includes(idToRemove)
624
+ )
625
+ )
626
+ });
627
+ return next;
628
+ };
629
+ var removeRelation = (current, relation) => {
630
+ const idA = relation[current.a];
631
+ const idB = relation[current.b];
632
+ return idB ? removeSpecific(current, idA, idB) : removeAll(current, idA);
633
+ };
634
+
635
+ // ../../anvl/src/join/set-relation.ts
636
+ var setManyToMany = (map2, idA, idB, ...rest) => {
637
+ var _a2, _b;
638
+ const next = __spreadProps(__spreadValues({}, map2), {
639
+ relations: __spreadProps(__spreadValues({}, map2.relations), {
640
+ [idA]: addTo((_a2 = map2.relations[idA]) != null ? _a2 : [])(idB),
641
+ [idB]: addTo((_b = map2.relations[idB]) != null ? _b : [])(idA)
642
+ })
643
+ });
644
+ const content = rest[0];
645
+ return content ? setContent(next, idA, idB, content) : next;
646
+ };
647
+ var removeEmpties = treeShake(isEmptyArray);
648
+ var set1ToMany = (current, leaderId, followerId, ...rest) => {
649
+ var _a2;
650
+ const relations = __spreadValues({}, current.relations);
651
+ const prevLeaderId = getRelatedId(current, followerId);
652
+ const next = __spreadProps(__spreadValues({}, current), {
653
+ relations: removeEmpties(__spreadProps(__spreadValues(__spreadValues({}, relations), prevLeaderId && prevLeaderId !== leaderId && {
654
+ [prevLeaderId]: relations[prevLeaderId].filter(
655
+ (id) => id !== followerId
656
+ )
657
+ }), {
658
+ [followerId]: [leaderId],
659
+ [leaderId]: addTo((_a2 = relations[leaderId]) != null ? _a2 : [])(followerId)
660
+ }))
661
+ });
662
+ const content = rest[0];
663
+ return content ? setContent(next, leaderId, followerId, content) : next;
664
+ };
665
+ var set1To1 = (current, wifeId, husbandId, ...rest) => {
666
+ const prevWifeId = getRelatedId(current, husbandId);
667
+ const prevHusbandId = getRelatedId(current, wifeId);
668
+ const next = __spreadProps(__spreadValues({}, current), {
669
+ relations: removeEmpties(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, current.relations), prevWifeId && { [prevWifeId]: [] }), prevHusbandId && { [prevHusbandId]: [] }), {
670
+ [wifeId]: [husbandId],
671
+ [husbandId]: [wifeId]
672
+ }))
673
+ });
674
+ const content = rest[0];
675
+ return content ? setContent(next, wifeId, husbandId, content) : next;
676
+ };
677
+ var setRelationWithContent = (current, relation, ...rest) => {
678
+ const { [current.a]: idA, [current.b]: idB } = relation;
679
+ switch (current.relationType) {
680
+ case `1:1`:
681
+ return set1To1(current, idA, idB, ...rest);
682
+ case `1:n`:
683
+ return set1ToMany(current, idA, idB, ...rest);
684
+ case `n:n`:
685
+ return setManyToMany(current, idA, idB, ...rest);
686
+ }
687
+ };
688
+
689
+ // ../../anvl/src/join/relation-contents.ts
690
+ var makeContentId = (idA, idB) => [idA, idB].sort().join(`/`);
691
+ var getContent = (relationMap, idA, idB) => relationMap.contents[makeContentId(idA, idB)];
692
+ var setContent = (map2, idA, idB, content) => __spreadProps(__spreadValues({}, map2), {
693
+ contents: __spreadProps(__spreadValues({}, map2.contents), {
694
+ [makeContentId(idA, idB)]: content
695
+ })
696
+ });
697
+ var getRelations = (relationMap, id) => getRelationEntries(relationMap, id).map(
698
+ ([id2, content]) => __spreadValues({
699
+ id: id2
700
+ }, content)
701
+ );
702
+ var setRelations = (current, subject, relations) => {
703
+ const idA = subject[current.a];
704
+ const idB = subject[current.b];
705
+ return pipe(
706
+ current,
707
+ (relationData) => {
708
+ const relatedIds = getRelatedIds(current, idA);
709
+ const removedIds = relatedIds.filter(
710
+ (id) => !relations.some((r) => r.id === id)
711
+ );
712
+ let step = relationData;
713
+ for (const id of removedIds) {
714
+ const remove = {
715
+ [current.a]: idA != null ? idA : id,
716
+ [current.b]: idB != null ? idB : id
717
+ };
718
+ step = removeRelation(step, remove);
719
+ }
720
+ return step;
721
+ },
722
+ (relationData) => {
723
+ let step = relationData;
724
+ for (const _a2 of relations) {
725
+ const _b = _a2, { id } = _b, rest = __objRest(_b, ["id"]);
726
+ const content = isEmptyObject(rest) ? void 0 : rest;
727
+ step = setRelationWithContent(
728
+ step,
729
+ { [current.a]: idA != null ? idA : id, [current.b]: idB != null ? idB : id },
730
+ // @ts-expect-error hacky
731
+ content
732
+ );
733
+ }
734
+ return step;
735
+ },
736
+ (relationData) => {
737
+ const newlyOrderedIds = relations.map((r) => r.id);
738
+ return __spreadProps(__spreadValues({}, relationData), {
739
+ relations: __spreadProps(__spreadValues({}, relationData.relations), {
740
+ [idA != null ? idA : idB]: newlyOrderedIds
741
+ })
742
+ });
743
+ }
744
+ );
745
+ };
746
+
747
+ // ../../anvl/src/join/index.ts
748
+ var Join = class _Join {
749
+ constructor(json) {
750
+ this.a = `from`;
751
+ this.b = `to`;
752
+ this.makeJsonInterface = (...params) => {
753
+ return makeJsonInterface(this, ...params);
754
+ };
755
+ Object.assign(this, __spreadProps(__spreadValues(__spreadValues({}, EMPTY_RELATION_DATA), json), {
756
+ makeJsonInterface: this.makeJsonInterface
757
+ }));
758
+ }
759
+ toJSON() {
760
+ return {
761
+ relationType: this.relationType,
762
+ relations: this.relations,
763
+ contents: this.contents,
764
+ a: this.a,
765
+ b: this.b
766
+ };
767
+ }
768
+ static fromJSON(json, options) {
769
+ const isValid = isRelationData(options)(json);
770
+ if (isValid) {
771
+ return new _Join(json);
772
+ }
773
+ throw new Error(
774
+ `Saved JSON for this Join is invalid: ${JSON.stringify(json)}`
775
+ );
776
+ }
777
+ from(newA) {
778
+ return new _Join(__spreadProps(__spreadValues({}, this), { a: newA }));
779
+ }
780
+ to(newB) {
781
+ return new _Join(__spreadProps(__spreadValues({}, this), { b: newB }));
782
+ }
783
+ getRelatedId(id) {
784
+ return getRelatedId(this, id);
785
+ }
786
+ getRelatedIds(id) {
787
+ return getRelatedIds(this, id);
788
+ }
789
+ getContent(idA, idB) {
790
+ return getContent(this, idA, idB);
791
+ }
792
+ getRelationEntries(id) {
793
+ return getRelationEntries(this, id);
794
+ }
795
+ getRelationRecord(id) {
796
+ return getRelationRecord(this, id);
797
+ }
798
+ getRelation(id) {
799
+ return getRelations(this, id)[0];
800
+ }
801
+ getRelations(id) {
802
+ return getRelations(this, id);
803
+ }
804
+ setRelations(subject, relations) {
805
+ return new _Join(setRelations(this, subject, relations));
806
+ }
807
+ set(relation, ...rest) {
808
+ return new _Join(setRelationWithContent(this, relation, ...rest));
809
+ }
810
+ remove(relation) {
811
+ return new _Join(
812
+ removeRelation(this, relation)
813
+ );
814
+ }
815
+ };
816
+ var ElasticInput = forwardRef(function ElasticInputFC(props, ref) {
817
+ var _a2, _b, _c, _d;
818
+ const inputRef = useRef(null);
819
+ const spanRef = useRef(null);
820
+ const [inputWidth, setInputWidth] = useState(`auto`);
821
+ useImperativeHandle(ref, () => ({
822
+ focus: () => {
823
+ var _a3;
824
+ (_a3 = inputRef.current) == null ? void 0 : _a3.focus();
825
+ }
826
+ }));
827
+ const extraWidth = props.type === `number` ? 15 : 0;
828
+ useLayoutEffect(() => {
829
+ if (spanRef.current) {
830
+ setInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`);
831
+ const interval = setInterval(() => {
832
+ if (spanRef.current) {
833
+ setInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`);
834
+ }
835
+ }, 1e3);
836
+ return () => clearInterval(interval);
837
+ }
838
+ }, [(_a2 = inputRef.current) == null ? void 0 : _a2.value, props.value]);
839
+ return /* @__PURE__ */ jsxs("div", { style: { display: `inline-block`, position: `relative` }, children: [
840
+ /* @__PURE__ */ jsx(
841
+ "input",
842
+ __spreadProps(__spreadValues({}, props), {
843
+ ref: inputRef,
844
+ style: __spreadValues({
845
+ padding: 0,
846
+ borderRadius: 0,
847
+ border: `none`,
848
+ fontFamily: `inherit`,
849
+ fontSize: `inherit`,
850
+ width: inputWidth
851
+ }, props.style)
852
+ })
853
+ ),
854
+ /* @__PURE__ */ jsx(
855
+ "span",
856
+ {
857
+ ref: spanRef,
858
+ style: {
859
+ padding: (_b = props.style) == null ? void 0 : _b.padding,
860
+ position: `absolute`,
861
+ visibility: `hidden`,
862
+ // color: `red`,
863
+ whiteSpace: `pre`,
864
+ fontFamily: ((_c = props.style) == null ? void 0 : _c.fontFamily) || `inherit`,
865
+ fontSize: ((_d = props.style) == null ? void 0 : _d.fontSize) || `inherit`
866
+ },
867
+ children: props.value
868
+ }
869
+ )
870
+ ] });
871
+ });
872
+
873
+ // ../../anvl/src/number/clamp.ts
874
+ var clampInto = (min, max) => (value) => value < min ? min : value > max ? max : value;
875
+
876
+ // ../../anvl/src/number/wrap.ts
877
+ var wrapInto = (min, max) => (value) => value < min ? max - (min - value) % (max - min) : min + (value - min) % (max - min);
878
+ function round(value, decimalPlaces) {
879
+ if (decimalPlaces === void 0)
880
+ return value;
881
+ const factor = 10 ** decimalPlaces;
882
+ return Math.round(value * factor) / factor;
883
+ }
884
+ var VALID_NON_NUMBERS = [``, `-`, `.`, `-.`];
885
+ var isValidNonNumber = (input) => VALID_NON_NUMBERS.includes(input);
886
+ var VALID_NON_NUMBER_INTERPRETATIONS = {
887
+ "": null,
888
+ "-": 0,
889
+ ".": 0,
890
+ "-.": 0
891
+ };
892
+ var isDecimalInProgress = (input) => input === `0` || !isNaN(Number(input)) && input.includes(`.`);
893
+ var textToValue = (input, allowDecimal) => {
894
+ if (isValidNonNumber(input))
895
+ return VALID_NON_NUMBER_INTERPRETATIONS[input];
896
+ return allowDecimal ? parseFloat(input) : Math.round(parseFloat(input));
897
+ };
898
+ var DEFAULT_NUMBER_CONSTRAINTS = {
899
+ max: Infinity,
900
+ min: -Infinity,
901
+ decimalPlaces: 100,
902
+ nullable: true
903
+ };
904
+ var initRefinery = (constraints) => (input) => {
905
+ if (input === null && constraints.nullable === true) {
906
+ return null;
907
+ }
908
+ const { max, min, decimalPlaces } = __spreadValues(__spreadValues({}, DEFAULT_NUMBER_CONSTRAINTS), constraints);
909
+ const constrained = pipe(
910
+ input != null ? input : 0,
911
+ clampInto(min, max),
912
+ (n) => decimalPlaces ? round(n, decimalPlaces) : n
913
+ );
914
+ return constrained;
915
+ };
916
+ var valueToText = (numericValue) => {
917
+ if (numericValue === null || numericValue === void 0) {
918
+ return ``;
919
+ }
920
+ return numericValue.toString();
921
+ };
922
+ var NumberInput = ({
923
+ autoSize = false,
924
+ customCss,
925
+ decimalPlaces,
926
+ disabled = false,
927
+ label,
928
+ max,
929
+ min,
930
+ name,
931
+ onChange,
932
+ onClick,
933
+ placeholder = ``,
934
+ set = () => null,
935
+ testId,
936
+ value = null
937
+ }) => {
938
+ const id = useId();
939
+ const [temporaryEntry, setTemporaryEntry] = useState(null);
940
+ const userHasMadeDeliberateChange = useRef(false);
941
+ const refine = initRefinery({ max, min, decimalPlaces, nullable: true });
942
+ const allowDecimal = decimalPlaces === void 0 || decimalPlaces > 0;
943
+ const handleBlur = () => {
944
+ if (userHasMadeDeliberateChange.current) {
945
+ set(refine(value != null ? value : null));
946
+ setTemporaryEntry(null);
947
+ }
948
+ userHasMadeDeliberateChange.current = false;
949
+ };
950
+ const handleChange = (event) => {
951
+ var _a2;
952
+ if (onChange)
953
+ onChange(event);
954
+ if (set === void 0)
955
+ return;
956
+ userHasMadeDeliberateChange.current = true;
957
+ const input = event.target.value;
958
+ if (isValidNonNumber(input) || isDecimalInProgress(input)) {
959
+ setTemporaryEntry(input);
960
+ const textInterpretation = isDecimalInProgress(input) ? input : (_a2 = min == null ? void 0 : min.toString()) != null ? _a2 : `0`;
961
+ const newValue = textToValue(textInterpretation, allowDecimal);
962
+ set(refine(newValue));
963
+ return;
964
+ }
965
+ setTemporaryEntry(null);
966
+ const inputIsNumeric = !isNaN(Number(input)) && !input.includes(` `) || allowDecimal && input === `.` || allowDecimal && input === `-.` || input === `` || input === `-`;
967
+ const numericValue = textToValue(input, allowDecimal);
968
+ if (inputIsNumeric) {
969
+ set(refine(numericValue));
970
+ }
971
+ };
972
+ const displayValue = temporaryEntry != null ? temporaryEntry : valueToText(value ? refine(value) : value);
973
+ return /* @__PURE__ */ jsxs("span", { css: customCss, children: [
974
+ label && /* @__PURE__ */ jsx("label", { htmlFor: id, children: label }),
975
+ autoSize ? /* @__PURE__ */ jsx(
976
+ ElasticInput,
977
+ {
978
+ type: "text",
979
+ value: displayValue,
980
+ placeholder: placeholder != null ? placeholder : `-`,
981
+ onChange: handleChange,
982
+ onBlur: handleBlur,
983
+ disabled,
984
+ name: name != null ? name : id,
985
+ id,
986
+ onClick,
987
+ "data-testid": `number-input-${testId != null ? testId : id}`
988
+ }
989
+ ) : /* @__PURE__ */ jsx(
990
+ "input",
991
+ {
992
+ type: "text",
993
+ value: displayValue,
994
+ placeholder: placeholder != null ? placeholder : `-`,
995
+ onChange: handleChange,
996
+ onBlur: handleBlur,
997
+ disabled,
998
+ name: name != null ? name : id,
999
+ id,
1000
+ onClick,
1001
+ "data-testid": `number-input-${testId != null ? testId : id}`
1002
+ }
1003
+ )
1004
+ ] });
1005
+ };
1006
+ var TextInput = ({
1007
+ value,
1008
+ set,
1009
+ label,
1010
+ placeholder,
1011
+ customCss,
1012
+ autoSize = false
1013
+ }) => {
1014
+ return /* @__PURE__ */ jsxs("span", { css: customCss, children: [
1015
+ /* @__PURE__ */ jsx("label", { children: label }),
1016
+ autoSize ? /* @__PURE__ */ jsx(
1017
+ ElasticInput,
1018
+ {
1019
+ type: "text",
1020
+ value,
1021
+ onChange: (e) => set == null ? void 0 : set(e.target.value),
1022
+ disabled: set === void 0,
1023
+ placeholder
1024
+ }
1025
+ ) : /* @__PURE__ */ jsx(
1026
+ "input",
1027
+ {
1028
+ type: "text",
1029
+ value,
1030
+ onChange: (e) => set == null ? void 0 : set(e.target.value),
1031
+ disabled: set === void 0,
1032
+ placeholder
1033
+ }
1034
+ )
1035
+ ] });
1036
+ };
1037
+ var NonJsonEditor = ({ data }) => {
1038
+ return data === void 0 ? /* @__PURE__ */ jsx(ElasticInput, { disabled: true, value: "undefined" }) : /* @__PURE__ */ jsx(
1039
+ ElasticInput,
1040
+ {
1041
+ disabled: true,
1042
+ value: Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data)
1043
+ }
1044
+ );
1045
+ };
1046
+ var JsonEditor_INTERNAL = ({
1047
+ data,
1048
+ set,
1049
+ schema,
1050
+ name,
1051
+ rename,
1052
+ remove,
1053
+ recast,
1054
+ path = [],
1055
+ isReadonly = () => false,
1056
+ isHidden = () => false,
1057
+ className,
1058
+ customCss,
1059
+ Header: HeaderDisplay,
1060
+ Components
1061
+ }) => {
1062
+ const dataIsJson = isJson(data);
1063
+ const refined = dataIsJson ? refineJsonType(data) : { type: `non-json`, data };
1064
+ const SubEditor = dataIsJson ? SubEditors[refined.type] : NonJsonEditor;
1065
+ const disabled = isReadonly(path);
1066
+ return isHidden(path) ? null : /* @__PURE__ */ jsx(Components.ErrorBoundary, { children: /* @__PURE__ */ jsxs(Components.EditorWrapper, { className, customCss, children: [
1067
+ remove && /* @__PURE__ */ jsx(
1068
+ Components.Button,
1069
+ {
1070
+ onClick: disabled ? doNothing : remove,
1071
+ disabled,
1072
+ children: /* @__PURE__ */ jsx(Components.DeleteIcon, {})
1073
+ }
1074
+ ),
1075
+ HeaderDisplay && /* @__PURE__ */ jsx(HeaderDisplay, { data, schema }),
1076
+ rename && /* @__PURE__ */ jsx(Components.KeyWrapper, { children: /* @__PURE__ */ jsx(
1077
+ ElasticInput,
1078
+ {
1079
+ value: name,
1080
+ onChange: disabled ? doNothing : (e) => rename(e.target.value),
1081
+ disabled
1082
+ }
1083
+ ) }),
1084
+ /* @__PURE__ */ jsx(
1085
+ SubEditor,
1086
+ {
1087
+ data: refined.data,
1088
+ set,
1089
+ schema,
1090
+ remove,
1091
+ rename,
1092
+ path,
1093
+ isReadonly,
1094
+ isHidden,
1095
+ Components
1096
+ }
1097
+ ),
1098
+ recast && dataIsJson ? /* @__PURE__ */ jsx(
1099
+ "select",
1100
+ {
1101
+ onChange: disabled ? doNothing : (e) => recast(e.target.value),
1102
+ value: refined.type,
1103
+ disabled,
1104
+ children: Object.keys(SubEditors).map((type) => /* @__PURE__ */ jsx("option", { value: type, children: type }, type))
1105
+ }
1106
+ ) : null
1107
+ ] }) });
1108
+ };
1109
+
1110
+ // ../../hamr/src/react-json-editor/editors-by-type/utilities/array-elements.ts
1111
+ var makeElementSetters = (data, set) => data.map(
1112
+ (value, index) => (newValue) => set(() => {
1113
+ const newData = [...data];
1114
+ newData[index] = become(newValue)(value);
1115
+ return newData;
1116
+ })
1117
+ );
1118
+ var ArrayEditor = ({
1119
+ path = [],
1120
+ isReadonly = () => false,
1121
+ isHidden = () => false,
1122
+ data,
1123
+ set,
1124
+ Components
1125
+ }) => {
1126
+ const setElement = makeElementSetters(data, set);
1127
+ return /* @__PURE__ */ jsx(Fragment, { children: data.map((element, index) => {
1128
+ const newPath = [...path, index];
1129
+ return /* @__PURE__ */ jsx(
1130
+ JsonEditor_INTERNAL,
1131
+ {
1132
+ path: newPath,
1133
+ isReadonly,
1134
+ isHidden,
1135
+ data: element,
1136
+ set: setElement[index],
1137
+ Components
1138
+ },
1139
+ newPath.join(``)
1140
+ );
1141
+ }) });
1142
+ };
1143
+
1144
+ // ../../anvl/src/json-schema/integer.ts
1145
+ var isInteger = (input) => Number.isInteger(input);
1146
+ var parseInteger = (input) => {
1147
+ if (isInteger(input))
1148
+ return input;
1149
+ throw new IntegerParseError(input);
1150
+ };
1151
+ var _a;
1152
+ var Fraction = class extends Number {
1153
+ constructor(n, d) {
1154
+ super(n / d);
1155
+ this[_a] = () => this.numerator / this.denominator;
1156
+ if (d === 0) {
1157
+ throw new Error(`Denominator cannot be zero`);
1158
+ }
1159
+ this.numerator = parseInteger(n);
1160
+ this.denominator = parseInteger(d);
1161
+ }
1162
+ };
1163
+ _a = Symbol.toPrimitive;
1164
+ var IntegerParseError = class extends Error {
1165
+ constructor(value) {
1166
+ super(`Could not parse integer from ${JSON.stringify(value)}`);
1167
+ }
1168
+ };
1169
+ var Int = Object.assign((input) => parseInteger(input), {
1170
+ from: (input) => pipe(
1171
+ input,
1172
+ String,
1173
+ parseFloat,
1174
+ (num) => isInteger(num) ? {
1175
+ value: num,
1176
+ error: null,
1177
+ round: null,
1178
+ upper: null,
1179
+ lower: null,
1180
+ ratio: null
1181
+ } : {
1182
+ value: null,
1183
+ error: new IntegerParseError(input),
1184
+ round: Math.round(num),
1185
+ upper: Math.ceil(num),
1186
+ lower: Math.floor(num),
1187
+ ratio: null
1188
+ }
1189
+ ),
1190
+ formula: (fm) => {
1191
+ return (input) => {
1192
+ return fm(
1193
+ input
1194
+ );
1195
+ };
1196
+ }
1197
+ });
1198
+ function asNumber(input) {
1199
+ return input;
1200
+ }
1201
+ asNumber(new Fraction(1, 2));
1202
+ asNumber([new Fraction(1, 2)]);
1203
+ asNumber({ a: new Fraction(1, 2) });
1204
+
1205
+ // ../../anvl/src/json-schema/refs.ts
1206
+ function isJsonSchemaRef(input) {
1207
+ return doesExtend({
1208
+ $ref: isString
1209
+ })(input);
1210
+ }
1211
+ ({
1212
+ $defs: {
1213
+ colorChannel: {
1214
+ type: `integer`,
1215
+ minimum: Int(0),
1216
+ maximum: Int(255)
1217
+ },
1218
+ color: {
1219
+ type: `object`,
1220
+ properties: {
1221
+ red: { $ref: `#/$defs/colorChannel` },
1222
+ green: { $ref: `#/$defs/colorChannel` },
1223
+ blue: { $ref: `#/$defs/colorChannel` }
1224
+ }
1225
+ }
1226
+ },
1227
+ type: `array`,
1228
+ items: {
1229
+ $ref: `#/$defs/color`
1230
+ }
1231
+ });
1232
+ var retrieveRef = ({
1233
+ refNode: { $ref },
1234
+ refMap = {},
1235
+ root
1236
+ }) => {
1237
+ if (typeof root === `boolean`) {
1238
+ throw new TypeError(`The root is a boolean and cannot be indexed`);
1239
+ }
1240
+ if ($ref in refMap)
1241
+ return { node: refMap[$ref], refMap };
1242
+ const [_, ...refPath] = $ref.split(`/`);
1243
+ const discovery = delve(root, refPath);
1244
+ if (discovery instanceof Error)
1245
+ throw discovery;
1246
+ let node = discovery.found;
1247
+ while (isJsonSchemaRef(node)) {
1248
+ const result = retrieveRef({ refNode: node, refMap, root });
1249
+ node = result.node;
1250
+ refMap = result.refMap;
1251
+ }
1252
+ if (isJsonSchema(node)) {
1253
+ return { node, refMap: __spreadProps(__spreadValues({}, refMap), { [$ref]: node }) };
1254
+ }
1255
+ throw new TypeError(`The refNode is not a JsonSchema`);
1256
+ };
1257
+
1258
+ // ../../anvl/src/json-schema/string-formats.ts
1259
+ var JSON_SCHEMA_STRING_FORMATS = [
1260
+ `date-time`,
1261
+ `date`,
1262
+ `email`,
1263
+ `hostname`,
1264
+ `ipv4`,
1265
+ `ipv6`,
1266
+ `regex`,
1267
+ `time`,
1268
+ `uri-reference`,
1269
+ `uri-template`,
1270
+ `uri`,
1271
+ `uuid`
1272
+ ];
1273
+
1274
+ // ../../anvl/src/json-schema/json-schema.ts
1275
+ var JSON_SCHEMA_TYPE_NAMES = [...JSON_TYPE_NAMES, `integer`];
1276
+ [
1277
+ ...JSON_SCHEMA_TYPE_NAMES,
1278
+ `any`,
1279
+ `never`
1280
+ ];
1281
+ var stringSchemaStructure = {
1282
+ type: isLiteral(`string`),
1283
+ enum: ifDefined(isArray(isString)),
1284
+ minLength: ifDefined(isInteger),
1285
+ maxLength: ifDefined(isInteger),
1286
+ pattern: ifDefined(isString),
1287
+ format: ifDefined(isWithin(JSON_SCHEMA_STRING_FORMATS))
1288
+ };
1289
+ function isStringSchema(input) {
1290
+ return doesExtend(stringSchemaStructure)(input);
1291
+ }
1292
+ var numberSchemaStructure = {
1293
+ type: isLiteral(`number`),
1294
+ enum: ifDefined(isArray(isNumber)),
1295
+ minimum: ifDefined(isNumber),
1296
+ maximum: ifDefined(isNumber),
1297
+ exclusiveMinimum: ifDefined(isNumber),
1298
+ exclusiveMaximum: ifDefined(isNumber),
1299
+ multipleOf: ifDefined(isNumber)
1300
+ };
1301
+ function isNumberSchema(input) {
1302
+ return doesExtend(numberSchemaStructure)(input);
1303
+ }
1304
+ var integerSchemaStructure = {
1305
+ type: isLiteral(`integer`),
1306
+ enum: ifDefined(isArray(isInteger)),
1307
+ minimum: ifDefined(isInteger),
1308
+ maximum: ifDefined(isInteger),
1309
+ exclusiveMinimum: ifDefined(isInteger),
1310
+ exclusiveMaximum: ifDefined(isInteger),
1311
+ multipleOf: ifDefined(isInteger)
1312
+ };
1313
+ function isIntegerSchema(input) {
1314
+ return doesExtend(integerSchemaStructure)(input);
1315
+ }
1316
+ var booleanSchemaStructure = {
1317
+ type: isLiteral(`boolean`),
1318
+ enum: ifDefined(isArray(isBoolean))
1319
+ };
1320
+ function isBooleanSchema(input) {
1321
+ return doesExtend(booleanSchemaStructure)(input);
1322
+ }
1323
+ var nullSchemaStructure = {
1324
+ type: isLiteral(`null`)
1325
+ };
1326
+ function isNullSchema(input) {
1327
+ return doesExtend(nullSchemaStructure)(input);
1328
+ }
1329
+ var objectSchemaStructure = {
1330
+ type: isLiteral(`object`),
1331
+ properties: ifDefined(isRecord(isString, isJsonSchema)),
1332
+ required: ifDefined(isArray(isString)),
1333
+ additionalProperties: ifDefined(isJsonSchema),
1334
+ propertyNames: ifDefined(isStringSchema),
1335
+ minProperties: ifDefined(isInteger),
1336
+ maxProperties: ifDefined(isInteger),
1337
+ dependentSchemas: ifDefined(isRecord(isString, isJsonSchema))
1338
+ };
1339
+ function isObjectSchema(input) {
1340
+ return doesExtend(objectSchemaStructure)(input);
1341
+ }
1342
+ var arraySchemaStructure = {
1343
+ type: isLiteral(`array`),
1344
+ items: ifDefined(
1345
+ mustSatisfyOneOfTheFollowing(isJsonSchema).or(isArray(isJsonSchema))
1346
+ ),
1347
+ minItems: ifDefined(isInteger),
1348
+ maxItems: ifDefined(isInteger),
1349
+ uniqueItems: ifDefined(isBoolean)
1350
+ };
1351
+ function isArraySchema(input) {
1352
+ return doesExtend(arraySchemaStructure)(input);
1353
+ }
1354
+ var unionSchemaStructure = { anyOf: isArray(isJsonSchema) };
1355
+ function isUnionSchema(input) {
1356
+ return doesExtend(unionSchemaStructure)(input);
1357
+ }
1358
+ var exclusiveSchemaStructure = { oneOf: isArray(isJsonSchema) };
1359
+ function isExclusiveSchema(input) {
1360
+ return doesExtend(exclusiveSchemaStructure)(input);
1361
+ }
1362
+ var intersectionSchemaStructure = { allOf: isArray(isJsonSchema) };
1363
+ function isIntersectionSchema(input) {
1364
+ return doesExtend(intersectionSchemaStructure)(input);
1365
+ }
1366
+ var conditionalSchemaStructure = {
1367
+ if: isJsonSchema,
1368
+ then: ifDefined(isJsonSchema),
1369
+ else: ifDefined(isJsonSchema)
1370
+ };
1371
+ function isConditionalSchema(input) {
1372
+ return doesExtend(conditionalSchemaStructure)(input);
1373
+ }
1374
+ var negationSchemaStructure = { not: isJsonSchema };
1375
+ function isNegationSchema(input) {
1376
+ return doesExtend(negationSchemaStructure)(input);
1377
+ }
1378
+ var mixedSchemaStructure = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, arraySchemaStructure), booleanSchemaStructure), integerSchemaStructure), nullSchemaStructure), numberSchemaStructure), objectSchemaStructure), stringSchemaStructure), {
1379
+ type: isArray(isWithin(JSON_SCHEMA_TYPE_NAMES)),
1380
+ enum: ifDefined(
1381
+ isArray(isUnion.or(isInteger).or(isBoolean).or(isNumber).or(isString))
1382
+ )
1383
+ });
1384
+ function isMixedSchema(input) {
1385
+ return doesExtend(mixedSchemaStructure)(input);
1386
+ }
1387
+ var isJsonSchemaCore = isUnion.or(isArraySchema).or(isBooleanSchema).or(isConditionalSchema).or(isExclusiveSchema).or(isIntegerSchema).or(isIntersectionSchema).or(isMixedSchema).or(isNegationSchema).or(isNullSchema).or(isNumberSchema).or(isObjectSchema).or(isStringSchema).or(isUnionSchema);
1388
+ var isJsonSchemaRoot = doesExtend({
1389
+ $id: ifDefined(isString),
1390
+ $schema: ifDefined(isString)
1391
+ });
1392
+ var isJsonSchemaObject = isIntersection.and(isJsonSchemaCore).and(isJsonSchemaRoot);
1393
+ function isJsonSchema(input) {
1394
+ return mustSatisfyOneOfTheFollowing(isBoolean).or(isJsonSchemaObject).or(isJsonSchemaRef)(input);
1395
+ }
1396
+
1397
+ // ../../anvl/src/json-schema/path-into.ts
1398
+ var expandPathForSchema = (path) => {
1399
+ try {
1400
+ return path.flatMap((key) => {
1401
+ switch (typeof key) {
1402
+ case `string`:
1403
+ return [`properties`, key];
1404
+ case `number`:
1405
+ return [`items`, key];
1406
+ case `symbol`:
1407
+ throw new TypeError(
1408
+ `The key ${String(
1409
+ key
1410
+ )} is not a valid JSON key; expected string or number, got symbol`
1411
+ );
1412
+ default:
1413
+ throw new TypeError(
1414
+ `The key ${key} is not a valid JSON key; expected string or number, got ${typeof key}`
1415
+ );
1416
+ }
1417
+ });
1418
+ } catch (caught) {
1419
+ if (caught instanceof TypeError)
1420
+ return caught;
1421
+ throw caught;
1422
+ }
1423
+ };
1424
+
1425
+ // ../../anvl/src/json-schema/find-sub-schema.ts
1426
+ var findSubSchema = (schema) => {
1427
+ if (typeof schema === `boolean`) {
1428
+ throw new Error(`The schema does not contain subSchemas`);
1429
+ }
1430
+ return (path) => {
1431
+ const pathIntoSchema = expandPathForSchema(path);
1432
+ if (pathIntoSchema instanceof Error)
1433
+ return pathIntoSchema;
1434
+ if (typeof schema === `boolean`) {
1435
+ return new TypeError(`The schema is not a JsonSchema`);
1436
+ }
1437
+ const { node, refMap } = pathIntoSchema.reduce(
1438
+ ({ node: node2, refMap: refMap2 = void 0 }, key) => (console.log({ node: node2, key }), isJsonSchemaRef(node2) ? retrieveRef({ refNode: node2, root: schema, refMap: refMap2 }) : { node: node2[key], refMap: refMap2 }),
1439
+ { node: schema, refMap: void 0 }
1440
+ );
1441
+ if (node instanceof Error)
1442
+ throw node;
1443
+ let subSchema = node;
1444
+ while (isJsonSchemaRef(subSchema)) {
1445
+ console.log({ subSchema });
1446
+ subSchema = retrieveRef({ refNode: subSchema, root: schema, refMap }).node;
1447
+ }
1448
+ console.log({ subSchema });
1449
+ if (isJsonSchema(subSchema)) {
1450
+ return subSchema;
1451
+ }
1452
+ throw new TypeError(`The subSchema is not a JsonSchema`);
1453
+ };
1454
+ };
1455
+
1456
+ // ../../anvl/src/json/cast-json.ts
1457
+ var stringToBoolean = (str) => str === `true`;
1458
+ var stringToNumber = (str) => Number(str);
1459
+ var stringToArray = (str) => str.split(`,`);
1460
+ var stringToObject = (str) => {
1461
+ try {
1462
+ return JSON.parse(str);
1463
+ } catch (e) {
1464
+ return { [str]: str };
1465
+ }
1466
+ };
1467
+ var objectToString = (obj) => JSON.stringify(obj);
1468
+ var objectToBoolean = (obj) => obj.true === true;
1469
+ var objectToNumber = (obj) => {
1470
+ var _a2, _b, _c;
1471
+ return Number((_c = (_b = (_a2 = obj.number) != null ? _a2 : obj.size) != null ? _b : obj.count) != null ? _c : 0);
1472
+ };
1473
+ var objectToArray = (obj) => Object.entries(obj);
1474
+ var booleanToString = (bool) => bool.toString();
1475
+ var booleanToNumber = (bool) => +bool;
1476
+ var booleanToObject = (bool) => ({
1477
+ [bool.toString()]: bool
1478
+ });
1479
+ var booleanToArray = (bool) => [bool];
1480
+ var numberToString = (num) => num.toString();
1481
+ var numberToBoolean = (num) => num === 1;
1482
+ var numberToObject = (num) => ({
1483
+ number: num
1484
+ });
1485
+ var numberToArray = (num) => Array(num).fill(null);
1486
+ var arrayToString = (arr) => arr.join(`,`);
1487
+ var arrayToNumber = (arr) => arr.length;
1488
+ var arrayToBoolean = (arr) => typeof arr[0] === `boolean` ? arr[0] : arr.length > 0;
1489
+ var arrayToObject = (arr) => arr.reduce((acc, cur, idx) => {
1490
+ acc[`${idx}`] = cur;
1491
+ return acc;
1492
+ }, {});
1493
+ var nullToString = () => ``;
1494
+ var nullToNumber = () => 0;
1495
+ var nullToBoolean = () => false;
1496
+ var nullToArray = () => [];
1497
+ var nullToObject = () => ({});
1498
+
1499
+ // ../../anvl/src/refinement/smart-cast-json.ts
1500
+ var castToJson = (input) => {
1501
+ const json = refineJsonType(input);
1502
+ return {
1503
+ to: {
1504
+ array: () => {
1505
+ switch (json.type) {
1506
+ case `array`:
1507
+ return json.data;
1508
+ case `object`:
1509
+ return objectToArray(json.data);
1510
+ case `string`:
1511
+ return stringToArray(json.data);
1512
+ case `boolean`:
1513
+ return booleanToArray(json.data);
1514
+ case `number`:
1515
+ return numberToArray(json.data);
1516
+ case `null`:
1517
+ return nullToArray();
1518
+ }
1519
+ },
1520
+ boolean: () => {
1521
+ switch (json.type) {
1522
+ case `array`:
1523
+ return arrayToBoolean(json.data);
1524
+ case `object`:
1525
+ return objectToBoolean(json.data);
1526
+ case `string`:
1527
+ return stringToBoolean(json.data);
1528
+ case `boolean`:
1529
+ return json.data;
1530
+ case `number`:
1531
+ return numberToBoolean(json.data);
1532
+ case `null`:
1533
+ return nullToBoolean();
1534
+ }
1535
+ },
1536
+ number: () => {
1537
+ switch (json.type) {
1538
+ case `array`:
1539
+ return arrayToNumber(json.data);
1540
+ case `object`:
1541
+ return objectToNumber(json.data);
1542
+ case `string`:
1543
+ return stringToNumber(json.data);
1544
+ case `boolean`:
1545
+ return booleanToNumber(json.data);
1546
+ case `number`:
1547
+ return json.data;
1548
+ case `null`:
1549
+ return nullToNumber();
1550
+ }
1551
+ },
1552
+ object: () => {
1553
+ switch (json.type) {
1554
+ case `array`:
1555
+ return arrayToObject(json.data);
1556
+ case `object`:
1557
+ return json.data;
1558
+ case `string`:
1559
+ return stringToObject(json.data);
1560
+ case `boolean`:
1561
+ return booleanToObject(json.data);
1562
+ case `number`:
1563
+ return numberToObject(json.data);
1564
+ case `null`:
1565
+ return nullToObject();
1566
+ }
1567
+ },
1568
+ string: () => {
1569
+ switch (json.type) {
1570
+ case `array`:
1571
+ return arrayToString(json.data);
1572
+ case `object`:
1573
+ return objectToString(json.data);
1574
+ case `string`:
1575
+ return json.data;
1576
+ case `boolean`:
1577
+ return booleanToString(json.data);
1578
+ case `number`:
1579
+ return numberToString(json.data);
1580
+ case `null`:
1581
+ return nullToString();
1582
+ }
1583
+ },
1584
+ null: () => null
1585
+ }
1586
+ };
1587
+ };
1588
+
1589
+ // ../../hamr/src/react-json-editor/editors-by-type/utilities/object-properties.ts
1590
+ var makePropertySetters = (data, set) => mapObject(
1591
+ data,
1592
+ (value, key) => (newValue) => set(__spreadProps(__spreadValues({}, data), { [key]: become(newValue)(value[key]) }))
1593
+ );
1594
+ var makePropertyRenamers = (data, set, stableKeyMapRef) => mapObject(
1595
+ data,
1596
+ (value, key) => (newKey) => Object.hasOwn(data, newKey) ? null : set(() => {
1597
+ const entries = Object.entries(data);
1598
+ const index = entries.findIndex(([k]) => k === key);
1599
+ entries[index] = [newKey, value];
1600
+ const stableKeyMap = stableKeyMapRef.current;
1601
+ stableKeyMapRef.current = __spreadProps(__spreadValues({}, stableKeyMap), {
1602
+ [newKey]: stableKeyMap[key]
1603
+ });
1604
+ return Object.fromEntries(entries);
1605
+ })
1606
+ );
1607
+ var makePropertyRemovers = (data, set) => mapObject(
1608
+ data,
1609
+ (_, key) => () => set(() => {
1610
+ const _a2 = data, rest = __objRest(_a2, [__restKey(key)]);
1611
+ return rest;
1612
+ })
1613
+ );
1614
+ var makePropertyRecasters = (data, set) => mapObject(
1615
+ data,
1616
+ (value, key) => (newType) => set(() => __spreadProps(__spreadValues({}, data), {
1617
+ [key]: castToJson(value).to[newType]()
1618
+ }))
1619
+ );
1620
+ var makePropertyCreationInterface = (data, set) => (key, type) => (value) => set(__spreadProps(__spreadValues({}, data), { [key]: value != null ? value : JSON_DEFAULTS[type] }));
1621
+ var makePropertySorter = (data, set, sortFn) => () => {
1622
+ const sortedKeys = Object.keys(data).sort(sortFn);
1623
+ const sortedObj = {};
1624
+ sortedKeys.forEach((key) => sortedObj[key] = data[key]);
1625
+ set(sortedObj);
1626
+ };
1627
+ var PropertyAdder = ({
1628
+ addProperty,
1629
+ disabled,
1630
+ propertyKey,
1631
+ Components
1632
+ }) => /* @__PURE__ */ jsxs(Components.MissingPropertyWrapper, { children: [
1633
+ /* @__PURE__ */ jsx(ElasticInput, { disabled: true, defaultValue: propertyKey }),
1634
+ ` `,
1635
+ /* @__PURE__ */ jsx(ElasticInput, { disabled: true, defaultValue: "is missing" }),
1636
+ /* @__PURE__ */ jsx(Components.Button, { onClick: () => addProperty(), disabled, children: "+" })
1637
+ ] });
1638
+ var ObjectEditor = ({
1639
+ schema,
1640
+ path = [],
1641
+ isReadonly = () => false,
1642
+ isHidden = () => false,
1643
+ data,
1644
+ set,
1645
+ Components
1646
+ }) => {
1647
+ var _a2;
1648
+ const disabled = isReadonly(path);
1649
+ const stableKeyMap = useRef(
1650
+ Object.keys(data).reduce((acc, key) => {
1651
+ acc[key] = key;
1652
+ return acc;
1653
+ }, {})
1654
+ );
1655
+ const setProperty = makePropertySetters(data, set);
1656
+ const renameProperty = makePropertyRenamers(data, set, stableKeyMap);
1657
+ const removeProperty = makePropertyRemovers(data, set);
1658
+ const recastProperty = makePropertyRecasters(data, set);
1659
+ const sortProperties = makePropertySorter(data, set);
1660
+ const makePropertyAdder = makePropertyCreationInterface(data, set);
1661
+ const subSchema = isPlainObject(schema) ? findSubSchema(schema)(path) : true;
1662
+ const schemaKeys = isLiteral(true)(subSchema) ? true : isObjectSchema(subSchema) ? Object.keys((_a2 = subSchema.properties) != null ? _a2 : {}) : [];
1663
+ const dataKeys = Object.keys(data);
1664
+ const [unofficialKeys, officialKeys] = dataKeys.reduce(
1665
+ ([unofficial, official], key) => {
1666
+ const isOfficial = schemaKeys === true || schemaKeys.includes(key);
1667
+ return isOfficial ? [unofficial, [...official, key]] : [[...unofficial, key], official];
1668
+ },
1669
+ [[], []]
1670
+ );
1671
+ const missingKeys = schemaKeys === true ? [] : schemaKeys.filter((key) => !dataKeys.includes(key));
1672
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1673
+ /* @__PURE__ */ jsx(Components.Button, { onClick: () => sortProperties(), disabled, children: "Sort" }),
1674
+ /* @__PURE__ */ jsxs(Components.ObjectWrapper, { children: [
1675
+ /* @__PURE__ */ jsx("div", { className: "json_editor_properties", children: [...missingKeys, ...officialKeys, ...unofficialKeys].map((key) => {
1676
+ const originalKey = stableKeyMap.current[key];
1677
+ const newPath = [...path, key];
1678
+ const originalPath = [...path, originalKey];
1679
+ const isOfficial = schemaKeys === true || schemaKeys.includes(key);
1680
+ const isMissing = missingKeys.includes(key);
1681
+ return isMissing ? /* @__PURE__ */ jsx(
1682
+ PropertyAdder,
1683
+ {
1684
+ propertyKey: key,
1685
+ addProperty: makePropertyAdder(key, `string`),
1686
+ disabled,
1687
+ Components
1688
+ },
1689
+ key + `IsMissing`
1690
+ ) : /* @__PURE__ */ jsx(
1691
+ JsonEditor_INTERNAL,
1692
+ {
1693
+ schema,
1694
+ path: newPath,
1695
+ name: key,
1696
+ isReadonly,
1697
+ isHidden,
1698
+ data: data[key],
1699
+ set: setProperty[key],
1700
+ rename: renameProperty[key],
1701
+ remove: removeProperty[key],
1702
+ recast: recastProperty[key],
1703
+ className: `json_editor_property ${isOfficial ? `json_editor_official` : `json_editor_unofficial`}`,
1704
+ Components
1705
+ },
1706
+ originalPath.join(`.`)
1707
+ );
1708
+ }) }),
1709
+ /* @__PURE__ */ jsx(
1710
+ Components.Button,
1711
+ {
1712
+ onClick: disabled ? doNothing : () => makePropertyAdder(`new_property`, `string`)(),
1713
+ disabled,
1714
+ children: "+"
1715
+ }
1716
+ )
1717
+ ] })
1718
+ ] });
1719
+ };
1720
+ var BooleanEditor = ({
1721
+ data,
1722
+ set,
1723
+ Components
1724
+ }) => /* @__PURE__ */ jsx(Components.BooleanWrapper, { children: /* @__PURE__ */ jsx(
1725
+ "input",
1726
+ {
1727
+ type: "checkbox",
1728
+ checked: data,
1729
+ onChange: (event) => set(event.target.checked)
1730
+ }
1731
+ ) });
1732
+ var NullEditor = ({
1733
+ Components
1734
+ }) => /* @__PURE__ */ jsx(Components.NullWrapper, { children: '" "' });
1735
+ var NumberEditor = ({
1736
+ path = [],
1737
+ isReadonly = () => false,
1738
+ data,
1739
+ set,
1740
+ Components
1741
+ }) => /* @__PURE__ */ jsx(Components.NumberWrapper, { children: /* @__PURE__ */ jsx(
1742
+ NumberInput,
1743
+ {
1744
+ value: data,
1745
+ set: isReadonly(path) ? void 0 : (newValue) => set(Number(newValue)),
1746
+ autoSize: true
1747
+ }
1748
+ ) });
1749
+ var StringEditor = ({
1750
+ path = [],
1751
+ isReadonly = () => false,
1752
+ data,
1753
+ set,
1754
+ Components
1755
+ }) => {
1756
+ return /* @__PURE__ */ jsx(Components.StringWrapper, { children: /* @__PURE__ */ jsx(
1757
+ TextInput,
1758
+ {
1759
+ value: data,
1760
+ set: isReadonly(path) ? void 0 : set,
1761
+ autoSize: true
1762
+ }
1763
+ ) });
1764
+ };
1765
+ var DefaultFallback = ({ error, errorInfo }) => {
1766
+ var _a2, _b;
1767
+ const component = errorInfo == null ? void 0 : errorInfo.componentStack.split(` `).filter(Boolean)[2];
1768
+ const message = (_b = (_a2 = error == null ? void 0 : error.toString()) != null ? _a2 : errorInfo == null ? void 0 : errorInfo.componentStack) != null ? _b : `Unknown error`;
1769
+ return /* @__PURE__ */ jsx(
1770
+ "div",
1771
+ {
1772
+ "data-testid": "error-boundary",
1773
+ style: {
1774
+ flex: `1`,
1775
+ background: `black`,
1776
+ backgroundImage: `url(./src/assets/kablooey.gif)`,
1777
+ backgroundPosition: `center`,
1778
+ // backgroundRepeat: `no-repeat`,
1779
+ backgroundSize: `overlay`
1780
+ },
1781
+ children: /* @__PURE__ */ jsx(
1782
+ "div",
1783
+ {
1784
+ style: {
1785
+ margin: `50px`,
1786
+ marginTop: `0`,
1787
+ padding: `50px`,
1788
+ border: `1px solid dashed`
1789
+ },
1790
+ children: /* @__PURE__ */ jsxs(
1791
+ "span",
1792
+ {
1793
+ style: {
1794
+ background: `black`,
1795
+ color: `white`,
1796
+ padding: 10,
1797
+ paddingTop: 5
1798
+ },
1799
+ children: [
1800
+ `\u26A0\uFE0F `,
1801
+ /* @__PURE__ */ jsx("span", { style: { color: `#fc0`, fontWeight: 700 }, children: component }),
1802
+ ` \u26A0\uFE0F `,
1803
+ message
1804
+ ]
1805
+ }
1806
+ )
1807
+ }
1808
+ )
1809
+ }
1810
+ );
1811
+ };
1812
+ var ErrorBoundary = class extends Component {
1813
+ constructor(props) {
1814
+ super(props);
1815
+ this.state = {};
1816
+ }
1817
+ componentDidCatch(error, errorInfo) {
1818
+ var _a2, _b;
1819
+ (_b = (_a2 = this.props).onError) == null ? void 0 : _b.call(_a2, error, errorInfo);
1820
+ this.setState({
1821
+ error,
1822
+ errorInfo
1823
+ });
1824
+ }
1825
+ render() {
1826
+ const { error, errorInfo } = this.state;
1827
+ const { children, Fallback = DefaultFallback } = this.props;
1828
+ return errorInfo ? /* @__PURE__ */ jsx(Fallback, { error, errorInfo }) : children;
1829
+ }
1830
+ };
1831
+ var DEFAULT_JSON_EDITOR_COMPONENTS = {
1832
+ ErrorBoundary: ({ children }) => /* @__PURE__ */ jsx(ErrorBoundary, { children }),
1833
+ Button: ({ onClick, children, disabled }) => /* @__PURE__ */ jsx(
1834
+ "button",
1835
+ {
1836
+ type: "button",
1837
+ className: "json_editor_button",
1838
+ onClick,
1839
+ disabled,
1840
+ children
1841
+ }
1842
+ ),
1843
+ EditorWrapper: ({ children, customCss, className }) => /* @__PURE__ */ jsx("div", { className: `json_editor ` + className, css: customCss, children }),
1844
+ EditorLayout: ({
1845
+ DeleteButton,
1846
+ Header,
1847
+ KeyInput,
1848
+ TypeSelect,
1849
+ ValueEditor,
1850
+ Wrapper
1851
+ }) => {
1852
+ return /* @__PURE__ */ jsxs(Wrapper, { children: [
1853
+ DeleteButton && /* @__PURE__ */ jsx(DeleteButton, {}),
1854
+ Header && /* @__PURE__ */ jsx(Header, {}),
1855
+ KeyInput && /* @__PURE__ */ jsx(KeyInput, {}),
1856
+ TypeSelect && /* @__PURE__ */ jsx(TypeSelect, {}),
1857
+ /* @__PURE__ */ jsx(ValueEditor, {})
1858
+ ] });
1859
+ },
1860
+ ArrayWrapper: ({ children }) => /* @__PURE__ */ jsx("div", { className: "json_editor_array", children }),
1861
+ ObjectWrapper: ({ children }) => /* @__PURE__ */ jsx("div", { className: "json_editor_object", children }),
1862
+ StringWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_string", children }),
1863
+ NumberWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_number", children }),
1864
+ BooleanWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_boolean", children }),
1865
+ NullWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_null", children }),
1866
+ MissingPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("div", { className: "json_editor_property json_editor_missing", children }),
1867
+ MiscastPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("div", { className: "json_editor_property json_editor_miscast", children }),
1868
+ IllegalPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_property json_editor_illegal", children }),
1869
+ OfficialPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_property json_editor_official", children }),
1870
+ UnofficialPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_property json_editor_unofficial", children }),
1871
+ DeleteIcon: () => /* @__PURE__ */ jsx("span", { className: "json_editor_icon json_editor_delete", children: "x" }),
1872
+ KeyWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_key", children })
1873
+ };
1874
+ var JsonEditor = ({
1875
+ data,
1876
+ set,
1877
+ schema = true,
1878
+ name,
1879
+ rename,
1880
+ remove,
1881
+ isReadonly = () => false,
1882
+ isHidden = () => false,
1883
+ // isIllegal = () => false,
1884
+ className,
1885
+ customCss,
1886
+ Header,
1887
+ Components: CustomComponents = {}
1888
+ }) => {
1889
+ const Components = __spreadValues(__spreadValues({}, DEFAULT_JSON_EDITOR_COMPONENTS), CustomComponents);
1890
+ return /* @__PURE__ */ jsx(
1891
+ JsonEditor_INTERNAL,
1892
+ {
1893
+ data,
1894
+ set,
1895
+ name,
1896
+ schema,
1897
+ rename,
1898
+ remove,
1899
+ path: [],
1900
+ isReadonly,
1901
+ isHidden,
1902
+ className,
1903
+ customCss,
1904
+ Header,
1905
+ Components
1906
+ }
1907
+ );
1908
+ };
1909
+
1910
+ // ../../hamr/src/react-json-editor/index.ts
1911
+ var SubEditors = {
1912
+ array: ArrayEditor,
1913
+ boolean: BooleanEditor,
1914
+ null: NullEditor,
1915
+ number: NumberEditor,
1916
+ object: ObjectEditor,
1917
+ string: StringEditor
1918
+ };
1919
+
1920
+ // ../../anvl/src/string/string-to-color.ts
1921
+ function stringToColor(input) {
1922
+ let hash = 0;
1923
+ for (let i = 0; i < input.length; i++) {
1924
+ const char = input.charCodeAt(i);
1925
+ hash = (hash << 5) - hash + char;
1926
+ hash |= 0;
1927
+ }
1928
+ let hexColor = (hash & 16777215).toString(16);
1929
+ while (hexColor.length < 6) {
1930
+ hexColor = `0` + hexColor;
1931
+ }
1932
+ return `#${hexColor}`;
1933
+ }
1934
+
1935
+ // ../../luum/src/constants/index.ts
1936
+ var CHANNEL_SPECIFIC_LUM = {
1937
+ R: 0.3,
1938
+ G: 0.5,
1939
+ B: 0.2
1940
+ };
1941
+
1942
+ // ../../luum/src/constants/filters.ts
1943
+ var unfiltered = [
1944
+ { sat: 255, hue: 0 },
1945
+ { sat: 255, hue: 360 }
1946
+ ];
1947
+
1948
+ // ../../luum/src/export/channelsToHex.ts
1949
+ var channelsToHex = (channels) => `#${Object.values(channels).map((channel) => {
1950
+ let channelHex = channel.toString(16);
1951
+ if (channelHex.length === 1)
1952
+ channelHex = 0 + channelHex;
1953
+ return channelHex;
1954
+ }).join(``)}`;
1955
+ var channelsToHex_default = channelsToHex;
1956
+
1957
+ // ../../luum/src/import/hueToRelativeChannels.ts
1958
+ var hueToRelativeChannels_default = (hue) => {
1959
+ const hueWrapped = wrapInto(0, 360)(hue);
1960
+ const hueReduced = hueWrapped / 60;
1961
+ const hueInteger = Math.floor(hueReduced);
1962
+ const hueDecimal = hueReduced - hueInteger;
1963
+ const x = hueDecimal;
1964
+ const y = 1 - hueDecimal;
1965
+ switch (hueInteger) {
1966
+ case 0:
1967
+ return [1, x, 0];
1968
+ case 1:
1969
+ return [y, 1, 0];
1970
+ case 2:
1971
+ return [0, 1, x];
1972
+ case 3:
1973
+ return [0, y, 1];
1974
+ case 4:
1975
+ return [x, 0, 1];
1976
+ case 5:
1977
+ return [1, 0, y];
1978
+ default:
1979
+ throw new Error(`invalid hue served: ${hue}`);
1980
+ }
1981
+ };
1982
+
1983
+ // ../../luum/src/solveFor/hueFromChannels.ts
1984
+ var hueFromChannels = ({ R, G, B }) => {
1985
+ let hue = 0;
1986
+ if (R > G && G >= B)
1987
+ hue = 60 * (0 + (G - B) / (R - B));
1988
+ if (G >= R && R > B)
1989
+ hue = 60 * (2 - (R - B) / (G - B));
1990
+ if (G > B && B >= R)
1991
+ hue = 60 * (2 + (B - R) / (G - R));
1992
+ if (B >= G && G > R)
1993
+ hue = 60 * (4 - (G - R) / (B - R));
1994
+ if (B > R && R >= G)
1995
+ hue = 60 * (4 + (R - G) / (B - G));
1996
+ if (R >= B && B > G)
1997
+ hue = 60 * (6 - (B - G) / (R - G));
1998
+ return hue;
1999
+ };
2000
+ var hueFromChannels_default = hueFromChannels;
2001
+
2002
+ // ../../luum/src/solveFor/lumFromChannels.ts
2003
+ var lumFromChannels = ({ R, G, B }) => {
2004
+ const lum = CHANNEL_SPECIFIC_LUM.R * R / 255 + CHANNEL_SPECIFIC_LUM.G * G / 255 + CHANNEL_SPECIFIC_LUM.B * B / 255;
2005
+ return lum;
2006
+ };
2007
+ var lumFromChannels_default = lumFromChannels;
2008
+
2009
+ // ../../luum/src/solveFor/maxSatForHueInFilter.ts
2010
+ var maxSatForHueInFilter_default = (hue, filter) => {
2011
+ let maxSat = 255;
2012
+ const hueWrapped = wrapInto(0, 360)(hue);
2013
+ for (let a2 = -1, b2 = 0; b2 < filter.length; a2++, b2++) {
2014
+ a2 = wrapInto(0, filter.length)(a2);
2015
+ const hueDoubleWrapped = a2 > b2 ? wrapInto(-180, 180)(hueWrapped) : void 0;
2016
+ const tuningPointA = filter[a2];
2017
+ const tuningPointB = filter[b2];
2018
+ const hueA = a2 > b2 ? wrapInto(-180, 180)(tuningPointA.hue) : tuningPointA.hue;
2019
+ const hueB = tuningPointB.hue;
2020
+ if ((hueDoubleWrapped || hueWrapped) >= hueA && (hueDoubleWrapped || hueWrapped) < hueB) {
2021
+ let $ = hueDoubleWrapped || hueWrapped;
2022
+ $ -= hueA;
2023
+ $ /= hueB - hueA;
2024
+ $ *= tuningPointB.sat - tuningPointA.sat;
2025
+ $ += tuningPointA.sat;
2026
+ maxSat = $;
2027
+ }
2028
+ }
2029
+ return maxSat;
2030
+ };
2031
+
2032
+ // ../../luum/src/solveFor/satFromChannels.ts
2033
+ var satFromChannels = ({ R, G, B }) => {
2034
+ const sat = Math.max(R, G, B) - Math.min(R, G, B);
2035
+ return sat;
2036
+ };
2037
+ var satFromChannels_default = satFromChannels;
2038
+
2039
+ // ../../luum/src/solveFor/specificLumFromHue.ts
2040
+ var specificLumFromHue_default = (hue) => {
2041
+ const [factorR, factorG, factorB] = hueToRelativeChannels_default(hue);
2042
+ const lumR = CHANNEL_SPECIFIC_LUM.R * factorR;
2043
+ const lumG = CHANNEL_SPECIFIC_LUM.G * factorG;
2044
+ const lumB = CHANNEL_SPECIFIC_LUM.B * factorB;
2045
+ const specificLum = lumR + lumG + lumB;
2046
+ return specificLum;
2047
+ };
2048
+
2049
+ // ../../luum/src/export/specToChannelsFixLimit.ts
2050
+ var minChannelsForSaturationFromHue = (hue) => {
2051
+ const relativeChannels = hueToRelativeChannels_default(hue);
2052
+ const channelSpreader = (trueSaturation) => {
2053
+ const makeMinChannel = (idx) => Math.round(relativeChannels[idx] * trueSaturation);
2054
+ return {
2055
+ R: makeMinChannel(0),
2056
+ G: makeMinChannel(1),
2057
+ B: makeMinChannel(2)
2058
+ };
2059
+ };
2060
+ return channelSpreader;
2061
+ };
2062
+ var channelsFromIlluminationObj = ({
2063
+ minChannels,
2064
+ trueLuminosity,
2065
+ minLum
2066
+ }) => {
2067
+ const { max, round: round2 } = Math;
2068
+ const maxWhite = 255 - max(...Object.values(minChannels));
2069
+ const white = clampInto(0, maxWhite)(round2((trueLuminosity - minLum) * 255));
2070
+ const channels = {
2071
+ R: minChannels.R + white,
2072
+ G: minChannels.G + white,
2073
+ B: minChannels.B + white
2074
+ };
2075
+ return channels;
2076
+ };
2077
+ var specToChannelsFixLimit = ({ hue, sat, lum, prefer = `lum` }, filter = unfiltered) => {
2078
+ const minChannelsForSaturation = minChannelsForSaturationFromHue(hue);
2079
+ let trueSaturation;
2080
+ let trueLuminosity;
2081
+ let minChannels;
2082
+ let maxChannels;
2083
+ let specificLum;
2084
+ let minLum = 0;
2085
+ let maxLum = 1;
2086
+ let maxSat = maxSatForHueInFilter_default(hue, filter);
2087
+ switch (prefer) {
2088
+ case `sat`:
2089
+ trueSaturation = clampInto(0, 255)(Math.min(sat, maxSat));
2090
+ minChannels = minChannelsForSaturation(trueSaturation);
2091
+ maxChannels = {
2092
+ R: minChannels.R + 255 - trueSaturation,
2093
+ G: minChannels.G + 255 - trueSaturation,
2094
+ B: minChannels.B + 255 - trueSaturation
2095
+ };
2096
+ minLum = lumFromChannels_default(minChannels);
2097
+ maxLum = lumFromChannels_default(maxChannels);
2098
+ trueLuminosity = clampInto(minLum, maxLum)(lum);
2099
+ break;
2100
+ case `lum`:
2101
+ trueLuminosity = clampInto(0, 1)(lum);
2102
+ specificLum = specificLumFromHue_default(hue);
2103
+ maxSat = Math.min(
2104
+ maxSat,
2105
+ Math.round(
2106
+ trueLuminosity <= specificLum ? 255 * (trueLuminosity / specificLum) : 255 * (1 - trueLuminosity) / (1 - specificLum)
2107
+ )
2108
+ );
2109
+ trueSaturation = Math.min(sat, maxSat);
2110
+ minChannels = minChannelsForSaturation(trueSaturation);
2111
+ minLum = lumFromChannels_default(minChannels);
2112
+ break;
2113
+ }
2114
+ const channels = channelsFromIlluminationObj({
2115
+ minChannels,
2116
+ trueLuminosity,
2117
+ minLum
2118
+ });
2119
+ return {
2120
+ channels,
2121
+ fix: {
2122
+ sat: trueSaturation,
2123
+ lum: trueLuminosity
2124
+ },
2125
+ limit: {
2126
+ sat: [0, maxSat],
2127
+ lum: [prefer === `lum` ? 0 : minLum, maxLum]
2128
+ }
2129
+ };
2130
+ };
2131
+ var specToChannelsFixLimit_default = specToChannelsFixLimit;
2132
+
2133
+ // ../../luum/src/export/specToHexFixLimit.ts
2134
+ var specToHexFixLimit = ({ hue, sat, lum, prefer }, filter) => {
2135
+ const { channels, fix, limit } = specToChannelsFixLimit_default(
2136
+ {
2137
+ hue,
2138
+ sat,
2139
+ lum,
2140
+ prefer
2141
+ },
2142
+ filter
2143
+ );
2144
+ const { R, G, B } = channels;
2145
+ const hex = channelsToHex_default({ R, G, B });
2146
+ return { hex, fix, limit };
2147
+ };
2148
+ var specToHexFixLimit_default = specToHexFixLimit;
2149
+
2150
+ // ../../luum/src/export/specToHex.ts
2151
+ var specToHex = ({ hue, sat, lum, prefer }, filter) => {
2152
+ const { hex } = specToHexFixLimit_default({ hue, sat, lum, prefer }, filter);
2153
+ return hex;
2154
+ };
2155
+ var specToHex_default = specToHex;
2156
+
2157
+ // ../../luum/src/import/channelsToSpec.ts
2158
+ var channelsToSpec = ({ R, G, B }) => {
2159
+ const hue = hueFromChannels_default({ R, G, B });
2160
+ const sat = satFromChannels_default({ R, G, B });
2161
+ const lum = lumFromChannels_default({ R, G, B });
2162
+ return { hue, sat, lum };
2163
+ };
2164
+ var channelsToSpec_default = channelsToSpec;
2165
+
2166
+ // ../../luum/src/import/normalizeHex.ts
2167
+ var BASE_16_CHAR_SET = `[a-fA-F0-9]+`;
2168
+ var miniHexToHex = (miniHex) => {
2169
+ const miniHexArray = miniHex.split(``);
2170
+ const hexTemplate = [0, 0, 1, 1, 2, 2];
2171
+ return hexTemplate.map((idx) => miniHexArray[idx]).join(``);
2172
+ };
2173
+ var normalizeHex = (maybeHex) => {
2174
+ const hex = maybeHex.replace(/^#/, ``);
2175
+ const hexIsCorrectLength = hex.length === 6 || hex.length === 3;
2176
+ const hexIsCorrectCharSet = hex.match(new RegExp(`^${BASE_16_CHAR_SET}$`)) !== null;
2177
+ const hexIsValid = hexIsCorrectLength && hexIsCorrectCharSet;
2178
+ if (!hexIsValid) {
2179
+ throw new Error(`${maybeHex} is not a valid hex code`);
2180
+ }
2181
+ if (hex.length === 3) {
2182
+ return miniHexToHex(hex);
2183
+ }
2184
+ return hex;
2185
+ };
2186
+ var normalizeHex_default = normalizeHex;
2187
+
2188
+ // ../../luum/src/import/hexToChannels.ts
2189
+ var hexToChannels_default = (maybeHex) => {
2190
+ const hex = normalizeHex_default(maybeHex);
2191
+ return {
2192
+ R: parseInt(hex.slice(0, 2), 16),
2193
+ G: parseInt(hex.slice(2, 4), 16),
2194
+ B: parseInt(hex.slice(4, 6), 16)
2195
+ };
2196
+ };
2197
+
2198
+ // ../../luum/src/import/hexToSpec.ts
2199
+ var hexToSpec = (hex) => {
2200
+ const { R, G, B } = hexToChannels_default(hex);
2201
+ const { hue, sat, lum } = channelsToSpec_default({ R, G, B });
2202
+ return { hue, sat, lum };
2203
+ };
2204
+ var hexToSpec_default = hexToSpec;
2205
+
2206
+ // ../../luum/src/mixers/contrast.ts
2207
+ var contrastMax = (color) => __spreadProps(__spreadValues({}, color), {
2208
+ lum: color.lum > 0.666 ? 0 : 1
2209
+ });
2210
+ var offset = (offsetAmount) => (color) => __spreadProps(__spreadValues({}, color), {
2211
+ lum: color.lum > 0.666 ? color.lum - offsetAmount : color.lum + offsetAmount
2212
+ });
2213
+
2214
+ // ../../luum/src/constants/luum-spec.ts
2215
+ var defaultSpec = {
2216
+ hue: 0,
2217
+ lum: 0,
2218
+ sat: 0,
2219
+ prefer: `lum`
2220
+ };
2221
+
2222
+ // ../../luum/src/scheme/index.ts
2223
+ var isLuumSpec = (input) => typeof input === `object` && input !== null && typeof input.hue === `number` && typeof input.sat === `number` && typeof input.lum === `number` && [`sat`, `lum`].includes(input.prefer);
2224
+ isModifier(isLuumSpec)(defaultSpec);
2225
+ var WAYFORGE_CORE_COLOR_NAMES = [
2226
+ `Red`,
2227
+ `Orange`,
2228
+ `Yellow`,
2229
+ `Lime`,
2230
+ `Green`,
2231
+ `Teal`,
2232
+ `Cyan`,
2233
+ `Blue`,
2234
+ `Indigo`,
2235
+ `Violet`,
2236
+ `Magenta`,
2237
+ `Pink`
2238
+ ];
2239
+ WAYFORGE_CORE_COLOR_NAMES.reduce((acc, name, idx) => {
2240
+ acc[name] = {
2241
+ hue: idx * 30,
2242
+ sat: 255,
2243
+ lum: 0.5,
2244
+ prefer: `sat`
2245
+ };
2246
+ return acc;
2247
+ }, {});
2248
+ var Id = ({ id }) => {
2249
+ const [isOpen, setIsOpen] = React.useState(false);
2250
+ const { refs, floatingStyles, context } = useFloating({
2251
+ open: isOpen,
2252
+ onOpenChange: setIsOpen,
2253
+ placement: `bottom-start`
2254
+ });
2255
+ const click = useClick(context);
2256
+ const { getReferenceProps, getFloatingProps } = useInteractions([click]);
2257
+ const bgColor = stringToColor(id);
2258
+ const contrastColor = pipe(bgColor, hexToSpec_default, contrastMax, specToHex_default);
2259
+ const offsetColor = pipe(bgColor, hexToSpec_default, offset(0.25), specToHex_default);
2260
+ const contrastOffsetColor = pipe(
2261
+ offsetColor,
2262
+ hexToSpec_default,
2263
+ contrastMax,
2264
+ specToHex_default
2265
+ );
2266
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2267
+ /* @__PURE__ */ jsx(
2268
+ "span",
2269
+ __spreadProps(__spreadValues({
2270
+ role: "content",
2271
+ ref: refs.setReference
2272
+ }, getReferenceProps()), {
2273
+ style: {
2274
+ background: bgColor,
2275
+ cursor: `pointer`,
2276
+ padding: `0px 4px`,
2277
+ color: contrastColor,
2278
+ userSelect: `none`,
2279
+ whiteSpace: `nowrap`
2280
+ },
2281
+ children: id.substring(0, 3)
2282
+ })
2283
+ ),
2284
+ isOpen && /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(
2285
+ "span",
2286
+ __spreadProps(__spreadValues({
2287
+ role: "popup",
2288
+ ref: refs.setFloating
2289
+ }, getFloatingProps()), {
2290
+ style: __spreadProps(__spreadValues({}, floatingStyles), {
2291
+ color: contrastOffsetColor,
2292
+ background: offsetColor,
2293
+ padding: `0px 4px`,
2294
+ boxShadow: `0px 2px 10px rgba(0, 0, 0, 0.1)`
2295
+ }),
2296
+ children: id
2297
+ })
2298
+ ) })
2299
+ ] });
2300
+ };
2301
+
2302
+ // ../../hamr/src/react-data-designer/RelationEditor.module.scss
2303
+ var RelationEditor_module_default = {};
2304
+ var RelationEditor = (props) => {
2305
+ const seen = /* @__PURE__ */ new Set();
2306
+ const data = Object.entries(props.data.relations).sort(([_, a2], [__, b2]) => b2.length - a2.length).filter(([head, tail]) => {
2307
+ if (seen.has(head))
2308
+ return false;
2309
+ seen.add(head);
2310
+ for (const tailElement of tail) {
2311
+ seen.add(tailElement);
2312
+ }
2313
+ return true;
2314
+ });
2315
+ return /* @__PURE__ */ jsx("article", { className: RelationEditor_module_default.class, children: data.map(([head, tail]) => /* @__PURE__ */ jsxs("section", { children: [
2316
+ /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Id, { id: head }) }),
2317
+ ":",
2318
+ /* @__PURE__ */ jsx("span", { children: tail.map((child) => /* @__PURE__ */ jsx(Id, { id: child })) })
2319
+ ] })) });
2320
+ };
2321
+ var StateEditor = ({ token }) => {
2322
+ const set = useI(token);
2323
+ const data = useO(token);
2324
+ return isJson(data) ? /* @__PURE__ */ jsx(JsonEditor, { data, set, schema: true }) : data instanceof Join ? /* @__PURE__ */ jsx(RelationEditor, { data, set }) : /* @__PURE__ */ jsx("div", { className: "json_editor", children: /* @__PURE__ */ jsx(
2325
+ ElasticInput,
2326
+ {
2327
+ value: data instanceof Set ? `Set { ${JSON.stringify([...data]).slice(1, -1)} }` : data instanceof Map ? `Map ` + JSON.stringify([...data]) : Object.getPrototypeOf(data).constructor.name + ` ` + fallback(() => JSON.stringify(data), `?`),
2328
+ disabled: true
2329
+ }
2330
+ ) });
2331
+ };
2332
+ var ReadonlySelectorViewer = ({ token }) => {
2333
+ const data = useO(token);
2334
+ return isJson(data) ? /* @__PURE__ */ jsx(
2335
+ JsonEditor,
2336
+ {
2337
+ data,
2338
+ set: () => null,
2339
+ schema: true,
2340
+ isReadonly: () => true
2341
+ }
2342
+ ) : /* @__PURE__ */ jsx("div", { className: "json_editor", children: /* @__PURE__ */ jsx(
2343
+ ElasticInput,
2344
+ {
2345
+ value: data instanceof Set ? `Set ` + JSON.stringify([...data]) : data instanceof Map ? `Map ` + JSON.stringify([...data]) : Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data),
2346
+ disabled: true
2347
+ }
2348
+ ) });
2349
+ };
2350
+ var StoreEditor = ({ token }) => {
2351
+ if (token.type === `readonly_selector`) {
2352
+ return /* @__PURE__ */ jsx(ReadonlySelectorViewer, { token });
2353
+ }
2354
+ return /* @__PURE__ */ jsx(StateEditor, { token });
2355
+ };
2356
+ var findStateTypeState = selectorFamily({
2357
+ key: `\u{1F441}\u200D\u{1F5E8} State Type`,
2358
+ get: (token) => ({ get }) => {
2359
+ let state;
2360
+ try {
2361
+ state = get(token);
2362
+ } catch (error) {
2363
+ return `error`;
2364
+ }
2365
+ if (state === void 0)
2366
+ return `undefined`;
2367
+ if (isJson(state))
2368
+ return refineJsonType(state).type;
2369
+ return Object.getPrototypeOf(state).constructor.name;
2370
+ }
2371
+ });
2372
+ var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
2373
+ var _a2, _b;
2374
+ const setIsOpen = useI(isOpenState);
2375
+ const isOpen = useO(isOpenState);
2376
+ const state = useO(node);
2377
+ const stateType = useO(typeState);
2378
+ const isPrimitive = Boolean(primitiveRefinery.refine(state));
2379
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2380
+ /* @__PURE__ */ jsxs("header", { children: [
2381
+ /* @__PURE__ */ jsx(
2382
+ button.OpenClose,
2383
+ {
2384
+ isOpen: isOpen && !isPrimitive,
2385
+ setIsOpen,
2386
+ disabled: isPrimitive
2387
+ }
2388
+ ),
2389
+ /* @__PURE__ */ jsxs(
2390
+ "label",
2391
+ {
2392
+ onClick: () => console.log(node, getState(node)),
2393
+ onKeyUp: () => console.log(node, getState(node)),
2394
+ children: [
2395
+ /* @__PURE__ */ jsx("h2", { children: (_b = (_a2 = node.family) == null ? void 0 : _a2.subKey) != null ? _b : node.key }),
2396
+ /* @__PURE__ */ jsxs("span", { className: "type detail", children: [
2397
+ "(",
2398
+ stateType,
2399
+ ")"
2400
+ ] })
2401
+ ]
2402
+ }
2403
+ ),
2404
+ isPrimitive ? /* @__PURE__ */ jsx(StoreEditor, { token: node }) : null
2405
+ ] }),
2406
+ isOpen && !isPrimitive ? /* @__PURE__ */ jsx("main", { children: /* @__PURE__ */ jsx(StoreEditor, { token: node }) }) : null
2407
+ ] });
2408
+ };
2409
+ var StateIndexTreeNode = ({ node, isOpenState }) => {
2410
+ const setIsOpen = useI(isOpenState);
2411
+ const isOpen = useO(isOpenState);
2412
+ Object.entries(node.familyMembers).forEach(([key, childNode]) => {
2413
+ findViewIsOpenState(key);
2414
+ findStateTypeState(childNode);
2415
+ });
2416
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2417
+ /* @__PURE__ */ jsxs("header", { children: [
2418
+ /* @__PURE__ */ jsx(button.OpenClose, { isOpen, setIsOpen }),
2419
+ /* @__PURE__ */ jsxs("label", { children: [
2420
+ /* @__PURE__ */ jsx("h2", { children: node.key }),
2421
+ /* @__PURE__ */ jsx("span", { className: "type detail", children: " (family)" })
2422
+ ] })
2423
+ ] }),
2424
+ isOpen ? Object.entries(node.familyMembers).map(([key, childNode]) => /* @__PURE__ */ jsx(
2425
+ StateIndexNode,
2426
+ {
2427
+ node: childNode,
2428
+ isOpenState: findViewIsOpenState(childNode.key),
2429
+ typeState: findStateTypeState(childNode)
2430
+ },
2431
+ key
2432
+ )) : null
2433
+ ] });
2434
+ };
2435
+ var StateIndexNode = ({ node, isOpenState, typeState }) => {
2436
+ if (node.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)) {
2437
+ return null;
2438
+ }
2439
+ return /* @__PURE__ */ jsx("section", { className: "node state", children: `type` in node ? /* @__PURE__ */ jsx(
2440
+ StateIndexLeafNode,
2441
+ {
2442
+ node,
2443
+ isOpenState,
2444
+ typeState
2445
+ }
2446
+ ) : /* @__PURE__ */ jsx(StateIndexTreeNode, { node, isOpenState }) });
2447
+ };
2448
+ var StateIndex = ({ tokenIndex }) => {
2449
+ const tokenIds = useO(tokenIndex);
2450
+ return /* @__PURE__ */ jsx("article", { className: "index state_index", children: Object.entries(tokenIds).filter(([key]) => !key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).sort().map(([key, node]) => {
2451
+ return /* @__PURE__ */ jsx(
2452
+ StateIndexNode,
2453
+ {
2454
+ node,
2455
+ isOpenState: findViewIsOpenState(node.key),
2456
+ typeState: findStateTypeState(node)
2457
+ },
2458
+ key
2459
+ );
2460
+ }) });
2461
+ };
2462
+ var AtomUpdateFC = ({ atomUpdate }) => {
2463
+ return /* @__PURE__ */ jsxs(
2464
+ "article",
2465
+ {
2466
+ className: "node atom_update",
2467
+ onClick: () => console.log(atomUpdate),
2468
+ onKeyUp: () => console.log(atomUpdate),
2469
+ children: [
2470
+ /* @__PURE__ */ jsxs("span", { className: "detail", children: [
2471
+ atomUpdate.key,
2472
+ ": "
2473
+ ] }),
2474
+ /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx("span", { className: "summary", children: prettyJson.diff(atomUpdate.oldValue, atomUpdate.newValue).summary }) })
2475
+ ]
2476
+ },
2477
+ atomUpdate.key
2478
+ );
2479
+ };
2480
+ var TransactionUpdateFC = ({ serialNumber, transactionUpdate }) => {
2481
+ return /* @__PURE__ */ jsxs("article", { className: "node transaction_update", children: [
2482
+ /* @__PURE__ */ jsx("header", { children: /* @__PURE__ */ jsx("h4", { children: serialNumber }) }),
2483
+ /* @__PURE__ */ jsxs("main", { children: [
2484
+ /* @__PURE__ */ jsxs("section", { className: "transaction_params", children: [
2485
+ /* @__PURE__ */ jsx("span", { className: "detail", children: "params: " }),
2486
+ transactionUpdate.params.map((param, index) => {
2487
+ return /* @__PURE__ */ jsxs(
2488
+ "article",
2489
+ {
2490
+ className: "node transaction_param",
2491
+ onClick: () => console.log(transactionUpdate),
2492
+ onKeyUp: () => console.log(transactionUpdate),
2493
+ children: [
2494
+ /* @__PURE__ */ jsxs("span", { className: "detail", children: [
2495
+ discoverType(param),
2496
+ ": "
2497
+ ] }),
2498
+ /* @__PURE__ */ jsx("span", { className: "summary", children: typeof param === `object` && param !== null && `type` in param && `target` in param ? /* @__PURE__ */ jsx(Fragment, { children: JSON.stringify(param.type) }) : /* @__PURE__ */ jsx(Fragment, { children: JSON.stringify(param) }) })
2499
+ ]
2500
+ },
2501
+ `param` + index
2502
+ );
2503
+ })
2504
+ ] }),
2505
+ /* @__PURE__ */ jsxs("section", { className: "node transaction_output", children: [
2506
+ /* @__PURE__ */ jsx("span", { className: "detail", children: "output: " }),
2507
+ /* @__PURE__ */ jsx("span", { className: "detail", children: discoverType(transactionUpdate.output) }),
2508
+ transactionUpdate.output ? /* @__PURE__ */ jsxs("span", { className: "summary", children: [
2509
+ ": ",
2510
+ JSON.stringify(transactionUpdate.output)
2511
+ ] }) : null
2512
+ ] }),
2513
+ /* @__PURE__ */ jsxs("section", { className: "transaction_impact", children: [
2514
+ /* @__PURE__ */ jsx("span", { className: "detail", children: "impact: " }),
2515
+ transactionUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
2516
+ return /* @__PURE__ */ jsx(
2517
+ article.AtomUpdate,
2518
+ {
2519
+ serialNumber: index,
2520
+ atomUpdate
2521
+ },
2522
+ `${transactionUpdate.key}:${index}:${atomUpdate.key}`
2523
+ );
2524
+ })
2525
+ ] })
2526
+ ] })
2527
+ ] });
2528
+ };
2529
+ var TimelineUpdateFC = ({ timelineUpdate }) => {
2530
+ return /* @__PURE__ */ jsxs("article", { className: "node timeline_update", children: [
2531
+ /* @__PURE__ */ jsx("header", { children: /* @__PURE__ */ jsxs("h4", { children: [
2532
+ timelineUpdate.timestamp,
2533
+ ": ",
2534
+ timelineUpdate.type,
2535
+ " (",
2536
+ timelineUpdate.key,
2537
+ ")"
2538
+ ] }) }),
2539
+ /* @__PURE__ */ jsx("main", { children: timelineUpdate.type === `transaction_update` ? timelineUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
2540
+ return /* @__PURE__ */ jsx(
2541
+ article.AtomUpdate,
2542
+ {
2543
+ serialNumber: index,
2544
+ atomUpdate
2545
+ },
2546
+ `${timelineUpdate.key}:${index}:${atomUpdate.key}`
2547
+ );
2548
+ }) : timelineUpdate.type === `selector_update` ? timelineUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
2549
+ return /* @__PURE__ */ jsx(
2550
+ article.AtomUpdate,
2551
+ {
2552
+ serialNumber: index,
2553
+ atomUpdate
2554
+ },
2555
+ `${timelineUpdate.key}:${index}:${atomUpdate.key}`
2556
+ );
2557
+ }) : timelineUpdate.type === `atom_update` ? /* @__PURE__ */ jsx(
2558
+ article.AtomUpdate,
2559
+ {
2560
+ serialNumber: timelineUpdate.timestamp,
2561
+ atomUpdate: timelineUpdate
2562
+ }
2563
+ ) : null })
2564
+ ] });
2565
+ };
2566
+ var article = {
2567
+ AtomUpdate: AtomUpdateFC,
2568
+ TransactionUpdate: TransactionUpdateFC,
2569
+ TimelineUpdate: TimelineUpdateFC
2570
+ };
2571
+ var YouAreHere = () => {
2572
+ return /* @__PURE__ */ jsx("span", { className: "you_are_here", children: "you are here" });
2573
+ };
2574
+ var TimelineLog = ({ token, isOpenState, timelineState }) => {
2575
+ const timeline = useO(timelineState);
2576
+ const isOpen = useO(isOpenState);
2577
+ const setIsOpen = useI(isOpenState);
2578
+ return /* @__PURE__ */ jsxs("section", { className: "node timeline_log", children: [
2579
+ /* @__PURE__ */ jsxs("header", { children: [
2580
+ /* @__PURE__ */ jsx(button.OpenClose, { isOpen, setIsOpen }),
2581
+ /* @__PURE__ */ jsxs("label", { children: [
2582
+ /* @__PURE__ */ jsx("h2", { children: token.key }),
2583
+ /* @__PURE__ */ jsxs("span", { className: "detail length", children: [
2584
+ "(",
2585
+ timeline.at,
2586
+ "/",
2587
+ timeline.history.length,
2588
+ ")"
2589
+ ] }),
2590
+ /* @__PURE__ */ jsx("span", { className: "gap" }),
2591
+ /* @__PURE__ */ jsxs("nav", { children: [
2592
+ /* @__PURE__ */ jsx(
2593
+ "button",
2594
+ {
2595
+ type: "button",
2596
+ onClick: () => undo(token),
2597
+ disabled: timeline.at === 0,
2598
+ children: "undo"
2599
+ }
2600
+ ),
2601
+ /* @__PURE__ */ jsx(
2602
+ "button",
2603
+ {
2604
+ type: "button",
2605
+ onClick: () => redo(token),
2606
+ disabled: timeline.at === timeline.history.length,
2607
+ children: "redo"
2608
+ }
2609
+ )
2610
+ ] })
2611
+ ] })
2612
+ ] }),
2613
+ isOpen ? /* @__PURE__ */ jsx("main", { children: timeline.history.map((update, index) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
2614
+ index === timeline.at ? /* @__PURE__ */ jsx(YouAreHere, {}) : null,
2615
+ /* @__PURE__ */ jsx(article.TimelineUpdate, { timelineUpdate: update }),
2616
+ index === timeline.history.length - 1 && timeline.at === timeline.history.length ? /* @__PURE__ */ jsx(YouAreHere, {}) : null
2617
+ ] }, update.key + index + timeline.at)) }) : null
2618
+ ] });
2619
+ };
2620
+ var TimelineIndex = () => {
2621
+ const tokenIds = useO(timelineIndex);
2622
+ return /* @__PURE__ */ jsx("article", { className: "index timeline_index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
2623
+ return /* @__PURE__ */ jsx(
2624
+ TimelineLog,
2625
+ {
2626
+ token,
2627
+ isOpenState: findViewIsOpenState(token.key),
2628
+ timelineState: findTimelineState(token.key)
2629
+ },
2630
+ token.key
2631
+ );
2632
+ }) });
2633
+ };
2634
+ var TransactionLog = ({ token, isOpenState, logState }) => {
2635
+ const log = useO(logState);
2636
+ const isOpen = useO(isOpenState);
2637
+ const setIsOpen = useI(isOpenState);
2638
+ return /* @__PURE__ */ jsxs("section", { className: "node transaction_log", children: [
2639
+ /* @__PURE__ */ jsxs("header", { children: [
2640
+ /* @__PURE__ */ jsx(button.OpenClose, { isOpen, setIsOpen }),
2641
+ /* @__PURE__ */ jsxs("label", { children: [
2642
+ /* @__PURE__ */ jsx("h2", { children: token.key }),
2643
+ /* @__PURE__ */ jsxs("span", { className: "detail length", children: [
2644
+ "(",
2645
+ log.length,
2646
+ ")"
2647
+ ] })
2648
+ ] })
2649
+ ] }),
2650
+ isOpen ? /* @__PURE__ */ jsx("main", { children: log.map((update, index) => /* @__PURE__ */ jsx(
2651
+ article.TransactionUpdate,
2652
+ {
2653
+ serialNumber: index,
2654
+ transactionUpdate: update
2655
+ },
2656
+ update.key + index
2657
+ )) }) : null
2658
+ ] });
2659
+ };
2660
+ var TransactionIndex = () => {
2661
+ const tokenIds = useO(transactionIndex);
2662
+ return /* @__PURE__ */ jsx("article", { className: "index transaction_index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
2663
+ return /* @__PURE__ */ jsx(
2664
+ TransactionLog,
2665
+ {
2666
+ token,
2667
+ isOpenState: findViewIsOpenState(token.key),
2668
+ logState: findTransactionLogState(token.key)
2669
+ },
2670
+ token.key
2671
+ );
2672
+ }) });
2673
+ };
2674
+ var AtomIODevtools = () => {
2675
+ const constraintsRef = useRef(null);
2676
+ const setDevtoolsAreOpen = useI(devtoolsAreOpenState);
2677
+ const devtoolsAreOpen = useO(devtoolsAreOpenState);
2678
+ const setDevtoolsView = useI(devtoolsViewSelectionState);
2679
+ const devtoolsView = useO(devtoolsViewSelectionState);
2680
+ const devtoolsViewOptions = useO(devtoolsViewOptionsState);
2681
+ const mouseHasMoved = useRef(false);
2682
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2683
+ /* @__PURE__ */ jsx(
2684
+ motion.span,
2685
+ {
2686
+ ref: constraintsRef,
2687
+ className: "atom_io_devtools_zone",
2688
+ style: {
2689
+ position: `fixed`,
2690
+ top: 0,
2691
+ left: 0,
2692
+ right: 0,
2693
+ bottom: 0,
2694
+ pointerEvents: `none`
2695
+ }
2696
+ }
2697
+ ),
2698
+ /* @__PURE__ */ jsxs(
2699
+ motion.main,
2700
+ {
2701
+ drag: true,
2702
+ dragConstraints: constraintsRef,
2703
+ className: "atom_io_devtools",
2704
+ transition: spring,
2705
+ style: devtoolsAreOpen ? {} : {
2706
+ backgroundColor: `#0000`,
2707
+ borderColor: `#0000`,
2708
+ maxHeight: 28,
2709
+ maxWidth: 33
2710
+ },
2711
+ children: [
2712
+ devtoolsAreOpen ? /* @__PURE__ */ jsxs(Fragment, { children: [
2713
+ /* @__PURE__ */ jsxs(motion.header, { children: [
2714
+ /* @__PURE__ */ jsx("h1", { children: "atom.io" }),
2715
+ /* @__PURE__ */ jsx("nav", { children: devtoolsViewOptions.map((viewOption) => /* @__PURE__ */ jsx(
2716
+ "button",
2717
+ {
2718
+ type: "button",
2719
+ className: viewOption === devtoolsView ? `active` : ``,
2720
+ onClick: () => setDevtoolsView(viewOption),
2721
+ disabled: viewOption === devtoolsView,
2722
+ children: viewOption
2723
+ },
2724
+ viewOption
2725
+ )) })
2726
+ ] }),
2727
+ /* @__PURE__ */ jsx(motion.main, { children: /* @__PURE__ */ jsx(LayoutGroup, { children: devtoolsView === `atoms` ? /* @__PURE__ */ jsx(StateIndex, { tokenIndex: atomIndex }) : devtoolsView === `selectors` ? /* @__PURE__ */ jsx(StateIndex, { tokenIndex: selectorIndex }) : devtoolsView === `transactions` ? /* @__PURE__ */ jsx(TransactionIndex, {}) : devtoolsView === `timelines` ? /* @__PURE__ */ jsx(TimelineIndex, {}) : null }) })
2728
+ ] }) : null,
2729
+ /* @__PURE__ */ jsx("footer", { children: /* @__PURE__ */ jsx(
2730
+ "button",
2731
+ {
2732
+ type: "button",
2733
+ onMouseDown: () => mouseHasMoved.current = false,
2734
+ onMouseMove: () => mouseHasMoved.current = true,
2735
+ onMouseUp: () => {
2736
+ if (!mouseHasMoved.current) {
2737
+ setDevtoolsAreOpen((open) => !open);
2738
+ }
2739
+ },
2740
+ children: "\u{1F441}\u200D\u{1F5E8}"
2741
+ }
2742
+ ) })
2743
+ ]
2744
+ }
2745
+ )
2746
+ ] });
2747
+ };
2748
+
2749
+ // src/index.ts
2750
+ var {
2751
+ atomIndex,
2752
+ selectorIndex,
2753
+ transactionIndex,
2754
+ findTransactionLogState,
2755
+ timelineIndex,
2756
+ findTimelineState
2757
+ } = attachIntrospectionStates();
2758
+ var devtoolsAreOpenState = atom({
2759
+ key: `\u{1F441}\u200D\u{1F5E8} Devtools Are Open`,
2760
+ default: true,
2761
+ effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools Are Open`)]
2762
+ });
2763
+ var devtoolsViewSelectionState = atom({
2764
+ key: `\u{1F441}\u200D\u{1F5E8} Devtools View Selection`,
2765
+ default: `atoms`,
2766
+ effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View`)]
2767
+ });
2768
+ var devtoolsViewOptionsState = atom({
2769
+ key: `\u{1F441}\u200D\u{1F5E8} Devtools View Options`,
2770
+ default: [`atoms`, `selectors`, `transactions`, `timelines`],
2771
+ effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View Options`)]
2772
+ });
2773
+ var findViewIsOpenState = atomFamily({
2774
+ key: `\u{1F441}\u200D\u{1F5E8} Devtools View Is Open`,
2775
+ default: false,
2776
+ effects: (key) => [lazyLocalStorageEffect(key + `:view-is-open`)]
2777
+ });
2778
+ var primitiveRefinery = new Refinery({
2779
+ number: (input) => typeof input === `number`,
2780
+ string: (input) => typeof input === `string`,
2781
+ boolean: (input) => typeof input === `boolean`,
2782
+ null: (input) => input === null
2783
+ });
2784
+ var jsonTreeRefinery = new Refinery({
2785
+ object: isPlainObject,
2786
+ array: (input) => Array.isArray(input)
2787
+ });
2788
+ var prettyJson = new Differ(primitiveRefinery, jsonTreeRefinery, {
2789
+ number: diffNumber,
2790
+ string: diffString,
2791
+ boolean: diffBoolean,
2792
+ null: () => ({ summary: `No Change` }),
2793
+ object: diffObject,
2794
+ array: diffArray
2795
+ });
2796
+
2797
+ export { AtomIODevtools, atomIndex, devtoolsAreOpenState, devtoolsViewOptionsState, devtoolsViewSelectionState, findTimelineState, findTransactionLogState, findViewIsOpenState, jsonTreeRefinery, prettyJson, primitiveRefinery, selectorIndex, timelineIndex, transactionIndex };
19
2798
  //# sourceMappingURL=out.js.map
20
2799
  //# sourceMappingURL=index.mjs.map