@sprawlify/primitives 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/dist/anatomy.cjs +3 -0
  2. package/dist/anatomy.d.cts +2 -0
  3. package/dist/anatomy.d.mts +2 -0
  4. package/dist/anatomy.mjs +3 -0
  5. package/dist/aria-hidden-DqYx0f_y.mjs +177 -0
  6. package/dist/aria-hidden-DtLU6hSU.cjs +182 -0
  7. package/dist/aria-hidden.cjs +4 -0
  8. package/dist/aria-hidden.d.cts +16 -0
  9. package/dist/aria-hidden.d.mts +16 -0
  10. package/dist/aria-hidden.mjs +4 -0
  11. package/dist/auto-resize-D3qHtFy1.mjs +114 -0
  12. package/dist/auto-resize-xzlPFDyD.cjs +125 -0
  13. package/dist/auto-resize.cjs +5 -0
  14. package/dist/auto-resize.d.cts +17 -0
  15. package/dist/auto-resize.d.mts +17 -0
  16. package/dist/auto-resize.mjs +4 -0
  17. package/dist/chunk-CbDLau6x.cjs +34 -0
  18. package/dist/collection-8XqaNHs_.mjs +1279 -0
  19. package/dist/collection-DIoIDISa.cjs +1326 -0
  20. package/dist/collection.cjs +11 -0
  21. package/dist/collection.d.cts +5 -0
  22. package/dist/collection.d.mts +5 -0
  23. package/dist/collection.mjs +4 -0
  24. package/dist/color-BkAP1Tkd.d.mts +60 -0
  25. package/dist/color-VKewNv2e.d.cts +60 -0
  26. package/dist/color-utils-Cc5GVXZh.mjs +657 -0
  27. package/dist/color-utils-LER_6Zwu.cjs +680 -0
  28. package/dist/color-utils.cjs +7 -0
  29. package/dist/color-utils.d.cts +19 -0
  30. package/dist/color-utils.d.mts +19 -0
  31. package/dist/color-utils.mjs +4 -0
  32. package/dist/core-30pJjyC2.d.mts +49 -0
  33. package/dist/core-CQFbMdTl.cjs +176 -0
  34. package/dist/core-CefBjbst.d.cts +49 -0
  35. package/dist/core-DCFNMTZF.mjs +129 -0
  36. package/dist/core.cjs +12 -0
  37. package/dist/core.d.cts +3 -0
  38. package/dist/core.d.mts +3 -0
  39. package/dist/core.mjs +5 -0
  40. package/dist/create-anatomy-B3XYc-qG.d.mts +70 -0
  41. package/dist/create-anatomy-BGQ8pv8J.d.cts +70 -0
  42. package/dist/create-anatomy-BbDZbHpC.mjs +39 -0
  43. package/dist/create-anatomy-CDsIFUXg.cjs +45 -0
  44. package/dist/create-props-BnF_vl-E.mjs +5 -0
  45. package/dist/create-props-YKy7JIKj.cjs +11 -0
  46. package/dist/data-url-C3ITPVRX.d.cts +10 -0
  47. package/dist/data-url-DLwZ9M77.d.mts +10 -0
  48. package/dist/date-utils-D2xPHa_I.cjs +738 -0
  49. package/dist/date-utils-wEa1hhpc.mjs +474 -0
  50. package/dist/date-utils.cjs +46 -0
  51. package/dist/date-utils.d.cts +101 -0
  52. package/dist/date-utils.d.mts +2 -0
  53. package/dist/date-utils.mjs +3 -0
  54. package/dist/defineProperty-BoUOT9Ie.cjs +49 -0
  55. package/dist/defineProperty-DrXfyjd4.mjs +43 -0
  56. package/dist/dismissable-CTfKZ4OG.cjs +282 -0
  57. package/dist/dismissable-DDrx0xnH.mjs +271 -0
  58. package/dist/dismissable-layer-C7pZU2wi.d.cts +39 -0
  59. package/dist/dismissable-layer-t_b0fk-p.d.mts +39 -0
  60. package/dist/dismissable.cjs +7 -0
  61. package/dist/dismissable.d.cts +3 -0
  62. package/dist/dismissable.d.mts +3 -0
  63. package/dist/dismissable.mjs +6 -0
  64. package/dist/dom-query-CWZdWUGp.cjs +2141 -0
  65. package/dist/dom-query-DFCRhyj1.mjs +1374 -0
  66. package/dist/dom-query.cjs +130 -0
  67. package/dist/dom-query.d.cts +307 -0
  68. package/dist/dom-query.d.mts +307 -0
  69. package/dist/dom-query.mjs +3 -0
  70. package/dist/file-utils.cjs +220 -0
  71. package/dist/file-utils.d.cts +51 -0
  72. package/dist/file-utils.d.mts +51 -0
  73. package/dist/file-utils.mjs +210 -0
  74. package/dist/focus-trap-D-bypQEJ.mjs +485 -0
  75. package/dist/focus-trap-D4i52S9A.cjs +496 -0
  76. package/dist/focus-trap.cjs +5 -0
  77. package/dist/focus-trap.d.cts +88 -0
  78. package/dist/focus-trap.d.mts +88 -0
  79. package/dist/focus-trap.mjs +4 -0
  80. package/dist/focus-visible-DYTWdWpa.cjs +210 -0
  81. package/dist/focus-visible-irppYatv.mjs +175 -0
  82. package/dist/focus-visible.cjs +9 -0
  83. package/dist/focus-visible.d.cts +31 -0
  84. package/dist/focus-visible.d.mts +31 -0
  85. package/dist/focus-visible.mjs +4 -0
  86. package/dist/functions-BOkTDEFM.d.cts +15 -0
  87. package/dist/functions-IZtWcC8Q.d.mts +15 -0
  88. package/dist/highlight-word.cjs +100 -0
  89. package/dist/highlight-word.d.cts +24 -0
  90. package/dist/highlight-word.d.mts +24 -0
  91. package/dist/highlight-word.mjs +99 -0
  92. package/dist/hotkeys.cjs +758 -0
  93. package/dist/hotkeys.d.cts +130 -0
  94. package/dist/hotkeys.d.mts +130 -0
  95. package/dist/hotkeys.mjs +754 -0
  96. package/dist/i18n-utils.cjs +450 -0
  97. package/dist/i18n-utils.d.cts +61 -0
  98. package/dist/i18n-utils.d.mts +61 -0
  99. package/dist/i18n-utils.mjs +440 -0
  100. package/dist/index-BkzYij2j.d.mts +25 -0
  101. package/dist/index-Bqw3r34-.d.cts +1383 -0
  102. package/dist/index-C0MKXQmE.d.mts +1383 -0
  103. package/dist/index-C9-feK5c.d.cts +25 -0
  104. package/dist/index-CD5FN7kY.d.mts +114 -0
  105. package/dist/index-CJji6wHl.d.cts +15 -0
  106. package/dist/index-CNi5FkPe.d.mts +15 -0
  107. package/dist/index-D96rs8B0.d.mts +115 -0
  108. package/dist/index.cjs +0 -0
  109. package/dist/index.d.cts +1 -0
  110. package/dist/index.d.mts +1 -0
  111. package/dist/index.mjs +1 -0
  112. package/dist/interact-outside-BplxR9cR.mjs +200 -0
  113. package/dist/interact-outside-C8-oFBpB.cjs +205 -0
  114. package/dist/interact-outside.cjs +5 -0
  115. package/dist/interact-outside.d.cts +2 -0
  116. package/dist/interact-outside.d.mts +2 -0
  117. package/dist/interact-outside.mjs +5 -0
  118. package/dist/json-tree-utils.cjs +1512 -0
  119. package/dist/json-tree-utils.d.cts +117 -0
  120. package/dist/json-tree-utils.d.mts +117 -0
  121. package/dist/json-tree-utils.mjs +1463 -0
  122. package/dist/list-collection-BIMJGQjn.d.cts +61 -0
  123. package/dist/list-collection-Db3eixRU.d.mts +61 -0
  124. package/dist/live-region-CcZPGo89.cjs +52 -0
  125. package/dist/live-region-CnPh21WH.mjs +46 -0
  126. package/dist/live-region.cjs +3 -0
  127. package/dist/live-region.d.cts +2 -0
  128. package/dist/live-region.d.mts +2 -0
  129. package/dist/live-region.mjs +3 -0
  130. package/dist/machines/accordion/index.cjs +328 -0
  131. package/dist/machines/accordion/index.d.cts +83 -0
  132. package/dist/machines/accordion/index.d.mts +83 -0
  133. package/dist/machines/accordion/index.mjs +322 -0
  134. package/dist/machines/async-list/index.cjs +311 -0
  135. package/dist/machines/async-list/index.d.cts +89 -0
  136. package/dist/machines/async-list/index.d.mts +89 -0
  137. package/dist/machines/async-list/index.mjs +310 -0
  138. package/dist/machines/avatar/index.cjs +169 -0
  139. package/dist/machines/avatar/index.d.cts +63 -0
  140. package/dist/machines/avatar/index.d.mts +63 -0
  141. package/dist/machines/avatar/index.mjs +165 -0
  142. package/dist/machines/bottom-sheet/index.cjs +676 -0
  143. package/dist/machines/bottom-sheet/index.d.cts +239 -0
  144. package/dist/machines/bottom-sheet/index.d.mts +239 -0
  145. package/dist/machines/bottom-sheet/index.mjs +672 -0
  146. package/dist/machines/carousel/index.cjs +859 -0
  147. package/dist/machines/carousel/index.d.cts +146 -0
  148. package/dist/machines/carousel/index.d.mts +146 -0
  149. package/dist/machines/carousel/index.mjs +851 -0
  150. package/dist/machines/checkbox/index.cjs +316 -0
  151. package/dist/machines/checkbox/index.d.cts +81 -0
  152. package/dist/machines/checkbox/index.d.mts +81 -0
  153. package/dist/machines/checkbox/index.mjs +312 -0
  154. package/dist/machines/clipboard/index.cjs +225 -0
  155. package/dist/machines/clipboard/index.d.cts +68 -0
  156. package/dist/machines/clipboard/index.d.mts +68 -0
  157. package/dist/machines/clipboard/index.mjs +219 -0
  158. package/dist/machines/collapsible/index.cjs +362 -0
  159. package/dist/machines/collapsible/index.d.cts +82 -0
  160. package/dist/machines/collapsible/index.d.mts +82 -0
  161. package/dist/machines/collapsible/index.mjs +358 -0
  162. package/dist/machines/color-picker/index.cjs +1529 -0
  163. package/dist/machines/color-picker/index.d.cts +205 -0
  164. package/dist/machines/color-picker/index.d.mts +205 -0
  165. package/dist/machines/color-picker/index.mjs +1514 -0
  166. package/dist/machines/combobox/index.cjs +1593 -0
  167. package/dist/machines/combobox/index.d.cts +214 -0
  168. package/dist/machines/combobox/index.d.mts +214 -0
  169. package/dist/machines/combobox/index.mjs +1582 -0
  170. package/dist/machines/date-picker/index.cjs +2177 -0
  171. package/dist/machines/date-picker/index.d.cts +350 -0
  172. package/dist/machines/date-picker/index.d.mts +350 -0
  173. package/dist/machines/date-picker/index.mjs +2161 -0
  174. package/dist/machines/dialog/index.cjs +325 -0
  175. package/dist/machines/dialog/index.d.cts +80 -0
  176. package/dist/machines/dialog/index.d.mts +80 -0
  177. package/dist/machines/dialog/index.mjs +321 -0
  178. package/dist/machines/editable/index.cjs +551 -0
  179. package/dist/machines/editable/index.d.cts +114 -0
  180. package/dist/machines/editable/index.d.mts +114 -0
  181. package/dist/machines/editable/index.mjs +547 -0
  182. package/dist/machines/floating-panel/index.cjs +995 -0
  183. package/dist/machines/floating-panel/index.d.cts +147 -0
  184. package/dist/machines/floating-panel/index.d.mts +147 -0
  185. package/dist/machines/floating-panel/index.mjs +988 -0
  186. package/dist/machines/hover-card/index.cjs +383 -0
  187. package/dist/machines/hover-card/index.d.cts +69 -0
  188. package/dist/machines/hover-card/index.d.mts +69 -0
  189. package/dist/machines/hover-card/index.mjs +379 -0
  190. package/dist/machines/image-cropper/index.cjs +1995 -0
  191. package/dist/machines/image-cropper/index.d.cts +182 -0
  192. package/dist/machines/image-cropper/index.d.mts +182 -0
  193. package/dist/machines/image-cropper/index.mjs +1990 -0
  194. package/dist/machines/listbox/index.cjs +794 -0
  195. package/dist/machines/listbox/index.d.cts +168 -0
  196. package/dist/machines/listbox/index.d.mts +168 -0
  197. package/dist/machines/listbox/index.mjs +782 -0
  198. package/dist/machines/marquee/index.cjs +395 -0
  199. package/dist/machines/marquee/index.d.cts +102 -0
  200. package/dist/machines/marquee/index.d.mts +102 -0
  201. package/dist/machines/marquee/index.mjs +391 -0
  202. package/dist/machines/menu/index.cjs +1298 -0
  203. package/dist/machines/menu/index.d.cts +175 -0
  204. package/dist/machines/menu/index.d.mts +175 -0
  205. package/dist/machines/menu/index.mjs +1286 -0
  206. package/dist/machines/navigation-menu/index.cjs +861 -0
  207. package/dist/machines/navigation-menu/index.d.cts +127 -0
  208. package/dist/machines/navigation-menu/index.d.mts +127 -0
  209. package/dist/machines/navigation-menu/index.mjs +857 -0
  210. package/dist/machines/number-input/index.cjs +996 -0
  211. package/dist/machines/number-input/index.d.cts +134 -0
  212. package/dist/machines/number-input/index.d.mts +134 -0
  213. package/dist/machines/number-input/index.mjs +991 -0
  214. package/dist/machines/pagination/index.cjs +419 -0
  215. package/dist/machines/pagination/index.d.cts +139 -0
  216. package/dist/machines/pagination/index.d.mts +139 -0
  217. package/dist/machines/pagination/index.mjs +411 -0
  218. package/dist/machines/password-input/index.cjs +228 -0
  219. package/dist/machines/password-input/index.d.cts +71 -0
  220. package/dist/machines/password-input/index.d.mts +71 -0
  221. package/dist/machines/password-input/index.mjs +224 -0
  222. package/dist/machines/pin-input/index.cjs +523 -0
  223. package/dist/machines/pin-input/index.d.cts +105 -0
  224. package/dist/machines/pin-input/index.d.mts +105 -0
  225. package/dist/machines/pin-input/index.mjs +519 -0
  226. package/dist/machines/popover/index.cjs +430 -0
  227. package/dist/machines/popover/index.d.cts +88 -0
  228. package/dist/machines/popover/index.d.mts +88 -0
  229. package/dist/machines/popover/index.mjs +426 -0
  230. package/dist/machines/presence/index.cjs +192 -0
  231. package/dist/machines/presence/index.d.cts +44 -0
  232. package/dist/machines/presence/index.d.mts +44 -0
  233. package/dist/machines/presence/index.mjs +190 -0
  234. package/dist/machines/progress/index.cjs +288 -0
  235. package/dist/machines/progress/index.d.cts +96 -0
  236. package/dist/machines/progress/index.d.mts +96 -0
  237. package/dist/machines/progress/index.mjs +284 -0
  238. package/dist/machines/qr-code/index.cjs +172 -0
  239. package/dist/machines/qr-code/index.d.cts +70 -0
  240. package/dist/machines/qr-code/index.d.mts +70 -0
  241. package/dist/machines/qr-code/index.mjs +167 -0
  242. package/dist/machines/radio-group/index.cjs +436 -0
  243. package/dist/machines/radio-group/index.d.cts +106 -0
  244. package/dist/machines/radio-group/index.d.mts +106 -0
  245. package/dist/machines/radio-group/index.mjs +430 -0
  246. package/dist/machines/rating-group/index.cjs +405 -0
  247. package/dist/machines/rating-group/index.d.cts +101 -0
  248. package/dist/machines/rating-group/index.d.mts +101 -0
  249. package/dist/machines/rating-group/index.mjs +399 -0
  250. package/dist/machines/scroll-area/index.cjs +857 -0
  251. package/dist/machines/scroll-area/index.d.cts +159 -0
  252. package/dist/machines/scroll-area/index.d.mts +159 -0
  253. package/dist/machines/scroll-area/index.mjs +853 -0
  254. package/dist/machines/select/index.cjs +1165 -0
  255. package/dist/machines/select/index.d.cts +183 -0
  256. package/dist/machines/select/index.d.mts +183 -0
  257. package/dist/machines/select/index.mjs +1154 -0
  258. package/dist/machines/signature-pad/index.cjs +334 -0
  259. package/dist/machines/signature-pad/index.d.cts +108 -0
  260. package/dist/machines/signature-pad/index.d.mts +108 -0
  261. package/dist/machines/signature-pad/index.mjs +328 -0
  262. package/dist/machines/slider/index.cjs +957 -0
  263. package/dist/machines/slider/index.d.cts +149 -0
  264. package/dist/machines/slider/index.d.mts +149 -0
  265. package/dist/machines/slider/index.mjs +949 -0
  266. package/dist/machines/splitter/index.cjs +1112 -0
  267. package/dist/machines/splitter/index.d.cts +155 -0
  268. package/dist/machines/splitter/index.d.mts +155 -0
  269. package/dist/machines/splitter/index.mjs +1103 -0
  270. package/dist/machines/steps/index.cjs +289 -0
  271. package/dist/machines/steps/index.d.cts +97 -0
  272. package/dist/machines/steps/index.d.mts +97 -0
  273. package/dist/machines/steps/index.mjs +285 -0
  274. package/dist/machines/switch/index.cjs +305 -0
  275. package/dist/machines/switch/index.d.cts +80 -0
  276. package/dist/machines/switch/index.d.mts +80 -0
  277. package/dist/machines/switch/index.mjs +301 -0
  278. package/dist/machines/tabs/index.cjs +508 -0
  279. package/dist/machines/tabs/index.d.cts +111 -0
  280. package/dist/machines/tabs/index.d.mts +111 -0
  281. package/dist/machines/tabs/index.mjs +500 -0
  282. package/dist/machines/tags-input/index.cjs +1127 -0
  283. package/dist/machines/tags-input/index.d.cts +179 -0
  284. package/dist/machines/tags-input/index.d.mts +179 -0
  285. package/dist/machines/tags-input/index.mjs +1121 -0
  286. package/dist/machines/timer/index.cjs +329 -0
  287. package/dist/machines/timer/index.d.cts +98 -0
  288. package/dist/machines/timer/index.d.mts +98 -0
  289. package/dist/machines/timer/index.mjs +324 -0
  290. package/dist/machines/toast/index.cjs +1155 -0
  291. package/dist/machines/toast/index.d.cts +195 -0
  292. package/dist/machines/toast/index.d.mts +195 -0
  293. package/dist/machines/toast/index.mjs +1151 -0
  294. package/dist/machines/toggle/index.cjs +103 -0
  295. package/dist/machines/toggle/index.d.cts +46 -0
  296. package/dist/machines/toggle/index.d.mts +46 -0
  297. package/dist/machines/toggle/index.mjs +99 -0
  298. package/dist/machines/toggle-group/index.cjs +328 -0
  299. package/dist/machines/toggle-group/index.d.cts +81 -0
  300. package/dist/machines/toggle-group/index.d.mts +81 -0
  301. package/dist/machines/toggle-group/index.mjs +322 -0
  302. package/dist/machines/tooltip/index.cjs +516 -0
  303. package/dist/machines/tooltip/index.d.cts +71 -0
  304. package/dist/machines/tooltip/index.d.mts +71 -0
  305. package/dist/machines/tooltip/index.mjs +512 -0
  306. package/dist/machines/tour/index.cjs +1108 -0
  307. package/dist/machines/tour/index.d.cts +206 -0
  308. package/dist/machines/tour/index.d.mts +206 -0
  309. package/dist/machines/tour/index.mjs +1101 -0
  310. package/dist/machines/tree-view/index.cjs +1271 -0
  311. package/dist/machines/tree-view/index.d.cts +215 -0
  312. package/dist/machines/tree-view/index.d.mts +215 -0
  313. package/dist/machines/tree-view/index.mjs +1263 -0
  314. package/dist/node-BctU8GXk.d.mts +24 -0
  315. package/dist/node-CSsuPZVZ.d.cts +24 -0
  316. package/dist/popper-BPJeAtcA.mjs +349 -0
  317. package/dist/popper-D0FAW_p7.cjs +373 -0
  318. package/dist/popper.cjs +8 -0
  319. package/dist/popper.d.cts +74 -0
  320. package/dist/popper.d.mts +2 -0
  321. package/dist/popper.mjs +5 -0
  322. package/dist/raf-BnlYUlDi.d.mts +15 -0
  323. package/dist/raf-Cd2FGy0z.d.cts +15 -0
  324. package/dist/rect-utils-0ellN0a_.mjs +854 -0
  325. package/dist/rect-utils-DKLRhP8G.cjs +1147 -0
  326. package/dist/rect-utils.cjs +51 -0
  327. package/dist/rect-utils.d.cts +198 -0
  328. package/dist/rect-utils.d.mts +198 -0
  329. package/dist/rect-utils.mjs +3 -0
  330. package/dist/remove-scroll-Lrfv79X_.mjs +58 -0
  331. package/dist/remove-scroll-Uvzg1L9r.cjs +63 -0
  332. package/dist/remove-scroll.cjs +0 -0
  333. package/dist/remove-scroll.d.cts +1 -0
  334. package/dist/remove-scroll.d.mts +1 -0
  335. package/dist/remove-scroll.mjs +1 -0
  336. package/dist/scroll-snap-CrTmQRzA.mjs +152 -0
  337. package/dist/scroll-snap-zyiZLv7W.cjs +175 -0
  338. package/dist/scroll-snap.cjs +7 -0
  339. package/dist/scroll-snap.d.cts +14 -0
  340. package/dist/scroll-snap.d.mts +14 -0
  341. package/dist/scroll-snap.mjs +4 -0
  342. package/dist/selection-BIhSzkF7.d.mts +50 -0
  343. package/dist/selection-CS1GBp8e.d.cts +50 -0
  344. package/dist/store-BZcXv49B.cjs +305 -0
  345. package/dist/store-DEojWy9H.mjs +263 -0
  346. package/dist/store.cjs +9 -0
  347. package/dist/store.d.cts +26 -0
  348. package/dist/store.d.mts +26 -0
  349. package/dist/store.mjs +3 -0
  350. package/dist/stringify-state.cjs +49 -0
  351. package/dist/stringify-state.d.cts +8 -0
  352. package/dist/stringify-state.d.mts +8 -0
  353. package/dist/stringify-state.mjs +46 -0
  354. package/dist/tree-collection-BwU5WhGQ.d.mts +78 -0
  355. package/dist/tree-collection-DP_eznnI.d.cts +78 -0
  356. package/dist/typeahead-BdNwVP09.d.cts +45 -0
  357. package/dist/typeahead-XN6lZ7G9.d.mts +45 -0
  358. package/dist/types-BivBkYg9.d.cts +57 -0
  359. package/dist/types-Bl_6JtPQ.d.mts +57 -0
  360. package/dist/types-CPUMVt7c.d.mts +54 -0
  361. package/dist/types-CT_W6HWr.d.cts +54 -0
  362. package/dist/types-DDTcG99l.d.mts +201 -0
  363. package/dist/types-DejIu60O.d.cts +201 -0
  364. package/dist/types-DiIdKZ3K.d.cts +45 -0
  365. package/dist/types-GxLIgJib.d.cts +17 -0
  366. package/dist/types.cjs +15 -0
  367. package/dist/types.d.cts +2 -0
  368. package/dist/types.d.mts +2 -0
  369. package/dist/types.mjs +14 -0
  370. package/dist/utils-BZyrxWWR.mjs +525 -0
  371. package/dist/utils-_6frwjgJ.cjs +1040 -0
  372. package/dist/utils.cjs +88 -0
  373. package/dist/utils.d.cts +144 -0
  374. package/dist/utils.d.mts +144 -0
  375. package/dist/utils.mjs +3 -0
  376. package/dist/wait-for-CMjPsqWk.d.cts +10 -0
  377. package/dist/wait-for-D2nkdD4z.d.mts +10 -0
  378. package/package.json +399 -0
@@ -0,0 +1,1463 @@
1
+ //#region src/shared/json-tree-utils/json-to-tree.ts
2
+ const MAX_DEPTH = 20;
3
+ const jsonToTree = (data, props = {}) => {
4
+ const { visited = /* @__PURE__ */ new WeakSet(), keyPath = [ROOT_KEY], depth = 0 } = props;
5
+ const options = getPreviewOptions(props.options);
6
+ if (depth > MAX_DEPTH) return {
7
+ value: "[Max Depth Reached]",
8
+ type: "string",
9
+ keyPath
10
+ };
11
+ if (data && typeof data === "object") {
12
+ if (visited.has(data)) return {
13
+ value: "[Circular Reference]",
14
+ type: "circular",
15
+ keyPath
16
+ };
17
+ visited.add(data);
18
+ }
19
+ return (dataTypes.find((dataType$1) => dataType$1.check(data)) || PrimitiveType).node({
20
+ value: data,
21
+ createNode: (nestedKeyPath, value) => jsonToTree(value, {
22
+ visited,
23
+ keyPath: [...keyPath, ...nestedKeyPath],
24
+ options,
25
+ depth: depth + 1
26
+ }),
27
+ keyPath,
28
+ options
29
+ });
30
+ };
31
+
32
+ //#endregion
33
+ //#region src/shared/json-tree-utils/shared.ts
34
+ const regexReturnCharacters = /\r/g;
35
+ function hash(str) {
36
+ const v = str.replace(regexReturnCharacters, "");
37
+ let hash$1 = 5381;
38
+ let i = v.length;
39
+ while (i--) hash$1 = (hash$1 << 5) - hash$1 ^ v.charCodeAt(i);
40
+ return (hash$1 >>> 0).toString(36);
41
+ }
42
+ function getProp(value, key) {
43
+ return value[key];
44
+ }
45
+ function defu(a, b) {
46
+ const res = { ...a };
47
+ for (const key in b) if (b[key] !== void 0) res[key] = b[key];
48
+ return res;
49
+ }
50
+ const isObj = (v) => v != null && typeof v === "object" && !Array.isArray(v);
51
+ const typeOf = (value) => Object.prototype.toString.call(value);
52
+
53
+ //#endregion
54
+ //#region src/shared/json-tree-utils/node-conversion.ts
55
+ const ROOT_KEY = "$";
56
+ const PATH_SEP = ".";
57
+ function isRootKeyPath(keyPath) {
58
+ return keyPath.length === 1 && keyPath[0] === ROOT_KEY;
59
+ }
60
+ function keyPathToId(keyPath) {
61
+ return keyPath.join(PATH_SEP);
62
+ }
63
+ function keyPathToKey(keyPath, opts) {
64
+ if (keyPath.length === 0) return "";
65
+ if (opts?.excludeRoot && isRootKeyPath(keyPath)) return "";
66
+ return String(keyPath[keyPath.length - 1]);
67
+ }
68
+ function nodeToValue(node) {
69
+ return hash(keyPathToId(node.keyPath));
70
+ }
71
+ function jsonPathToValue(path) {
72
+ return hash(path);
73
+ }
74
+ function nodeToString(node) {
75
+ return keyPathToKey(node.keyPath) || "root";
76
+ }
77
+ function getRootNode(data, opts) {
78
+ return {
79
+ value: "",
80
+ type: "object",
81
+ keyPath: [],
82
+ children: [jsonToTree(data, {
83
+ visited: /* @__PURE__ */ new WeakSet(),
84
+ keyPath: [ROOT_KEY],
85
+ options: getPreviewOptions(opts)
86
+ })]
87
+ };
88
+ }
89
+ const DEFAULT_PREVIEW_OPTIONS = {
90
+ maxPreviewItems: 3,
91
+ collapseStringsAfterLength: 30,
92
+ groupArraysAfterLength: 100,
93
+ showNonenumerable: true
94
+ };
95
+ const getPreviewOptions = (opts) => {
96
+ if (!opts) return DEFAULT_PREVIEW_OPTIONS;
97
+ return defu(DEFAULT_PREVIEW_OPTIONS, opts);
98
+ };
99
+
100
+ //#endregion
101
+ //#region src/shared/json-tree-utils/data-type.ts
102
+ const generatePreviewText = (items, hasMore) => {
103
+ return ` ${items.join(", ")}${hasMore ? ", … " : " "}`;
104
+ };
105
+ const ENTRIES_KEY = "[[Entries]]";
106
+ const txt = (value) => ({
107
+ type: "text",
108
+ value
109
+ });
110
+ const jsx = (tagName, properties = {}, children = []) => ({
111
+ type: "element",
112
+ tagName,
113
+ properties,
114
+ children
115
+ });
116
+ const formatValueMini = (child) => {
117
+ if (child.type === "string") return `"${child.value}"`;
118
+ if (child.type === "null") return "null";
119
+ if (child.type === "undefined" || child.type === "symbol") return "undefined";
120
+ if (child.type === "object") return "{…}";
121
+ if (child.type === "array") return "[…]";
122
+ if (child.type === "set") return "Set(…)";
123
+ if (child.type === "map") return "Map(…)";
124
+ if (child.type === "iterable") return "Iterable(…)";
125
+ if (child.type === "function") return "ƒ(…)";
126
+ return String(child.value);
127
+ };
128
+ const formatValue = (value) => {
129
+ if (value === null) return "null";
130
+ if (value === void 0) return "undefined";
131
+ if (typeof value === "string") return `"${value}"`;
132
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
133
+ if (value instanceof Date) return value.toISOString();
134
+ if (value instanceof Set) return `Set(${value.size})`;
135
+ if (value instanceof Map) return `Map(${value.size})`;
136
+ if (Array.isArray(value)) return `Array(${value.length})`;
137
+ if (typeof value === "object") return "Object";
138
+ return String(value);
139
+ };
140
+ function dataType(opts) {
141
+ return opts;
142
+ }
143
+ const NullType = dataType({
144
+ type: "null",
145
+ description: "null",
146
+ check(value) {
147
+ return value === null;
148
+ },
149
+ previewElement() {
150
+ return jsx("span", {}, [txt("null")]);
151
+ },
152
+ node({ value, keyPath }) {
153
+ return {
154
+ value,
155
+ type: "null",
156
+ keyPath
157
+ };
158
+ }
159
+ });
160
+ const UndefinedType = dataType({
161
+ type: "undefined",
162
+ description: "undefined",
163
+ check(value) {
164
+ return value === void 0;
165
+ },
166
+ previewElement() {
167
+ return jsx("span", {}, [txt("undefined")]);
168
+ },
169
+ node({ value, keyPath }) {
170
+ return {
171
+ type: "undefined",
172
+ value,
173
+ keyPath
174
+ };
175
+ }
176
+ });
177
+ const SymbolType = dataType({
178
+ type: "symbol",
179
+ description(node) {
180
+ return String(node.value);
181
+ },
182
+ check(value) {
183
+ return typeof value === "symbol";
184
+ },
185
+ previewElement(node) {
186
+ return jsx("span", {}, [txt(node.value.toString())]);
187
+ },
188
+ node({ value, keyPath }) {
189
+ return {
190
+ type: "symbol",
191
+ value,
192
+ keyPath
193
+ };
194
+ }
195
+ });
196
+ const BigIntType = dataType({
197
+ type: "bigint",
198
+ description(node) {
199
+ return `${node.value}n`;
200
+ },
201
+ check(value) {
202
+ return typeof value === "bigint";
203
+ },
204
+ previewElement(node) {
205
+ return jsx("span", {}, [txt(`${node.value}n`)]);
206
+ },
207
+ node({ value, keyPath }) {
208
+ return {
209
+ type: "bigint",
210
+ value,
211
+ keyPath
212
+ };
213
+ }
214
+ });
215
+ const SetType = dataType({
216
+ type: "set",
217
+ description(node) {
218
+ return `Set(${node.value.size})`;
219
+ },
220
+ check(value) {
221
+ return value instanceof Set;
222
+ },
223
+ previewText(node, opts) {
224
+ const maxItems = opts.maxPreviewItems;
225
+ const entries = Array.from(node.value);
226
+ return generatePreviewText(entries.slice(0, maxItems).map(formatValue), entries.length > maxItems);
227
+ },
228
+ previewElement(node, opts) {
229
+ const preview = this.previewText?.(node, opts) ?? "";
230
+ const size = node.value.size;
231
+ const children = [jsx("span", { kind: "constructor" }, [txt(`Set(${size})`)]), jsx("span", { kind: "brace" }, [txt(" {")])];
232
+ if (preview) children.push(jsx("span", { kind: "preview-text" }, [txt(preview)]));
233
+ children.push(jsx("span", { kind: "brace" }, [txt("}")]));
234
+ return jsx("span", {}, children);
235
+ },
236
+ node({ value, keyPath, createNode }) {
237
+ const entriesChildren = Array.from(value).map((item, index) => createNode([ENTRIES_KEY, index.toString()], item));
238
+ return {
239
+ type: "set",
240
+ value,
241
+ keyPath,
242
+ children: [{
243
+ value: Array.from(value),
244
+ keyPath: [...keyPath, ENTRIES_KEY],
245
+ type: "array",
246
+ children: entriesChildren,
247
+ isNonEnumerable: true
248
+ }, createNode(["size"], value.size)]
249
+ };
250
+ }
251
+ });
252
+ const WeakSetType = dataType({
253
+ type: "weakset",
254
+ description: "WeakSet",
255
+ check(value) {
256
+ return value instanceof WeakSet;
257
+ },
258
+ previewElement() {
259
+ return jsx("span", {}, [
260
+ jsx("span", { kind: "constructor" }, [txt("WeakSet")]),
261
+ jsx("span", { kind: "brace" }, [txt(" {")]),
262
+ jsx("span", { kind: "preview" }, [txt(" [[Entries]]: not enumerable ")]),
263
+ jsx("span", { kind: "brace" }, [txt("}")])
264
+ ]);
265
+ },
266
+ node({ value, keyPath }) {
267
+ return {
268
+ type: "weakset",
269
+ value,
270
+ keyPath
271
+ };
272
+ }
273
+ });
274
+ const WeakMapType = dataType({
275
+ type: "weakmap",
276
+ description: "WeakMap",
277
+ check(value) {
278
+ return value instanceof WeakMap;
279
+ },
280
+ previewElement() {
281
+ return jsx("span", {}, [
282
+ jsx("span", { kind: "constructor" }, [txt("WeakMap")]),
283
+ jsx("span", { kind: "brace" }, [txt(" {")]),
284
+ jsx("span", { kind: "preview" }, [txt(" [[Entries]]: not enumerable ")]),
285
+ jsx("span", { kind: "brace" }, [txt("}")])
286
+ ]);
287
+ },
288
+ node({ value, keyPath }) {
289
+ return {
290
+ type: "weakmap",
291
+ value,
292
+ keyPath
293
+ };
294
+ }
295
+ });
296
+ const REGEX_KEYS = [
297
+ "lastIndex",
298
+ "dotAll",
299
+ "flags",
300
+ "global",
301
+ "hasIndices",
302
+ "ignoreCase",
303
+ "multiline",
304
+ "source",
305
+ "sticky",
306
+ "unicode"
307
+ ];
308
+ const RegexType = dataType({
309
+ type: "regex",
310
+ description(node) {
311
+ return String(node.value);
312
+ },
313
+ check(value) {
314
+ return value instanceof RegExp;
315
+ },
316
+ previewElement(node) {
317
+ return jsx("span", {}, [txt(String(node.value))]);
318
+ },
319
+ node({ value, keyPath, createNode }) {
320
+ return {
321
+ value,
322
+ type: "regex",
323
+ keyPath,
324
+ children: REGEX_KEYS.map((key) => createNode([key], getProp(value, key)))
325
+ };
326
+ }
327
+ });
328
+ const DATA_VIEW_KEYS = [
329
+ "byteLength",
330
+ "byteOffset",
331
+ "buffer"
332
+ ];
333
+ const DataViewType = dataType({
334
+ type: "dataview",
335
+ description(node) {
336
+ return `DataView(${node.value.byteLength})`;
337
+ },
338
+ check(value) {
339
+ return value instanceof DataView;
340
+ },
341
+ previewElement(node) {
342
+ const dataView = node.value;
343
+ return jsx("span", {}, [
344
+ jsx("span", { kind: "constructor" }, [txt(`DataView(${dataView.byteLength})`)]),
345
+ jsx("span", { kind: "brace" }, [txt(" { ")]),
346
+ jsx("span", { kind: "preview" }, [txt(` buffer: ArrayBuffer(${dataView.buffer.byteLength}), byteOffset: ${dataView.byteOffset} `)]),
347
+ jsx("span", { kind: "brace" }, [txt(" }")])
348
+ ]);
349
+ },
350
+ node({ value, keyPath, createNode }) {
351
+ return {
352
+ value,
353
+ keyPath,
354
+ type: "dataview",
355
+ children: DATA_VIEW_KEYS.map((key) => createNode([key], getProp(value, key)))
356
+ };
357
+ }
358
+ });
359
+ const URL_KEYS = [
360
+ "href",
361
+ "origin",
362
+ "protocol",
363
+ "username",
364
+ "password",
365
+ "host",
366
+ "hostname",
367
+ "port",
368
+ "pathname",
369
+ "search",
370
+ "searchParams",
371
+ "hash"
372
+ ];
373
+ const UrlType = dataType({
374
+ type: "url",
375
+ description: "URL",
376
+ check(value) {
377
+ return typeOf(value) === "[object URL]";
378
+ },
379
+ previewElement(node, opts) {
380
+ const url = node.value;
381
+ const maxItems = opts.maxPreviewItems;
382
+ const preview = URL_KEYS.slice(0, maxItems).map((key) => `${key}: '${url[key]}'`).join(", ");
383
+ const hasMore = URL_KEYS.length > maxItems;
384
+ return jsx("span", {}, [
385
+ jsx("span", { kind: "constructor" }, [txt("URL")]),
386
+ jsx("span", { kind: "brace" }, [txt(" { ")]),
387
+ jsx("span", { kind: "preview-text" }, [txt(` ${preview}${hasMore ? ", …" : ""} `)]),
388
+ jsx("span", { kind: "brace" }, [txt(" }")])
389
+ ]);
390
+ },
391
+ node({ value, keyPath, createNode }) {
392
+ return {
393
+ value,
394
+ keyPath,
395
+ type: "url",
396
+ children: URL_KEYS.map((key) => createNode([key], Reflect.get(value, key)))
397
+ };
398
+ }
399
+ });
400
+ const URLSearchParamsType = dataType({
401
+ type: "urlsearchparams",
402
+ description: "URLSearchParams",
403
+ check(value) {
404
+ return typeOf(value) === "[object URLSearchParams]";
405
+ },
406
+ previewElement(node) {
407
+ const params = node.value;
408
+ const paramsArray = Array.from(params.entries());
409
+ return jsx("span", {}, [
410
+ jsx("span", { kind: "constructor" }, [txt("URLSearchParams")]),
411
+ jsx("span", { kind: "brace" }, [txt(" { ")]),
412
+ jsx("span", { kind: "preview" }, [txt(`size: ${paramsArray.length}`)]),
413
+ jsx("span", { kind: "brace" }, [txt(" }")])
414
+ ]);
415
+ },
416
+ node({ value, keyPath, createNode }) {
417
+ const entriesChildren = Array.from(value.entries()).map(([key, value$1], index) => {
418
+ const keyStr = String(key);
419
+ const keyNode = createNode([
420
+ ENTRIES_KEY,
421
+ keyStr,
422
+ "key"
423
+ ], key);
424
+ const valueNode = createNode([
425
+ ENTRIES_KEY,
426
+ keyStr,
427
+ "value"
428
+ ], value$1);
429
+ return {
430
+ keyPath: [
431
+ ...keyPath,
432
+ ENTRIES_KEY,
433
+ index
434
+ ],
435
+ value: { [key]: value$1 },
436
+ type: "object",
437
+ children: [keyNode, valueNode]
438
+ };
439
+ });
440
+ return {
441
+ value,
442
+ keyPath,
443
+ type: "urlsearchparams",
444
+ children: [{
445
+ keyPath: [...keyPath, "[[Entries]]"],
446
+ value: Array.from(value.entries()),
447
+ type: "array",
448
+ children: entriesChildren,
449
+ isNonEnumerable: true
450
+ }, createNode(["size"], Array.from(value.entries()).length)]
451
+ };
452
+ }
453
+ });
454
+ const BLOB_KEYS = ["size", "type"];
455
+ const BlobType = dataType({
456
+ type: "blob",
457
+ description(node) {
458
+ return `Blob(${node.value.size})`;
459
+ },
460
+ check(value) {
461
+ return typeOf(value) === "[object Blob]";
462
+ },
463
+ previewElement(node) {
464
+ const blob = node.value;
465
+ return jsx("span", {}, [
466
+ jsx("span", { kind: "constructor" }, [txt("Blob")]),
467
+ jsx("span", { kind: "brace" }, [txt(" { ")]),
468
+ jsx("span", { kind: "preview" }, [txt(`size: ${blob.size}, type: '${blob.type || "application/octet-stream"}'`)]),
469
+ jsx("span", { kind: "brace" }, [txt(" }")])
470
+ ]);
471
+ },
472
+ node({ value, keyPath, createNode }) {
473
+ return {
474
+ value,
475
+ keyPath,
476
+ type: "blob",
477
+ children: BLOB_KEYS.map((key) => ({
478
+ key,
479
+ value: Reflect.get(value, key)
480
+ })).map(({ key, value: value$1 }) => createNode([key], value$1))
481
+ };
482
+ }
483
+ });
484
+ const FILE_KEYS = [
485
+ "name",
486
+ "size",
487
+ "type",
488
+ "lastModified",
489
+ "webkitRelativePath"
490
+ ];
491
+ const FileType = dataType({
492
+ type: "file",
493
+ description(node) {
494
+ return `File(${node.value.size})`;
495
+ },
496
+ check(value) {
497
+ return typeOf(value) === "[object File]";
498
+ },
499
+ previewElement(node) {
500
+ const file = node.value;
501
+ const hasMore = FILE_KEYS.length > 2;
502
+ return jsx("span", {}, [
503
+ jsx("span", { kind: "constructor" }, [txt("File")]),
504
+ jsx("span", { kind: "brace" }, [txt(" { ")]),
505
+ jsx("span", { kind: "preview" }, [txt(`name: '${file.name}', lastModified: ${file.lastModified}${hasMore ? ", …" : ""}`)]),
506
+ jsx("span", { kind: "brace" }, [txt(" }")])
507
+ ]);
508
+ },
509
+ node({ value, keyPath, createNode }) {
510
+ return {
511
+ value,
512
+ keyPath,
513
+ type: "file",
514
+ children: FILE_KEYS.map((key) => ({
515
+ key,
516
+ value: getProp(value, key) || ""
517
+ })).map(({ key, value: value$1 }) => createNode([key], value$1))
518
+ };
519
+ }
520
+ });
521
+ const getFunctionString = (func) => {
522
+ try {
523
+ return func.toString();
524
+ } catch {
525
+ switch (func.constructor.name) {
526
+ case "AsyncFunction": return "async function () {}";
527
+ case "AsyncGeneratorFunction": return "async function * () {}";
528
+ case "GeneratorFunction": return "function * () {}";
529
+ default: return "function () {}";
530
+ }
531
+ }
532
+ };
533
+ const FUNCTION_SIGNATURE_REGEX = /(?:async\s+)?(?:function\s*\*?\s*)?([^(]*\([^)]*\))/;
534
+ const getFunctionSignature = (func) => {
535
+ const signatureMatch = getFunctionString(func).match(FUNCTION_SIGNATURE_REGEX);
536
+ return signatureMatch ? signatureMatch[1] : `${func.name || "anonymous"}()`;
537
+ };
538
+ const FUNC_KEYS = [
539
+ "name",
540
+ "length",
541
+ "prototype",
542
+ "caller",
543
+ "arguments"
544
+ ];
545
+ const FunctionType = dataType({
546
+ type: "function",
547
+ description(node) {
548
+ const func = node.value;
549
+ const name = func.name || "anonymous";
550
+ switch (func.constructor.name) {
551
+ case "AsyncFunction": return `async ƒ ${name}()`;
552
+ case "AsyncGeneratorFunction": return `async ƒ* ${name}()`;
553
+ case "GeneratorFunction": return `ƒ* ${name}()`;
554
+ default: return `ƒ ${name}()`;
555
+ }
556
+ },
557
+ check(value) {
558
+ return typeof value === "function";
559
+ },
560
+ previewElement(node) {
561
+ const func = node.value;
562
+ const signature = getFunctionSignature(func);
563
+ const constructorName = func.constructor.name;
564
+ const preview = signature.length > 50 ? `${signature.substring(0, 47)}...` : signature;
565
+ let functionTypePrefix = "";
566
+ if (constructorName === "AsyncFunction") functionTypePrefix += "async ";
567
+ if (constructorName === "AsyncGeneratorFunction") functionTypePrefix += "async ";
568
+ if (constructorName === "GeneratorFunction" || constructorName === "AsyncGeneratorFunction") functionTypePrefix += "ƒ* ";
569
+ if (!constructorName.includes("Generator")) functionTypePrefix += "ƒ ";
570
+ return jsx("span", {}, [jsx("span", { kind: "function-type" }, [txt(functionTypePrefix)]), jsx("span", { kind: "function-body" }, [txt(preview)])]);
571
+ },
572
+ node({ value, keyPath, createNode, options }) {
573
+ const funcName = value.name || "anonymous";
574
+ const constructorName = value.constructor.name;
575
+ const enumerableProperties = [];
576
+ const nonEnumerableProperties = [];
577
+ const funcString = getFunctionString(value);
578
+ nonEnumerableProperties.push({
579
+ key: "[[Function]]",
580
+ value: funcString
581
+ });
582
+ enumerableProperties.push({
583
+ key: "name",
584
+ value: funcName
585
+ });
586
+ enumerableProperties.push({
587
+ key: "length",
588
+ value: value.length
589
+ });
590
+ enumerableProperties.push({
591
+ key: "constructor",
592
+ value: constructorName
593
+ });
594
+ const additionalProps = Object.getOwnPropertyNames(value).filter((key) => !FUNC_KEYS.includes(key)).map((key) => ({
595
+ key,
596
+ value: Reflect.get(value, key)
597
+ }));
598
+ enumerableProperties.push(...additionalProps);
599
+ const enumerableChildren = enumerableProperties.map(({ key, value: value$1 }) => createNode([key], value$1));
600
+ const nonEnumerableChildren = options?.showNonenumerable ? nonEnumerableProperties.map(({ key, value: value$1 }) => {
601
+ const node = createNode([key], value$1);
602
+ node.isNonEnumerable = true;
603
+ return node;
604
+ }) : [];
605
+ return {
606
+ value,
607
+ type: "function",
608
+ keyPath,
609
+ children: [...enumerableChildren, ...nonEnumerableChildren]
610
+ };
611
+ }
612
+ });
613
+ const ArrayBufferType = dataType({
614
+ type: "arraybuffer",
615
+ description(node) {
616
+ return `ArrayBuffer(${node.value.byteLength})`;
617
+ },
618
+ check(value) {
619
+ return value instanceof ArrayBuffer;
620
+ },
621
+ previewElement(node) {
622
+ return jsx("span", { nodeType: "arraybuffer" }, [txt(node.value.toString())]);
623
+ },
624
+ node({ value, keyPath }) {
625
+ return {
626
+ value,
627
+ keyPath,
628
+ type: "arraybuffer"
629
+ };
630
+ }
631
+ });
632
+ const SharedArrayBufferType = dataType({
633
+ type: "sharedarraybuffer",
634
+ description(node) {
635
+ return `SharedArrayBuffer(${node.value.byteLength})`;
636
+ },
637
+ check(value) {
638
+ return typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
639
+ },
640
+ previewElement() {
641
+ return jsx("span", { nodeType: "sharedarraybuffer" }, [txt("sharedarraybuffer")]);
642
+ },
643
+ node({ value, keyPath }) {
644
+ return {
645
+ value,
646
+ keyPath,
647
+ type: "sharedarraybuffer"
648
+ };
649
+ }
650
+ });
651
+ const BufferType = dataType({
652
+ type: "buffer",
653
+ description(node) {
654
+ return `Buffer(${node.value.length})`;
655
+ },
656
+ check(value) {
657
+ return typeof Buffer !== "undefined" && value instanceof Buffer;
658
+ },
659
+ previewElement(node) {
660
+ const buffer = node.value;
661
+ const preview = Array.from(new Uint8Array(buffer).slice(0, 8)).map((byte) => byte.toString(16).padStart(2, "0")).join(" ");
662
+ const hasMore = buffer.length > 8;
663
+ return jsx("span", {}, [
664
+ jsx("span", { kind: "constructor" }, [txt(`Buffer(${buffer.length})`)]),
665
+ jsx("span", { kind: "brace" }, [txt(" ['")]),
666
+ jsx("span", { kind: "preview-text" }, [txt(preview + (hasMore ? " …" : ""))]),
667
+ jsx("span", { kind: "brace" }, [txt("']")])
668
+ ]);
669
+ },
670
+ node({ value, keyPath }) {
671
+ return {
672
+ value,
673
+ keyPath,
674
+ type: "buffer"
675
+ };
676
+ }
677
+ });
678
+ const DateType = dataType({
679
+ type: "date",
680
+ description(node) {
681
+ return String(node.value);
682
+ },
683
+ check(value) {
684
+ return value instanceof Date;
685
+ },
686
+ previewElement(node) {
687
+ return jsx("span", {}, [txt(node.value.toISOString())]);
688
+ },
689
+ node({ value, keyPath }) {
690
+ return {
691
+ value,
692
+ keyPath,
693
+ type: "date"
694
+ };
695
+ }
696
+ });
697
+ const MapType = dataType({
698
+ type: "map",
699
+ description(node) {
700
+ return `Map(${node.value.size})`;
701
+ },
702
+ check(value) {
703
+ return value instanceof Map;
704
+ },
705
+ previewText(node, opts) {
706
+ const maxItems = opts.maxPreviewItems;
707
+ const entries = Array.from(node.value.entries());
708
+ return generatePreviewText(entries.slice(0, maxItems).map(([key, value]) => {
709
+ const valueDesc = formatValue(value);
710
+ return `${typeof key === "string" ? `"${key}"` : String(key)} => ${valueDesc}`;
711
+ }), entries.length > maxItems);
712
+ },
713
+ previewElement(node, opts) {
714
+ const preview = this.previewText?.(node, opts) || "";
715
+ const size = node.value.size;
716
+ const children = [jsx("span", { kind: "constructor" }, [txt(`Map(${size})`)]), jsx("span", { kind: "brace" }, [txt(" {")])];
717
+ if (preview) children.push(jsx("span", { kind: "preview-text" }, [txt(preview)]));
718
+ children.push(jsx("span", { kind: "brace" }, [txt("}")]));
719
+ return jsx("span", {}, children);
720
+ },
721
+ node({ value, keyPath, createNode }) {
722
+ const entriesChildren = Array.from(value.entries()).map(([key, value$1], index) => {
723
+ const keyStr = String(key);
724
+ const keyNode = createNode([
725
+ ENTRIES_KEY,
726
+ keyStr,
727
+ "key"
728
+ ], key);
729
+ const valueNode = createNode([
730
+ ENTRIES_KEY,
731
+ keyStr,
732
+ "value"
733
+ ], value$1);
734
+ return {
735
+ keyPath: [
736
+ ...keyPath,
737
+ ENTRIES_KEY,
738
+ index
739
+ ],
740
+ value: { [keyStr]: value$1 },
741
+ type: "object",
742
+ children: [keyNode, valueNode]
743
+ };
744
+ });
745
+ return {
746
+ value,
747
+ keyPath,
748
+ type: "map",
749
+ children: [{
750
+ keyPath: [...keyPath, ENTRIES_KEY],
751
+ value: Array.from(value.entries()),
752
+ type: "array",
753
+ children: entriesChildren,
754
+ isNonEnumerable: true
755
+ }, createNode(["size"], value.size)]
756
+ };
757
+ }
758
+ });
759
+ const ERROR_KEYS = [
760
+ "name",
761
+ "message",
762
+ "stack"
763
+ ];
764
+ const ErrorType = dataType({
765
+ type: "error",
766
+ description(node) {
767
+ const err = node.value;
768
+ return `${err.name}: ${err.message}`;
769
+ },
770
+ check(value) {
771
+ return value instanceof Error;
772
+ },
773
+ previewElement(node) {
774
+ const err = node.value;
775
+ return jsx("span", {}, [
776
+ jsx("span", { kind: "constructor" }, [txt(err.name)]),
777
+ jsx("span", { kind: "colon" }, [txt(": ")]),
778
+ jsx("span", {}, [txt(err.message)])
779
+ ]);
780
+ },
781
+ node({ value, keyPath, createNode }) {
782
+ const errorProperties = ERROR_KEYS.map((key) => ({
783
+ key,
784
+ value: Reflect.get(value, key)
785
+ }));
786
+ const additionalProps = Object.getOwnPropertyNames(value).filter((key) => !ERROR_KEYS.includes(key)).map((key) => ({
787
+ key,
788
+ value: getProp(value, key)
789
+ }));
790
+ return {
791
+ value,
792
+ keyPath,
793
+ type: "error",
794
+ children: [...errorProperties, ...additionalProps].map(({ key, value: value$1 }) => createNode([key], value$1))
795
+ };
796
+ }
797
+ });
798
+ function errorStackToElement(stack) {
799
+ const stackLines = stack?.split("\n").filter((line) => line.trim()) || [];
800
+ return jsx("span", {}, stackLines.map((line, index) => {
801
+ const appendNewLine = index < stackLines.length - 1;
802
+ return jsx("span", {
803
+ nodeType: "string",
804
+ kind: "error-stack"
805
+ }, [jsx("span", {}, [txt(line + (appendNewLine ? "\\n" : ""))]), jsx("span", { kind: "operator" }, [txt(appendNewLine ? " +" : "")])]);
806
+ }));
807
+ }
808
+ const HeadersType = dataType({
809
+ type: "headers",
810
+ description: "Headers",
811
+ check(value) {
812
+ return typeOf(value) === "[object Headers]";
813
+ },
814
+ previewElement(node) {
815
+ const headers = node.value;
816
+ const entriesArray = Array.from(headers.entries());
817
+ const preview = entriesArray.slice(0, 2).map(([key, value]) => `${key}: ${value}`).join(", ");
818
+ const hasMore = entriesArray.length > 2;
819
+ return jsx("span", {}, [
820
+ jsx("span", { kind: "constructor" }, [txt(`Headers(${entriesArray.length})`)]),
821
+ jsx("span", { kind: "brace" }, [txt(" {")]),
822
+ jsx("span", { kind: "preview-text" }, [txt(` ${preview}${hasMore ? ", …" : ""} `)]),
823
+ jsx("span", { kind: "brace" }, [txt("}")])
824
+ ]);
825
+ },
826
+ node({ value, keyPath, createNode }) {
827
+ const entriesChildren = Array.from(value.entries()).map(([key, value$1], index) => {
828
+ const keyStr = String(key);
829
+ const keyNode = createNode([
830
+ ENTRIES_KEY,
831
+ keyStr,
832
+ "key"
833
+ ], key);
834
+ const valueNode = createNode([
835
+ ENTRIES_KEY,
836
+ keyStr,
837
+ "value"
838
+ ], value$1);
839
+ return {
840
+ keyPath: [
841
+ ...keyPath,
842
+ ENTRIES_KEY,
843
+ index
844
+ ],
845
+ value: { [key]: value$1 },
846
+ type: "object",
847
+ children: [keyNode, valueNode]
848
+ };
849
+ });
850
+ return {
851
+ value,
852
+ keyPath,
853
+ type: "headers",
854
+ children: [{
855
+ keyPath: [...keyPath, ENTRIES_KEY],
856
+ value: Array.from(value.entries()),
857
+ type: "array",
858
+ children: entriesChildren,
859
+ isNonEnumerable: true
860
+ }]
861
+ };
862
+ }
863
+ });
864
+ const FormDataType = dataType({
865
+ type: "formdata",
866
+ description: "FormData",
867
+ check(value) {
868
+ return typeOf(value) === "[object FormData]";
869
+ },
870
+ previewElement(node) {
871
+ const formData = node.value;
872
+ const entriesArray = Array.from(formData.entries());
873
+ const preview = entriesArray.slice(0, 2).map(([key, value]) => {
874
+ return `${key}: ${FileType.check(value) ? `File(${value.size})` : String(value)}`;
875
+ }).join(", ");
876
+ const hasMore = entriesArray.length > 2;
877
+ return jsx("span", {}, [
878
+ jsx("span", { kind: "constructor" }, [txt(`FormData(${entriesArray.length})`)]),
879
+ jsx("span", { kind: "brace" }, [txt(" {")]),
880
+ jsx("span", { kind: "preview-text" }, [txt(` ${preview}${hasMore ? ", …" : ""} `)]),
881
+ jsx("span", { kind: "brace" }, [txt("}")])
882
+ ]);
883
+ },
884
+ node({ value, keyPath, createNode }) {
885
+ const entriesChildren = Array.from(value.entries()).map(([key, value$1], index) => {
886
+ const keyNode = createNode([
887
+ ENTRIES_KEY,
888
+ index,
889
+ "key"
890
+ ], key);
891
+ const valueNode = createNode([
892
+ ENTRIES_KEY,
893
+ index,
894
+ "value"
895
+ ], value$1);
896
+ return {
897
+ keyPath: [
898
+ ...keyPath,
899
+ ENTRIES_KEY,
900
+ index
901
+ ],
902
+ value: { [key]: value$1 },
903
+ type: "object",
904
+ children: [keyNode, valueNode]
905
+ };
906
+ });
907
+ return {
908
+ value,
909
+ keyPath,
910
+ type: "formdata",
911
+ children: [{
912
+ keyPath: [...keyPath, ENTRIES_KEY],
913
+ value: Array.from(value.entries()),
914
+ type: "array",
915
+ children: entriesChildren,
916
+ isNonEnumerable: true
917
+ }]
918
+ };
919
+ }
920
+ });
921
+ const ArrayType = dataType({
922
+ type: "array",
923
+ description(node) {
924
+ return `Array(${node.value.length})`;
925
+ },
926
+ check(value) {
927
+ return Array.isArray(value);
928
+ },
929
+ previewText(node, opts) {
930
+ const maxItems = opts.maxPreviewItems;
931
+ const enumerableChildren = (node.children || []).filter((child) => !child.isNonEnumerable && keyPathToKey(child.keyPath) !== "length");
932
+ return generatePreviewText(enumerableChildren.slice(0, maxItems).map(formatValueMini), enumerableChildren.length > maxItems);
933
+ },
934
+ previewElement(node, opts) {
935
+ const preview = this.previewText?.(node, opts) || "";
936
+ const count = node.value.length;
937
+ const children = [];
938
+ if (count > 0) children.push(jsx("span", { kind: "constructor" }, [txt(`(${count}) `)]));
939
+ children.push(jsx("span", { kind: "brace" }, [txt("[")]));
940
+ if (preview) children.push(jsx("span", { kind: "preview-text" }, [txt(preview)]));
941
+ children.push(jsx("span", { kind: "brace" }, [txt("]")]));
942
+ return jsx("span", {}, children);
943
+ },
944
+ node({ value, keyPath, createNode, options }) {
945
+ const arrayChildren = [];
946
+ const definedIndices = Object.keys(value).filter((key) => !Number.isNaN(Number(key))).map(Number).sort((a, b) => a - b);
947
+ const chunkSize = options?.groupArraysAfterLength;
948
+ if (chunkSize && definedIndices.length > chunkSize) {
949
+ const chunks = [];
950
+ for (let i = 0; i < definedIndices.length; i += chunkSize) chunks.push(definedIndices.slice(i, i + chunkSize));
951
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
952
+ const chunk = chunks[chunkIndex];
953
+ const groupKey = `[${chunk[0]}…${chunk[chunk.length - 1]}]`;
954
+ const groupChildren = chunk.map((index) => createNode([index.toString()], value[index]));
955
+ const groupNode = {
956
+ keyPath: [...keyPath, groupKey],
957
+ value: chunk.map((index) => value[index]),
958
+ type: "array",
959
+ children: groupChildren,
960
+ isNonEnumerable: false
961
+ };
962
+ arrayChildren.push(groupNode);
963
+ }
964
+ } else for (const index of definedIndices) arrayChildren.push(createNode([index.toString()], value[index]));
965
+ const lengthChild = createNode(["length"], value.length);
966
+ const propertyNames = Object.getOwnPropertyNames(value);
967
+ const enumerableKeys = Object.keys(value).filter((key) => !Number.isNaN(Number(key)));
968
+ const nonEnumerableKeys = propertyNames.filter((key) => !enumerableKeys.includes(key) && key !== "length" && Number.isNaN(Number(key)));
969
+ const nonEnumerableChildren = options?.showNonenumerable ? nonEnumerableKeys.map((key) => {
970
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
971
+ const node = createNode([key], Reflect.get(value, key));
972
+ node.isNonEnumerable = true;
973
+ node.propertyDescriptor = descriptor;
974
+ return node;
975
+ }) : [];
976
+ return {
977
+ value,
978
+ type: "array",
979
+ children: [
980
+ ...arrayChildren,
981
+ lengthChild,
982
+ ...nonEnumerableChildren
983
+ ],
984
+ keyPath
985
+ };
986
+ }
987
+ });
988
+ const typedArrayConstructors = {
989
+ Int8Array: "int8array",
990
+ Uint8Array: "uint8array",
991
+ Uint8ClampedArray: "uint8clampedarray",
992
+ Int16Array: "int16array",
993
+ Uint16Array: "uint16array",
994
+ Int32Array: "int32array",
995
+ Uint32Array: "uint32array",
996
+ Float32Array: "float32array",
997
+ Float64Array: "float64array",
998
+ BigInt64Array: "bigint64array",
999
+ BigUint64Array: "biguint64array"
1000
+ };
1001
+ const revertTypedArrayConstructors = Object.fromEntries(Object.entries(typedArrayConstructors).map(([key, value]) => [value, key]));
1002
+ const TYPED_ARRAY_KEYS = [
1003
+ "length",
1004
+ "byteLength",
1005
+ "byteOffset",
1006
+ "buffer"
1007
+ ];
1008
+ const TypedArrayType = dataType({
1009
+ type: (value) => Reflect.get(typedArrayConstructors, value.constructor.name),
1010
+ description(node) {
1011
+ const typedArray = node.value;
1012
+ return `${revertTypedArrayConstructors[typedArray.constructor.name]}(${typedArray.length})`;
1013
+ },
1014
+ check(value) {
1015
+ return isObj(value) && value.constructor.name in typedArrayConstructors;
1016
+ },
1017
+ previewElement(node) {
1018
+ const typedArray = node.value;
1019
+ const constructorName = typedArray.constructor.name;
1020
+ const preview = Array.from(typedArray).slice(0, 5).join(", ");
1021
+ const hasMore = typedArray.length > 5;
1022
+ return jsx("span", {}, [
1023
+ jsx("span", { kind: "constructor" }, [txt(`${constructorName}(${typedArray.length})`)]),
1024
+ jsx("span", { kind: "brace" }, [txt(" [ ")]),
1025
+ jsx("span", { kind: "preview-text" }, [txt(preview + (hasMore ? ", …" : ""))]),
1026
+ jsx("span", { kind: "brace" }, [txt(" ]")])
1027
+ ]);
1028
+ },
1029
+ node({ value, keyPath, createNode, options }) {
1030
+ const typedArray = value;
1031
+ const enumerableChildren = TYPED_ARRAY_KEYS.map((key) => ({
1032
+ key,
1033
+ value: Reflect.get(typedArray, key)
1034
+ })).map(({ key, value: value$1 }) => createNode([key], value$1));
1035
+ const nonEnumerableChildren = options?.showNonenumerable ? (() => {
1036
+ const node = createNode(["[[Values]]"], Array.from(typedArray).slice(0, 100));
1037
+ node.isNonEnumerable = true;
1038
+ return [node];
1039
+ })() : [];
1040
+ const children = [...enumerableChildren, ...nonEnumerableChildren];
1041
+ return {
1042
+ value,
1043
+ keyPath,
1044
+ type: Reflect.get(typedArrayConstructors, value.constructor.name),
1045
+ children
1046
+ };
1047
+ }
1048
+ });
1049
+ const IterableType = dataType({
1050
+ type: "iterable",
1051
+ description: "Iterable",
1052
+ check(value) {
1053
+ return Boolean(value && typeof value === "object" && typeof value[Symbol.iterator] === "function" && !(value instanceof Set) && !(value instanceof Map) && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && !(value instanceof ArrayBuffer));
1054
+ },
1055
+ previewElement(node, opts) {
1056
+ const preview = SetType.previewText?.(node, opts) ?? "";
1057
+ const entriesArray = Array.from(node.value);
1058
+ const children = [jsx("span", { kind: "constructor" }, [txt(`Iterable(${node.value.size ?? node.value.length ?? entriesArray.length})`)]), jsx("span", { kind: "brace" }, [txt(" {")])];
1059
+ if (preview) children.push(jsx("span", { kind: "preview-text" }, [txt(preview)]));
1060
+ children.push(jsx("span", { kind: "brace" }, [txt("}")]));
1061
+ return jsx("span", {}, children);
1062
+ },
1063
+ node({ value, keyPath, createNode }) {
1064
+ const entriesArray = Array.from(value);
1065
+ const entriesChildren = entriesArray.map((item, index) => createNode([ENTRIES_KEY, index], item));
1066
+ return {
1067
+ value,
1068
+ type: "iterable",
1069
+ children: [{
1070
+ keyPath: [...keyPath, ENTRIES_KEY],
1071
+ value: entriesArray,
1072
+ type: "array",
1073
+ children: entriesChildren,
1074
+ isNonEnumerable: true
1075
+ }, createNode(["size"], value.size ?? value.length ?? entriesArray.length)],
1076
+ keyPath
1077
+ };
1078
+ }
1079
+ });
1080
+ const ClassType = dataType({
1081
+ type: "object",
1082
+ description(node) {
1083
+ return node.constructorName || "Object";
1084
+ },
1085
+ check(value) {
1086
+ return typeof value === "object" && value !== null && value.constructor !== Object;
1087
+ },
1088
+ previewText(node, opts) {
1089
+ return ObjectType.previewText?.(node, opts) || "";
1090
+ },
1091
+ previewElement(node, opts) {
1092
+ return ObjectType.previewElement(node, opts);
1093
+ },
1094
+ node({ value, keyPath, createNode, options }) {
1095
+ const constructorName = value.constructor.name;
1096
+ const allPropertyNames = Object.getOwnPropertyNames(value);
1097
+ const enumerableKeys = Object.keys(value);
1098
+ const nonEnumerableKeys = allPropertyNames.filter((key) => !enumerableKeys.includes(key));
1099
+ const enumerableChildren = enumerableKeys.map((key) => createNode([key], Reflect.get(value, key)));
1100
+ const nonEnumerableChildren = options?.showNonenumerable ? nonEnumerableKeys.map((key) => {
1101
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
1102
+ const node = createNode([`[[${key}]]`], getProp(value, key));
1103
+ node.isNonEnumerable = true;
1104
+ node.propertyDescriptor = descriptor;
1105
+ return node;
1106
+ }) : [];
1107
+ return {
1108
+ value,
1109
+ keyPath,
1110
+ type: "object",
1111
+ constructorName,
1112
+ children: [...enumerableChildren, ...nonEnumerableChildren]
1113
+ };
1114
+ }
1115
+ });
1116
+ const ObjectType = dataType({
1117
+ type: "object",
1118
+ description: "Object",
1119
+ check(value) {
1120
+ return typeof value === "object" && value !== null;
1121
+ },
1122
+ previewText(node, opts) {
1123
+ const maxItems = opts.maxPreviewItems;
1124
+ const children = node.children || [];
1125
+ return generatePreviewText(children.slice(0, maxItems).map((child) => {
1126
+ const valueDesc = getNodeTypeDescription(child);
1127
+ return `${keyPathToKey(child.keyPath)}: ${valueDesc}`;
1128
+ }), children.length > maxItems);
1129
+ },
1130
+ previewElement(node, opts) {
1131
+ const preview = this.previewText?.(node, opts) ?? "";
1132
+ const children = [];
1133
+ if (node.constructorName) children.push(jsx("span", { kind: "constructor" }, [txt(`${node.constructorName} `)]));
1134
+ children.push(jsx("span", { kind: "brace" }, [txt("{")]));
1135
+ if (preview) children.push(jsx("span", { kind: "preview-text" }, [txt(preview)]));
1136
+ children.push(jsx("span", { kind: "brace" }, [txt("}")]));
1137
+ return jsx("span", {}, children);
1138
+ },
1139
+ node({ value, keyPath, createNode, options }) {
1140
+ const allPropertyNames = Object.getOwnPropertyNames(value);
1141
+ const enumerableKeys = Object.keys(value);
1142
+ const nonEnumerableKeys = allPropertyNames.filter((key) => !enumerableKeys.includes(key));
1143
+ const enumerableChildren = enumerableKeys.map((key) => createNode([key], getProp(value, key)));
1144
+ const nonEnumerableChildren = options?.showNonenumerable ? nonEnumerableKeys.map((key) => {
1145
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
1146
+ const node = createNode([`[[${key}]]`], getProp(value, key));
1147
+ node.isNonEnumerable = true;
1148
+ node.propertyDescriptor = descriptor;
1149
+ return node;
1150
+ }) : [];
1151
+ return {
1152
+ value,
1153
+ type: "object",
1154
+ children: [...enumerableChildren, ...nonEnumerableChildren],
1155
+ keyPath
1156
+ };
1157
+ }
1158
+ });
1159
+ const ELEMENT_KEYS = [
1160
+ "attributes",
1161
+ "childElementCount",
1162
+ "className",
1163
+ "dataset",
1164
+ "hidden",
1165
+ "id",
1166
+ "inert",
1167
+ "isConnected",
1168
+ "isContentEditable",
1169
+ "nodeType",
1170
+ "style",
1171
+ "tabIndex",
1172
+ "tagName"
1173
+ ];
1174
+ const isSvg = (el) => typeof el === "object" && el.tagName === "svg" && el.namespaceURI === "http://www.w3.org/2000/svg";
1175
+ const isHTML = (el) => typeof el === "object" && el.namespaceURI === "http://www.w3.org/1999/xhtml";
1176
+ const ElementType = dataType({
1177
+ type: "element",
1178
+ description(node) {
1179
+ return typeOf(node.value);
1180
+ },
1181
+ check(value) {
1182
+ return isSvg(value) || isHTML(value);
1183
+ },
1184
+ previewElement(node) {
1185
+ const el = node.value;
1186
+ const classList = Array.from(el.classList).slice(0, 3);
1187
+ return jsx("span", {}, [
1188
+ jsx("span", { kind: "constructor" }, [txt(el.constructor.name)]),
1189
+ jsx("span", {}, [txt(" ")]),
1190
+ jsx("span", { kind: "preview-text" }, [txt(`<${el.localName}${el.id ? `#${el.id}` : ""}${classList.length > 0 ? "." + classList.join(".") : ""}>`)])
1191
+ ]);
1192
+ },
1193
+ node({ value, keyPath, createNode }) {
1194
+ return {
1195
+ value,
1196
+ keyPath,
1197
+ type: "element",
1198
+ children: ELEMENT_KEYS.reduce((acc, key) => {
1199
+ let childValue = Reflect.get(value, key);
1200
+ if (key === "attributes") {
1201
+ const attrs = Array.from(value.attributes);
1202
+ childValue = attrs.length ? Object.fromEntries(attrs.map((attr) => [attr.name, attr.value])) : void 0;
1203
+ }
1204
+ if (key === "style") {
1205
+ const style = Array.from(value.style);
1206
+ childValue = style.length ? Object.fromEntries(style.map((key$1) => [key$1, value.style.getPropertyValue(key$1)])) : void 0;
1207
+ }
1208
+ acc.push(createNode([key], childValue));
1209
+ return acc;
1210
+ }, [])
1211
+ };
1212
+ }
1213
+ });
1214
+ const DOCUMENT_KEYS = [
1215
+ "title",
1216
+ "URL",
1217
+ "documentElement",
1218
+ "head",
1219
+ "body",
1220
+ "contentType",
1221
+ "readyState"
1222
+ ];
1223
+ const DocumentType = dataType({
1224
+ type: "document",
1225
+ description: "Document",
1226
+ check(value) {
1227
+ return typeOf(value) === "[object HTMLDocument]";
1228
+ },
1229
+ previewElement(node) {
1230
+ const url = node.value.URL || "unknown";
1231
+ return jsx("span", {}, [jsx("span", { kind: "constructor" }, [txt("#document")]), jsx("span", { kind: "preview-text" }, [txt(` (${url})`)])]);
1232
+ },
1233
+ node({ value, keyPath, createNode }) {
1234
+ return {
1235
+ value,
1236
+ keyPath,
1237
+ type: "document",
1238
+ children: DOCUMENT_KEYS.map((key) => createNode([key], Reflect.get(value, key)))
1239
+ };
1240
+ }
1241
+ });
1242
+ const WINDOW_KEYS = [
1243
+ "location",
1244
+ "navigator",
1245
+ "document",
1246
+ "innerWidth",
1247
+ "innerHeight",
1248
+ "devicePixelRatio",
1249
+ "origin"
1250
+ ];
1251
+ const WindowType = dataType({
1252
+ type: "window",
1253
+ description: "Window",
1254
+ check(value) {
1255
+ return typeOf(value) === "[object Window]";
1256
+ },
1257
+ previewElement() {
1258
+ return jsx("span", {}, [jsx("span", { kind: "constructor" }, [txt("Window")]), jsx("span", { kind: "preview-text" }, [txt(" { … }")])]);
1259
+ },
1260
+ node({ value, keyPath, createNode }) {
1261
+ return {
1262
+ value,
1263
+ keyPath,
1264
+ type: "window",
1265
+ children: WINDOW_KEYS.map((key) => {
1266
+ const childValue = Reflect.get(value, key);
1267
+ return createNode([key], childValue);
1268
+ })
1269
+ };
1270
+ }
1271
+ });
1272
+ const REACT_ELEMENT_KEYS = [
1273
+ "$$typeof",
1274
+ "type",
1275
+ "key",
1276
+ "ref",
1277
+ "props"
1278
+ ];
1279
+ const getElementTypeName = (type) => {
1280
+ if (typeof type === "string") return type;
1281
+ if (typeof type === "function") return type.displayName || type.name || "Component";
1282
+ return type?.toString() || "Component";
1283
+ };
1284
+ const ReactElementType = dataType({
1285
+ type: "react-element",
1286
+ description(node) {
1287
+ const el = node.value;
1288
+ return getElementTypeName(el.type);
1289
+ },
1290
+ check(value) {
1291
+ return isObj(value) && "$$typeof" in value && "props" in value;
1292
+ },
1293
+ previewElement(node, opts) {
1294
+ const el = node.value;
1295
+ const elName = getElementTypeName(el.type);
1296
+ const props = Object.entries(el.props);
1297
+ const hasMore = props.length > opts.maxPreviewItems;
1298
+ return jsx("span", {}, [
1299
+ txt(`<${elName} `),
1300
+ ...props.slice(0, opts.maxPreviewItems).reduce((acc, [key, value]) => {
1301
+ if (key === "children") return acc;
1302
+ acc.push(jsx("span", {}, [txt(` ${key}=${typeof value === "string" ? `"${value}"` : `{${value}}`}`)]));
1303
+ return acc;
1304
+ }, []),
1305
+ ...hasMore ? [txt(" …")] : [],
1306
+ txt(el.children ? `> {…} </${elName}>` : ` />`)
1307
+ ]);
1308
+ },
1309
+ node({ value, keyPath, createNode }) {
1310
+ return {
1311
+ value,
1312
+ type: "react-element",
1313
+ keyPath,
1314
+ children: REACT_ELEMENT_KEYS.reduce((acc, key) => {
1315
+ let childValue = Reflect.get(value, key);
1316
+ if (key === "type") childValue = getElementTypeName(childValue);
1317
+ acc.push(createNode([key], childValue));
1318
+ return acc;
1319
+ }, [])
1320
+ };
1321
+ }
1322
+ });
1323
+ const map = {
1324
+ "\n": "\\n",
1325
+ " ": "\\t",
1326
+ "\r": "\\r"
1327
+ };
1328
+ const STRING_ESCAPE_REGEXP = /[\n\t\r]/g;
1329
+ const StringType = dataType({
1330
+ type: "string",
1331
+ description(node, opts) {
1332
+ return `"${this.previewText?.(node, opts) ?? node.value}"`;
1333
+ },
1334
+ check(value) {
1335
+ return typeof value === "string";
1336
+ },
1337
+ previewText(node, opts) {
1338
+ const serialised = node.value.replace(STRING_ESCAPE_REGEXP, (_) => map[_]);
1339
+ return serialised.slice(0, opts.collapseStringsAfterLength) + (serialised.length > opts.collapseStringsAfterLength ? "…" : "");
1340
+ },
1341
+ previewElement(node) {
1342
+ return jsx("span", {}, [txt(`"${node.value.replace(STRING_ESCAPE_REGEXP, (_) => map[_])}"`)]);
1343
+ },
1344
+ node({ value, keyPath }) {
1345
+ return {
1346
+ value,
1347
+ type: "string",
1348
+ keyPath
1349
+ };
1350
+ }
1351
+ });
1352
+ const PrimitiveType = dataType({
1353
+ type(value) {
1354
+ return typeof value;
1355
+ },
1356
+ description(node) {
1357
+ return String(node.value);
1358
+ },
1359
+ check(value) {
1360
+ return value !== null && value !== void 0;
1361
+ },
1362
+ previewElement(node) {
1363
+ return jsx("span", {}, [txt(String(node.value))]);
1364
+ },
1365
+ node({ value, keyPath }) {
1366
+ return {
1367
+ value,
1368
+ type: typeof value,
1369
+ keyPath
1370
+ };
1371
+ }
1372
+ });
1373
+ const dataTypes = [
1374
+ NullType,
1375
+ UndefinedType,
1376
+ SymbolType,
1377
+ BigIntType,
1378
+ FunctionType,
1379
+ ArrayBufferType,
1380
+ SharedArrayBufferType,
1381
+ BufferType,
1382
+ DataViewType,
1383
+ ErrorType,
1384
+ DateType,
1385
+ RegexType,
1386
+ SetType,
1387
+ MapType,
1388
+ WeakMapType,
1389
+ WeakSetType,
1390
+ FileType,
1391
+ BlobType,
1392
+ ReactElementType,
1393
+ WindowType,
1394
+ DocumentType,
1395
+ ElementType,
1396
+ UrlType,
1397
+ URLSearchParamsType,
1398
+ HeadersType,
1399
+ FormDataType,
1400
+ ArrayType,
1401
+ TypedArrayType,
1402
+ IterableType,
1403
+ ClassType,
1404
+ ObjectType,
1405
+ StringType,
1406
+ PrimitiveType
1407
+ ];
1408
+ const jsonNodeToElement = (node, opts) => {
1409
+ const options = getPreviewOptions(opts);
1410
+ const key = keyPathToKey(node.keyPath, { excludeRoot: true });
1411
+ if (key === "stack" && typeof node.value === "string") return errorStackToElement(node.value);
1412
+ const dataType$1 = dataTypes.find((dataType$2) => dataType$2.check(node.value));
1413
+ if (!dataType$1) return jsx("span", {}, [txt(String(node.value))]);
1414
+ const element = dataType$1.previewElement(node, options);
1415
+ if (!key) element.properties.root = true;
1416
+ element.properties.kind = "preview";
1417
+ element.properties.nodeType = typeof dataType$1.type === "function" ? dataType$1.type(node.value) : dataType$1.type;
1418
+ return element;
1419
+ };
1420
+ const getNodeTypeDescription = (node, opts) => {
1421
+ const options = getPreviewOptions(opts);
1422
+ const dataType$1 = dataTypes.find((dataType$2) => dataType$2.check(node.value));
1423
+ if (dataType$1) return typeof dataType$1.description === "function" ? dataType$1.description(node, options) : dataType$1.description;
1424
+ return String(node.value);
1425
+ };
1426
+
1427
+ //#endregion
1428
+ //#region src/shared/json-tree-utils/accessibility.ts
1429
+ const propertyWord = (count) => count === 1 ? "property" : "properties";
1430
+ const isPrimitive = (node) => {
1431
+ return node.type === "string" || node.type === "number" || node.type === "boolean";
1432
+ };
1433
+ const getAccessibleDescription = (node, opts) => {
1434
+ const typeDescription = getNodeTypeDescription(node, opts);
1435
+ const key = keyPathToKey(node.keyPath, { excludeRoot: true });
1436
+ const nonEnumerablePrefix = node.isNonEnumerable ? "non-enumerable " : "";
1437
+ const format = (text) => {
1438
+ return [key, `${nonEnumerablePrefix}${text}`].filter(Boolean).join(": ");
1439
+ };
1440
+ if (node.children && node.children.length > 0) {
1441
+ const childCount = node.children.length;
1442
+ if (key === "[[Entries]]") return format(`${childCount} ${propertyWord(childCount)}`);
1443
+ return format(`${typeDescription}, expandable with ${childCount} ${propertyWord(childCount)}`);
1444
+ }
1445
+ if (isPrimitive(node)) {
1446
+ if (key === "stack") return format(node.value.split("\n")[1]?.trim() || "trace");
1447
+ if (key === "[[Function]]") return format("function implementation");
1448
+ return format(`${typeof node.value === "string" ? `"${node.value}"` : String(node.value)}${node.isNonEnumerable && node.propertyDescriptor ? `, ${getDescriptorInfo(node.propertyDescriptor)}` : ""}`);
1449
+ }
1450
+ if (node.type === "null") return format("null");
1451
+ if (node.type === "undefined") return format("undefined");
1452
+ if (node.type === "circular") return format("circular reference");
1453
+ return format(`${nonEnumerablePrefix}${typeDescription}${node.isNonEnumerable && node.propertyDescriptor ? `, ${getDescriptorInfo(node.propertyDescriptor)}` : ""}`);
1454
+ };
1455
+ const getDescriptorInfo = (descriptor) => {
1456
+ const parts = [];
1457
+ if (!descriptor.writable) parts.push("read-only");
1458
+ if (!descriptor.configurable) parts.push("non-configurable");
1459
+ return parts.length > 0 ? parts.join(", ") : "non-enumerable";
1460
+ };
1461
+
1462
+ //#endregion
1463
+ export { ArrayBufferType, ArrayType, BigIntType, BlobType, BufferType, ClassType, DEFAULT_PREVIEW_OPTIONS, DataViewType, DateType, DocumentType, ElementType, ErrorType, FileType, FormDataType, FunctionType, HeadersType, IterableType, MapType, NullType, ObjectType, PATH_SEP, PrimitiveType, ROOT_KEY, ReactElementType, RegexType, SetType, SharedArrayBufferType, StringType, SymbolType, TypedArrayType, URLSearchParamsType, UndefinedType, UrlType, WeakMapType, WeakSetType, WindowType, dataTypes, getAccessibleDescription, getNodeTypeDescription, getPreviewOptions, getRootNode, isRootKeyPath, jsonNodeToElement, jsonPathToValue, jsonToTree, keyPathToId, keyPathToKey, nodeToString, nodeToValue };