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