@synnaxlabs/pluto 0.50.1 → 0.52.3

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 (260) hide show
  1. package/dist/{Animated-C4xrEVd-.js → Animated-6qL1fRZx.js} +61 -60
  2. package/dist/Animated-Bn4jMc7c.js +29 -0
  3. package/dist/Animated-vGAs0qOH.cjs +1 -0
  4. package/dist/Animated-xK__WUQp.cjs +1 -0
  5. package/dist/{Box-DLO7l9hM.js → Box-Bi280MYh.js} +28 -27
  6. package/dist/Box-CNUz5BsV.cjs +1 -0
  7. package/dist/Copy-CzkBKGca.js +337 -0
  8. package/dist/Copy-DuC8dTK7.cjs +1 -0
  9. package/dist/Dialog-DNrgykEv.cjs +1 -0
  10. package/dist/{Dialog-BspO7uo8.js → Dialog-Dos5l3K2.js} +13 -12
  11. package/dist/{Editable-DjQORuR1.js → Editable-4ZwvICC4.js} +46 -45
  12. package/dist/Editable-HUPqTaui.cjs +1 -0
  13. package/dist/{Haul-DBy-2ds_.js → Haul-CxbMtSY4.js} +18 -18
  14. package/dist/Haul-V5NQI3MY.cjs +1 -0
  15. package/dist/{Items-CX11yLMf.js → Items-CNPUoiob.js} +22 -21
  16. package/dist/Items-DYYNNIjr.cjs +4 -0
  17. package/dist/Menu-C0scum-k.cjs +1 -0
  18. package/dist/{Menu-GBo3ayoP.js → Menu-CTuOX5DR.js} +42 -41
  19. package/dist/Provider-DSMJjyuY.cjs +1 -0
  20. package/dist/{Provider-BkxUzTWS.js → Provider-ZIy-UlnE.js} +95 -93
  21. package/dist/Tags-6OV0_eBz.cjs +1 -0
  22. package/dist/{Tags-V7sNuGZv.js → Tags-BUDnOqms.js} +223 -222
  23. package/dist/{Text-XeD58Fq8.js → Text-BSTMZRuo.js} +717 -675
  24. package/dist/Text-C2_VsLzw.cjs +1 -0
  25. package/dist/Video-Bew5_j16.js +10 -0
  26. package/dist/Video-BryrVNlH.cjs +1 -0
  27. package/dist/button.cjs +1 -1
  28. package/dist/button.js +1 -1
  29. package/dist/color.cjs +1 -1
  30. package/dist/color.js +1 -1
  31. package/dist/css-CloSmhZB.cjs +1 -0
  32. package/dist/css-D90kZTM8.js +63 -0
  33. package/dist/css.cjs +1 -1
  34. package/dist/css.js +2 -2
  35. package/dist/dialog.cjs +1 -1
  36. package/dist/dialog.js +1 -1
  37. package/dist/dimensions-CdFEW3oU.cjs +1 -0
  38. package/dist/{dimensions-qj2CkPTy.js → dimensions-DbMN4145.js} +8 -8
  39. package/dist/{eraser-DuAfpO0P.js → eraser-BShvqlBE.js} +52 -49
  40. package/dist/eraser-rFMFKqsg.cjs +11 -0
  41. package/dist/eslint.config.d.ts +2 -2
  42. package/dist/eslint.config.d.ts.map +1 -1
  43. package/dist/ether.cjs +1 -1
  44. package/dist/ether.js +65 -62
  45. package/dist/external--liXQuyF.cjs +1 -0
  46. package/dist/external-B3ipr7m2.cjs +1 -0
  47. package/dist/{external-Ct1k30Nd.js → external-B7UnU0MW.js} +27 -26
  48. package/dist/{external-PXU0gc_j.cjs → external-BRxBwBtj.cjs} +44 -44
  49. package/dist/{external-MvcifV4O.js → external-Ba2qQp_c.js} +3 -3
  50. package/dist/{external-g_vt4Lku.js → external-Bjd-DyWx.js} +22 -30
  51. package/dist/{external-B3o5P8Yw.cjs → external-BwbypKCk.cjs} +1 -1
  52. package/dist/external-C0rrTDhu.cjs +1 -0
  53. package/dist/{external-Dp5OkGYV.js → external-CG70NZqY.js} +97 -96
  54. package/dist/external-Ci1Iy9ku.js +32 -0
  55. package/dist/external-CmYpRWry.cjs +1 -0
  56. package/dist/{external-B-JsNciM.js → external-CoCI_tg5.js} +9 -8
  57. package/dist/{external-CLQdSLv0.js → external-Ctnukdzx.js} +10 -9
  58. package/dist/{external-DXWEyk9d.js → external-CvYxFUrc.js} +17 -17
  59. package/dist/{external-DNbIzfVy.js → external-Czkrdv2A.js} +55 -54
  60. package/dist/external-Czv2P05t.cjs +1 -0
  61. package/dist/{external-DxmgAHkn.js → external-DAotNquC.js} +3 -3
  62. package/dist/external-DFvPOUIQ.cjs +1 -0
  63. package/dist/{external-DojNoICL.cjs → external-DWEpl5aM.cjs} +1 -1
  64. package/dist/{external-xfkS0zGI.js → external-JwicH0Yv.js} +18 -17
  65. package/dist/external-N5bKB8Zx.cjs +1 -0
  66. package/dist/external-ZtJmVgiY.cjs +1 -0
  67. package/dist/external-ieDANY3X.cjs +28 -0
  68. package/dist/{external-sYHm9OG8.js → external-s6DOSL29.js} +16 -15
  69. package/dist/flex.cjs +1 -1
  70. package/dist/flex.js +1 -1
  71. package/dist/{fontString-CSWLcJcC.js → fontString-76R2eWDd.js} +3 -3
  72. package/dist/fontString-BNnhiwug.cjs +1 -0
  73. package/dist/header.cjs +1 -1
  74. package/dist/header.js +1 -1
  75. package/dist/hooks-C4ji1BSZ.cjs +1 -0
  76. package/dist/{hooks-BeSuo_di.js → hooks-CWEfATTF.js} +16 -16
  77. package/dist/index.cjs +35 -18
  78. package/dist/index.js +15379 -14087
  79. package/dist/input.cjs +1 -1
  80. package/dist/input.js +1 -1
  81. package/dist/{jsx-runtime-BbD0H88J.js → jsx-runtime-tc70JA_2.js} +2 -2
  82. package/dist/list.cjs +1 -1
  83. package/dist/list.js +1 -1
  84. package/dist/menu.cjs +1 -1
  85. package/dist/menu.js +1 -1
  86. package/dist/pluto.css +1 -1
  87. package/dist/provider-Bt-E2O6g.js +810 -0
  88. package/dist/provider-DQkVj3tA.cjs +10 -0
  89. package/dist/src/access/policy/queries.d.ts +6 -6
  90. package/dist/src/button/Copy.d.ts +28 -0
  91. package/dist/src/button/Copy.d.ts.map +1 -0
  92. package/dist/src/button/Copy.spec.d.ts +2 -0
  93. package/dist/src/button/Copy.spec.d.ts.map +1 -0
  94. package/dist/src/button/external.d.ts +1 -0
  95. package/dist/src/button/external.d.ts.map +1 -1
  96. package/dist/src/channel/queries.d.ts +1 -1
  97. package/dist/src/channel/queries.d.ts.map +1 -1
  98. package/dist/src/color/Provider.d.ts +11 -1
  99. package/dist/src/color/Provider.d.ts.map +1 -1
  100. package/dist/src/device/queries.d.ts +122 -72
  101. package/dist/src/device/queries.d.ts.map +1 -1
  102. package/dist/src/errors/Fallback.d.ts.map +1 -1
  103. package/dist/src/flux/base/store.d.ts +2 -2
  104. package/dist/src/flux/base/store.d.ts.map +1 -1
  105. package/dist/src/flux/retrieve.d.ts +1 -1
  106. package/dist/src/flux/retrieve.d.ts.map +1 -1
  107. package/dist/src/icon/EtherCAT.d.ts +2 -0
  108. package/dist/src/icon/EtherCAT.d.ts.map +1 -0
  109. package/dist/src/icon/registry.d.ts +3 -0
  110. package/dist/src/icon/registry.d.ts.map +1 -1
  111. package/dist/src/index.d.ts +2 -0
  112. package/dist/src/index.d.ts.map +1 -1
  113. package/dist/src/input/Numeric.d.ts.map +1 -1
  114. package/dist/src/json/SelectType.d.ts +8 -0
  115. package/dist/src/json/SelectType.d.ts.map +1 -0
  116. package/dist/src/json/external.d.ts +3 -0
  117. package/dist/src/json/external.d.ts.map +1 -0
  118. package/dist/src/json/index.d.ts +2 -0
  119. package/dist/src/json/index.d.ts.map +1 -0
  120. package/dist/src/json/primitive.d.ts +7 -0
  121. package/dist/src/json/primitive.d.ts.map +1 -0
  122. package/dist/src/json/primitive.spec.d.ts +2 -0
  123. package/dist/src/json/primitive.spec.d.ts.map +1 -0
  124. package/dist/src/label/queries.d.ts +30 -2
  125. package/dist/src/label/queries.d.ts.map +1 -1
  126. package/dist/src/lineplot/aether/XAxis.d.ts +40 -0
  127. package/dist/src/lineplot/aether/XAxis.d.ts.map +1 -1
  128. package/dist/src/lineplot/aether/YAxis.d.ts +40 -0
  129. package/dist/src/lineplot/aether/YAxis.d.ts.map +1 -1
  130. package/dist/src/lineplot/aether/axis.d.ts +20 -0
  131. package/dist/src/lineplot/aether/axis.d.ts.map +1 -1
  132. package/dist/src/lineplot/range/aether/provider.d.ts +90 -6
  133. package/dist/src/lineplot/range/aether/provider.d.ts.map +1 -1
  134. package/dist/src/lineplot/tooltip/aether/tooltip.d.ts +80 -0
  135. package/dist/src/lineplot/tooltip/aether/tooltip.d.ts.map +1 -1
  136. package/dist/src/log/aether/Log.d.ts +30 -0
  137. package/dist/src/log/aether/Log.d.ts.map +1 -1
  138. package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
  139. package/dist/src/ranger/queries.d.ts +33 -5
  140. package/dist/src/ranger/queries.d.ts.map +1 -1
  141. package/dist/src/schematic/symbol/Forms.d.ts +2 -0
  142. package/dist/src/schematic/symbol/Forms.d.ts.map +1 -1
  143. package/dist/src/schematic/symbol/Primitives.d.ts +23 -0
  144. package/dist/src/schematic/symbol/Primitives.d.ts.map +1 -1
  145. package/dist/src/schematic/symbol/Symbols.d.ts +14 -0
  146. package/dist/src/schematic/symbol/Symbols.d.ts.map +1 -1
  147. package/dist/src/schematic/symbol/queries.d.ts +6 -6
  148. package/dist/src/schematic/symbol/registry.d.ts +2 -0
  149. package/dist/src/schematic/symbol/registry.d.ts.map +1 -1
  150. package/dist/src/status/aether/errorHandler.d.ts.map +1 -1
  151. package/dist/src/status/queries.d.ts +3 -2
  152. package/dist/src/status/queries.d.ts.map +1 -1
  153. package/dist/src/table/cells/Cells.d.ts +20 -0
  154. package/dist/src/table/cells/Cells.d.ts.map +1 -1
  155. package/dist/src/telem/aether/static.d.ts +10 -0
  156. package/dist/src/telem/aether/static.d.ts.map +1 -1
  157. package/dist/src/telem/aether/transformers.d.ts +15 -0
  158. package/dist/src/telem/aether/transformers.d.ts.map +1 -1
  159. package/dist/src/telem/control/Controller.d.ts +1 -0
  160. package/dist/src/telem/control/Controller.d.ts.map +1 -1
  161. package/dist/src/telem/control/Legend.d.ts +4 -2
  162. package/dist/src/telem/control/Legend.d.ts.map +1 -1
  163. package/dist/src/telem/control/aether/controller.d.ts +10 -0
  164. package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
  165. package/dist/src/telem/control/aether/indicator.d.ts +50 -0
  166. package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
  167. package/dist/src/telem/control/aether/legend.d.ts +22 -0
  168. package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
  169. package/dist/src/telem/control/aether/state.d.ts +13 -0
  170. package/dist/src/telem/control/aether/state.d.ts.map +1 -1
  171. package/dist/src/theming/aether/provider.d.ts +1413 -3
  172. package/dist/src/theming/aether/provider.d.ts.map +1 -1
  173. package/dist/src/theming/base/theme.d.ts +941 -1
  174. package/dist/src/theming/base/theme.d.ts.map +1 -1
  175. package/dist/src/user/queries.d.ts +1 -1
  176. package/dist/src/vis/axis/axis.d.ts +20 -0
  177. package/dist/src/vis/axis/axis.d.ts.map +1 -1
  178. package/dist/src/vis/gauge/aether/gauge.d.ts +30 -0
  179. package/dist/src/vis/gauge/aether/gauge.d.ts.map +1 -1
  180. package/dist/src/vis/gauge/use.d.ts +10 -0
  181. package/dist/src/vis/gauge/use.d.ts.map +1 -1
  182. package/dist/src/vis/line/aether/line.d.ts +10 -0
  183. package/dist/src/vis/line/aether/line.d.ts.map +1 -1
  184. package/dist/src/vis/measure/aether/measure.d.ts +80 -0
  185. package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
  186. package/dist/src/vis/rule/aether/aether.d.ts +20 -0
  187. package/dist/src/vis/rule/aether/aether.d.ts.map +1 -1
  188. package/dist/src/vis/stateIndicator/aether/index.d.ts +2 -0
  189. package/dist/src/vis/stateIndicator/aether/index.d.ts.map +1 -0
  190. package/dist/src/vis/stateIndicator/aether/stateIndicator.d.ts +48 -0
  191. package/dist/src/vis/stateIndicator/aether/stateIndicator.d.ts.map +1 -0
  192. package/dist/src/vis/stateIndicator/index.d.ts +2 -0
  193. package/dist/src/vis/stateIndicator/index.d.ts.map +1 -0
  194. package/dist/src/vis/stateIndicator/use.d.ts +9 -0
  195. package/dist/src/vis/stateIndicator/use.d.ts.map +1 -0
  196. package/dist/src/vis/value/aether/value.d.ts +60 -0
  197. package/dist/src/vis/value/aether/value.d.ts.map +1 -1
  198. package/dist/src/vis/value/redline.d.ts +5 -0
  199. package/dist/src/vis/value/redline.d.ts.map +1 -1
  200. package/dist/src/vis/value/use.d.ts +20 -0
  201. package/dist/src/vis/value/use.d.ts.map +1 -1
  202. package/dist/src/workspace/queries.d.ts +1 -1
  203. package/dist/stylelint.config.d.ts +3 -0
  204. package/dist/stylelint.config.d.ts.map +1 -0
  205. package/dist/tabs.cjs +1 -1
  206. package/dist/tabs.js +1 -1
  207. package/dist/text.cjs +1 -1
  208. package/dist/text.js +2 -2
  209. package/dist/theming.cjs +1 -1
  210. package/dist/theming.js +2 -2
  211. package/dist/tree.cjs +1 -1
  212. package/dist/tree.js +1 -1
  213. package/dist/triggers.cjs +1 -1
  214. package/dist/triggers.js +1 -1
  215. package/dist/{types-B5-Tni3G.js → types-CGRCBVD4.js} +2 -2
  216. package/dist/{types-C0tUDfsz.cjs → types-DI2vtOGs.cjs} +1 -1
  217. package/dist/units-Bu36uC6z.cjs +1 -0
  218. package/dist/units-DMip-eZH.js +14 -0
  219. package/dist/value-Bfn0uQuG.cjs +53 -0
  220. package/dist/{value-BmuhX6zs.js → value-DimszMFu.js} +2108 -2057
  221. package/dist/video.cjs +1 -1
  222. package/dist/video.js +1 -1
  223. package/package.json +25 -21
  224. package/dist/Animated-BbeJdao0.js +0 -28
  225. package/dist/Animated-Dvm2k_z_.cjs +0 -1
  226. package/dist/Animated-umWjgTzy.cjs +0 -1
  227. package/dist/Box-D27bV7QJ.cjs +0 -1
  228. package/dist/Button-BSek5HG5.cjs +0 -1
  229. package/dist/Button-DLtxKGH5.js +0 -308
  230. package/dist/Dialog-BpjxXSmw.cjs +0 -1
  231. package/dist/Editable-C-z-stcD.cjs +0 -1
  232. package/dist/Haul-WgPKptr9.cjs +0 -1
  233. package/dist/Items-07R286kW.cjs +0 -4
  234. package/dist/Menu-58O-OOPJ.cjs +0 -1
  235. package/dist/Provider-BA3zQVbv.cjs +0 -1
  236. package/dist/Tags-DWsEZD9t.cjs +0 -1
  237. package/dist/Text-DW5FpCk9.cjs +0 -1
  238. package/dist/Video-C56z7qvH.js +0 -9
  239. package/dist/Video-CBPTBLTB.cjs +0 -1
  240. package/dist/css-BkBrZtKZ.js +0 -5328
  241. package/dist/css-D3NdC2sx.cjs +0 -8
  242. package/dist/dimensions-C7b02rFi.cjs +0 -1
  243. package/dist/eraser-Bocga8Eb.cjs +0 -11
  244. package/dist/external-5_uHky7w.cjs +0 -28
  245. package/dist/external-B9omdiDK.cjs +0 -1
  246. package/dist/external-BIbdeWQE.cjs +0 -1
  247. package/dist/external-BRA_zA83.cjs +0 -1
  248. package/dist/external-Bjh6lsVm.cjs +0 -1
  249. package/dist/external-BwRkgEyo.cjs +0 -1
  250. package/dist/external-CdHyPhLI.js +0 -31
  251. package/dist/external-Ct2A_YCT.cjs +0 -1
  252. package/dist/external-DT82RBon.cjs +0 -1
  253. package/dist/external-DyTk_hS7.cjs +0 -1
  254. package/dist/fontString-TocVNWmy.cjs +0 -1
  255. package/dist/hooks-Eb94kuDd.cjs +0 -1
  256. package/dist/provider-D0K9E52u.js +0 -16236
  257. package/dist/provider-DksyuJua.cjs +0 -78
  258. package/dist/units-Bd_mf9Ye.cjs +0 -1
  259. package/dist/units-CEfK1L7C.js +0 -14
  260. package/dist/value-CZfzRi_x.cjs +0 -53
@@ -1,8 +0,0 @@
1
- "use strict";const a=require("zod"),cr=t=>a.union([a.union([a.null(),a.undefined()]).transform(()=>[]),t.array()]),Dn=t=>Array.isArray(t)?t:t==null?[]:[t],hr=(t,e)=>{if(Array.isArray(e))return e.reduce((s,i)=>hr(s,i),t??[]);if(t==null)return[e];const r=t.findIndex(s=>s==e),n=[...t];return r===-1?n.push(e):n[r]=e,n},Pn=((t,e)=>{if(t!=null)return Array.isArray(e)?t.filter(r=>!e.includes(r)):t.filter(r=>r!=e)}),fr=(t,e)=>{if(Array.isArray(e))return e.reduce((s,i)=>fr(s,i),t??[]);if(t==null)return[e];const r=t.findIndex(s=>s.key===e.key),n=[...t];return r===-1?n.push(e):n[r]=e,n},qn=((t,e)=>{if(t!=null)return Array.isArray(e)?t.filter(r=>!e.includes(r.key)):t.filter(r=>r.key!==e)}),Zn=Object.freeze(Object.defineProperty({__proto__:null,nullableZ:cr,remove:Pn,removeKeyed:qn,toArray:Dn,upsert:hr,upsertKeyed:fr},Symbol.toStringTag,{value:"Module"})),Fn=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},Fe=t=>{const e=(r,n=it)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!_e(r))return r;n=Wn(n);const s={},i=r;return"toJSON"in i&&typeof i.toJSON=="function"?e(i.toJSON(),n):(Object.keys(i).forEach(o=>{let u=i[o];const l=t(o);n.recursive&&(_e(u)?er(u)||(u=e(u,n)):n.recursiveInArray&&_t(u)&&(u=[...u].map(h=>{let f=h;return _e(h)?er(f)||(f=e(h,n)):_t(h)&&(f=e({key:h},n).key),f}))),s[l]=u}),s)};return e},St=Fe(Fn),Yn=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),dr=Fe(Yn),gr=t=>t.length===0?t:t[0].toUpperCase()+t.slice(1),Vn=[Number,String,Uint8Array],it={recursive:!0,recursiveInArray:!0},Wn=(t=it)=>(t.recursive==null?t=it:t.recursiveInArray??=!1,t),_t=t=>t!=null&&Array.isArray(t),_e=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),er=t=>Vn.some(e=>t instanceof e),Gn=t=>t.replace(/[\s_]+/g,"-").replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}-${n.toLowerCase()}`).toLowerCase(),Hn=Fe(Gn),Xn=t=>{if(t.length===0)return t;let e=t.replace(/[_-]/g," ");return e=e.replace(/([a-z0-9])([A-Z])/g,(r,n,s)=>`${n} ${s}`),e=e.replace(/([A-Z]+)([A-Z][a-z])/g,(r,n,s)=>`${n} ${s}`),e=e.replace(/\s+/g," ").trim(),e=e.replace(/\b\w/g,r=>r.toUpperCase()),e},Jn=Fe(Xn),Kn=Object.freeze(Object.defineProperty({__proto__:null,camelToSnake:dr,capitalize:gr,snakeToCamel:St,toKebab:Hn,toProperNoun:Jn},Symbol.toStringTag,{value:"Module"})),Ue=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Qn=Object.freeze(Object.defineProperty({__proto__:null,isObject:Ue},Symbol.toStringTag,{value:"Module"}));class _n{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e))}decode(e,r){return this.decodeString(this.decoder.decode(e),r)}decodeString(e,r){const n=JSON.parse(e),s=St(n);return r!=null?r.parse(s):s}encodeString(e){const r=dr(e);return JSON.stringify(r,(n,s)=>ArrayBuffer.isView(s)?Array.from(s):typeof s=="bigint"?s.toString():s)}}const ot=new _n,B=t=>t!=null&&typeof t=="object"&&"value"in t;class re{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}}const Nt=t=>t!=null&&typeof t=="object"&&"toString"in t,pr=t=>{if(Nt(t))return t?.toString().length===0;switch(typeof t){case"string":return t.length===0;case"number":return t===0;case"bigint":return t===0n;case"boolean":return!t;case"undefined":return!0;case"object":return t==null;default:return!1}},es=t=>!pr(t),ts=Object.freeze(Object.defineProperty({__proto__:null,ValueExtension:re,isCrudeValueExtension:B,isNonZero:es,isStringer:Nt,isZero:pr},Symbol.toStringTag,{value:"Module"})),at=t=>[...new Set(t)],rs=(t,e,r=!0)=>{const n=new Map;return t.forEach(s=>{const i=e(s);if(n.has(i)){if(r)return;n.delete(i)}n.set(i,s)}),Array.from(n.values())},ns=Object.freeze(Object.defineProperty({__proto__:null,by:rs,unique:at},Symbol.toStringTag,{value:"Module"})),Se=(t,e=!1)=>{const r=Nt(t)?"stringer":typeof t;let n;switch(r){case"string":n=(s,i)=>s.localeCompare(i);break;case"stringer":n=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":n=(s,i)=>Number(s)-Number(i);break;case"bigint":n=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":n=(s,i)=>Number(s)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?mr(n):n},ss=(t,e,r)=>{const n=Se(e[t],r);return(s,i)=>n(s[t],i[t])},is=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,yr=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=Se(t[0]),n=[...t].sort(r),s=[...e].sort(r);return n.every((i,o)=>i===s[o])?0:-1},os=(t,e)=>{const r=at(t),n=at(e);return yr(r,n)},as=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,mr=t=>(e,r)=>t(r,e),ne=0,Y=-1,V=1,br=t=>t<ne,wr=t=>t>ne,us=t=>t>=ne,Or=t=>t===ne,ls=(t,e)=>{const r=/([a-zA-Z]+)|(\d+)/g,n=t.replace(/[\s_.-]+/g,"").match(r),s=e.replace(/[\s_.-]+/g,"").match(r);if(!n||!s)return 0;for(let i=0;i<Math.min(n.length,s.length);i++){const o=n[i],u=s[i];if(isNaN(Number(o))&&isNaN(Number(u))){const l=o.localeCompare(u);if(l!==0)return l}else if(!isNaN(Number(o))&&!isNaN(Number(u))){const l=Number(o)-Number(u);if(l!==0)return l}else return isNaN(Number(o))?-1:1}return n.length-s.length},vr=(t,e,r)=>{let n=0,s=t.length;const i=r??Se(e);for(;n<s;){const o=Math.floor((n+s)/2),u=i(t[o],e);if(u===0)return o;u<0?n=o+1:s=o}return n},cs=(t,e,r)=>{const n=vr(t,e,r);t.splice(n,0,e)},hs=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:ne,GREATER_THAN:V,LESS_THAN:Y,insert:cs,isEqualTo:Or,isGreaterThan:wr,isGreaterThanEqual:us,isLessThan:br,newF:Se,newFieldF:ss,order:as,primitiveArrays:is,reverseF:mr,search:vr,stringsWithNumbers:ls,uniqueUnorderedPrimitiveArrays:os,unorderedPrimitiveArrays:yr},Symbol.toStringTag,{value:"Module"}));let Tr=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};const xr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",fs=`0123456789${xr}`,Sr=11,ds=Tr(xr,1),gs=Tr(fs,Sr-1),It=()=>`${ds()}${gs()}`,ps=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:Sr,create:It},Symbol.toStringTag,{value:"Module"})),ys=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,ms=2**8-1,Nr=2**12-1,bs=2**16-1,ws=2**32-1,Os=2n**64n-1n,vs=2**64-1,Ts=-128,xs=2**7-1,Ss=-32768,Ns=2**15-1,Is=-2147483648,Ms=2**31-1,As=-(2n**63n),ke=2n**63n-1n,zs=-9223372036854776e3,Ir=2**63-1,ue=t=>(e,r)=>{if(typeof e=="bigint"){if(De(r))return t(e,BigInt(r));const n=t(Number(e),Number(r));return typeof n=="number"?BigInt(Math.round(n)):n}return t(Number(e),Number(r))},q=ue((t,e)=>t-e),W=ue((t,e)=>t+e),Es=(t,e,r=1e-4)=>Math.abs(t-e)<r,ut=(t,e)=>{const r=typeof t=="bigint",n=typeof e=="bigint";return r&&n?t===e:r&&De(e)?t===BigInt(e):n&&De(t)?e===BigInt(t):t===e},js=t=>{const e=10**Math.floor(Math.log10(t));return Math.round(t/e)*e},Mr=ue((t,e)=>t<=e?t:e),De=t=>typeof t=="bigint"?!0:Number.isInteger(t),Us=ue((t,e)=>t>=e?t:e),Ar=t=>typeof t=="bigint"?t<0n?-t:t:t<0?-t:t,R=ue((t,e)=>t*e),Ne=ue((t,e)=>t/e),zr=a.z.tuple([a.z.number(),a.z.number()]),Mt=a.z.object({width:a.z.number(),height:a.z.number()}),Bs=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),$s=["start","center","end"],ae=a.z.object({x:a.z.number(),y:a.z.number()}),Er=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),Ye=["x","y"],At=a.z.enum(Ye),zt=["top","right","bottom","left"],Cs=a.z.enum(zt),Ve=["left","right"],Et=a.z.enum(Ve),We=["top","bottom"],jt=a.z.enum(We),Ut=["center"],lt=a.z.enum(Ut),Rs=[...zt,...Ut],Bt=a.z.enum(Rs);a.z.enum($s);const Ls=["first","last"];a.z.enum(Ls);const ks=a.z.object({lower:a.z.number(),upper:a.z.number()}),Ds=a.z.enum([...At.options,...Bt.options]),Ps=a.z.union([At,Bt,a.z.instanceof(String)]),w=(t,e,r)=>{const n={};if(typeof e=="object"&&(r=e,e=void 0),r={makeValid:!0,...r},typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else n.lower=t.lower,n.upper=t.upper;return r?.makeValid?jr(n):n},qs=Object.freeze({lower:0,upper:0}),Zs=Object.freeze({lower:-1/0,upper:1/0}),Fs=Object.freeze({lower:0,upper:1}),Ys=Object.freeze({lower:-1,upper:1}),Vs=(t,e)=>{if(t==null&&e==null)return!0;if(t==null||e==null)return!1;const r=w(t),n=w(e);return r?.lower===n?.lower&&r?.upper===n?.upper},jr=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,ct=(t,e)=>{const r=w(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e},k=(t,e)=>{const r=w(t);if(typeof e=="number"||typeof e=="bigint")return e>=r.lower&&e<r.upper;const n=w(e);return n.lower>=r.lower&&n.upper<=r.upper},Ws=(t,e)=>{const r=w(t),n=w(e);return r.lower===n.lower?!0:n.upper===r.lower||n.lower===r.upper?!1:k(r,n.upper)||k(r,n.lower)||k(n,r.upper)||k(n,r.lower)},le=t=>{const e=w(t);return e.upper-e.lower},Gs=t=>{const e=w(t);return typeof e.lower=="bigint"?e.lower===0n&&e.upper===0n:e.lower===0&&e.upper===0},Hs=t=>{const e=le(t);return typeof e=="number"?e===0:e===0n},Xs=t=>{const e=w(t);return typeof e.lower=="bigint"?!0:Number.isFinite(e.lower)&&Number.isFinite(e.upper)},Js=t=>{const e=w(t);return(e.upper+e.lower)/2},Ur=t=>({lower:Math.min(...t.map(e=>w(e).lower)),upper:Math.max(...t.map(e=>w(e).upper))}),Ks=t=>({lower:Math.max(...t.map(e=>w(e).lower)),upper:Math.min(...t.map(e=>w(e).upper))}),Qs=t=>{const e=w(t),r=typeof e.lower=="bigint";return Array.from({length:Number(le(t))},(n,s)=>r?e.lower+BigInt(s):e.lower+s)},ht=(t,e)=>{const r=t.map(i=>w(i)),n=r.findIndex(i=>k(i,e)||e<i.lower);if(n===-1)return{index:t.length,position:0};const s=r[n];return k(s,e)?{index:n,position:Number(e-s.lower)}:{index:n,position:0}},et={removeBefore:0,removeAfter:0,insertInto:0,deleteInBetween:0},_s=(t,e)=>{const r=t.map(h=>w(h)),n=w(e);if(r.length===0)return et;const s=ht(r,n.lower),i=ht(r,n.upper);if(s.index===t.length)return{...et,insertInto:t.length};if(i.index===0)return{...et,removeAfter:i.position};if(s.index===i.index)return s.position!==0&&i.position!==0?null:{removeAfter:i.position,removeBefore:s.position,insertInto:s.index,deleteInBetween:0};let o=i.index-s.index,u=s.index,l=q(Number(le(r[s.index])),s.position);return s.position!==0?(o-=1,u+=1):l=0,{removeBefore:l,removeAfter:i.position,insertInto:u,deleteInBetween:o}},Br=(t,e,r)=>{const n=t.map(u=>w(u)),s=r>0?1:r<0?-1:0;if(s===0)return e;let i=r,o=e;for(;ut(i,0)===!1;){const u=n.findIndex(l=>s>0?o>=l.lower&&o<l.upper:o>l.lower&&o<=l.upper);if(u!==-1){const l=n[u];let h;if(s>0?h=q(l.upper,o):h=q(o,l.lower),h>0){const f=Mr(Ar(i),h);if(o=W(o,s>0?f:-f),i=q(i,s>0?f:-f),ut(i,0))return o;continue}}if(s>0){const l=n.filter(h=>h.lower>o);if(l.length>0)o=l[0].lower;else return o}else{const l=n.filter(h=>h.upper<o);if(l.length>0)o=l[l.length-1].upper;else return o}}return o},$r=(t,e,r)=>{const n=t.map(o=>w(o));if(e===r)return typeof e=="bigint"?0n:0;const s=e<r?w([e,r]):w([r,e]);let i=typeof e=="bigint"?0n:0;for(const o of n){const u=o.lower>s.lower?o.lower:s.lower,l=o.upper<s.upper?o.upper:s.upper;if(u<l){const h=l-u;i=i+h}}return i},ei=Object.freeze(Object.defineProperty({__proto__:null,CLIP:Ys,DECIMAL:Fs,INFINITE:Zs,ZERO:qs,bounds:ks,buildInsertionPlan:_s,clamp:ct,construct:w,contains:k,distance:$r,equals:Vs,findInsertPosition:ht,isFinite:Xs,isZero:Gs,linspace:Qs,makeValid:jr,max:Ur,mean:Js,min:Ks,overlapsWith:Ws,span:le,spanIsZero:Hs,traverse:Br},Symbol.toStringTag,{value:"Module"})),ft=2,dt=3,Cr=2,ti=(t,e)=>{if(Number.isNaN(t)||!Number.isFinite(t))return t;const r=le(e);if(r==0)return t;let n;r>=1e3?n=ft:r>=1?n=dt:n=Math.ceil(-Math.log10(r))+Cr;const s=10**n;return Math.round(t*s)/s},ri=5,ni=1e-10,si=(t,e)=>{if(Number.isNaN(t)||!Number.isFinite(t))return t;const r=Math.abs(t);if(r===0)return 0;let n=!1,s=0;if(e!=null){s=le(e);const u=s/r;n=s>0&&u>ni}if(n){let u;s>=1e3?u=ft:s>=1?u=dt:u=Math.ceil(-Math.log10(s))+Cr;const l=10**u;return Math.round(t*l)/l}if(r>=1e3){const u=10**ft;return Math.round(t*u)/u}if(r>=1){const u=10**dt;return Math.round(t*u)/u}const i=Math.floor(Math.log10(r)),o=10**(ri-i-1);return Math.round(t*o)/o},ii=Object.freeze(Object.defineProperty({__proto__:null,MAX_INT16:Ns,MAX_INT32:Ms,MAX_INT64:ke,MAX_INT64_NUMBER:Ir,MAX_INT8:xs,MAX_UINT12:Nr,MAX_UINT16:bs,MAX_UINT32:ws,MAX_UINT64:Os,MAX_UINT64_NUMBER:vs,MAX_UINT8:ms,MIN_INT16:Ss,MIN_INT32:Is,MIN_INT64:As,MIN_INT64_NUMBER:zs,MIN_INT8:Ts,abs:Ar,add:W,closeTo:Es,div:Ne,equal:ut,isInteger:De,max:Us,min:Mr,mult:R,roundBySpan:ti,roundToNearestMagnitude:js,smartRound:si,sub:q},Symbol.toStringTag,{value:"Module"})),Rr=Ds,P=t=>Ye.includes(t)?t:We.includes(t)?"y":"x",oi=t=>P(t)==="x"?"y":"x",ai=t=>P(t)==="x"?"width":"height",ui=t=>P(t)==="x"?"left":"top",li=t=>Rr.safeParse(t).success,ci=t=>P(t)==="x"?"signedWidth":"signedHeight",hi=t=>t==="center"?!1:P(t)==="x",fi=t=>P(t)==="y",Lr=Object.freeze(Object.defineProperty({__proto__:null,DIRECTIONS:Ye,construct:P,crude:Rr,dimension:ai,direction:At,isDirection:li,isX:hi,isY:fi,location:ui,signedDimension:ci,swap:oi},Symbol.toStringTag,{value:"Module"})),di=Et,gi=jt,pi=lt,yi={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},mi={top:{clockwise:"left",counterclockwise:"right"},right:{clockwise:"top",counterclockwise:"bottom"},bottom:{clockwise:"right",counterclockwise:"left"},left:{clockwise:"bottom",counterclockwise:"top"}},bi=Ps,ee=t=>t instanceof String||!Ye.includes(t)?t:t==="x"?"left":"top",wi=t=>yi[ee(t)],Oi=(t,e)=>mi[t][e],Oe=t=>{const e=ee(t);return e==="top"||e==="bottom"?"y":"x"},vi=a.z.object({x:Et.or(lt),y:jt.or(lt)}),$t=a.z.object({x:Et,y:jt}),ce=Object.freeze({x:"left",y:"top"}),Ct=Object.freeze({x:"right",y:"top"}),Ge=Object.freeze({x:"left",y:"bottom"}),Rt=Object.freeze({x:"right",y:"bottom"}),Lt=Object.freeze({x:"center",y:"center"}),kt=Object.freeze({x:"center",y:"top"}),Dt=Object.freeze({x:"center",y:"bottom"}),Pt=Object.freeze({x:"right",y:"center"}),qt=Object.freeze({x:"left",y:"center"}),Ti=Object.freeze([qt,Pt,kt,Dt,ce,Ct,Ge,Rt,Lt]),Zt=(t,e)=>t.x===e.x&&t.y===e.y,xi=(t,e)=>{if(typeof e=="object"){let r=!0;return"x"in e&&(t.x===e.x||(r=!1)),"y"in e&&(t.y===e.y||(r=!1)),r}return t.x===e||t.y===e},kr=t=>[t.x,t.y],Be=t=>Oe(ee(t))==="x",Si=t=>Oe(ee(t))==="y",Ni=t=>`${t.x}${gr(t.y)}`,Ii=(t,e)=>{let r,n;if(typeof t=="object"&&"x"in t?(r=t.x,n=t.y):(r=ee(t),n=ee(e??t)),Oe(r)===Oe(n)&&r!=="center"&&n!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${r.toString()} - ${n.toString()}`);const s={...Lt};return r==="center"?Be(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n]:n==="center"?Be(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r]:Be(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r],s},Dr=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:Dt,BOTTOM_LEFT:Ge,BOTTOM_RIGHT:Rt,CENTER:Lt,CENTER_LEFT:qt,CENTER_LOCATIONS:Ut,CENTER_RIGHT:Pt,OUTER_LOCATIONS:zt,TOP_CENTER:kt,TOP_LEFT:ce,TOP_RIGHT:Ct,XY_LOCATIONS:Ti,X_LOCATIONS:Ve,Y_LOCATIONS:We,center:pi,construct:ee,constructXY:Ii,corner:$t,crude:bi,direction:Oe,isX:Be,isY:Si,location:Bt,outer:Cs,rotate:Oi,swap:wi,x:di,xy:vi,xyCouple:kr,xyEquals:Zt,xyMatches:xi,xyToString:Ni,y:gi},Symbol.toStringTag,{value:"Module"})),gt=a.z.union([a.z.number(),ae,zr,Mt,Bs,Er]),v=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},Z=Object.freeze({x:0,y:0}),Pr=Object.freeze({x:1,y:1}),Mi=Object.freeze({x:1/0,y:1/0}),Ai=Object.freeze({x:NaN,y:NaN}),Pe=(t,e,r=0)=>{const n=v(t),s=v(e);return r===0?n.x===s.x&&n.y===s.y:Math.abs(n.x-s.x)<=r&&Math.abs(n.y-s.y)<=r},zi=t=>Pe(t,Z),Ft=(t,e,r)=>{const n=v(t),s=v(e,r);return{x:n.x*s.x,y:n.y*s.y}},qr=(t,e)=>{const r=v(t);return{x:r.x+e,y:r.y}},Zr=(t,e)=>{const r=v(t);return{x:r.x,y:r.y+e}},ve=(t,e,r,...n)=>{if(typeof e=="string"){if(typeof r!="number")throw new Error("The value must be a number.");return e==="x"?qr(t,r):Zr(t,r)}if(typeof e=="object"&&"x"in e&&typeof e.x=="string"){const s=v(r),i=v(t);return e.x==="left"?s.x=-s.x:e.x==="center"&&(s.x=0),e.y==="top"?s.y=-s.y:e.y==="center"&&(s.y=0),{x:i.x+s.x,y:i.y+s.y}}return[t,e,r??Z,...n].reduce((s,i)=>{const o=v(i);return{x:s.x+o.x,y:s.y+o.y}},Z)},Ei=(t,e,r)=>{const n=v(t);return P(e)==="x"?{x:r,y:n.y}:{x:n.x,y:r}},ji=(t,e)=>{const r=v(t),n=v(e);return Math.sqrt((r.x-n.x)**2+(r.y-n.y)**2)},Ui=(t,e)=>{const r=v(t),n=v(e);return{x:n.x-r.x,y:n.y-r.y}},Bi=t=>{const e=v(t);return Number.isNaN(e.x)||Number.isNaN(e.y)},$i=t=>{const e=v(t);return Number.isFinite(e.x)&&Number.isFinite(e.y)},Ci=t=>{const e=v(t);return[e.x,e.y]},Ri=t=>{const e=v(t);return{left:e.x,top:e.y}},qe=(t,e=0)=>{const r=v(t);return{x:Number(r.x.toFixed(e)),y:Number(r.y.toFixed(e))}},de=(t,e)=>{const r=v(t),n=v(e);return{x:r.x-n.x,y:r.y-n.y}},ge=t=>{const e=v(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:-e.y/r,y:e.x/r}},Fr=t=>{const e=v(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:e.x/r,y:e.y/r}},Yr=(...t)=>{const e=t.reduce((r,n)=>ve(r,n),Z);return Ft(e,1/t.length)},Li=(t,e)=>{const r=[];for(let n=0;n<t.length;n++){const s=t[n];let i,o,u,l;if(n===0){const h=t[n+1],f=de(h,s);o=ge(f),u=o,l=e}else if(n===t.length-1){const h=t[n-1],f=de(s,h);i=ge(f),u=i,l=e}else{const h=t[n-1],f=t[n+1],y=de(s,h),p=de(f,s);i=ge(y),o=ge(p);const I=Math.acos((y.x*p.x+y.y*p.y)/(Math.hypot(y.x,y.y)*Math.hypot(p.x,p.y))),A=Math.sin(I/2);A===0?l=e:l=e/A,u=Fr(Yr(i,o))}r.push(Ft(u,l))}return r},ki=t=>{const e=v(t);return{x:e.y,y:e.x}},pt=t=>{const e=v(t);return{x:Math.round(e.x),y:Math.round(e.y)}},Di=t=>{const e=v(t);return{x:1/e.x,y:1/e.y}},Pi=(t,e,r)=>{const n=v(t),s=v(e),i=r==="clockwise"?Math.PI/2:-Math.PI/2,o=n.x-s.x,u=n.y-s.y,l=o*Math.cos(i)-u*Math.sin(i),h=o*Math.sin(i)+u*Math.cos(i);return{x:l+s.x,y:h+s.y}},qi=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Mi,NAN:Ai,ONE:Pr,ZERO:Z,average:Yr,calculateMiters:Li,clientXY:Er,construct:v,couple:Ci,crudeZ:gt,css:Ri,distance:ji,equals:Pe,isFinite:$i,isNan:Bi,isZero:zi,normal:ge,normalize:Fr,reciprocal:Di,rotate:Pi,round:pt,scale:Ft,set:Ei,sub:de,swap:ki,translate:ve,translateX:qr,translateY:Zr,translation:Ui,truncate:qe,xy:ae},Symbol.toStringTag,{value:"Module"})),Me=a.z.union([a.z.number(),a.z.string()]),Zi=a.z.object({top:Me,left:Me,width:Me,height:Me}),Fi=a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()}),Yi=a.z.object({one:ae,two:ae,root:$t}),Vr={one:Z,two:Z,root:ce},Vi={one:Z,two:Pr,root:Ge},Wr=(t,e)=>({one:t.one,two:t.two,root:e??t.root}),x=(t,e,r=0,n=0,s)=>{const i={one:{...Z},two:{...Z},root:s??ce};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Wi=(t,e,r)=>{const n=x(t);if(typeof e=="string"){if(r==null)throw new Error("Invalid arguments for resize");const s=P(e);return x(n.one,void 0,s==="x"?r:E(n),s==="y"?r:j(n),n.root)}return x(n.one,e,void 0,void 0,n.root)},Gi=(t,e,r=!0)=>{const n=x(t);let s=(i,o)=>i<o;return r&&(s=(i,o)=>i<=o),"one"in e?s(X(n),X(e))&&s(Q(e),Q(n))&&s(J(n),J(e))&&s(_(e),_(n)):s(X(n),e.x)&&s(e.x,Q(n))&&s(J(n),e.y)&&s(e.y,_(n))},Hi=(t,e)=>Pe(t.one,e.one)&&Pe(t.two,e.two)&&Zt(t.root,e.root),Gr=t=>({width:E(t),height:j(t)}),Xi=t=>({signedWidth:He(t),signedHeight:Xe(t)}),Ji=t=>({top:J(t),left:X(t),width:E(t),height:j(t)}),Yt=(t,e,r=!1)=>{const n=P(e)==="y"?Xe(t):He(t);return r?n:Math.abs(n)},G=(t,e)=>{const r=x(t);return{x:e.x==="center"?yt(r).x:te(r,e.x),y:e.y==="center"?yt(r).y:te(r,e.y)}},te=(t,e)=>{const r=x(t),n=kr(r.root).includes(e)?Math.min:Math.max;return Ve.includes(e)?n(r.one.x,r.two.x):n(r.one.y,r.two.y)},Ki=t=>Jr(t)===0,E=t=>Yt(t,"x"),j=t=>Yt(t,"y"),He=t=>{const e=x(t);return e.two.x-e.one.x},Xe=t=>{const e=x(t);return e.two.y-e.one.y},Hr=t=>G(t,ce),Qi=t=>G(t,kt),_i=t=>G(t,Ct),eo=t=>G(t,Ge),to=t=>G(t,Dt),ro=t=>G(t,Rt),no=t=>G(t,qt),so=t=>G(t,Pt),Q=t=>te(t,"right"),_=t=>te(t,"bottom"),X=t=>te(t,"left"),J=t=>te(t,"top"),yt=t=>ve(Hr(t),{x:He(t)/2,y:Xe(t)/2}),Vt=t=>{const e=x(t);return e.root.x==="left"?X(e):Q(e)},Wt=t=>{const e=x(t);return e.root.y==="top"?J(e):_(e)},io=t=>({x:Vt(t),y:Wt(t)}),$e=t=>{const e=x(t);return{lower:e.one.x,upper:e.two.x}},Ce=t=>{const e=x(t);return{lower:e.one.y,upper:e.two.y}},oo=(t,e)=>Wr(t,e),ao=(t,e)=>{const r=x(t),n=Ve.includes(e)?"x":We.includes(e)?"y":null;if(n===null)throw new Error(`Invalid location: ${e}`);const s=e==="top"||e==="left"?Math.min:Math.max,i={...r.one},o={...r.two};return i[n]=s(r.one[n],r.two[n]),o[n]=s(r.one[n],r.two[n]),[i,o]},uo=(t,e)=>{const r=x(t),n=x(e),s=Vt(n)+(E(n)-E(r))/2,i=Wt(n)+(j(n)-j(r))/2;return x({x:s,y:i},Gr(r))},Xr=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,lo=t=>E(t)/j(t),co=(t,e,r)=>{if(typeof e=="string"){if(r==null)throw new Error("Undefined amount passed into box.translate");const s=P(e);e=v(s,r)}const n=x(t);return x(ve(n.one,e),ve(n.two,e),void 0,void 0,n.root)},ho=(t,e)=>{const r=Math.max(X(t),X(e)),n=Math.max(J(t),J(e)),s=Math.min(Q(t),Q(e)),i=Math.min(_(t),_(e));return r>s||n>i?Vr:x({x:r,y:n},{x:s,y:i},void 0,void 0,t.root)},Jr=t=>E(t)*j(t),fo=(t,e)=>{const r=x(t);return x(qe(r.one,e),qe(r.two,e),void 0,void 0,r.root)},go=(t,e,r,n,s,i)=>{const o={x:t,y:e},u={x:t+r,y:e+n};return s.x!==i.x&&(s.x==="center"?(o.x-=r/2,u.x-=r/2):(o.x-=r,u.x-=r)),s.y!==i.y&&(s.y==="center"?(o.y-=n/2,u.y-=n/2):(o.y-=n,u.y-=n)),x(o,u,void 0,void 0,i)},po=t=>{const e=x(t);return x(pt(e.one),pt(e.two),void 0,void 0,e.root)},yo=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:Vi,ZERO:Vr,area:Jr,areaIsZero:Ki,aspect:lo,bottom:_,bottomCenter:to,bottomLeft:eo,bottomRight:ro,box:Yi,center:yt,centerLeft:no,centerRight:so,construct:x,constructWithAlternateRoot:go,contains:Gi,copy:Wr,css:Ji,cssBox:Zi,dim:Yt,dims:Gr,domRect:Fi,edgePoints:ao,equals:Hi,height:j,intersection:ho,isBox:Xr,left:X,loc:te,positionInCenter:uo,reRoot:oo,resize:Wi,right:Q,root:io,round:po,signedDims:Xi,signedHeight:Xe,signedWidth:He,top:J,topCenter:Qi,topLeft:Hr,topRight:_i,translate:co,truncate:fo,width:E,x:Vt,xBounds:$e,xyLoc:G,y:Wt,yBounds:Ce},Symbol.toStringTag,{value:"Module"})),Kr=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),mo=a.z.union([Mt,Kr,ae,zr]),bo={width:0,height:0},wo={width:1,height:1},D=(t,e)=>typeof t=="number"?{width:t,height:e??t}:Array.isArray(t)?{width:t[0],height:t[1]}:"x"in t?{width:t.x,height:t.y}:"signedWidth"in t?{width:t.signedWidth,height:t.signedHeight}:{...t},Oo=(t,e)=>{if(e==null)return!1;const r=D(t),n=D(e);return r.width===n.width&&r.height===n.height},vo=t=>{const e=D(t);return{width:e.height,height:e.width}},To=t=>{const e=D(t);return`0 0 ${e.width} ${e.height}`},xo=t=>{const e=D(t);return[e.width,e.height]},So=t=>({width:Math.max(...t.map(e=>D(e).width)),height:Math.max(...t.map(e=>D(e).height))}),No=t=>({width:Math.min(...t.map(e=>D(e).width)),height:Math.min(...t.map(e=>D(e).height))}),Io=(t,e)=>{const r=D(t);return{width:r.width*e,height:r.height*e}},Mo=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:wo,ZERO:bo,construct:D,couple:xo,crude:mo,dimensions:Mt,equals:Oo,max:So,min:No,scale:Io,signed:Kr,svgViewBox:To,swap:vo},Symbol.toStringTag,{value:"Module"})),Qr=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t,Ao=a.z.object({offset:gt,scale:gt}),zo=a.z.object({offset:a.z.number(),scale:a.z.number()}),Eo=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],jo=t=>(e,r,n,s)=>[e,s?n/t:n*t],Uo=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:i}=e,{lower:o,upper:u}=t,l=i-s,h=u-o;if(r==="dimension")return[t,n*(h/l)];const f=(n-s)*(h/l)+o;return[t,f]},Bo=t=>(e,r,n)=>[t,n],$o=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},Co=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=Qr(n,s,i),[e,n]};class F{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new F().translate(e)}static magnify(e){return new F().magnify(e)}static scale(e,r){return new F().scale(e,r)}translate(e){const r=this.new(),n=Eo(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=jo(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=w(e,r),s=this.new(),i=Uo(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=w(e,r),s=this.new(),i=Co(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=w(e,r),s=this.new(),i=Bo(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=$o();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new F;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],i)=>i(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([o,u])=>s>=o&&s<=u))return;const i=e.ops.findIndex((o,u)=>o.type==="scale"&&u>s);i!==-1&&r.push([s,i])}),r.forEach(([n,s])=>{const i=e.ops.slice(n,s);i.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new F}class C{x;y;currRoot;constructor(e=new F,r=new F,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new C().translate(e,r)}static translateX(e){return new C().translateX(e)}static translateY(e){return new C().translateY(e)}static clamp(e){return new C().clamp(e)}static magnify(e){return new C().magnify(e)}static scale(e){return new C().scale(e)}static reBound(e){return new C().reBound(e)}translate(e,r){const n=v(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(Xr(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Zt(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale($e(e)),r.y=r.y.scale(Ce(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound($e(e)),r.y=this.y.reBound(Ce(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp($e(e)),r.y=this.y.clamp(Ce(e)),r}copy(){const e=new C;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return x(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new C}const Ro=Object.freeze(Object.defineProperty({__proto__:null,Scale:F,XY:C,crudeXYTransform:Ao,transform:zo},Symbol.toStringTag,{value:"Module"})),_r=ae.extend({root:$t,units:a.object({x:a.enum(["px","decimal"]),y:a.enum(["px","decimal"])})}),Lo=_r.partial({root:!0,units:!0}),ko=t=>{const e={};return e[t.root?.x??"left"]=t?.units?.x==="px"?`${t.x}px`:`${t.x*100}%`,e[t.root?.y??"top"]=t?.units?.y==="px"?`${t.y}px`:`${t.y*100}%`,e},Do=({position:t,element:e,container:r})=>{const n={x:t.x,y:t.y};return t.units?.x==="decimal"?t.root?.x==="right"&&(n.x=1-t.x):t.root?.x==="right"?n.x=1-(t.x+E(e))/E(r):n.x/=E(r),t.units?.y==="decimal"?t.root?.y==="bottom"&&(n.y=1-t.y):t.root?.y==="bottom"?n.y=1-(t.y+j(e))/j(r):n.y/=j(r),n},Po=({position:t,element:e,container:r,lowerThreshold:n=.2,upperThreshold:s=.8})=>{const i={x:t.x,y:t.y,root:{...ce},units:{x:"px",y:"px"}};return t.x>s?(i.x=(1-t.x)*E(r)-E(e),i.root.x="right"):t.x<n?i.x=t.x*E(r):i.units.x="decimal",t.y>s?(i.y=(1-t.y)*j(r)-j(e),i.root.y="bottom"):t.y<n?i.y=t.y*j(r):i.units.y="decimal",i.x=Math.round(i.x*100)/100,{...i,...qe(i,3)}},qo=Object.freeze(Object.defineProperty({__proto__:null,calculate:Po,completeXY:_r,toCSS:ko,toDecimal:Do,xy:Lo},Symbol.toStringTag,{value:"Module"})),Zo=a.z.enum(["static","dynamic"]),tr=365,Ae=30,Fo=a.z.union([a.z.tuple([a.z.int()]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12)]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12),a.z.int().min(1).max(31)])]),en=(t,e)=>{const r=new d(e);if(![g.DAY,g.HOUR,g.MINUTE,g.SECOND,g.MILLISECOND,g.MICROSECOND,g.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof d?new d(n):new g(n)};class d extends re{constructor(e,r="UTC"){if(e==null)super(d.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*d.MILLISECOND.valueOf());else if(typeof e=="string")super(d.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(d.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=d.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e===Ir?e=ke:e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=d.MAX:e=d.MIN)),B(e)&&(e=e.value),super(BigInt(e.valueOf())+n)}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new d(BigInt(s.getTime())*d.MILLISECOND.valueOf()).truncate(d.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",u="00";i!=null&&([o,u]=i.split("."));let l=d.hours(parseInt(n??"00")).add(d.minutes(parseInt(s??"00"))).add(d.seconds(parseInt(o??"00"))).add(d.milliseconds(parseInt(u??"00")));return r==="local"&&(l=l.add(d.utcOffset)),l.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return d.parseTimeString(e,r);if(e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let s=e,i=0;if(e.includes(".")){const h=e.split(".");s=h[0];const f=h[1]||"0";i=parseInt(f.padEnd(3,"0").slice(0,3))}const o=r==="local"?new Date(s.replace("T"," ")):new Date(`${s}Z`),u=BigInt(o.getTime())*d.MILLISECOND.valueOf(),l=BigInt(i)*d.MILLISECOND.valueOf();return u+l}const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new d(BigInt(n.getTime())*d.MILLISECOND.valueOf(),r).valueOf()}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(d.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new g(BigInt(new Date().getTimezoneOffset())*d.MINUTE.valueOf())}static since(e){return new d().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new d(e).valueOf()}span(e){return this.range(e).span}range(e){return new N(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new d(e).valueOf()}afterEq(e){return this.valueOf()>=new d(e).valueOf()}before(e){return this.valueOf()<new d(e).valueOf()}beforeEq(e){return this.valueOf()<=new d(e).valueOf()}add(e){return new d(W(this.valueOf(),new g(e).valueOf()))}sub(e){return new d(q(this.valueOf(),new g(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(d.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(d.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(e){const r=this.date();return r.setUTCFullYear(e),new d(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new d(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new d(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new d(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new d(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new d(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new d(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new d(r)}toString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}remainder(e){return en(this,e)}get isToday(){return this.truncate(g.DAY).equals(d.now().truncate(g.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(g.days(30))?"shortDate":e.greaterThanOrEqual(g.DAY)?"dateTime":e.greaterThanOrEqual(g.HOUR)?"time":e.greaterThanOrEqual(g.SECOND)?"preciseTime":"ISOTime"}static now(){return new d(new Date)}static max(...e){let r=d.MIN;for(const n of e){const s=new d(n);s.after(r)&&(r=s)}return r}static min(...e){let r=d.MAX;for(const n of e){const s=new d(n);s.before(r)&&(r=s)}return r}static nanoseconds(e,r="UTC"){return new d(e,r)}static NANOSECOND=d.nanoseconds(1);static microseconds(e,r="UTC"){return d.nanoseconds(e*1e3,r)}static MICROSECOND=d.microseconds(1);static milliseconds(e,r="UTC"){return d.microseconds(e*1e3,r)}static MILLISECOND=d.milliseconds(1);static seconds(e,r="UTC"){return d.milliseconds(e*1e3,r)}static SECOND=d.seconds(1);static minutes(e,r="UTC"){return d.seconds(e*60,r)}static MINUTE=d.minutes(1);static hours(e,r="UTC"){return d.minutes(e*60,r)}static HOUR=d.hours(1);static days(e,r="UTC"){return d.hours(e*24,r)}static DAY=d.days(1);static MAX=new d(ke);static MIN=new d(0);static ZERO=new d(0);static z=a.z.union([a.z.instanceof(d),a.z.object({value:a.z.bigint()}).transform(e=>new d(e.value)),a.z.string().transform(e=>new d(BigInt(e))),a.z.number().transform(e=>new d(e)),a.z.bigint().transform(e=>new d(e)),a.z.date().transform(e=>new d(e)),a.z.custom(e=>e instanceof g).transform(e=>new d(e)),Fo.transform(e=>new d(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}}class g extends re{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),B(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof g?e:e instanceof z?e.period:e instanceof d?new g(e):(B(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.seconds(e):new g(e))}static fromMilliseconds(e){return e instanceof g?e:e instanceof z?e.period:e instanceof d?new g(e):(B(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.milliseconds(e):new g(e))}valueOf(){return this.value}lessThan(e){return this.valueOf()<new g(e).valueOf()}greaterThan(e){return this.valueOf()>new g(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new g(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new g(e).valueOf()}remainder(e){return en(this,e)}truncate(e){return new g(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(e="full"){if(e==="semantic")return this.toSemanticString();const r=this.truncate(g.DAY),n=this.truncate(g.HOUR),s=this.truncate(g.MINUTE),i=this.truncate(g.SECOND),o=this.truncate(g.MILLISECOND),u=this.truncate(g.MICROSECOND),l=this.truncate(g.NANOSECOND),h=r,f=n.sub(r),y=s.sub(n),p=i.sub(s),I=o.sub(i),A=u.sub(o),$=l.sub(u);let O="";return h.isZero||(O+=`${h.days}d `),f.isZero||(O+=`${f.hours}h `),y.isZero||(O+=`${y.minutes}m `),p.isZero||(O+=`${p.seconds}s `),I.isZero||(O+=`${I.milliseconds}ms `),A.isZero||(O+=`${A.microseconds}µs `),$.isZero||(O+=`${$.nanoseconds}ns`),O.trim()}toSemanticString(){const e=this.valueOf()<0n?-this.valueOf():this.valueOf(),r=new g(e),n=this.valueOf()<0n;if(r.valueOf()===0n)return"0s";if(r.lessThan(g.SECOND))return"< 1s";const s=r.days,i=r.hours,o=r.minutes,u=r.seconds,l=Math.floor(s/tr),h=Math.floor(s/Ae),f=Math.floor(s/7),y=Math.floor(s),p=Math.floor(i),I=Math.floor(o),A=Math.floor(u),$=n?"-":"";if(l>=1){let O=`${l}y`;if(l<2){const S=Math.floor(s%tr/Ae);S>0&&(O+=` ${S}mo`)}return $+O}if(f>=1&&s<Ae&&s%7===0){let O=`${f}w`;const S=Math.floor(s%7),K=Math.floor(i-f*7*24);return f<2&&(S>0?O+=` ${S}d`:K>0&&K<24&&(O+=` ${K}h`)),$+O}if(h>=1){let O=`${h}mo`;if(h<3){const S=Math.floor(s%Ae);S>0&&(O+=` ${S}d`)}return $+O}if(f>=1){let O=`${f}w`;const S=Math.floor(s%7),K=Math.floor(i-f*7*24);return f<2&&(S>0?O+=` ${S}d`:K>0&&K<24&&(O+=` ${K}h`)),$+O}if(y>=1){let O=`${y}d`;const S=Math.floor(i-y*24);return y<2&&S>0&&(O+=` ${S}h`),$+O}if(p>=1){let O=`${p}h`;if(p<3){const S=Math.floor(o-p*60);S>0&&(O+=` ${S}m`)}return $+O}if(I>=1){let O=`${I}m`;if(I<5){const S=Math.floor(u-I*60);S>0&&(O+=` ${S}s`)}return $+O}return`${$}${A}s`}mult(e){return new g(R(this.valueOf(),e))}div(e){return new g(Ne(this.valueOf(),e))}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(g.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(g.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(e){return this.valueOf()===new g(e).valueOf()}add(e){return new g(this.valueOf()+new g(e).valueOf())}sub(e){return new g(this.valueOf()-new g(e).valueOf())}static nanoseconds(e=1){return new g(e)}static NANOSECOND=g.nanoseconds(1);static microseconds(e=1){return g.nanoseconds(R(e,1e3))}static MICROSECOND=g.microseconds(1);static milliseconds(e=1){return g.microseconds(R(e,1e3))}static MILLISECOND=g.milliseconds(1);static seconds(e=1){return g.milliseconds(R(e,1e3))}static SECOND=g.seconds(1);static minutes(e=1){return g.seconds(R(e,60))}static MINUTE=g.minutes(1);static hours(e){return g.minutes(R(e,60))}static HOUR=g.hours(1);static days(e){return g.hours(R(e,24))}static DAY=g.days(1);static MAX=new g(ke);static MIN=new g(0);static ZERO=new g(0);static z=a.z.union([a.z.object({value:a.z.bigint()}).transform(e=>new g(e.value)),a.z.string().transform(e=>new g(BigInt(e))),a.z.number().transform(e=>new g(e)),a.z.bigint().transform(e=>new g(e)),a.z.instanceof(g),a.z.instanceof(d).transform(e=>new g(e)),a.z.custom(e=>e instanceof z).transform(e=>new g(e))])}class z extends re{constructor(e){B(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new z(e).valueOf()}get period(){return g.seconds(1/this.valueOf())}sampleCount(e){return new g(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new b(r).valueOf()}span(e){return g.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new b(r).valueOf())}add(e){return new z(W(this.valueOf(),new z(e).valueOf()))}sub(e){return new z(q(this.valueOf(),new z(e).valueOf()))}mult(e){return new z(R(this.valueOf(),e))}div(e){return new z(Ne(this.valueOf(),e))}static hz(e){return new z(e)}static khz(e){return z.hz(e*1e3)}static z=a.z.union([a.z.number().transform(e=>new z(e)),a.z.instanceof(z)])}class b extends re{constructor(e){B(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new m(e*this.valueOf())}add(e){return new b(W(this.valueOf(),new b(e).valueOf()))}sub(e){return new b(q(this.valueOf(),new b(e).valueOf()))}mult(e){return new b(R(this.valueOf(),e))}div(e){return new b(Ne(this.valueOf(),e))}static UNKNOWN=new b(0);static BIT128=new b(16);static BIT64=new b(8);static BIT32=new b(4);static BIT16=new b(2);static BIT8=new b(1);static z=a.z.union([a.z.number().transform(e=>new b(e)),a.z.instanceof(b)])}class N{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new d(e.start),this.end=new d(e.end)):(this.start=new d(e),this.end=new d(r))}get span(){return new g(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new N(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,r=g.ZERO){if(r.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=g.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=d.max(n.start,e.start),i=d.min(n.end,e.end);return i.before(s)?!1:new g(i.sub(s)).greaterThanOrEqual(r)}contains(e){return e instanceof N?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new N(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}static max(...e){return new N(d.min(...e.map(r=>r.start)),d.max(...e.map(r=>r.end)))}static MAX=new N(d.MIN,d.MAX);static ZERO=new N(d.ZERO,d.ZERO);static z=a.z.union([a.z.object({start:d.z,end:d.z}).transform(e=>new N(e.start,e.end)),a.z.instanceof(N)]);static sort(e,r){return d.sort(e.start,r.start)||d.sort(e.end,r.end)}static merge(...e){return N.max(...e.map(r=>new N(r).makeValid()))}}class c extends re{constructor(e){if(B(e)&&(e=e.value),e instanceof c||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=c.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r==null)throw new Error(`unable to find data type for ${e.toString()}`);super(r.valueOf())}}get Array(){const e=c.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(e=!1){return e?c.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(c.JSON)||this.equals(c.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(c.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=c.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(c.UINT8)||this.equals(c.UINT16)||this.equals(c.UINT32)||this.equals(c.UINT64)}get isSignedInteger(){return this.equals(c.INT8)||this.equals(c.INT16)||this.equals(c.INT32)||this.equals(c.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsignedInteger&&e.isSignedInteger?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(c.INT32)&&e.equals(c.FLOAT64)||this.equals(c.INT8)&&e.equals(c.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsignedInteger===e.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return c.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new c("unknown");static FLOAT64=new c("float64");static FLOAT32=new c("float32");static INT64=new c("int64");static INT32=new c("int32");static INT16=new c("int16");static INT8=new c("int8");static UINT64=new c("uint64");static UINT32=new c("uint32");static UINT16=new c("uint16");static UINT8=new c("uint8");static BOOLEAN=new c("boolean");static TIMESTAMP=new c("timestamp");static UUID=new c("uuid");static STRING=new c("string");static JSON=new c("json");static ARRAY_CONSTRUCTORS=new Map([[c.UINT8.toString(),Uint8Array],[c.UINT16.toString(),Uint16Array],[c.UINT32.toString(),Uint32Array],[c.UINT64.toString(),BigUint64Array],[c.FLOAT32.toString(),Float32Array],[c.FLOAT64.toString(),Float64Array],[c.INT8.toString(),Int8Array],[c.INT16.toString(),Int16Array],[c.INT32.toString(),Int32Array],[c.INT64.toString(),BigInt64Array],[c.TIMESTAMP.toString(),BigInt64Array],[c.STRING.toString(),Uint8Array],[c.JSON.toString(),Uint8Array],[c.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,c.UINT8],[Uint16Array.name,c.UINT16],[Uint32Array.name,c.UINT32],[BigUint64Array.name,c.UINT64],[Float32Array.name,c.FLOAT32],[Float64Array.name,c.FLOAT64],[Int8Array.name,c.INT8],[Int16Array.name,c.INT16],[Int32Array.name,c.INT32],[BigInt64Array.name,c.INT64]]);static DENSITIES=new Map([[c.UINT8.toString(),b.BIT8],[c.UINT16.toString(),b.BIT16],[c.UINT32.toString(),b.BIT32],[c.UINT64.toString(),b.BIT64],[c.FLOAT32.toString(),b.BIT32],[c.FLOAT64.toString(),b.BIT64],[c.INT8.toString(),b.BIT8],[c.INT16.toString(),b.BIT16],[c.INT32.toString(),b.BIT32],[c.INT64.toString(),b.BIT64],[c.TIMESTAMP.toString(),b.BIT64],[c.STRING.toString(),b.UNKNOWN],[c.JSON.toString(),b.UNKNOWN],[c.UUID.toString(),b.BIT128]]);static ALL=[c.UNKNOWN,c.FLOAT64,c.FLOAT32,c.INT64,c.INT32,c.INT16,c.INT8,c.UINT64,c.UINT32,c.UINT16,c.UINT8,c.TIMESTAMP,c.UUID,c.STRING,c.JSON];static SHORT_STRINGS=new Map([[c.UINT8.toString(),"u8"],[c.UINT16.toString(),"u16"],[c.UINT32.toString(),"u32"],[c.UINT64.toString(),"u64"],[c.INT8.toString(),"i8"],[c.INT16.toString(),"i16"],[c.INT32.toString(),"i32"],[c.INT64.toString(),"i64"],[c.FLOAT32.toString(),"f32"],[c.FLOAT64.toString(),"f64"],[c.BOOLEAN.toString(),"bool"],[c.TIMESTAMP.toString(),"ts"],[c.UUID.toString(),"uuid"],[c.STRING.toString(),"str"],[c.JSON.toString(),"json"]]);static BIG_INT_TYPES=[c.INT64,c.UINT64,c.TIMESTAMP];static z=a.z.union([a.z.string().transform(e=>new c(e)),a.z.instanceof(c)])}class m extends re{constructor(e){B(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return B(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return B(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return B(e)&&(e=e.value),new m(W(this.valueOf(),e.valueOf()))}sub(e){return B(e)&&(e=e.value),new m(q(this.valueOf(),e.valueOf()))}mult(e){return new m(R(this.valueOf(),e))}div(e){return new m(Ne(this.valueOf(),e))}truncate(e){return new m(Math.trunc(this.valueOf()/new m(e).valueOf())*new m(e).valueOf())}remainder(e){return m.bytes(this.valueOf()%new m(e).valueOf())}get gigabytes(){return this.valueOf()/m.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/m.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/m.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/m.TERABYTE.valueOf()}toString(){const e=this.truncate(m.TERABYTE),r=this.truncate(m.GIGABYTE),n=this.truncate(m.MEGABYTE),s=this.truncate(m.KILOBYTE),i=this.truncate(m.BYTE),o=e,u=r.sub(e),l=n.sub(r),h=s.sub(n),f=i.sub(s);let y="";return o.isZero||(y+=`${o.terabytes}TB `),u.isZero||(y+=`${u.gigabytes}GB `),l.isZero||(y+=`${l.megabytes}MB `),h.isZero||(y+=`${h.kilobytes}KB `),(!f.isZero||y==="")&&(y+=`${f.valueOf()}B`),y.trim()}static bytes(e=1){return new m(e)}static BYTE=new m(1);static kilobytes(e=1){return m.bytes(new m(e).valueOf()*1e3)}static KILOBYTE=m.kilobytes(1);static megabytes(e=1){return m.kilobytes(new m(e).valueOf()*1e3)}static MEGABYTE=m.megabytes(1);static gigabytes(e=1){return m.megabytes(new m(e).valueOf()*1e3)}static GIGABYTE=m.gigabytes(1);static terabytes(e){return m.gigabytes(new m(e).valueOf()*1e3)}static TERABYTE=m.terabytes(1);static ZERO=new m(0);static z=a.z.union([a.z.number().transform(e=>new m(e)),a.z.instanceof(m)]);get isZero(){return this.valueOf()===0}}a.z.object({start:a.z.number(),end:a.z.number()});const Yo=a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]),tn=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof d||t instanceof g||t instanceof Date},Vo=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):q(r,n),Wo="00000000-0000-0000-0000-000000000000",Go=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Ho(t){return typeof t=="string"&&Go.test(t)}const M=[];for(let t=0;t<256;++t)M.push((t+256).toString(16).slice(1));function rn(t,e=0){return(M[t[e+0]]+M[t[e+1]]+M[t[e+2]]+M[t[e+3]]+"-"+M[t[e+4]]+M[t[e+5]]+"-"+M[t[e+6]]+M[t[e+7]]+"-"+M[t[e+8]]+M[t[e+9]]+"-"+M[t[e+10]]+M[t[e+11]]+M[t[e+12]]+M[t[e+13]]+M[t[e+14]]+M[t[e+15]]).toLowerCase()}function Xo(t,e=0){const r=rn(t,e);if(!Ho(r))throw TypeError("Stringified UUID is invalid");return r}let tt;const Jo=new Uint8Array(16);function Ko(){if(!tt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");tt=crypto.getRandomValues.bind(crypto)}return tt(Jo)}const Qo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),rr={randomUUID:Qo};function _o(t,e,r){t=t||{};const n=t.random??t.rng?.()??Ko();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,rn(n)}function ea(t,e,r){return rr.randomUUID&&!t?rr.randomUUID():_o(t)}const ta=()=>ea(),Gt=(t,e)=>Xo(t,e),ra=Wo,na=Object.freeze(Object.defineProperty({__proto__:null,ZERO:ra,create:ta,parse:Gt},Symbol.toStringTag,{value:"Module"})),H=-1,mt={[Symbol.iterator]:()=>mt,next:()=>({done:!0,value:void 0})},sa=a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),ia=a.z.union([a.z.null(),a.z.undefined()]).transform(()=>new Uint8Array().buffer),bt=10,nn=(t,e)=>{if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},sn="sy_x_telem_series";class L{key;discriminator=sn;dataType;sampleOffset;gl;_data;timeRange=N.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=H;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=a.z.object({timeRange:N.z.optional(),dataType:c.z,alignment:a.z.coerce.bigint().optional(),data:a.z.union([sa,ia,a.z.instanceof(ArrayBuffer),a.z.instanceof(Uint8Array)]),glBufferUsage:Zo.default("static").optional()});static z=L.crudeZ.transform(e=>new L(e));constructor(e){oa(e)&&(e={data:e}),e.data??=[];const{dataType:r,timeRange:n,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:u=1n,key:l=It(),data:h}=e;if(on(h)){const p=h;this.key=p.key,this.dataType=p.dataType,this.sampleOffset=p.sampleOffset,this.gl=p.gl,this._data=p._data,this.timeRange=p.timeRange,this.alignment=p.alignment,this.alignmentMultiple=p.alignmentMultiple,this.cachedMin=p.cachedMin,this.cachedMax=p.cachedMax,this.writePos=p.writePos,this._refCount=p._refCount,this.cachedLength=p.cachedLength;return}const f=tn(h),y=Array.isArray(h);if(r!=null)this.dataType=new c(r);else{if(h instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(y||f){let p=h;if(!f){if(h.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");p=h[0]}if(typeof p=="string")this.dataType=c.STRING;else if(typeof p=="number")this.dataType=c.FLOAT64;else if(typeof p=="bigint")this.dataType=c.INT64;else if(typeof p=="boolean")this.dataType=c.BOOLEAN;else if(p instanceof d||p instanceof Date||p instanceof d)this.dataType=c.TIMESTAMP;else if(typeof p=="object")this.dataType=c.JSON;else throw new Error(`cannot infer data type of ${typeof p} when constructing a Series from a JS array`)}else this.dataType=new c(h)}if(!y&&!f)this._data=h;else if(y&&h.length===0)this._data=new this.dataType.Array([]).buffer;else{let p=f?[h]:h;const I=p[0];(I instanceof d||I instanceof Date||I instanceof g)&&(p=p.map(A=>new d(A).valueOf())),this.dataType.equals(c.STRING)?(this.cachedLength=p.length,this._data=new TextEncoder().encode(`${p.join(`
2
- `)}
3
- `).buffer):this.dataType.equals(c.JSON)?(this.cachedLength=p.length,this._data=new TextEncoder().encode(`${p.map(A=>ot.encodeString(A)).join(`
4
- `)}
5
- `).buffer):this.dataType.usesBigInt&&typeof I=="number"?this._data=new this.dataType.Array(p.map(A=>BigInt(Math.round(A)))).buffer:!this.dataType.usesBigInt&&typeof I=="bigint"?this._data=new this.dataType.Array(p.map(Number)).buffer:this._data=new this.dataType.Array(p).buffer}this.key=l,this.alignment=o,this.alignmentMultiple=u,this.sampleOffset=s??0,this.timeRange=n??N.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new c(r).Array(e),i=new L({data:s.buffer,dataType:r,...n});return i.writePos=0,i}get refCount(){return this._refCount}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){this._refCount--,this.refCount===0&&this.gl.control!=null?this.maybeGarbageCollectGLBuffer(this.gl.control):this.refCount<0&&console.warn("cannot release a series with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===H)return 0;const r=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,r);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this.cachedLength!=null&&(this.cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===H)return 0;const r=this.capacity-this.writePos,n=e.sub(0,r);return this.writeToUnderlyingData(n),this.cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===H?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
6
- `).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(c.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(ot.decodeString(r)))}get byteCapacity(){return new m(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===H?this.byteCapacity:this.dataType.isVariable?new m(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===H?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const r=[0];return this.data.forEach((n,s)=>{n===bt&&(e++,r.push(s+1))}),this._cachedIndexes=r,this.cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=Vo(this.dataType,e,this.data[s],r);return new L({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(c.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this.cachedMax??=this.calcRawMax(),W(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(c.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this.cachedMin??=this.calcRawMin(),W(this.cachedMin,this.sampleOffset))}get bounds(){return w(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){const r=e.cachedMin??e.calcRawMin();r<this.cachedMin&&(this.cachedMin=r)}if(this.cachedMax!=null){const r=e.cachedMax??e.calcRawMax();r>this.cachedMax&&(this.cachedMax=r)}}atAlignment(e,r){const n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(r===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,r)}at(e,r=!1){if(this.dataType.isVariable)return this.atVariable(e,r??!1);if(this.dataType.equals(c.UUID))return this.atUUID(e,r);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return W(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=Gt(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(r)throw new Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,r){let n=0,s=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],s=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===bt){if(e===0){s=o;break}n=o+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(n,s);return this.dataType.equals(c.STRING)?new TextDecoder().decode(i):St(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const s=Se(e);for(;r<=n;){const i=Math.floor((r+n)/2),o=s(this.at(i,!0),e);if(o===0)return i;o<0?r=i+1:n=i-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(c.FLOAT32)&&!this.dataType.equals(c.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:s}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==H){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=H}as(e){return nn(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:sr(this.alignmentBounds.lower),upper:sr(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return w(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new aa(this);return this.dataType.equals(c.JSON)?new Ht(e):e}return this.dataType.equals(c.UUID)?new ua(this):new la(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new nr(this,e,r??this.length)}subAlignmentIterator(e,r){const n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),s=Math.ceil(Number(r-this.alignment)/Number(this.alignmentMultiple));return new nr(this,n,s)}subBytes(e,r){if(e>=0&&(r==null||r>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,r);return new L({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,r,n){if(r<=0&&(n==null||n>=this.length))return this;let s;return e?s=this.data.subarray(r,n):s=this.data.slice(r,n),new L({data:s,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(r)})}reAlign(e){return new L({data:this.buffer,dataType:this.dataType,timeRange:N.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)e+=`${this.at(r)?.toString()}`,e+=",";e+="...,";for(let r=-5;r<0;r++)e+=this.at(r)?.toString(),r<-1&&(e+=",")}return e+="])",e}}const oa=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof L?!0:tn(t),on=ys(sn,L);class nr{series;end;index;constructor(e,r,n){this.series=e;const s=w(0,e.length+1);this.end=ct(s,n),this.index=ct(s,r)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class aa{series;index;decoder;constructor(e){if(!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==bt;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}}class Ht{wrapped;static schema=a.z.record(a.z.string(),a.z.unknown());constructor(e){this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:ot.decodeString(e.value,Ht.schema)}}}class ua{series;index;data;density;constructor(e){if(!e.dataType.equals(c.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=e,this.index=0,this.data=new Uint8Array(e.buffer),this.density=c.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const e=Gt(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}}class la{series;index;constructor(e){this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class ca{series;constructor(e=[]){if(e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){return nn(e,this.dataType),this}get dataType(){return this.series.length===0?c.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?N.ZERO:new N(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?w(0n,0n):w(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){const r=()=>new Error(`cannot push a ${e.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),n=e.dataType.equals(this.dataType);if(on(e)){if(this.series.length!==0&&!n)throw r();this.series.push(e)}else{if(this.series.length!==0&&e.series.length!==0&&!n)throw r();this.series.push(...e.series)}}get length(){return this.series.reduce((e,r)=>e+r.length,0)}atAlignment(e,r){for(const n of this.series)if(k(n.alignmentBounds,e))return n.atAlignment(e,r);if(r)throw new Error(`[series] - no value at alignment ${e}`)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,r){return new rt(this,e,r??this.length)}subAlignmentIterator(e,r){if(e>=this.alignmentBounds.upper||r<=this.alignmentBounds.lower)return mt;let n=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)n+=o.length;else if(k(o.alignmentBounds,e)){n+=Math.ceil(Number(e-o.alignment)/Number(o.alignmentMultiple));break}}let s=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(r<o.alignment)break;if(r>=o.alignmentBounds.upper)s+=o.length;else if(k(o.alignmentBounds,r)){s+=Math.ceil(Number(r-o.alignment)/Number(o.alignmentMultiple));break}}return new rt(this,n,s)}subAlignmentSpanIterator(e,r){if(e>=this.alignmentBounds.upper)return mt;r=Math.min(r,Number(this.distance(e,this.alignmentBounds.upper)));let n=0;for(let s=0;s<this.series.length;s++){const i=this.series[s];if(e<i.alignment)break;if(e>=i.alignmentBounds.upper)n+=i.length;else if(k(i.alignmentBounds,e)){n+=Number(e-i.alignment);break}}return new rt(this,n,n+r)}updateGLBuffer(e){this.series.forEach(r=>r.updateGLBuffer(e))}get bounds(){return Ur(this.series.map(e=>e.bounds))}get byteLength(){return new m(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,r){const n=this.series.map(s=>s.alignmentBounds);return Br(n,e,r)}acquire(e){this.series.forEach(r=>r.acquire(e))}release(){this.series.forEach(e=>e.release())}distance(e,r){const n=this.series.map(s=>s.alignmentBounds);return $r(n,e,r)}parseJSON(e){if(!this.dataType.equals(c.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(r=>r.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new ha(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}}class ha{series;seriesIndex;internal;constructor(e){this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}}class rt{series;index;end;constructor(e,r,n){this.series=e,this.end=n,this.index=r}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}const sr=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}};a.z.object({baseInterval:g.z.optional(),maxRetries:a.z.number().optional(),scale:a.z.number().optional()});const fa=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Ze=a.z.string().regex(fa),oe=a.z.number().min(0).max(255),an=a.z.number().min(0).max(1),Je=a.z.tuple([oe,oe,oe,an]),da=a.z.tuple([oe,oe,oe]),ga=a.z.object({rgba255:Je}),pa=a.z.number().min(0).max(360),ya=a.z.number().min(0).max(100),ma=a.z.number().min(0).max(100),un=a.z.tuple([pa,ya,ma,an]),Ke=a.z.union([Ze,da,Je,un,ga]),Qe=Ke.transform(t=>T(t)),ba=t=>Qe.safeParse(t).success,wa=t=>Je.safeParse(t).success,Oa=(t=>{if(t==null)return;const e=Qe.safeParse(t);if(e.success)return cn(e.data);if(typeof t=="string")return t;throw e.error}),T=(t,e=1)=>{if(t=Ke.parse(t),typeof t=="string")return Re(t,e);if(Array.isArray(t)){if(t.length<3||t.length>4)throw new Error(`Invalid color: [${t.join(", ")}]`);return t.length===3?[...t,e]:t}return t.rgba255},ln=(t,e)=>{if(t==null||e==null)return t==e;const r=T(t),n=T(e);return r.every((s,i)=>s===n[i])},va=(t=>{if(t==null)return;const[e,r,n,s]=T(t);return`#${ze(e)}${ze(r)}${ze(n)}${s===1?"":ze(s*255)}`}),cn=t=>{const[e,r,n,s]=T(t);return`rgba(${e}, ${r}, ${n}, ${s})`},Ta=t=>`rgb(${hn(t)})`,hn=t=>{const[e,r,n]=T(t);return`${e}, ${r}, ${n}`},xa=t=>[...Xt(t),we(t)],Xt=t=>[ye(t)/255,me(t)/255,be(t)/255],ye=t=>T(t)[0],me=t=>T(t)[1],be=t=>T(t)[2],we=t=>T(t)[3],Sa=t=>ln(Jt,t),Na=t=>$a(T(t)),Ia=(t,e)=>{const[r,n,s]=T(t);if(e>100)throw new Error(`Color opacity must be between 0 and 100, got ${e}`);return e>1&&(e/=100),[r,n,s,e]},Te=t=>{const[e,r,n]=Xt(t).map(s=>s<=.03928?s/12.92:((s+.055)/1.055)**2.4);return Number((.2126*e+.7152*r+.0722*n).toFixed(3))},Ma=t=>{const[e,r,n]=Xt(t);return 1-(Math.max(e,r,n)-Math.min(e,r,n))},wt=(t,e)=>{const r=T(t),n=T(e),s=Te(r),i=Te(n);return(Math.max(s,i)+.5)/(Math.min(s,i)+.5)},Aa=(t,...e)=>{if(e.length===0)throw new Error("[Color.pickByContrast] - must provide at least one color");const r=T(t),[n]=e.sort((s,i)=>wt(r,i)-wt(r,s));return T(n)},za=t=>Te(t)<.5,Ea=t=>Te(t)>.5,Re=(t,e=1)=>(t=Ze.parse(t),t=ja(t),[Ee(t,0),Ee(t,2),Ee(t,4),t.length===8?Ee(t,6)/255:e]),Jt=[0,0,0,0],ze=t=>Math.floor(t).toString(16).padStart(2,"0"),Ee=(t,e)=>parseInt(t.slice(e,e+2),16),ja=t=>t.startsWith("#")?t.slice(1):t,ir={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff",yellow:"#ffff00",cyan:"#00ffff",magenta:"#ff00ff",silver:"#c0c0c0",gray:"#808080",grey:"#808080",maroon:"#800000",olive:"#808000",lime:"#00ff00",aqua:"#00ffff",teal:"#008080",navy:"#000080",fuchsia:"#ff00ff",purple:"#800080",orange:"#ffa500",brown:"#a52a2a",tan:"#d2b48c",gold:"#ffd700",indigo:"#4b0082",violet:"#ee82ee",pink:"#ffc0cb",coral:"#ff7f50",salmon:"#fa8072",khaki:"#f0e68c",crimson:"#dc143c",transparent:"transparent"},Ua=t=>{if(!t)return;const e=t.trim().toLowerCase();if(!(e==="transparent"||e==="none")){if(e.startsWith("#")){if(e.length===4){const r=e[1],n=e[2],s=e[3],i=`#${r}${r}${n}${n}${s}${s}`;if(Ze.safeParse(i).success)return Re(i)}return(e.length===7||e.length===9)&&Ze.safeParse(e).success?Re(e):void 0}if(e.startsWith("rgb")){const r=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);if(r){const[,n,s,i,o]=r;return[parseInt(n),parseInt(s),parseInt(i),o?parseFloat(o):1]}}if(ir[e])return Re(ir[e])}},Ba=t=>{t=un.parse(t);let[e,r,n]=t;const s=t[3];e/=360,r/=100,n/=100;let i,o,u;if(r===0)i=o=u=n;else{const l=n<.5?n*(1+r):n+r-n*r,h=2*n-l;i=nt(h,l,e+1/3),o=nt(h,l,e),u=nt(h,l,e-1/3)}return[Math.round(i*255),Math.round(o*255),Math.round(u*255),s]},nt=(t,e,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*(2/3-r)*6:t),$a=t=>{t=Je.parse(t);let[e,r,n]=t;const s=t[3];e/=255,r/=255,n/=255;const i=Math.max(e,r,n),o=Math.min(e,r,n);let u,l,h=(i+o)/2;if(i===o)u=l=0;else{const f=i-o;l=h>.5?f/(2-i-o):f/(i+o),i===e?u=(r-n)/f+(r<n?6:0):i===r?u=(n-e)/f+2:u=(e-r)/f+4,u/=6}return u*=360,l*=100,h*=100,[Math.round(u),Math.round(l),Math.round(h),s]},Ca=T("#000000"),Ra=T("#ffffff"),fn=a.z.object({key:a.z.string(),color:Ke,position:a.z.number(),switched:a.z.boolean().optional()}),La=a.z.array(fn),ka=(t,e)=>{if(t.length===0)return Jt;if(t=t.slice().sort((r,n)=>r.position-n.position),e<=t[0].position)return T(t[0].color);if(e>=t[t.length-1].position)return T(t[t.length-1].color);for(let r=0;r<t.length-1;r++){const n=t[r],s=t[r+1];if(e<n.position||e>s.position)continue;if(e===n.position)return T(n.color);if(e===s.position)return T(s.color);const i=(e-n.position)/(s.position-n.position),o=T(n.color),u=T(s.color),l=Math.round(ye(o)+i*(ye(u)-ye(o))),h=Math.round(me(o)+i*(me(u)-me(o))),f=Math.round(be(o)+i*(be(u)-be(o))),y=we(o)+i*(we(u)-we(o));return T([l,h,f,y])}return T(t[t.length-1].color)},Da=a.z.object({key:a.z.string(),name:a.z.string(),color:Qe}),Pa=a.z.object({key:a.z.string(),name:a.z.string(),swatches:a.z.array(Da)}),dn=Object.freeze(Object.defineProperty({__proto__:null,BLACK:Ca,WHITE:Ra,ZERO:Jt,aValue:we,bValue:be,colorZ:Qe,construct:T,contrast:wt,crudeZ:Ke,cssString:Oa,equals:ln,fromCSS:Ua,fromGradient:ka,fromHSLA:Ba,gValue:me,gradientZ:La,grayness:Ma,hex:va,hsla:Na,isColor:wa,isCrude:ba,isDark:za,isLight:Ea,isZero:Sa,luminance:Te,paletteZ:Pa,pickByContrast:Aa,rValue:ye,rgbCSS:Ta,rgbString:hn,rgba1:xa,rgbaCSS:cn,setAlpha:Ia,stopZ:fn},Symbol.toStringTag,{value:"Module"})),gn=a.z.int().min(0).max(255),pn=255,yn=0,qa={lower:yn,upper:pn+1},mn=a.z.object({name:a.z.string(),key:a.z.string()}),xe=t=>a.z.object({subject:mn,resource:t,authority:gn}),Za=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),bn=t=>a.z.object({from:xe(t),to:a.z.null()}),wn=t=>a.z.object({from:a.z.null(),to:xe(t)}),Fa=t=>a.z.union([bn(t),wn(t),a.z.object({from:xe(t),to:xe(t)})]),Ya=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:pn,AUTHORITY_BOUNDS:qa,ZERO_AUTHORITY:yn,acquireZ:wn,authorityZ:gn,filterTransfersByChannelKey:Za,releaseZ:bn,stateZ:xe,subjectZ:mn,transferZ:Fa},Symbol.toStringTag,{value:"Module"})),Va=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},Wa=(t,e)=>{let r=null;return e===0?t:(...n)=>{r===null&&(r=setTimeout(()=>{t(...n),r=null},e))}},Ga=t=>{try{return structuredClone(t)}catch{return console.warn("Failed to deep copy object, falling back to JSON.parse(JSON.stringify)",t),console.trace(),JSON.parse(JSON.stringify(t))}},Ha=(t,e,r="")=>{const n={},s=(i,o,u)=>{if(typeof i!=typeof o||i===null||o===null){n[u]=[i,o];return}if(typeof i=="object"&&typeof o=="object")if(Array.isArray(i)&&Array.isArray(o)){if(i.length!==o.length){n[u]=[i,o];return}for(let l=0;l<i.length;l++)s(i[l],o[l],`${u}[${l}]`)}else new Set([...Object.keys(i),...Object.keys(o)]).forEach(l=>{s(i[l],o[l],u!==""?`${u}.${l}`:l)});else i!==o&&(n[u]=[i,o])};return s(t,e,r),n},Ot=(t,e)=>{const r=Array.isArray(t),n=Array.isArray(e);if(r!==n)return!1;if(r&&n){const o=t,u=e;if(o.length!==u.length)return!1;for(let l=0;l<o.length;l++)if(!Ot(o[l],u[l]))return!1;return!0}if(t==null||e==null||typeof t!="object"||typeof e!="object")return t===e;if("equals"in t)return t.equals(e);const s=Object.keys(t),i=Object.keys(e);if(s.length!==i.length)return!1;for(const o of s){const u=t[o],l=e[o];if(typeof u=="object"&&typeof l=="object"){if(!Ot(u,l))return!1}else if(u!==l)return!1}return!0},On=(t,e)=>{if(typeof t!="object"||t==null)return t===e;const r=Object.keys(t),n=Object.keys(e);if(n.length>r.length)return!1;for(const s of n){const i=t[s],o=e[s];if(typeof i=="object"&&typeof o=="object"){if(!On(i,o))return!1}else if(i!==o)return!1}return!0},U=".",vn=(t,e,r=U)=>{const n=t.split(r);return n.map((s,i)=>{const o=e(s,i,n);return o==null?null:typeof o=="string"?o:o.join(r)}).filter(s=>s!=null).join(r)},he=(t,e)=>{if(!Array.isArray(t))return t[e];const r=t[e];if(r!=null||t.length==0)return r;const n=t[0];if(typeof n=="object"&&"key"in n)return t.find(s=>s.key===e)},Xa=(t,e)=>{const r=t.split(U);return r.forEach((n,s)=>{e=he(e,n),e!=null&&typeof e=="object"&&"key"in e&&(r[s]=e.key)}),r.join(U)},Ja=(t,e)=>{const r=t.split(U);return e<0?r[r.length+e]:r[e]},Ka=(t,e)=>{if(e.length===0)return!0;const r=t.split(U),n=e.split(U);if(n.length>r.length)return!1;for(let s=0;s<n.length;s++){const i=r[s],o=n[s];if(o!=="*"&&i!==o)return!1}return!0},ie=t=>{const e=parseInt(t);return isNaN(e)||e<0||e.toString()!==t?null:e},vt=(t,e)=>{for(let r=1;r<=e.length;r++){const n=e.slice(0,r).join(U);if(he(t,n)!=null)return[n,r]}return null},Kt=((t,e,r={optional:!1})=>{const{optional:n,getter:s=he}=r;if(e==="")return t;const i=e.split(U);if(i.length===1){const u=s(t,i[0]);if(u===void 0){if(n)return null;throw new Error(`Path ${e} does not exist. ${i[0]} is undefined`)}return u}const o=(u,l)=>{if(l>=i.length)return u;for(let h=i.length-l;h>=1;h--){const f=i.slice(l,l+h).join(U),y=s(u,f);if(y!==void 0){if(l+h===i.length)return y;if(y===null){if(n)return null;throw new Error(`Path ${e} does not exist. ${f} is null`)}return o(y,l+h)}}if(n)return null;throw new Error(`Path ${e} does not exist. ${i[l]} is undefined`)};return o(t,0)}),Qa=(t,e)=>Kt(t,e,{optional:!0})!==null,Tt=(t,...e)=>{if(e.length===0)return t;const r=e.shift();if(Ue(t)&&Ue(r))for(const n in r)try{Ue(r[n])?(n in t||Object.assign(t,{[n]:{}}),Tt(t[n],r[n])):Object.assign(t,{[n]:r[n]})}catch(s){throw s instanceof TypeError?new TypeError(`.${n}: ${s.message}`):s}return Tt(t,...e)},_a=(t,e,r)=>{const n=(s,i,o)=>{if(o.def?.type==="union")return o.def.options.reduce((u,l)=>n(u,i,l),s);if(o.def?.type==="intersection"){const u=n(s,i,o.def.left);return n(u,i,o.def.right)}for(const u in i){const l=i[u];let h=o?.shape;if(h!=null)for(;h!=null;){if(h[u]!=null){const f=h[u].safeParse(l);if(f.success){s[u]=f.data;break}}h=h.def?.shape}typeof l=="object"&&!Array.isArray(l)&&l!==null&&o&&o.shape&&o.shape[u]&&(s[u]||={},n(s[u],l,o.shape[u]))}return s};return n({...t},e,r)},eu=(t,e)=>{const r=e.split(U);let n=t,s=0;for(;s<r.length;){if(s===r.length-1){const o=r[s];if(Array.isArray(n)){const u=parseInt(o);if(!isNaN(u)&&u<n.length){n.splice(u,1);return}const l=n[0];if(typeof l=="object"&&"key"in l){const h=n.findIndex(f=>f.key===o);if(h!==-1){n.splice(h,1);return}}return}delete n[o];return}let i=!1;if(Array.isArray(n)&&n.length>0){const o=n[0];if(typeof o=="object"&&"key"in o)for(let u=r.length-s;u>=1;u--){const l=r.slice(s,s+u).join(U),h=n.find(f=>f.key===l);if(h!=null){if(s+u===r.length){const f=n.findIndex(y=>y.key===l);f!==-1&&n.splice(f,1);return}n=h,s+=u,i=!0;break}}}if(!i)for(let o=r.length-s;o>=1;o--){const u=r.slice(s,s+o).join(U);if(!Array.isArray(n)&&typeof n=="object"&&n!==null&&u in n){if(s+o===r.length){delete n[u];return}n=n[u],s+=o,i=!0;break}}if(!i){const o=he(n,r[s]);if(o==null)return;n=o,s++}}},tu=(t,e,r)=>{const n=e.split(U);let s=t,i=0;for(;i<n.length-1;){const o=vt(s,n.slice(i,n.length-1));let u;o!=null?[u,i]=[o[0],i+o[1]]:(u=n[i],i++);let l=he(s,u);if(l==null){const h=n[i];let f=ie(h);f==null&&h.startsWith("-")&&ie(h.substring(1))!=null&&(f=0),l=f!=null?[]:{},s[u]=l}s=l}try{const o=n[n.length-1];if(Array.isArray(s)){let l=ie(o);if(l==null){if(o.startsWith("-")){const h=ie(o.substring(1));h!=null&&(l=s.length-h)}if(l==null){if(s.length===0){const f=ie(o);if(f!=null){s[f]=r;return}}const h=s[0];if(typeof h=="object"&&"key"in h){const f=s.findIndex(y=>y.key===o);if(f!==-1){s[f]=r;return}}return}}s[l]=r;return}const u=vt(s,[o]);if(u!=null){s[u[0]]=r;return}s[o]=r}catch(o){throw console.error("failed to set value",r,"at path",e,"on object",t),o}},ru=Object.freeze(Object.defineProperty({__proto__:null,SEPARATOR:U,copy:Ga,defaultGetter:he,difference:Ha,element:Ja,equal:Ot,findBestKey:vt,get:Kt,getIndex:ie,has:Qa,override:Tt,overrideValidItems:_a,partialEqual:On,pathsMatch:Ka,remove:eu,resolvePath:Xa,set:tu,transformPath:vn},Symbol.toStringTag,{value:"Module"})),nu=t=>Object.getOwnPropertySymbols(globalThis).includes(t),su=(t,e)=>{const r=Symbol.for(t);if(!nu(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},Tn="sy_x_error",iu=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(t):e instanceof Error?e.message.startsWith(t):typeof e!="string"?!1:e.startsWith(t),xn=t=>class pe extends Error{static discriminator=Tn;discriminator=pe.discriminator;static TYPE=t;type=pe.TYPE;static matches=iu(t);matches=pe.matches;constructor(r,n){super(r,n),this.name=pe.TYPE}static sub(r){return xn(`${t}.${r}`)}},ou=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==Tn)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},fe="unknown",or="nil";class au{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:or,data:""};if(ou(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:fe,data:e.message};if(typeof e=="string")return{type:fe,data:e};try{return{type:fe,data:JSON.stringify(e)}}catch{return{type:fe,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===or)return null;if(e.type===fe)return new ar(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new ar(e.data)}}su("synnax-error-registry",()=>new au);class ar extends xn("unknown"){}a.z.object({type:a.z.string(),data:a.z.string()});const uu=a.object({jsonrpc:a.literal("2.0"),method:a.string(),params:a.any().optional(),id:a.union([a.string(),a.number(),a.null()]).optional()}),Sn=a.object({jsonrpc:a.literal("2.0"),id:a.union([a.string(),a.number(),a.null()])}),lu=Sn.extend({result:a.json()}),cu=Sn.extend({error:a.object({code:a.number().int(),message:a.string().optional(),data:a.json().optional()})}),hu=a.union([lu,cu]);a.union([uu,hu]);a.z.object({key:a.z.string(),value:a.z.string()});const fu=a.uuid(),du=a.object({key:fu,name:a.string().min(1),color:a.string()}),gu=(t,e,r)=>{const n=t.get(e);return n===void 0?(t.set(e,r),r):n},pu=Object.freeze(Object.defineProperty({__proto__:null,getOrSetDefault:gu},Symbol.toStringTag,{value:"Module"})),xt=a.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),yu=(t,e)=>{const r=t.split("."),n=e.split("."),s=Math.max(r.length,n.length);for(let i=0;i<s;i++){const o=r[i],u=n[i];if(o===void 0)return Y;if(u===void 0)return V;const l=/^\d+$/.test(o),h=/^\d+$/.test(u);if(l&&!h)return Y;if(!l&&h)return V;if(l&&h){const f=parseInt(o),y=parseInt(u);if(f<y)return Y;if(f>y)return V}else{if(o<u)return Y;if(o>u)return V}}return ne},Ie=((t,e,r={})=>{r.checkMajor??=!0,r.checkMinor??=!0,r.checkPatch??=!0;const n=xt.parse(t),s=xt.parse(e),[i,o]=n.split("-"),[u,l]=s.split("-"),[h,f,y]=i.split(".").map(Number),[p,I,A]=u.split(".").map(Number);if(r.checkMajor){if(h<p)return Y;if(h>p)return V}if(r.checkMinor){if(f<I)return Y;if(f>I)return V}if(r.checkPatch){if(y<A)return Y;if(y>A)return V}return o===void 0&&l===void 0?ne:o===void 0?V:l===void 0?Y:yu(o,l)}),mu=(t,e,r={})=>Or(Ie(t,e,r)),Nn=(t,e,r={})=>wr(Ie(t,e,r)),bu=(t,e,r={})=>br(Ie(t,e,r)),wu=({name:t,migrate:e})=>r=>{try{const n=e(r);return console.log(`${t} migrated: ${r.version} -> ${n.version}`),n}catch(n){throw console.log(`${t} failed to migrate from ${r.version}`),console.error(n),n}},Ou=({name:t,migrations:e,targetSchema:r,defaultVersion:n,def:s})=>{const i=Object.keys(e).sort(Ie).pop();if(i==null)return h=>{if(h.version??=n,h.version!==s.version)return console.log(`${t} version ${h.version} is newer than latest version of ${s.version}.
7
- Returning default instead.
8
- `),s;try{return r!=null?r.parse(h):h}catch(f){return console.log(`${t} failed to parse default. Exiting with default`),console.error(f),s}};const o=Object.keys(e).length;let u=!1;const l=h=>{try{if(o===0||Nn(h.version,i))return console.log(u?`${t} ${h.version} now up to date`:`${t} version ${h.version} is up to date with target version ${s.version}`),h;const f=h.version,y=e[f],p=y(h);return u=!0,l(p)}catch(f){return console.log(`${t} failed to migrate from ${h.version} to ${i}`),console.error(f),s}};return h=>{try{if(h.version==null)if(n!=null)console.log(`${t} version is null. Setting version to default of ${n}`),h.version=n;else return console.log(`${t} version is null and no default version set. Exiting with default`),s;return l(h)}catch(f){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(f),s}}},vu=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:Ie,createMigration:wu,migrator:Ou,semVerNewer:Nn,semVerOlder:bu,semVerZ:xt,versionsEqual:mu},Symbol.toStringTag,{value:"Module"})),In=["standard","scientific","engineering"],Tu=a.z.enum(In),xu=(t,e,r)=>{if(Number.isNaN(t))return"NaN";if(t===1/0)return"∞";if(t===-1/0)return"-∞";if(r==="standard")return t.toFixed(e);if(t===0)return e===0?"0ᴇ0":`0.${"0".repeat(e)}ᴇ0`;let n;return r==="scientific"?n=Math.floor(Math.log10(Math.abs(t))):n=Math.floor(Math.log10(Math.abs(t))/3)*3,`${(t/10**n).toFixed(e)}ᴇ${n}`},Su=Object.freeze(Object.defineProperty({__proto__:null,NOTATIONS:In,notationZ:Tu,stringifyNumber:xu},Symbol.toStringTag,{value:"Module"}));class Nu{handlers;transform;closer;constructor(e,r){this.transform=e,this.handlers=r??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let r=e;if(this.transform!=null){const[n,s]=this.transform(e);if(!s)return;r=n}this.handlers.forEach((n,s)=>s(r))}setCloser(e){this.closer=e}async close(){return await this.closer?.()}}class Iu{handlers;constructor(e){this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((r,n)=>n(e))}}const Mu=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Iu,Observer:Nu},Symbol.toStringTag,{value:"Module"})),Mn=a.z.union([a.z.string(),a.z.number()]),Au=a.z.record(Mn,a.z.unknown()),Qt=t=>Object.entries(t),zu=(t,e)=>Object.fromEntries(Qt(t).map(([r,n])=>[r,e(n,r)])),Eu=t=>Object.fromEntries(Qt(t).filter(([e,r])=>r!==void 0)),ju=(t,...e)=>{const r={...t};for(const n of e)delete r[n];return r},Uu=Object.freeze(Object.defineProperty({__proto__:null,entries:Qt,keyZ:Mn,map:zu,omit:ju,purgeUndefined:Eu,unknownZ:Au},Symbol.toStringTag,{value:"Module"})),An=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Bu=An(),zn=["macOS","Windows","Linux"],$u=["macos","windows","linux"],Cu={macos:"macOS",windows:"Windows",linux:"Linux"},Ru=a.z.enum(zn).or(a.z.enum($u).transform(t=>Cu[t])),Lu=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"macOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"};let st;const ku=((t={})=>{const{force:e,default:r}=t;return e??st??(st=Lu(),st??r)}),Du=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:zn,RUNTIME:Bu,detect:An,getOS:ku,osZ:Ru},Symbol.toStringTag,{value:"Module"})),Pu=()=>Promise.resolve(),qu=()=>new Promise(t=>setTimeout(t,0)),Zu=Object.freeze(Object.defineProperty({__proto__:null,flushMicrotasks:Pu,flushTaskQueue:qu},Symbol.toStringTag,{value:"Module"})),Fu=t=>Array.isArray(t)?[...t]:typeof t=="object"&&t!==null?{...t}:t,Yu=Object.freeze(Object.defineProperty({__proto__:null,copy:Fu},Symbol.toStringTag,{value:"Module"})),En=a.z.enum(["success","info","warning","error","loading","disabled"]),Vu=t=>a.z.object({key:a.z.string(),name:a.z.string().default(""),variant:En,message:a.z.string(),description:a.z.string().optional(),time:d.z,labels:cr(du).optional(),details:t??a.z.unknown().optional()}),Wu=a.z.object({stack:a.z.string(),error:a.z.instanceof(Error)}),Gu=(t,e)=>{if(!(t instanceof Error))throw t;return jn({variant:"error",message:e??t.message,description:e!=null?t.message:void 0,details:{stack:t.stack??"",error:t}})},jn=t=>({key:It(),time:d.now(),name:"",...t}),Hu=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?t:void 0:e===t?t:void 0},Xu=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?void 0:t:e===t?void 0:t},Ju=Object.freeze(Object.defineProperty({__proto__:null,create:jn,exceptionDetailsSchema:Wu,fromException:Gu,keepVariants:Hu,removeVariants:Xu,statusZ:Vu,variantZ:En},Symbol.toStringTag,{value:"Module"})),Ku=(t,e)=>{if(!e.has(t))return t;let r=t,n=1,s=t;for(;e.has(s);){const i=s.match(Qu);i?(r=s.slice(0,i.index).trim(),n=parseInt(i[1])+1):(r=s,n=1),s=`${r} (${n})`}return s},Qu=/\((\d+)\)$/,_u=(t,e="")=>{if(typeof t=="string")return t;const r=t.length;return r===0?e:r===1?t[0]:r===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[r-1]}`},el=t=>{const e=t.split(" "),r=new Set,n=e.map(o=>o.charAt(0).toLowerCase()).join("");r.add(n.replace(/-/g,"_")),r.add(n.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"));const s=/\d+/g;t.match(s)&&e.forEach((o,u)=>{if(s.test(o)){const l=e.map((h,f)=>f!==u?h.charAt(0).toLowerCase():h).join("");r.add(l.replace(/-/g,"_")),r.add(l.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"))}});const i=e.map(o=>(o.length>3?o.substring(0,3):o).toLowerCase());return r.add(i.join("").replace(/-/g,"_")),r.add(i.join("_").replace(/-/g,"_")),Array.from(r).filter(o=>o.length>=2&&o.length<=12&&!/^\d/.test(o))},tl=(t,e)=>t.startsWith(e)?t.slice(e.length):t,rl=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:el,deduplicateFileName:Ku,naturalLanguageJoin:_u,trimPrefix:tl},Symbol.toStringTag,{value:"Module"})),nl=new Error("request for lock canceled");var sl=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function u(f){try{h(n.next(f))}catch(y){o(y)}}function l(f){try{h(n.throw(f))}catch(y){o(y)}}function h(f){f.done?i(f.value):s(f.value).then(u,l)}h((n=n.apply(t,e||[])).next())})};class il{constructor(e,r=nl){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,s)=>{const i={resolve:n,reject:s,weight:e,priority:r},o=Un(this._queue,u=>r<=u.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return sl(this,arguments,void 0,function*(r,n=1,s=0){const[i,o]=yield this.acquire(n,s);try{return yield r(i)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),ol(this._weightedWaiters[e-1],{resolve:n,priority:r})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const s=n.findIndex(i=>i.priority<=e);(s===-1?n:n.splice(0,s)).forEach((i=>i.resolve()))}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function ol(t,e){const r=Un(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function Un(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var al=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function u(f){try{h(n.next(f))}catch(y){o(y)}}function l(f){try{h(n.throw(f))}catch(y){o(y)}}function h(f){f.done?i(f.value):s(f.value).then(u,l)}h((n=n.apply(t,e||[])).next())})};class ul{constructor(e){this._semaphore=new il(1,e)}acquire(){return al(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class Bn extends ul{constructor(e){super(),Object.assign(this,e)}}const ll=t=>new Bn(t),cl=Object.freeze(Object.defineProperty({__proto__:null,mutex:Bn,newMutex:ll},Symbol.toStringTag,{value:"Module"})),hl=(...t)=>t.map($n).join(""),$n=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),fl=t=>t.endsWith("/")?t.slice(0,-1):t;class Le{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){this.protocol=n,this.host=e,this.port=r,this.path=$n(s)}replace(e){return new Le({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Le({...this,pathPrefix:hl(this.path,e)})}toString(){return fl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new Le({host:"unknown",port:0})}class dl{sender;handlers;constructor(e){this.sender=e,this.handlers=new Map}handle({data:e}){const r=this.handlers.get(e.type)?.handler;r==null?console.warn(`No handler for ${e.type}`):r(e.payload)}route(e){const r=gl(e,this.sender),n=new pl(r);return this.handlers.set(e,n),n}}const gl=(t,e)=>(r,n)=>e({type:t,payload:r},n);class pl{_send;handler;constructor(e){this._send=e,this.handler=null}send(e,r=[]){this._send(e,r)}handle(e){this.handler=e}}const yl=t=>t.nullable().transform(e=>e===null?void 0:e).optional(),ml=a.z.int().min(0).max(Nr),bl=t=>a.array(t).or(t.transform(e=>[e])),wl=t=>t._zod.def.output,Cn=t=>vn(t,(e,r,n)=>{const s=r===n.length-1,i=!isNaN(parseInt(e)),o=!isNaN(parseInt(n[r+1]));return i&&(e="element"),s||o?e:[e,"shape"]}),ur=(t,e)=>{if(t==null)return null;const r=t[e];return r==null&&typeof t=="object"&&"sourceType"in t?t.sourceType()[e]:r},Ol=((t,e,r)=>e===""?t:Kt(ur(t,"shape"),Cn(e),{...r,getter:ur})),vl=Object.freeze(Object.defineProperty({__proto__:null,functionOutput:wl,getFieldSchema:Ol,getFieldSchemaPath:Cn,nullToUndefined:yl,toArray:bl,uint12:ml},Symbol.toStringTag,{value:"Module"}));function Rn(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(r=Rn(t[e]))&&(n&&(n+=" "),n+=r)}else for(r in t)t[r]&&(n&&(n+=" "),n+=r);return n}function Ln(){for(var t,e,r=0,n="",s=arguments.length;r<s;r++)(t=arguments[r])&&(e=Rn(t))&&(n&&(n+=" "),n+=e);return n}const Tl=Ln,se="-",lr="__",je="--",kn=t=>{const e=(...r)=>Tl(...r);return e.B=(...r)=>t+se+r.join(se),e.E=r=>t+lr+r,e.M=(...r)=>t+je+r.join("-"),e.BM=(r,...n)=>e.B(r)+je+n.join("-"),e.BE=(r,...n)=>e.B(r)+lr+n.join(se),e.BEM=(r,n,...s)=>e.BE(r,n)+je+s.join(se),e.var=(...r)=>je+t+se+r.join(se),e};class xl{rows=[];columns=[];prefix;constructor(e=""){this.prefix=e}row(e,r,n){const{prefix:s}=this;return this.rows.push({startLabel:s+e,endLabel:s+r,size:n}),this}col(e,r,n){const{prefix:s}=this;return this.columns.push({startLabel:s+e,endLabel:s+r,size:n}),this}build(){return{display:"grid",gridTemplateRows:this.rows.map((e,r)=>{let n=r===0?"[":"";return n+=`${e.startLabel}] ${e.size}${typeof e.size=="number"?"px":""} [${e.endLabel}`,n+=r===this.rows.length-1?"]":"",n}).join(" "),gridTemplateColumns:this.columns.map((e,r)=>{let n=r===0?"[":"";return n+=`${e.startLabel}] ${e.size}${typeof e.size=="number"?"px":""} [${e.endLabel}`,n+=r===this.columns.length-1?"]":"",n}).join(" ")}}}const Sl=(t,e)=>Object.entries(e).forEach(([r,n])=>n!=null&&t.style.setProperty(r,`${n}`)),Nl=(t,e)=>Array.from(t.style).forEach(r=>{r.startsWith(e)&&t.style.removeProperty(r)}),Il=t=>{const e=kn(t);return e.visible=r=>e.M(r?"visible":"hidden"),e.expanded=r=>e.M(r?"expanded":"collapsed"),e.loc=r=>e.M("location",Dr.construct(r)),e.disabled=r=>r===!0&&e.M("disabled"),e.align=r=>e.M(r),e.dir=r=>r!=null&&e.M("direction",Lr.construct(r)),e.sharp=r=>r!==!1&&e.M("sharp"),e.rounded=r=>r!==!1&&e.M("rounded"),e.bordered=r=>typeof r=="boolean"?r&&e.M("bordered"):r!=null?e.M(`bordered-${r.toString()}`):e.M("bordered"),e.selected=r=>r&&e.M("selected"),e.altColor=r=>r&&e.M("alt-color"),e.editable=r=>r&&e.M("editable"),e.noSelect=e.M("no-select"),e.applyVars=Sl,e.removeVars=Nl,e.newGridBuilder=r=>new xl(r),e.dropRegion=r=>r&&e.B("haul-drop-region"),e.px=r=>`${r}px`,e.inheritDims=(r=!0)=>r&&e.M("inherit-dims"),e.shade=(r=>r!=null&&e.M(`shade-${r}`)),e.colorVar=r=>{if(!(r==null||r===!1))return typeof r=="number"?`var(--${t}-gray-l${r})`:dn.cssString(r)},e.levelSizeVar=r=>`var(--${t}-${r}-size)`,e.level=r=>e.M(`level-${r}`),e},Ml=Il("pluto");exports.$=z;exports.Au=qi;exports.Bu=na;exports.CSS=Ml;exports.Cu=Yo;exports.E=N;exports.Eu=yo;exports.Fu=Va;exports.Iu=ei;exports.Ku=vu;exports.Mu=Dr;exports.Nu=ii;exports.Ou=ps;exports.Qu=Su;exports.Ru=ca;exports.Su=Mo;exports.Tu=Ro;exports.Uu=qo;exports.Vu=ru;exports.Xu=pu;exports.Zu=dn;exports._u=Ya;exports.al=cl;exports.bu=ns;exports.cl=rl;exports.clsx=Ln;exports.d=d;exports.du=Zn;exports.f=c;exports.fn=dl;exports.g=g;exports.gu=Kn;exports.hl=vl;exports.il=Yu;exports.newBEM=kn;exports.nl=Uu;exports.ol=Ju;exports.p=m;exports.pu=ts;exports.q=L;exports.rl=Du;exports.sl=Zu;exports.tl=Mu;exports.vo=Qr;exports.vu=Lr;exports.wu=hs;exports.x=b;exports.yu=Qn;exports.zu=Wa;
@@ -1 +0,0 @@
1
- "use strict";const i=require("./css-D3NdC2sx.cjs");let e=null;const u=()=>(e??=document.createElement("canvas"),e),c=(t,a,n)=>{if(i.rl.RUNTIME==="node")return{width:0,height:0};n??=u().getContext("2d"),n.font=a;const o=n.measureText(t);return s(o)},s=t=>({width:Math.trunc(Math.abs(t.actualBoundingBoxLeft)+Math.abs(t.actualBoundingBoxRight)),height:Math.trunc(Math.abs(t.actualBoundingBoxAscent)+Math.abs(t.actualBoundingBoxDescent))});exports.dimensions=c;exports.dimensionsFromMetrics=s;
@@ -1,11 +0,0 @@
1
- "use strict";const a=require("./css-D3NdC2sx.cjs"),_=require("zod"),d=require("./provider-DksyuJua.cjs"),F=require("./dimensions-C7b02rFi.cjs"),I=_.z.object({include:_.z.string().array().optional(),exclude:_.z.string().array().optional(),level:_.z.enum(d.g.LOG_LEVELS).default("info")}),T="alamos-provider";class A extends d.Composite{static TYPE="alamos.Provider";schema=I;afterUpdate(t){if(t.getOptional(T)!=null)return;const s=[],{include:i,exclude:r,level:n}=this.state;(i!=null||r!=null)&&s.push(d.g.logLevelKeyFiler({include:i,exclude:r})),n!=null&&s.push(d.g.logThresholdFilter(n)),s.length===0&&s.push(()=>!1),this.internal.ins=new d.g.Instrumentation({key:"aether",logger:new d.g.Logger({filters:s})}),t.set(T,this.internal.ins)}}const B=(l,t)=>{const e=l.get(T);if(e==null)throw new Error("No instrumentation provider");return t==null?e:e.child(t)},Z={[A.TYPE]:A},y=(l,t)=>a.Eu.construct(a.Eu.left(l)-t.x,a.Eu.top(l)-t.y,a.Eu.width(l)+t.x*2,a.Eu.height(l)+t.y*2);class C{scale_;wrapped;atlasRegistry;cachedFont=null;cachedFillStyle=null;cachedStrokeStyle=null;cachedLineWidth=null;cachedGlobalAlpha=null;cachedTextAlign=null;cachedTextBaseline=null;cachedLineCap=null;cachedLineJoin=null;cachedMiterLimit=null;dpr;constructor(t,e,s,i=a.Tu.XY.IDENTITY){this.wrapped=t,this.scale_=i,this.atlasRegistry=e,this.dpr=s}get fontStretch(){return this.wrapped.fontStretch}set fontStretch(t){this.wrapped.fontStretch=t}get fontVariantCaps(){return this.wrapped.fontVariantCaps}set fontVariantCaps(t){this.wrapped.fontVariantCaps=t}isContextLost(){return this.wrapped.isContextLost()}get wordSpacing(){return this.wrapped.wordSpacing}set wordSpacing(t){this.wrapped.wordSpacing=t}get letterSpacing(){return this.wrapped.letterSpacing}set letterSpacing(t){this.wrapped.letterSpacing=t}get textRendering(){return this.wrapped.textRendering}set textRendering(t){this.wrapped.textRendering=t}checkAtlasFillStyle(t=!1){return t&&typeof this.fillStyle=="string"?[!0,this.fillStyle]:(t&&console.warn("attempted to use a text atlas with a gradient fill style. This is not supported. Falling back to default canvas fill."),[!1,null])}reset(){this.wrapped.reset()}applyScale(t){return new C(this,this.atlasRegistry,this.dpr,t)}get canvas(){return this.wrapped.canvas}get miterLimit(){return this.cachedMiterLimit??this.wrapped.miterLimit}set miterLimit(t){const e=this.scale_.x.dim(t);e!==this.cachedMiterLimit&&(this.cachedMiterLimit=e,this.wrapped.miterLimit=e)}get globalAlpha(){return this.cachedGlobalAlpha??this.wrapped.globalAlpha}set globalAlpha(t){t!==this.cachedGlobalAlpha&&(this.cachedGlobalAlpha=t,this.wrapped.globalAlpha=t)}get globalCompositeOperation(){return this.wrapped.globalCompositeOperation}set globalCompositeOperation(t){this.wrapped.globalCompositeOperation=t}get fillStyle(){return this.cachedFillStyle??this.wrapped.fillStyle}set fillStyle(t){t!==this.cachedFillStyle&&(this.cachedFillStyle=t,this.wrapped.fillStyle=t)}get strokeStyle(){return this.cachedStrokeStyle??this.wrapped.strokeStyle}set strokeStyle(t){t!==this.cachedStrokeStyle&&(this.cachedStrokeStyle=t,this.wrapped.strokeStyle=t)}drawImage(t,e,s,i,r,n,h,o,p){this.wrapped.drawImage(t,e,s,i,r,n!=null?this.scale_.x.pos(n):n,h!=null?this.scale_.y.pos(h):h,o!=null?this.scale_.x.dim(o):o,p!=null?this.scale_.y.dim(p):p)}beginPath(){this.wrapped.beginPath()}clip(t,e){this.wrapped.clip(t,e)}fill(t,e){if(t==null)return this.wrapped.fill();this.wrapped.fill(t,e)}isPointInPath(t,e,s,i){return this.wrapped.isPointInPath(t,e,s,i)}isPointInStroke(t,e,s){return this.wrapped.isPointInStroke(t,e,s)}stroke(t){if(t==null)return this.wrapped.stroke();this.wrapped.stroke(t)}createConicGradient(t,e,s){return this.wrapped.createConicGradient(t,e,s)}createLinearGradient(t,e,s,i){return this.wrapped.createLinearGradient(t,e,s,i)}createPattern(t,e){return this.wrapped.createPattern(t,e)}createRadialGradient(t,e,s,i,r,n){return this.wrapped.createRadialGradient(t,e,s,i,r,n)}get filter(){return this.wrapped.filter}set filter(t){this.wrapped.filter=t}createImageData(t,e,s){return this.wrapped.createImageData(t,e,s)}getImageData(t,e,s,i,r){return this.wrapped.getImageData(t,e,s,i,r)}putImageData(t,e,s,i,r,n,h){this.wrapped.putImageData(t,e,s,i,r,n,h)}get imageSmoothingEnabled(){return this.wrapped.imageSmoothingEnabled}set imageSmoothingEnabled(t){this.wrapped.imageSmoothingEnabled=t}get imageSmoothingQuality(){return this.wrapped.imageSmoothingQuality}set imageSmoothingQuality(t){this.wrapped.imageSmoothingQuality=t}arc(t,e,s,i,r,n){this.wrapped.arc(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),i,r,n)}arcTo(t,e,s,i,r){this.wrapped.arcTo(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.pos(s),this.scale_.y.pos(i),this.scale_.x.dim(r))}bezierCurveTo(t,e,s,i,r,n){this.wrapped.bezierCurveTo(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.pos(s),this.scale_.y.pos(i),this.scale_.x.pos(r),this.scale_.y.pos(n))}closePath(){this.wrapped.closePath()}ellipse(t,e,s,i,r,n,h,o){this.wrapped.ellipse(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),this.scale_.y.dim(i),r,n,h,o)}lineTo(t,e){this.wrapped.lineTo(this.scale_.x.pos(t),this.scale_.y.pos(e))}moveTo(t,e){this.wrapped.moveTo(this.scale_.x.pos(t),this.scale_.y.pos(e))}quadraticCurveTo(t,e,s,i){this.wrapped.quadraticCurveTo(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.pos(s),this.scale_.y.pos(i))}rect(t,e,s,i){this.wrapped.rect(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),this.scale_.y.dim(i))}roundRect(t,e,s,i,r){this.wrapped.roundRect(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),this.scale_.y.dim(i),typeof r=="number"?this.scale_.x.dim(r):r)}get lineCap(){return this.cachedLineCap??this.wrapped.lineCap}set lineCap(t){t!==this.cachedLineCap&&(this.cachedLineCap=t,this.wrapped.lineCap=t)}get lineDashOffset(){return this.wrapped.lineDashOffset}set lineDashOffset(t){this.wrapped.lineDashOffset=this.scale_.x.dim(t)}get lineJoin(){return this.cachedLineJoin??this.wrapped.lineJoin}set lineJoin(t){t!==this.cachedLineJoin&&(this.cachedLineJoin=t,this.wrapped.lineJoin=t)}get lineWidth(){return this.cachedLineWidth??this.wrapped.lineWidth}set lineWidth(t){const e=this.scale_.x.dim(t);e!==this.cachedLineWidth&&(this.cachedLineWidth=e,this.wrapped.lineWidth=e)}getLineDash(){return this.wrapped.getLineDash()}setLineDash(t){const e=Array.from(t).map(s=>this.scale_.x.dim(s));this.wrapped.setLineDash(e)}clearRect(t,e,s,i){this.wrapped.clearRect(t,e,s,i)}fillRect(t,e,s,i){this.wrapped.fillRect(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),this.scale_.y.dim(i))}strokeRect(t,e,s,i){this.wrapped.strokeRect(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),this.scale_.y.dim(i))}get shadowBlur(){return this.wrapped.shadowBlur}set shadowBlur(t){this.wrapped.shadowBlur=t}get shadowColor(){return this.wrapped.shadowColor}set shadowColor(t){this.wrapped.shadowColor=t}get shadowOffsetX(){return this.wrapped.shadowOffsetX}set shadowOffsetX(t){this.wrapped.shadowOffsetX=t}get shadowOffsetY(){return this.wrapped.shadowOffsetY}restore(){this.cachedFillStyle=null,this.cachedStrokeStyle=null,this.cachedLineWidth=null,this.cachedGlobalAlpha=null,this.cachedTextAlign=null,this.cachedTextBaseline=null,this.cachedLineCap=null,this.cachedLineJoin=null,this.cachedMiterLimit=null,this.cachedFont=null,this.wrapped.restore()}save(){this.wrapped.save()}fillText(t,e,s,i,r={}){const[n,h]=this.checkAtlasFillStyle(r.useAtlas);if(n){this.atlasRegistry.get({font:this.font,textColor:h}).fillText(this,t,e,s);return}this.wrapped.fillText(t,this.scale_.x.pos(e),this.scale_.y.pos(s),i!=null?this.scale_.x.dim(i):void 0)}measureText(t){return this.wrapped.measureText(t)}textDimensions(t,e={}){const[s,i]=this.checkAtlasFillStyle(e.useAtlas);return s?this.atlasRegistry.get({font:this.font,textColor:i}).measureText(t):F.dimensionsFromMetrics(this.measureText(t))}strokeText(t,e,s,i){this.wrapped.strokeText(t,this.scale_.x.pos(e),this.scale_.y.pos(s),i!=null?this.scale_.x.dim(i):void 0)}get direction(){return this.wrapped.direction}set direction(t){this.wrapped.direction=t}get font(){return this.cachedFont!=null?this.cachedFont:this.wrapped.font}set font(t){t!==this.cachedFont&&(this.cachedFont=t,this.wrapped.font=this.cachedFont)}get fontKerning(){return this.wrapped.fontKerning}set fontKerning(t){this.wrapped.fontKerning=t}get textAlign(){return this.cachedTextAlign??this.wrapped.textAlign}set textAlign(t){t!==this.cachedTextAlign&&(this.cachedTextAlign=t,this.wrapped.textAlign=t)}get textBaseline(){return this.cachedTextBaseline??this.wrapped.textBaseline}set textBaseline(t){t!==this.cachedTextBaseline&&(this.cachedTextBaseline=t,this.wrapped.textBaseline=t)}getTransform(){return this.wrapped.getTransform()}resetTransform(){this.wrapped.resetTransform()}rotate(t){this.wrapped.rotate(t)}scale(t,e){this.wrapped.scale(t,e),this.dpr=t}scissor(t,e=a.Au.ZERO){const s=new X(this.scale_);return t=y(t,e),s.rect(...a.Au.couple(a.Eu.topLeft(t)),...a.Su.couple(a.Eu.dims(t))),this.save(),this.clip(s.getPath()),()=>this.restore()}setTransform(t,e,s,i,r,n){this.wrapped.setTransform(t,e,s,i,r,n)}transform(t,e,s,i,r,n){this.wrapped.transform(t,e,s,i,r,n)}translate(t,e){this.wrapped.translate(t,e)}}class X{scale_;path;constructor(t=a.Tu.XY.IDENTITY,e){this.scale_=t,e instanceof Path2D||typeof e=="string"?this.path=new Path2D(e):this.path=new Path2D}addPath(t,e){this.path.addPath(t,e)}arc(t,e,s,i,r,n){this.path.arc(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),i,r,n)}arcTo(t,e,s,i,r){this.path.arcTo(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.pos(s),this.scale_.y.pos(i),this.scale_.x.dim(r))}bezierCurveTo(t,e,s,i,r,n){this.path.bezierCurveTo(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.pos(s),this.scale_.y.pos(i),this.scale_.x.pos(r),this.scale_.y.pos(n))}closePath(){this.path.closePath()}ellipse(t,e,s,i,r,n,h,o){this.path.ellipse(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),this.scale_.y.dim(i),r,n,h,o)}lineTo(t,e){this.path.lineTo(this.scale_.x.pos(t),this.scale_.y.pos(e))}moveTo(t,e){this.path.moveTo(this.scale_.x.pos(t),this.scale_.y.pos(e))}quadraticCurveTo(t,e,s,i){this.path.quadraticCurveTo(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.pos(s),this.scale_.y.pos(i))}rect(t,e,s,i){this.path.rect(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),this.scale_.y.dim(i))}roundRect(t,e,s,i,r){const n=this.scaleRadii(r);this.path.roundRect(this.scale_.x.pos(t),this.scale_.y.pos(e),this.scale_.x.dim(s),this.scale_.y.dim(i),n)}scaleRadii(t){return t==null?t:typeof t=="number"?this.scale_.x.dim(t):Array.isArray(t)?t.map(e=>this.scaleRadius(e)):this.scaleRadius(t)}scaleRadius(t){return typeof t=="number"?this.scale_.x.dim(t):{x:this.scale_.x.dim(t.x??0),y:this.scale_.y.dim(t.y??0)}}getPath(){return this.path}}const U=`precision mediump float;
2
-
3
- void main(void) {
4
- gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
5
- }
6
- `,K=`attribute vec4 a_position;
7
-
8
- void main(void) {
9
- gl_Position = a_position;
10
- }
11
- `,O=l=>new Error(`failed to compile webgl program: ${l}`),W=new Error("null shader encountered");let k=class{renderCtx;prog;vertShader;fragShader;uniformLocCache=new Map;constructor(t,e,s){this.renderCtx=t;const i=t.gl.createProgram();if(i==null)throw O("failed to create program");this.prog=i,this.vertShader=e,this.fragShader=s,this.compile()}setAsActive(){return this.renderCtx.gl.useProgram(this.prog),()=>this.renderCtx.gl.useProgram(null)}uniformXY(t,e){this.renderCtx.gl.uniform2fv(this.getUniformLoc(t),a.Au.couple(e))}uniformColor(t,e){this.renderCtx.gl.uniform4fv(this.getUniformLoc(t),a.Zu.rgba1(e))}getUniformLoc(t){const e=this.uniformLocCache.get(t);if(e!=null)return e;const s=this.renderCtx.gl.getUniformLocation(this.prog,t);if(s==null)throw new Error(`unexpected missing uniform ${t}`);return this.uniformLocCache.set(t,s),s}compile(){const t=this.renderCtx.gl;this.compileShader(this.vertShader,t.VERTEX_SHADER),this.compileShader(this.fragShader,t.FRAGMENT_SHADER),t.linkProgram(this.prog)}compileShader(t,e){const s=this.renderCtx.gl,i=s.createShader(e);if(i==null)throw W;if(s.shaderSource(i,t),s.compileShader(i),!s.getShaderParameter(i,s.COMPILE_STATUS)){const n=s.getShaderInfoLog(i);throw s.deleteShader(i),O(n??"unknown")}s.attachShader(this.prog,i)}};const H=new Float32Array([0,0,0,0,0,0]);class V extends k{positionBuffer;constructor(t){super(t,K,U);const e=t.gl.createBuffer();if(e==null)throw new d.St("webgl: failed to create buffer");this.positionBuffer=e,t.gl.bindBuffer(t.gl.ARRAY_BUFFER,this.positionBuffer),t.gl.bufferData(t.gl.ARRAY_BUFFER,H,t.gl.STATIC_DRAW)}exec(){const{gl:t}=this.renderCtx,e=t.getAttribLocation(this.prog,"a_position");t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer);const s=t.createVertexArray();t.bindVertexArray(s),t.enableVertexAttribArray(e),t.vertexAttribPointer(e,2,t.FLOAT,!1,0,0),this.setAsActive(),t.drawArrays(t.TRIANGLES,0,3)}}const v={high:1,low:0};class G{requests=new Map;cleanup=new Map;afterRender;instrumentation;handleError;constructor({afterRender:t,instrumentation:e=d.g.Instrumentation.NOOP,handleError:s}){this.afterRender=t,this.instrumentation=e,this.handleError=s,this.start()}set(t){const e=this.requests.get(t.key);if(e==null)this.requests.set(t.key,t);else{const s=v[t.priority]>=v[e.priority],i=t.canvases.length>=e.canvases.length;s&&i&&this.requests.set(t.key,t)}}render(){const{requests:t}=this;t.size!==0&&(this.runCleanupsSync(),this.renderSync(),this.requests.clear(),this.afterRender?.())}runCleanupsSync(){const{cleanup:t,requests:e}=this;t.forEach((s,i)=>{const r=e.get(i);r!=null&&(s(r),t.delete(i))})}renderSync(){const{requests:t}=this;t.forEach(e=>{try{const s=e.render();s!=null&&this.cleanup.set(e.key,s)}catch(s){this.handleError(s,"render loop failed")}})}start(){const t=()=>{try{this.render()}catch(e){this.handleError(e,"render loop failed")}requestAnimationFrame(t)};requestAnimationFrame(t)}}const x=2,g=2;class L{atlas;charDims;charMap;static DEFAULT_CHARS="0123456789.:-°µmsNa∞ᴇABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz%";constructor(t){const{font:e,characters:s=L.DEFAULT_CHARS,textColor:i}=t;this.charMap=new Map;const r=a.bu.unique(Array.from(s)),h=new OffscreenCanvas(1,1).getContext("2d");h.font=e;const o=h.measureText("0");this.charDims=F.dimensionsFromMetrics(o),this.charDims.width+=x,this.charDims.height+=x;const p=r.length,u=this.charDims.width,m=this.charDims.height,c=Math.ceil(Math.sqrt(p)),S=Math.ceil(p/c);this.atlas=new OffscreenCanvas(u*c*g,m*(S+1)*g);const w=this.atlas.getContext("2d");w.scale(g,g),w.font=e,w.textBaseline="alphabetic",w.textAlign="left",w.fillStyle=a.Zu.hex(i),w.clearRect(0,0,this.atlas.width,this.atlas.height),r.forEach((b,E)=>{const Y=E%c,z=Math.floor(E/c),q=Y*u,N=(z+1)*m;w.fillText(b,q,N),this.charMap.set(b,E)})}fillText(t,e,s,i){const{width:r,height:n}=this.charDims,h=Math.ceil(Math.sqrt(this.charMap.size));t.textAlign==="center"&&(s-=r*e.length/2),t.textBaseline==="middle"&&(i+=n/2);for(let o=0;o<e.length;o++){const p=e[o],u=this.charMap.get(p);if(u===void 0)continue;const m=u%h,c=Math.floor(u/h);t.drawImage(this.atlas,m*r*g,c*n*g+x,r*g,n*g,s+o*r,i-n-x/g,r,n)}}measureText(t){return{width:t.length*this.charDims.width,height:this.charDims.height}}}class J{atlases;constructor(){this.atlases=new Map}get(t){const e=`${t.font}-${a.Zu.hex(t.textColor)}-${t.characters}`;if(this.atlases.has(e))return this.atlases.get(e);const s=new L(t);return this.atlases.set(e,s),s}}const D=l=>(l.textRendering="optimizeSpeed",l.imageSmoothingEnabled=!1,l);class f{glCanvas;upper2dCanvas;lower2dCanvas;gl;lower2d;upper2d;region;dpr;loop;clearProgram;os;static CONTEXT_KEY=a.CSS.B("render-context");instrumentation;static create(t,e,s,i,r){const n=B(t,"render_context"),h=new f(e,s,i,r,n,d.useAdder(t),d.useErrorHandler(t));return t.set(f.CONTEXT_KEY,h),h}constructor(t,e,s,i,r,n,h){this.upper2dCanvas=s,this.lower2dCanvas=e,this.glCanvas=t,this.os=i,this.instrumentation=r,this.dpr=1;const o=this.lower2dCanvas.getContext("2d");if(o==null)throw new Error("Could not get 2D context");const p=new J;this.lower2d=D(new C(o,p,this.dpr));const u=this.upper2dCanvas.getContext("2d");if(u==null)throw new Error("Could not get 2D context");this.upper2d=D(new C(u,p,this.dpr));const m={preserveDrawingBuffer:!0,powerPreference:"high-performance",stencil:!1,depth:!1},c=this.glCanvas.getContext("webgl2",m);if(c==null)throw new Error("Could not get WebGL context");c.disable(c.DEPTH_TEST),c.disable(c.STENCIL_TEST),c.disable(c.CULL_FACE),c.disable(c.DITHER),this.gl=c,this.glCanvas.oncontextlost=()=>n({variant:"error",message:"WebGL context lost"});const S=()=>{this.gl.flush(),this.gl.finish()};this.loop=new G({afterRender:S,instrumentation:this.instrumentation,handleError:h}),this.region=a.Eu.ZERO,this.os==="Windows"&&(this.clearProgram=new V(this))}static useOptional(t){return t.getOptional(f.CONTEXT_KEY)}static use(t){return t.get(f.CONTEXT_KEY)}update(t){t.set(f.CONTEXT_KEY,this)}resize(t,e){a.Eu.equals(this.region,t)&&this.dpr===e||(this.region=t,this.dpr=e,this.resizeCanvas(this.glCanvas),this.resizeCanvas(this.upper2dCanvas),this.resizeCanvas(this.lower2dCanvas),this.lower2d.scale(this.dpr,this.dpr),this.upper2d.scale(this.dpr,this.dpr),this.gl.viewport(0,0,a.Eu.width(t)*e,a.Eu.height(t)*e))}resizeCanvas(t){t.width=a.Eu.width(this.region)*this.dpr,t.height=a.Eu.height(this.region)*this.dpr}get aspect(){return a.Eu.aspect(this.region)}scaleRegion(t){return new a.Tu.XY(a.Tu.Scale.scale(0,1).scale(a.Eu.width(t)).translate(a.Eu.left(t)).reBound(a.Eu.width(this.region)).scale(-1,1),a.Tu.Scale.scale(0,1).scale(a.Eu.height(t)).invert().translate(a.Eu.top(t)).reBound(a.Eu.height(this.region)).scale(-1,1).invert())}scissor(t,e=a.Au.ZERO,s){const i=[];return s.includes("upper2d")&&i.push(this.upper2d.scissor(t,e)),s.includes("lower2d")&&i.push(this.lower2d.scissor(t,e)),s.includes("gl")&&i.push(this.scissorGL(t,e)),()=>i.forEach(r=>r())}scissorGL(t,e=a.Au.ZERO){return this.gl.enable(this.gl.SCISSOR_TEST),t=y(t,e),this.gl.scissor(a.Eu.left(t)*this.dpr,(a.Eu.height(this.region)-a.Eu.bottom(t))*this.dpr,a.Eu.width(t)*this.dpr,a.Eu.height(t)*this.dpr),()=>this.gl.disable(this.gl.SCISSOR_TEST)}erase(t,e=a.Au.ZERO,...s){e=a.Au.construct(e),s.length===0&&(s=["upper2d","lower2d","gl"]),s.includes("upper2d")&&this.eraseCanvas(this.upper2d,t,e),s.includes("lower2d")&&this.eraseCanvas(this.lower2d,t,e),s.includes("gl")&&this.eraseGL(t,e)}eraseGL(t,e=a.Au.ZERO){const{gl:s}=this,i=this.scissorGL(y(t,e));s.clearColor(...a.Zu.rgba1(a.Zu.ZERO)),s.clear(s.COLOR_BUFFER_BIT),this.os==="Windows"&&this.clearProgram?.exec(),i()}eraseCanvas(t,e,s=a.Au.ZERO){const i=y(e,s);t.clearRect(...a.Au.couple(a.Eu.topLeft(i)),...a.Su.couple(a.Eu.dims(i)))}}const M=_.z.object({region:a.Eu.box,enabled:_.z.boolean().default(!1)}),P=["gl","lower2d","upper2d"];class R extends d.Leaf{static TYPE="eraser";schema=M;afterUpdate(t){this.deleted||(this.internal.renderCtx=f.use(t),this.renderOnLifecycleChange())}afterDelete(){this.renderOnLifecycleChange()}renderOnLifecycleChange(){this.internal.renderCtx.loop.set({key:`${this.type}-${this.key}`,render:this.render.bind(this),priority:"high",canvases:P})}render(){this.deleted||!this.state.enabled||this.internal.renderCtx.erase(this.state.region,a.Au.construct(0),...P)}}const $={[R.TYPE]:R};exports.Context=f;exports.Eraser=R;exports.GLProgram=k;exports.Loop=G;exports.Provider=A;exports.REGISTRY=$;exports.REGISTRY$1=Z;exports.eraserStateZ=M;exports.providerStateZ=I;exports.useInstrumentation=B;