storybook 10.1.0-alpha.10 → 10.1.0-alpha.12

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 (192) 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-3IAH5M2U.js +171 -0
  5. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  6. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  7. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  8. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  9. package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-74YHFU5B.js} +44 -109
  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-BE2DAXKJ.js +2966 -0
  15. package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  16. package/dist/_browser-chunks/chunk-EBHB6RPS.js +61 -0
  17. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  18. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  19. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  20. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -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-QMY4G4R2.js → chunk-L4RMQ7D7.js} +17 -64
  26. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  27. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  28. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  29. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  30. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  31. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
  32. package/dist/_browser-chunks/chunk-WXP2XJ3O.js +950 -0
  33. package/dist/_browser-chunks/chunk-X3DUQ5RA.js +47 -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-RJZASWHL.js → syntaxhighlighter-WKBQ5RC7.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-HA7CYFCK.js → builder-manager-YUOHSIUB.js} +475 -1013
  40. package/dist/_node-chunks/camelcase-JREIL7NV.js +18 -0
  41. package/dist/_node-chunks/{chunk-RMHAL25C.js → chunk-2D2IODUU.js} +88 -228
  42. package/dist/_node-chunks/chunk-2DMESZFJ.js +943 -0
  43. package/dist/_node-chunks/chunk-4FT2DHGE.js +3009 -0
  44. package/dist/_node-chunks/chunk-5HV3B5OP.js +45571 -0
  45. package/dist/_node-chunks/{chunk-OVXB5GGT.js → chunk-5KLIDWFN.js} +292 -688
  46. package/dist/_node-chunks/chunk-A4APXFQ2.js +759 -0
  47. package/dist/_node-chunks/chunk-B6JWY6PC.js +37 -0
  48. package/dist/_node-chunks/chunk-CZ5GHJCC.js +603 -0
  49. package/dist/_node-chunks/chunk-DUXPWBOK.js +61 -0
  50. package/dist/_node-chunks/chunk-DWXTZT3D.js +58 -0
  51. package/dist/_node-chunks/chunk-E5FJS66Z.js +20 -0
  52. package/dist/_node-chunks/chunk-EZWWR7AR.js +936 -0
  53. package/dist/_node-chunks/chunk-FDXFVHIL.js +1114 -0
  54. package/dist/_node-chunks/{chunk-F3XOPI6H.js → chunk-FZLRAH4N.js} +469 -983
  55. package/dist/_node-chunks/chunk-HZG65SU3.js +34 -0
  56. package/dist/_node-chunks/chunk-IXVYNBMD.js +18 -0
  57. package/dist/_node-chunks/chunk-JARUEMEP.js +4523 -0
  58. package/dist/_node-chunks/chunk-LIH7MTP7.js +3214 -0
  59. package/dist/_node-chunks/chunk-N5GIRUP5.js +1047 -0
  60. package/dist/_node-chunks/{chunk-X4XU27M6.js → chunk-NAOYEL54.js} +15 -24
  61. package/dist/_node-chunks/chunk-O5DA7YLO.js +3171 -0
  62. package/dist/_node-chunks/chunk-OP3INKUD.js +54 -0
  63. package/dist/_node-chunks/chunk-QCO2ZM7F.js +209 -0
  64. package/dist/_node-chunks/chunk-QYQIZBS6.js +26 -0
  65. package/dist/_node-chunks/chunk-SEMIAAWG.js +1564 -0
  66. package/dist/_node-chunks/chunk-TS2UUH2J.js +301 -0
  67. package/dist/_node-chunks/chunk-WA6KZQZ2.js +119 -0
  68. package/dist/_node-chunks/{chunk-ZHSCUGNP.js → chunk-WFLWJO24.js} +3799 -7849
  69. package/dist/_node-chunks/chunk-WUXQMQCB.js +72 -0
  70. package/dist/_node-chunks/{chunk-VPR5IBMG.js → chunk-XXPJ7XR3.js} +8 -10
  71. package/dist/_node-chunks/chunk-Y4E6IGQF.js +61 -0
  72. package/dist/_node-chunks/chunk-ZL3AFKRX.js +1029 -0
  73. package/dist/_node-chunks/chunk-ZXSD6L3S.js +756 -0
  74. package/dist/_node-chunks/dist-DS2B5A3J.js +121 -0
  75. package/dist/_node-chunks/globby-6THB7HVX.js +3452 -0
  76. package/dist/_node-chunks/lib-5NKX4YGG.js +366 -0
  77. package/dist/_node-chunks/mdx-N42X6CFJ-ZLT3QOFF.js +14329 -0
  78. package/dist/_node-chunks/p-limit-PDMWNG7W.js +116 -0
  79. package/dist/_node-chunks/plugin-6XMWOGPO.js +123 -0
  80. package/dist/_node-chunks/{plugin-6ZPCS4LI.js → plugin-LTOXVT6A.js} +36 -56
  81. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-2SFE5LQS.js +46582 -0
  82. package/dist/_node-chunks/webpack-mock-plugin-CX5J2U56.js +92 -0
  83. package/dist/actions/decorator.js +21 -42
  84. package/dist/actions/index.js +3 -3
  85. package/dist/babel/index.d.ts +671 -335
  86. package/dist/babel/index.js +11 -11
  87. package/dist/bin/core.js +592 -1546
  88. package/dist/bin/dispatcher.js +26 -37
  89. package/dist/bin/loader.js +23 -34
  90. package/dist/channels/index.js +98 -234
  91. package/dist/cli/index.js +1951 -5308
  92. package/dist/client-logger/index.js +31 -61
  93. package/dist/common/index.js +20 -20
  94. package/dist/components/index.js +4211 -8586
  95. package/dist/core-events/index.js +2 -66
  96. package/dist/core-server/index.js +3054 -7290
  97. package/dist/core-server/presets/common-manager.css +2 -2
  98. package/dist/core-server/presets/common-manager.js +1806 -3427
  99. package/dist/core-server/presets/common-override-preset.js +31 -60
  100. package/dist/core-server/presets/common-preset.js +434 -924
  101. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +15 -19
  102. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +12 -17
  103. package/dist/csf/index.js +534 -1179
  104. package/dist/csf-tools/index.js +9 -9
  105. package/dist/docs-tools/index.js +6 -6
  106. package/dist/highlight/index.js +2 -2
  107. package/dist/instrumenter/index.js +199 -415
  108. package/dist/manager/globals-runtime.js +24150 -47364
  109. package/dist/manager/globals.js +2 -3
  110. package/dist/manager/runtime.js +3961 -8373
  111. package/dist/manager-api/index.js +1231 -2425
  112. package/dist/manager-errors.d.ts +3 -0
  113. package/dist/manager-errors.js +3 -3
  114. package/dist/node-logger/index.js +1253 -2601
  115. package/dist/preview/globals.js +2 -3
  116. package/dist/preview/runtime.js +10364 -21990
  117. package/dist/preview-api/index.d.ts +67 -68
  118. package/dist/preview-api/index.js +13 -13
  119. package/dist/preview-errors.d.ts +3 -0
  120. package/dist/preview-errors.js +4 -4
  121. package/dist/router/index.js +347 -899
  122. package/dist/server-errors.d.ts +3 -0
  123. package/dist/server-errors.js +10 -10
  124. package/dist/telemetry/index.js +24 -24
  125. package/dist/test/index.js +5860 -11645
  126. package/dist/theming/create.js +4 -4
  127. package/dist/theming/index.d.ts +3363 -2597
  128. package/dist/theming/index.js +490 -1086
  129. package/dist/types/index.js +2 -11
  130. package/dist/viewport/index.js +3 -3
  131. package/package.json +5 -5
  132. package/dist/_browser-chunks/Color-FQNEU7YS.js +0 -1695
  133. package/dist/_browser-chunks/WithTooltip-6NHN2GXF.js +0 -2343
  134. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  135. package/dist/_browser-chunks/chunk-AW46NMGV.js +0 -1308
  136. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  137. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  138. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  139. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  140. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  141. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  142. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  143. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  144. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  145. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  146. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  147. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  148. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  149. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  150. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  151. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  152. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  153. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  154. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  155. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  156. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  157. package/dist/_node-chunks/camelcase-QALD4XFE.js +0 -18
  158. package/dist/_node-chunks/chunk-2XY53ALL.js +0 -420
  159. package/dist/_node-chunks/chunk-3CBQMG2A.js +0 -6712
  160. package/dist/_node-chunks/chunk-3WDAPZYQ.js +0 -28
  161. package/dist/_node-chunks/chunk-4ZB555EJ.js +0 -697
  162. package/dist/_node-chunks/chunk-52DXKXY3.js +0 -4272
  163. package/dist/_node-chunks/chunk-5OVB4A6F.js +0 -69
  164. package/dist/_node-chunks/chunk-AGHGNXGH.js +0 -18
  165. package/dist/_node-chunks/chunk-B23X5ZCK.js +0 -1531
  166. package/dist/_node-chunks/chunk-B2DAHWJK.js +0 -220
  167. package/dist/_node-chunks/chunk-CC4PW5MJ.js +0 -34
  168. package/dist/_node-chunks/chunk-D7NIZELR.js +0 -2256
  169. package/dist/_node-chunks/chunk-DO5Q3H4L.js +0 -1250
  170. package/dist/_node-chunks/chunk-ECK7WVFX.js +0 -304
  171. package/dist/_node-chunks/chunk-EUH3NHXA.js +0 -79
  172. package/dist/_node-chunks/chunk-FOQHPHCV.js +0 -1657
  173. package/dist/_node-chunks/chunk-G6EL47NS.js +0 -111
  174. package/dist/_node-chunks/chunk-GFLS4TJB.js +0 -90
  175. package/dist/_node-chunks/chunk-J3XZKWHE.js +0 -1586
  176. package/dist/_node-chunks/chunk-LE63EHJ5.js +0 -1518
  177. package/dist/_node-chunks/chunk-M47XA42S.js +0 -4741
  178. package/dist/_node-chunks/chunk-OOI74AL3.js +0 -61
  179. package/dist/_node-chunks/chunk-PRJHT3GJ.js +0 -61
  180. package/dist/_node-chunks/chunk-Q52PVUSU.js +0 -101
  181. package/dist/_node-chunks/chunk-SDCF5RNN.js +0 -1198
  182. package/dist/_node-chunks/chunk-UJ5SJ23M.js +0 -5029
  183. package/dist/_node-chunks/chunk-UPHK4ETU.js +0 -64658
  184. package/dist/_node-chunks/chunk-V7VURIPB.js +0 -1544
  185. package/dist/_node-chunks/dist-6TXHNR5C.js +0 -175
  186. package/dist/_node-chunks/globby-PBTV6PX6.js +0 -5222
  187. package/dist/_node-chunks/lib-4RTDZVGX.js +0 -518
  188. package/dist/_node-chunks/mdx-N42X6CFJ-COWEH7KR.js +0 -22017
  189. package/dist/_node-chunks/p-limit-PBVZQOFY.js +0 -168
  190. package/dist/_node-chunks/plugin-EOZKYZAG.js +0 -159
  191. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-35HMSMR5.js +0 -69102
  192. package/dist/_node-chunks/webpack-mock-plugin-GT3MA5E2.js +0 -124
@@ -0,0 +1,756 @@
1
+ import CJS_COMPAT_NODE_URL_57ru1wfqqjv from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_57ru1wfqqjv from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_57ru1wfqqjv from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_57ru1wfqqjv.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_57ru1wfqqjv.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_57ru1wfqqjv.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+
13
+ // ../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
14
+ var comma = 44, semicolon = 59, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
15
+ for (let i = 0; i < chars.length; i++) {
16
+ let c = chars.charCodeAt(i);
17
+ intToChar[i] = c, charToInt[c] = i;
18
+ }
19
+ function encodeInteger(builder, num, relative) {
20
+ let delta = num - relative;
21
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
22
+ do {
23
+ let clamped = delta & 31;
24
+ delta >>>= 5, delta > 0 && (clamped |= 32), builder.write(intToChar[clamped]);
25
+ } while (delta > 0);
26
+ return num;
27
+ }
28
+ var bufLength = 1024 * 16, td = typeof TextDecoder < "u" ? new TextDecoder() : typeof Buffer < "u" ? {
29
+ decode(buf) {
30
+ return Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength).toString();
31
+ }
32
+ } : {
33
+ decode(buf) {
34
+ let out = "";
35
+ for (let i = 0; i < buf.length; i++)
36
+ out += String.fromCharCode(buf[i]);
37
+ return out;
38
+ }
39
+ }, StringWriter = class {
40
+ constructor() {
41
+ this.pos = 0, this.out = "", this.buffer = new Uint8Array(bufLength);
42
+ }
43
+ write(v) {
44
+ let { buffer } = this;
45
+ buffer[this.pos++] = v, this.pos === bufLength && (this.out += td.decode(buffer), this.pos = 0);
46
+ }
47
+ flush() {
48
+ let { buffer, out, pos } = this;
49
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
50
+ }
51
+ };
52
+ function encode(decoded) {
53
+ let writer = new StringWriter(), sourcesIndex = 0, sourceLine = 0, sourceColumn = 0, namesIndex = 0;
54
+ for (let i = 0; i < decoded.length; i++) {
55
+ let line = decoded[i];
56
+ if (i > 0 && writer.write(semicolon), line.length === 0) continue;
57
+ let genColumn = 0;
58
+ for (let j = 0; j < line.length; j++) {
59
+ let segment = line[j];
60
+ j > 0 && writer.write(comma), genColumn = encodeInteger(writer, segment[0], genColumn), segment.length !== 1 && (sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex), sourceLine = encodeInteger(writer, segment[2], sourceLine), sourceColumn = encodeInteger(writer, segment[3], sourceColumn), segment.length !== 4 && (namesIndex = encodeInteger(writer, segment[4], namesIndex)));
61
+ }
62
+ }
63
+ return writer.flush();
64
+ }
65
+
66
+ // ../node_modules/magic-string/dist/magic-string.es.mjs
67
+ var BitSet = class _BitSet {
68
+ constructor(arg) {
69
+ this.bits = arg instanceof _BitSet ? arg.bits.slice() : [];
70
+ }
71
+ add(n2) {
72
+ this.bits[n2 >> 5] |= 1 << (n2 & 31);
73
+ }
74
+ has(n2) {
75
+ return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
76
+ }
77
+ }, Chunk = class _Chunk {
78
+ constructor(start, end, content) {
79
+ this.start = start, this.end = end, this.original = content, this.intro = "", this.outro = "", this.content = content, this.storeName = !1, this.edited = !1, this.previous = null, this.next = null;
80
+ }
81
+ appendLeft(content) {
82
+ this.outro += content;
83
+ }
84
+ appendRight(content) {
85
+ this.intro = this.intro + content;
86
+ }
87
+ clone() {
88
+ let chunk = new _Chunk(this.start, this.end, this.original);
89
+ return chunk.intro = this.intro, chunk.outro = this.outro, chunk.content = this.content, chunk.storeName = this.storeName, chunk.edited = this.edited, chunk;
90
+ }
91
+ contains(index) {
92
+ return this.start < index && index < this.end;
93
+ }
94
+ eachNext(fn) {
95
+ let chunk = this;
96
+ for (; chunk; )
97
+ fn(chunk), chunk = chunk.next;
98
+ }
99
+ eachPrevious(fn) {
100
+ let chunk = this;
101
+ for (; chunk; )
102
+ fn(chunk), chunk = chunk.previous;
103
+ }
104
+ edit(content, storeName, contentOnly) {
105
+ return this.content = content, contentOnly || (this.intro = "", this.outro = ""), this.storeName = storeName, this.edited = !0, this;
106
+ }
107
+ prependLeft(content) {
108
+ this.outro = content + this.outro;
109
+ }
110
+ prependRight(content) {
111
+ this.intro = content + this.intro;
112
+ }
113
+ reset() {
114
+ this.intro = "", this.outro = "", this.edited && (this.content = this.original, this.storeName = !1, this.edited = !1);
115
+ }
116
+ split(index) {
117
+ let sliceIndex = index - this.start, originalBefore = this.original.slice(0, sliceIndex), originalAfter = this.original.slice(sliceIndex);
118
+ this.original = originalBefore;
119
+ let newChunk = new _Chunk(index, this.end, originalAfter);
120
+ return newChunk.outro = this.outro, this.outro = "", this.end = index, this.edited ? (newChunk.edit("", !1), this.content = "") : this.content = originalBefore, newChunk.next = this.next, newChunk.next && (newChunk.next.previous = newChunk), newChunk.previous = this, this.next = newChunk, newChunk;
121
+ }
122
+ toString() {
123
+ return this.intro + this.content + this.outro;
124
+ }
125
+ trimEnd(rx) {
126
+ if (this.outro = this.outro.replace(rx, ""), this.outro.length) return !0;
127
+ let trimmed = this.content.replace(rx, "");
128
+ if (trimmed.length)
129
+ return trimmed !== this.content && (this.split(this.start + trimmed.length).edit("", void 0, !0), this.edited && this.edit(trimmed, this.storeName, !0)), !0;
130
+ if (this.edit("", void 0, !0), this.intro = this.intro.replace(rx, ""), this.intro.length) return !0;
131
+ }
132
+ trimStart(rx) {
133
+ if (this.intro = this.intro.replace(rx, ""), this.intro.length) return !0;
134
+ let trimmed = this.content.replace(rx, "");
135
+ if (trimmed.length) {
136
+ if (trimmed !== this.content) {
137
+ let newChunk = this.split(this.end - trimmed.length);
138
+ this.edited && newChunk.edit(trimmed, this.storeName, !0), this.edit("", void 0, !0);
139
+ }
140
+ return !0;
141
+ } else if (this.edit("", void 0, !0), this.outro = this.outro.replace(rx, ""), this.outro.length) return !0;
142
+ }
143
+ };
144
+ function getBtoa() {
145
+ return typeof globalThis < "u" && typeof globalThis.btoa == "function" ? (str) => globalThis.btoa(unescape(encodeURIComponent(str))) : typeof Buffer == "function" ? (str) => Buffer.from(str, "utf-8").toString("base64") : () => {
146
+ throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
147
+ };
148
+ }
149
+ var btoa = getBtoa(), SourceMap = class {
150
+ constructor(properties) {
151
+ this.version = 3, this.file = properties.file, this.sources = properties.sources, this.sourcesContent = properties.sourcesContent, this.names = properties.names, this.mappings = encode(properties.mappings), typeof properties.x_google_ignoreList < "u" && (this.x_google_ignoreList = properties.x_google_ignoreList), typeof properties.debugId < "u" && (this.debugId = properties.debugId);
152
+ }
153
+ toString() {
154
+ return JSON.stringify(this);
155
+ }
156
+ toUrl() {
157
+ return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
158
+ }
159
+ };
160
+ function guessIndent(code) {
161
+ let lines = code.split(`
162
+ `), tabbed = lines.filter((line) => /^\t+/.test(line)), spaced = lines.filter((line) => /^ {2,}/.test(line));
163
+ if (tabbed.length === 0 && spaced.length === 0)
164
+ return null;
165
+ if (tabbed.length >= spaced.length)
166
+ return " ";
167
+ let min = spaced.reduce((previous, current) => {
168
+ let numSpaces = /^ +/.exec(current)[0].length;
169
+ return Math.min(numSpaces, previous);
170
+ }, 1 / 0);
171
+ return new Array(min + 1).join(" ");
172
+ }
173
+ function getRelativePath(from, to) {
174
+ let fromParts = from.split(/[/\\]/), toParts = to.split(/[/\\]/);
175
+ for (fromParts.pop(); fromParts[0] === toParts[0]; )
176
+ fromParts.shift(), toParts.shift();
177
+ if (fromParts.length) {
178
+ let i = fromParts.length;
179
+ for (; i--; ) fromParts[i] = "..";
180
+ }
181
+ return fromParts.concat(toParts).join("/");
182
+ }
183
+ var toString = Object.prototype.toString;
184
+ function isObject(thing) {
185
+ return toString.call(thing) === "[object Object]";
186
+ }
187
+ function getLocator(source) {
188
+ let originalLines = source.split(`
189
+ `), lineOffsets = [];
190
+ for (let i = 0, pos = 0; i < originalLines.length; i++)
191
+ lineOffsets.push(pos), pos += originalLines[i].length + 1;
192
+ return function(index) {
193
+ let i = 0, j = lineOffsets.length;
194
+ for (; i < j; ) {
195
+ let m = i + j >> 1;
196
+ index < lineOffsets[m] ? j = m : i = m + 1;
197
+ }
198
+ let line = i - 1, column = index - lineOffsets[line];
199
+ return { line, column };
200
+ };
201
+ }
202
+ var wordRegex = /\w/, Mappings = class {
203
+ constructor(hires) {
204
+ this.hires = hires, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] = [], this.pending = null;
205
+ }
206
+ addEdit(sourceIndex, content, loc, nameIndex) {
207
+ if (content.length) {
208
+ let contentLengthMinusOne = content.length - 1, contentLineEnd = content.indexOf(`
209
+ `, 0), previousContentLineEnd = -1;
210
+ for (; contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd; ) {
211
+ let segment2 = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
212
+ nameIndex >= 0 && segment2.push(nameIndex), this.rawSegments.push(segment2), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, previousContentLineEnd = contentLineEnd, contentLineEnd = content.indexOf(`
213
+ `, contentLineEnd + 1);
214
+ }
215
+ let segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
216
+ nameIndex >= 0 && segment.push(nameIndex), this.rawSegments.push(segment), this.advance(content.slice(previousContentLineEnd + 1));
217
+ } else this.pending && (this.rawSegments.push(this.pending), this.advance(content));
218
+ this.pending = null;
219
+ }
220
+ addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
221
+ let originalCharIndex = chunk.start, first = !0, charInHiresBoundary = !1;
222
+ for (; originalCharIndex < chunk.end; ) {
223
+ if (original[originalCharIndex] === `
224
+ `)
225
+ loc.line += 1, loc.column = 0, this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, first = !0, charInHiresBoundary = !1;
226
+ else {
227
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
228
+ let segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
229
+ this.hires === "boundary" ? wordRegex.test(original[originalCharIndex]) ? charInHiresBoundary || (this.rawSegments.push(segment), charInHiresBoundary = !0) : (this.rawSegments.push(segment), charInHiresBoundary = !1) : this.rawSegments.push(segment);
230
+ }
231
+ loc.column += 1, this.generatedCodeColumn += 1, first = !1;
232
+ }
233
+ originalCharIndex += 1;
234
+ }
235
+ this.pending = null;
236
+ }
237
+ advance(str) {
238
+ if (!str) return;
239
+ let lines = str.split(`
240
+ `);
241
+ if (lines.length > 1) {
242
+ for (let i = 0; i < lines.length - 1; i++)
243
+ this.generatedCodeLine++, this.raw[this.generatedCodeLine] = this.rawSegments = [];
244
+ this.generatedCodeColumn = 0;
245
+ }
246
+ this.generatedCodeColumn += lines[lines.length - 1].length;
247
+ }
248
+ }, n = `
249
+ `, warned = {
250
+ insertLeft: !1,
251
+ insertRight: !1,
252
+ storeName: !1
253
+ }, MagicString = class _MagicString {
254
+ constructor(string, options = {}) {
255
+ let chunk = new Chunk(0, string.length, string);
256
+ Object.defineProperties(this, {
257
+ original: { writable: !0, value: string },
258
+ outro: { writable: !0, value: "" },
259
+ intro: { writable: !0, value: "" },
260
+ firstChunk: { writable: !0, value: chunk },
261
+ lastChunk: { writable: !0, value: chunk },
262
+ lastSearchedChunk: { writable: !0, value: chunk },
263
+ byStart: { writable: !0, value: {} },
264
+ byEnd: { writable: !0, value: {} },
265
+ filename: { writable: !0, value: options.filename },
266
+ indentExclusionRanges: { writable: !0, value: options.indentExclusionRanges },
267
+ sourcemapLocations: { writable: !0, value: new BitSet() },
268
+ storedNames: { writable: !0, value: {} },
269
+ indentStr: { writable: !0, value: void 0 },
270
+ ignoreList: { writable: !0, value: options.ignoreList },
271
+ offset: { writable: !0, value: options.offset || 0 }
272
+ }), this.byStart[0] = chunk, this.byEnd[string.length] = chunk;
273
+ }
274
+ addSourcemapLocation(char) {
275
+ this.sourcemapLocations.add(char);
276
+ }
277
+ append(content) {
278
+ if (typeof content != "string") throw new TypeError("outro content must be a string");
279
+ return this.outro += content, this;
280
+ }
281
+ appendLeft(index, content) {
282
+ if (index = index + this.offset, typeof content != "string") throw new TypeError("inserted content must be a string");
283
+ this._split(index);
284
+ let chunk = this.byEnd[index];
285
+ return chunk ? chunk.appendLeft(content) : this.intro += content, this;
286
+ }
287
+ appendRight(index, content) {
288
+ if (index = index + this.offset, typeof content != "string") throw new TypeError("inserted content must be a string");
289
+ this._split(index);
290
+ let chunk = this.byStart[index];
291
+ return chunk ? chunk.appendRight(content) : this.outro += content, this;
292
+ }
293
+ clone() {
294
+ let cloned = new _MagicString(this.original, { filename: this.filename, offset: this.offset }), originalChunk = this.firstChunk, clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
295
+ for (; originalChunk; ) {
296
+ cloned.byStart[clonedChunk.start] = clonedChunk, cloned.byEnd[clonedChunk.end] = clonedChunk;
297
+ let nextOriginalChunk = originalChunk.next, nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
298
+ nextClonedChunk && (clonedChunk.next = nextClonedChunk, nextClonedChunk.previous = clonedChunk, clonedChunk = nextClonedChunk), originalChunk = nextOriginalChunk;
299
+ }
300
+ return cloned.lastChunk = clonedChunk, this.indentExclusionRanges && (cloned.indentExclusionRanges = this.indentExclusionRanges.slice()), cloned.sourcemapLocations = new BitSet(this.sourcemapLocations), cloned.intro = this.intro, cloned.outro = this.outro, cloned;
301
+ }
302
+ generateDecodedMap(options) {
303
+ options = options || {};
304
+ let sourceIndex = 0, names = Object.keys(this.storedNames), mappings = new Mappings(options.hires), locate = getLocator(this.original);
305
+ return this.intro && mappings.advance(this.intro), this.firstChunk.eachNext((chunk) => {
306
+ let loc = locate(chunk.start);
307
+ chunk.intro.length && mappings.advance(chunk.intro), chunk.edited ? mappings.addEdit(
308
+ sourceIndex,
309
+ chunk.content,
310
+ loc,
311
+ chunk.storeName ? names.indexOf(chunk.original) : -1
312
+ ) : mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations), chunk.outro.length && mappings.advance(chunk.outro);
313
+ }), this.outro && mappings.advance(this.outro), {
314
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
315
+ sources: [
316
+ options.source ? getRelativePath(options.file || "", options.source) : options.file || ""
317
+ ],
318
+ sourcesContent: options.includeContent ? [this.original] : void 0,
319
+ names,
320
+ mappings: mappings.raw,
321
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
322
+ };
323
+ }
324
+ generateMap(options) {
325
+ return new SourceMap(this.generateDecodedMap(options));
326
+ }
327
+ _ensureindentStr() {
328
+ this.indentStr === void 0 && (this.indentStr = guessIndent(this.original));
329
+ }
330
+ _getRawIndentString() {
331
+ return this._ensureindentStr(), this.indentStr;
332
+ }
333
+ getIndentString() {
334
+ return this._ensureindentStr(), this.indentStr === null ? " " : this.indentStr;
335
+ }
336
+ indent(indentStr, options) {
337
+ let pattern = /^[^\r\n]/gm;
338
+ if (isObject(indentStr) && (options = indentStr, indentStr = void 0), indentStr === void 0 && (this._ensureindentStr(), indentStr = this.indentStr || " "), indentStr === "") return this;
339
+ options = options || {};
340
+ let isExcluded = {};
341
+ options.exclude && (typeof options.exclude[0] == "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
342
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1)
343
+ isExcluded[i] = !0;
344
+ });
345
+ let shouldIndentNextCharacter = options.indentStart !== !1, replacer = (match) => shouldIndentNextCharacter ? `${indentStr}${match}` : (shouldIndentNextCharacter = !0, match);
346
+ this.intro = this.intro.replace(pattern, replacer);
347
+ let charIndex = 0, chunk = this.firstChunk;
348
+ for (; chunk; ) {
349
+ let end = chunk.end;
350
+ if (chunk.edited)
351
+ isExcluded[charIndex] || (chunk.content = chunk.content.replace(pattern, replacer), chunk.content.length && (shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === `
352
+ `));
353
+ else
354
+ for (charIndex = chunk.start; charIndex < end; ) {
355
+ if (!isExcluded[charIndex]) {
356
+ let char = this.original[charIndex];
357
+ char === `
358
+ ` ? shouldIndentNextCharacter = !0 : char !== "\r" && shouldIndentNextCharacter && (shouldIndentNextCharacter = !1, charIndex === chunk.start || (this._splitChunk(chunk, charIndex), chunk = chunk.next), chunk.prependRight(indentStr));
359
+ }
360
+ charIndex += 1;
361
+ }
362
+ charIndex = chunk.end, chunk = chunk.next;
363
+ }
364
+ return this.outro = this.outro.replace(pattern, replacer), this;
365
+ }
366
+ insert() {
367
+ throw new Error(
368
+ "magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
369
+ );
370
+ }
371
+ insertLeft(index, content) {
372
+ return warned.insertLeft || (console.warn(
373
+ "magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
374
+ ), warned.insertLeft = !0), this.appendLeft(index, content);
375
+ }
376
+ insertRight(index, content) {
377
+ return warned.insertRight || (console.warn(
378
+ "magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
379
+ ), warned.insertRight = !0), this.prependRight(index, content);
380
+ }
381
+ move(start, end, index) {
382
+ if (start = start + this.offset, end = end + this.offset, index = index + this.offset, index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
383
+ this._split(start), this._split(end), this._split(index);
384
+ let first = this.byStart[start], last = this.byEnd[end], oldLeft = first.previous, oldRight = last.next, newRight = this.byStart[index];
385
+ if (!newRight && last === this.lastChunk) return this;
386
+ let newLeft = newRight ? newRight.previous : this.lastChunk;
387
+ return oldLeft && (oldLeft.next = oldRight), oldRight && (oldRight.previous = oldLeft), newLeft && (newLeft.next = first), newRight && (newRight.previous = last), first.previous || (this.firstChunk = last.next), last.next || (this.lastChunk = first.previous, this.lastChunk.next = null), first.previous = newLeft, last.next = newRight || null, newLeft || (this.firstChunk = first), newRight || (this.lastChunk = last), this;
388
+ }
389
+ overwrite(start, end, content, options) {
390
+ return options = options || {}, this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
391
+ }
392
+ update(start, end, content, options) {
393
+ if (start = start + this.offset, end = end + this.offset, typeof content != "string") throw new TypeError("replacement content must be a string");
394
+ if (this.original.length !== 0) {
395
+ for (; start < 0; ) start += this.original.length;
396
+ for (; end < 0; ) end += this.original.length;
397
+ }
398
+ if (end > this.original.length) throw new Error("end is out of bounds");
399
+ if (start === end)
400
+ throw new Error(
401
+ "Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
402
+ );
403
+ this._split(start), this._split(end), options === !0 && (warned.storeName || (console.warn(
404
+ "The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
405
+ ), warned.storeName = !0), options = { storeName: !0 });
406
+ let storeName = options !== void 0 ? options.storeName : !1, overwrite = options !== void 0 ? options.overwrite : !1;
407
+ if (storeName) {
408
+ let original = this.original.slice(start, end);
409
+ Object.defineProperty(this.storedNames, original, {
410
+ writable: !0,
411
+ value: !0,
412
+ enumerable: !0
413
+ });
414
+ }
415
+ let first = this.byStart[start], last = this.byEnd[end];
416
+ if (first) {
417
+ let chunk = first;
418
+ for (; chunk !== last; ) {
419
+ if (chunk.next !== this.byStart[chunk.end])
420
+ throw new Error("Cannot overwrite across a split point");
421
+ chunk = chunk.next, chunk.edit("", !1);
422
+ }
423
+ first.edit(content, storeName, !overwrite);
424
+ } else {
425
+ let newChunk = new Chunk(start, end, "").edit(content, storeName);
426
+ last.next = newChunk, newChunk.previous = last;
427
+ }
428
+ return this;
429
+ }
430
+ prepend(content) {
431
+ if (typeof content != "string") throw new TypeError("outro content must be a string");
432
+ return this.intro = content + this.intro, this;
433
+ }
434
+ prependLeft(index, content) {
435
+ if (index = index + this.offset, typeof content != "string") throw new TypeError("inserted content must be a string");
436
+ this._split(index);
437
+ let chunk = this.byEnd[index];
438
+ return chunk ? chunk.prependLeft(content) : this.intro = content + this.intro, this;
439
+ }
440
+ prependRight(index, content) {
441
+ if (index = index + this.offset, typeof content != "string") throw new TypeError("inserted content must be a string");
442
+ this._split(index);
443
+ let chunk = this.byStart[index];
444
+ return chunk ? chunk.prependRight(content) : this.outro = content + this.outro, this;
445
+ }
446
+ remove(start, end) {
447
+ if (start = start + this.offset, end = end + this.offset, this.original.length !== 0) {
448
+ for (; start < 0; ) start += this.original.length;
449
+ for (; end < 0; ) end += this.original.length;
450
+ }
451
+ if (start === end) return this;
452
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
453
+ if (start > end) throw new Error("end must be greater than start");
454
+ this._split(start), this._split(end);
455
+ let chunk = this.byStart[start];
456
+ for (; chunk; )
457
+ chunk.intro = "", chunk.outro = "", chunk.edit(""), chunk = end > chunk.end ? this.byStart[chunk.end] : null;
458
+ return this;
459
+ }
460
+ reset(start, end) {
461
+ if (start = start + this.offset, end = end + this.offset, this.original.length !== 0) {
462
+ for (; start < 0; ) start += this.original.length;
463
+ for (; end < 0; ) end += this.original.length;
464
+ }
465
+ if (start === end) return this;
466
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
467
+ if (start > end) throw new Error("end must be greater than start");
468
+ this._split(start), this._split(end);
469
+ let chunk = this.byStart[start];
470
+ for (; chunk; )
471
+ chunk.reset(), chunk = end > chunk.end ? this.byStart[chunk.end] : null;
472
+ return this;
473
+ }
474
+ lastChar() {
475
+ if (this.outro.length) return this.outro[this.outro.length - 1];
476
+ let chunk = this.lastChunk;
477
+ do {
478
+ if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
479
+ if (chunk.content.length) return chunk.content[chunk.content.length - 1];
480
+ if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
481
+ } while (chunk = chunk.previous);
482
+ return this.intro.length ? this.intro[this.intro.length - 1] : "";
483
+ }
484
+ lastLine() {
485
+ let lineIndex = this.outro.lastIndexOf(n);
486
+ if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
487
+ let lineStr = this.outro, chunk = this.lastChunk;
488
+ do {
489
+ if (chunk.outro.length > 0) {
490
+ if (lineIndex = chunk.outro.lastIndexOf(n), lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
491
+ lineStr = chunk.outro + lineStr;
492
+ }
493
+ if (chunk.content.length > 0) {
494
+ if (lineIndex = chunk.content.lastIndexOf(n), lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
495
+ lineStr = chunk.content + lineStr;
496
+ }
497
+ if (chunk.intro.length > 0) {
498
+ if (lineIndex = chunk.intro.lastIndexOf(n), lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
499
+ lineStr = chunk.intro + lineStr;
500
+ }
501
+ } while (chunk = chunk.previous);
502
+ return lineIndex = this.intro.lastIndexOf(n), lineIndex !== -1 ? this.intro.substr(lineIndex + 1) + lineStr : this.intro + lineStr;
503
+ }
504
+ slice(start = 0, end = this.original.length - this.offset) {
505
+ if (start = start + this.offset, end = end + this.offset, this.original.length !== 0) {
506
+ for (; start < 0; ) start += this.original.length;
507
+ for (; end < 0; ) end += this.original.length;
508
+ }
509
+ let result = "", chunk = this.firstChunk;
510
+ for (; chunk && (chunk.start > start || chunk.end <= start); ) {
511
+ if (chunk.start < end && chunk.end >= end)
512
+ return result;
513
+ chunk = chunk.next;
514
+ }
515
+ if (chunk && chunk.edited && chunk.start !== start)
516
+ throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
517
+ let startChunk = chunk;
518
+ for (; chunk; ) {
519
+ chunk.intro && (startChunk !== chunk || chunk.start === start) && (result += chunk.intro);
520
+ let containsEnd = chunk.start < end && chunk.end >= end;
521
+ if (containsEnd && chunk.edited && chunk.end !== end)
522
+ throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
523
+ let sliceStart = startChunk === chunk ? start - chunk.start : 0, sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
524
+ if (result += chunk.content.slice(sliceStart, sliceEnd), chunk.outro && (!containsEnd || chunk.end === end) && (result += chunk.outro), containsEnd)
525
+ break;
526
+ chunk = chunk.next;
527
+ }
528
+ return result;
529
+ }
530
+ // TODO deprecate this? not really very useful
531
+ snip(start, end) {
532
+ let clone = this.clone();
533
+ return clone.remove(0, start), clone.remove(end, clone.original.length), clone;
534
+ }
535
+ _split(index) {
536
+ if (this.byStart[index] || this.byEnd[index]) return;
537
+ let chunk = this.lastSearchedChunk, previousChunk = chunk, searchForward = index > chunk.end;
538
+ for (; chunk; ) {
539
+ if (chunk.contains(index)) return this._splitChunk(chunk, index);
540
+ if (chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start], chunk === previousChunk) return;
541
+ previousChunk = chunk;
542
+ }
543
+ }
544
+ _splitChunk(chunk, index) {
545
+ if (chunk.edited && chunk.content.length) {
546
+ let loc = getLocator(this.original)(index);
547
+ throw new Error(
548
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`
549
+ );
550
+ }
551
+ let newChunk = chunk.split(index);
552
+ return this.byEnd[index] = chunk, this.byStart[index] = newChunk, this.byEnd[newChunk.end] = newChunk, chunk === this.lastChunk && (this.lastChunk = newChunk), this.lastSearchedChunk = chunk, !0;
553
+ }
554
+ toString() {
555
+ let str = this.intro, chunk = this.firstChunk;
556
+ for (; chunk; )
557
+ str += chunk.toString(), chunk = chunk.next;
558
+ return str + this.outro;
559
+ }
560
+ isEmpty() {
561
+ let chunk = this.firstChunk;
562
+ do
563
+ if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
564
+ return !1;
565
+ while (chunk = chunk.next);
566
+ return !0;
567
+ }
568
+ length() {
569
+ let chunk = this.firstChunk, length = 0;
570
+ do
571
+ length += chunk.intro.length + chunk.content.length + chunk.outro.length;
572
+ while (chunk = chunk.next);
573
+ return length;
574
+ }
575
+ trimLines() {
576
+ return this.trim("[\\r\\n]");
577
+ }
578
+ trim(charType) {
579
+ return this.trimStart(charType).trimEnd(charType);
580
+ }
581
+ trimEndAborted(charType) {
582
+ let rx = new RegExp((charType || "\\s") + "+$");
583
+ if (this.outro = this.outro.replace(rx, ""), this.outro.length) return !0;
584
+ let chunk = this.lastChunk;
585
+ do {
586
+ let end = chunk.end, aborted = chunk.trimEnd(rx);
587
+ if (chunk.end !== end && (this.lastChunk === chunk && (this.lastChunk = chunk.next), this.byEnd[chunk.end] = chunk, this.byStart[chunk.next.start] = chunk.next, this.byEnd[chunk.next.end] = chunk.next), aborted) return !0;
588
+ chunk = chunk.previous;
589
+ } while (chunk);
590
+ return !1;
591
+ }
592
+ trimEnd(charType) {
593
+ return this.trimEndAborted(charType), this;
594
+ }
595
+ trimStartAborted(charType) {
596
+ let rx = new RegExp("^" + (charType || "\\s") + "+");
597
+ if (this.intro = this.intro.replace(rx, ""), this.intro.length) return !0;
598
+ let chunk = this.firstChunk;
599
+ do {
600
+ let end = chunk.end, aborted = chunk.trimStart(rx);
601
+ if (chunk.end !== end && (chunk === this.lastChunk && (this.lastChunk = chunk.next), this.byEnd[chunk.end] = chunk, this.byStart[chunk.next.start] = chunk.next, this.byEnd[chunk.next.end] = chunk.next), aborted) return !0;
602
+ chunk = chunk.next;
603
+ } while (chunk);
604
+ return !1;
605
+ }
606
+ trimStart(charType) {
607
+ return this.trimStartAborted(charType), this;
608
+ }
609
+ hasChanged() {
610
+ return this.original !== this.toString();
611
+ }
612
+ _replaceRegexp(searchValue, replacement) {
613
+ function getReplacement(match, str) {
614
+ return typeof replacement == "string" ? replacement.replace(/\$(\$|&|\d+)/g, (_, i) => i === "$" ? "$" : i === "&" ? match[0] : +i < match.length ? match[+i] : `$${i}`) : replacement(...match, match.index, str, match.groups);
615
+ }
616
+ function matchAll(re, str) {
617
+ let match, matches = [];
618
+ for (; match = re.exec(str); )
619
+ matches.push(match);
620
+ return matches;
621
+ }
622
+ if (searchValue.global)
623
+ matchAll(searchValue, this.original).forEach((match) => {
624
+ if (match.index != null) {
625
+ let replacement2 = getReplacement(match, this.original);
626
+ replacement2 !== match[0] && this.overwrite(match.index, match.index + match[0].length, replacement2);
627
+ }
628
+ });
629
+ else {
630
+ let match = this.original.match(searchValue);
631
+ if (match && match.index != null) {
632
+ let replacement2 = getReplacement(match, this.original);
633
+ replacement2 !== match[0] && this.overwrite(match.index, match.index + match[0].length, replacement2);
634
+ }
635
+ }
636
+ return this;
637
+ }
638
+ _replaceString(string, replacement) {
639
+ let { original } = this, index = original.indexOf(string);
640
+ return index !== -1 && (typeof replacement == "function" && (replacement = replacement(string, index, original)), string !== replacement && this.overwrite(index, index + string.length, replacement)), this;
641
+ }
642
+ replace(searchValue, replacement) {
643
+ return typeof searchValue == "string" ? this._replaceString(searchValue, replacement) : this._replaceRegexp(searchValue, replacement);
644
+ }
645
+ _replaceAllString(string, replacement) {
646
+ let { original } = this, stringLength = string.length;
647
+ for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
648
+ let previous = original.slice(index, index + stringLength), _replacement = replacement;
649
+ typeof replacement == "function" && (_replacement = replacement(previous, index, original)), previous !== _replacement && this.overwrite(index, index + stringLength, _replacement);
650
+ }
651
+ return this;
652
+ }
653
+ replaceAll(searchValue, replacement) {
654
+ if (typeof searchValue == "string")
655
+ return this._replaceAllString(searchValue, replacement);
656
+ if (!searchValue.global)
657
+ throw new TypeError(
658
+ "MagicString.prototype.replaceAll called with a non-global RegExp argument"
659
+ );
660
+ return this._replaceRegexp(searchValue, replacement);
661
+ }
662
+ };
663
+
664
+ // src/core-server/presets/vitePlugins/vite-inject-mocker/constants.ts
665
+ var __STORYBOOK_GLOBAL_THIS_ACCESSOR__ = "__vitest_mocker__";
666
+
667
+ // src/core-server/mocking-utils/esmWalker.ts
668
+ function getArbitraryModuleIdentifier(node) {
669
+ return node.type === "Identifier" ? node.name : node.raw;
670
+ }
671
+
672
+ // src/core-server/mocking-utils/automock.ts
673
+ function getAutomockCode(originalCode, isSpy, parse) {
674
+ return automockModule(originalCode, isSpy ? "autospy" : "automock", parse, {
675
+ globalThisAccessor: JSON.stringify(__STORYBOOK_GLOBAL_THIS_ACCESSOR__)
676
+ });
677
+ }
678
+ function automockModule(code, mockType, parse, options = {}) {
679
+ let globalThisAccessor = options.globalThisAccessor || '"__vitest_mocker__"', ast = parse(code), m = new MagicString(code), allSpecifiers = [], importIndex = 0;
680
+ for (let _node of ast.body) {
681
+ if (_node.type === "ExportAllDeclaration")
682
+ throw new Error(
683
+ "automocking files with `export *` is not supported in browser mode because it cannot be statically analysed"
684
+ );
685
+ if (_node.type === "ExportNamedDeclaration") {
686
+ let traversePattern2 = function(expression) {
687
+ if (expression.type === "Identifier")
688
+ allSpecifiers.push({ name: expression.name });
689
+ else if (expression.type === "ArrayPattern")
690
+ expression.elements.forEach((element) => {
691
+ element && traversePattern2(element);
692
+ });
693
+ else if (expression.type === "ObjectPattern")
694
+ expression.properties.forEach((property) => {
695
+ property.type === "RestElement" ? traversePattern2(property) : property.type === "Property" && traversePattern2(property.value);
696
+ });
697
+ else if (expression.type === "RestElement")
698
+ traversePattern2(expression.argument);
699
+ else {
700
+ if (expression.type === "AssignmentPattern")
701
+ throw new Error("AssignmentPattern is not supported. Please open a new bug report.");
702
+ if (expression.type === "MemberExpression")
703
+ throw new Error("MemberExpression is not supported. Please open a new bug report.");
704
+ }
705
+ };
706
+ var traversePattern = traversePattern2;
707
+ let node = _node, declaration = node.declaration;
708
+ declaration && (declaration.type === "FunctionDeclaration" ? allSpecifiers.push({ name: declaration.id.name }) : declaration.type === "VariableDeclaration" ? declaration.declarations.forEach((declaration2) => {
709
+ traversePattern2(declaration2.id);
710
+ }) : declaration.type === "ClassDeclaration" && allSpecifiers.push({ name: declaration.id.name }), m.remove(node.start, declaration.start));
711
+ let specifiers = node.specifiers || [], source = node.source;
712
+ if (!source && specifiers.length)
713
+ specifiers.forEach((specifier) => {
714
+ allSpecifiers.push({
715
+ alias: getArbitraryModuleIdentifier(specifier.exported),
716
+ name: getArbitraryModuleIdentifier(specifier.local)
717
+ });
718
+ }), m.remove(node.start, node.end);
719
+ else if (source && specifiers.length) {
720
+ let importNames = [];
721
+ specifiers.forEach((specifier) => {
722
+ let importedName = `__vitest_imported_${importIndex++}__`;
723
+ importNames.push([getArbitraryModuleIdentifier(specifier.local), importedName]), allSpecifiers.push({
724
+ name: importedName,
725
+ alias: getArbitraryModuleIdentifier(specifier.exported)
726
+ });
727
+ });
728
+ let importString = `import { ${importNames.map(([name, alias]) => `${name} as ${alias}`).join(", ")} } from '${source.value}'`;
729
+ m.overwrite(node.start, node.end, importString);
730
+ }
731
+ }
732
+ if (_node.type === "ExportDefaultDeclaration") {
733
+ let node = _node, declaration = node.declaration;
734
+ allSpecifiers.push({ name: "__vitest_default", alias: "default" }), m.overwrite(node.start, declaration.start, "const __vitest_default = ");
735
+ }
736
+ }
737
+ let moduleObject = `
738
+ const __vitest_current_es_module__ = {
739
+ __esModule: true,
740
+ ${allSpecifiers.map(({ name }) => `["${name}"]: ${name},`).join(`
741
+ `)}
742
+ }
743
+ const __vitest_mocked_module__ = globalThis[${globalThisAccessor}].mockObject(__vitest_current_es_module__, "${mockType}")
744
+ `, assigning = allSpecifiers.map(({ name }, index) => `const __vitest_mocked_${index}__ = __vitest_mocked_module__["${name}"]`).join(`
745
+ `), specifiersExports = `
746
+ export {
747
+ ${allSpecifiers.map(({ name, alias }, index) => ` __vitest_mocked_${index}__ as ${alias || name},`).join(`
748
+ `)}
749
+ }
750
+ `;
751
+ return m.append(moduleObject + assigning + specifiersExports), m;
752
+ }
753
+
754
+ export {
755
+ getAutomockCode
756
+ };