storybook 9.0.0-alpha.1 → 9.0.0-alpha.10

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 (259) hide show
  1. package/README.md +31 -29
  2. package/assets/browser/favicon.svg +1 -0
  3. package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
  4. package/assets/browser/nunito-sans-bold.woff2 +0 -0
  5. package/assets/browser/nunito-sans-italic.woff2 +0 -0
  6. package/assets/browser/nunito-sans-regular.woff2 +0 -0
  7. package/assets/docs/addon-controls-args-annotated.png +0 -0
  8. package/assets/docs/addon-controls-args-background-color.png +0 -0
  9. package/assets/docs/addon-controls-args-background-string.png +0 -0
  10. package/assets/docs/addon-controls-args-docs.png +0 -0
  11. package/assets/docs/addon-controls-args-logging.png +0 -0
  12. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  13. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  14. package/assets/docs/addon-controls-args-reflow.png +0 -0
  15. package/assets/docs/addon-controls-args-template.png +0 -0
  16. package/assets/docs/addon-controls-expanded.png +0 -0
  17. package/assets/docs/addon-controls-hero.gif +0 -0
  18. package/assets/docs/addon-controls-install.png +0 -0
  19. package/assets/docs/hero.gif +0 -0
  20. package/assets/docs/message-reference.png +0 -0
  21. package/assets/docs/viewport.png +0 -0
  22. package/assets/server/addon.tsconfig.json +6 -0
  23. package/assets/server/base-preview-body.html +119 -0
  24. package/assets/server/base-preview-head.html +451 -0
  25. package/assets/server/template.ejs +87 -0
  26. package/bin/index.cjs +1 -1
  27. package/dist/actions/decorator.d.ts +6 -0
  28. package/dist/actions/decorator.js +139 -0
  29. package/dist/actions/index.cjs +127 -0
  30. package/dist/actions/index.d.ts +105 -0
  31. package/dist/actions/index.js +112 -0
  32. package/dist/actions/manager.js +1196 -0
  33. package/dist/actions/preview.cjs +165 -0
  34. package/dist/actions/preview.d.ts +55 -0
  35. package/dist/actions/preview.js +156 -0
  36. package/dist/babel/index.cjs +54034 -0
  37. package/dist/babel/index.d.ts +7488 -0
  38. package/dist/babel/index.js +54044 -0
  39. package/dist/bin/index.cjs +119 -0
  40. package/dist/bin/index.js +113 -0
  41. package/dist/builder-manager/index.cjs +2140 -0
  42. package/dist/builder-manager/index.d.ts +19 -0
  43. package/dist/builder-manager/index.js +2162 -0
  44. package/dist/channels/index.cjs +1913 -0
  45. package/dist/channels/index.d.ts +108 -0
  46. package/dist/channels/index.js +1881 -0
  47. package/dist/cli/bin/index.cjs +2687 -0
  48. package/dist/cli/bin/index.d.ts +2 -0
  49. package/dist/cli/bin/index.js +2707 -0
  50. package/dist/cli/index.cjs +17327 -0
  51. package/dist/cli/index.d.ts +209 -0
  52. package/dist/cli/index.js +17349 -0
  53. package/dist/client-logger/index.cjs +80 -0
  54. package/dist/client-logger/index.d.ts +29 -0
  55. package/dist/client-logger/index.js +64 -0
  56. package/dist/common/index.cjs +20569 -0
  57. package/dist/common/index.d.ts +949 -0
  58. package/dist/common/index.js +20654 -0
  59. package/dist/components/index.cjs +27924 -0
  60. package/dist/components/index.d.ts +1423 -0
  61. package/dist/components/index.js +24673 -0
  62. package/dist/controls/decorator.d.ts +5 -0
  63. package/dist/controls/decorator.js +8 -0
  64. package/dist/controls/index.cjs +26 -0
  65. package/dist/controls/index.d.ts +39 -0
  66. package/dist/controls/index.js +6 -0
  67. package/dist/controls/manager.js +5545 -0
  68. package/dist/controls/preview.cjs +26 -0
  69. package/dist/controls/preview.d.ts +55 -0
  70. package/dist/controls/preview.js +9 -0
  71. package/dist/core-events/index.cjs +167 -0
  72. package/dist/core-events/index.d.ts +426 -0
  73. package/dist/core-events/index.js +149 -0
  74. package/dist/core-server/index.cjs +38183 -0
  75. package/dist/core-server/index.d.ts +720 -0
  76. package/dist/core-server/index.js +38272 -0
  77. package/dist/core-server/presets/common-manager.js +20 -0
  78. package/dist/core-server/presets/common-override-preset.cjs +4824 -0
  79. package/dist/core-server/presets/common-override-preset.js +4829 -0
  80. package/dist/core-server/presets/common-preset.cjs +10231 -0
  81. package/dist/core-server/presets/common-preset.js +10309 -0
  82. package/dist/csf/index.cjs +179 -0
  83. package/dist/csf/index.d.ts +750 -0
  84. package/dist/csf/index.js +172 -0
  85. package/dist/csf-tools/index.cjs +1422 -0
  86. package/dist/csf-tools/index.d.ts +250 -0
  87. package/dist/csf-tools/index.js +1439 -0
  88. package/dist/docs-tools/index.cjs +2891 -0
  89. package/dist/docs-tools/index.d.ts +162 -0
  90. package/dist/docs-tools/index.js +2876 -0
  91. package/dist/index.cjs +17 -1
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.js +2 -7
  94. package/dist/instrumenter/index.cjs +3485 -0
  95. package/dist/instrumenter/index.d.ts +104 -0
  96. package/dist/instrumenter/index.js +4965 -0
  97. package/dist/manager/globals-module-info.cjs +817 -0
  98. package/dist/manager/globals-module-info.d.ts +36 -0
  99. package/dist/manager/globals-module-info.js +804 -0
  100. package/dist/manager/globals-runtime.js +77536 -0
  101. package/dist/manager/globals.cjs +47 -0
  102. package/dist/manager/globals.d.ts +24 -0
  103. package/dist/manager/globals.js +34 -0
  104. package/dist/manager/runtime.js +12323 -0
  105. package/dist/manager-api/index.cjs +11074 -0
  106. package/dist/manager-api/index.d.ts +1512 -0
  107. package/dist/manager-api/index.js +4835 -0
  108. package/dist/manager-errors.d.ts +89 -0
  109. package/dist/manager-errors.js +99 -0
  110. package/dist/node-logger/index.cjs +1642 -0
  111. package/dist/node-logger/index.d.ts +117 -0
  112. package/dist/node-logger/index.js +1652 -0
  113. package/dist/preview/globals.cjs +38 -0
  114. package/dist/preview/globals.d.ts +15 -0
  115. package/dist/preview/globals.js +25 -0
  116. package/dist/preview/runtime.js +43629 -0
  117. package/dist/preview-api/index.cjs +5224 -0
  118. package/dist/preview-api/index.d.ts +1093 -0
  119. package/dist/preview-api/index.js +5292 -0
  120. package/dist/preview-errors.cjs +503 -0
  121. package/dist/preview-errors.d.ts +212 -0
  122. package/dist/preview-errors.js +449 -0
  123. package/dist/router/index.cjs +3296 -0
  124. package/dist/router/index.d.ts +385 -0
  125. package/dist/router/index.js +1843 -0
  126. package/dist/server-errors.cjs +727 -0
  127. package/dist/server-errors.d.ts +296 -0
  128. package/dist/server-errors.js +728 -0
  129. package/dist/telemetry/index.cjs +2756 -0
  130. package/dist/telemetry/index.d.ts +133 -0
  131. package/dist/telemetry/index.js +2797 -0
  132. package/dist/test/index.cjs +35685 -0
  133. package/dist/test/index.d.ts +186 -0
  134. package/dist/test/index.js +33751 -0
  135. package/dist/test/preview.cjs +15869 -0
  136. package/dist/test/preview.d.ts +54 -0
  137. package/dist/test/preview.js +14440 -0
  138. package/dist/test/spy.cjs +257 -0
  139. package/dist/test/spy.d.ts +66 -0
  140. package/dist/test/spy.js +239 -0
  141. package/dist/theming/create.cjs +232 -0
  142. package/dist/theming/create.d.ts +50 -0
  143. package/dist/theming/create.js +216 -0
  144. package/dist/theming/index.cjs +2665 -0
  145. package/dist/theming/index.d.ts +11939 -0
  146. package/dist/theming/index.js +2485 -0
  147. package/dist/types/index.cjs +27 -0
  148. package/dist/types/index.d.ts +2795 -0
  149. package/dist/types/index.js +7 -0
  150. package/dist/viewport/index.cjs +310 -0
  151. package/dist/viewport/index.d.ts +320 -0
  152. package/dist/viewport/index.js +290 -0
  153. package/dist/viewport/manager.js +400 -0
  154. package/dist/viewport/preview.cjs +35 -0
  155. package/dist/viewport/preview.d.ts +69 -0
  156. package/dist/viewport/preview.js +19 -0
  157. package/package.json +518 -209
  158. package/.eslintrc.cjs +0 -31
  159. package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
  160. package/core/babel/index.cjs +0 -1
  161. package/core/babel/index.d.ts +0 -2
  162. package/core/babel/index.js +0 -1
  163. package/core/builder-manager/index.cjs +0 -1
  164. package/core/builder-manager/index.d.ts +0 -2
  165. package/core/builder-manager/index.js +0 -1
  166. package/core/channels/index.cjs +0 -1
  167. package/core/channels/index.d.ts +0 -2
  168. package/core/channels/index.js +0 -1
  169. package/core/cli/bin/index.cjs +0 -1
  170. package/core/cli/bin/index.d.ts +0 -2
  171. package/core/cli/bin/index.js +0 -1
  172. package/core/cli/index.cjs +0 -1
  173. package/core/cli/index.d.ts +0 -2
  174. package/core/cli/index.js +0 -1
  175. package/core/client-logger/index.cjs +0 -1
  176. package/core/client-logger/index.d.ts +0 -2
  177. package/core/client-logger/index.js +0 -1
  178. package/core/common/index.cjs +0 -1
  179. package/core/common/index.d.ts +0 -2
  180. package/core/common/index.js +0 -1
  181. package/core/components/index.cjs +0 -1
  182. package/core/components/index.d.ts +0 -2
  183. package/core/components/index.js +0 -1
  184. package/core/core-events/index.cjs +0 -1
  185. package/core/core-events/index.d.ts +0 -2
  186. package/core/core-events/index.js +0 -1
  187. package/core/core-server/index.cjs +0 -1
  188. package/core/core-server/index.d.ts +0 -2
  189. package/core/core-server/index.js +0 -1
  190. package/core/core-server/presets/common-manager.js +0 -1
  191. package/core/core-server/presets/common-override-preset.cjs +0 -1
  192. package/core/core-server/presets/common-override-preset.js +0 -1
  193. package/core/core-server/presets/common-preset.cjs +0 -1
  194. package/core/core-server/presets/common-preset.js +0 -1
  195. package/core/csf/index.cjs +0 -1
  196. package/core/csf/index.d.ts +0 -2
  197. package/core/csf/index.js +0 -1
  198. package/core/csf-tools/index.cjs +0 -1
  199. package/core/csf-tools/index.d.ts +0 -2
  200. package/core/csf-tools/index.js +0 -1
  201. package/core/docs-tools/index.cjs +0 -1
  202. package/core/docs-tools/index.d.ts +0 -2
  203. package/core/docs-tools/index.js +0 -1
  204. package/core/index.cjs +0 -1
  205. package/core/index.d.ts +0 -2
  206. package/core/index.js +0 -1
  207. package/core/manager/globals-module-info.cjs +0 -1
  208. package/core/manager/globals-module-info.d.ts +0 -2
  209. package/core/manager/globals-module-info.js +0 -1
  210. package/core/manager/globals-runtime.js +0 -1
  211. package/core/manager/globals.cjs +0 -1
  212. package/core/manager/globals.d.ts +0 -2
  213. package/core/manager/globals.js +0 -1
  214. package/core/manager-api/index.cjs +0 -1
  215. package/core/manager-api/index.d.ts +0 -2
  216. package/core/manager-api/index.js +0 -1
  217. package/core/manager-errors.d.ts +0 -2
  218. package/core/manager-errors.js +0 -1
  219. package/core/node-logger/index.cjs +0 -1
  220. package/core/node-logger/index.d.ts +0 -2
  221. package/core/node-logger/index.js +0 -1
  222. package/core/preview/globals.cjs +0 -1
  223. package/core/preview/globals.d.ts +0 -2
  224. package/core/preview/globals.js +0 -1
  225. package/core/preview/runtime.js +0 -1
  226. package/core/preview-api/index.cjs +0 -1
  227. package/core/preview-api/index.d.ts +0 -2
  228. package/core/preview-api/index.js +0 -1
  229. package/core/preview-errors.cjs +0 -1
  230. package/core/preview-errors.d.ts +0 -2
  231. package/core/preview-errors.js +0 -1
  232. package/core/router/index.cjs +0 -1
  233. package/core/router/index.d.ts +0 -2
  234. package/core/router/index.js +0 -1
  235. package/core/server-errors.cjs +0 -1
  236. package/core/server-errors.d.ts +0 -2
  237. package/core/server-errors.js +0 -1
  238. package/core/telemetry/index.cjs +0 -1
  239. package/core/telemetry/index.d.ts +0 -2
  240. package/core/telemetry/index.js +0 -1
  241. package/core/theming/create.cjs +0 -1
  242. package/core/theming/create.d.ts +0 -2
  243. package/core/theming/create.js +0 -1
  244. package/core/theming/index.cjs +0 -1
  245. package/core/theming/index.d.ts +0 -2
  246. package/core/theming/index.js +0 -1
  247. package/core/types/index.cjs +0 -1
  248. package/core/types/index.d.ts +0 -2
  249. package/core/types/index.js +0 -1
  250. package/core.cjs +0 -0
  251. package/core.d.ts +0 -0
  252. package/core.js +0 -1
  253. package/dist/chunk-OWLSIX54.js +0 -8
  254. package/dist/core-path.cjs +0 -1
  255. package/dist/core-path.d.ts +0 -3
  256. package/dist/core-path.js +0 -9
  257. package/dist/proxy.cjs +0 -1
  258. package/dist/proxy.d.ts +0 -2
  259. package/dist/proxy.js +0 -9
@@ -0,0 +1,1881 @@
1
+ var se = Object.create;
2
+ var ut = Object.defineProperty;
3
+ var le = Object.getOwnPropertyDescriptor;
4
+ var ce = Object.getOwnPropertyNames;
5
+ var pe = Object.getPrototypeOf, ue = Object.prototype.hasOwnProperty;
6
+ var a = (r, t) => ut(r, "name", { value: t, configurable: !0 }), H = /* @__PURE__ */ ((r) => typeof require < "u" ? require : typeof Proxy <
7
+ "u" ? new Proxy(r, {
8
+ get: (t, e) => (typeof require < "u" ? require : t)[e]
9
+ }) : r)(function(r) {
10
+ if (typeof require < "u") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + r + '" is not supported');
12
+ });
13
+ var fe = (r, t) => () => (t || r((t = { exports: {} }).exports, t), t.exports);
14
+ var he = (r, t, e, n) => {
15
+ if (t && typeof t == "object" || typeof t == "function")
16
+ for (let o of ce(t))
17
+ !ue.call(r, o) && o !== e && ut(r, o, { get: () => t[o], enumerable: !(n = le(t, o)) || n.enumerable });
18
+ return r;
19
+ };
20
+ var ye = (r, t, e) => (e = r != null ? se(pe(r)) : {}, he(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ t || !r || !r.__esModule ? ut(e, "default", { value: r, enumerable: !0 }) : e,
26
+ r
27
+ ));
28
+
29
+ // ../node_modules/memoizerific/memoizerific.js
30
+ var xt = fe((It, yt) => {
31
+ (function(r) {
32
+ if (typeof It == "object" && typeof yt < "u")
33
+ yt.exports = r();
34
+ else if (typeof define == "function" && define.amd)
35
+ define([], r);
36
+ else {
37
+ var t;
38
+ typeof window < "u" ? t = window : typeof global < "u" ? t = global : typeof self < "u" ? t = self : t = this, t.memoizerific = r();
39
+ }
40
+ })(function() {
41
+ var r, t, e;
42
+ return (/* @__PURE__ */ a(function n(o, s, l) {
43
+ function c(p, u) {
44
+ if (!s[p]) {
45
+ if (!o[p]) {
46
+ var y = typeof H == "function" && H;
47
+ if (!u && y) return y(p, !0);
48
+ if (i) return i(p, !0);
49
+ var v = new Error("Cannot find module '" + p + "'");
50
+ throw v.code = "MODULE_NOT_FOUND", v;
51
+ }
52
+ var d = s[p] = { exports: {} };
53
+ o[p][0].call(d.exports, function(m) {
54
+ var E = o[p][1][m];
55
+ return c(E || m);
56
+ }, d, d.exports, n, o, s, l);
57
+ }
58
+ return s[p].exports;
59
+ }
60
+ a(c, "s");
61
+ for (var i = typeof H == "function" && H, g = 0; g < l.length; g++) c(l[g]);
62
+ return c;
63
+ }, "e"))({ 1: [function(n, o, s) {
64
+ o.exports = function(l) {
65
+ if (typeof Map != "function" || l) {
66
+ var c = n("./similar");
67
+ return new c();
68
+ } else
69
+ return /* @__PURE__ */ new Map();
70
+ };
71
+ }, { "./similar": 2 }], 2: [function(n, o, s) {
72
+ function l() {
73
+ return this.list = [], this.lastItem = void 0, this.size = 0, this;
74
+ }
75
+ a(l, "Similar"), l.prototype.get = function(c) {
76
+ var i;
77
+ if (this.lastItem && this.isEqual(this.lastItem.key, c))
78
+ return this.lastItem.val;
79
+ if (i = this.indexOf(c), i >= 0)
80
+ return this.lastItem = this.list[i], this.list[i].val;
81
+ }, l.prototype.set = function(c, i) {
82
+ var g;
83
+ return this.lastItem && this.isEqual(this.lastItem.key, c) ? (this.lastItem.val = i, this) : (g = this.indexOf(c), g >= 0 ? (this.lastItem =
84
+ this.list[g], this.list[g].val = i, this) : (this.lastItem = { key: c, val: i }, this.list.push(this.lastItem), this.size++, this));
85
+ }, l.prototype.delete = function(c) {
86
+ var i;
87
+ if (this.lastItem && this.isEqual(this.lastItem.key, c) && (this.lastItem = void 0), i = this.indexOf(c), i >= 0)
88
+ return this.size--, this.list.splice(i, 1)[0];
89
+ }, l.prototype.has = function(c) {
90
+ var i;
91
+ return this.lastItem && this.isEqual(this.lastItem.key, c) ? !0 : (i = this.indexOf(c), i >= 0 ? (this.lastItem = this.list[i], !0) :
92
+ !1);
93
+ }, l.prototype.forEach = function(c, i) {
94
+ var g;
95
+ for (g = 0; g < this.size; g++)
96
+ c.call(i || this, this.list[g].val, this.list[g].key, this);
97
+ }, l.prototype.indexOf = function(c) {
98
+ var i;
99
+ for (i = 0; i < this.size; i++)
100
+ if (this.isEqual(this.list[i].key, c))
101
+ return i;
102
+ return -1;
103
+ }, l.prototype.isEqual = function(c, i) {
104
+ return c === i || c !== c && i !== i;
105
+ }, o.exports = l;
106
+ }, {}], 3: [function(n, o, s) {
107
+ var l = n("map-or-similar");
108
+ o.exports = function(p) {
109
+ var u = new l(!1), y = [];
110
+ return function(v) {
111
+ var d = /* @__PURE__ */ a(function() {
112
+ var m = u, E, I, _ = arguments.length - 1, R = Array(_ + 1), C = !0, N;
113
+ if ((d.numArgs || d.numArgs === 0) && d.numArgs !== _ + 1)
114
+ throw new Error("Memoizerific functions should always be called with the same number of arguments");
115
+ for (N = 0; N < _; N++) {
116
+ if (R[N] = {
117
+ cacheItem: m,
118
+ arg: arguments[N]
119
+ }, m.has(arguments[N])) {
120
+ m = m.get(arguments[N]);
121
+ continue;
122
+ }
123
+ C = !1, E = new l(!1), m.set(arguments[N], E), m = E;
124
+ }
125
+ return C && (m.has(arguments[_]) ? I = m.get(arguments[_]) : C = !1), C || (I = v.apply(null, arguments), m.set(arguments[_], I)),
126
+ p > 0 && (R[_] = {
127
+ cacheItem: m,
128
+ arg: arguments[_]
129
+ }, C ? c(y, R) : y.push(R), y.length > p && i(y.shift())), d.wasMemoized = C, d.numArgs = _ + 1, I;
130
+ }, "memoizerific");
131
+ return d.limit = p, d.wasMemoized = !1, d.cache = u, d.lru = y, d;
132
+ };
133
+ };
134
+ function c(p, u) {
135
+ var y = p.length, v = u.length, d, m, E;
136
+ for (m = 0; m < y; m++) {
137
+ for (d = !0, E = 0; E < v; E++)
138
+ if (!g(p[m][E].arg, u[E].arg)) {
139
+ d = !1;
140
+ break;
141
+ }
142
+ if (d)
143
+ break;
144
+ }
145
+ p.push(p.splice(m, 1)[0]);
146
+ }
147
+ a(c, "moveToMostRecentLru");
148
+ function i(p) {
149
+ var u = p.length, y = p[u - 1], v, d;
150
+ for (y.cacheItem.delete(y.arg), d = u - 2; d >= 0 && (y = p[d], v = y.cacheItem.get(y.arg), !v || !v.size); d--)
151
+ y.cacheItem.delete(y.arg);
152
+ }
153
+ a(i, "removeCachedResult");
154
+ function g(p, u) {
155
+ return p === u || p !== p && u !== u;
156
+ }
157
+ a(g, "isEqual");
158
+ }, { "map-or-similar": 1 }] }, {}, [3])(3);
159
+ });
160
+ });
161
+
162
+ // src/channels/index.ts
163
+ import { global as uo } from "@storybook/global";
164
+
165
+ // ../node_modules/ts-dedent/esm/index.js
166
+ function F(r) {
167
+ for (var t = [], e = 1; e < arguments.length; e++)
168
+ t[e - 1] = arguments[e];
169
+ var n = Array.from(typeof r == "string" ? [r] : r);
170
+ n[n.length - 1] = n[n.length - 1].replace(/\r?\n([\t ]*)$/, "");
171
+ var o = n.reduce(function(c, i) {
172
+ var g = i.match(/\n([\t ]+|(?!\s).)/g);
173
+ return g ? c.concat(g.map(function(p) {
174
+ var u, y;
175
+ return (y = (u = p.match(/[\t ]/g)) === null || u === void 0 ? void 0 : u.length) !== null && y !== void 0 ? y : 0;
176
+ })) : c;
177
+ }, []);
178
+ if (o.length) {
179
+ var s = new RegExp(`
180
+ [ ]{` + Math.min.apply(Math, o) + "}", "g");
181
+ n = n.map(function(c) {
182
+ return c.replace(s, `
183
+ `);
184
+ });
185
+ }
186
+ n[0] = n[0].replace(/^\r?\n/, "");
187
+ var l = n[0];
188
+ return t.forEach(function(c, i) {
189
+ var g = l.match(/(?:^|\n)( *)$/), p = g ? g[1] : "", u = c;
190
+ typeof c == "string" && c.includes(`
191
+ `) && (u = String(c).split(`
192
+ `).map(function(y, v) {
193
+ return v === 0 ? y : "" + p + y;
194
+ }).join(`
195
+ `)), l += u + n[i + 1];
196
+ }), l;
197
+ }
198
+ a(F, "dedent");
199
+
200
+ // src/shared/universal-store/instances.ts
201
+ var ft = /* @__PURE__ */ new Map();
202
+
203
+ // src/shared/universal-store/index.ts
204
+ var de = "UNIVERSAL_STORE:", x = {
205
+ PENDING: "PENDING",
206
+ RESOLVED: "RESOLVED",
207
+ REJECTED: "REJECTED"
208
+ }, h = class h {
209
+ constructor(t, e) {
210
+ /** Enable debug logs for this store */
211
+ this.debugging = !1;
212
+ // TODO: narrow type of listeners based on event type
213
+ this.listeners = /* @__PURE__ */ new Map([["*", /* @__PURE__ */ new Set()]]);
214
+ /** Gets the current state */
215
+ this.getState = /* @__PURE__ */ a(() => (this.debug("getState", { state: this.state }), this.state), "getState");
216
+ /**
217
+ * Subscribes to store events
218
+ *
219
+ * @returns A function to unsubscribe
220
+ */
221
+ this.subscribe = /* @__PURE__ */ a((t, e) => {
222
+ let n = typeof t == "function", o = n ? "*" : t, s = n ? t : e;
223
+ if (this.debug("subscribe", { eventType: o, listener: s }), !s)
224
+ throw new TypeError(
225
+ `Missing first subscribe argument, or second if first is the event type, when subscribing to a UniversalStore with id '${this.id}'`
226
+ );
227
+ return this.listeners.has(o) || this.listeners.set(o, /* @__PURE__ */ new Set()), this.listeners.get(o).add(s), () => {
228
+ this.debug("unsubscribe", { eventType: o, listener: s }), this.listeners.has(o) && (this.listeners.get(o).delete(s), this.listeners.
229
+ get(o)?.size === 0 && this.listeners.delete(o));
230
+ };
231
+ }, "subscribe");
232
+ /** Sends a custom event to the other stores */
233
+ this.send = /* @__PURE__ */ a((t) => {
234
+ if (this.debug("send", { event: t }), this.status !== h.Status.READY)
235
+ throw new TypeError(
236
+ F`Cannot send event before store is ready. You can get the current status with store.status,
237
+ or await store.readyPromise to wait for the store to be ready before sending events.
238
+ ${JSON.stringify(
239
+ {
240
+ event: t,
241
+ id: this.id,
242
+ actor: this.actor,
243
+ environment: this.environment
244
+ },
245
+ null,
246
+ 2
247
+ )}`
248
+ );
249
+ this.emitToListeners(t, { actor: this.actor }), this.emitToChannel(t, { actor: this.actor });
250
+ }, "send");
251
+ if (this.debugging = t.debug ?? !1, !h.isInternalConstructing)
252
+ throw new TypeError(
253
+ "UniversalStore is not constructable - use UniversalStore.create() instead"
254
+ );
255
+ if (h.isInternalConstructing = !1, this.id = t.id, this.actorId = Date.now().toString(36) + Math.random().toString(36).substring(2), this.
256
+ actorType = t.leader ? h.ActorType.LEADER : h.ActorType.FOLLOWER, this.state = t.initialState, this.channelEventName = `${de}${this.id}`,
257
+ this.debug("constructor", {
258
+ options: t,
259
+ environmentOverrides: e,
260
+ channelEventName: this.channelEventName
261
+ }), this.actor.type === h.ActorType.LEADER)
262
+ this.syncing = {
263
+ state: x.RESOLVED,
264
+ promise: Promise.resolve()
265
+ };
266
+ else {
267
+ let n, o, s = new Promise((l, c) => {
268
+ n = /* @__PURE__ */ a(() => {
269
+ this.syncing.state === x.PENDING && (this.syncing.state = x.RESOLVED, l());
270
+ }, "syncingResolve"), o = /* @__PURE__ */ a((i) => {
271
+ this.syncing.state === x.PENDING && (this.syncing.state = x.REJECTED, c(i));
272
+ }, "syncingReject");
273
+ });
274
+ this.syncing = {
275
+ state: x.PENDING,
276
+ promise: s,
277
+ resolve: n,
278
+ reject: o
279
+ };
280
+ }
281
+ this.getState = this.getState.bind(this), this.setState = this.setState.bind(this), this.subscribe = this.subscribe.bind(this), this.onStateChange =
282
+ this.onStateChange.bind(this), this.send = this.send.bind(this), this.emitToChannel = this.emitToChannel.bind(this), this.prepareThis = this.
283
+ prepareThis.bind(this), this.emitToListeners = this.emitToListeners.bind(this), this.handleChannelEvents = this.handleChannelEvents.bind(
284
+ this), this.debug = this.debug.bind(this), this.channel = e?.channel ?? h.preparation.channel, this.environment = e?.environment ?? h.preparation.
285
+ environment, this.channel && this.environment ? this.prepareThis({ channel: this.channel, environment: this.environment }) : h.preparation.
286
+ promise.then(this.prepareThis);
287
+ }
288
+ static setupPreparationPromise() {
289
+ let t, e, n = new Promise(
290
+ (o, s) => {
291
+ t = /* @__PURE__ */ a((l) => {
292
+ o(l);
293
+ }, "resolveRef"), e = /* @__PURE__ */ a((...l) => {
294
+ s(l);
295
+ }, "rejectRef");
296
+ }
297
+ );
298
+ h.preparation = {
299
+ resolve: t,
300
+ reject: e,
301
+ promise: n
302
+ };
303
+ }
304
+ /** The actor object representing the store instance with a unique ID and a type */
305
+ get actor() {
306
+ return Object.freeze({
307
+ id: this.actorId,
308
+ type: this.actorType,
309
+ environment: this.environment ?? h.Environment.UNKNOWN
310
+ });
311
+ }
312
+ /**
313
+ * The current state of the store, that signals both if the store is prepared by Storybook and
314
+ * also - in the case of a follower - if the state has been synced with the leader's state.
315
+ */
316
+ get status() {
317
+ if (!this.channel || !this.environment)
318
+ return h.Status.UNPREPARED;
319
+ switch (this.syncing?.state) {
320
+ case x.PENDING:
321
+ case void 0:
322
+ return h.Status.SYNCING;
323
+ case x.REJECTED:
324
+ return h.Status.ERROR;
325
+ case x.RESOLVED:
326
+ default:
327
+ return h.Status.READY;
328
+ }
329
+ }
330
+ /**
331
+ * A promise that resolves when the store is fully ready. A leader will be ready when the store
332
+ * has been prepared by Storybook, which is almost instantly.
333
+ *
334
+ * A follower will be ready when the state has been synced with the leader's state, within a few
335
+ * hundred milliseconds.
336
+ */
337
+ untilReady() {
338
+ return Promise.all([h.preparation.promise, this.syncing?.promise]);
339
+ }
340
+ /** Creates a new instance of UniversalStore */
341
+ static create(t) {
342
+ if (!t || typeof t?.id != "string")
343
+ throw new TypeError("id is required and must be a string, when creating a UniversalStore");
344
+ t.debug && console.debug(
345
+ F`[UniversalStore]
346
+ create`,
347
+ { options: t }
348
+ );
349
+ let e = ft.get(t.id);
350
+ if (e)
351
+ return console.warn(F`UniversalStore with id "${t.id}" already exists in this environment, re-using existing.
352
+ You should reuse the existing instance instead of trying to create a new one.`), e;
353
+ h.isInternalConstructing = !0;
354
+ let n = new h(t);
355
+ return ft.set(t.id, n), n;
356
+ }
357
+ /**
358
+ * Used by Storybook to set the channel for all instances of UniversalStore in the given
359
+ * environment.
360
+ *
361
+ * @internal
362
+ */
363
+ static __prepare(t, e) {
364
+ h.preparation.channel = t, h.preparation.environment = e, h.preparation.resolve({ channel: t, environment: e });
365
+ }
366
+ /**
367
+ * Updates the store's state
368
+ *
369
+ * Either a new state or a state updater function can be passed to the method.
370
+ */
371
+ setState(t) {
372
+ let e = this.state, n = typeof t == "function" ? t(e) : t;
373
+ if (this.debug("setState", { newState: n, previousState: e, updater: t }), this.status !== h.Status.READY)
374
+ throw new TypeError(
375
+ F`Cannot set state before store is ready. You can get the current status with store.status,
376
+ or await store.readyPromise to wait for the store to be ready before sending events.
377
+ ${JSON.stringify(
378
+ {
379
+ newState: n,
380
+ id: this.id,
381
+ actor: this.actor,
382
+ environment: this.environment
383
+ },
384
+ null,
385
+ 2
386
+ )}`
387
+ );
388
+ this.state = n;
389
+ let o = {
390
+ type: h.InternalEventType.SET_STATE,
391
+ payload: {
392
+ state: n,
393
+ previousState: e
394
+ }
395
+ };
396
+ this.emitToChannel(o, { actor: this.actor }), this.emitToListeners(o, { actor: this.actor });
397
+ }
398
+ /**
399
+ * Subscribes to state changes
400
+ *
401
+ * @returns Unsubscribe function
402
+ */
403
+ onStateChange(t) {
404
+ return this.debug("onStateChange", { listener: t }), this.subscribe(
405
+ h.InternalEventType.SET_STATE,
406
+ ({ payload: e }, n) => {
407
+ t(e.state, e.previousState, n);
408
+ }
409
+ );
410
+ }
411
+ emitToChannel(t, e) {
412
+ this.debug("emitToChannel", { event: t, eventInfo: e, channel: !!this.channel }), this.channel?.emit(this.channelEventName, {
413
+ event: t,
414
+ eventInfo: e
415
+ });
416
+ }
417
+ prepareThis({
418
+ channel: t,
419
+ environment: e
420
+ }) {
421
+ this.channel = t, this.environment = e, this.debug("prepared", { channel: !!t, environment: e }), this.channel.on(this.channelEventName,
422
+ this.handleChannelEvents), this.actor.type === h.ActorType.LEADER ? this.emitToChannel(
423
+ { type: h.InternalEventType.LEADER_CREATED },
424
+ { actor: this.actor }
425
+ ) : (this.emitToChannel(
426
+ { type: h.InternalEventType.FOLLOWER_CREATED },
427
+ { actor: this.actor }
428
+ ), this.emitToChannel(
429
+ { type: h.InternalEventType.EXISTING_STATE_REQUEST },
430
+ { actor: this.actor }
431
+ ), setTimeout(() => {
432
+ this.syncing.reject(
433
+ new TypeError(
434
+ `No existing state found for follower with id: '${this.id}'. Make sure a leader with the same id exists before creating a follower\
435
+ .`
436
+ )
437
+ );
438
+ }, 1e3));
439
+ }
440
+ emitToListeners(t, e) {
441
+ let n = this.listeners.get(t.type), o = this.listeners.get("*");
442
+ this.debug("emitToListeners", {
443
+ event: t,
444
+ eventInfo: e,
445
+ eventTypeListeners: n,
446
+ everythingListeners: o
447
+ }), [...n ?? [], ...o ?? []].forEach(
448
+ (s) => s(t, e)
449
+ );
450
+ }
451
+ handleChannelEvents(t) {
452
+ let { event: e, eventInfo: n } = t;
453
+ if ([n.actor.id, n.forwardingActor?.id].includes(this.actor.id)) {
454
+ this.debug("handleChannelEvents: Ignoring event from self", { channelEvent: t });
455
+ return;
456
+ } else if (this.syncing?.state === x.PENDING && e.type !== h.InternalEventType.EXISTING_STATE_RESPONSE) {
457
+ this.debug("handleChannelEvents: Ignoring event while syncing", { channelEvent: t });
458
+ return;
459
+ }
460
+ if (this.debug("handleChannelEvents", { channelEvent: t }), this.actor.type === h.ActorType.LEADER) {
461
+ let o = !0;
462
+ switch (e.type) {
463
+ case h.InternalEventType.EXISTING_STATE_REQUEST:
464
+ o = !1;
465
+ let s = {
466
+ type: h.InternalEventType.EXISTING_STATE_RESPONSE,
467
+ payload: this.state
468
+ };
469
+ this.debug("handleChannelEvents: responding to existing state request", {
470
+ responseEvent: s
471
+ }), this.emitToChannel(s, { actor: this.actor });
472
+ break;
473
+ case h.InternalEventType.LEADER_CREATED:
474
+ o = !1, this.syncing.state = x.REJECTED, this.debug("handleChannelEvents: erroring due to second leader being created", {
475
+ event: e
476
+ }), console.error(
477
+ F`Detected multiple UniversalStore leaders created with the same id "${this.id}".
478
+ Only one leader can exists at a time, your stores are now in an invalid state.
479
+ Leaders detected:
480
+ this: ${JSON.stringify(this.actor, null, 2)}
481
+ other: ${JSON.stringify(n.actor, null, 2)}`
482
+ );
483
+ break;
484
+ }
485
+ o && (this.debug("handleChannelEvents: forwarding event", { channelEvent: t }), this.emitToChannel(e, { actor: n.actor, forwardingActor: this.
486
+ actor }));
487
+ }
488
+ if (this.actor.type === h.ActorType.FOLLOWER)
489
+ switch (e.type) {
490
+ case h.InternalEventType.EXISTING_STATE_RESPONSE:
491
+ if (this.debug("handleChannelEvents: Setting state from leader's existing state response", {
492
+ event: e
493
+ }), this.syncing?.state !== x.PENDING)
494
+ break;
495
+ this.syncing.resolve?.();
496
+ let o = {
497
+ type: h.InternalEventType.SET_STATE,
498
+ payload: {
499
+ state: e.payload,
500
+ previousState: this.state
501
+ }
502
+ };
503
+ this.state = e.payload, this.emitToListeners(o, n);
504
+ break;
505
+ }
506
+ switch (e.type) {
507
+ case h.InternalEventType.SET_STATE:
508
+ this.debug("handleChannelEvents: Setting state", { event: e }), this.state = e.payload.state;
509
+ break;
510
+ }
511
+ this.emitToListeners(e, { actor: n.actor });
512
+ }
513
+ debug(t, e) {
514
+ this.debugging && console.debug(
515
+ F`[UniversalStore::${this.id}::${this.environment ?? h.Environment.UNKNOWN}]
516
+ ${t}`,
517
+ JSON.stringify(
518
+ {
519
+ data: e,
520
+ actor: this.actor,
521
+ state: this.state,
522
+ status: this.status
523
+ },
524
+ null,
525
+ 2
526
+ )
527
+ );
528
+ }
529
+ /**
530
+ * Used to reset the static fields of the UniversalStore class when cleaning up tests
531
+ *
532
+ * @internal
533
+ */
534
+ static __reset() {
535
+ h.preparation.reject(new Error("reset")), h.setupPreparationPromise(), h.isInternalConstructing = !1;
536
+ }
537
+ };
538
+ a(h, "UniversalStore"), /**
539
+ * Defines the possible actor types in the store system
540
+ *
541
+ * @readonly
542
+ */
543
+ h.ActorType = {
544
+ LEADER: "LEADER",
545
+ FOLLOWER: "FOLLOWER"
546
+ }, /**
547
+ * Defines the possible environments the store can run in
548
+ *
549
+ * @readonly
550
+ */
551
+ h.Environment = {
552
+ SERVER: "SERVER",
553
+ MANAGER: "MANAGER",
554
+ PREVIEW: "PREVIEW",
555
+ UNKNOWN: "UNKNOWN",
556
+ MOCK: "MOCK"
557
+ }, /**
558
+ * Internal event types used for store synchronization
559
+ *
560
+ * @readonly
561
+ */
562
+ h.InternalEventType = {
563
+ EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST",
564
+ EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE",
565
+ SET_STATE: "__SET_STATE",
566
+ LEADER_CREATED: "__LEADER_CREATED",
567
+ FOLLOWER_CREATED: "__FOLLOWER_CREATED"
568
+ }, h.Status = {
569
+ UNPREPARED: "UNPREPARED",
570
+ SYNCING: "SYNCING",
571
+ READY: "READY",
572
+ ERROR: "ERROR"
573
+ }, // This is used to check if constructor was called from the static factory create()
574
+ h.isInternalConstructing = !1, h.setupPreparationPromise();
575
+ var $ = h;
576
+
577
+ // src/channels/main.ts
578
+ var ge = /* @__PURE__ */ a((r) => r.transports !== void 0, "isMulti"), ve = /* @__PURE__ */ a(() => Math.random().toString(16).slice(2), "ge\
579
+ nerateRandomId"), ht = class ht {
580
+ constructor(t = {}) {
581
+ this.sender = ve();
582
+ this.events = {};
583
+ this.data = {};
584
+ this.transports = [];
585
+ this.isAsync = t.async || !1, ge(t) ? (this.transports = t.transports || [], this.transports.forEach((e) => {
586
+ e.setHandler((n) => this.handleEvent(n));
587
+ })) : this.transports = t.transport ? [t.transport] : [], this.transports.forEach((e) => {
588
+ e.setHandler((n) => this.handleEvent(n));
589
+ });
590
+ }
591
+ get hasTransport() {
592
+ return this.transports.length > 0;
593
+ }
594
+ addListener(t, e) {
595
+ this.events[t] = this.events[t] || [], this.events[t].push(e);
596
+ }
597
+ emit(t, ...e) {
598
+ let n = { type: t, args: e, from: this.sender }, o = {};
599
+ e.length >= 1 && e[0] && e[0].options && (o = e[0].options);
600
+ let s = /* @__PURE__ */ a(() => {
601
+ this.transports.forEach((l) => {
602
+ l.send(n, o);
603
+ }), this.handleEvent(n);
604
+ }, "handler");
605
+ this.isAsync ? setImmediate(s) : s();
606
+ }
607
+ last(t) {
608
+ return this.data[t];
609
+ }
610
+ eventNames() {
611
+ return Object.keys(this.events);
612
+ }
613
+ listenerCount(t) {
614
+ let e = this.listeners(t);
615
+ return e ? e.length : 0;
616
+ }
617
+ listeners(t) {
618
+ return this.events[t] || void 0;
619
+ }
620
+ once(t, e) {
621
+ let n = this.onceListener(t, e);
622
+ this.addListener(t, n);
623
+ }
624
+ removeAllListeners(t) {
625
+ t ? this.events[t] && delete this.events[t] : this.events = {};
626
+ }
627
+ removeListener(t, e) {
628
+ let n = this.listeners(t);
629
+ n && (this.events[t] = n.filter((o) => o !== e));
630
+ }
631
+ on(t, e) {
632
+ this.addListener(t, e);
633
+ }
634
+ off(t, e) {
635
+ this.removeListener(t, e);
636
+ }
637
+ handleEvent(t) {
638
+ let e = this.listeners(t.type);
639
+ e && e.length && e.forEach((n) => {
640
+ n.apply(t, t.args);
641
+ }), this.data[t.type] = t.args;
642
+ }
643
+ onceListener(t, e) {
644
+ let n = /* @__PURE__ */ a((...o) => (this.removeListener(t, n), e(...o)), "onceListener");
645
+ return n;
646
+ }
647
+ };
648
+ a(ht, "Channel");
649
+ var B = ht;
650
+
651
+ // src/channels/postmessage/index.ts
652
+ import { logger as Kt, pretty as Yt } from "storybook/internal/client-logger";
653
+ import * as lo from "storybook/internal/core-events";
654
+ import { global as A } from "@storybook/global";
655
+
656
+ // ../node_modules/telejson/dist/chunk-465TF3XA.mjs
657
+ var me = Object.create, Ot = Object.defineProperty, Ee = Object.getOwnPropertyDescriptor, Ct = Object.getOwnPropertyNames, be = Object.getPrototypeOf,
658
+ Se = Object.prototype.hasOwnProperty, P = /* @__PURE__ */ a((r, t) => /* @__PURE__ */ a(function() {
659
+ return t || (0, r[Ct(r)[0]])((t = { exports: {} }).exports, t), t.exports;
660
+ }, "__require"), "__commonJS"), _e = /* @__PURE__ */ a((r, t, e, n) => {
661
+ if (t && typeof t == "object" || typeof t == "function")
662
+ for (let o of Ct(t))
663
+ !Se.call(r, o) && o !== e && Ot(r, o, { get: /* @__PURE__ */ a(() => t[o], "get"), enumerable: !(n = Ee(t, o)) || n.enumerable });
664
+ return r;
665
+ }, "__copyProps"), ot = /* @__PURE__ */ a((r, t, e) => (e = r != null ? me(be(r)) : {}, _e(
666
+ t || !r || !r.__esModule ? Ot(e, "default", { value: r, enumerable: !0 }) : e,
667
+ r
668
+ )), "__toESM"), Te = [
669
+ "bubbles",
670
+ "cancelBubble",
671
+ "cancelable",
672
+ "composed",
673
+ "currentTarget",
674
+ "defaultPrevented",
675
+ "eventPhase",
676
+ "isTrusted",
677
+ "returnValue",
678
+ "srcElement",
679
+ "target",
680
+ "timeStamp",
681
+ "type"
682
+ ], Ae = ["detail"];
683
+ function Pt(r) {
684
+ let t = Te.filter((e) => r[e] !== void 0).reduce((e, n) => ({ ...e, [n]: r[n] }), {});
685
+ return r instanceof CustomEvent && Ae.filter((e) => r[e] !== void 0).forEach((e) => {
686
+ t[e] = r[e];
687
+ }), t;
688
+ }
689
+ a(Pt, "extractEventHiddenProperties");
690
+
691
+ // ../node_modules/telejson/dist/index.mjs
692
+ var Bt = ye(xt(), 1);
693
+ var Ft = P({
694
+ "node_modules/has-symbols/shams.js"(r, t) {
695
+ "use strict";
696
+ t.exports = /* @__PURE__ */ a(function() {
697
+ if (typeof Symbol != "function" || typeof Object.getOwnPropertySymbols != "function")
698
+ return !1;
699
+ if (typeof Symbol.iterator == "symbol")
700
+ return !0;
701
+ var n = {}, o = Symbol("test"), s = Object(o);
702
+ if (typeof o == "string" || Object.prototype.toString.call(o) !== "[object Symbol]" || Object.prototype.toString.call(s) !== "[object \
703
+ Symbol]")
704
+ return !1;
705
+ var l = 42;
706
+ n[o] = l;
707
+ for (o in n)
708
+ return !1;
709
+ if (typeof Object.keys == "function" && Object.keys(n).length !== 0 || typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(
710
+ n).length !== 0)
711
+ return !1;
712
+ var c = Object.getOwnPropertySymbols(n);
713
+ if (c.length !== 1 || c[0] !== o || !Object.prototype.propertyIsEnumerable.call(n, o))
714
+ return !1;
715
+ if (typeof Object.getOwnPropertyDescriptor == "function") {
716
+ var i = Object.getOwnPropertyDescriptor(n, o);
717
+ if (i.value !== l || i.enumerable !== !0)
718
+ return !1;
719
+ }
720
+ return !0;
721
+ }, "hasSymbols");
722
+ }
723
+ }), Mt = P({
724
+ "node_modules/has-symbols/index.js"(r, t) {
725
+ "use strict";
726
+ var e = typeof Symbol < "u" && Symbol, n = Ft();
727
+ t.exports = /* @__PURE__ */ a(function() {
728
+ return typeof e != "function" || typeof Symbol != "function" || typeof e("foo") != "symbol" || typeof Symbol("bar") != "symbol" ? !1 :
729
+ n();
730
+ }, "hasNativeSymbols");
731
+ }
732
+ }), we = P({
733
+ "node_modules/function-bind/implementation.js"(r, t) {
734
+ "use strict";
735
+ var e = "Function.prototype.bind called on incompatible ", n = Array.prototype.slice, o = Object.prototype.toString, s = "[object Functi\
736
+ on]";
737
+ t.exports = /* @__PURE__ */ a(function(c) {
738
+ var i = this;
739
+ if (typeof i != "function" || o.call(i) !== s)
740
+ throw new TypeError(e + i);
741
+ for (var g = n.call(arguments, 1), p, u = /* @__PURE__ */ a(function() {
742
+ if (this instanceof p) {
743
+ var E = i.apply(
744
+ this,
745
+ g.concat(n.call(arguments))
746
+ );
747
+ return Object(E) === E ? E : this;
748
+ } else
749
+ return i.apply(
750
+ c,
751
+ g.concat(n.call(arguments))
752
+ );
753
+ }, "binder"), y = Math.max(0, i.length - g.length), v = [], d = 0; d < y; d++)
754
+ v.push("$" + d);
755
+ if (p = Function("binder", "return function (" + v.join(",") + "){ return binder.apply(this,arguments); }")(u), i.prototype) {
756
+ var m = /* @__PURE__ */ a(function() {
757
+ }, "Empty2");
758
+ m.prototype = i.prototype, p.prototype = new m(), m.prototype = null;
759
+ }
760
+ return p;
761
+ }, "bind");
762
+ }
763
+ }), gt = P({
764
+ "node_modules/function-bind/index.js"(r, t) {
765
+ "use strict";
766
+ var e = we();
767
+ t.exports = Function.prototype.bind || e;
768
+ }
769
+ }), Oe = P({
770
+ "node_modules/has/src/index.js"(r, t) {
771
+ "use strict";
772
+ var e = gt();
773
+ t.exports = e.call(Function.call, Object.prototype.hasOwnProperty);
774
+ }
775
+ }), $t = P({
776
+ "node_modules/get-intrinsic/index.js"(r, t) {
777
+ "use strict";
778
+ var e, n = SyntaxError, o = Function, s = TypeError, l = /* @__PURE__ */ a(function(j) {
779
+ try {
780
+ return o('"use strict"; return (' + j + ").constructor;")();
781
+ } catch {
782
+ }
783
+ }, "getEvalledConstructor"), c = Object.getOwnPropertyDescriptor;
784
+ if (c)
785
+ try {
786
+ c({}, "");
787
+ } catch {
788
+ c = null;
789
+ }
790
+ var i = /* @__PURE__ */ a(function() {
791
+ throw new s();
792
+ }, "throwTypeError"), g = c ? function() {
793
+ try {
794
+ return arguments.callee, i;
795
+ } catch {
796
+ try {
797
+ return c(arguments, "callee").get;
798
+ } catch {
799
+ return i;
800
+ }
801
+ }
802
+ }() : i, p = Mt()(), u = Object.getPrototypeOf || function(j) {
803
+ return j.__proto__;
804
+ }, y = {}, v = typeof Uint8Array > "u" ? e : u(Uint8Array), d = {
805
+ "%AggregateError%": typeof AggregateError > "u" ? e : AggregateError,
806
+ "%Array%": Array,
807
+ "%ArrayBuffer%": typeof ArrayBuffer > "u" ? e : ArrayBuffer,
808
+ "%ArrayIteratorPrototype%": p ? u([][Symbol.iterator]()) : e,
809
+ "%AsyncFromSyncIteratorPrototype%": e,
810
+ "%AsyncFunction%": y,
811
+ "%AsyncGenerator%": y,
812
+ "%AsyncGeneratorFunction%": y,
813
+ "%AsyncIteratorPrototype%": y,
814
+ "%Atomics%": typeof Atomics > "u" ? e : Atomics,
815
+ "%BigInt%": typeof BigInt > "u" ? e : BigInt,
816
+ "%Boolean%": Boolean,
817
+ "%DataView%": typeof DataView > "u" ? e : DataView,
818
+ "%Date%": Date,
819
+ "%decodeURI%": decodeURI,
820
+ "%decodeURIComponent%": decodeURIComponent,
821
+ "%encodeURI%": encodeURI,
822
+ "%encodeURIComponent%": encodeURIComponent,
823
+ "%Error%": Error,
824
+ "%eval%": eval,
825
+ "%EvalError%": EvalError,
826
+ "%Float32Array%": typeof Float32Array > "u" ? e : Float32Array,
827
+ "%Float64Array%": typeof Float64Array > "u" ? e : Float64Array,
828
+ "%FinalizationRegistry%": typeof FinalizationRegistry > "u" ? e : FinalizationRegistry,
829
+ "%Function%": o,
830
+ "%GeneratorFunction%": y,
831
+ "%Int8Array%": typeof Int8Array > "u" ? e : Int8Array,
832
+ "%Int16Array%": typeof Int16Array > "u" ? e : Int16Array,
833
+ "%Int32Array%": typeof Int32Array > "u" ? e : Int32Array,
834
+ "%isFinite%": isFinite,
835
+ "%isNaN%": isNaN,
836
+ "%IteratorPrototype%": p ? u(u([][Symbol.iterator]())) : e,
837
+ "%JSON%": typeof JSON == "object" ? JSON : e,
838
+ "%Map%": typeof Map > "u" ? e : Map,
839
+ "%MapIteratorPrototype%": typeof Map > "u" || !p ? e : u((/* @__PURE__ */ new Map())[Symbol.iterator]()),
840
+ "%Math%": Math,
841
+ "%Number%": Number,
842
+ "%Object%": Object,
843
+ "%parseFloat%": parseFloat,
844
+ "%parseInt%": parseInt,
845
+ "%Promise%": typeof Promise > "u" ? e : Promise,
846
+ "%Proxy%": typeof Proxy > "u" ? e : Proxy,
847
+ "%RangeError%": RangeError,
848
+ "%ReferenceError%": ReferenceError,
849
+ "%Reflect%": typeof Reflect > "u" ? e : Reflect,
850
+ "%RegExp%": RegExp,
851
+ "%Set%": typeof Set > "u" ? e : Set,
852
+ "%SetIteratorPrototype%": typeof Set > "u" || !p ? e : u((/* @__PURE__ */ new Set())[Symbol.iterator]()),
853
+ "%SharedArrayBuffer%": typeof SharedArrayBuffer > "u" ? e : SharedArrayBuffer,
854
+ "%String%": String,
855
+ "%StringIteratorPrototype%": p ? u(""[Symbol.iterator]()) : e,
856
+ "%Symbol%": p ? Symbol : e,
857
+ "%SyntaxError%": n,
858
+ "%ThrowTypeError%": g,
859
+ "%TypedArray%": v,
860
+ "%TypeError%": s,
861
+ "%Uint8Array%": typeof Uint8Array > "u" ? e : Uint8Array,
862
+ "%Uint8ClampedArray%": typeof Uint8ClampedArray > "u" ? e : Uint8ClampedArray,
863
+ "%Uint16Array%": typeof Uint16Array > "u" ? e : Uint16Array,
864
+ "%Uint32Array%": typeof Uint32Array > "u" ? e : Uint32Array,
865
+ "%URIError%": URIError,
866
+ "%WeakMap%": typeof WeakMap > "u" ? e : WeakMap,
867
+ "%WeakRef%": typeof WeakRef > "u" ? e : WeakRef,
868
+ "%WeakSet%": typeof WeakSet > "u" ? e : WeakSet
869
+ }, m = /* @__PURE__ */ a(function j(b) {
870
+ var T;
871
+ if (b === "%AsyncFunction%")
872
+ T = l("async function () {}");
873
+ else if (b === "%GeneratorFunction%")
874
+ T = l("function* () {}");
875
+ else if (b === "%AsyncGeneratorFunction%")
876
+ T = l("async function* () {}");
877
+ else if (b === "%AsyncGenerator%") {
878
+ var S = j("%AsyncGeneratorFunction%");
879
+ S && (T = S.prototype);
880
+ } else if (b === "%AsyncIteratorPrototype%") {
881
+ var w = j("%AsyncGenerator%");
882
+ w && (T = u(w.prototype));
883
+ }
884
+ return d[b] = T, T;
885
+ }, "doEval2"), E = {
886
+ "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"],
887
+ "%ArrayPrototype%": ["Array", "prototype"],
888
+ "%ArrayProto_entries%": ["Array", "prototype", "entries"],
889
+ "%ArrayProto_forEach%": ["Array", "prototype", "forEach"],
890
+ "%ArrayProto_keys%": ["Array", "prototype", "keys"],
891
+ "%ArrayProto_values%": ["Array", "prototype", "values"],
892
+ "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"],
893
+ "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"],
894
+ "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"],
895
+ "%BooleanPrototype%": ["Boolean", "prototype"],
896
+ "%DataViewPrototype%": ["DataView", "prototype"],
897
+ "%DatePrototype%": ["Date", "prototype"],
898
+ "%ErrorPrototype%": ["Error", "prototype"],
899
+ "%EvalErrorPrototype%": ["EvalError", "prototype"],
900
+ "%Float32ArrayPrototype%": ["Float32Array", "prototype"],
901
+ "%Float64ArrayPrototype%": ["Float64Array", "prototype"],
902
+ "%FunctionPrototype%": ["Function", "prototype"],
903
+ "%Generator%": ["GeneratorFunction", "prototype"],
904
+ "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"],
905
+ "%Int8ArrayPrototype%": ["Int8Array", "prototype"],
906
+ "%Int16ArrayPrototype%": ["Int16Array", "prototype"],
907
+ "%Int32ArrayPrototype%": ["Int32Array", "prototype"],
908
+ "%JSONParse%": ["JSON", "parse"],
909
+ "%JSONStringify%": ["JSON", "stringify"],
910
+ "%MapPrototype%": ["Map", "prototype"],
911
+ "%NumberPrototype%": ["Number", "prototype"],
912
+ "%ObjectPrototype%": ["Object", "prototype"],
913
+ "%ObjProto_toString%": ["Object", "prototype", "toString"],
914
+ "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"],
915
+ "%PromisePrototype%": ["Promise", "prototype"],
916
+ "%PromiseProto_then%": ["Promise", "prototype", "then"],
917
+ "%Promise_all%": ["Promise", "all"],
918
+ "%Promise_reject%": ["Promise", "reject"],
919
+ "%Promise_resolve%": ["Promise", "resolve"],
920
+ "%RangeErrorPrototype%": ["RangeError", "prototype"],
921
+ "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"],
922
+ "%RegExpPrototype%": ["RegExp", "prototype"],
923
+ "%SetPrototype%": ["Set", "prototype"],
924
+ "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"],
925
+ "%StringPrototype%": ["String", "prototype"],
926
+ "%SymbolPrototype%": ["Symbol", "prototype"],
927
+ "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"],
928
+ "%TypedArrayPrototype%": ["TypedArray", "prototype"],
929
+ "%TypeErrorPrototype%": ["TypeError", "prototype"],
930
+ "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"],
931
+ "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"],
932
+ "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"],
933
+ "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"],
934
+ "%URIErrorPrototype%": ["URIError", "prototype"],
935
+ "%WeakMapPrototype%": ["WeakMap", "prototype"],
936
+ "%WeakSetPrototype%": ["WeakSet", "prototype"]
937
+ }, I = gt(), _ = Oe(), R = I.call(Function.call, Array.prototype.concat), C = I.call(Function.apply, Array.prototype.splice), N = I.call(
938
+ Function.call, String.prototype.replace), Q = I.call(Function.call, String.prototype.slice), re = I.call(Function.call, RegExp.prototype.
939
+ exec), ne = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, oe = /\\(\\)?/g, ie = /* @__PURE__ */ a(
940
+ function(b) {
941
+ var T = Q(b, 0, 1), S = Q(b, -1);
942
+ if (T === "%" && S !== "%")
943
+ throw new n("invalid intrinsic syntax, expected closing `%`");
944
+ if (S === "%" && T !== "%")
945
+ throw new n("invalid intrinsic syntax, expected opening `%`");
946
+ var w = [];
947
+ return N(b, ne, function(L, M, O, Z) {
948
+ w[w.length] = O ? N(Z, oe, "$1") : M || L;
949
+ }), w;
950
+ }, "stringToPath3"), ae = /* @__PURE__ */ a(function(b, T) {
951
+ var S = b, w;
952
+ if (_(E, S) && (w = E[S], S = "%" + w[0] + "%"), _(d, S)) {
953
+ var L = d[S];
954
+ if (L === y && (L = m(S)), typeof L > "u" && !T)
955
+ throw new s("intrinsic " + b + " exists, but is not available. Please file an issue!");
956
+ return {
957
+ alias: w,
958
+ name: S,
959
+ value: L
960
+ };
961
+ }
962
+ throw new n("intrinsic " + b + " does not exist!");
963
+ }, "getBaseIntrinsic2");
964
+ t.exports = /* @__PURE__ */ a(function(b, T) {
965
+ if (typeof b != "string" || b.length === 0)
966
+ throw new s("intrinsic name must be a non-empty string");
967
+ if (arguments.length > 1 && typeof T != "boolean")
968
+ throw new s('"allowMissing" argument must be a boolean');
969
+ if (re(/^%?[^%]*%?$/, b) === null)
970
+ throw new n("`%` may not be present anywhere but at the beginning and end of the intrinsic name");
971
+ var S = ie(b), w = S.length > 0 ? S[0] : "", L = ae("%" + w + "%", T), M = L.name, O = L.value, Z = !1, pt = L.alias;
972
+ pt && (w = pt[0], C(S, R([0, 1], pt)));
973
+ for (var tt = 1, z = !0; tt < S.length; tt += 1) {
974
+ var D = S[tt], et = Q(D, 0, 1), rt = Q(D, -1);
975
+ if ((et === '"' || et === "'" || et === "`" || rt === '"' || rt === "'" || rt === "`") && et !== rt)
976
+ throw new n("property names with quotes must have matching quotes");
977
+ if ((D === "constructor" || !z) && (Z = !0), w += "." + D, M = "%" + w + "%", _(d, M))
978
+ O = d[M];
979
+ else if (O != null) {
980
+ if (!(D in O)) {
981
+ if (!T)
982
+ throw new s("base intrinsic for " + b + " exists, but the property is not available.");
983
+ return;
984
+ }
985
+ if (c && tt + 1 >= S.length) {
986
+ var nt = c(O, D);
987
+ z = !!nt, z && "get" in nt && !("originalValue" in nt.get) ? O = nt.get : O = O[D];
988
+ } else
989
+ z = _(O, D), O = O[D];
990
+ z && !Z && (d[M] = O);
991
+ }
992
+ }
993
+ return O;
994
+ }, "GetIntrinsic");
995
+ }
996
+ }), Ce = P({
997
+ "node_modules/call-bind/index.js"(r, t) {
998
+ "use strict";
999
+ var e = gt(), n = $t(), o = n("%Function.prototype.apply%"), s = n("%Function.prototype.call%"), l = n("%Reflect.apply%", !0) || e.call(
1000
+ s, o), c = n("%Object.getOwnPropertyDescriptor%", !0), i = n("%Object.defineProperty%", !0), g = n("%Math.max%");
1001
+ if (i)
1002
+ try {
1003
+ i({}, "a", { value: 1 });
1004
+ } catch {
1005
+ i = null;
1006
+ }
1007
+ t.exports = /* @__PURE__ */ a(function(y) {
1008
+ var v = l(e, s, arguments);
1009
+ if (c && i) {
1010
+ var d = c(v, "length");
1011
+ d.configurable && i(
1012
+ v,
1013
+ "length",
1014
+ { value: 1 + g(0, y.length - (arguments.length - 1)) }
1015
+ );
1016
+ }
1017
+ return v;
1018
+ }, "callBind");
1019
+ var p = /* @__PURE__ */ a(function() {
1020
+ return l(e, o, arguments);
1021
+ }, "applyBind2");
1022
+ i ? i(t.exports, "apply", { value: p }) : t.exports.apply = p;
1023
+ }
1024
+ }), Pe = P({
1025
+ "node_modules/call-bind/callBound.js"(r, t) {
1026
+ "use strict";
1027
+ var e = $t(), n = Ce(), o = n(e("String.prototype.indexOf"));
1028
+ t.exports = /* @__PURE__ */ a(function(l, c) {
1029
+ var i = e(l, !!c);
1030
+ return typeof i == "function" && o(l, ".prototype.") > -1 ? n(i) : i;
1031
+ }, "callBoundIntrinsic");
1032
+ }
1033
+ }), Ie = P({
1034
+ "node_modules/has-tostringtag/shams.js"(r, t) {
1035
+ "use strict";
1036
+ var e = Ft();
1037
+ t.exports = /* @__PURE__ */ a(function() {
1038
+ return e() && !!Symbol.toStringTag;
1039
+ }, "hasToStringTagShams");
1040
+ }
1041
+ }), xe = P({
1042
+ "node_modules/is-regex/index.js"(r, t) {
1043
+ "use strict";
1044
+ var e = Pe(), n = Ie()(), o, s, l, c;
1045
+ n && (o = e("Object.prototype.hasOwnProperty"), s = e("RegExp.prototype.exec"), l = {}, i = /* @__PURE__ */ a(function() {
1046
+ throw l;
1047
+ }, "throwRegexMarker"), c = {
1048
+ toString: i,
1049
+ valueOf: i
1050
+ }, typeof Symbol.toPrimitive == "symbol" && (c[Symbol.toPrimitive] = i));
1051
+ var i, g = e("Object.prototype.toString"), p = Object.getOwnPropertyDescriptor, u = "[object RegExp]";
1052
+ t.exports = /* @__PURE__ */ a(n ? function(v) {
1053
+ if (!v || typeof v != "object")
1054
+ return !1;
1055
+ var d = p(v, "lastIndex"), m = d && o(d, "value");
1056
+ if (!m)
1057
+ return !1;
1058
+ try {
1059
+ s(v, c);
1060
+ } catch (E) {
1061
+ return E === l;
1062
+ }
1063
+ } : function(v) {
1064
+ return !v || typeof v != "object" && typeof v != "function" ? !1 : g(v) === u;
1065
+ }, "isRegex");
1066
+ }
1067
+ }), Re = P({
1068
+ "node_modules/is-function/index.js"(r, t) {
1069
+ t.exports = n;
1070
+ var e = Object.prototype.toString;
1071
+ function n(o) {
1072
+ if (!o)
1073
+ return !1;
1074
+ var s = e.call(o);
1075
+ return s === "[object Function]" || typeof o == "function" && s !== "[object RegExp]" || typeof window < "u" && (o === window.setTimeout ||
1076
+ o === window.alert || o === window.confirm || o === window.prompt);
1077
+ }
1078
+ a(n, "isFunction3");
1079
+ }
1080
+ }), Ne = P({
1081
+ "node_modules/is-symbol/index.js"(r, t) {
1082
+ "use strict";
1083
+ var e = Object.prototype.toString, n = Mt()();
1084
+ n ? (o = Symbol.prototype.toString, s = /^Symbol\(.*\)$/, l = /* @__PURE__ */ a(function(i) {
1085
+ return typeof i.valueOf() != "symbol" ? !1 : s.test(o.call(i));
1086
+ }, "isRealSymbolObject"), t.exports = /* @__PURE__ */ a(function(i) {
1087
+ if (typeof i == "symbol")
1088
+ return !0;
1089
+ if (e.call(i) !== "[object Symbol]")
1090
+ return !1;
1091
+ try {
1092
+ return l(i);
1093
+ } catch {
1094
+ return !1;
1095
+ }
1096
+ }, "isSymbol3")) : t.exports = /* @__PURE__ */ a(function(i) {
1097
+ return !1;
1098
+ }, "isSymbol3");
1099
+ var o, s, l;
1100
+ }
1101
+ }), je = ot(xe()), Le = ot(Re()), De = ot(Ne());
1102
+ function Fe(r) {
1103
+ return r != null && typeof r == "object" && Array.isArray(r) === !1;
1104
+ }
1105
+ a(Fe, "isObject");
1106
+ var Me = typeof global == "object" && global && global.Object === Object && global, $e = Me, Ue = typeof self == "object" && self && self.Object ===
1107
+ Object && self, ke = $e || Ue || Function("return this")(), vt = ke, Ge = vt.Symbol, U = Ge, Ut = Object.prototype, We = Ut.hasOwnProperty, ze = Ut.
1108
+ toString, q = U ? U.toStringTag : void 0;
1109
+ function He(r) {
1110
+ var t = We.call(r, q), e = r[q];
1111
+ try {
1112
+ r[q] = void 0;
1113
+ var n = !0;
1114
+ } catch {
1115
+ }
1116
+ var o = ze.call(r);
1117
+ return n && (t ? r[q] = e : delete r[q]), o;
1118
+ }
1119
+ a(He, "getRawTag");
1120
+ var Be = He, qe = Object.prototype, Ve = qe.toString;
1121
+ function Je(r) {
1122
+ return Ve.call(r);
1123
+ }
1124
+ a(Je, "objectToString");
1125
+ var Ke = Je, Ye = "[object Null]", Xe = "[object Undefined]", Rt = U ? U.toStringTag : void 0;
1126
+ function Qe(r) {
1127
+ return r == null ? r === void 0 ? Xe : Ye : Rt && Rt in Object(r) ? Be(r) : Ke(r);
1128
+ }
1129
+ a(Qe, "baseGetTag");
1130
+ var kt = Qe;
1131
+ function Ze(r) {
1132
+ return r != null && typeof r == "object";
1133
+ }
1134
+ a(Ze, "isObjectLike");
1135
+ var tr = Ze, er = "[object Symbol]";
1136
+ function rr(r) {
1137
+ return typeof r == "symbol" || tr(r) && kt(r) == er;
1138
+ }
1139
+ a(rr, "isSymbol");
1140
+ var mt = rr;
1141
+ function nr(r, t) {
1142
+ for (var e = -1, n = r == null ? 0 : r.length, o = Array(n); ++e < n; )
1143
+ o[e] = t(r[e], e, r);
1144
+ return o;
1145
+ }
1146
+ a(nr, "arrayMap");
1147
+ var or = nr, ir = Array.isArray, Et = ir, ar = 1 / 0, Nt = U ? U.prototype : void 0, jt = Nt ? Nt.toString : void 0;
1148
+ function Gt(r) {
1149
+ if (typeof r == "string")
1150
+ return r;
1151
+ if (Et(r))
1152
+ return or(r, Gt) + "";
1153
+ if (mt(r))
1154
+ return jt ? jt.call(r) : "";
1155
+ var t = r + "";
1156
+ return t == "0" && 1 / r == -ar ? "-0" : t;
1157
+ }
1158
+ a(Gt, "baseToString");
1159
+ var sr = Gt;
1160
+ function lr(r) {
1161
+ var t = typeof r;
1162
+ return r != null && (t == "object" || t == "function");
1163
+ }
1164
+ a(lr, "isObject2");
1165
+ var Wt = lr, cr = "[object AsyncFunction]", pr = "[object Function]", ur = "[object GeneratorFunction]", fr = "[object Proxy]";
1166
+ function hr(r) {
1167
+ if (!Wt(r))
1168
+ return !1;
1169
+ var t = kt(r);
1170
+ return t == pr || t == ur || t == cr || t == fr;
1171
+ }
1172
+ a(hr, "isFunction");
1173
+ var yr = hr, dr = vt["__core-js_shared__"], dt = dr, Lt = function() {
1174
+ var r = /[^.]+$/.exec(dt && dt.keys && dt.keys.IE_PROTO || "");
1175
+ return r ? "Symbol(src)_1." + r : "";
1176
+ }();
1177
+ function gr(r) {
1178
+ return !!Lt && Lt in r;
1179
+ }
1180
+ a(gr, "isMasked");
1181
+ var vr = gr, mr = Function.prototype, Er = mr.toString;
1182
+ function br(r) {
1183
+ if (r != null) {
1184
+ try {
1185
+ return Er.call(r);
1186
+ } catch {
1187
+ }
1188
+ try {
1189
+ return r + "";
1190
+ } catch {
1191
+ }
1192
+ }
1193
+ return "";
1194
+ }
1195
+ a(br, "toSource");
1196
+ var Sr = br, _r = /[\\^$.*+?()[\]{}|]/g, Tr = /^\[object .+?Constructor\]$/, Ar = Function.prototype, wr = Object.prototype, Or = Ar.toString,
1197
+ Cr = wr.hasOwnProperty, Pr = RegExp(
1198
+ "^" + Or.call(Cr).replace(_r, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
1199
+ );
1200
+ function Ir(r) {
1201
+ if (!Wt(r) || vr(r))
1202
+ return !1;
1203
+ var t = yr(r) ? Pr : Tr;
1204
+ return t.test(Sr(r));
1205
+ }
1206
+ a(Ir, "baseIsNative");
1207
+ var xr = Ir;
1208
+ function Rr(r, t) {
1209
+ return r?.[t];
1210
+ }
1211
+ a(Rr, "getValue");
1212
+ var Nr = Rr;
1213
+ function jr(r, t) {
1214
+ var e = Nr(r, t);
1215
+ return xr(e) ? e : void 0;
1216
+ }
1217
+ a(jr, "getNative");
1218
+ var zt = jr;
1219
+ function Lr(r, t) {
1220
+ return r === t || r !== r && t !== t;
1221
+ }
1222
+ a(Lr, "eq");
1223
+ var Dr = Lr, Fr = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, Mr = /^\w*$/;
1224
+ function $r(r, t) {
1225
+ if (Et(r))
1226
+ return !1;
1227
+ var e = typeof r;
1228
+ return e == "number" || e == "symbol" || e == "boolean" || r == null || mt(r) ? !0 : Mr.test(r) || !Fr.test(r) || t != null && r in Object(
1229
+ t);
1230
+ }
1231
+ a($r, "isKey");
1232
+ var Ur = $r, kr = zt(Object, "create"), V = kr;
1233
+ function Gr() {
1234
+ this.__data__ = V ? V(null) : {}, this.size = 0;
1235
+ }
1236
+ a(Gr, "hashClear");
1237
+ var Wr = Gr;
1238
+ function zr(r) {
1239
+ var t = this.has(r) && delete this.__data__[r];
1240
+ return this.size -= t ? 1 : 0, t;
1241
+ }
1242
+ a(zr, "hashDelete");
1243
+ var Hr = zr, Br = "__lodash_hash_undefined__", qr = Object.prototype, Vr = qr.hasOwnProperty;
1244
+ function Jr(r) {
1245
+ var t = this.__data__;
1246
+ if (V) {
1247
+ var e = t[r];
1248
+ return e === Br ? void 0 : e;
1249
+ }
1250
+ return Vr.call(t, r) ? t[r] : void 0;
1251
+ }
1252
+ a(Jr, "hashGet");
1253
+ var Kr = Jr, Yr = Object.prototype, Xr = Yr.hasOwnProperty;
1254
+ function Qr(r) {
1255
+ var t = this.__data__;
1256
+ return V ? t[r] !== void 0 : Xr.call(t, r);
1257
+ }
1258
+ a(Qr, "hashHas");
1259
+ var Zr = Qr, tn = "__lodash_hash_undefined__";
1260
+ function en(r, t) {
1261
+ var e = this.__data__;
1262
+ return this.size += this.has(r) ? 0 : 1, e[r] = V && t === void 0 ? tn : t, this;
1263
+ }
1264
+ a(en, "hashSet");
1265
+ var rn = en;
1266
+ function k(r) {
1267
+ var t = -1, e = r == null ? 0 : r.length;
1268
+ for (this.clear(); ++t < e; ) {
1269
+ var n = r[t];
1270
+ this.set(n[0], n[1]);
1271
+ }
1272
+ }
1273
+ a(k, "Hash");
1274
+ k.prototype.clear = Wr;
1275
+ k.prototype.delete = Hr;
1276
+ k.prototype.get = Kr;
1277
+ k.prototype.has = Zr;
1278
+ k.prototype.set = rn;
1279
+ var Dt = k;
1280
+ function nn() {
1281
+ this.__data__ = [], this.size = 0;
1282
+ }
1283
+ a(nn, "listCacheClear");
1284
+ var on = nn;
1285
+ function an(r, t) {
1286
+ for (var e = r.length; e--; )
1287
+ if (Dr(r[e][0], t))
1288
+ return e;
1289
+ return -1;
1290
+ }
1291
+ a(an, "assocIndexOf");
1292
+ var at = an, sn = Array.prototype, ln = sn.splice;
1293
+ function cn(r) {
1294
+ var t = this.__data__, e = at(t, r);
1295
+ if (e < 0)
1296
+ return !1;
1297
+ var n = t.length - 1;
1298
+ return e == n ? t.pop() : ln.call(t, e, 1), --this.size, !0;
1299
+ }
1300
+ a(cn, "listCacheDelete");
1301
+ var pn = cn;
1302
+ function un(r) {
1303
+ var t = this.__data__, e = at(t, r);
1304
+ return e < 0 ? void 0 : t[e][1];
1305
+ }
1306
+ a(un, "listCacheGet");
1307
+ var fn = un;
1308
+ function hn(r) {
1309
+ return at(this.__data__, r) > -1;
1310
+ }
1311
+ a(hn, "listCacheHas");
1312
+ var yn = hn;
1313
+ function dn(r, t) {
1314
+ var e = this.__data__, n = at(e, r);
1315
+ return n < 0 ? (++this.size, e.push([r, t])) : e[n][1] = t, this;
1316
+ }
1317
+ a(dn, "listCacheSet");
1318
+ var gn = dn;
1319
+ function G(r) {
1320
+ var t = -1, e = r == null ? 0 : r.length;
1321
+ for (this.clear(); ++t < e; ) {
1322
+ var n = r[t];
1323
+ this.set(n[0], n[1]);
1324
+ }
1325
+ }
1326
+ a(G, "ListCache");
1327
+ G.prototype.clear = on;
1328
+ G.prototype.delete = pn;
1329
+ G.prototype.get = fn;
1330
+ G.prototype.has = yn;
1331
+ G.prototype.set = gn;
1332
+ var vn = G, mn = zt(vt, "Map"), En = mn;
1333
+ function bn() {
1334
+ this.size = 0, this.__data__ = {
1335
+ hash: new Dt(),
1336
+ map: new (En || vn)(),
1337
+ string: new Dt()
1338
+ };
1339
+ }
1340
+ a(bn, "mapCacheClear");
1341
+ var Sn = bn;
1342
+ function _n(r) {
1343
+ var t = typeof r;
1344
+ return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? r !== "__proto__" : r === null;
1345
+ }
1346
+ a(_n, "isKeyable");
1347
+ var Tn = _n;
1348
+ function An(r, t) {
1349
+ var e = r.__data__;
1350
+ return Tn(t) ? e[typeof t == "string" ? "string" : "hash"] : e.map;
1351
+ }
1352
+ a(An, "getMapData");
1353
+ var st = An;
1354
+ function wn(r) {
1355
+ var t = st(this, r).delete(r);
1356
+ return this.size -= t ? 1 : 0, t;
1357
+ }
1358
+ a(wn, "mapCacheDelete");
1359
+ var On = wn;
1360
+ function Cn(r) {
1361
+ return st(this, r).get(r);
1362
+ }
1363
+ a(Cn, "mapCacheGet");
1364
+ var Pn = Cn;
1365
+ function In(r) {
1366
+ return st(this, r).has(r);
1367
+ }
1368
+ a(In, "mapCacheHas");
1369
+ var xn = In;
1370
+ function Rn(r, t) {
1371
+ var e = st(this, r), n = e.size;
1372
+ return e.set(r, t), this.size += e.size == n ? 0 : 1, this;
1373
+ }
1374
+ a(Rn, "mapCacheSet");
1375
+ var Nn = Rn;
1376
+ function W(r) {
1377
+ var t = -1, e = r == null ? 0 : r.length;
1378
+ for (this.clear(); ++t < e; ) {
1379
+ var n = r[t];
1380
+ this.set(n[0], n[1]);
1381
+ }
1382
+ }
1383
+ a(W, "MapCache");
1384
+ W.prototype.clear = Sn;
1385
+ W.prototype.delete = On;
1386
+ W.prototype.get = Pn;
1387
+ W.prototype.has = xn;
1388
+ W.prototype.set = Nn;
1389
+ var Ht = W, jn = "Expected a function";
1390
+ function bt(r, t) {
1391
+ if (typeof r != "function" || t != null && typeof t != "function")
1392
+ throw new TypeError(jn);
1393
+ var e = /* @__PURE__ */ a(function() {
1394
+ var n = arguments, o = t ? t.apply(this, n) : n[0], s = e.cache;
1395
+ if (s.has(o))
1396
+ return s.get(o);
1397
+ var l = r.apply(this, n);
1398
+ return e.cache = s.set(o, l) || s, l;
1399
+ }, "memoized");
1400
+ return e.cache = new (bt.Cache || Ht)(), e;
1401
+ }
1402
+ a(bt, "memoize");
1403
+ bt.Cache = Ht;
1404
+ var Ln = bt, Dn = 500;
1405
+ function Fn(r) {
1406
+ var t = Ln(r, function(n) {
1407
+ return e.size === Dn && e.clear(), n;
1408
+ }), e = t.cache;
1409
+ return t;
1410
+ }
1411
+ a(Fn, "memoizeCapped");
1412
+ var Mn = Fn, $n = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, Un = /\\(\\)?/g, kn = Mn(
1413
+ function(r) {
1414
+ var t = [];
1415
+ return r.charCodeAt(0) === 46 && t.push(""), r.replace($n, function(e, n, o, s) {
1416
+ t.push(o ? s.replace(Un, "$1") : n || e);
1417
+ }), t;
1418
+ }), Gn = kn;
1419
+ function Wn(r) {
1420
+ return r == null ? "" : sr(r);
1421
+ }
1422
+ a(Wn, "toString");
1423
+ var zn = Wn;
1424
+ function Hn(r, t) {
1425
+ return Et(r) ? r : Ur(r, t) ? [r] : Gn(zn(r));
1426
+ }
1427
+ a(Hn, "castPath");
1428
+ var Bn = Hn, qn = 1 / 0;
1429
+ function Vn(r) {
1430
+ if (typeof r == "string" || mt(r))
1431
+ return r;
1432
+ var t = r + "";
1433
+ return t == "0" && 1 / r == -qn ? "-0" : t;
1434
+ }
1435
+ a(Vn, "toKey");
1436
+ var Jn = Vn;
1437
+ function Kn(r, t) {
1438
+ t = Bn(t, r);
1439
+ for (var e = 0, n = t.length; r != null && e < n; )
1440
+ r = r[Jn(t[e++])];
1441
+ return e && e == n ? r : void 0;
1442
+ }
1443
+ a(Kn, "baseGet");
1444
+ var Yn = Kn;
1445
+ function Xn(r, t, e) {
1446
+ var n = r == null ? void 0 : Yn(r, t);
1447
+ return n === void 0 ? e : n;
1448
+ }
1449
+ a(Xn, "get");
1450
+ var Qn = Xn, it = Fe, Zn = /* @__PURE__ */ a((r) => {
1451
+ let t = null, e = !1, n = !1, o = !1, s = "";
1452
+ if (r.indexOf("//") >= 0 || r.indexOf("/*") >= 0)
1453
+ for (let l = 0; l < r.length; l += 1)
1454
+ !t && !e && !n && !o ? r[l] === '"' || r[l] === "'" || r[l] === "`" ? t = r[l] : r[l] === "/" && r[l + 1] === "*" ? e = !0 : r[l] === "\
1455
+ /" && r[l + 1] === "/" ? n = !0 : r[l] === "/" && r[l + 1] !== "/" && (o = !0) : (t && (r[l] === t && r[l - 1] !== "\\" || r[l] === `
1456
+ ` && t !== "`") && (t = null), o && (r[l] === "/" && r[l - 1] !== "\\" || r[l] === `
1457
+ `) && (o = !1), e && r[l - 1] === "/" && r[l - 2] === "*" && (e = !1), n && r[l] === `
1458
+ ` && (n = !1)), !e && !n && (s += r[l]);
1459
+ else
1460
+ s = r;
1461
+ return s;
1462
+ }, "removeCodeComments"), to = (0, Bt.default)(1e4)(
1463
+ (r) => Zn(r).replace(/\n\s*/g, "").trim()
1464
+ ), eo = /* @__PURE__ */ a(function(t, e) {
1465
+ let n = e.slice(0, e.indexOf("{")), o = e.slice(e.indexOf("{"));
1466
+ if (n.includes("=>") || n.includes("function"))
1467
+ return e;
1468
+ let s = n;
1469
+ return s = s.replace(t, "function"), s + o;
1470
+ }, "convertShorthandMethods2"), ro = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/, J = /* @__PURE__ */ a((r) => r.match(/^[\[\{\"\}].*[\]\}\"]$/),
1471
+ "isJSON");
1472
+ function qt(r) {
1473
+ if (!it(r))
1474
+ return r;
1475
+ let t = r, e = !1;
1476
+ return typeof Event < "u" && r instanceof Event && (t = Pt(t), e = !0), t = Object.keys(t).reduce((n, o) => {
1477
+ try {
1478
+ t[o] && t[o].toJSON, n[o] = t[o];
1479
+ } catch {
1480
+ e = !0;
1481
+ }
1482
+ return n;
1483
+ }, {}), e ? t : r;
1484
+ }
1485
+ a(qt, "convertUnconventionalData");
1486
+ var no = /* @__PURE__ */ a(function(t) {
1487
+ let e, n, o, s;
1488
+ return /* @__PURE__ */ a(function(c, i) {
1489
+ try {
1490
+ if (c === "")
1491
+ return s = [], e = /* @__PURE__ */ new Map([[i, "[]"]]), n = /* @__PURE__ */ new Map(), o = [], i;
1492
+ let g = n.get(this) || this;
1493
+ for (; o.length && g !== o[0]; )
1494
+ o.shift(), s.pop();
1495
+ if (typeof i == "boolean")
1496
+ return i;
1497
+ if (i === void 0)
1498
+ return t.allowUndefined ? "_undefined_" : void 0;
1499
+ if (i === null)
1500
+ return null;
1501
+ if (typeof i == "number")
1502
+ return i === -1 / 0 ? "_-Infinity_" : i === 1 / 0 ? "_Infinity_" : Number.isNaN(i) ? "_NaN_" : i;
1503
+ if (typeof i == "bigint")
1504
+ return `_bigint_${i.toString()}`;
1505
+ if (typeof i == "string")
1506
+ return ro.test(i) ? t.allowDate ? `_date_${i}` : void 0 : i;
1507
+ if ((0, je.default)(i))
1508
+ return t.allowRegExp ? `_regexp_${i.flags}|${i.source}` : void 0;
1509
+ if ((0, Le.default)(i)) {
1510
+ if (!t.allowFunction)
1511
+ return;
1512
+ let { name: u } = i, y = i.toString();
1513
+ return y.match(
1514
+ /(\[native code\]|WEBPACK_IMPORTED_MODULE|__webpack_exports__|__webpack_require__)/
1515
+ ) ? `_function_${u}|${(() => {
1516
+ }).toString()}` : `_function_${u}|${to(eo(c, y))}`;
1517
+ }
1518
+ if ((0, De.default)(i)) {
1519
+ if (!t.allowSymbol)
1520
+ return;
1521
+ let u = Symbol.keyFor(i);
1522
+ return u !== void 0 ? `_gsymbol_${u}` : `_symbol_${i.toString().slice(7, -1)}`;
1523
+ }
1524
+ if (o.length >= t.maxDepth)
1525
+ return Array.isArray(i) ? `[Array(${i.length})]` : "[Object]";
1526
+ if (i === this)
1527
+ return `_duplicate_${JSON.stringify(s)}`;
1528
+ if (i instanceof Error && t.allowError)
1529
+ return {
1530
+ __isConvertedError__: !0,
1531
+ errorProperties: {
1532
+ ...i.cause ? { cause: i.cause } : {},
1533
+ ...i,
1534
+ name: i.name,
1535
+ message: i.message,
1536
+ stack: i.stack,
1537
+ "_constructor-name_": i.constructor.name
1538
+ }
1539
+ };
1540
+ if (i.constructor && i.constructor.name && i.constructor.name !== "Object" && !Array.isArray(i) && !t.allowClass)
1541
+ return;
1542
+ let p = e.get(i);
1543
+ if (!p) {
1544
+ let u = Array.isArray(i) ? i : qt(i);
1545
+ if (i.constructor && i.constructor.name && i.constructor.name !== "Object" && !Array.isArray(i) && t.allowClass)
1546
+ try {
1547
+ Object.assign(u, { "_constructor-name_": i.constructor.name });
1548
+ } catch {
1549
+ }
1550
+ return s.push(c), o.unshift(u), e.set(i, JSON.stringify(s)), i !== u && n.set(i, u), u;
1551
+ }
1552
+ return `_duplicate_${p}`;
1553
+ } catch {
1554
+ return;
1555
+ }
1556
+ }, "replace");
1557
+ }, "replacer2"), oo = /* @__PURE__ */ a(function reviver(options) {
1558
+ let refs = [], root;
1559
+ return /* @__PURE__ */ a(function revive(key, value) {
1560
+ if (key === "" && (root = value, refs.forEach(({ target: r, container: t, replacement: e }) => {
1561
+ let n = J(e) ? JSON.parse(e) : e.split(".");
1562
+ n.length === 0 ? t[r] = root : t[r] = Qn(root, n);
1563
+ })), key === "_constructor-name_")
1564
+ return value;
1565
+ if (it(value) && value.__isConvertedError__) {
1566
+ let { message: r, ...t } = value.errorProperties, e = new Error(r);
1567
+ return Object.assign(e, t), e;
1568
+ }
1569
+ if (it(value) && value["_constructor-name_"] && options.allowFunction) {
1570
+ let r = value["_constructor-name_"];
1571
+ if (r !== "Object") {
1572
+ let t = new Function(`return function ${r.replace(/[^a-zA-Z0-9$_]+/g, "")}(){}`)();
1573
+ Object.setPrototypeOf(value, new t());
1574
+ }
1575
+ return delete value["_constructor-name_"], value;
1576
+ }
1577
+ if (typeof value == "string" && value.startsWith("_function_") && options.allowFunction) {
1578
+ let [, name, source] = value.match(/_function_([^|]*)\|(.*)/) || [], sourceSanitized = source.replace(/[(\(\))|\\| |\]|`]*$/, "");
1579
+ if (!options.lazyEval)
1580
+ return eval(`(${sourceSanitized})`);
1581
+ let result = /* @__PURE__ */ a((...args) => {
1582
+ let f = eval(`(${sourceSanitized})`);
1583
+ return f(...args);
1584
+ }, "result");
1585
+ return Object.defineProperty(result, "toString", {
1586
+ value: /* @__PURE__ */ a(() => sourceSanitized, "value")
1587
+ }), Object.defineProperty(result, "name", {
1588
+ value: name
1589
+ }), result;
1590
+ }
1591
+ if (typeof value == "string" && value.startsWith("_regexp_") && options.allowRegExp) {
1592
+ let [, r, t] = value.match(/_regexp_([^|]*)\|(.*)/) || [];
1593
+ return new RegExp(t, r);
1594
+ }
1595
+ return typeof value == "string" && value.startsWith("_date_") && options.allowDate ? new Date(value.replace("_date_", "")) : typeof value ==
1596
+ "string" && value.startsWith("_duplicate_") ? (refs.push({ target: key, container: this, replacement: value.replace(/^_duplicate_/, "") }),
1597
+ null) : typeof value == "string" && value.startsWith("_symbol_") && options.allowSymbol ? Symbol(value.replace("_symbol_", "")) : typeof value ==
1598
+ "string" && value.startsWith("_gsymbol_") && options.allowSymbol ? Symbol.for(value.replace("_gsymbol_", "")) : typeof value == "string" &&
1599
+ value === "_-Infinity_" ? -1 / 0 : typeof value == "string" && value === "_Infinity_" ? 1 / 0 : typeof value == "string" && value === "_\
1600
+ NaN_" ? NaN : typeof value == "string" && value.startsWith("_bigint_") && typeof BigInt == "function" ? BigInt(value.replace("_bigint_", "")) :
1601
+ value;
1602
+ }, "revive");
1603
+ }, "reviver"), Vt = {
1604
+ maxDepth: 10,
1605
+ space: void 0,
1606
+ allowFunction: !0,
1607
+ allowRegExp: !0,
1608
+ allowDate: !0,
1609
+ allowClass: !0,
1610
+ allowError: !0,
1611
+ allowUndefined: !0,
1612
+ allowSymbol: !0,
1613
+ lazyEval: !0
1614
+ }, lt = /* @__PURE__ */ a((r, t = {}) => {
1615
+ let e = { ...Vt, ...t };
1616
+ return JSON.stringify(qt(r), no(e), t.space);
1617
+ }, "stringify"), io = /* @__PURE__ */ a(() => {
1618
+ let r = /* @__PURE__ */ new Map();
1619
+ return /* @__PURE__ */ a(function t(e) {
1620
+ it(e) && Object.entries(e).forEach(([n, o]) => {
1621
+ o === "_undefined_" ? e[n] = void 0 : r.get(o) || (r.set(o, !0), t(o));
1622
+ }), Array.isArray(e) && e.forEach((n, o) => {
1623
+ n === "_undefined_" ? (r.set(n, !0), e[o] = void 0) : r.get(n) || (r.set(n, !0), t(n));
1624
+ });
1625
+ }, "mutateUndefined");
1626
+ }, "mutator"), ct = /* @__PURE__ */ a((r, t = {}) => {
1627
+ let e = { ...Vt, ...t }, n = JSON.parse(r, oo(e));
1628
+ return io()(n), n;
1629
+ }, "parse");
1630
+
1631
+ // ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
1632
+ var ao = !1, St = "Invariant failed";
1633
+ function K(r, t) {
1634
+ if (!r) {
1635
+ if (ao)
1636
+ throw new Error(St);
1637
+ var e = typeof t == "function" ? t() : t, n = e ? "".concat(St, ": ").concat(e) : St;
1638
+ throw new Error(n);
1639
+ }
1640
+ }
1641
+ a(K, "invariant");
1642
+
1643
+ // src/channels/postmessage/getEventSourceUrl.ts
1644
+ import { logger as so } from "storybook/internal/client-logger";
1645
+ var Jt = /* @__PURE__ */ a((r) => {
1646
+ let t = Array.from(
1647
+ document.querySelectorAll("iframe[data-is-storybook]")
1648
+ ), [e, ...n] = t.filter((s) => {
1649
+ try {
1650
+ return s.contentWindow?.location.origin === r.source.location.origin && s.contentWindow?.location.pathname === r.source.location.pathname;
1651
+ } catch {
1652
+ }
1653
+ try {
1654
+ return s.contentWindow === r.source;
1655
+ } catch {
1656
+ }
1657
+ let l = s.getAttribute("src"), c;
1658
+ try {
1659
+ if (!l)
1660
+ return !1;
1661
+ ({ origin: c } = new URL(l, document.location.toString()));
1662
+ } catch {
1663
+ return !1;
1664
+ }
1665
+ return c === r.origin;
1666
+ }), o = e?.getAttribute("src");
1667
+ if (o && n.length === 0) {
1668
+ let { protocol: s, host: l, pathname: c } = new URL(o, document.location.toString());
1669
+ return `${s}//${l}${c}`;
1670
+ }
1671
+ return n.length > 0 && so.error("found multiple candidates for event source"), null;
1672
+ }, "getEventSourceUrl");
1673
+
1674
+ // src/channels/postmessage/index.ts
1675
+ var { document: _t, location: Tt } = A, Xt = "storybook-channel", co = { allowFunction: !1, maxDepth: 25 }, At = class At {
1676
+ constructor(t) {
1677
+ this.config = t;
1678
+ this.connected = !1;
1679
+ if (this.buffer = [], typeof A?.addEventListener == "function" && A.addEventListener("message", this.handleEvent.bind(this), !1), t.page !==
1680
+ "manager" && t.page !== "preview")
1681
+ throw new Error(`postmsg-channel: "config.page" cannot be "${t.page}"`);
1682
+ }
1683
+ setHandler(t) {
1684
+ this.handler = (...e) => {
1685
+ t.apply(this, e), !this.connected && this.getLocalFrame().length && (this.flush(), this.connected = !0);
1686
+ };
1687
+ }
1688
+ /**
1689
+ * Sends `event` to the associated window. If the window does not yet exist the event will be
1690
+ * stored in a buffer and sent when the window exists.
1691
+ *
1692
+ * @param event
1693
+ */
1694
+ send(t, e) {
1695
+ let {
1696
+ target: n,
1697
+ // telejson options
1698
+ allowRegExp: o,
1699
+ allowFunction: s,
1700
+ allowSymbol: l,
1701
+ allowDate: c,
1702
+ allowError: i,
1703
+ allowUndefined: g,
1704
+ allowClass: p,
1705
+ maxDepth: u,
1706
+ space: y,
1707
+ lazyEval: v
1708
+ } = e || {}, d = Object.fromEntries(
1709
+ Object.entries({
1710
+ allowRegExp: o,
1711
+ allowFunction: s,
1712
+ allowSymbol: l,
1713
+ allowDate: c,
1714
+ allowError: i,
1715
+ allowUndefined: g,
1716
+ allowClass: p,
1717
+ maxDepth: u,
1718
+ space: y,
1719
+ lazyEval: v
1720
+ }).filter(([R, C]) => typeof C < "u")
1721
+ ), m = {
1722
+ ...co,
1723
+ ...A.CHANNEL_OPTIONS || {},
1724
+ ...d
1725
+ }, E = this.getFrames(n), I = new URLSearchParams(Tt?.search || ""), _ = lt(
1726
+ {
1727
+ key: Xt,
1728
+ event: t,
1729
+ refId: I.get("refId")
1730
+ },
1731
+ m
1732
+ );
1733
+ return E.length ? (this.buffer.length && this.flush(), E.forEach((R) => {
1734
+ try {
1735
+ R.postMessage(_, "*");
1736
+ } catch {
1737
+ Kt.error("sending over postmessage fail");
1738
+ }
1739
+ }), Promise.resolve(null)) : new Promise((R, C) => {
1740
+ this.buffer.push({ event: t, resolve: R, reject: C });
1741
+ });
1742
+ }
1743
+ flush() {
1744
+ let { buffer: t } = this;
1745
+ this.buffer = [], t.forEach((e) => {
1746
+ this.send(e.event).then(e.resolve).catch(e.reject);
1747
+ });
1748
+ }
1749
+ getFrames(t) {
1750
+ if (this.config.page === "manager") {
1751
+ let n = Array.from(
1752
+ _t.querySelectorAll("iframe[data-is-storybook][data-is-loaded]")
1753
+ ).flatMap((o) => {
1754
+ try {
1755
+ return o.contentWindow && o.dataset.isStorybook !== void 0 && o.id === t ? [o.contentWindow] : [];
1756
+ } catch {
1757
+ return [];
1758
+ }
1759
+ });
1760
+ return n?.length ? n : this.getCurrentFrames();
1761
+ }
1762
+ return A && A.parent && A.parent !== A.self ? [A.parent] : [];
1763
+ }
1764
+ getCurrentFrames() {
1765
+ return this.config.page === "manager" ? Array.from(
1766
+ _t.querySelectorAll('[data-is-storybook="true"]')
1767
+ ).flatMap((e) => e.contentWindow ? [e.contentWindow] : []) : A && A.parent ? [A.parent] : [];
1768
+ }
1769
+ getLocalFrame() {
1770
+ return this.config.page === "manager" ? Array.from(
1771
+ _t.querySelectorAll("#storybook-preview-iframe")
1772
+ ).flatMap((e) => e.contentWindow ? [e.contentWindow] : []) : A && A.parent ? [A.parent] : [];
1773
+ }
1774
+ handleEvent(t) {
1775
+ try {
1776
+ let { data: e } = t, { key: n, event: o, refId: s } = typeof e == "string" && J(e) ? ct(e, A.CHANNEL_OPTIONS || {}) : e;
1777
+ if (n === Xt) {
1778
+ let l = this.config.page === "manager" ? '<span style="color: #37D5D3; background: black"> manager </span>' : '<span style="color: #\
1779
+ 1EA7FD; background: black"> preview </span>', c = Object.values(lo).includes(o.type) ? `<span style="color: #FF4785">${o.type}</span>` : `<s\
1780
+ pan style="color: #FFAE00">${o.type}</span>`;
1781
+ if (s && (o.refId = s), o.source = this.config.page === "preview" ? t.origin : Jt(t), !o.source) {
1782
+ Yt.error(
1783
+ `${l} received ${c} but was unable to determine the source of the event`
1784
+ );
1785
+ return;
1786
+ }
1787
+ let i = `${l} received ${c} (${e.length})`;
1788
+ Yt.debug(
1789
+ Tt.origin !== o.source ? i : `${i} <span style="color: gray">(on ${Tt.origin} from ${o.source})</span>`,
1790
+ ...o.args
1791
+ ), K(this.handler, "ChannelHandler should be set"), this.handler(o);
1792
+ }
1793
+ } catch (e) {
1794
+ Kt.error(e);
1795
+ }
1796
+ }
1797
+ };
1798
+ a(At, "PostMessageTransport");
1799
+ var Y = At;
1800
+
1801
+ // src/channels/websocket/index.ts
1802
+ import * as Qt from "storybook/internal/core-events";
1803
+ import { global as Zt } from "@storybook/global";
1804
+ var { WebSocket: po } = Zt, te = 15e3, ee = 5e3, wt = class wt {
1805
+ constructor({ url: t, onError: e, page: n }) {
1806
+ this.buffer = [];
1807
+ this.isReady = !1;
1808
+ this.isClosed = !1;
1809
+ this.pingTimeout = 0;
1810
+ this.socket = new po(t), this.socket.onopen = () => {
1811
+ this.isReady = !0, this.heartbeat(), this.flush();
1812
+ }, this.socket.onmessage = ({ data: o }) => {
1813
+ let s = typeof o == "string" && J(o) ? ct(o) : o;
1814
+ K(this.handler, "WebsocketTransport handler should be set"), this.handler(s), s.type === "ping" && (this.heartbeat(), this.send({ type: "\
1815
+ pong" }));
1816
+ }, this.socket.onerror = (o) => {
1817
+ e && e(o);
1818
+ }, this.socket.onclose = (o) => {
1819
+ K(this.handler, "WebsocketTransport handler should be set"), this.handler({
1820
+ type: Qt.CHANNEL_WS_DISCONNECT,
1821
+ args: [{ reason: o.reason, code: o.code }],
1822
+ from: n || "preview"
1823
+ }), this.isClosed = !0, clearTimeout(this.pingTimeout);
1824
+ };
1825
+ }
1826
+ heartbeat() {
1827
+ clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => {
1828
+ this.socket.close(3008, "timeout");
1829
+ }, te + ee);
1830
+ }
1831
+ setHandler(t) {
1832
+ this.handler = t;
1833
+ }
1834
+ send(t) {
1835
+ this.isClosed || (this.isReady ? this.sendNow(t) : this.sendLater(t));
1836
+ }
1837
+ sendLater(t) {
1838
+ this.buffer.push(t);
1839
+ }
1840
+ sendNow(t) {
1841
+ let e = lt(t, {
1842
+ maxDepth: 15,
1843
+ allowFunction: !1,
1844
+ ...Zt.CHANNEL_OPTIONS
1845
+ });
1846
+ this.socket.send(e);
1847
+ }
1848
+ flush() {
1849
+ let { buffer: t } = this;
1850
+ this.buffer = [], t.forEach((e) => this.send(e));
1851
+ }
1852
+ };
1853
+ a(wt, "WebsocketTransport");
1854
+ var X = wt;
1855
+
1856
+ // src/channels/index.ts
1857
+ var { CONFIG_TYPE: fo } = uo, Qo = B;
1858
+ function Zo({ page: r, extraTransports: t = [] }) {
1859
+ let e = [new Y({ page: r }), ...t];
1860
+ if (fo === "DEVELOPMENT") {
1861
+ let o = window.location.protocol === "http:" ? "ws" : "wss", { hostname: s, port: l } = window.location, c = `${o}://${s}:${l}/storybook\
1862
+ -server-channel`;
1863
+ e.push(new X({ url: c, onError: /* @__PURE__ */ a(() => {
1864
+ }, "onError"), page: r }));
1865
+ }
1866
+ let n = new B({ transports: e });
1867
+ return $.__prepare(
1868
+ n,
1869
+ r === "manager" ? $.Environment.MANAGER : $.Environment.PREVIEW
1870
+ ), n;
1871
+ }
1872
+ a(Zo, "createBrowserChannel");
1873
+ export {
1874
+ B as Channel,
1875
+ te as HEARTBEAT_INTERVAL,
1876
+ ee as HEARTBEAT_MAX_LATENCY,
1877
+ Y as PostMessageTransport,
1878
+ X as WebsocketTransport,
1879
+ Zo as createBrowserChannel,
1880
+ Qo as default
1881
+ };