storybook 10.1.0-alpha.8 → 10.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
  2. package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
  3. package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
  4. package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
  5. package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
  6. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  7. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  8. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  9. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  10. package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
  11. package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
  12. package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
  13. package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
  14. package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  15. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  16. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  17. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  18. package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
  19. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
  20. package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
  21. package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
  22. package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
  23. package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
  24. package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
  25. package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
  26. package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
  27. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  28. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  29. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  30. package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
  31. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  32. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  33. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
  34. package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
  35. package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
  36. package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
  37. package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
  38. package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-57OYTFQ5.js → builder-manager-BDAQHXFI.js} +510 -1019
  40. package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
  41. package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
  42. package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
  43. package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
  44. package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
  45. package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
  46. package/dist/_node-chunks/{chunk-2GK7NW46.js → chunk-BG4RDXG7.js} +8 -10
  47. package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
  48. package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
  49. package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
  50. package/dist/_node-chunks/{chunk-RG4Z25PY.js → chunk-D6ND3TVY.js} +116 -276
  51. package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
  52. package/dist/_node-chunks/{chunk-EBYCXVVR.js → chunk-EVK2SBW5.js} +292 -688
  53. package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
  54. package/dist/_node-chunks/{chunk-6F6CCOXH.js → chunk-KVRF22SH.js} +469 -983
  55. package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
  56. package/dist/_node-chunks/{chunk-C4KEDJ6O.js → chunk-MMVV6DGG.js} +8133 -8887
  57. package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
  58. package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
  59. package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
  60. package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
  61. package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
  62. package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
  63. package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
  64. package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
  65. package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
  66. package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
  67. package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
  68. package/dist/_node-chunks/{chunk-RSHLCHYY.js → chunk-YWV55YW3.js} +15 -24
  69. package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
  70. package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
  71. package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
  72. package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
  73. package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
  74. package/dist/actions/decorator.js +21 -42
  75. package/dist/actions/index.js +3 -3
  76. package/dist/babel/index.d.ts +671 -335
  77. package/dist/babel/index.js +10 -11
  78. package/dist/bin/core.js +601 -1548
  79. package/dist/bin/dispatcher.js +36 -36
  80. package/dist/bin/loader.js +24 -38
  81. package/dist/channels/index.js +98 -234
  82. package/dist/cli/index.d.ts +1479 -133
  83. package/dist/cli/index.js +30 -8540
  84. package/dist/client-logger/index.js +31 -61
  85. package/dist/common/index.d.ts +139 -62
  86. package/dist/common/index.js +66 -51
  87. package/dist/components/index.d.ts +575 -273
  88. package/dist/components/index.js +14863 -4313
  89. package/dist/core-events/index.js +2 -66
  90. package/dist/core-server/index.d.ts +3 -2
  91. package/dist/core-server/index.js +2910 -8519
  92. package/dist/core-server/presets/common-manager.css +2 -2
  93. package/dist/core-server/presets/common-manager.js +2521 -5233
  94. package/dist/core-server/presets/common-override-preset.js +31 -60
  95. package/dist/core-server/presets/common-preset.js +663 -962
  96. package/dist/csf/index.js +534 -1179
  97. package/dist/csf-tools/index.js +9 -9
  98. package/dist/docs-tools/index.js +6 -6
  99. package/dist/highlight/index.js +2 -2
  100. package/dist/instrumenter/index.js +199 -415
  101. package/dist/manager/globals-runtime.js +59044 -67141
  102. package/dist/manager/globals.js +2 -3
  103. package/dist/manager/manager-stores.d.ts +1 -0
  104. package/dist/manager/manager-stores.js +23 -0
  105. package/dist/manager/runtime.js +11511 -10953
  106. package/dist/manager-api/index.d.ts +1811 -2
  107. package/dist/manager-api/index.js +1348 -2401
  108. package/dist/manager-errors.d.ts +9 -0
  109. package/dist/manager-errors.js +3 -3
  110. package/dist/mocking-utils/index.d.ts +1126 -0
  111. package/dist/mocking-utils/index.js +1181 -0
  112. package/dist/node-logger/index.d.ts +192 -24
  113. package/dist/node-logger/index.js +23 -4471
  114. package/dist/preview/globals.js +2 -3
  115. package/dist/preview/runtime.js +10799 -22393
  116. package/dist/preview-api/index.d.ts +1 -1
  117. package/dist/preview-api/index.js +13 -13
  118. package/dist/preview-errors.d.ts +9 -0
  119. package/dist/preview-errors.js +4 -4
  120. package/dist/router/index.js +347 -899
  121. package/dist/server-errors.d.ts +34 -1
  122. package/dist/server-errors.js +17 -10
  123. package/dist/telemetry/index.d.ts +24 -3
  124. package/dist/telemetry/index.js +25 -24
  125. package/dist/test/index.js +6131 -11916
  126. package/dist/theming/create.d.ts +1 -0
  127. package/dist/theming/create.js +4 -4
  128. package/dist/theming/index.d.ts +3366 -2599
  129. package/dist/theming/index.js +501 -1091
  130. package/dist/types/index.d.ts +72 -8
  131. package/dist/types/index.js +27 -12
  132. package/dist/viewport/index.js +3 -3
  133. package/package.json +26 -17
  134. package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
  135. package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
  136. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  137. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  138. package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
  139. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  140. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  141. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  142. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  143. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  144. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  145. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  146. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  147. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  148. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  149. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  150. package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
  151. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  152. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  153. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  154. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  155. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  156. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  157. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  158. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  159. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  160. package/dist/_node-chunks/camelcase-2KEDZHZ2.js +0 -18
  161. package/dist/_node-chunks/chunk-34NNXTBR.js +0 -28
  162. package/dist/_node-chunks/chunk-3N2A3KZX.js +0 -420
  163. package/dist/_node-chunks/chunk-5P7P5KDN.js +0 -90
  164. package/dist/_node-chunks/chunk-5WBRBDXI.js +0 -79
  165. package/dist/_node-chunks/chunk-7PWTU7T2.js +0 -697
  166. package/dist/_node-chunks/chunk-CHRHQ7AZ.js +0 -4272
  167. package/dist/_node-chunks/chunk-D4EGQLJI.js +0 -64656
  168. package/dist/_node-chunks/chunk-EKCURTKU.js +0 -1544
  169. package/dist/_node-chunks/chunk-GBVPPW4H.js +0 -1657
  170. package/dist/_node-chunks/chunk-J6VOKT2F.js +0 -220
  171. package/dist/_node-chunks/chunk-JLBYSGXS.js +0 -69
  172. package/dist/_node-chunks/chunk-LLCELSUL.js +0 -1198
  173. package/dist/_node-chunks/chunk-NS4OCQ4F.js +0 -61
  174. package/dist/_node-chunks/chunk-NXVLFYDR.js +0 -1518
  175. package/dist/_node-chunks/chunk-NZPWAJOZ.js +0 -304
  176. package/dist/_node-chunks/chunk-OYFSIV3I.js +0 -6712
  177. package/dist/_node-chunks/chunk-OZ43LMDF.js +0 -5029
  178. package/dist/_node-chunks/chunk-Q5HJHFF2.js +0 -61
  179. package/dist/_node-chunks/chunk-QHER4CEN.js +0 -34
  180. package/dist/_node-chunks/chunk-RF2PJM54.js +0 -1531
  181. package/dist/_node-chunks/chunk-S3OHGEE3.js +0 -101
  182. package/dist/_node-chunks/chunk-S5XOMVSV.js +0 -2256
  183. package/dist/_node-chunks/chunk-SGXQZ47H.js +0 -1586
  184. package/dist/_node-chunks/chunk-TDU6OVUH.js +0 -111
  185. package/dist/_node-chunks/chunk-TYQQFNQX.js +0 -1250
  186. package/dist/_node-chunks/chunk-WNGLARN2.js +0 -4741
  187. package/dist/_node-chunks/chunk-YUOVDCXL.js +0 -18
  188. package/dist/_node-chunks/dist-O5FB7YUW.js +0 -175
  189. package/dist/_node-chunks/globby-3NMV7WHX.js +0 -5222
  190. package/dist/_node-chunks/lib-VZD7BRSA.js +0 -518
  191. package/dist/_node-chunks/mdx-N42X6CFJ-3RP7RKKU.js +0 -22017
  192. package/dist/_node-chunks/p-limit-LIKBTXEJ.js +0 -168
  193. package/dist/_node-chunks/plugin-2NYZBK4A.js +0 -129
  194. package/dist/_node-chunks/plugin-6QGMO7J7.js +0 -159
  195. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-Z2JI6J2H.js +0 -69102
  196. package/dist/_node-chunks/webpack-mock-plugin-D4BE2SSI.js +0 -124
  197. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
  198. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
package/dist/csf/index.js CHANGED
@@ -3,31 +3,31 @@ import {
3
3
  PARAM_KEY as PARAM_KEY2,
4
4
  PARAM_KEY2 as PARAM_KEY3,
5
5
  PARAM_KEY3 as PARAM_KEY4
6
- } from "../_browser-chunks/chunk-CADGRH3P.js";
6
+ } from "../_browser-chunks/chunk-FNXWN6IK.js";
7
7
  import {
8
8
  composeConfigs,
9
9
  composeStory,
10
10
  mountDestructured,
11
11
  normalizeArrays,
12
12
  normalizeProjectAnnotations
13
- } from "../_browser-chunks/chunk-RW5PKMWM.js";
14
- import "../_browser-chunks/chunk-LYCSRYYR.js";
15
- import "../_browser-chunks/chunk-Y3M7TW6K.js";
13
+ } from "../_browser-chunks/chunk-SS2NHR7W.js";
14
+ import "../_browser-chunks/chunk-IPA5A322.js";
15
+ import "../_browser-chunks/chunk-3OXGAGBE.js";
16
16
  import {
17
17
  combineParameters
18
- } from "../_browser-chunks/chunk-B4A3ADP3.js";
19
- import "../_browser-chunks/chunk-ZNRFDIVA.js";
18
+ } from "../_browser-chunks/chunk-VYJQ7RU5.js";
19
+ import "../_browser-chunks/chunk-3IAH5M2U.js";
20
+ import "../_browser-chunks/chunk-QKODTO7K.js";
20
21
  import {
21
22
  invariant
22
- } from "../_browser-chunks/chunk-FUOHXXZT.js";
23
- import "../_browser-chunks/chunk-AB7OOPUX.js";
24
- import "../_browser-chunks/chunk-F4Q6SGTB.js";
25
- import "../_browser-chunks/chunk-UTNZYD2N.js";
26
- import "../_browser-chunks/chunk-FSBVR7H5.js";
27
- import "../_browser-chunks/chunk-NVV6MIOE.js";
23
+ } from "../_browser-chunks/chunk-AS2HQEYC.js";
24
+ import "../_browser-chunks/chunk-YKE5S47A.js";
25
+ import "../_browser-chunks/chunk-AIOS4NGK.js";
26
+ import "../_browser-chunks/chunk-GFLS4VP3.js";
27
+ import "../_browser-chunks/chunk-WJYERY3R.js";
28
28
  import {
29
29
  dedent
30
- } from "../_browser-chunks/chunk-OPCDBBL3.js";
30
+ } from "../_browser-chunks/chunk-JP7NCOJX.js";
31
31
  import {
32
32
  HIGHLIGHT,
33
33
  MAX_Z_INDEX,
@@ -35,39 +35,37 @@ import {
35
35
  REMOVE_HIGHLIGHT,
36
36
  RESET_HIGHLIGHT,
37
37
  SCROLL_INTO_VIEW
38
- } from "../_browser-chunks/chunk-GTKOCWCT.js";
38
+ } from "../_browser-chunks/chunk-KJHJLCBK.js";
39
39
  import "../_browser-chunks/chunk-ECQ75MKQ.js";
40
40
  import {
41
41
  action
42
- } from "../_browser-chunks/chunk-PB6FZ3WE.js";
43
- import "../_browser-chunks/chunk-XW6KSYKF.js";
42
+ } from "../_browser-chunks/chunk-EUVGDK4H.js";
43
+ import "../_browser-chunks/chunk-6XWLIJQL.js";
44
44
  import {
45
45
  PARAM_KEY
46
- } from "../_browser-chunks/chunk-HHW4FUMO.js";
46
+ } from "../_browser-chunks/chunk-SL75JR6Y.js";
47
47
  import {
48
48
  __commonJS,
49
49
  __export,
50
- __name,
51
50
  __toESM
52
- } from "../_browser-chunks/chunk-MM7DTO55.js";
51
+ } from "../_browser-chunks/chunk-A242L54C.js";
53
52
 
54
53
  // ../node_modules/@ngard/tiny-isequal/index.js
55
54
  var require_tiny_isequal = __commonJS({
56
55
  "../node_modules/@ngard/tiny-isequal/index.js"(exports) {
57
- Object.defineProperty(exports, "__esModule", { value: true }), exports.isEqual = /* @__PURE__ */ function() {
56
+ Object.defineProperty(exports, "__esModule", { value: !0 }), exports.isEqual = /* @__PURE__ */ (function() {
58
57
  var e = Object.prototype.toString, r = Object.getPrototypeOf, t = Object.getOwnPropertySymbols ? function(e2) {
59
58
  return Object.keys(e2).concat(Object.getOwnPropertySymbols(e2));
60
59
  } : Object.keys;
61
60
  return function(n, a) {
62
- return (/* @__PURE__ */ __name(function n2(a2, c, u) {
61
+ return (function n2(a2, c, u) {
63
62
  var i, s, l, o = e.call(a2), f = e.call(c);
64
- if (a2 === c) return true;
65
- if (null == a2 || null == c) return false;
66
- if (u.indexOf(a2) > -1 && u.indexOf(c) > -1) return true;
67
- if (u.push(a2, c), o != f) return false;
68
- if (i = t(a2), s = t(c), i.length != s.length || i.some(function(e2) {
63
+ if (a2 === c) return !0;
64
+ if (a2 == null || c == null) return !1;
65
+ if (u.indexOf(a2) > -1 && u.indexOf(c) > -1) return !0;
66
+ if (u.push(a2, c), o != f || (i = t(a2), s = t(c), i.length != s.length || i.some(function(e2) {
69
67
  return !n2(a2[e2], c[e2], u);
70
- })) return false;
68
+ }))) return !1;
71
69
  switch (o.slice(8, -1)) {
72
70
  case "Symbol":
73
71
  return a2.valueOf() == c.valueOf();
@@ -82,10 +80,10 @@ var require_tiny_isequal = __commonJS({
82
80
  case "Set":
83
81
  case "Map":
84
82
  i = a2.entries(), s = c.entries();
85
- do {
86
- if (!n2((l = i.next()).value, s.next().value, u)) return false;
87
- } while (!l.done);
88
- return true;
83
+ do
84
+ if (!n2((l = i.next()).value, s.next().value, u)) return !1;
85
+ while (!l.done);
86
+ return !0;
89
87
  case "ArrayBuffer":
90
88
  a2 = new Uint8Array(a2), c = new Uint8Array(c);
91
89
  case "DataView":
@@ -101,17 +99,17 @@ var require_tiny_isequal = __commonJS({
101
99
  case "Uint8ClampedArray":
102
100
  case "Arguments":
103
101
  case "Array":
104
- if (a2.length != c.length) return false;
105
- for (l = 0; l < a2.length; l++) if ((l in a2 || l in c) && (l in a2 != l in c || !n2(a2[l], c[l], u))) return false;
106
- return true;
102
+ if (a2.length != c.length) return !1;
103
+ for (l = 0; l < a2.length; l++) if ((l in a2 || l in c) && (l in a2 != l in c || !n2(a2[l], c[l], u))) return !1;
104
+ return !0;
107
105
  case "Object":
108
106
  return n2(r(a2), r(c), u);
109
107
  default:
110
- return false;
108
+ return !1;
111
109
  }
112
- }, "n"))(n, a, []);
110
+ })(n, a, []);
113
111
  };
114
- }();
112
+ })();
115
113
  }
116
114
  });
117
115
 
@@ -119,40 +117,30 @@ var require_tiny_isequal = __commonJS({
119
117
  function toStartCaseStr(str) {
120
118
  return str.replace(/_/g, " ").replace(/-/g, " ").replace(/\./g, " ").replace(/([^\n])([A-Z])([a-z])/g, (str2, $1, $2, $3) => `${$1} ${$2}${$3}`).replace(/([a-z])([A-Z])/g, (str2, $1, $2) => `${$1} ${$2}`).replace(/([a-z])([0-9])/gi, (str2, $1, $2) => `${$1} ${$2}`).replace(/([0-9])([a-z])/gi, (str2, $1, $2) => `${$1} ${$2}`).replace(/(\s|^)(\w)/g, (str2, $1, $2) => `${$1}${$2.toUpperCase()}`).replace(/ +/g, " ").trim();
121
119
  }
122
- __name(toStartCaseStr, "toStartCaseStr");
123
120
 
124
121
  // src/csf/includeConditionalArg.ts
125
- var import_tiny_isequal = __toESM(require_tiny_isequal(), 1);
126
- var count = /* @__PURE__ */ __name((vals) => vals.map((v) => typeof v !== "undefined").filter(Boolean).length, "count");
127
- var testValue = /* @__PURE__ */ __name((cond, value) => {
128
- const { exists, eq, neq, truthy } = cond;
129
- if (count([exists, eq, neq, truthy]) > 1) {
122
+ var import_tiny_isequal = __toESM(require_tiny_isequal(), 1), count = (vals) => vals.map((v) => typeof v < "u").filter(Boolean).length, testValue = (cond, value) => {
123
+ let { exists, eq, neq, truthy } = cond;
124
+ if (count([exists, eq, neq, truthy]) > 1)
130
125
  throw new Error(`Invalid conditional test ${JSON.stringify({ exists, eq, neq })}`);
131
- }
132
- if (typeof eq !== "undefined") {
126
+ if (typeof eq < "u")
133
127
  return (0, import_tiny_isequal.isEqual)(value, eq);
134
- }
135
- if (typeof neq !== "undefined") {
128
+ if (typeof neq < "u")
136
129
  return !(0, import_tiny_isequal.isEqual)(value, neq);
137
- }
138
- if (typeof exists !== "undefined") {
139
- const valueExists = typeof value !== "undefined";
130
+ if (typeof exists < "u") {
131
+ let valueExists = typeof value < "u";
140
132
  return exists ? valueExists : !valueExists;
141
133
  }
142
- const shouldBeTruthy = typeof truthy === "undefined" ? true : truthy;
143
- return shouldBeTruthy ? !!value : !value;
144
- }, "testValue");
145
- var includeConditionalArg = /* @__PURE__ */ __name((argType, args, globals) => {
146
- if (!argType.if) {
147
- return true;
148
- }
149
- const { arg, global: global5 } = argType.if;
150
- if (count([arg, global5]) !== 1) {
134
+ return (typeof truthy > "u" ? !0 : truthy) ? !!value : !value;
135
+ }, includeConditionalArg = (argType, args, globals) => {
136
+ if (!argType.if)
137
+ return !0;
138
+ let { arg, global: global5 } = argType.if;
139
+ if (count([arg, global5]) !== 1)
151
140
  throw new Error(`Invalid conditional value ${JSON.stringify({ arg, global: global5 })}`);
152
- }
153
- const value = arg ? args[arg] : globals[global5];
141
+ let value = arg ? args[arg] : globals[global5];
154
142
  return testValue(argType.if, value);
155
- }, "includeConditionalArg");
143
+ };
156
144
 
157
145
  // src/csf/csf-factories.ts
158
146
  import { combineTags } from "storybook/internal/csf";
@@ -167,45 +155,27 @@ __export(addArgs_exports, {
167
155
  });
168
156
 
169
157
  // src/actions/addArgsHelpers.ts
170
- var isInInitialArgs = /* @__PURE__ */ __name((name, initialArgs) => typeof initialArgs[name] === "undefined" && !(name in initialArgs), "isInInitialArgs");
171
- var inferActionsFromArgTypesRegex = /* @__PURE__ */ __name((context) => {
172
- const {
158
+ var isInInitialArgs = (name, initialArgs) => typeof initialArgs[name] > "u" && !(name in initialArgs), inferActionsFromArgTypesRegex = (context) => {
159
+ let {
173
160
  initialArgs,
174
161
  argTypes,
175
162
  id,
176
163
  parameters: { actions }
177
164
  } = context;
178
- if (!actions || actions.disable || !actions.argTypesRegex || !argTypes) {
165
+ if (!actions || actions.disable || !actions.argTypesRegex || !argTypes)
179
166
  return {};
180
- }
181
- const argTypesRegex = new RegExp(actions.argTypesRegex);
182
- const argTypesMatchingRegex = Object.entries(argTypes).filter(
167
+ let argTypesRegex = new RegExp(actions.argTypesRegex);
168
+ return Object.entries(argTypes).filter(
183
169
  ([name]) => !!argTypesRegex.test(name)
184
- );
185
- return argTypesMatchingRegex.reduce((acc, [name, argType]) => {
186
- if (isInInitialArgs(name, initialArgs)) {
187
- acc[name] = action(name, { implicit: true, id });
188
- }
189
- return acc;
190
- }, {});
191
- }, "inferActionsFromArgTypesRegex");
192
- var addActionsFromArgTypes = /* @__PURE__ */ __name((context) => {
193
- const {
170
+ ).reduce((acc, [name, argType]) => (isInInitialArgs(name, initialArgs) && (acc[name] = action(name, { implicit: !0, id })), acc), {});
171
+ }, addActionsFromArgTypes = (context) => {
172
+ let {
194
173
  initialArgs,
195
174
  argTypes,
196
175
  parameters: { actions }
197
176
  } = context;
198
- if (actions?.disable || !argTypes) {
199
- return {};
200
- }
201
- const argTypesWithAction = Object.entries(argTypes).filter(([name, argType]) => !!argType.action);
202
- return argTypesWithAction.reduce((acc, [name, argType]) => {
203
- if (isInInitialArgs(name, initialArgs)) {
204
- acc[name] = action(typeof argType.action === "string" ? argType.action : name);
205
- }
206
- return acc;
207
- }, {});
208
- }, "addActionsFromArgTypes");
177
+ return actions?.disable || !argTypes ? {} : Object.entries(argTypes).filter(([name, argType]) => !!argType.action).reduce((acc, [name, argType]) => (isInInitialArgs(name, initialArgs) && (acc[name] = action(typeof argType.action == "string" ? argType.action : name)), acc), {});
178
+ };
209
179
 
210
180
  // src/actions/addArgs.ts
211
181
  var argsEnhancers = [
@@ -219,44 +189,28 @@ __export(loaders_exports, {
219
189
  loaders: () => loaders
220
190
  });
221
191
  import { onMockCall } from "storybook/test";
222
- var subscribed = false;
223
- var logActionsWhenMockCalled = /* @__PURE__ */ __name((context) => {
224
- const { parameters: parameters2 } = context;
225
- if (parameters2?.actions?.disable) {
226
- return;
227
- }
228
- if (!subscribed) {
229
- onMockCall((mock, args) => {
230
- const name = mock.getMockName();
231
- if (name === "spy") {
232
- return;
233
- }
234
- if (name === "vi.fn()") {
235
- return;
236
- }
237
- if (!/^next\/.*::/.test(name) || [
238
- "next/router::useRouter()",
239
- "next/navigation::useRouter()",
240
- "next/navigation::redirect",
241
- "next/cache::",
242
- "next/headers::cookies().set",
243
- "next/headers::cookies().delete",
244
- "next/headers::headers().set",
245
- "next/headers::headers().delete"
246
- ].some((prefix) => name.startsWith(prefix))) {
247
- action(name)(args);
248
- }
249
- });
250
- subscribed = true;
251
- }
252
- }, "logActionsWhenMockCalled");
253
- var loaders = [logActionsWhenMockCalled];
192
+ var subscribed = !1, logActionsWhenMockCalled = (context) => {
193
+ let { parameters: parameters2 } = context;
194
+ parameters2?.actions?.disable || subscribed || (onMockCall((mock, args) => {
195
+ let name = mock.getMockName();
196
+ name !== "spy" && name !== "vi.fn()" && (!/^next\/.*::/.test(name) || [
197
+ "next/router::useRouter()",
198
+ "next/navigation::useRouter()",
199
+ "next/navigation::redirect",
200
+ "next/cache::",
201
+ "next/headers::cookies().set",
202
+ "next/headers::cookies().delete",
203
+ "next/headers::headers().set",
204
+ "next/headers::headers().delete"
205
+ ].some((prefix) => name.startsWith(prefix))) && action(name)(args);
206
+ }), subscribed = !0);
207
+ }, loaders = [logActionsWhenMockCalled];
254
208
 
255
209
  // src/actions/preview.ts
256
- var preview_default = /* @__PURE__ */ __name(() => definePreviewAddon({
210
+ var preview_default = () => definePreviewAddon({
257
211
  ...addArgs_exports,
258
212
  ...loaders_exports
259
- }), "default");
213
+ });
260
214
 
261
215
  // src/backgrounds/preview.ts
262
216
  import { definePreviewAddon as definePreviewAddon2 } from "storybook/internal/csf";
@@ -265,97 +219,50 @@ import { definePreviewAddon as definePreviewAddon2 } from "storybook/internal/cs
265
219
  import { useEffect } from "storybook/preview-api";
266
220
 
267
221
  // src/backgrounds/utils.ts
268
- var { document: document2 } = globalThis;
269
- var isReduceMotionEnabled = /* @__PURE__ */ __name(() => {
270
- if (!globalThis?.matchMedia) {
271
- return false;
272
- }
273
- const prefersReduceMotion = globalThis.matchMedia("(prefers-reduced-motion: reduce)");
274
- return !!prefersReduceMotion?.matches;
275
- }, "isReduceMotionEnabled");
276
- var clearStyles = /* @__PURE__ */ __name((selector) => {
277
- const selectors = Array.isArray(selector) ? selector : [selector];
278
- selectors.forEach(clearStyle);
279
- }, "clearStyles");
280
- var clearStyle = /* @__PURE__ */ __name((selector) => {
281
- if (!document2) {
222
+ var { document: document2 } = globalThis, isReduceMotionEnabled = () => globalThis?.matchMedia ? !!globalThis.matchMedia("(prefers-reduced-motion: reduce)")?.matches : !1, clearStyles = (selector) => {
223
+ (Array.isArray(selector) ? selector : [selector]).forEach(clearStyle);
224
+ }, clearStyle = (selector) => {
225
+ if (!document2)
282
226
  return;
283
- }
284
- const element = document2.getElementById(selector);
285
- if (element && element.parentElement) {
286
- element.parentElement.removeChild(element);
287
- }
288
- }, "clearStyle");
289
- var addGridStyle = /* @__PURE__ */ __name((selector, css) => {
290
- if (!document2) {
227
+ let element = document2.getElementById(selector);
228
+ element && element.parentElement && element.parentElement.removeChild(element);
229
+ }, addGridStyle = (selector, css) => {
230
+ if (!document2)
291
231
  return;
232
+ let existingStyle = document2.getElementById(selector);
233
+ if (existingStyle)
234
+ existingStyle.innerHTML !== css && (existingStyle.innerHTML = css);
235
+ else {
236
+ let style = document2.createElement("style");
237
+ style.setAttribute("id", selector), style.innerHTML = css, document2.head.appendChild(style);
292
238
  }
293
- const existingStyle = document2.getElementById(selector);
294
- if (existingStyle) {
295
- if (existingStyle.innerHTML !== css) {
296
- existingStyle.innerHTML = css;
297
- }
298
- } else {
299
- const style = document2.createElement("style");
300
- style.setAttribute("id", selector);
301
- style.innerHTML = css;
302
- document2.head.appendChild(style);
303
- }
304
- }, "addGridStyle");
305
- var addBackgroundStyle = /* @__PURE__ */ __name((selector, css, storyId) => {
306
- if (!document2) {
239
+ }, addBackgroundStyle = (selector, css, storyId) => {
240
+ if (!document2)
307
241
  return;
242
+ let existingStyle = document2.getElementById(selector);
243
+ if (existingStyle)
244
+ existingStyle.innerHTML !== css && (existingStyle.innerHTML = css);
245
+ else {
246
+ let style = document2.createElement("style");
247
+ style.setAttribute("id", selector), style.innerHTML = css;
248
+ let gridStyleSelector = `addon-backgrounds-grid${storyId ? `-docs-${storyId}` : ""}`, existingGridStyle = document2.getElementById(gridStyleSelector);
249
+ existingGridStyle ? existingGridStyle.parentElement?.insertBefore(style, existingGridStyle) : document2.head.appendChild(style);
308
250
  }
309
- const existingStyle = document2.getElementById(selector);
310
- if (existingStyle) {
311
- if (existingStyle.innerHTML !== css) {
312
- existingStyle.innerHTML = css;
313
- }
314
- } else {
315
- const style = document2.createElement("style");
316
- style.setAttribute("id", selector);
317
- style.innerHTML = css;
318
- const gridStyleSelector = `addon-backgrounds-grid${storyId ? `-docs-${storyId}` : ""}`;
319
- const existingGridStyle = document2.getElementById(gridStyleSelector);
320
- if (existingGridStyle) {
321
- existingGridStyle.parentElement?.insertBefore(style, existingGridStyle);
322
- } else {
323
- document2.head.appendChild(style);
324
- }
325
- }
326
- }, "addBackgroundStyle");
251
+ };
327
252
 
328
253
  // src/backgrounds/decorator.ts
329
254
  var defaultGrid = {
330
255
  cellSize: 100,
331
256
  cellAmount: 10,
332
257
  opacity: 0.8
333
- };
334
- var BG_SELECTOR_BASE = `addon-backgrounds`;
335
- var GRID_SELECTOR_BASE = "addon-backgrounds-grid";
336
- var transitionStyle = isReduceMotionEnabled() ? "" : "transition: background-color 0.3s;";
337
- var withBackgroundAndGrid = /* @__PURE__ */ __name((StoryFn, context) => {
338
- const { globals = {}, parameters: parameters2 = {}, viewMode, id } = context;
339
- const {
258
+ }, BG_SELECTOR_BASE = "addon-backgrounds", GRID_SELECTOR_BASE = "addon-backgrounds-grid", transitionStyle = isReduceMotionEnabled() ? "" : "transition: background-color 0.3s;", withBackgroundAndGrid = (StoryFn, context) => {
259
+ let { globals = {}, parameters: parameters2 = {}, viewMode, id } = context, {
340
260
  options = DEFAULT_BACKGROUNDS,
341
261
  disable,
342
262
  grid = defaultGrid
343
- } = parameters2[PARAM_KEY2] || {};
344
- const data = globals[PARAM_KEY2] || {};
345
- const backgroundName = typeof data === "string" ? data : data?.value;
346
- const item = backgroundName ? options[backgroundName] : void 0;
347
- const value = typeof item === "string" ? item : item?.value || "transparent";
348
- const showGrid = typeof data === "string" ? false : data.grid || false;
349
- const shownBackground = !!item && !disable;
350
- const backgroundSelector = viewMode === "docs" ? `#anchor--${id} .docs-story` : ".sb-show-main";
351
- const gridSelector = viewMode === "docs" ? `#anchor--${id} .docs-story` : ".sb-show-main";
352
- const isLayoutPadded = parameters2.layout === void 0 || parameters2.layout === "padded";
353
- const defaultOffset = viewMode === "docs" ? 20 : isLayoutPadded ? 16 : 0;
354
- const { cellAmount, cellSize, opacity, offsetX = defaultOffset, offsetY = defaultOffset } = grid;
355
- const backgroundSelectorId = viewMode === "docs" ? `${BG_SELECTOR_BASE}-docs-${id}` : `${BG_SELECTOR_BASE}-color`;
356
- const backgroundTarget = viewMode === "docs" ? id : null;
263
+ } = parameters2[PARAM_KEY2] || {}, data = globals[PARAM_KEY2] || {}, backgroundName = typeof data == "string" ? data : data?.value, item = backgroundName ? options[backgroundName] : void 0, value = typeof item == "string" ? item : item?.value || "transparent", showGrid = typeof data == "string" ? !1 : data.grid || !1, shownBackground = !!item && !disable, backgroundSelector = viewMode === "docs" ? `#anchor--${id} .docs-story` : ".sb-show-main", gridSelector = viewMode === "docs" ? `#anchor--${id} .docs-story` : ".sb-show-main", isLayoutPadded = parameters2.layout === void 0 || parameters2.layout === "padded", defaultOffset = viewMode === "docs" ? 20 : isLayoutPadded ? 16 : 0, { cellAmount, cellSize, opacity, offsetX = defaultOffset, offsetY = defaultOffset } = grid, backgroundSelectorId = viewMode === "docs" ? `${BG_SELECTOR_BASE}-docs-${id}` : `${BG_SELECTOR_BASE}-color`, backgroundTarget = viewMode === "docs" ? id : null;
357
264
  useEffect(() => {
358
- const backgroundStyles = `
265
+ let backgroundStyles = `
359
266
  ${backgroundSelector} {
360
267
  background: ${value} !important;
361
268
  ${transitionStyle}
@@ -366,19 +273,18 @@ var withBackgroundAndGrid = /* @__PURE__ */ __name((StoryFn, context) => {
366
273
  }
367
274
  addBackgroundStyle(backgroundSelectorId, backgroundStyles, backgroundTarget);
368
275
  }, [backgroundSelector, backgroundSelectorId, backgroundTarget, shownBackground, value]);
369
- const gridSelectorId = viewMode === "docs" ? `${GRID_SELECTOR_BASE}-docs-${id}` : `${GRID_SELECTOR_BASE}`;
370
- useEffect(() => {
276
+ let gridSelectorId = viewMode === "docs" ? `${GRID_SELECTOR_BASE}-docs-${id}` : `${GRID_SELECTOR_BASE}`;
277
+ return useEffect(() => {
371
278
  if (!showGrid) {
372
279
  clearStyles(gridSelectorId);
373
280
  return;
374
281
  }
375
- const gridSize = [
282
+ let gridSize = [
376
283
  `${cellSize * cellAmount}px ${cellSize * cellAmount}px`,
377
284
  `${cellSize * cellAmount}px ${cellSize * cellAmount}px`,
378
285
  `${cellSize}px ${cellSize}px`,
379
286
  `${cellSize}px ${cellSize}px`
380
- ].join(", ");
381
- const gridStyles = `
287
+ ].join(", "), gridStyles = `
382
288
  ${gridSelector} {
383
289
  background-size: ${gridSize} !important;
384
290
  background-position: ${offsetX}px ${offsetY}px, ${offsetX}px ${offsetY}px, ${offsetX}px ${offsetY}px, ${offsetX}px ${offsetY}px !important;
@@ -390,30 +296,26 @@ var withBackgroundAndGrid = /* @__PURE__ */ __name((StoryFn, context) => {
390
296
  }
391
297
  `;
392
298
  addGridStyle(gridSelectorId, gridStyles);
393
- }, [cellAmount, cellSize, gridSelector, gridSelectorId, showGrid, offsetX, offsetY, opacity]);
394
- return StoryFn();
395
- }, "withBackgroundAndGrid");
299
+ }, [cellAmount, cellSize, gridSelector, gridSelectorId, showGrid, offsetX, offsetY, opacity]), StoryFn();
300
+ };
396
301
 
397
302
  // src/backgrounds/preview.ts
398
- var decorators = globalThis.FEATURES?.backgrounds ? [withBackgroundAndGrid] : [];
399
- var parameters = {
303
+ var decorators = globalThis.FEATURES?.backgrounds ? [withBackgroundAndGrid] : [], parameters = {
400
304
  [PARAM_KEY2]: {
401
305
  grid: {
402
306
  cellSize: 20,
403
307
  opacity: 0.5,
404
308
  cellAmount: 5
405
309
  },
406
- disable: false
310
+ disable: !1
407
311
  }
408
- };
409
- var initialGlobals = {
410
- [PARAM_KEY2]: { value: void 0, grid: false }
411
- };
412
- var preview_default2 = /* @__PURE__ */ __name(() => definePreviewAddon2({
312
+ }, initialGlobals = {
313
+ [PARAM_KEY2]: { value: void 0, grid: !1 }
314
+ }, preview_default2 = () => definePreviewAddon2({
413
315
  decorators,
414
316
  parameters,
415
317
  initialGlobals
416
- }), "default");
318
+ });
417
319
 
418
320
  // src/component-testing/preview.ts
419
321
  import { definePreviewAddon as definePreviewAddon3 } from "storybook/internal/csf";
@@ -425,16 +327,15 @@ var { step } = instrument(
425
327
  // await step("label", (context) => {
426
328
  // // labeled step
427
329
  // });
428
- step: /* @__PURE__ */ __name(async (label, play, context) => play(context), "step")
330
+ step: async (label, play, context) => play(context)
429
331
  },
430
- { intercept: true }
431
- );
432
- var preview_default3 = /* @__PURE__ */ __name(() => definePreviewAddon3({
332
+ { intercept: !0 }
333
+ ), preview_default3 = () => definePreviewAddon3({
433
334
  parameters: {
434
- throwPlayFunctionExceptions: false
335
+ throwPlayFunctionExceptions: !1
435
336
  },
436
337
  runStep: step
437
- }), "default");
338
+ });
438
339
 
439
340
  // src/highlight/preview.ts
440
341
  import { definePreviewAddon as definePreviewAddon4 } from "storybook/internal/csf";
@@ -462,43 +363,21 @@ var iconPaths = {
462
363
  };
463
364
 
464
365
  // src/highlight/utils.ts
465
- var svgElements = "svg,path,rect,circle,line,polyline,polygon,ellipse,text".split(",");
466
- var createElement = /* @__PURE__ */ __name((type, props = {}, children) => {
467
- const element = svgElements.includes(type) ? document.createElementNS("http://www.w3.org/2000/svg", type) : document.createElement(type);
468
- Object.entries(props).forEach(([key, val]) => {
469
- if (/[A-Z]/.test(key)) {
470
- if (key === "onClick") {
471
- element.addEventListener("click", val);
472
- element.addEventListener("keydown", (e) => {
473
- if (e.key === "Enter" || e.key === " ") {
474
- e.preventDefault();
475
- val();
476
- }
477
- });
366
+ var svgElements = "svg,path,rect,circle,line,polyline,polygon,ellipse,text".split(","), createElement = (type, props = {}, children) => {
367
+ let element = svgElements.includes(type) ? document.createElementNS("http://www.w3.org/2000/svg", type) : document.createElement(type);
368
+ return Object.entries(props).forEach(([key, val]) => {
369
+ /[A-Z]/.test(key) ? (key === "onClick" && (element.addEventListener("click", val), element.addEventListener("keydown", (e) => {
370
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), val());
371
+ })), key === "onMouseEnter" && element.addEventListener("mouseenter", val), key === "onMouseLeave" && element.addEventListener("mouseleave", val)) : element.setAttribute(key, val);
372
+ }), children?.forEach((child) => {
373
+ if (!(child == null || child === !1))
374
+ try {
375
+ element.appendChild(child);
376
+ } catch {
377
+ element.appendChild(document.createTextNode(String(child)));
478
378
  }
479
- if (key === "onMouseEnter") {
480
- element.addEventListener("mouseenter", val);
481
- }
482
- if (key === "onMouseLeave") {
483
- element.addEventListener("mouseleave", val);
484
- }
485
- } else {
486
- element.setAttribute(key, val);
487
- }
488
- });
489
- children?.forEach((child) => {
490
- if (child === null || child === void 0 || child === false) {
491
- return;
492
- }
493
- try {
494
- element.appendChild(child);
495
- } catch (e) {
496
- element.appendChild(document.createTextNode(String(child)));
497
- }
498
- });
499
- return element;
500
- }, "createElement");
501
- var createIcon = /* @__PURE__ */ __name((name) => iconPaths[name] && createElement(
379
+ }), element;
380
+ }, createIcon = (name) => iconPaths[name] && createElement(
502
381
  "svg",
503
382
  { width: "14", height: "14", viewBox: "0 0 14 14", xmlns: "http://www.w3.org/2000/svg" },
504
383
  iconPaths[name].map(
@@ -509,10 +388,9 @@ var createIcon = /* @__PURE__ */ __name((name) => iconPaths[name] && createEleme
509
388
  d
510
389
  })
511
390
  )
512
- ), "createIcon");
513
- var normalizeOptions = /* @__PURE__ */ __name((options) => {
391
+ ), normalizeOptions = (options) => {
514
392
  if ("elements" in options) {
515
- const { elements, color, style } = options;
393
+ let { elements, color, style } = options;
516
394
  return {
517
395
  id: void 0,
518
396
  priority: 0,
@@ -525,7 +403,7 @@ var normalizeOptions = /* @__PURE__ */ __name((options) => {
525
403
  menu: void 0
526
404
  };
527
405
  }
528
- const { menu, ...rest } = options;
406
+ let { menu, ...rest } = options;
529
407
  return {
530
408
  id: void 0,
531
409
  priority: 0,
@@ -535,56 +413,30 @@ var normalizeOptions = /* @__PURE__ */ __name((options) => {
535
413
  ...rest,
536
414
  menu: Array.isArray(menu) ? menu.every(Array.isArray) ? menu : [menu] : void 0
537
415
  };
538
- }, "normalizeOptions");
539
- var isFunction = /* @__PURE__ */ __name((obj) => obj instanceof Function, "isFunction");
540
- var state = /* @__PURE__ */ new Map();
541
- var listeners = /* @__PURE__ */ new Map();
542
- var teardowns = /* @__PURE__ */ new Map();
543
- var useStore = /* @__PURE__ */ __name((initialValue) => {
544
- const key = Symbol();
545
- listeners.set(key, []);
546
- state.set(key, initialValue);
547
- const get = /* @__PURE__ */ __name(() => state.get(key), "get");
548
- const set = /* @__PURE__ */ __name((update) => {
549
- const current = state.get(key);
550
- const next = isFunction(update) ? update(current) : update;
551
- if (next !== current) {
552
- state.set(key, next);
553
- listeners.get(key)?.forEach((listener) => {
554
- teardowns.get(listener)?.();
555
- teardowns.set(listener, listener(next));
556
- });
557
- }
558
- }, "set");
559
- const subscribe = /* @__PURE__ */ __name((listener) => {
560
- listeners.get(key)?.push(listener);
561
- return () => {
562
- const list = listeners.get(key);
563
- if (list) {
564
- listeners.set(
565
- key,
566
- list.filter((l) => l !== listener)
567
- );
568
- }
569
- };
570
- }, "subscribe");
571
- const teardown = /* @__PURE__ */ __name(() => {
416
+ }, isFunction = (obj) => obj instanceof Function, state = /* @__PURE__ */ new Map(), listeners = /* @__PURE__ */ new Map(), teardowns = /* @__PURE__ */ new Map(), useStore = (initialValue) => {
417
+ let key = Symbol();
418
+ return listeners.set(key, []), state.set(key, initialValue), { get: () => state.get(key), set: (update) => {
419
+ let current = state.get(key), next = isFunction(update) ? update(current) : update;
420
+ next !== current && (state.set(key, next), listeners.get(key)?.forEach((listener) => {
421
+ teardowns.get(listener)?.(), teardowns.set(listener, listener(next));
422
+ }));
423
+ }, subscribe: (listener) => (listeners.get(key)?.push(listener), () => {
424
+ let list = listeners.get(key);
425
+ list && listeners.set(
426
+ key,
427
+ list.filter((l) => l !== listener)
428
+ );
429
+ }), teardown: () => {
572
430
  listeners.get(key)?.forEach((listener) => {
573
- teardowns.get(listener)?.();
574
- teardowns.delete(listener);
575
- });
576
- listeners.delete(key);
577
- state.delete(key);
578
- }, "teardown");
579
- return { get, set, subscribe, teardown };
580
- }, "useStore");
581
- var mapElements = /* @__PURE__ */ __name((highlights) => {
582
- const root = document.getElementById("storybook-root");
583
- const map = /* @__PURE__ */ new Map();
584
- for (const highlight of highlights) {
585
- const { priority = 0 } = highlight;
586
- for (const selector of highlight.selectors) {
587
- const elements = [
431
+ teardowns.get(listener)?.(), teardowns.delete(listener);
432
+ }), listeners.delete(key), state.delete(key);
433
+ } };
434
+ }, mapElements = (highlights) => {
435
+ let root = document.getElementById("storybook-root"), map = /* @__PURE__ */ new Map();
436
+ for (let highlight of highlights) {
437
+ let { priority = 0 } = highlight;
438
+ for (let selector of highlight.selectors) {
439
+ let elements = [
588
440
  ...document.querySelectorAll(
589
441
  // Elements matching the selector, excluding storybook elements and their descendants.
590
442
  // Necessary to find portaled elements (e.g. children of `body`).
@@ -593,23 +445,19 @@ var mapElements = /* @__PURE__ */ __name((highlights) => {
593
445
  // Elements matching the selector inside the storybook root, as these were excluded above.
594
446
  ...root?.querySelectorAll(selector) || []
595
447
  ];
596
- for (const element of elements) {
597
- const existing = map.get(element);
598
- if (!existing || existing.priority <= priority) {
599
- map.set(element, {
600
- ...highlight,
601
- priority,
602
- selectors: Array.from(new Set((existing?.selectors || []).concat(selector)))
603
- });
604
- }
448
+ for (let element of elements) {
449
+ let existing = map.get(element);
450
+ (!existing || existing.priority <= priority) && map.set(element, {
451
+ ...highlight,
452
+ priority,
453
+ selectors: Array.from(new Set((existing?.selectors || []).concat(selector)))
454
+ });
605
455
  }
606
456
  }
607
457
  }
608
458
  return map;
609
- }, "mapElements");
610
- var mapBoxes = /* @__PURE__ */ __name((elements) => Array.from(elements.entries()).map(([element, { selectors, styles, hoverStyles, focusStyles, menu }]) => {
611
- const { top, left, width, height } = element.getBoundingClientRect();
612
- const { position } = getComputedStyle(element);
459
+ }, mapBoxes = (elements) => Array.from(elements.entries()).map(([element, { selectors, styles, hoverStyles, focusStyles, menu }]) => {
460
+ let { top, left, width, height } = element.getBoundingClientRect(), { position } = getComputedStyle(element);
613
461
  return {
614
462
  element,
615
463
  selectors,
@@ -622,42 +470,21 @@ var mapBoxes = /* @__PURE__ */ __name((elements) => Array.from(elements.entries(
622
470
  width,
623
471
  height
624
472
  };
625
- }).sort((a, b) => b.width * b.height - a.width * a.height), "mapBoxes");
626
- var isOverMenu = /* @__PURE__ */ __name((menuElement, coordinates) => {
627
- const menu = menuElement.getBoundingClientRect();
628
- const { x, y } = coordinates;
473
+ }).sort((a, b) => b.width * b.height - a.width * a.height), isOverMenu = (menuElement, coordinates) => {
474
+ let menu = menuElement.getBoundingClientRect(), { x, y } = coordinates;
629
475
  return menu?.top && menu?.left && x >= menu.left && x <= menu.left + menu.width && y >= menu.top && y <= menu.top + menu.height;
630
- }, "isOverMenu");
631
- var isTargeted = /* @__PURE__ */ __name((box, boxElement, coordinates) => {
632
- if (!boxElement || !coordinates) {
633
- return false;
634
- }
476
+ }, isTargeted = (box, boxElement, coordinates) => {
477
+ if (!boxElement || !coordinates)
478
+ return !1;
635
479
  let { left, top, width, height } = box;
636
- if (height < MIN_TOUCH_AREA_SIZE) {
637
- top = top - Math.round((MIN_TOUCH_AREA_SIZE - height) / 2);
638
- height = MIN_TOUCH_AREA_SIZE;
639
- }
640
- if (width < MIN_TOUCH_AREA_SIZE) {
641
- left = left - Math.round((MIN_TOUCH_AREA_SIZE - width) / 2);
642
- width = MIN_TOUCH_AREA_SIZE;
643
- }
644
- if (boxElement.style.position === "fixed") {
645
- left += window.scrollX;
646
- top += window.scrollY;
647
- }
648
- const { x, y } = coordinates;
480
+ height < MIN_TOUCH_AREA_SIZE && (top = top - Math.round((MIN_TOUCH_AREA_SIZE - height) / 2), height = MIN_TOUCH_AREA_SIZE), width < MIN_TOUCH_AREA_SIZE && (left = left - Math.round((MIN_TOUCH_AREA_SIZE - width) / 2), width = MIN_TOUCH_AREA_SIZE), boxElement.style.position === "fixed" && (left += window.scrollX, top += window.scrollY);
481
+ let { x, y } = coordinates;
649
482
  return x >= left && x <= left + width && y >= top && y <= top + height;
650
- }, "isTargeted");
651
- var keepInViewport = /* @__PURE__ */ __name((element, targetCoordinates, options = {}) => {
652
- const { x, y } = targetCoordinates;
653
- const { margin = 5, topOffset = 0, centered = false } = options;
654
- const { scrollX, scrollY, innerHeight: windowHeight, innerWidth: windowWidth } = window;
655
- const top = Math.min(
483
+ }, keepInViewport = (element, targetCoordinates, options = {}) => {
484
+ let { x, y } = targetCoordinates, { margin = 5, topOffset = 0, centered = !1 } = options, { scrollX, scrollY, innerHeight: windowHeight, innerWidth: windowWidth } = window, top = Math.min(
656
485
  element.style.position === "fixed" ? y - scrollY : y,
657
486
  windowHeight - element.clientHeight - margin - topOffset + scrollY
658
- );
659
- const leftOffset = centered ? element.clientWidth / 2 : 0;
660
- const left = element.style.position === "fixed" ? Math.max(Math.min(x - scrollX, windowWidth - leftOffset - margin), leftOffset + margin) : Math.max(
487
+ ), leftOffset = centered ? element.clientWidth / 2 : 0, left = element.style.position === "fixed" ? Math.max(Math.min(x - scrollX, windowWidth - leftOffset - margin), leftOffset + margin) : Math.max(
661
488
  Math.min(x, windowWidth - leftOffset - margin + scrollX),
662
489
  leftOffset + margin + scrollX
663
490
  );
@@ -665,18 +492,11 @@ var keepInViewport = /* @__PURE__ */ __name((element, targetCoordinates, options
665
492
  ...left !== x && { left: `${left}px` },
666
493
  ...top !== y && { top: `${top}px` }
667
494
  });
668
- }, "keepInViewport");
669
- var showPopover = /* @__PURE__ */ __name((element) => {
670
- if (window.HTMLElement.prototype.hasOwnProperty("showPopover")) {
671
- element.showPopover();
672
- }
673
- }, "showPopover");
674
- var hidePopover = /* @__PURE__ */ __name((element) => {
675
- if (window.HTMLElement.prototype.hasOwnProperty("showPopover")) {
676
- element.hidePopover();
677
- }
678
- }, "hidePopover");
679
- var getEventDetails = /* @__PURE__ */ __name((target) => ({
495
+ }, showPopover = (element) => {
496
+ window.HTMLElement.prototype.hasOwnProperty("showPopover") && element.showPopover();
497
+ }, hidePopover = (element) => {
498
+ window.HTMLElement.prototype.hasOwnProperty("showPopover") && element.hidePopover();
499
+ }, getEventDetails = (target) => ({
680
500
  top: target.top,
681
501
  left: target.left,
682
502
  width: target.width,
@@ -690,185 +510,116 @@ var getEventDetails = /* @__PURE__ */ __name((target) => ({
690
510
  tagName: target.element.tagName,
691
511
  outerHTML: target.element.outerHTML
692
512
  }
693
- }), "getEventDetails");
513
+ });
694
514
 
695
515
  // src/highlight/useHighlights.ts
696
- var menuId = "storybook-highlights-menu";
697
- var rootId = "storybook-highlights-root";
698
- var storybookRootId = "storybook-root";
699
- var useHighlights = /* @__PURE__ */ __name((channel) => {
700
- if (globalThis.__STORYBOOK_HIGHLIGHT_INITIALIZED) {
516
+ var menuId = "storybook-highlights-menu", rootId = "storybook-highlights-root", storybookRootId = "storybook-root", useHighlights = (channel) => {
517
+ if (globalThis.__STORYBOOK_HIGHLIGHT_INITIALIZED)
701
518
  return;
702
- }
703
- globalThis.__STORYBOOK_HIGHLIGHT_INITIALIZED = true;
704
- const { document: document3 } = globalThis;
705
- const highlights = useStore([]);
706
- const elements = useStore(/* @__PURE__ */ new Map());
707
- const boxes = useStore([]);
708
- const clickCoords = useStore();
709
- const hoverCoords = useStore();
710
- const targets = useStore([]);
711
- const hovered = useStore([]);
712
- const focused = useStore();
713
- const selected = useStore();
714
- let root = document3.getElementById(rootId);
519
+ globalThis.__STORYBOOK_HIGHLIGHT_INITIALIZED = !0;
520
+ let { document: document3 } = globalThis, highlights = useStore([]), elements = useStore(/* @__PURE__ */ new Map()), boxes = useStore([]), clickCoords = useStore(), hoverCoords = useStore(), targets = useStore([]), hovered = useStore([]), focused = useStore(), selected = useStore(), root = document3.getElementById(rootId);
715
521
  highlights.subscribe(() => {
716
- if (!root) {
717
- root = createElement("div", { id: rootId });
718
- document3.body.appendChild(root);
719
- }
720
- });
721
- highlights.subscribe((value) => {
722
- const storybookRoot = document3.getElementById(storybookRootId);
723
- if (!storybookRoot) {
522
+ root || (root = createElement("div", { id: rootId }), document3.body.appendChild(root));
523
+ }), highlights.subscribe((value) => {
524
+ let storybookRoot = document3.getElementById(storybookRootId);
525
+ if (!storybookRoot)
724
526
  return;
725
- }
726
527
  elements.set(mapElements(value));
727
- const observer = new MutationObserver(() => elements.set(mapElements(value)));
728
- observer.observe(storybookRoot, { subtree: true, childList: true });
729
- return () => {
528
+ let observer = new MutationObserver(() => elements.set(mapElements(value)));
529
+ return observer.observe(storybookRoot, { subtree: !0, childList: !0 }), () => {
730
530
  observer.disconnect();
731
531
  };
732
- });
733
- elements.subscribe((value) => {
734
- const updateBoxes = /* @__PURE__ */ __name(() => requestAnimationFrame(() => boxes.set(mapBoxes(value))), "updateBoxes");
735
- const observer = new ResizeObserver(updateBoxes);
736
- observer.observe(document3.body);
737
- Array.from(value.keys()).forEach((element) => observer.observe(element));
738
- const scrollers = Array.from(document3.body.querySelectorAll("*")).filter((el) => {
739
- const { overflow, overflowX, overflowY } = window.getComputedStyle(el);
532
+ }), elements.subscribe((value) => {
533
+ let updateBoxes = () => requestAnimationFrame(() => boxes.set(mapBoxes(value))), observer = new ResizeObserver(updateBoxes);
534
+ observer.observe(document3.body), Array.from(value.keys()).forEach((element) => observer.observe(element));
535
+ let scrollers = Array.from(document3.body.querySelectorAll("*")).filter((el) => {
536
+ let { overflow, overflowX, overflowY } = window.getComputedStyle(el);
740
537
  return ["auto", "scroll"].some((o) => [overflow, overflowX, overflowY].includes(o));
741
538
  });
742
- scrollers.forEach((element) => element.addEventListener("scroll", updateBoxes));
743
- return () => {
744
- observer.disconnect();
745
- scrollers.forEach((element) => element.removeEventListener("scroll", updateBoxes));
539
+ return scrollers.forEach((element) => element.addEventListener("scroll", updateBoxes)), () => {
540
+ observer.disconnect(), scrollers.forEach((element) => element.removeEventListener("scroll", updateBoxes));
746
541
  };
747
- });
748
- elements.subscribe((value) => {
749
- const sticky = Array.from(value.keys()).filter(({ style }) => style.position === "sticky");
750
- const updateBoxes = /* @__PURE__ */ __name(() => requestAnimationFrame(() => {
542
+ }), elements.subscribe((value) => {
543
+ let sticky = Array.from(value.keys()).filter(({ style }) => style.position === "sticky"), updateBoxes = () => requestAnimationFrame(() => {
751
544
  boxes.set(
752
545
  (current) => current.map((box) => {
753
546
  if (sticky.includes(box.element)) {
754
- const { top, left } = box.element.getBoundingClientRect();
547
+ let { top, left } = box.element.getBoundingClientRect();
755
548
  return { ...box, top: top + window.scrollY, left: left + window.scrollX };
756
549
  }
757
550
  return box;
758
551
  })
759
552
  );
760
- }), "updateBoxes");
761
- document3.addEventListener("scroll", updateBoxes);
762
- return () => document3.removeEventListener("scroll", updateBoxes);
763
- });
764
- elements.subscribe((value) => {
553
+ });
554
+ return document3.addEventListener("scroll", updateBoxes), () => document3.removeEventListener("scroll", updateBoxes);
555
+ }), elements.subscribe((value) => {
765
556
  targets.set((t) => t.filter(({ element }) => value.has(element)));
557
+ }), targets.subscribe((value) => {
558
+ value.length ? (selected.set((s) => value.some((t) => t.element === s?.element) ? s : void 0), focused.set((s) => value.some((t) => t.element === s?.element) ? s : void 0)) : (selected.set(void 0), focused.set(void 0), clickCoords.set(void 0));
766
559
  });
767
- targets.subscribe((value) => {
768
- if (value.length) {
769
- selected.set((s) => value.some((t) => t.element === s?.element) ? s : void 0);
770
- focused.set((s) => value.some((t) => t.element === s?.element) ? s : void 0);
771
- } else {
772
- selected.set(void 0);
773
- focused.set(void 0);
774
- clickCoords.set(void 0);
775
- }
776
- });
777
- const styleElementByHighlight = new Map(/* @__PURE__ */ new Map());
560
+ let styleElementByHighlight = new Map(/* @__PURE__ */ new Map());
778
561
  highlights.subscribe((value) => {
779
562
  value.forEach(({ keyframes }) => {
780
563
  if (keyframes) {
781
564
  let style = styleElementByHighlight.get(keyframes);
782
- if (!style) {
783
- style = document3.createElement("style");
784
- style.setAttribute("data-highlight", "keyframes");
785
- styleElementByHighlight.set(keyframes, style);
786
- document3.head.appendChild(style);
787
- }
788
- style.innerHTML = keyframes;
789
- }
790
- });
791
- styleElementByHighlight.forEach((style, keyframes) => {
792
- if (!value.some((v) => v.keyframes === keyframes)) {
793
- style.remove();
794
- styleElementByHighlight.delete(keyframes);
565
+ style || (style = document3.createElement("style"), style.setAttribute("data-highlight", "keyframes"), styleElementByHighlight.set(keyframes, style), document3.head.appendChild(style)), style.innerHTML = keyframes;
795
566
  }
567
+ }), styleElementByHighlight.forEach((style, keyframes) => {
568
+ value.some((v) => v.keyframes === keyframes) || (style.remove(), styleElementByHighlight.delete(keyframes));
796
569
  });
797
570
  });
798
- const boxElementByTargetElement = new Map(/* @__PURE__ */ new Map());
571
+ let boxElementByTargetElement = new Map(/* @__PURE__ */ new Map());
799
572
  boxes.subscribe((value) => {
800
573
  value.forEach((box) => {
801
574
  let boxElement = boxElementByTargetElement.get(box.element);
802
575
  if (root && !boxElement) {
803
- const props = {
576
+ let props = {
804
577
  popover: "manual",
805
578
  "data-highlight-dimensions": `w${box.width.toFixed(0)}h${box.height.toFixed(0)}`,
806
579
  "data-highlight-coordinates": `x${box.left.toFixed(0)}y${box.top.toFixed(0)}`
807
580
  };
808
581
  boxElement = root.appendChild(
809
582
  createElement("div", props, [createElement("div")])
810
- );
811
- boxElementByTargetElement.set(box.element, boxElement);
583
+ ), boxElementByTargetElement.set(box.element, boxElement);
812
584
  }
585
+ }), boxElementByTargetElement.forEach((box, element) => {
586
+ value.some(({ element: e }) => e === element) || (box.remove(), boxElementByTargetElement.delete(element));
813
587
  });
814
- boxElementByTargetElement.forEach((box, element) => {
815
- if (!value.some(({ element: e }) => e === element)) {
816
- box.remove();
817
- boxElementByTargetElement.delete(element);
818
- }
819
- });
820
- });
821
- boxes.subscribe((value) => {
822
- const targetable = value.filter((box) => box.menu);
823
- if (!targetable.length) {
588
+ }), boxes.subscribe((value) => {
589
+ let targetable = value.filter((box) => box.menu);
590
+ if (!targetable.length)
824
591
  return;
825
- }
826
- const onClick = /* @__PURE__ */ __name((event) => {
592
+ let onClick = (event) => {
827
593
  requestAnimationFrame(() => {
828
- const menu = document3.getElementById(menuId);
829
- const coords = { x: event.pageX, y: event.pageY };
594
+ let menu = document3.getElementById(menuId), coords = { x: event.pageX, y: event.pageY };
830
595
  if (menu && !isOverMenu(menu, coords)) {
831
- const results = targetable.filter((box) => {
832
- const boxElement = boxElementByTargetElement.get(box.element);
596
+ let results = targetable.filter((box) => {
597
+ let boxElement = boxElementByTargetElement.get(box.element);
833
598
  return isTargeted(box, boxElement, coords);
834
599
  });
835
- clickCoords.set(results.length ? coords : void 0);
836
- targets.set(results);
600
+ clickCoords.set(results.length ? coords : void 0), targets.set(results);
837
601
  }
838
602
  });
839
- }, "onClick");
840
- document3.addEventListener("click", onClick);
841
- return () => document3.removeEventListener("click", onClick);
603
+ };
604
+ return document3.addEventListener("click", onClick), () => document3.removeEventListener("click", onClick);
842
605
  });
843
- const updateHovered = /* @__PURE__ */ __name(() => {
844
- const menu = document3.getElementById(menuId);
845
- const coords = hoverCoords.get();
846
- if (!coords || menu && isOverMenu(menu, coords)) {
847
- return;
848
- }
849
- hovered.set((current) => {
850
- const update = boxes.get().filter((box) => {
851
- const boxElement = boxElementByTargetElement.get(box.element);
606
+ let updateHovered = () => {
607
+ let menu = document3.getElementById(menuId), coords = hoverCoords.get();
608
+ !coords || menu && isOverMenu(menu, coords) || hovered.set((current) => {
609
+ let update = boxes.get().filter((box) => {
610
+ let boxElement = boxElementByTargetElement.get(box.element);
852
611
  return isTargeted(box, boxElement, coords);
853
- });
854
- const existing = current.filter((box) => update.includes(box));
855
- const additions = update.filter((box) => !current.includes(box));
856
- const hasRemovals = current.length - existing.length;
612
+ }), existing = current.filter((box) => update.includes(box)), additions = update.filter((box) => !current.includes(box)), hasRemovals = current.length - existing.length;
857
613
  return additions.length || hasRemovals ? [...existing, ...additions] : current;
858
614
  });
859
- }, "updateHovered");
860
- hoverCoords.subscribe(updateHovered);
861
- boxes.subscribe(updateHovered);
862
- const updateBoxStyles = /* @__PURE__ */ __name(() => {
863
- const selectedElement = selected.get();
864
- const targetElements = selectedElement ? [selectedElement] : targets.get();
865
- const focusedElement = targetElements.length === 1 ? targetElements[0] : focused.get();
866
- const isMenuOpen = clickCoords.get() !== void 0;
615
+ };
616
+ hoverCoords.subscribe(updateHovered), boxes.subscribe(updateHovered);
617
+ let updateBoxStyles = () => {
618
+ let selectedElement = selected.get(), targetElements = selectedElement ? [selectedElement] : targets.get(), focusedElement = targetElements.length === 1 ? targetElements[0] : focused.get(), isMenuOpen = clickCoords.get() !== void 0;
867
619
  boxes.get().forEach((box) => {
868
- const boxElement = boxElementByTargetElement.get(box.element);
620
+ let boxElement = boxElementByTargetElement.get(box.element);
869
621
  if (boxElement) {
870
- const isFocused = focusedElement === box;
871
- const isHovered = isMenuOpen ? focusedElement ? isFocused : targetElements.includes(box) : hovered.get()?.includes(box);
622
+ let isFocused = focusedElement === box, isHovered = isMenuOpen ? focusedElement ? isFocused : targetElements.includes(box) : hovered.get()?.includes(box);
872
623
  Object.assign(boxElement.style, {
873
624
  animation: "none",
874
625
  background: "transparent",
@@ -893,35 +644,27 @@ var useHighlights = /* @__PURE__ */ __name((channel) => {
893
644
  alignItems: "center",
894
645
  justifyContent: "center",
895
646
  overflow: "visible"
896
- });
897
- Object.assign(boxElement.children[0].style, {
647
+ }), Object.assign(boxElement.children[0].style, {
898
648
  width: "100%",
899
649
  height: "100%",
900
650
  minHeight: `${MIN_TOUCH_AREA_SIZE}px`,
901
651
  minWidth: `${MIN_TOUCH_AREA_SIZE}px`,
902
652
  boxSizing: "content-box",
903
653
  padding: boxElement.style.outlineWidth || "0px"
904
- });
905
- showPopover(boxElement);
654
+ }), showPopover(boxElement);
906
655
  }
907
656
  });
908
- }, "updateBoxStyles");
909
- boxes.subscribe(updateBoxStyles);
910
- targets.subscribe(updateBoxStyles);
911
- hovered.subscribe(updateBoxStyles);
912
- focused.subscribe(updateBoxStyles);
913
- selected.subscribe(updateBoxStyles);
914
- const renderMenu = /* @__PURE__ */ __name(() => {
915
- if (!root) {
657
+ };
658
+ boxes.subscribe(updateBoxStyles), targets.subscribe(updateBoxStyles), hovered.subscribe(updateBoxStyles), focused.subscribe(updateBoxStyles), selected.subscribe(updateBoxStyles);
659
+ let renderMenu = () => {
660
+ if (!root)
916
661
  return;
917
- }
918
662
  let menu = document3.getElementById(menuId);
919
- if (menu) {
663
+ if (menu)
920
664
  menu.innerHTML = "";
921
- } else {
922
- const props = { id: menuId, popover: "manual" };
923
- menu = root.appendChild(createElement("div", props));
924
- root.appendChild(
665
+ else {
666
+ let props = { id: menuId, popover: "manual" };
667
+ menu = root.appendChild(createElement("div", props)), root.appendChild(
925
668
  createElement("style", {}, [
926
669
  `
927
670
  #${menuId} {
@@ -1022,132 +765,99 @@ var useHighlights = /* @__PURE__ */ __name((channel) => {
1022
765
  ])
1023
766
  );
1024
767
  }
1025
- const selectedElement = selected.get();
1026
- const elementList = selectedElement ? [selectedElement] : targets.get();
1027
- if (elementList.length) {
1028
- menu.style.position = getComputedStyle(elementList[0].element).position === "fixed" ? "fixed" : "absolute";
1029
- menu.appendChild(
1030
- createElement(
1031
- "ul",
1032
- { class: "element-list" },
1033
- elementList.map((target) => {
1034
- const selectable = elementList.length > 1 && !!target.menu?.some(
1035
- (group) => group.some(
1036
- (item) => !item.selectors || item.selectors.some((s) => target.selectors.includes(s))
1037
- )
1038
- );
1039
- const props = selectable ? {
1040
- class: "selectable",
1041
- onClick: /* @__PURE__ */ __name(() => selected.set(target), "onClick"),
1042
- onMouseEnter: /* @__PURE__ */ __name(() => focused.set(target), "onMouseEnter"),
1043
- onMouseLeave: /* @__PURE__ */ __name(() => focused.set(void 0), "onMouseLeave")
1044
- } : selectedElement ? { class: "selected", onClick: /* @__PURE__ */ __name(() => selected.set(void 0), "onClick") } : {};
1045
- const asButton = selectable || selectedElement;
1046
- return createElement("li", props, [
1047
- createElement(asButton ? "button" : "div", asButton ? { type: "button" } : {}, [
1048
- selectedElement ? createIcon("chevronLeft") : null,
1049
- createElement("code", {}, [target.element.outerHTML]),
1050
- selectable ? createIcon("chevronRight") : null
1051
- ])
1052
- ]);
1053
- })
1054
- )
1055
- );
1056
- }
1057
- if (selected.get() || targets.get().length === 1) {
1058
- const target = selected.get() || targets.get()[0];
1059
- const menuGroups = target.menu?.filter(
768
+ let selectedElement = selected.get(), elementList = selectedElement ? [selectedElement] : targets.get();
769
+ if (elementList.length && (menu.style.position = getComputedStyle(elementList[0].element).position === "fixed" ? "fixed" : "absolute", menu.appendChild(
770
+ createElement(
771
+ "ul",
772
+ { class: "element-list" },
773
+ elementList.map((target) => {
774
+ let selectable = elementList.length > 1 && !!target.menu?.some(
775
+ (group) => group.some(
776
+ (item) => !item.selectors || item.selectors.some((s) => target.selectors.includes(s))
777
+ )
778
+ ), props = selectable ? {
779
+ class: "selectable",
780
+ onClick: () => selected.set(target),
781
+ onMouseEnter: () => focused.set(target),
782
+ onMouseLeave: () => focused.set(void 0)
783
+ } : selectedElement ? { class: "selected", onClick: () => selected.set(void 0) } : {}, asButton = selectable || selectedElement;
784
+ return createElement("li", props, [
785
+ createElement(asButton ? "button" : "div", asButton ? { type: "button" } : {}, [
786
+ selectedElement ? createIcon("chevronLeft") : null,
787
+ createElement("code", {}, [target.element.outerHTML]),
788
+ selectable ? createIcon("chevronRight") : null
789
+ ])
790
+ ]);
791
+ })
792
+ )
793
+ )), selected.get() || targets.get().length === 1) {
794
+ let target = selected.get() || targets.get()[0], menuGroups = target.menu?.filter(
1060
795
  (group) => group.some(
1061
796
  (item) => !item.selectors || item.selectors.some((s) => target.selectors.includes(s))
1062
797
  )
1063
798
  );
1064
- if (menuGroups?.length) {
1065
- menu.appendChild(
1066
- createElement(
1067
- "ul",
1068
- { class: "menu-list" },
1069
- menuGroups.map(
1070
- (menuItems) => createElement("li", {}, [
1071
- createElement(
1072
- "ul",
1073
- { class: "menu-items" },
1074
- menuItems.map(
1075
- ({ id, title, description, iconLeft, iconRight, clickEvent: event }) => {
1076
- const onClick = event && (() => channel.emit(event, id, getEventDetails(target)));
1077
- return createElement("li", {}, [
1078
- createElement(
1079
- onClick ? "button" : "div",
1080
- onClick ? { class: "menu-item", type: "button", onClick } : { class: "menu-item" },
1081
- [
1082
- iconLeft ? createIcon(iconLeft) : null,
1083
- createElement("div", { class: "menu-item-content" }, [
1084
- createElement(description ? "strong" : "span", {}, [title]),
1085
- description && createElement("span", {}, [description])
1086
- ]),
1087
- iconRight ? createIcon(iconRight) : null
1088
- ]
1089
- )
1090
- ]);
1091
- }
1092
- )
799
+ menuGroups?.length && menu.appendChild(
800
+ createElement(
801
+ "ul",
802
+ { class: "menu-list" },
803
+ menuGroups.map(
804
+ (menuItems) => createElement("li", {}, [
805
+ createElement(
806
+ "ul",
807
+ { class: "menu-items" },
808
+ menuItems.map(
809
+ ({ id, title, description, iconLeft, iconRight, clickEvent: event }) => {
810
+ let onClick = event && (() => channel.emit(event, id, getEventDetails(target)));
811
+ return createElement("li", {}, [
812
+ createElement(
813
+ onClick ? "button" : "div",
814
+ onClick ? { class: "menu-item", type: "button", onClick } : { class: "menu-item" },
815
+ [
816
+ iconLeft ? createIcon(iconLeft) : null,
817
+ createElement("div", { class: "menu-item-content" }, [
818
+ createElement(description ? "strong" : "span", {}, [title]),
819
+ description && createElement("span", {}, [description])
820
+ ]),
821
+ iconRight ? createIcon(iconRight) : null
822
+ ]
823
+ )
824
+ ]);
825
+ }
1093
826
  )
1094
- ])
1095
- )
827
+ )
828
+ ])
1096
829
  )
1097
- );
1098
- }
830
+ )
831
+ );
1099
832
  }
1100
- const coords = clickCoords.get();
1101
- if (coords) {
1102
- Object.assign(menu.style, {
1103
- display: "block",
1104
- left: `${menu.style.position === "fixed" ? coords.x - window.scrollX : coords.x}px`,
1105
- top: `${menu.style.position === "fixed" ? coords.y - window.scrollY : coords.y}px`
1106
- });
1107
- showPopover(menu);
1108
- requestAnimationFrame(() => keepInViewport(menu, coords, { topOffset: 15, centered: true }));
1109
- } else {
1110
- hidePopover(menu);
1111
- Object.assign(menu.style, { display: "none" });
1112
- }
1113
- }, "renderMenu");
1114
- targets.subscribe(renderMenu);
1115
- selected.subscribe(renderMenu);
1116
- const addHighlight = /* @__PURE__ */ __name((highlight) => {
1117
- const info = normalizeOptions(highlight);
833
+ let coords = clickCoords.get();
834
+ coords ? (Object.assign(menu.style, {
835
+ display: "block",
836
+ left: `${menu.style.position === "fixed" ? coords.x - window.scrollX : coords.x}px`,
837
+ top: `${menu.style.position === "fixed" ? coords.y - window.scrollY : coords.y}px`
838
+ }), showPopover(menu), requestAnimationFrame(() => keepInViewport(menu, coords, { topOffset: 15, centered: !0 }))) : (hidePopover(menu), Object.assign(menu.style, { display: "none" }));
839
+ };
840
+ targets.subscribe(renderMenu), selected.subscribe(renderMenu);
841
+ let addHighlight = (highlight) => {
842
+ let info = normalizeOptions(highlight);
1118
843
  highlights.set((value) => {
1119
- const others = info.id ? value.filter((h) => h.id !== info.id) : value;
844
+ let others = info.id ? value.filter((h) => h.id !== info.id) : value;
1120
845
  return info.selectors?.length ? [...others, info] : others;
1121
846
  });
1122
- }, "addHighlight");
1123
- const removeHighlight = /* @__PURE__ */ __name((id) => {
1124
- if (id) {
1125
- highlights.set((value) => value.filter((h) => h.id !== id));
1126
- }
1127
- }, "removeHighlight");
1128
- const resetState = /* @__PURE__ */ __name(() => {
1129
- highlights.set([]);
1130
- elements.set(/* @__PURE__ */ new Map());
1131
- boxes.set([]);
1132
- clickCoords.set(void 0);
1133
- hoverCoords.set(void 0);
1134
- targets.set([]);
1135
- hovered.set([]);
1136
- focused.set(void 0);
1137
- selected.set(void 0);
1138
- }, "resetState");
1139
- let removeTimeout;
1140
- const scrollIntoView = /* @__PURE__ */ __name((target, options) => {
1141
- const id = "scrollIntoView-highlight";
1142
- clearTimeout(removeTimeout);
1143
- removeHighlight(id);
1144
- const element = document3.querySelector(target);
847
+ }, removeHighlight = (id) => {
848
+ id && highlights.set((value) => value.filter((h) => h.id !== id));
849
+ }, resetState = () => {
850
+ highlights.set([]), elements.set(/* @__PURE__ */ new Map()), boxes.set([]), clickCoords.set(void 0), hoverCoords.set(void 0), targets.set([]), hovered.set([]), focused.set(void 0), selected.set(void 0);
851
+ }, removeTimeout, scrollIntoView = (target, options) => {
852
+ let id = "scrollIntoView-highlight";
853
+ clearTimeout(removeTimeout), removeHighlight(id);
854
+ let element = document3.querySelector(target);
1145
855
  if (!element) {
1146
856
  console.warn(`Cannot scroll into view: ${target} not found`);
1147
857
  return;
1148
858
  }
1149
859
  element.scrollIntoView({ behavior: "smooth", block: "center", ...options });
1150
- const keyframeName = `kf-${Math.random().toString(36).substring(2, 15)}`;
860
+ let keyframeName = `kf-${Math.random().toString(36).substring(2, 15)}`;
1151
861
  highlights.set((value) => [
1152
862
  ...value,
1153
863
  {
@@ -1168,29 +878,18 @@ var useHighlights = /* @__PURE__ */ __name((channel) => {
1168
878
  100% { outline: 2px solid #1EA7FD00; }
1169
879
  }`
1170
880
  }
1171
- ]);
1172
- removeTimeout = setTimeout(() => removeHighlight(id), 3500);
1173
- }, "scrollIntoView");
1174
- const onMouseMove = /* @__PURE__ */ __name((event) => {
881
+ ]), removeTimeout = setTimeout(() => removeHighlight(id), 3500);
882
+ }, onMouseMove = (event) => {
1175
883
  requestAnimationFrame(() => hoverCoords.set({ x: event.pageX, y: event.pageY }));
1176
- }, "onMouseMove");
1177
- document3.body.addEventListener("mousemove", onMouseMove);
1178
- channel.on(HIGHLIGHT, addHighlight);
1179
- channel.on(REMOVE_HIGHLIGHT, removeHighlight);
1180
- channel.on(RESET_HIGHLIGHT, resetState);
1181
- channel.on(SCROLL_INTO_VIEW, scrollIntoView);
1182
- channel.on(STORY_RENDER_PHASE_CHANGED, ({ newPhase }) => {
1183
- if (newPhase === "loading") {
1184
- resetState();
1185
- }
884
+ };
885
+ document3.body.addEventListener("mousemove", onMouseMove), channel.on(HIGHLIGHT, addHighlight), channel.on(REMOVE_HIGHLIGHT, removeHighlight), channel.on(RESET_HIGHLIGHT, resetState), channel.on(SCROLL_INTO_VIEW, scrollIntoView), channel.on(STORY_RENDER_PHASE_CHANGED, ({ newPhase }) => {
886
+ newPhase === "loading" && resetState();
1186
887
  });
1187
- }, "useHighlights");
888
+ };
1188
889
 
1189
890
  // src/highlight/preview.ts
1190
- if (globalThis?.FEATURES?.highlight && addons?.ready) {
1191
- addons.ready().then(useHighlights);
1192
- }
1193
- var preview_default4 = /* @__PURE__ */ __name(() => definePreviewAddon4({}), "default");
891
+ globalThis?.FEATURES?.highlight && addons?.ready && addons.ready().then(useHighlights);
892
+ var preview_default4 = () => definePreviewAddon4({});
1194
893
 
1195
894
  // src/measure/preview.ts
1196
895
  import { definePreviewAddon as definePreviewAddon5 } from "storybook/internal/csf";
@@ -1201,73 +900,40 @@ import { useEffect as useEffect2 } from "storybook/preview-api";
1201
900
  // src/measure/box-model/canvas.ts
1202
901
  import { global } from "@storybook/global";
1203
902
  function getDocumentWidthAndHeight() {
1204
- const container = global.document.documentElement;
1205
- const height = Math.max(container.scrollHeight, container.offsetHeight);
1206
- const width = Math.max(container.scrollWidth, container.offsetWidth);
1207
- return { width, height };
903
+ let container = global.document.documentElement, height = Math.max(container.scrollHeight, container.offsetHeight);
904
+ return { width: Math.max(container.scrollWidth, container.offsetWidth), height };
1208
905
  }
1209
- __name(getDocumentWidthAndHeight, "getDocumentWidthAndHeight");
1210
906
  function createCanvas() {
1211
- const canvas = global.document.createElement("canvas");
907
+ let canvas = global.document.createElement("canvas");
1212
908
  canvas.id = "storybook-addon-measure";
1213
- const context = canvas.getContext("2d");
909
+ let context = canvas.getContext("2d");
1214
910
  invariant(context != null);
1215
- const { width, height } = getDocumentWidthAndHeight();
1216
- setCanvasWidthAndHeight(canvas, context, { width, height });
1217
- canvas.style.position = "absolute";
1218
- canvas.style.left = "0";
1219
- canvas.style.top = "0";
1220
- canvas.style.zIndex = "2147483647";
1221
- canvas.style.pointerEvents = "none";
1222
- global.document.body.appendChild(canvas);
1223
- return { canvas, context, width, height };
911
+ let { width, height } = getDocumentWidthAndHeight();
912
+ return setCanvasWidthAndHeight(canvas, context, { width, height }), canvas.style.position = "absolute", canvas.style.left = "0", canvas.style.top = "0", canvas.style.zIndex = "2147483647", canvas.style.pointerEvents = "none", global.document.body.appendChild(canvas), { canvas, context, width, height };
1224
913
  }
1225
- __name(createCanvas, "createCanvas");
1226
914
  function setCanvasWidthAndHeight(canvas, context, { width, height }) {
1227
- canvas.style.width = `${width}px`;
1228
- canvas.style.height = `${height}px`;
1229
- const scale = global.window.devicePixelRatio;
1230
- canvas.width = Math.floor(width * scale);
1231
- canvas.height = Math.floor(height * scale);
1232
- context.scale(scale, scale);
915
+ canvas.style.width = `${width}px`, canvas.style.height = `${height}px`;
916
+ let scale = global.window.devicePixelRatio;
917
+ canvas.width = Math.floor(width * scale), canvas.height = Math.floor(height * scale), context.scale(scale, scale);
1233
918
  }
1234
- __name(setCanvasWidthAndHeight, "setCanvasWidthAndHeight");
1235
919
  var state2 = {};
1236
920
  function init() {
1237
- if (!state2.canvas) {
1238
- state2 = createCanvas();
1239
- }
921
+ state2.canvas || (state2 = createCanvas());
1240
922
  }
1241
- __name(init, "init");
1242
923
  function clear() {
1243
- if (state2.context) {
1244
- state2.context.clearRect(0, 0, state2.width ?? 0, state2.height ?? 0);
1245
- }
924
+ state2.context && state2.context.clearRect(0, 0, state2.width ?? 0, state2.height ?? 0);
1246
925
  }
1247
- __name(clear, "clear");
1248
926
  function draw(callback) {
1249
- clear();
1250
- callback(state2.context);
927
+ clear(), callback(state2.context);
1251
928
  }
1252
- __name(draw, "draw");
1253
929
  function rescale() {
1254
- invariant(state2.canvas, "Canvas should exist in the state.");
1255
- invariant(state2.context, "Context should exist in the state.");
1256
- setCanvasWidthAndHeight(state2.canvas, state2.context, { width: 0, height: 0 });
1257
- const { width, height } = getDocumentWidthAndHeight();
1258
- setCanvasWidthAndHeight(state2.canvas, state2.context, { width, height });
1259
- state2.width = width;
1260
- state2.height = height;
930
+ invariant(state2.canvas, "Canvas should exist in the state."), invariant(state2.context, "Context should exist in the state."), setCanvasWidthAndHeight(state2.canvas, state2.context, { width: 0, height: 0 });
931
+ let { width, height } = getDocumentWidthAndHeight();
932
+ setCanvasWidthAndHeight(state2.canvas, state2.context, { width, height }), state2.width = width, state2.height = height;
1261
933
  }
1262
- __name(rescale, "rescale");
1263
934
  function destroy() {
1264
- if (state2.canvas) {
1265
- clear();
1266
- state2.canvas.parentNode?.removeChild(state2.canvas);
1267
- state2 = {};
1268
- }
935
+ state2.canvas && (clear(), state2.canvas.parentNode?.removeChild(state2.canvas), state2 = {});
1269
936
  }
1270
- __name(destroy, "destroy");
1271
937
 
1272
938
  // src/measure/box-model/visualizer.ts
1273
939
  import { global as global2 } from "@storybook/global";
@@ -1279,189 +945,67 @@ var colors = {
1279
945
  padding: "#93c47d",
1280
946
  content: "#6fa8dc",
1281
947
  text: "#232020"
1282
- };
1283
- var labelPadding = 6;
948
+ }, labelPadding = 6;
1284
949
  function roundedRect(context, { x, y, w, h, r }) {
1285
- x = x - w / 2;
1286
- y = y - h / 2;
1287
- if (w < 2 * r) {
1288
- r = w / 2;
1289
- }
1290
- if (h < 2 * r) {
1291
- r = h / 2;
1292
- }
1293
- context.beginPath();
1294
- context.moveTo(x + r, y);
1295
- context.arcTo(x + w, y, x + w, y + h, r);
1296
- context.arcTo(x + w, y + h, x, y + h, r);
1297
- context.arcTo(x, y + h, x, y, r);
1298
- context.arcTo(x, y, x + w, y, r);
1299
- context.closePath();
950
+ x = x - w / 2, y = y - h / 2, w < 2 * r && (r = w / 2), h < 2 * r && (r = h / 2), context.beginPath(), context.moveTo(x + r, y), context.arcTo(x + w, y, x + w, y + h, r), context.arcTo(x + w, y + h, x, y + h, r), context.arcTo(x, y + h, x, y, r), context.arcTo(x, y, x + w, y, r), context.closePath();
1300
951
  }
1301
- __name(roundedRect, "roundedRect");
1302
952
  function positionCoordinate(position, { padding, border, width, height, top, left }) {
1303
- const contentWidth = width - border.left - border.right - padding.left - padding.right;
1304
- const contentHeight = height - padding.top - padding.bottom - border.top - border.bottom;
1305
- let x = left + border.left + padding.left;
1306
- let y = top + border.top + padding.top;
1307
- if (position === "top") {
1308
- x += contentWidth / 2;
1309
- } else if (position === "right") {
1310
- x += contentWidth;
1311
- y += contentHeight / 2;
1312
- } else if (position === "bottom") {
1313
- x += contentWidth / 2;
1314
- y += contentHeight;
1315
- } else if (position === "left") {
1316
- y += contentHeight / 2;
1317
- } else if (position === "center") {
1318
- x += contentWidth / 2;
1319
- y += contentHeight / 2;
1320
- }
1321
- return { x, y };
953
+ let contentWidth = width - border.left - border.right - padding.left - padding.right, contentHeight = height - padding.top - padding.bottom - border.top - border.bottom, x = left + border.left + padding.left, y = top + border.top + padding.top;
954
+ return position === "top" ? x += contentWidth / 2 : position === "right" ? (x += contentWidth, y += contentHeight / 2) : position === "bottom" ? (x += contentWidth / 2, y += contentHeight) : position === "left" ? y += contentHeight / 2 : position === "center" && (x += contentWidth / 2, y += contentHeight / 2), { x, y };
1322
955
  }
1323
- __name(positionCoordinate, "positionCoordinate");
1324
956
  function offset(type, position, { margin, border, padding }, labelPaddingSize, external) {
1325
- let shift = /* @__PURE__ */ __name((dir) => 0, "shift");
1326
- let offsetX = 0;
1327
- let offsetY = 0;
1328
- const locationMultiplier = external ? 1 : 0.5;
1329
- const labelPaddingShift = external ? labelPaddingSize * 2 : 0;
1330
- if (type === "padding") {
1331
- shift = /* @__PURE__ */ __name((dir) => padding[dir] * locationMultiplier + labelPaddingShift, "shift");
1332
- } else if (type === "border") {
1333
- shift = /* @__PURE__ */ __name((dir) => padding[dir] + border[dir] * locationMultiplier + labelPaddingShift, "shift");
1334
- } else if (type === "margin") {
1335
- shift = /* @__PURE__ */ __name((dir) => padding[dir] + border[dir] + margin[dir] * locationMultiplier + labelPaddingShift, "shift");
1336
- }
1337
- if (position === "top") {
1338
- offsetY = -shift("top");
1339
- } else if (position === "right") {
1340
- offsetX = shift("right");
1341
- } else if (position === "bottom") {
1342
- offsetY = shift("bottom");
1343
- } else if (position === "left") {
1344
- offsetX = -shift("left");
1345
- }
1346
- return { offsetX, offsetY };
957
+ let shift = (dir) => 0, offsetX = 0, offsetY = 0, locationMultiplier = external ? 1 : 0.5, labelPaddingShift = external ? labelPaddingSize * 2 : 0;
958
+ return type === "padding" ? shift = (dir) => padding[dir] * locationMultiplier + labelPaddingShift : type === "border" ? shift = (dir) => padding[dir] + border[dir] * locationMultiplier + labelPaddingShift : type === "margin" && (shift = (dir) => padding[dir] + border[dir] + margin[dir] * locationMultiplier + labelPaddingShift), position === "top" ? offsetY = -shift("top") : position === "right" ? offsetX = shift("right") : position === "bottom" ? offsetY = shift("bottom") : position === "left" && (offsetX = -shift("left")), { offsetX, offsetY };
1347
959
  }
1348
- __name(offset, "offset");
1349
960
  function collide(a, b) {
1350
961
  return Math.abs(a.x - b.x) < Math.abs(a.w + b.w) / 2 && Math.abs(a.y - b.y) < Math.abs(a.h + b.h) / 2;
1351
962
  }
1352
- __name(collide, "collide");
1353
963
  function overlapAdjustment(position, currentRect, prevRect) {
1354
- if (position === "top") {
1355
- currentRect.y = prevRect.y - prevRect.h - labelPadding;
1356
- } else if (position === "right") {
1357
- currentRect.x = prevRect.x + prevRect.w / 2 + labelPadding + currentRect.w / 2;
1358
- } else if (position === "bottom") {
1359
- currentRect.y = prevRect.y + prevRect.h + labelPadding;
1360
- } else if (position === "left") {
1361
- currentRect.x = prevRect.x - prevRect.w / 2 - labelPadding - currentRect.w / 2;
1362
- }
1363
- return { x: currentRect.x, y: currentRect.y };
964
+ return position === "top" ? currentRect.y = prevRect.y - prevRect.h - labelPadding : position === "right" ? currentRect.x = prevRect.x + prevRect.w / 2 + labelPadding + currentRect.w / 2 : position === "bottom" ? currentRect.y = prevRect.y + prevRect.h + labelPadding : position === "left" && (currentRect.x = prevRect.x - prevRect.w / 2 - labelPadding - currentRect.w / 2), { x: currentRect.x, y: currentRect.y };
1364
965
  }
1365
- __name(overlapAdjustment, "overlapAdjustment");
1366
966
  function textWithRect(context, type, { x, y, w, h }, text) {
1367
- roundedRect(context, { x, y, w, h, r: 3 });
1368
- context.fillStyle = `${colors[type]}dd`;
1369
- context.fill();
1370
- context.strokeStyle = colors[type];
1371
- context.stroke();
1372
- context.fillStyle = colors.text;
1373
- context.fillText(text, x, y);
1374
- roundedRect(context, { x, y, w, h, r: 3 });
1375
- context.fillStyle = `${colors[type]}dd`;
1376
- context.fill();
1377
- context.strokeStyle = colors[type];
1378
- context.stroke();
1379
- context.fillStyle = colors.text;
1380
- context.fillText(text, x, y);
1381
- return { x, y, w, h };
967
+ return roundedRect(context, { x, y, w, h, r: 3 }), context.fillStyle = `${colors[type]}dd`, context.fill(), context.strokeStyle = colors[type], context.stroke(), context.fillStyle = colors.text, context.fillText(text, x, y), roundedRect(context, { x, y, w, h, r: 3 }), context.fillStyle = `${colors[type]}dd`, context.fill(), context.strokeStyle = colors[type], context.stroke(), context.fillStyle = colors.text, context.fillText(text, x, y), { x, y, w, h };
1382
968
  }
1383
- __name(textWithRect, "textWithRect");
1384
969
  function configureText(context, text) {
1385
- context.font = "600 12px monospace";
1386
- context.textBaseline = "middle";
1387
- context.textAlign = "center";
1388
- const metrics = context.measureText(text);
1389
- const actualHeight = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent;
1390
- const w = metrics.width + labelPadding * 2;
1391
- const h = actualHeight + labelPadding * 2;
970
+ context.font = "600 12px monospace", context.textBaseline = "middle", context.textAlign = "center";
971
+ let metrics = context.measureText(text), actualHeight = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent, w = metrics.width + labelPadding * 2, h = actualHeight + labelPadding * 2;
1392
972
  return { w, h };
1393
973
  }
1394
- __name(configureText, "configureText");
1395
- function drawLabel(context, measurements, { type, position = "center", text }, prevRect, external = false) {
1396
- let { x, y } = positionCoordinate(position, measurements);
1397
- const { offsetX, offsetY } = offset(type, position, measurements, labelPadding + 1, external);
1398
- x += offsetX;
1399
- y += offsetY;
1400
- const { w, h } = configureText(context, text);
974
+ function drawLabel(context, measurements, { type, position = "center", text }, prevRect, external = !1) {
975
+ let { x, y } = positionCoordinate(position, measurements), { offsetX, offsetY } = offset(type, position, measurements, labelPadding + 1, external);
976
+ x += offsetX, y += offsetY;
977
+ let { w, h } = configureText(context, text);
1401
978
  if (prevRect && collide({ x, y, w, h }, prevRect)) {
1402
- const adjusted = overlapAdjustment(position, { x, y, w, h }, prevRect);
1403
- x = adjusted.x;
1404
- y = adjusted.y;
979
+ let adjusted = overlapAdjustment(position, { x, y, w, h }, prevRect);
980
+ x = adjusted.x, y = adjusted.y;
1405
981
  }
1406
982
  return textWithRect(context, type, { x, y, w, h }, text);
1407
983
  }
1408
- __name(drawLabel, "drawLabel");
1409
984
  function floatingOffset(alignment, { w, h }) {
1410
- const deltaW = w * 0.5 + labelPadding;
1411
- const deltaH = h * 0.5 + labelPadding;
985
+ let deltaW = w * 0.5 + labelPadding, deltaH = h * 0.5 + labelPadding;
1412
986
  return {
1413
987
  offsetX: (alignment.x === "left" ? -1 : 1) * deltaW,
1414
988
  offsetY: (alignment.y === "top" ? -1 : 1) * deltaH
1415
989
  };
1416
990
  }
1417
- __name(floatingOffset, "floatingOffset");
1418
991
  function drawFloatingLabel(context, measurements, { type, text }) {
1419
- const { floatingAlignment: floatingAlignment2, extremities } = measurements;
1420
- let x = extremities[floatingAlignment2.x];
1421
- let y = extremities[floatingAlignment2.y];
1422
- const { w, h } = configureText(context, text);
1423
- const { offsetX, offsetY } = floatingOffset(floatingAlignment2, {
992
+ let { floatingAlignment: floatingAlignment2, extremities } = measurements, x = extremities[floatingAlignment2.x], y = extremities[floatingAlignment2.y], { w, h } = configureText(context, text), { offsetX, offsetY } = floatingOffset(floatingAlignment2, {
1424
993
  w,
1425
994
  h
1426
995
  });
1427
- x += offsetX;
1428
- y += offsetY;
1429
- return textWithRect(context, type, { x, y, w, h }, text);
996
+ return x += offsetX, y += offsetY, textWithRect(context, type, { x, y, w, h }, text);
1430
997
  }
1431
- __name(drawFloatingLabel, "drawFloatingLabel");
1432
998
  function drawStack(context, measurements, stack, external) {
1433
- const rects = [];
999
+ let rects = [];
1434
1000
  stack.forEach((l, idx) => {
1435
- const rect = external && l.position === "center" ? drawFloatingLabel(context, measurements, l) : drawLabel(context, measurements, l, rects[idx - 1], external);
1001
+ let rect = external && l.position === "center" ? drawFloatingLabel(context, measurements, l) : drawLabel(context, measurements, l, rects[idx - 1], external);
1436
1002
  rects[idx] = rect;
1437
1003
  });
1438
1004
  }
1439
- __name(drawStack, "drawStack");
1440
1005
  function labelStacks(context, measurements, labels, externalLabels) {
1441
- const stacks = labels.reduce((acc, l) => {
1442
- if (!Object.prototype.hasOwnProperty.call(acc, l.position)) {
1443
- acc[l.position] = [];
1444
- }
1445
- acc[l.position]?.push(l);
1446
- return acc;
1447
- }, {});
1448
- if (stacks.top) {
1449
- drawStack(context, measurements, stacks.top, externalLabels);
1450
- }
1451
- if (stacks.right) {
1452
- drawStack(context, measurements, stacks.right, externalLabels);
1453
- }
1454
- if (stacks.bottom) {
1455
- drawStack(context, measurements, stacks.bottom, externalLabels);
1456
- }
1457
- if (stacks.left) {
1458
- drawStack(context, measurements, stacks.left, externalLabels);
1459
- }
1460
- if (stacks.center) {
1461
- drawStack(context, measurements, stacks.center, externalLabels);
1462
- }
1006
+ let stacks = labels.reduce((acc, l) => (Object.prototype.hasOwnProperty.call(acc, l.position) || (acc[l.position] = []), acc[l.position]?.push(l), acc), {});
1007
+ stacks.top && drawStack(context, measurements, stacks.top, externalLabels), stacks.right && drawStack(context, measurements, stacks.right, externalLabels), stacks.bottom && drawStack(context, measurements, stacks.bottom, externalLabels), stacks.left && drawStack(context, measurements, stacks.left, externalLabels), stacks.center && drawStack(context, measurements, stacks.center, externalLabels);
1463
1008
  }
1464
- __name(labelStacks, "labelStacks");
1465
1009
 
1466
1010
  // src/measure/box-model/visualizer.ts
1467
1011
  var colors2 = {
@@ -1469,28 +1013,23 @@ var colors2 = {
1469
1013
  border: "#ffe599a8",
1470
1014
  padding: "#93c47d8c",
1471
1015
  content: "#6fa8dca8"
1472
- };
1473
- var SMALL_NODE_SIZE = 30;
1016
+ }, SMALL_NODE_SIZE = 30;
1474
1017
  function pxToNumber(px) {
1475
1018
  return parseInt(px.replace("px", ""), 10);
1476
1019
  }
1477
- __name(pxToNumber, "pxToNumber");
1478
1020
  function round(value) {
1479
1021
  return Number.isInteger(value) ? value : value.toFixed(2);
1480
1022
  }
1481
- __name(round, "round");
1482
1023
  function filterZeroValues(labels) {
1483
1024
  return labels.filter((l) => l.text !== 0 && l.text !== "0");
1484
1025
  }
1485
- __name(filterZeroValues, "filterZeroValues");
1486
1026
  function floatingAlignment(extremities) {
1487
- const windowExtremities = {
1027
+ let windowExtremities = {
1488
1028
  top: global2.window.scrollY,
1489
1029
  bottom: global2.window.scrollY + global2.window.innerHeight,
1490
1030
  left: global2.window.scrollX,
1491
1031
  right: global2.window.scrollX + global2.window.innerWidth
1492
- };
1493
- const distances = {
1032
+ }, distances = {
1494
1033
  top: Math.abs(windowExtremities.top - extremities.top),
1495
1034
  bottom: Math.abs(windowExtremities.bottom - extremities.bottom),
1496
1035
  left: Math.abs(windowExtremities.left - extremities.left),
@@ -1501,11 +1040,8 @@ function floatingAlignment(extremities) {
1501
1040
  y: distances.top > distances.bottom ? "top" : "bottom"
1502
1041
  };
1503
1042
  }
1504
- __name(floatingAlignment, "floatingAlignment");
1505
1043
  function measureElement(element) {
1506
- const style = global2.getComputedStyle(element);
1507
- let { top, left, right, bottom, width, height } = element.getBoundingClientRect();
1508
- const {
1044
+ let style = global2.getComputedStyle(element), { top, left, right, bottom, width, height } = element.getBoundingClientRect(), {
1509
1045
  marginTop,
1510
1046
  marginBottom,
1511
1047
  marginLeft,
@@ -1519,29 +1055,23 @@ function measureElement(element) {
1519
1055
  borderLeftWidth,
1520
1056
  borderRightWidth
1521
1057
  } = style;
1522
- top = top + global2.window.scrollY;
1523
- left = left + global2.window.scrollX;
1524
- bottom = bottom + global2.window.scrollY;
1525
- right = right + global2.window.scrollX;
1526
- const margin = {
1058
+ top = top + global2.window.scrollY, left = left + global2.window.scrollX, bottom = bottom + global2.window.scrollY, right = right + global2.window.scrollX;
1059
+ let margin = {
1527
1060
  top: pxToNumber(marginTop),
1528
1061
  bottom: pxToNumber(marginBottom),
1529
1062
  left: pxToNumber(marginLeft),
1530
1063
  right: pxToNumber(marginRight)
1531
- };
1532
- const padding = {
1064
+ }, padding = {
1533
1065
  top: pxToNumber(paddingTop),
1534
1066
  bottom: pxToNumber(paddingBottom),
1535
1067
  left: pxToNumber(paddingLeft),
1536
1068
  right: pxToNumber(paddingRight)
1537
- };
1538
- const border = {
1069
+ }, border = {
1539
1070
  top: pxToNumber(borderTopWidth),
1540
1071
  bottom: pxToNumber(borderBottomWidth),
1541
1072
  left: pxToNumber(borderLeftWidth),
1542
1073
  right: pxToNumber(borderRightWidth)
1543
- };
1544
- const extremities = {
1074
+ }, extremities = {
1545
1075
  top: top - margin.top,
1546
1076
  bottom: bottom + margin.bottom,
1547
1077
  left: left - margin.left,
@@ -1561,15 +1091,10 @@ function measureElement(element) {
1561
1091
  floatingAlignment: floatingAlignment(extremities)
1562
1092
  };
1563
1093
  }
1564
- __name(measureElement, "measureElement");
1565
1094
  function drawMargin(context, { margin, width, height, top, left, bottom, right }) {
1566
- const marginHeight = height + margin.bottom + margin.top;
1567
- context.fillStyle = colors2.margin;
1568
- context.fillRect(left, top - margin.top, width, margin.top);
1569
- context.fillRect(right, top - margin.top, margin.right, marginHeight);
1570
- context.fillRect(left, bottom, width, margin.bottom);
1571
- context.fillRect(left - margin.left, top - margin.top, margin.left, marginHeight);
1572
- const marginLabels = [
1095
+ let marginHeight = height + margin.bottom + margin.top;
1096
+ context.fillStyle = colors2.margin, context.fillRect(left, top - margin.top, width, margin.top), context.fillRect(right, top - margin.top, margin.right, marginHeight), context.fillRect(left, bottom, width, margin.bottom), context.fillRect(left - margin.left, top - margin.top, margin.left, marginHeight);
1097
+ let marginLabels = [
1573
1098
  {
1574
1099
  type: "margin",
1575
1100
  text: round(margin.top),
@@ -1593,26 +1118,20 @@ function drawMargin(context, { margin, width, height, top, left, bottom, right }
1593
1118
  ];
1594
1119
  return filterZeroValues(marginLabels);
1595
1120
  }
1596
- __name(drawMargin, "drawMargin");
1597
1121
  function drawPadding(context, { padding, border, width, height, top, left, bottom, right }) {
1598
- const paddingWidth = width - border.left - border.right;
1599
- const paddingHeight = height - padding.top - padding.bottom - border.top - border.bottom;
1600
- context.fillStyle = colors2.padding;
1601
- context.fillRect(left + border.left, top + border.top, paddingWidth, padding.top);
1602
- context.fillRect(
1122
+ let paddingWidth = width - border.left - border.right, paddingHeight = height - padding.top - padding.bottom - border.top - border.bottom;
1123
+ context.fillStyle = colors2.padding, context.fillRect(left + border.left, top + border.top, paddingWidth, padding.top), context.fillRect(
1603
1124
  right - padding.right - border.right,
1604
1125
  top + padding.top + border.top,
1605
1126
  padding.right,
1606
1127
  paddingHeight
1607
- );
1608
- context.fillRect(
1128
+ ), context.fillRect(
1609
1129
  left + border.left,
1610
1130
  bottom - padding.bottom - border.bottom,
1611
1131
  paddingWidth,
1612
1132
  padding.bottom
1613
- );
1614
- context.fillRect(left + border.left, top + padding.top + border.top, padding.left, paddingHeight);
1615
- const paddingLabels = [
1133
+ ), context.fillRect(left + border.left, top + padding.top + border.top, padding.left, paddingHeight);
1134
+ let paddingLabels = [
1616
1135
  {
1617
1136
  type: "padding",
1618
1137
  text: padding.top,
@@ -1636,15 +1155,10 @@ function drawPadding(context, { padding, border, width, height, top, left, botto
1636
1155
  ];
1637
1156
  return filterZeroValues(paddingLabels);
1638
1157
  }
1639
- __name(drawPadding, "drawPadding");
1640
1158
  function drawBorder(context, { border, width, height, top, left, bottom, right }) {
1641
- const borderHeight = height - border.top - border.bottom;
1642
- context.fillStyle = colors2.border;
1643
- context.fillRect(left, top, width, border.top);
1644
- context.fillRect(left, bottom - border.bottom, width, border.bottom);
1645
- context.fillRect(left, top + border.top, border.left, borderHeight);
1646
- context.fillRect(right - border.right, top + border.top, border.right, borderHeight);
1647
- const borderLabels = [
1159
+ let borderHeight = height - border.top - border.bottom;
1160
+ context.fillStyle = colors2.border, context.fillRect(left, top, width, border.top), context.fillRect(left, bottom - border.bottom, width, border.bottom), context.fillRect(left, top + border.top, border.left, borderHeight), context.fillRect(right - border.right, top + border.top, border.right, borderHeight);
1161
+ let borderLabels = [
1648
1162
  {
1649
1163
  type: "border",
1650
1164
  text: border.top,
@@ -1668,18 +1182,14 @@ function drawBorder(context, { border, width, height, top, left, bottom, right }
1668
1182
  ];
1669
1183
  return filterZeroValues(borderLabels);
1670
1184
  }
1671
- __name(drawBorder, "drawBorder");
1672
1185
  function drawContent(context, { padding, border, width, height, top, left }) {
1673
- const contentWidth = width - border.left - border.right - padding.left - padding.right;
1674
- const contentHeight = height - padding.top - padding.bottom - border.top - border.bottom;
1675
- context.fillStyle = colors2.content;
1676
- context.fillRect(
1186
+ let contentWidth = width - border.left - border.right - padding.left - padding.right, contentHeight = height - padding.top - padding.bottom - border.top - border.bottom;
1187
+ return context.fillStyle = colors2.content, context.fillRect(
1677
1188
  left + border.left + padding.left,
1678
1189
  top + border.top + padding.top,
1679
1190
  contentWidth,
1680
1191
  contentHeight
1681
- );
1682
- return [
1192
+ ), [
1683
1193
  {
1684
1194
  type: "content",
1685
1195
  position: "center",
@@ -1687,16 +1197,10 @@ function drawContent(context, { padding, border, width, height, top, left }) {
1687
1197
  }
1688
1198
  ];
1689
1199
  }
1690
- __name(drawContent, "drawContent");
1691
1200
  function drawBoxModel(element) {
1692
1201
  return (context) => {
1693
1202
  if (element && context) {
1694
- const measurements = measureElement(element);
1695
- const marginLabels = drawMargin(context, measurements);
1696
- const paddingLabels = drawPadding(context, measurements);
1697
- const borderLabels = drawBorder(context, measurements);
1698
- const contentLabels = drawContent(context, measurements);
1699
- const externalLabels = measurements.width <= SMALL_NODE_SIZE * 3 || measurements.height <= SMALL_NODE_SIZE;
1203
+ let measurements = measureElement(element), marginLabels = drawMargin(context, measurements), paddingLabels = drawPadding(context, measurements), borderLabels = drawBorder(context, measurements), contentLabels = drawContent(context, measurements), externalLabels = measurements.width <= SMALL_NODE_SIZE * 3 || measurements.height <= SMALL_NODE_SIZE;
1700
1204
  labelStacks(
1701
1205
  context,
1702
1206
  measurements,
@@ -1706,94 +1210,64 @@ function drawBoxModel(element) {
1706
1210
  }
1707
1211
  };
1708
1212
  }
1709
- __name(drawBoxModel, "drawBoxModel");
1710
1213
  function drawSelectedElement(element) {
1711
1214
  draw(drawBoxModel(element));
1712
1215
  }
1713
- __name(drawSelectedElement, "drawSelectedElement");
1714
1216
 
1715
1217
  // src/measure/util.ts
1716
1218
  import { global as global3 } from "@storybook/global";
1717
- var deepElementFromPoint = /* @__PURE__ */ __name((x, y) => {
1718
- const element = global3.document.elementFromPoint(x, y);
1719
- const crawlShadows = /* @__PURE__ */ __name((node) => {
1219
+ var deepElementFromPoint = (x, y) => {
1220
+ let element = global3.document.elementFromPoint(x, y), crawlShadows = (node) => {
1720
1221
  if (node && node.shadowRoot) {
1721
- const nestedElement = node.shadowRoot.elementFromPoint(x, y);
1722
- if (node.isEqualNode(nestedElement)) {
1723
- return node;
1724
- }
1725
- if (nestedElement.shadowRoot) {
1726
- return crawlShadows(nestedElement);
1727
- }
1728
- return nestedElement;
1222
+ let nestedElement = node.shadowRoot.elementFromPoint(x, y);
1223
+ return node.isEqualNode(nestedElement) ? node : nestedElement.shadowRoot ? crawlShadows(nestedElement) : nestedElement;
1729
1224
  }
1730
1225
  return node;
1731
- }, "crawlShadows");
1732
- const shadowElement = crawlShadows(element);
1733
- return shadowElement || element;
1734
- }, "deepElementFromPoint");
1226
+ };
1227
+ return crawlShadows(element) || element;
1228
+ };
1735
1229
 
1736
1230
  // src/measure/withMeasure.ts
1737
- var nodeAtPointerRef;
1738
- var pointer = { x: 0, y: 0 };
1231
+ var nodeAtPointerRef, pointer = { x: 0, y: 0 };
1739
1232
  function findAndDrawElement(x, y) {
1740
- nodeAtPointerRef = deepElementFromPoint(x, y);
1741
- drawSelectedElement(nodeAtPointerRef);
1233
+ nodeAtPointerRef = deepElementFromPoint(x, y), drawSelectedElement(nodeAtPointerRef);
1742
1234
  }
1743
- __name(findAndDrawElement, "findAndDrawElement");
1744
- var withMeasure = /* @__PURE__ */ __name((StoryFn, context) => {
1745
- const { measureEnabled } = context.globals || {};
1746
- useEffect2(() => {
1747
- if (typeof globalThis.document === "undefined") {
1235
+ var withMeasure = (StoryFn, context) => {
1236
+ let { measureEnabled } = context.globals || {};
1237
+ return useEffect2(() => {
1238
+ if (typeof globalThis.document > "u")
1748
1239
  return;
1749
- }
1750
- const onPointerMove = /* @__PURE__ */ __name((event) => {
1240
+ let onPointerMove = (event) => {
1751
1241
  window.requestAnimationFrame(() => {
1752
- event.stopPropagation();
1753
- pointer.x = event.clientX;
1754
- pointer.y = event.clientY;
1242
+ event.stopPropagation(), pointer.x = event.clientX, pointer.y = event.clientY;
1755
1243
  });
1756
- }, "onPointerMove");
1757
- globalThis.document.addEventListener("pointermove", onPointerMove);
1758
- return () => {
1244
+ };
1245
+ return globalThis.document.addEventListener("pointermove", onPointerMove), () => {
1759
1246
  globalThis.document.removeEventListener("pointermove", onPointerMove);
1760
1247
  };
1761
- }, []);
1762
- useEffect2(() => {
1763
- const onPointerOver = /* @__PURE__ */ __name((event) => {
1248
+ }, []), useEffect2(() => {
1249
+ let onPointerOver = (event) => {
1764
1250
  window.requestAnimationFrame(() => {
1765
- event.stopPropagation();
1766
- findAndDrawElement(event.clientX, event.clientY);
1251
+ event.stopPropagation(), findAndDrawElement(event.clientX, event.clientY);
1767
1252
  });
1768
- }, "onPointerOver");
1769
- const onResize = /* @__PURE__ */ __name(() => {
1253
+ }, onResize = () => {
1770
1254
  window.requestAnimationFrame(() => {
1771
1255
  rescale();
1772
1256
  });
1773
- }, "onResize");
1774
- if (context.viewMode === "story" && measureEnabled) {
1775
- globalThis.document.addEventListener("pointerover", onPointerOver);
1776
- init();
1777
- globalThis.window.addEventListener("resize", onResize);
1778
- findAndDrawElement(pointer.x, pointer.y);
1779
- }
1780
- return () => {
1781
- globalThis.window.removeEventListener("resize", onResize);
1782
- destroy();
1783
1257
  };
1784
- }, [measureEnabled, context.viewMode]);
1785
- return StoryFn();
1786
- }, "withMeasure");
1258
+ return context.viewMode === "story" && measureEnabled && (globalThis.document.addEventListener("pointerover", onPointerOver), init(), globalThis.window.addEventListener("resize", onResize), findAndDrawElement(pointer.x, pointer.y)), () => {
1259
+ globalThis.window.removeEventListener("resize", onResize), destroy();
1260
+ };
1261
+ }, [measureEnabled, context.viewMode]), StoryFn();
1262
+ };
1787
1263
 
1788
1264
  // src/measure/preview.ts
1789
- var decorators2 = globalThis.FEATURES?.measure ? [withMeasure] : [];
1790
- var initialGlobals2 = {
1791
- [PARAM_KEY3]: false
1792
- };
1793
- var preview_default5 = /* @__PURE__ */ __name(() => definePreviewAddon5({
1265
+ var decorators2 = globalThis.FEATURES?.measure ? [withMeasure] : [], initialGlobals2 = {
1266
+ [PARAM_KEY3]: !1
1267
+ }, preview_default5 = () => definePreviewAddon5({
1794
1268
  decorators: decorators2,
1795
1269
  initialGlobals: initialGlobals2
1796
- }), "default");
1270
+ });
1797
1271
 
1798
1272
  // src/outline/preview.ts
1799
1273
  import { definePreviewAddon as definePreviewAddon6 } from "storybook/internal/csf";
@@ -1803,30 +1277,20 @@ import { useEffect as useEffect3, useMemo } from "storybook/preview-api";
1803
1277
 
1804
1278
  // src/outline/helpers.ts
1805
1279
  import { global as global4 } from "@storybook/global";
1806
- var clearStyles2 = /* @__PURE__ */ __name((selector) => {
1807
- const selectors = Array.isArray(selector) ? selector : [selector];
1808
- selectors.forEach(clearStyle2);
1809
- }, "clearStyles");
1810
- var clearStyle2 = /* @__PURE__ */ __name((input) => {
1811
- const selector = typeof input === "string" ? input : input.join("");
1812
- const element = global4.document.getElementById(selector);
1813
- if (element && element.parentElement) {
1814
- element.parentElement.removeChild(element);
1815
- }
1816
- }, "clearStyle");
1817
- var addOutlineStyles = /* @__PURE__ */ __name((selector, css) => {
1818
- const existingStyle = global4.document.getElementById(selector);
1819
- if (existingStyle) {
1820
- if (existingStyle.innerHTML !== css) {
1821
- existingStyle.innerHTML = css;
1822
- }
1823
- } else {
1824
- const style = global4.document.createElement("style");
1825
- style.setAttribute("id", selector);
1826
- style.innerHTML = css;
1827
- global4.document.head.appendChild(style);
1280
+ var clearStyles2 = (selector) => {
1281
+ (Array.isArray(selector) ? selector : [selector]).forEach(clearStyle2);
1282
+ }, clearStyle2 = (input) => {
1283
+ let selector = typeof input == "string" ? input : input.join(""), element = global4.document.getElementById(selector);
1284
+ element && element.parentElement && element.parentElement.removeChild(element);
1285
+ }, addOutlineStyles = (selector, css) => {
1286
+ let existingStyle = global4.document.getElementById(selector);
1287
+ if (existingStyle)
1288
+ existingStyle.innerHTML !== css && (existingStyle.innerHTML = css);
1289
+ else {
1290
+ let style = global4.document.createElement("style");
1291
+ style.setAttribute("id", selector), style.innerHTML = css, global4.document.head.appendChild(style);
1828
1292
  }
1829
- }, "addOutlineStyles");
1293
+ };
1830
1294
 
1831
1295
  // src/outline/outlineCSS.ts
1832
1296
  function outlineCSS(selector) {
@@ -2227,37 +1691,22 @@ function outlineCSS(selector) {
2227
1691
  outline: 1px solid #db175b !important;
2228
1692
  }`;
2229
1693
  }
2230
- __name(outlineCSS, "outlineCSS");
2231
1694
 
2232
1695
  // src/outline/withOutline.ts
2233
- var withOutline = /* @__PURE__ */ __name((StoryFn, context) => {
2234
- const globals = context.globals || {};
2235
- const isActive = [true, "true"].includes(globals[PARAM_KEY4]);
2236
- const isInDocs = context.viewMode === "docs";
2237
- const outlineStyles = useMemo(() => {
2238
- const selector = isInDocs ? `[data-story-block="true"]` : ".sb-show-main";
2239
- return outlineCSS(selector);
2240
- }, [context]);
2241
- useEffect3(() => {
2242
- const selectorId = isInDocs ? `addon-outline-docs-${context.id}` : `addon-outline`;
2243
- if (!isActive) {
2244
- clearStyles2(selectorId);
2245
- } else {
2246
- addOutlineStyles(selectorId, outlineStyles);
2247
- }
2248
- return () => {
1696
+ var withOutline = (StoryFn, context) => {
1697
+ let globals = context.globals || {}, isActive = [!0, "true"].includes(globals[PARAM_KEY4]), isInDocs = context.viewMode === "docs", outlineStyles = useMemo(() => outlineCSS(isInDocs ? '[data-story-block="true"]' : ".sb-show-main"), [context]);
1698
+ return useEffect3(() => {
1699
+ let selectorId = isInDocs ? `addon-outline-docs-${context.id}` : "addon-outline";
1700
+ return isActive ? addOutlineStyles(selectorId, outlineStyles) : clearStyles2(selectorId), () => {
2249
1701
  clearStyles2(selectorId);
2250
1702
  };
2251
- }, [isActive, outlineStyles, context]);
2252
- return StoryFn();
2253
- }, "withOutline");
1703
+ }, [isActive, outlineStyles, context]), StoryFn();
1704
+ };
2254
1705
 
2255
1706
  // src/outline/preview.ts
2256
- var decorators3 = globalThis.FEATURES?.outline ? [withOutline] : [];
2257
- var initialGlobals3 = {
2258
- [PARAM_KEY4]: false
2259
- };
2260
- var preview_default6 = /* @__PURE__ */ __name(() => definePreviewAddon6({ decorators: decorators3, initialGlobals: initialGlobals3 }), "default");
1707
+ var decorators3 = globalThis.FEATURES?.outline ? [withOutline] : [], initialGlobals3 = {
1708
+ [PARAM_KEY4]: !1
1709
+ }, preview_default6 = () => definePreviewAddon6({ decorators: decorators3, initialGlobals: initialGlobals3 });
2261
1710
 
2262
1711
  // src/test/preview.ts
2263
1712
  import { definePreviewAddon as definePreviewAddon7 } from "storybook/internal/csf";
@@ -2271,112 +1720,69 @@ import {
2271
1720
  uninstrumentedUserEvent,
2272
1721
  within
2273
1722
  } from "storybook/test";
2274
- var resetAllMocksLoader = /* @__PURE__ */ __name(({ parameters: parameters2 }) => {
2275
- if (parameters2?.test?.mockReset === true) {
2276
- resetAllMocks();
2277
- } else if (parameters2?.test?.clearMocks === true) {
2278
- clearAllMocks();
2279
- } else if (parameters2?.test?.restoreMocks !== false) {
2280
- restoreAllMocks();
2281
- }
2282
- }, "resetAllMocksLoader");
2283
- var traverseArgs = /* @__PURE__ */ __name((value, depth = 0, key) => {
2284
- if (depth > 5) {
2285
- return value;
2286
- }
2287
- if (value == null) {
2288
- return value;
2289
- }
2290
- if (isMockFunction(value)) {
2291
- if (key) {
2292
- value.mockName(key);
2293
- }
1723
+ var resetAllMocksLoader = ({ parameters: parameters2 }) => {
1724
+ parameters2?.test?.mockReset === !0 ? resetAllMocks() : parameters2?.test?.clearMocks === !0 ? clearAllMocks() : parameters2?.test?.restoreMocks !== !1 && restoreAllMocks();
1725
+ }, traverseArgs = (value, depth = 0, key) => {
1726
+ if (depth > 5 || value == null)
2294
1727
  return value;
2295
- }
2296
- if (typeof value === "function" && "isAction" in value && value.isAction && !("implicit" in value && value.implicit)) {
2297
- const mock = fn(value);
2298
- if (key) {
2299
- mock.mockName(key);
2300
- }
2301
- return mock;
1728
+ if (isMockFunction(value))
1729
+ return key && value.mockName(key), value;
1730
+ if (typeof value == "function" && "isAction" in value && value.isAction && !("implicit" in value && value.implicit)) {
1731
+ let mock = fn(value);
1732
+ return key && mock.mockName(key), mock;
2302
1733
  }
2303
1734
  if (Array.isArray(value)) {
2304
1735
  depth++;
2305
- for (let i = 0; i < value.length; i++) {
2306
- if (Object.getOwnPropertyDescriptor(value, i)?.writable) {
2307
- value[i] = traverseArgs(value[i], depth);
2308
- }
2309
- }
1736
+ for (let i = 0; i < value.length; i++)
1737
+ Object.getOwnPropertyDescriptor(value, i)?.writable && (value[i] = traverseArgs(value[i], depth));
2310
1738
  return value;
2311
1739
  }
2312
- if (typeof value === "object" && value.constructor === Object) {
1740
+ if (typeof value == "object" && value.constructor === Object) {
2313
1741
  depth++;
2314
- for (const [k, v] of Object.entries(value)) {
2315
- if (Object.getOwnPropertyDescriptor(value, k)?.writable) {
2316
- value[k] = traverseArgs(v, depth, k);
2317
- }
2318
- }
1742
+ for (let [k, v] of Object.entries(value))
1743
+ Object.getOwnPropertyDescriptor(value, k)?.writable && (value[k] = traverseArgs(v, depth, k));
2319
1744
  return value;
2320
1745
  }
2321
1746
  return value;
2322
- }, "traverseArgs");
2323
- var nameSpiesAndWrapActionsInSpies = /* @__PURE__ */ __name(({ initialArgs }) => {
1747
+ }, nameSpiesAndWrapActionsInSpies = ({ initialArgs }) => {
2324
1748
  traverseArgs(initialArgs);
2325
- }, "nameSpiesAndWrapActionsInSpies");
2326
- var patchedFocus = false;
2327
- var enhanceContext = /* @__PURE__ */ __name(async (context) => {
2328
- if (globalThis.HTMLElement && context.canvasElement instanceof globalThis.HTMLElement) {
2329
- context.canvas = within(context.canvasElement);
2330
- }
2331
- const clipboard = globalThis.window?.navigator?.clipboard;
2332
- if (clipboard) {
2333
- context.userEvent = instrument2(
2334
- { userEvent: uninstrumentedUserEvent.setup() },
2335
- {
2336
- intercept: true,
2337
- getKeys: /* @__PURE__ */ __name((obj) => Object.keys(obj).filter((key) => key !== "eventWrapper"), "getKeys")
2338
- }
2339
- ).userEvent;
2340
- Object.defineProperty(globalThis.window.navigator, "clipboard", {
2341
- get: /* @__PURE__ */ __name(() => clipboard, "get"),
2342
- configurable: true
2343
- });
2344
- if (!patchedFocus) {
2345
- const originalFocus = HTMLElement.prototype.focus;
2346
- let currentFocus = HTMLElement.prototype.focus;
2347
- const focusingElements = /* @__PURE__ */ new Set();
2348
- Object.defineProperties(HTMLElement.prototype, {
2349
- focus: {
2350
- configurable: true,
2351
- set: /* @__PURE__ */ __name((newFocus) => {
2352
- currentFocus = newFocus;
2353
- }, "set"),
2354
- get() {
2355
- if (focusingElements.has(this)) {
2356
- return originalFocus;
2357
- }
2358
- focusingElements.add(this);
2359
- setTimeout(() => focusingElements.delete(this), 0);
2360
- return currentFocus;
2361
- }
1749
+ }, patchedFocus = !1, enhanceContext = async (context) => {
1750
+ globalThis.HTMLElement && context.canvasElement instanceof globalThis.HTMLElement && (context.canvas = within(context.canvasElement));
1751
+ let clipboard = globalThis.window?.navigator?.clipboard;
1752
+ if (clipboard && (context.userEvent = instrument2(
1753
+ { userEvent: uninstrumentedUserEvent.setup() },
1754
+ {
1755
+ intercept: !0,
1756
+ getKeys: (obj) => Object.keys(obj).filter((key) => key !== "eventWrapper")
1757
+ }
1758
+ ).userEvent, Object.defineProperty(globalThis.window.navigator, "clipboard", {
1759
+ get: () => clipboard,
1760
+ configurable: !0
1761
+ }), !patchedFocus)) {
1762
+ let originalFocus = HTMLElement.prototype.focus, currentFocus = HTMLElement.prototype.focus, focusingElements = /* @__PURE__ */ new Set();
1763
+ Object.defineProperties(HTMLElement.prototype, {
1764
+ focus: {
1765
+ configurable: !0,
1766
+ set: (newFocus) => {
1767
+ currentFocus = newFocus;
1768
+ },
1769
+ get() {
1770
+ return focusingElements.has(this) ? originalFocus : (focusingElements.add(this), setTimeout(() => focusingElements.delete(this), 0), currentFocus);
2362
1771
  }
2363
- });
2364
- patchedFocus = true;
2365
- }
1772
+ }
1773
+ }), patchedFocus = !0;
2366
1774
  }
2367
- }, "enhanceContext");
2368
- var preview_default7 = /* @__PURE__ */ __name(() => definePreviewAddon7({
1775
+ }, preview_default7 = () => definePreviewAddon7({
2369
1776
  loaders: [resetAllMocksLoader, nameSpiesAndWrapActionsInSpies, enhanceContext]
2370
- }), "default");
1777
+ });
2371
1778
 
2372
1779
  // src/viewport/preview.ts
2373
1780
  import { definePreviewAddon as definePreviewAddon8 } from "storybook/internal/csf";
2374
1781
  var initialGlobals4 = {
2375
- [PARAM_KEY]: { value: void 0, isRotated: false }
2376
- };
2377
- var preview_default8 = /* @__PURE__ */ __name(() => definePreviewAddon8({
1782
+ [PARAM_KEY]: { value: void 0, isRotated: !1 }
1783
+ }, preview_default8 = () => definePreviewAddon8({
2378
1784
  initialGlobals: initialGlobals4
2379
- }), "default");
1785
+ });
2380
1786
 
2381
1787
  // src/csf/core-annotations.ts
2382
1788
  function getCoreAnnotations() {
@@ -2399,44 +1805,35 @@ function getCoreAnnotations() {
2399
1805
  (preview_default7.default ?? preview_default7)()
2400
1806
  ];
2401
1807
  }
2402
- __name(getCoreAnnotations, "getCoreAnnotations");
2403
1808
 
2404
1809
  // src/csf/csf-factories.ts
2405
1810
  function definePreview(input) {
2406
- let composed;
2407
- const preview = {
1811
+ let composed, preview = {
2408
1812
  _tag: "Preview",
2409
1813
  input,
2410
1814
  get composed() {
2411
- if (composed) {
1815
+ if (composed)
2412
1816
  return composed;
2413
- }
2414
- const { addons: addons2, ...rest } = input;
2415
- composed = normalizeProjectAnnotations(
1817
+ let { addons: addons2, ...rest } = input;
1818
+ return composed = normalizeProjectAnnotations(
2416
1819
  composeConfigs([...getCoreAnnotations(), ...addons2 ?? [], rest])
2417
- );
2418
- return composed;
1820
+ ), composed;
2419
1821
  },
2420
1822
  meta(meta) {
2421
1823
  return defineMeta(meta, this);
2422
1824
  }
2423
1825
  };
2424
- globalThis.globalProjectAnnotations = preview.composed;
2425
- return preview;
1826
+ return globalThis.globalProjectAnnotations = preview.composed, preview;
2426
1827
  }
2427
- __name(definePreview, "definePreview");
2428
1828
  function definePreviewAddon9(preview) {
2429
1829
  return preview;
2430
1830
  }
2431
- __name(definePreviewAddon9, "definePreviewAddon");
2432
1831
  function isPreview(input) {
2433
- return input != null && typeof input === "object" && "_tag" in input && input?._tag === "Preview";
1832
+ return input != null && typeof input == "object" && "_tag" in input && input?._tag === "Preview";
2434
1833
  }
2435
- __name(isPreview, "isPreview");
2436
1834
  function isMeta(input) {
2437
- return input != null && typeof input === "object" && "_tag" in input && input?._tag === "Meta";
1835
+ return input != null && typeof input == "object" && "_tag" in input && input?._tag === "Meta";
2438
1836
  }
2439
- __name(isMeta, "isMeta");
2440
1837
  function defineMeta(input, preview) {
2441
1838
  return {
2442
1839
  _tag: "Meta",
@@ -2444,29 +1841,20 @@ function defineMeta(input, preview) {
2444
1841
  preview,
2445
1842
  // @ts-expect-error hard
2446
1843
  story(story = {}) {
2447
- return defineStory(typeof story === "function" ? { render: story } : story, this);
1844
+ return defineStory(typeof story == "function" ? { render: story } : story, this);
2448
1845
  }
2449
1846
  };
2450
1847
  }
2451
- __name(defineMeta, "defineMeta");
2452
1848
  function isStory(input) {
2453
- return input != null && typeof input === "object" && "_tag" in input && input?._tag === "Story";
1849
+ return input != null && typeof input == "object" && "_tag" in input && input?._tag === "Story";
2454
1850
  }
2455
- __name(isStory, "isStory");
2456
1851
  function defineStory(input, meta) {
2457
- let composed;
2458
- const compose = /* @__PURE__ */ __name(() => {
2459
- if (!composed) {
2460
- composed = composeStory(
2461
- input,
2462
- meta.input,
2463
- void 0,
2464
- meta.preview.composed
2465
- );
2466
- }
2467
- return composed;
2468
- }, "compose");
2469
- const __children = [];
1852
+ let composed, compose = () => (composed || (composed = composeStory(
1853
+ input,
1854
+ meta.input,
1855
+ void 0,
1856
+ meta.preview.composed
1857
+ )), composed), __children = [];
2470
1858
  return {
2471
1859
  _tag: "Story",
2472
1860
  input,
@@ -2475,8 +1863,7 @@ function defineStory(input, meta) {
2475
1863
  __compose: compose,
2476
1864
  __children,
2477
1865
  get composed() {
2478
- const composed2 = compose();
2479
- const { args, argTypes, parameters: parameters2, id, tags, globals, storyName: name } = composed2;
1866
+ let composed2 = compose(), { args, argTypes, parameters: parameters2, id, tags, globals, storyName: name } = composed2;
2480
1867
  return { args, argTypes, parameters: parameters2, id, tags, name, globals };
2481
1868
  },
2482
1869
  get play() {
@@ -2487,23 +1874,17 @@ function defineStory(input, meta) {
2487
1874
  await compose().run(context);
2488
1875
  },
2489
1876
  test(name, overridesOrTestFn, testFn) {
2490
- const annotations = typeof overridesOrTestFn !== "function" ? overridesOrTestFn : {};
2491
- const testFunction = typeof overridesOrTestFn !== "function" ? testFn : overridesOrTestFn;
2492
- const play = mountDestructured(this.play) || mountDestructured(testFunction) ? async ({ context }) => {
2493
- await this.play?.(context);
2494
- await testFunction(context);
1877
+ let annotations = typeof overridesOrTestFn != "function" ? overridesOrTestFn : {}, testFunction = typeof overridesOrTestFn != "function" ? testFn : overridesOrTestFn, play = mountDestructured(this.play) || mountDestructured(testFunction) ? async ({ context }) => {
1878
+ await this.play?.(context), await testFunction(context);
2495
1879
  } : async (context) => {
2496
- await this.play?.(context);
2497
- await testFunction(context);
2498
- };
2499
- const test = this.extend({
1880
+ await this.play?.(context), await testFunction(context);
1881
+ }, test = this.extend({
2500
1882
  ...annotations,
2501
1883
  name,
2502
1884
  tags: ["test-fn", "!autodocs", ...annotations.tags ?? []],
2503
1885
  play
2504
1886
  });
2505
- __children.push(test);
2506
- return test;
1887
+ return __children.push(test), test;
2507
1888
  },
2508
1889
  extend(input2) {
2509
1890
  return defineStory(
@@ -2537,62 +1918,36 @@ function defineStory(input, meta) {
2537
1918
  }
2538
1919
  };
2539
1920
  }
2540
- __name(defineStory, "defineStory");
2541
1921
  function getStoryChildren(story) {
2542
- if ("__children" in story) {
2543
- return story.__children;
2544
- }
2545
- return [];
1922
+ return "__children" in story ? story.__children : [];
2546
1923
  }
2547
- __name(getStoryChildren, "getStoryChildren");
2548
1924
 
2549
1925
  // src/csf/index.ts
2550
- var sanitize = /* @__PURE__ */ __name((string) => {
2551
- return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
2552
- }, "sanitize");
2553
- var sanitizeSafe = /* @__PURE__ */ __name((string, part) => {
2554
- const sanitized = sanitize(string);
2555
- if (sanitized === "") {
1926
+ var sanitize = (string) => string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, ""), sanitizeSafe = (string, part) => {
1927
+ let sanitized = sanitize(string);
1928
+ if (sanitized === "")
2556
1929
  throw new Error(`Invalid ${part} '${string}', must include alphanumeric characters`);
2557
- }
2558
1930
  return sanitized;
2559
- }, "sanitizeSafe");
2560
- var toId = /* @__PURE__ */ __name((kind, name) => `${sanitizeSafe(kind, "kind")}${name ? `--${sanitizeSafe(name, "name")}` : ""}`, "toId");
2561
- var toTestId = /* @__PURE__ */ __name((parentId, testName) => `${parentId}:${sanitizeSafe(testName, "test")}`, "toTestId");
2562
- var storyNameFromExport = /* @__PURE__ */ __name((key) => toStartCaseStr(key), "storyNameFromExport");
1931
+ }, toId = (kind, name) => `${sanitizeSafe(kind, "kind")}${name ? `--${sanitizeSafe(name, "name")}` : ""}`, toTestId = (parentId, testName) => `${parentId}:${sanitizeSafe(testName, "test")}`, storyNameFromExport = (key) => toStartCaseStr(key);
2563
1932
  function matches(storyKey, arrayOrRegex) {
2564
- if (Array.isArray(arrayOrRegex)) {
2565
- return arrayOrRegex.includes(storyKey);
2566
- }
2567
- return storyKey.match(arrayOrRegex);
1933
+ return Array.isArray(arrayOrRegex) ? arrayOrRegex.includes(storyKey) : storyKey.match(arrayOrRegex);
2568
1934
  }
2569
- __name(matches, "matches");
2570
1935
  function isExportStory(key, { includeStories, excludeStories }) {
2571
1936
  return (
2572
1937
  // https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs
2573
1938
  key !== "__esModule" && (!includeStories || matches(key, includeStories)) && (!excludeStories || !matches(key, excludeStories))
2574
1939
  );
2575
1940
  }
2576
- __name(isExportStory, "isExportStory");
2577
- var parseKind = /* @__PURE__ */ __name((kind, { rootSeparator, groupSeparator }) => {
2578
- const [root, remainder] = kind.split(rootSeparator, 2);
2579
- const groups = (remainder || kind).split(groupSeparator).filter((i) => !!i);
1941
+ var parseKind = (kind, { rootSeparator, groupSeparator }) => {
1942
+ let [root, remainder] = kind.split(rootSeparator, 2), groups = (remainder || kind).split(groupSeparator).filter((i) => !!i);
2580
1943
  return {
2581
1944
  root: remainder ? root : null,
2582
1945
  groups
2583
1946
  };
2584
- }, "parseKind");
2585
- var combineTags2 = /* @__PURE__ */ __name((...tags) => {
2586
- const result = tags.reduce((acc, tag) => {
2587
- if (tag.startsWith("!")) {
2588
- acc.delete(tag.slice(1));
2589
- } else {
2590
- acc.add(tag);
2591
- }
2592
- return acc;
2593
- }, /* @__PURE__ */ new Set());
1947
+ }, combineTags2 = (...tags) => {
1948
+ let result = tags.reduce((acc, tag) => (tag.startsWith("!") ? acc.delete(tag.slice(1)) : acc.add(tag), acc), /* @__PURE__ */ new Set());
2594
1949
  return Array.from(result);
2595
- }, "combineTags");
1950
+ };
2596
1951
  export {
2597
1952
  combineTags2 as combineTags,
2598
1953
  definePreview,