@aussieljk/forkbook 0.0.0-stage → 0.0.1-2

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 (598) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +77 -2
  3. package/assets/addon-vitest/templates/vitest.config.4.template.ts +36 -0
  4. package/assets/browser/favicon-wrapper.svg +46 -0
  5. package/assets/browser/favicon.svg +1 -0
  6. package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
  7. package/assets/browser/nunito-sans-bold.woff2 +0 -0
  8. package/assets/browser/nunito-sans-italic.woff2 +0 -0
  9. package/assets/browser/nunito-sans-regular.woff2 +0 -0
  10. package/assets/builder-vite/iframe.html +99 -0
  11. package/assets/create/rendererAssets/.eslintrc.json +16 -0
  12. package/assets/create/rendererAssets/common/Configure.mdx +388 -0
  13. package/assets/create/rendererAssets/common/assets/accessibility.png +0 -0
  14. package/assets/create/rendererAssets/common/assets/accessibility.svg +1 -0
  15. package/assets/create/rendererAssets/common/assets/addon-library.png +0 -0
  16. package/assets/create/rendererAssets/common/assets/assets.png +0 -0
  17. package/assets/create/rendererAssets/common/assets/avif-test-image.avif +0 -0
  18. package/assets/create/rendererAssets/common/assets/context.png +0 -0
  19. package/assets/create/rendererAssets/common/assets/discord.svg +1 -0
  20. package/assets/create/rendererAssets/common/assets/docs.png +0 -0
  21. package/assets/create/rendererAssets/common/assets/figma-plugin.png +0 -0
  22. package/assets/create/rendererAssets/common/assets/github.svg +1 -0
  23. package/assets/create/rendererAssets/common/assets/share.png +0 -0
  24. package/assets/create/rendererAssets/common/assets/styling.png +0 -0
  25. package/assets/create/rendererAssets/common/assets/testing.png +0 -0
  26. package/assets/create/rendererAssets/common/assets/theming.png +0 -0
  27. package/assets/create/rendererAssets/common/assets/tutorials.svg +1 -0
  28. package/assets/create/rendererAssets/common/assets/youtube.svg +1 -0
  29. package/assets/create/rendererAssets/common/button.css +30 -0
  30. package/assets/create/rendererAssets/common/header.css +32 -0
  31. package/assets/create/rendererAssets/common/page.css +68 -0
  32. package/assets/create/templates/react-native/index.expo.js +20 -0
  33. package/assets/create/templates/react-native/index.js +25 -0
  34. package/assets/docs/addon-backgrounds.gif +0 -0
  35. package/assets/docs/addon-controls-args-annotated.png +0 -0
  36. package/assets/docs/addon-controls-args-background-color.png +0 -0
  37. package/assets/docs/addon-controls-args-background-string.png +0 -0
  38. package/assets/docs/addon-controls-args-docs.png +0 -0
  39. package/assets/docs/addon-controls-args-logging.png +0 -0
  40. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  41. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  42. package/assets/docs/addon-controls-args-reflow.png +0 -0
  43. package/assets/docs/addon-controls-args-template.png +0 -0
  44. package/assets/docs/addon-controls-expanded.png +0 -0
  45. package/assets/docs/addon-controls-hero.gif +0 -0
  46. package/assets/docs/addon-controls-install.png +0 -0
  47. package/assets/docs/hero.gif +0 -0
  48. package/assets/docs/highlight.png +0 -0
  49. package/assets/docs/message-reference.png +0 -0
  50. package/assets/docs/viewport.png +0 -0
  51. package/assets/react-native/metro-env.d.ts +69 -0
  52. package/assets/server/addon.tsconfig.json +6 -0
  53. package/assets/server/base-preview-body.html +116 -0
  54. package/assets/server/base-preview-head.html +494 -0
  55. package/assets/server/openBrowser.applescript +94 -0
  56. package/assets/server/template.ejs +87 -0
  57. package/dist/.build-stamp +0 -0
  58. package/dist/_browser-chunks/Color-PCLE2J36.js +1025 -0
  59. package/dist/_browser-chunks/DocsRenderer-JXND3PVQ.js +10 -0
  60. package/dist/_browser-chunks/WithTooltip-XSQFTBMB.js +1619 -0
  61. package/dist/_browser-chunks/chunk-2JDQ35OA.js +247 -0
  62. package/dist/_browser-chunks/chunk-2JT76G3E.js +104 -0
  63. package/dist/_browser-chunks/chunk-2MEPHP35.js +17 -0
  64. package/dist/_browser-chunks/chunk-2SCZVUKW.js +24 -0
  65. package/dist/_browser-chunks/chunk-46Z7NGAS.js +41 -0
  66. package/dist/_browser-chunks/chunk-4ATQOMJB.js +30 -0
  67. package/dist/_browser-chunks/chunk-52CW7FF7.js +49 -0
  68. package/dist/_browser-chunks/chunk-5I7E4GMO.js +62 -0
  69. package/dist/_browser-chunks/chunk-5P4QA6MY.js +20 -0
  70. package/dist/_browser-chunks/chunk-5WMXI5GW.js +816 -0
  71. package/dist/_browser-chunks/chunk-66OCZ54D.js +2604 -0
  72. package/dist/_browser-chunks/chunk-6SXYJQST.js +253 -0
  73. package/dist/_browser-chunks/chunk-AYRF6EJB.js +36 -0
  74. package/dist/_browser-chunks/chunk-B4AUNNU4.js +156 -0
  75. package/dist/_browser-chunks/chunk-BCP2FFXF.js +369 -0
  76. package/dist/_browser-chunks/chunk-C3D4HEFY.js +3396 -0
  77. package/dist/_browser-chunks/chunk-CFAOWGL7.js +43 -0
  78. package/dist/_browser-chunks/chunk-CFWWCCZV.js +223 -0
  79. package/dist/_browser-chunks/chunk-CNED6RYH.js +18 -0
  80. package/dist/_browser-chunks/chunk-DRQKCCAG.js +136 -0
  81. package/dist/_browser-chunks/chunk-ECQ75MKQ.js +0 -0
  82. package/dist/_browser-chunks/chunk-EIYAKDGP.js +302 -0
  83. package/dist/_browser-chunks/chunk-ENKK74N4.js +12 -0
  84. package/dist/_browser-chunks/chunk-FENFYI4X.js +698 -0
  85. package/dist/_browser-chunks/chunk-FJGWSWL5.js +155 -0
  86. package/dist/_browser-chunks/chunk-FVSEPWWX.js +2810 -0
  87. package/dist/_browser-chunks/chunk-GNZY6LOW.js +10116 -0
  88. package/dist/_browser-chunks/chunk-IE4ULIOQ.js +14 -0
  89. package/dist/_browser-chunks/chunk-IMSF75WX.js +42 -0
  90. package/dist/_browser-chunks/chunk-IWQGIXJS.js +14 -0
  91. package/dist/_browser-chunks/chunk-JMC7AIKT.js +108 -0
  92. package/dist/_browser-chunks/chunk-JPUOQJUI.js +8 -0
  93. package/dist/_browser-chunks/chunk-JSBKXXXF.js +218 -0
  94. package/dist/_browser-chunks/chunk-JWSKPMPC.js +73 -0
  95. package/dist/_browser-chunks/chunk-JYVGARBG.js +2943 -0
  96. package/dist/_browser-chunks/chunk-KBK7GKBN.js +35 -0
  97. package/dist/_browser-chunks/chunk-KQ7CRO2B.js +108 -0
  98. package/dist/_browser-chunks/chunk-LAWXTSXK.js +18 -0
  99. package/dist/_browser-chunks/chunk-LE2LTDW3.js +14 -0
  100. package/dist/_browser-chunks/chunk-LEVSOOLQ.js +48 -0
  101. package/dist/_browser-chunks/chunk-LV5PIKV4.js +93 -0
  102. package/dist/_browser-chunks/chunk-MDOL7KML.js +56 -0
  103. package/dist/_browser-chunks/chunk-MFMDGWP6.js +34 -0
  104. package/dist/_browser-chunks/chunk-MLBOOZL4.js +67 -0
  105. package/dist/_browser-chunks/chunk-NQUD4B7H.js +91 -0
  106. package/dist/_browser-chunks/chunk-NULBREPZ.js +43 -0
  107. package/dist/_browser-chunks/chunk-NZMVUW5T.js +7 -0
  108. package/dist/_browser-chunks/chunk-OD6IBQCC.js +117 -0
  109. package/dist/_browser-chunks/chunk-ODVJ3XZJ.js +157 -0
  110. package/dist/_browser-chunks/chunk-OQWFVDIN.js +386 -0
  111. package/dist/_browser-chunks/chunk-OVH3USFB.js +20 -0
  112. package/dist/_browser-chunks/chunk-OZZPSYQR.js +14 -0
  113. package/dist/_browser-chunks/chunk-P6PK47TQ.js +1970 -0
  114. package/dist/_browser-chunks/chunk-PFRNG3UC.js +22 -0
  115. package/dist/_browser-chunks/chunk-PJSMZ27A.js +13 -0
  116. package/dist/_browser-chunks/chunk-QC4HFS6K.js +41 -0
  117. package/dist/_browser-chunks/chunk-QDXFODK4.js +274 -0
  118. package/dist/_browser-chunks/chunk-RBCHTR7C.js +28 -0
  119. package/dist/_browser-chunks/chunk-RMYQ3QN3.js +294 -0
  120. package/dist/_browser-chunks/chunk-RNTIV5CE.js +411 -0
  121. package/dist/_browser-chunks/chunk-RSPAQWVJ.js +80 -0
  122. package/dist/_browser-chunks/chunk-S6TK43XQ.js +836 -0
  123. package/dist/_browser-chunks/chunk-SC67XZST.js +18 -0
  124. package/dist/_browser-chunks/chunk-SFVA4SBT.js +683 -0
  125. package/dist/_browser-chunks/chunk-SZYFOQMT.js +25 -0
  126. package/dist/_browser-chunks/chunk-TBJCJXK4.js +18 -0
  127. package/dist/_browser-chunks/chunk-UMDO3KB7.js +205 -0
  128. package/dist/_browser-chunks/chunk-V2G23FV7.js +11 -0
  129. package/dist/_browser-chunks/chunk-V5M7Q4HT.js +88 -0
  130. package/dist/_browser-chunks/chunk-W5M6NPS3.js +198 -0
  131. package/dist/_browser-chunks/chunk-W7NE2JXW.js +84 -0
  132. package/dist/_browser-chunks/chunk-WGVAAM43.js +1110 -0
  133. package/dist/_browser-chunks/chunk-WHQRNHXD.js +8 -0
  134. package/dist/_browser-chunks/chunk-WOSOWBCA.js +12 -0
  135. package/dist/_browser-chunks/chunk-WZ7KR7SH.js +85 -0
  136. package/dist/_browser-chunks/chunk-YEKO6BHJ.js +20 -0
  137. package/dist/_browser-chunks/chunk-YI2IBIQS.js +7 -0
  138. package/dist/_browser-chunks/chunk-YTIT5NA5.js +1966 -0
  139. package/dist/_browser-chunks/chunk-ZEHRUHTA.js +6 -0
  140. package/dist/_browser-chunks/chunk-ZTQ5MEJ5.js +203 -0
  141. package/dist/_browser-chunks/matchers-YLBYSYAF.js +1263 -0
  142. package/dist/_browser-chunks/react-dom-client-4OHE3QDV.js +9 -0
  143. package/dist/_node-chunks/attached-runtime-I2G4WLJI.js +282 -0
  144. package/dist/_node-chunks/builder-manager-VVHYQXCH.js +1661 -0
  145. package/dist/_node-chunks/chunk-2BUPBPFB.js +82 -0
  146. package/dist/_node-chunks/chunk-2DSIDINN.js +884 -0
  147. package/dist/_node-chunks/chunk-2RU7BKEW.js +23 -0
  148. package/dist/_node-chunks/chunk-34EO2PUT.js +26 -0
  149. package/dist/_node-chunks/chunk-3BKIBF5S.js +3008 -0
  150. package/dist/_node-chunks/chunk-3SDUYDXH.js +98 -0
  151. package/dist/_node-chunks/chunk-3T4ZSNPH.js +662 -0
  152. package/dist/_node-chunks/chunk-3W7F2B7P.js +79 -0
  153. package/dist/_node-chunks/chunk-3Y6AAY5H.js +80 -0
  154. package/dist/_node-chunks/chunk-42UWAGPW.js +1193 -0
  155. package/dist/_node-chunks/chunk-4FEANXWU.js +1986 -0
  156. package/dist/_node-chunks/chunk-5DQFEZEA.js +40 -0
  157. package/dist/_node-chunks/chunk-6KEHV53S.js +1218 -0
  158. package/dist/_node-chunks/chunk-6LMWA44H.js +3837 -0
  159. package/dist/_node-chunks/chunk-6YKBRP72.js +20 -0
  160. package/dist/_node-chunks/chunk-7GUDZVRQ.js +110 -0
  161. package/dist/_node-chunks/chunk-B5J7Q7J4.js +21 -0
  162. package/dist/_node-chunks/chunk-BS2WMZMR.js +90 -0
  163. package/dist/_node-chunks/chunk-BSKFCWQD.js +47 -0
  164. package/dist/_node-chunks/chunk-BXVYT7SB.js +36 -0
  165. package/dist/_node-chunks/chunk-CCOTJ4FC.js +688 -0
  166. package/dist/_node-chunks/chunk-CQKMLL5J.js +33 -0
  167. package/dist/_node-chunks/chunk-CXRU72ET.js +63 -0
  168. package/dist/_node-chunks/chunk-DC7DKR5K.js +20 -0
  169. package/dist/_node-chunks/chunk-DHJFTB4K.js +25 -0
  170. package/dist/_node-chunks/chunk-DUR55DJJ.js +1094 -0
  171. package/dist/_node-chunks/chunk-E6YESGLX.js +7032 -0
  172. package/dist/_node-chunks/chunk-EHUNOMDD.js +52345 -0
  173. package/dist/_node-chunks/chunk-ET7PWEO7.js +298 -0
  174. package/dist/_node-chunks/chunk-EWOX7HPJ.js +20 -0
  175. package/dist/_node-chunks/chunk-F3ZFKBHY.js +844 -0
  176. package/dist/_node-chunks/chunk-FK7KGTV7.js +26 -0
  177. package/dist/_node-chunks/chunk-FPZB5OI7.js +35 -0
  178. package/dist/_node-chunks/chunk-FW2HQUBQ.js +25 -0
  179. package/dist/_node-chunks/chunk-FY6UXW6G.js +11 -0
  180. package/dist/_node-chunks/chunk-GEFQN7K3.js +499 -0
  181. package/dist/_node-chunks/chunk-GRBLDJCR.js +989 -0
  182. package/dist/_node-chunks/chunk-H32DYT6P.js +87 -0
  183. package/dist/_node-chunks/chunk-H4PPVMP5.js +23 -0
  184. package/dist/_node-chunks/chunk-HMP2G23X.js +25 -0
  185. package/dist/_node-chunks/chunk-ICPBH3E7.js +59 -0
  186. package/dist/_node-chunks/chunk-IDEL2J23.js +23 -0
  187. package/dist/_node-chunks/chunk-IK4FGZLR.js +223 -0
  188. package/dist/_node-chunks/chunk-JDXXX6LB.js +68 -0
  189. package/dist/_node-chunks/chunk-JGGFYIG5.js +5468 -0
  190. package/dist/_node-chunks/chunk-JPAZLYJ3.js +29 -0
  191. package/dist/_node-chunks/chunk-JZOO7GGC.js +48 -0
  192. package/dist/_node-chunks/chunk-KISMCCP5.js +4744 -0
  193. package/dist/_node-chunks/chunk-LCK4ZQKG.js +115 -0
  194. package/dist/_node-chunks/chunk-LO56I6E2.js +132 -0
  195. package/dist/_node-chunks/chunk-LXBD4UL4.js +104 -0
  196. package/dist/_node-chunks/chunk-MA24JW6C.js +7162 -0
  197. package/dist/_node-chunks/chunk-MK2KYAI6.js +5414 -0
  198. package/dist/_node-chunks/chunk-NDWKJ4CL.js +2102 -0
  199. package/dist/_node-chunks/chunk-NIBT7XDZ.js +168 -0
  200. package/dist/_node-chunks/chunk-NPO45IMH.js +33 -0
  201. package/dist/_node-chunks/chunk-OISX4AGQ.js +414 -0
  202. package/dist/_node-chunks/chunk-OUW6R7C3.js +26 -0
  203. package/dist/_node-chunks/chunk-OWNFOGTA.js +194 -0
  204. package/dist/_node-chunks/chunk-Q7QNUM5H.js +49 -0
  205. package/dist/_node-chunks/chunk-QEQLR22M.js +1877 -0
  206. package/dist/_node-chunks/chunk-RRN2V55B.js +45 -0
  207. package/dist/_node-chunks/chunk-RWFIFGO5.js +144 -0
  208. package/dist/_node-chunks/chunk-RXNJDRGO.js +209 -0
  209. package/dist/_node-chunks/chunk-RZMQ7S3L.js +92 -0
  210. package/dist/_node-chunks/chunk-SIEXZVCR.js +51 -0
  211. package/dist/_node-chunks/chunk-SLWQNBGO.js +2034 -0
  212. package/dist/_node-chunks/chunk-SVTBJ7Q3.js +35 -0
  213. package/dist/_node-chunks/chunk-SWO5CDYU.js +32 -0
  214. package/dist/_node-chunks/chunk-TD5PLLQG.js +121 -0
  215. package/dist/_node-chunks/chunk-TEQGGSP7.js +33 -0
  216. package/dist/_node-chunks/chunk-TFCEV2XX.js +155 -0
  217. package/dist/_node-chunks/chunk-TFEWM4E3.js +1073 -0
  218. package/dist/_node-chunks/chunk-TINO74G5.js +21 -0
  219. package/dist/_node-chunks/chunk-TNJIXE37.js +40 -0
  220. package/dist/_node-chunks/chunk-TWI4GVH7.js +19 -0
  221. package/dist/_node-chunks/chunk-U5W53R2J.js +1011 -0
  222. package/dist/_node-chunks/chunk-UBOGWBEA.js +148 -0
  223. package/dist/_node-chunks/chunk-UMUBKI6E.js +3787 -0
  224. package/dist/_node-chunks/chunk-UVINFLGY.js +56 -0
  225. package/dist/_node-chunks/chunk-V2DY426G.js +1133 -0
  226. package/dist/_node-chunks/chunk-VLOXOXXE.js +45 -0
  227. package/dist/_node-chunks/chunk-W4OMYLSP.js +1297 -0
  228. package/dist/_node-chunks/chunk-WAXVSN3O.js +18 -0
  229. package/dist/_node-chunks/chunk-WCULS5TP.js +3767 -0
  230. package/dist/_node-chunks/chunk-WNZ2UMFM.js +153 -0
  231. package/dist/_node-chunks/chunk-WZJF2OUH.js +74 -0
  232. package/dist/_node-chunks/chunk-XGIUVY52.js +611 -0
  233. package/dist/_node-chunks/chunk-XHL2LVBM.js +415 -0
  234. package/dist/_node-chunks/chunk-XI6B6P47.js +59 -0
  235. package/dist/_node-chunks/chunk-XLP2ZKXV.js +60 -0
  236. package/dist/_node-chunks/chunk-YCMRA6RX.js +95 -0
  237. package/dist/_node-chunks/chunk-YZFWBA5L.js +2700 -0
  238. package/dist/_node-chunks/chunk-ZMAMXQKP.js +4731 -0
  239. package/dist/_node-chunks/chunk-ZWBCQ4MJ.js +110 -0
  240. package/dist/_node-chunks/dist-VTSTZKUB.js +16 -0
  241. package/dist/_node-chunks/globby-OEMHPBFY.js +2884 -0
  242. package/dist/_node-chunks/jiti-NFX6UU74.js +3848 -0
  243. package/dist/_node-chunks/lib-MDVARD7W.js +366 -0
  244. package/dist/_node-chunks/local-runtime-NTKIN2QT.js +78 -0
  245. package/dist/_node-chunks/mdx-plugin-MWISDWDQ.js +5680 -0
  246. package/dist/_node-chunks/monorepo-LIRFMQXE.js +121 -0
  247. package/dist/_node-chunks/monorepo-optimized-tests-relaxed-limits-no-story-deletion-CPDW4XTW.js +121 -0
  248. package/dist/_node-chunks/optimized-tests-HDOLR3EY.js +22 -0
  249. package/dist/_node-chunks/pattern-copy-play-EKHIUAU2.js +807 -0
  250. package/dist/_node-chunks/postinstallAddon-GYGMWDL6.js +20 -0
  251. package/dist/_node-chunks/rehype-external-links-BUN3HUCO.js +121 -0
  252. package/dist/_node-chunks/rehype-slug-PLADX223.js +52 -0
  253. package/dist/_node-chunks/relaxed-limits-GBHW6KIQ.js +117 -0
  254. package/dist/_node-chunks/run-KDTIZNSY.js +103 -0
  255. package/dist/_node-chunks/run-NL66VTNR.js +4532 -0
  256. package/dist/_node-chunks/session-id-KIIVOQLR.js +23 -0
  257. package/dist/_node-chunks/setup-MGC7BQO6.js +278 -0
  258. package/dist/_node-chunks/vitest.config.4.template-JH2THZFG.js +54 -0
  259. package/dist/actions/decorator.d.ts +7 -0
  260. package/dist/actions/decorator.js +43 -0
  261. package/dist/actions/index.d.ts +67 -0
  262. package/dist/actions/index.js +28 -0
  263. package/dist/addon-a11y/index.d.ts +52 -0
  264. package/dist/addon-a11y/index.js +16 -0
  265. package/dist/addon-a11y/manager.js +1429 -0
  266. package/dist/addon-a11y/preset.js +18 -0
  267. package/dist/addon-a11y/preview.d.ts +17 -0
  268. package/dist/addon-a11y/preview.js +15 -0
  269. package/dist/addon-docs/blocks.d.ts +1061 -0
  270. package/dist/addon-docs/blocks.js +2461 -0
  271. package/dist/addon-docs/index.d.ts +236 -0
  272. package/dist/addon-docs/index.js +16 -0
  273. package/dist/addon-docs/manager.js +90 -0
  274. package/dist/addon-docs/mdx-react-shim.d.ts +1 -0
  275. package/dist/addon-docs/mdx-react-shim.js +2 -0
  276. package/dist/addon-docs/preset.js +378 -0
  277. package/dist/addon-docs/preview.d.ts +4 -0
  278. package/dist/addon-docs/preview.js +7 -0
  279. package/dist/addon-links/index.d.ts +22 -0
  280. package/dist/addon-links/index.js +20 -0
  281. package/dist/addon-links/manager.js +14 -0
  282. package/dist/addon-links/preview.d.ts +6 -0
  283. package/dist/addon-links/preview.js +9 -0
  284. package/dist/addon-links/react/index.d.ts +25 -0
  285. package/dist/addon-links/react/index.js +52 -0
  286. package/dist/addon-mcp/preset.js +1345 -0
  287. package/dist/addon-mcp/preview.js +29 -0
  288. package/dist/addon-mcp/tools/preview-stories/preview-stories-app-script.js +1153 -0
  289. package/dist/addon-ondevice-actions/index.d.ts +4 -0
  290. package/dist/addon-ondevice-actions/index.js +7 -0
  291. package/dist/addon-ondevice-actions/register.js +7 -0
  292. package/dist/addon-ondevice-controls/index.d.ts +6 -0
  293. package/dist/addon-ondevice-controls/index.js +14 -0
  294. package/dist/addon-ondevice-controls/register.js +10 -0
  295. package/dist/addon-pseudo-states/index.d.ts +35 -0
  296. package/dist/addon-pseudo-states/index.js +15 -0
  297. package/dist/addon-pseudo-states/manager.js +53 -0
  298. package/dist/addon-pseudo-states/preview.d.ts +9 -0
  299. package/dist/addon-pseudo-states/preview.js +10 -0
  300. package/dist/addon-themes/index.d.ts +80 -0
  301. package/dist/addon-themes/index.js +104 -0
  302. package/dist/addon-themes/manager.js +97 -0
  303. package/dist/addon-themes/postinstall.js +33 -0
  304. package/dist/addon-themes/preview.d.ts +6 -0
  305. package/dist/addon-themes/preview.js +8 -0
  306. package/dist/addon-vitest/constants.d.ts +132 -0
  307. package/dist/addon-vitest/constants.js +66 -0
  308. package/dist/addon-vitest/index.d.ts +4 -0
  309. package/dist/addon-vitest/index.js +8 -0
  310. package/dist/addon-vitest/manager.js +665 -0
  311. package/dist/addon-vitest/node/coverage-reporter.js +1284 -0
  312. package/dist/addon-vitest/node/vitest.js +674 -0
  313. package/dist/addon-vitest/postinstall.js +24 -0
  314. package/dist/addon-vitest/preset.js +943 -0
  315. package/dist/addon-vitest/vitest-plugin/global-setup.js +162 -0
  316. package/dist/addon-vitest/vitest-plugin/index.d.ts +56 -0
  317. package/dist/addon-vitest/vitest-plugin/index.js +463 -0
  318. package/dist/addon-vitest/vitest-plugin/setup-file-with-project-annotations.js +9 -0
  319. package/dist/addon-vitest/vitest-plugin/setup-file.browser.4.js +20 -0
  320. package/dist/addon-vitest/vitest-plugin/setup-file.js +50 -0
  321. package/dist/addon-vitest/vitest-plugin/test-utils.js +128 -0
  322. package/dist/babel/index.d.ts +2301 -0
  323. package/dist/babel/index.js +61 -0
  324. package/dist/backgrounds/index.d.ts +6 -0
  325. package/dist/backgrounds/index.js +15 -0
  326. package/dist/bin/core.js +1705 -0
  327. package/dist/bin/dispatcher.js +43 -0
  328. package/dist/bin/loader.js +115 -0
  329. package/dist/builder-vite/index.d.ts +50 -0
  330. package/dist/builder-vite/index.js +245 -0
  331. package/dist/builder-vite/preset.js +27 -0
  332. package/dist/channels/index.d.ts +2 -0
  333. package/dist/channels/index.js +352 -0
  334. package/dist/chunk-B2t1tGRh.d.ts +284 -0
  335. package/dist/chunk-BCoJQE-f.d.ts +602 -0
  336. package/dist/chunk-BGkgZp-H.d.ts +214 -0
  337. package/dist/chunk-BTVrWliM.d.ts +115 -0
  338. package/dist/chunk-BXLImeLy.d.ts +197 -0
  339. package/dist/chunk-BfBzpgct.d.ts +916 -0
  340. package/dist/chunk-Bpi2tz-6.d.ts +511 -0
  341. package/dist/chunk-BxWufQms.d.ts +142 -0
  342. package/dist/chunk-C-bavsOH.d.ts +34 -0
  343. package/dist/chunk-C2p5r3Vt.d.ts +13001 -0
  344. package/dist/chunk-C6PAgHLT.d.ts +12 -0
  345. package/dist/chunk-CMeX4WRe.d.ts +179 -0
  346. package/dist/chunk-Ct9xd6IM.d.ts +65 -0
  347. package/dist/chunk-CwQKNaYL.d.ts +15 -0
  348. package/dist/chunk-D7DwV41f.d.ts +3622 -0
  349. package/dist/chunk-DEVFdzxR.d.ts +253 -0
  350. package/dist/chunk-DaVb55-_.d.ts +124 -0
  351. package/dist/chunk-DgRNfmj_.d.ts +40 -0
  352. package/dist/chunk-DoIGKY33.d.ts +666 -0
  353. package/dist/chunk-Dr3R0DXk.d.ts +40 -0
  354. package/dist/chunk-DtHByo32.d.ts +55 -0
  355. package/dist/chunk-Dw1z1Pki.d.ts +933 -0
  356. package/dist/chunk-DzuY9DXg.d.ts +79 -0
  357. package/dist/chunk-FjDVzZTj.d.ts +62 -0
  358. package/dist/chunk-Kt1tW-D1.d.ts +59 -0
  359. package/dist/chunk-XP8oHzpE.d.ts +6 -0
  360. package/dist/chunk-gCX81nOr.d.ts +61 -0
  361. package/dist/chunk-pcFXCimE.d.ts +741 -0
  362. package/dist/cli/index.d.ts +1174 -0
  363. package/dist/cli/index.js +5613 -0
  364. package/dist/cli/skills/content/index.d.ts +72 -0
  365. package/dist/cli/skills/content/index.js +335 -0
  366. package/dist/cli/tools/sdk/child-host.d.ts +61 -0
  367. package/dist/cli/tools/sdk/child-host.js +131 -0
  368. package/dist/cli/tools/sdk/index.d.ts +137 -0
  369. package/dist/cli/tools/sdk/index.js +44 -0
  370. package/dist/cli-commands/bin/index.js +25 -0
  371. package/dist/client-logger/index.d.ts +31 -0
  372. package/dist/client-logger/index.js +63 -0
  373. package/dist/common/index.d.ts +1103 -0
  374. package/dist/common/index.js +364 -0
  375. package/dist/components/index.d.ts +1924 -0
  376. package/dist/components/index.js +13759 -0
  377. package/dist/core-events/index.d.ts +155 -0
  378. package/dist/core-events/index.js +136 -0
  379. package/dist/core-server/index.d.ts +2200 -0
  380. package/dist/core-server/index.js +4165 -0
  381. package/dist/core-server/presets/common-manager.css +170 -0
  382. package/dist/core-server/presets/common-manager.js +4168 -0
  383. package/dist/core-server/presets/common-override-preset.js +81 -0
  384. package/dist/core-server/presets/common-preset.js +2187 -0
  385. package/dist/create/bin/index.js +23 -0
  386. package/dist/create/index.js +25 -0
  387. package/dist/csf/csf-utils.d.ts +2 -0
  388. package/dist/csf/csf-utils.js +19 -0
  389. package/dist/csf/index.d.ts +7 -0
  390. package/dist/csf/index.js +2142 -0
  391. package/dist/csf-tools/index.d.ts +1157 -0
  392. package/dist/csf-tools/index.js +736 -0
  393. package/dist/docs-tools/index.d.ts +197 -0
  394. package/dist/docs-tools/index.js +61 -0
  395. package/dist/highlight/index.d.ts +10 -0
  396. package/dist/highlight/index.js +15 -0
  397. package/dist/instrumenter/index.d.ts +113 -0
  398. package/dist/instrumenter/index.js +2595 -0
  399. package/dist/manager/_manager-chunks/globals-runtime-8HkdnU2F.js +6144 -0
  400. package/dist/manager/_manager-chunks/globals-runtime-BIKBO23x.js +3389 -0
  401. package/dist/manager/_manager-chunks/globals-runtime-BdGkqNEt.js +45 -0
  402. package/dist/manager/_manager-chunks/globals-runtime-BmphMP6z.js +1190 -0
  403. package/dist/manager/_manager-chunks/globals-runtime-BvM-NY2g.js +13307 -0
  404. package/dist/manager/_manager-chunks/globals-runtime-C02fvgcd.js +9243 -0
  405. package/dist/manager/_manager-chunks/globals-runtime-DkAPXCvc.js +9766 -0
  406. package/dist/manager/_manager-chunks/globals-runtime-DpNYC-qi.js +5564 -0
  407. package/dist/manager/_manager-chunks/globals-runtime-DtcOnYHR.js +5357 -0
  408. package/dist/manager/_manager-chunks/globals-runtime-DwFqpqya.js +722 -0
  409. package/dist/manager/_manager-chunks/globals-runtime-FC201B7s.js +6837 -0
  410. package/dist/manager/_manager-chunks/globals-runtime-Rp_zjGnh.js +121 -0
  411. package/dist/manager/_manager-chunks/globals-runtime-ZHrQFa3-.js +10463 -0
  412. package/dist/manager/_manager-chunks/globals-runtime-eLPTIfX-.js +7759 -0
  413. package/dist/manager/_manager-chunks/globals-runtime-qKvCZHFY.js +4468 -0
  414. package/dist/manager/_manager-chunks/globals-runtime-sGpNlIJ1.js +5102 -0
  415. package/dist/manager/_manager-chunks/runtime-B1L9TH89.js +452 -0
  416. package/dist/manager/_manager-chunks/runtime-BK0zF7FN.js +22 -0
  417. package/dist/manager/_manager-chunks/runtime-BhkT2CXl.js +1408 -0
  418. package/dist/manager/_manager-chunks/runtime-Bly6WJLN.js +998 -0
  419. package/dist/manager/_manager-chunks/runtime-D0UOWx0U.js +979 -0
  420. package/dist/manager/_manager-chunks/runtime-D94Vq3oR.js +4014 -0
  421. package/dist/manager/_manager-chunks/runtime-DMig8mT7.js +77 -0
  422. package/dist/manager/_manager-chunks/runtime-EITvVbkG.js +46 -0
  423. package/dist/manager/_manager-chunks/runtime-cp5pazY2.js +8936 -0
  424. package/dist/manager/_manager-chunks/runtime-eDVAYF7N.js +6860 -0
  425. package/dist/manager/_manager-chunks/runtime-i-PDAHLR.js +2493 -0
  426. package/dist/manager/globals-runtime.js +2 -0
  427. package/dist/manager/globals.d.ts +23 -0
  428. package/dist/manager/globals.js +26 -0
  429. package/dist/manager/manager-stores.d.ts +2 -0
  430. package/dist/manager/manager-stores.js +19 -0
  431. package/dist/manager/runtime.js +2 -0
  432. package/dist/manager-api/index.d.ts +2 -0
  433. package/dist/manager-api/index.js +3257 -0
  434. package/dist/manager-errors.d.ts +89 -0
  435. package/dist/manager-errors.js +20 -0
  436. package/dist/mcp/index.d.ts +270 -0
  437. package/dist/mcp/index.js +305 -0
  438. package/dist/mocking-utils/index.d.ts +689 -0
  439. package/dist/mocking-utils/index.js +521 -0
  440. package/dist/mocking-utils/mocker-runtime.js +1254 -0
  441. package/dist/nextjs-vite/config/preview.js +3 -0
  442. package/dist/nextjs-vite/export-mocks/cache/index.d.ts +25 -0
  443. package/dist/nextjs-vite/export-mocks/cache/index.js +29 -0
  444. package/dist/nextjs-vite/export-mocks/headers/index.d.ts +37 -0
  445. package/dist/nextjs-vite/export-mocks/headers/index.js +54 -0
  446. package/dist/nextjs-vite/export-mocks/link/index.d.ts +9 -0
  447. package/dist/nextjs-vite/export-mocks/link/index.js +59 -0
  448. package/dist/nextjs-vite/export-mocks/navigation/index.d.ts +28 -0
  449. package/dist/nextjs-vite/export-mocks/navigation/index.js +58 -0
  450. package/dist/nextjs-vite/export-mocks/router/index.d.ts +34 -0
  451. package/dist/nextjs-vite/export-mocks/router/index.js +63 -0
  452. package/dist/nextjs-vite/index.d.ts +92 -0
  453. package/dist/nextjs-vite/index.js +58 -0
  454. package/dist/nextjs-vite/node/index.d.ts +6 -0
  455. package/dist/nextjs-vite/node/index.js +20 -0
  456. package/dist/nextjs-vite/preset.js +648 -0
  457. package/dist/nextjs-vite/preview.d.ts +20 -0
  458. package/dist/nextjs-vite/preview.js +11 -0
  459. package/dist/nextjs-vite/vite-plugin/index.d.ts +6 -0
  460. package/dist/nextjs-vite/vite-plugin/index.js +19 -0
  461. package/dist/nextjs-vite-plugin/index.d.ts +28 -0
  462. package/dist/nextjs-vite-plugin/index.js +923 -0
  463. package/dist/nextjs-vite-plugin/mocks/storybook.global.js +29 -0
  464. package/dist/nextjs-vite-plugin/plugins/next-image/alias/image-context.js +8 -0
  465. package/dist/nextjs-vite-plugin/plugins/next-image/alias/image-default-loader.js +23 -0
  466. package/dist/nextjs-vite-plugin/plugins/next-image/alias/next-image.js +28 -0
  467. package/dist/nextjs-vite-plugin/plugins/next-image/alias/next-legacy-image.js +17 -0
  468. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/cache/index.js +29 -0
  469. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/dynamic/index.js +40 -0
  470. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/headers/index.js +55 -0
  471. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/link/index.js +63 -0
  472. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/navigation/index.js +71 -0
  473. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/router/index.js +74 -0
  474. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/rsc/server-only.js +7 -0
  475. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/safe-stable-stringify/index.js +13 -0
  476. package/dist/nextjs-vite-plugin/plugins/next-mocks/compatibility/draft-mode.compat.js +7 -0
  477. package/dist/node-logger/index.d.ts +495 -0
  478. package/dist/node-logger/index.js +42 -0
  479. package/dist/oxc-parser/index.d.ts +99 -0
  480. package/dist/oxc-parser/index.js +275 -0
  481. package/dist/oxc-parser/worker.js +37 -0
  482. package/dist/preview/_chunks/runtime-BIzIdDbb.js +10263 -0
  483. package/dist/preview/_chunks/runtime-BTPtVY1p.js +1102 -0
  484. package/dist/preview/_chunks/runtime-BZSnICCg.js +8484 -0
  485. package/dist/preview/_chunks/runtime-BdGkqNEt.js +45 -0
  486. package/dist/preview/_chunks/runtime-BwSxqk3t.js +63 -0
  487. package/dist/preview/_chunks/runtime-CqHxptiK.js +6143 -0
  488. package/dist/preview/_chunks/runtime-CsV4HZPV.js +5064 -0
  489. package/dist/preview/_chunks/runtime-CxZK_Ln3.js +284 -0
  490. package/dist/preview/_chunks/runtime-DZToXfvO.js +9767 -0
  491. package/dist/preview/_chunks/runtime-DrTjJkPY.js +3872 -0
  492. package/dist/preview/_chunks/runtime-DuHdxMFA.js +387 -0
  493. package/dist/preview/_chunks/runtime-iXdo8CR8.js +3635 -0
  494. package/dist/preview/_chunks/runtime-q3wt0e_N.js +6838 -0
  495. package/dist/preview/globals.d.ts +16 -0
  496. package/dist/preview/globals.js +20 -0
  497. package/dist/preview/runtime.js +6 -0
  498. package/dist/preview-api/index.d.ts +4 -0
  499. package/dist/preview-api/index.js +147 -0
  500. package/dist/preview-errors.d.ts +186 -0
  501. package/dist/preview-errors.js +56 -0
  502. package/dist/react/docgen/docgen-worker.js +38 -0
  503. package/dist/react/entry-preview-argtypes.js +9 -0
  504. package/dist/react/entry-preview-docs.js +12 -0
  505. package/dist/react/entry-preview-rsc.js +11 -0
  506. package/dist/react/entry-preview.js +21 -0
  507. package/dist/react/index.d.ts +119 -0
  508. package/dist/react/index.js +26 -0
  509. package/dist/react/preset.js +301 -0
  510. package/dist/react/preview.d.ts +2 -0
  511. package/dist/react/preview.js +11 -0
  512. package/dist/react-native/bin/get-stories.js +34 -0
  513. package/dist/react-native/index.d.ts +160 -0
  514. package/dist/react-native/index.js +1547 -0
  515. package/dist/react-native/metro/node.d.ts +83 -0
  516. package/dist/react-native/metro/node.js +21 -0
  517. package/dist/react-native/metro/withStorybook.d.ts +2269 -0
  518. package/dist/react-native/metro/withStorybook.js +138 -0
  519. package/dist/react-native/preview.d.ts +6 -0
  520. package/dist/react-native/preview.js +20 -0
  521. package/dist/react-native/scripts/generate.d.ts +22 -0
  522. package/dist/react-native/scripts/generate.js +18 -0
  523. package/dist/react-native/stub.js +20 -0
  524. package/dist/react-native-theming/index.d.ts +175 -0
  525. package/dist/react-native-theming/index.js +2591 -0
  526. package/dist/react-native-ui/index.d.ts +130 -0
  527. package/dist/react-native-ui/index.js +1448 -0
  528. package/dist/react-native-ui-common/index.d.ts +230 -0
  529. package/dist/react-native-ui-common/index.js +514 -0
  530. package/dist/react-vite/index.d.ts +4 -0
  531. package/dist/react-vite/index.js +8 -0
  532. package/dist/react-vite/node/index.d.ts +6 -0
  533. package/dist/react-vite/node/index.js +20 -0
  534. package/dist/react-vite/preset.d.ts +6 -0
  535. package/dist/react-vite/preset.js +21 -0
  536. package/dist/router/index.d.ts +141 -0
  537. package/dist/router/index.js +1217 -0
  538. package/dist/server-errors.d.ts +2 -0
  539. package/dist/server-errors.js +149 -0
  540. package/dist/shared/open-service/index.d.ts +3 -0
  541. package/dist/shared/open-service/index.js +115 -0
  542. package/dist/shared/open-service/services/docgen/worker/docgen-worker.js +75 -0
  543. package/dist/shared/open-service/toolsets/docs/public.d.ts +1296 -0
  544. package/dist/shared/open-service/toolsets/docs/public.js +991 -0
  545. package/dist/telemetry/index.d.ts +314 -0
  546. package/dist/telemetry/index.js +103 -0
  547. package/dist/test/index.d.ts +158 -0
  548. package/dist/test/index.js +19421 -0
  549. package/dist/theming/create.d.ts +15 -0
  550. package/dist/theming/create.js +11 -0
  551. package/dist/theming/index.d.ts +54 -0
  552. package/dist/theming/index.js +511 -0
  553. package/dist/types/index.d.ts +2 -0
  554. package/dist/types/index.js +48 -0
  555. package/dist/viewport/index.d.ts +275 -0
  556. package/dist/viewport/index.js +21 -0
  557. package/package.json +1054 -4
  558. package/template/nextjs-vite/cli/.eslintrc.json +6 -0
  559. package/template/nextjs-vite/cli/js/Button.jsx +42 -0
  560. package/template/nextjs-vite/cli/js/Button.stories.js +49 -0
  561. package/template/nextjs-vite/cli/js/Configure.mdx +470 -0
  562. package/template/nextjs-vite/cli/js/Header.jsx +58 -0
  563. package/template/nextjs-vite/cli/js/Header.stories.js +30 -0
  564. package/template/nextjs-vite/cli/js/Page.jsx +68 -0
  565. package/template/nextjs-vite/cli/js/Page.stories.js +28 -0
  566. package/template/nextjs-vite/cli/ts/Button.stories.ts +54 -0
  567. package/template/nextjs-vite/cli/ts/Button.tsx +39 -0
  568. package/template/nextjs-vite/cli/ts/Configure.mdx +446 -0
  569. package/template/nextjs-vite/cli/ts/Header.stories.ts +34 -0
  570. package/template/nextjs-vite/cli/ts/Header.tsx +54 -0
  571. package/template/nextjs-vite/cli/ts/Page.stories.ts +33 -0
  572. package/template/nextjs-vite/cli/ts/Page.tsx +73 -0
  573. package/template/react/cli/.eslintrc.json +5 -0
  574. package/template/react/cli/js/Button.jsx +39 -0
  575. package/template/react/cli/js/Button.stories.js +49 -0
  576. package/template/react/cli/js/Header.jsx +56 -0
  577. package/template/react/cli/js/Header.stories.js +29 -0
  578. package/template/react/cli/js/Page.jsx +69 -0
  579. package/template/react/cli/js/Page.stories.js +28 -0
  580. package/template/react/cli/ts/Button.stories.ts +54 -0
  581. package/template/react/cli/ts/Button.tsx +37 -0
  582. package/template/react/cli/ts/Header.stories.ts +34 -0
  583. package/template/react/cli/ts/Header.tsx +56 -0
  584. package/template/react/cli/ts/Page.stories.ts +33 -0
  585. package/template/react/cli/ts/Page.tsx +73 -0
  586. package/template/react-vite/cli/.eslintrc.json +5 -0
  587. package/template/react-vite/cli/js/Button.jsx +39 -0
  588. package/template/react-vite/cli/js/Button.stories.js +49 -0
  589. package/template/react-vite/cli/js/Header.jsx +56 -0
  590. package/template/react-vite/cli/js/Header.stories.js +29 -0
  591. package/template/react-vite/cli/js/Page.jsx +69 -0
  592. package/template/react-vite/cli/js/Page.stories.js +28 -0
  593. package/template/react-vite/cli/ts/Button.stories.ts +54 -0
  594. package/template/react-vite/cli/ts/Button.tsx +37 -0
  595. package/template/react-vite/cli/ts/Header.stories.ts +34 -0
  596. package/template/react-vite/cli/ts/Header.tsx +56 -0
  597. package/template/react-vite/cli/ts/Page.stories.ts +33 -0
  598. package/template/react-vite/cli/ts/Page.tsx +73 -0
@@ -0,0 +1,3872 @@
1
+ import { n as __esmMin, r as __exportAll } from "./runtime-BdGkqNEt.js";
2
+ import { at as init_dist, ct as stringify, it as invariant, lt as dedent, ot as isJSON, rt as init_tiny_invariant, st as parse, ut as init_esm } from "./runtime-BZSnICCg.js";
3
+ import { n as init_storybook_error, t as StorybookError } from "./runtime-BwSxqk3t.js";
4
+ import { A as matchesHostname, M as init_universal_store, O as LOOPBACK_HOSTNAMES, f as init_preview$7, h as preview_default$6, j as UniversalStore, k as init_local_hosts, m as init_preview$6, p as preview_default$7 } from "./runtime-iXdo8CR8.js";
5
+ import { f as require_tiny_isequal, h as scope, m as init_dist$1 } from "./runtime-BTPtVY1p.js";
6
+ import { c as useMemo, d as ImplicitActionsDuringRendering, f as InvalidChannelPageError, l as addons$1, p as init_preview_errors, r as init_preview_api$1, s as useEffect } from "./runtime-CsV4HZPV.js";
7
+ import { o as init_preview$8, s as preview_default$8 } from "./runtime-CxZK_Ln3.js";
8
+ import { h as processError, m as init_error } from "./runtime-q3wt0e_N.js";
9
+ import { n as preview_default$9, o as onMockCall, r as init_test, t as init_preview$9 } from "./runtime-DuHdxMFA.js";
10
+ //#region src/manager-errors.ts
11
+ var UniversalStoreFollowerTimeoutError, OpenServiceStaticSnapshotLoadError, OpenServiceStaticSnapshotInvalidError;
12
+ function init_manager_errors() {
13
+ return (init_manager_errors = __esmMin((() => {
14
+ init_storybook_error();
15
+ UniversalStoreFollowerTimeoutError = class extends StorybookError {
16
+ constructor(followerId) {
17
+ super({
18
+ name: "UniversalStoreFollowerTimeoutError",
19
+ category: "MANAGER_UNIVERSAL-STORE",
20
+ code: 1,
21
+ message: `Timed out waiting for leader state for UniversalStore follower with id: '${followerId}'. Ensure a leader with the same id exists and is reachable before creating a follower.`
22
+ });
23
+ }
24
+ };
25
+ OpenServiceStaticSnapshotLoadError = class extends StorybookError {
26
+ constructor(data) {
27
+ super({
28
+ name: "OpenServiceStaticSnapshotLoadError",
29
+ category: "MANAGER_OPEN-SERVICE",
30
+ code: 1,
31
+ message: `Failed to load open-service static snapshot "${data.logicalPath}" from "${data.url}" for "${data.serviceId}.${data.queryName}".`,
32
+ cause: data.cause
33
+ });
34
+ this.data = data;
35
+ }
36
+ };
37
+ OpenServiceStaticSnapshotInvalidError = class extends StorybookError {
38
+ constructor(data) {
39
+ super({
40
+ name: "OpenServiceStaticSnapshotInvalidError",
41
+ category: "MANAGER_OPEN-SERVICE",
42
+ code: 2,
43
+ message: `Open-service static snapshot "${data.logicalPath}" from "${data.url}" for "${data.serviceId}.${data.queryName}" must be a plain object.`
44
+ });
45
+ this.data = data;
46
+ }
47
+ };
48
+ })))();
49
+ }
50
+ //#endregion
51
+ //#region src/channels/main.ts
52
+ var isMulti, generateRandomId, Channel;
53
+ function init_main() {
54
+ return (init_main = __esmMin((() => {
55
+ isMulti = (args) => {
56
+ return args.transports !== void 0;
57
+ };
58
+ generateRandomId = () => {
59
+ return Math.random().toString(16).slice(2);
60
+ };
61
+ Channel = class {
62
+ constructor(input = {}) {
63
+ this.sender = generateRandomId();
64
+ this.events = {};
65
+ this.data = {};
66
+ this.transports = [];
67
+ this.isAsync = input.async || false;
68
+ if (isMulti(input)) {
69
+ this.transports = input.transports || [];
70
+ this.transports.forEach((t) => {
71
+ t.setHandler((event) => this.handleEvent(event));
72
+ });
73
+ } else this.transports = input.transport ? [input.transport] : [];
74
+ this.transports.forEach((t) => {
75
+ t.setHandler((event) => this.handleEvent(event));
76
+ });
77
+ }
78
+ get hasTransport() {
79
+ return this.transports.length > 0;
80
+ }
81
+ addListener(eventName, listener) {
82
+ this.events[eventName] = this.events[eventName] || [];
83
+ this.events[eventName].push(listener);
84
+ }
85
+ emit(eventName, ...args) {
86
+ const event = {
87
+ type: eventName,
88
+ args,
89
+ from: this.sender
90
+ };
91
+ let options = {};
92
+ if (args.length >= 1 && args[0] && args[0].options) options = args[0].options;
93
+ const handler = () => {
94
+ this.transports.forEach((t) => {
95
+ t.send(event, options);
96
+ });
97
+ this.handleEvent(event);
98
+ };
99
+ if (this.isAsync) setImmediate(handler);
100
+ else handler();
101
+ }
102
+ last(eventName) {
103
+ return this.data[eventName];
104
+ }
105
+ eventNames() {
106
+ return Object.keys(this.events);
107
+ }
108
+ listenerCount(eventName) {
109
+ const listeners = this.listeners(eventName);
110
+ return listeners ? listeners.length : 0;
111
+ }
112
+ listeners(eventName) {
113
+ return this.events[eventName] || void 0;
114
+ }
115
+ once(eventName, listener) {
116
+ const onceListener = this.onceListener(eventName, listener);
117
+ this.addListener(eventName, onceListener);
118
+ }
119
+ removeAllListeners(eventName) {
120
+ if (!eventName) this.events = {};
121
+ else if (this.events[eventName]) delete this.events[eventName];
122
+ }
123
+ removeListener(eventName, listener) {
124
+ const listeners = this.listeners(eventName);
125
+ if (listeners) this.events[eventName] = listeners.filter((l) => l !== listener);
126
+ }
127
+ on(eventName, listener) {
128
+ this.addListener(eventName, listener);
129
+ }
130
+ off(eventName, listener) {
131
+ this.removeListener(eventName, listener);
132
+ }
133
+ /**
134
+ * Deliver an event to local listeners without sending it to this channel's transports.
135
+ */
136
+ receive(event) {
137
+ this.handleEvent(event);
138
+ }
139
+ handleEvent(event) {
140
+ const listeners = this.listeners(event.type);
141
+ if (listeners && listeners.length) listeners.forEach((fn) => {
142
+ fn.apply(event, event.args);
143
+ });
144
+ this.data[event.type] = event.args;
145
+ }
146
+ onceListener(eventName, listener) {
147
+ const onceListener = (...args) => {
148
+ this.removeListener(eventName, onceListener);
149
+ return listener(...args);
150
+ };
151
+ return onceListener;
152
+ }
153
+ };
154
+ })))();
155
+ }
156
+ //#endregion
157
+ //#region src/client-logger/index.ts
158
+ var client_logger_exports = /* @__PURE__ */ __exportAll({
159
+ deprecate: () => deprecate,
160
+ logger: () => logger,
161
+ once: () => once,
162
+ pretty: () => pretty
163
+ });
164
+ var LOGLEVEL, levels, currentLogLevelNumber, logger, logged, once, deprecate, pretty;
165
+ function init_client_logger() {
166
+ return (init_client_logger = __esmMin((() => {
167
+ init_dist$1();
168
+ ({LOGLEVEL} = scope);
169
+ levels = {
170
+ trace: 1,
171
+ debug: 2,
172
+ info: 3,
173
+ warn: 4,
174
+ error: 5,
175
+ silent: 10
176
+ };
177
+ currentLogLevelNumber = levels[LOGLEVEL] || levels.info;
178
+ logger = {
179
+ trace: (message, ...rest) => {
180
+ if (currentLogLevelNumber <= levels.trace) console.trace(message, ...rest);
181
+ },
182
+ debug: (message, ...rest) => {
183
+ if (currentLogLevelNumber <= levels.debug) console.debug(message, ...rest);
184
+ },
185
+ info: (message, ...rest) => {
186
+ if (currentLogLevelNumber <= levels.info) console.info(message, ...rest);
187
+ },
188
+ warn: (message, ...rest) => {
189
+ if (currentLogLevelNumber <= levels.warn) console.warn(message, ...rest);
190
+ },
191
+ error: (message, ...rest) => {
192
+ if (currentLogLevelNumber <= levels.error) console.error(message, ...rest);
193
+ },
194
+ log: (message, ...rest) => {
195
+ if (currentLogLevelNumber < levels.silent) console.log(message, ...rest);
196
+ }
197
+ };
198
+ logged = /* @__PURE__ */ new Set();
199
+ once = (type) => (message, ...rest) => {
200
+ if (logged.has(message)) return;
201
+ logged.add(message);
202
+ return logger[type](message, ...rest);
203
+ };
204
+ once.clear = () => logged.clear();
205
+ once.trace = once("trace");
206
+ once.debug = once("debug");
207
+ once.info = once("info");
208
+ once.warn = once("warn");
209
+ once.error = once("error");
210
+ once.log = once("log");
211
+ deprecate = once("warn");
212
+ pretty = (type) => (...args) => {
213
+ const argArray = [];
214
+ if (args.length) {
215
+ const startTagRe = /<span\s+style=(['"])([^'"]*)\1\s*>/gi;
216
+ const endTagRe = /<\/span>/gi;
217
+ let reResultArray;
218
+ argArray.push(args[0].replace(startTagRe, "%c").replace(endTagRe, "%c"));
219
+ while (reResultArray = startTagRe.exec(args[0])) {
220
+ argArray.push(reResultArray[2]);
221
+ argArray.push("");
222
+ }
223
+ for (let j = 1; j < args.length; j++) argArray.push(args[j]);
224
+ }
225
+ logger[type].apply(logger, argArray);
226
+ };
227
+ pretty.trace = pretty("trace");
228
+ pretty.debug = pretty("debug");
229
+ pretty.info = pretty("info");
230
+ pretty.warn = pretty("warn");
231
+ pretty.error = pretty("error");
232
+ })))();
233
+ }
234
+ //#endregion
235
+ //#region src/core-events/index.ts
236
+ var core_events_exports = /* @__PURE__ */ __exportAll({
237
+ AI_PROMPT_NUDGE: () => AI_PROMPT_NUDGE,
238
+ AI_SETUP_ANALYTICS_REQUEST: () => AI_SETUP_ANALYTICS_REQUEST,
239
+ AI_SETUP_ANALYTICS_RESPONSE: () => AI_SETUP_ANALYTICS_RESPONSE,
240
+ ARGTYPES_INFO_REQUEST: () => ARGTYPES_INFO_REQUEST,
241
+ ARGTYPES_INFO_RESPONSE: () => ARGTYPES_INFO_RESPONSE,
242
+ CHANNEL_CREATED: () => CHANNEL_CREATED,
243
+ CHANNEL_WS_DISCONNECT: () => CHANNEL_WS_DISCONNECT,
244
+ CONFIG_ERROR: () => CONFIG_ERROR,
245
+ CURRENT_STORY_WAS_SET: () => CURRENT_STORY_WAS_SET,
246
+ DOCS_PREPARED: () => DOCS_PREPARED,
247
+ DOCS_RENDERED: () => DOCS_RENDERED,
248
+ FORCE_REMOUNT: () => FORCE_REMOUNT,
249
+ FORCE_RE_RENDER: () => FORCE_RE_RENDER,
250
+ GHOST_STORIES_REQUEST: () => GHOST_STORIES_REQUEST,
251
+ GHOST_STORIES_RESPONSE: () => GHOST_STORIES_RESPONSE,
252
+ GLOBALS_UPDATED: () => GLOBALS_UPDATED,
253
+ MANAGER_INERT_ATTRIBUTE_CHANGED: () => MANAGER_INERT_ATTRIBUTE_CHANGED,
254
+ NAVIGATE_URL: () => NAVIGATE_URL,
255
+ OPEN_IN_EDITOR_REQUEST: () => OPEN_IN_EDITOR_REQUEST,
256
+ OPEN_IN_EDITOR_RESPONSE: () => OPEN_IN_EDITOR_RESPONSE,
257
+ PLAY_FUNCTION_THREW_EXCEPTION: () => PLAY_FUNCTION_THREW_EXCEPTION,
258
+ PRELOAD_ENTRIES: () => PRELOAD_ENTRIES,
259
+ PREVIEW_BUILDER_PROGRESS: () => PREVIEW_BUILDER_PROGRESS,
260
+ PREVIEW_INITIALIZED: () => PREVIEW_INITIALIZED,
261
+ PREVIEW_KEYDOWN: () => PREVIEW_KEYDOWN,
262
+ REGISTER_SUBSCRIPTION: () => REGISTER_SUBSCRIPTION,
263
+ REQUEST_WHATS_NEW_DATA: () => REQUEST_WHATS_NEW_DATA,
264
+ RESET_STORY_ARGS: () => RESET_STORY_ARGS,
265
+ RESULT_WHATS_NEW_DATA: () => RESULT_WHATS_NEW_DATA,
266
+ SAVE_STORY_REQUEST: () => SAVE_STORY_REQUEST,
267
+ SAVE_STORY_RESPONSE: () => SAVE_STORY_RESPONSE,
268
+ SELECT_STORY: () => SELECT_STORY,
269
+ SET_CONFIG: () => SET_CONFIG,
270
+ SET_CURRENT_STORY: () => SET_CURRENT_STORY,
271
+ SET_FILTER: () => SET_FILTER,
272
+ SET_GLOBALS: () => SET_GLOBALS,
273
+ SET_INDEX: () => SET_INDEX,
274
+ SET_STORIES: () => SET_STORIES,
275
+ SET_WHATS_NEW_CACHE: () => SET_WHATS_NEW_CACHE,
276
+ SHARED_STATE_CHANGED: () => SHARED_STATE_CHANGED,
277
+ SHARED_STATE_SET: () => SHARED_STATE_SET,
278
+ SHARE_ISOLATE_MODE: () => SHARE_ISOLATE_MODE,
279
+ SIDEBAR_FILTER_CHANGED: () => SIDEBAR_FILTER_CHANGED,
280
+ STORIES_COLLAPSE_ALL: () => STORIES_COLLAPSE_ALL,
281
+ STORIES_EXPAND_ALL: () => STORIES_EXPAND_ALL,
282
+ STORY_ARGS_UPDATED: () => STORY_ARGS_UPDATED,
283
+ STORY_CHANGED: () => STORY_CHANGED,
284
+ STORY_ERRORED: () => STORY_ERRORED,
285
+ STORY_FINISHED: () => STORY_FINISHED,
286
+ STORY_HOT_UPDATED: () => STORY_HOT_UPDATED,
287
+ STORY_INDEX_INVALIDATED: () => STORY_INDEX_INVALIDATED,
288
+ STORY_MISSING: () => STORY_MISSING,
289
+ STORY_PREPARED: () => STORY_PREPARED,
290
+ STORY_RENDERED: () => STORY_RENDERED,
291
+ STORY_RENDER_PHASE_CHANGED: () => STORY_RENDER_PHASE_CHANGED,
292
+ STORY_SPECIFIED: () => STORY_SPECIFIED,
293
+ STORY_THREW_EXCEPTION: () => STORY_THREW_EXCEPTION,
294
+ STORY_UNCHANGED: () => STORY_UNCHANGED,
295
+ TELEMETRY_ERROR: () => TELEMETRY_ERROR,
296
+ TOGGLE_WHATS_NEW_NOTIFICATIONS: () => TOGGLE_WHATS_NEW_NOTIFICATIONS,
297
+ UNHANDLED_ERRORS_WHILE_PLAYING: () => UNHANDLED_ERRORS_WHILE_PLAYING,
298
+ UPDATE_GLOBALS: () => UPDATE_GLOBALS,
299
+ UPDATE_QUERY_PARAMS: () => UPDATE_QUERY_PARAMS,
300
+ UPDATE_STORY_ARGS: () => UPDATE_STORY_ARGS,
301
+ default: () => events
302
+ });
303
+ var events, CHANNEL_WS_DISCONNECT, CHANNEL_CREATED, CONFIG_ERROR, CURRENT_STORY_WAS_SET, DOCS_PREPARED, DOCS_RENDERED, FORCE_RE_RENDER, FORCE_REMOUNT, GLOBALS_UPDATED, NAVIGATE_URL, PLAY_FUNCTION_THREW_EXCEPTION, UNHANDLED_ERRORS_WHILE_PLAYING, PRELOAD_ENTRIES, PREVIEW_INITIALIZED, PREVIEW_BUILDER_PROGRESS, PREVIEW_KEYDOWN, REGISTER_SUBSCRIPTION, RESET_STORY_ARGS, SELECT_STORY, SET_CONFIG, SET_CURRENT_STORY, SET_FILTER, SET_GLOBALS, SET_INDEX, SET_STORIES, SHARED_STATE_CHANGED, SHARED_STATE_SET, STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL, STORY_ARGS_UPDATED, STORY_CHANGED, STORY_ERRORED, STORY_INDEX_INVALIDATED, STORY_MISSING, STORY_PREPARED, STORY_RENDER_PHASE_CHANGED, STORY_RENDERED, STORY_FINISHED, STORY_SPECIFIED, STORY_THREW_EXCEPTION, STORY_UNCHANGED, STORY_HOT_UPDATED, UPDATE_GLOBALS, UPDATE_QUERY_PARAMS, UPDATE_STORY_ARGS, REQUEST_WHATS_NEW_DATA, RESULT_WHATS_NEW_DATA, SET_WHATS_NEW_CACHE, TOGGLE_WHATS_NEW_NOTIFICATIONS, TELEMETRY_ERROR, SAVE_STORY_REQUEST, SAVE_STORY_RESPONSE, ARGTYPES_INFO_REQUEST, ARGTYPES_INFO_RESPONSE, GHOST_STORIES_REQUEST, GHOST_STORIES_RESPONSE, AI_SETUP_ANALYTICS_RESPONSE, AI_SETUP_ANALYTICS_REQUEST, OPEN_IN_EDITOR_REQUEST, OPEN_IN_EDITOR_RESPONSE, MANAGER_INERT_ATTRIBUTE_CHANGED, SHARE_ISOLATE_MODE, AI_PROMPT_NUDGE, SIDEBAR_FILTER_CHANGED;
304
+ function init_core_events() {
305
+ return (init_core_events = __esmMin((() => {
306
+ events = /* @__PURE__ */ function(events) {
307
+ events["CHANNEL_WS_DISCONNECT"] = "channelWSDisconnect";
308
+ events["CHANNEL_CREATED"] = "channelCreated";
309
+ events["CONFIG_ERROR"] = "configError";
310
+ events["STORY_INDEX_INVALIDATED"] = "storyIndexInvalidated";
311
+ events["STORY_SPECIFIED"] = "storySpecified";
312
+ events["SET_CONFIG"] = "setConfig";
313
+ events["SET_STORIES"] = "setStories";
314
+ events["SET_INDEX"] = "setIndex";
315
+ events["SET_CURRENT_STORY"] = "setCurrentStory";
316
+ events["CURRENT_STORY_WAS_SET"] = "currentStoryWasSet";
317
+ events["FORCE_RE_RENDER"] = "forceReRender";
318
+ events["FORCE_REMOUNT"] = "forceRemount";
319
+ events["PRELOAD_ENTRIES"] = "preloadStories";
320
+ events["STORY_PREPARED"] = "storyPrepared";
321
+ events["DOCS_PREPARED"] = "docsPrepared";
322
+ events["STORY_CHANGED"] = "storyChanged";
323
+ events["STORY_UNCHANGED"] = "storyUnchanged";
324
+ events["STORY_RENDERED"] = "storyRendered";
325
+ events["STORY_FINISHED"] = "storyFinished";
326
+ events["STORY_MISSING"] = "storyMissing";
327
+ events["STORY_ERRORED"] = "storyErrored";
328
+ events["STORY_THREW_EXCEPTION"] = "storyThrewException";
329
+ events["STORY_RENDER_PHASE_CHANGED"] = "storyRenderPhaseChanged";
330
+ events["STORY_HOT_UPDATED"] = "storyHotUpdated";
331
+ events["PLAY_FUNCTION_THREW_EXCEPTION"] = "playFunctionThrewException";
332
+ events["UNHANDLED_ERRORS_WHILE_PLAYING"] = "unhandledErrorsWhilePlaying";
333
+ events["UPDATE_STORY_ARGS"] = "updateStoryArgs";
334
+ events["STORY_ARGS_UPDATED"] = "storyArgsUpdated";
335
+ events["RESET_STORY_ARGS"] = "resetStoryArgs";
336
+ events["SET_FILTER"] = "setFilter";
337
+ events["SET_GLOBALS"] = "setGlobals";
338
+ events["UPDATE_GLOBALS"] = "updateGlobals";
339
+ events["GLOBALS_UPDATED"] = "globalsUpdated";
340
+ events["REGISTER_SUBSCRIPTION"] = "registerSubscription";
341
+ events["PREVIEW_INITIALIZED"] = "previewInitialized";
342
+ events["PREVIEW_KEYDOWN"] = "previewKeydown";
343
+ events["PREVIEW_BUILDER_PROGRESS"] = "preview_builder_progress";
344
+ events["SELECT_STORY"] = "selectStory";
345
+ events["STORIES_COLLAPSE_ALL"] = "storiesCollapseAll";
346
+ events["STORIES_EXPAND_ALL"] = "storiesExpandAll";
347
+ events["DOCS_RENDERED"] = "docsRendered";
348
+ events["SHARED_STATE_CHANGED"] = "sharedStateChanged";
349
+ events["SHARED_STATE_SET"] = "sharedStateSet";
350
+ events["NAVIGATE_URL"] = "navigateUrl";
351
+ events["UPDATE_QUERY_PARAMS"] = "updateQueryParams";
352
+ events["REQUEST_WHATS_NEW_DATA"] = "requestWhatsNewData";
353
+ events["RESULT_WHATS_NEW_DATA"] = "resultWhatsNewData";
354
+ events["SET_WHATS_NEW_CACHE"] = "setWhatsNewCache";
355
+ events["TOGGLE_WHATS_NEW_NOTIFICATIONS"] = "toggleWhatsNewNotifications";
356
+ events["TELEMETRY_ERROR"] = "telemetryError";
357
+ events["SAVE_STORY_REQUEST"] = "saveStoryRequest";
358
+ events["SAVE_STORY_RESPONSE"] = "saveStoryResponse";
359
+ events["ARGTYPES_INFO_REQUEST"] = "argtypesInfoRequest";
360
+ events["ARGTYPES_INFO_RESPONSE"] = "argtypesInfoResponse";
361
+ events["GHOST_STORIES_REQUEST"] = "ghostStoriesRequest";
362
+ events["GHOST_STORIES_RESPONSE"] = "ghostStoriesResponse";
363
+ events["AI_SETUP_ANALYTICS_RESPONSE"] = "aiSetupAnalyticsResponse";
364
+ events["AI_SETUP_ANALYTICS_REQUEST"] = "aiSetupAnalyticsRequest";
365
+ events["OPEN_IN_EDITOR_REQUEST"] = "openInEditorRequest";
366
+ events["OPEN_IN_EDITOR_RESPONSE"] = "openInEditorResponse";
367
+ events["MANAGER_INERT_ATTRIBUTE_CHANGED"] = "managerInertAttributeChanged";
368
+ events["SHARE_ISOLATE_MODE"] = "shareIsolateMode";
369
+ events["AI_PROMPT_NUDGE"] = "aiPromptNudge";
370
+ events["SIDEBAR_FILTER_CHANGED"] = "sidebarFilterChanged";
371
+ return events;
372
+ }(events || {});
373
+ ({CHANNEL_WS_DISCONNECT, CHANNEL_CREATED, CONFIG_ERROR, CURRENT_STORY_WAS_SET, DOCS_PREPARED, DOCS_RENDERED, FORCE_RE_RENDER, FORCE_REMOUNT, GLOBALS_UPDATED, NAVIGATE_URL, PLAY_FUNCTION_THREW_EXCEPTION, UNHANDLED_ERRORS_WHILE_PLAYING, PRELOAD_ENTRIES, PREVIEW_INITIALIZED, PREVIEW_BUILDER_PROGRESS, PREVIEW_KEYDOWN, REGISTER_SUBSCRIPTION, RESET_STORY_ARGS, SELECT_STORY, SET_CONFIG, SET_CURRENT_STORY, SET_FILTER, SET_GLOBALS, SET_INDEX, SET_STORIES, SHARED_STATE_CHANGED, SHARED_STATE_SET, STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL, STORY_ARGS_UPDATED, STORY_CHANGED, STORY_ERRORED, STORY_INDEX_INVALIDATED, STORY_MISSING, STORY_PREPARED, STORY_RENDER_PHASE_CHANGED, STORY_RENDERED, STORY_FINISHED, STORY_SPECIFIED, STORY_THREW_EXCEPTION, STORY_UNCHANGED, STORY_HOT_UPDATED, UPDATE_GLOBALS, UPDATE_QUERY_PARAMS, UPDATE_STORY_ARGS, REQUEST_WHATS_NEW_DATA, RESULT_WHATS_NEW_DATA, SET_WHATS_NEW_CACHE, TOGGLE_WHATS_NEW_NOTIFICATIONS, TELEMETRY_ERROR, SAVE_STORY_REQUEST, SAVE_STORY_RESPONSE, ARGTYPES_INFO_REQUEST, ARGTYPES_INFO_RESPONSE, GHOST_STORIES_REQUEST, GHOST_STORIES_RESPONSE, AI_SETUP_ANALYTICS_RESPONSE, AI_SETUP_ANALYTICS_REQUEST, OPEN_IN_EDITOR_REQUEST, OPEN_IN_EDITOR_RESPONSE, MANAGER_INERT_ATTRIBUTE_CHANGED, SHARE_ISOLATE_MODE, AI_PROMPT_NUDGE, SIDEBAR_FILTER_CHANGED} = events);
374
+ })))();
375
+ }
376
+ //#endregion
377
+ //#region src/channels/postmessage/getEventSourceUrl.ts
378
+ var pickFrameByRefId, getEventSourceUrl;
379
+ function init_getEventSourceUrl() {
380
+ return (init_getEventSourceUrl = __esmMin((() => {
381
+ init_client_logger();
382
+ pickFrameByRefId = (candidates, refId) => {
383
+ if (candidates.length === 1) return candidates[0];
384
+ if (candidates.length === 0 || !refId) return;
385
+ return candidates.find((el) => (el.getAttribute("src") ?? "").includes(`refId=${encodeURIComponent(refId)}`));
386
+ };
387
+ getEventSourceUrl = (event, refId) => {
388
+ const candidates = Array.from(document.querySelectorAll("iframe[data-is-storybook]")).filter((element) => {
389
+ try {
390
+ return element.contentWindow?.location.origin === event.source.location.origin && element.contentWindow?.location.pathname === event.source.location.pathname;
391
+ } catch {}
392
+ try {
393
+ return element.contentWindow === event.source;
394
+ } catch {}
395
+ const src = element.getAttribute("src");
396
+ let origin;
397
+ try {
398
+ if (!src) return false;
399
+ ({origin} = new URL(src, document.location.toString()));
400
+ } catch {
401
+ return false;
402
+ }
403
+ return origin === event.origin;
404
+ });
405
+ const src = pickFrameByRefId(candidates, refId)?.getAttribute("src");
406
+ if (src) {
407
+ const { protocol, host, pathname } = new URL(src, document.location.toString());
408
+ return `${protocol}//${host}${pathname}`;
409
+ }
410
+ if (candidates.length > 1) logger.error("found multiple candidates for event source");
411
+ return null;
412
+ };
413
+ })))();
414
+ }
415
+ //#endregion
416
+ //#region src/channels/postmessage/index.ts
417
+ var document$2, location, KEY, CHANNEL_OPTIONS$1, defaultEventOptions, getReferrerOrigin, isOnInitialBlankDocument, getOriginValidator, PostMessageTransport;
418
+ function init_postmessage() {
419
+ return (init_postmessage = __esmMin((() => {
420
+ init_client_logger();
421
+ init_core_events();
422
+ init_dist();
423
+ init_tiny_invariant();
424
+ init_preview_errors();
425
+ init_local_hosts();
426
+ init_getEventSourceUrl();
427
+ ({document: document$2, location} = globalThis);
428
+ KEY = "storybook-channel";
429
+ CHANNEL_OPTIONS$1 = globalThis.CHANNEL_OPTIONS || {};
430
+ defaultEventOptions = { maxDepth: 25 };
431
+ getReferrerOrigin = () => {
432
+ try {
433
+ const origin = document$2?.referrer && new URL(document$2.referrer).origin;
434
+ return origin && origin !== "null" ? origin : null;
435
+ } catch {
436
+ return null;
437
+ }
438
+ };
439
+ isOnInitialBlankDocument = (frame) => {
440
+ try {
441
+ return frame.location.href === "about:blank";
442
+ } catch {
443
+ return false;
444
+ }
445
+ };
446
+ getOriginValidator = () => {
447
+ const own = location?.origin;
448
+ if (globalThis.CONFIG_TYPE !== "DEVELOPMENT" || !own || own === "null") return null;
449
+ return (origin) => {
450
+ if (origin === own) return true;
451
+ try {
452
+ return matchesHostname(new URL(origin).hostname, LOOPBACK_HOSTNAMES);
453
+ } catch {
454
+ return false;
455
+ }
456
+ };
457
+ };
458
+ PostMessageTransport = class {
459
+ constructor(config) {
460
+ this.config = config;
461
+ this.connected = false;
462
+ this.rejectedOrigins = /* @__PURE__ */ new Set();
463
+ this.buffer = [];
464
+ this.originValidator = getOriginValidator();
465
+ this.insecureIframeMessaging = globalThis.INSECURE_IFRAME_MESSAGING === true;
466
+ this.pinsTargetOrigin = globalThis.CONFIG_TYPE === "DEVELOPMENT" && !this.insecureIframeMessaging;
467
+ if (typeof globalThis.addEventListener === "function") globalThis.addEventListener("message", this.handleEvent.bind(this), false);
468
+ if (config.page !== "manager" && config.page !== "preview") throw new InvalidChannelPageError({ page: config.page });
469
+ }
470
+ setHandler(handler) {
471
+ this.handler = (...args) => {
472
+ handler.apply(this, args);
473
+ if (!this.connected && this.getLocalFrame().length) {
474
+ this.flush();
475
+ this.connected = true;
476
+ }
477
+ };
478
+ }
479
+ /**
480
+ * Sends `event` to the associated window. If the window does not yet exist the event will be
481
+ * stored in a buffer and sent when the window exists.
482
+ *
483
+ * @param event
484
+ */
485
+ send(event, options) {
486
+ const { target, allowRegExp, allowSymbol, allowDate, allowError, allowUndefined, maxDepth, space } = options || {};
487
+ const eventOptions = Object.fromEntries(Object.entries({
488
+ allowRegExp,
489
+ allowSymbol,
490
+ allowDate,
491
+ allowError,
492
+ allowUndefined,
493
+ maxDepth,
494
+ space
495
+ }).filter(([k, v]) => typeof v !== "undefined"));
496
+ const stringifyOptions = {
497
+ ...defaultEventOptions,
498
+ ...CHANNEL_OPTIONS$1,
499
+ ...eventOptions
500
+ };
501
+ const frames = this.getFrames(target);
502
+ const query = new URLSearchParams(location?.search || "");
503
+ const data = stringify({
504
+ key: KEY,
505
+ event,
506
+ refId: query.get("refId")
507
+ }, stringifyOptions);
508
+ if (!frames.length) return new Promise((resolve, reject) => {
509
+ this.buffer.push({
510
+ event,
511
+ resolve,
512
+ reject
513
+ });
514
+ });
515
+ if (this.buffer.length) this.flush();
516
+ frames.forEach(({ contentWindow, targetOrigin }) => {
517
+ if (this.config.page === "manager" && isOnInitialBlankDocument(contentWindow)) return;
518
+ try {
519
+ contentWindow.postMessage(data, this.pinsTargetOrigin ? targetOrigin : "*");
520
+ } catch (e) {
521
+ logger.error("sending over postmessage fail");
522
+ }
523
+ });
524
+ return Promise.resolve(null);
525
+ }
526
+ flush() {
527
+ const { buffer } = this;
528
+ this.buffer = [];
529
+ buffer.forEach((item) => {
530
+ this.send(item.event).then(item.resolve).catch(item.reject);
531
+ });
532
+ }
533
+ getFrames(target) {
534
+ if (this.config.page === "manager") {
535
+ const list = Array.from(document$2.querySelectorAll("iframe[data-is-storybook][data-is-loaded]")).flatMap((e) => {
536
+ try {
537
+ if (!!e.contentWindow && e.dataset.isStorybook !== void 0 && e.id === target) return [{
538
+ contentWindow: e.contentWindow,
539
+ targetOrigin: this.getIframeTargetOrigin(e)
540
+ }];
541
+ return [];
542
+ } catch (er) {
543
+ return [];
544
+ }
545
+ });
546
+ return list?.length ? list : this.getCurrentFrames();
547
+ }
548
+ if (globalThis.parent && globalThis.parent !== globalThis.self) return [{
549
+ contentWindow: globalThis.parent,
550
+ targetOrigin: this.getManagerTargetOrigin()
551
+ }];
552
+ return [];
553
+ }
554
+ getCurrentFrames() {
555
+ if (this.config.page === "manager") return Array.from(document$2.querySelectorAll("[data-is-storybook=\"true\"]")).flatMap((e) => e.contentWindow ? [{
556
+ contentWindow: e.contentWindow,
557
+ targetOrigin: this.getIframeTargetOrigin(e)
558
+ }] : []);
559
+ if (globalThis.parent) return [{
560
+ contentWindow: globalThis.parent,
561
+ targetOrigin: this.getManagerTargetOrigin()
562
+ }];
563
+ return [];
564
+ }
565
+ getIframeTargetOrigin(element) {
566
+ const src = element.getAttribute("src");
567
+ if (src) try {
568
+ const { origin } = new URL(src, document$2.location.toString());
569
+ if (origin !== "null") return origin;
570
+ } catch {}
571
+ return location?.origin && location.origin !== "null" ? location.origin : "*";
572
+ }
573
+ getManagerTargetOrigin() {
574
+ const referrerOrigin = getReferrerOrigin();
575
+ if (this.originValidator) return referrerOrigin !== null && this.originValidator(referrerOrigin) ? referrerOrigin : location.origin;
576
+ return referrerOrigin ?? "*";
577
+ }
578
+ getLocalFrame() {
579
+ if (this.config.page === "manager") return Array.from(document$2.querySelectorAll("#storybook-preview-iframe")).flatMap((e) => e.contentWindow ? [e.contentWindow] : []);
580
+ if (globalThis.parent) return [globalThis.parent];
581
+ return [];
582
+ }
583
+ isAllowedSender(rawEvent) {
584
+ if (this.insecureIframeMessaging) return true;
585
+ if (this.config.page === "manager") return this.isAllowedToContactManager(rawEvent);
586
+ else if (this.config.page === "preview") return this.isAllowedToContactPreview(rawEvent);
587
+ return false;
588
+ }
589
+ isAllowedToContactPreview(rawEvent) {
590
+ if (!this.originValidator) return true;
591
+ if (this.originValidator(rawEvent.origin)) return true;
592
+ this.warnOnceAboutRejectedSender(rawEvent, `Ignored Forkbook channel message from unexpected origin "${rawEvent.origin}". While it runs in dev mode, this preview only accepts messages from local hosts and its own origin. To accept messages from any origin, set "security.insecureIframeMessaging" to true in the main config of the Forkbook serving this preview.`);
593
+ return false;
594
+ }
595
+ isAllowedToContactManager(rawEvent) {
596
+ const senderFrame = rawEvent.source ? Array.from(document$2.querySelectorAll("iframe")).find((frame) => frame.contentWindow === rawEvent.source) : void 0;
597
+ if (senderFrame?.hasAttribute("data-is-storybook")) {
598
+ if (!this.pinsTargetOrigin) return true;
599
+ const expectedOrigin = this.getIframeTargetOrigin(senderFrame);
600
+ if (expectedOrigin === "*" || expectedOrigin === rawEvent.origin) return true;
601
+ this.warnOnceAboutRejectedSender(rawEvent, `Ignored Forkbook channel message from a registered preview iframe that is on origin "${rawEvent.origin}" instead of "${expectedOrigin}". While it runs in dev mode, the manager only accepts channel messages from the origin each preview iframe was given, so a page the iframe navigated to cannot send them. To accept messages from any origin, set "security.insecureIframeMessaging" to true.`);
602
+ return false;
603
+ }
604
+ if (!senderFrame?.hasAttribute("data-is-storybook-thumbnail")) this.warnOnceAboutRejectedSender(rawEvent, `Ignored Forkbook channel message from a window that is not a registered preview iframe (origin "${rawEvent.origin}"). The manager only accepts channel messages from its own preview and composed Forkbook iframes, never from a page that embeds it. To accept messages from any window, set "security.insecureIframeMessaging" to true.`);
605
+ return false;
606
+ }
607
+ warnOnceAboutRejectedSender(rawEvent, message) {
608
+ if ((typeof rawEvent.data === "string" ? rawEvent.data.includes("storybook-channel") : rawEvent.data?.key === "storybook-channel") && !this.rejectedOrigins.has(rawEvent.origin)) {
609
+ this.rejectedOrigins.add(rawEvent.origin);
610
+ logger.warn(message);
611
+ }
612
+ }
613
+ handleEvent(rawEvent) {
614
+ try {
615
+ if (!this.isAllowedSender(rawEvent)) return;
616
+ const { data } = rawEvent;
617
+ const { key, event, refId } = typeof data === "string" && isJSON(data) ? parse(data, CHANNEL_OPTIONS$1) : data;
618
+ if (key === "storybook-channel") {
619
+ const pageString = this.config.page === "manager" ? `<span style="color: #37D5D3; background: black"> manager </span>` : `<span style="color: #1EA7FD; background: black"> preview </span>`;
620
+ const eventString = Object.values(core_events_exports).includes(event.type) ? `<span style="color: #FF4785">${event.type}</span>` : `<span style="color: #FFAE00">${event.type}</span>`;
621
+ if (refId) event.refId = refId;
622
+ event.source = this.config.page === "preview" ? rawEvent.origin : getEventSourceUrl(rawEvent, refId);
623
+ if (!event.source) {
624
+ pretty.error(`${pageString} received ${eventString} but was unable to determine the source of the event`);
625
+ return;
626
+ }
627
+ const message = `${pageString} received ${eventString} (${data.length})`;
628
+ pretty.debug(location.origin !== event.source ? message : `${message} <span style="color: gray">(on ${location.origin} from ${event.source})</span>`, ...event.args);
629
+ invariant(this.handler, "ChannelHandler should be set");
630
+ if (this.config.page === "manager" && this.buffer.length) this.flush();
631
+ this.handler(event);
632
+ }
633
+ } catch (error) {
634
+ logger.error(error);
635
+ }
636
+ }
637
+ };
638
+ })))();
639
+ }
640
+ //#endregion
641
+ //#region src/channels/websocket/index.ts
642
+ var HEARTBEAT_INTERVAL, SERVER_CHANNEL_PATH, CHANNEL_OPTIONS, WebsocketTransport;
643
+ function init_websocket() {
644
+ return (init_websocket = __esmMin((() => {
645
+ init_core_events();
646
+ init_dist();
647
+ init_tiny_invariant();
648
+ HEARTBEAT_INTERVAL = 15e3;
649
+ SERVER_CHANNEL_PATH = "/storybook-server-channel";
650
+ CHANNEL_OPTIONS = globalThis.CHANNEL_OPTIONS || {};
651
+ WebsocketTransport = class {
652
+ constructor({ url, onError, page, createSocket }) {
653
+ this.buffer = [];
654
+ this.isReady = false;
655
+ this.isClosed = false;
656
+ this.socket = createSocket ? createSocket(url) : new WebSocket(url);
657
+ this.socket.onopen = () => {
658
+ this.isReady = true;
659
+ this.flush();
660
+ };
661
+ this.socket.onmessage = ({ data }) => {
662
+ const event = typeof data === "string" && isJSON(data) ? parse(data) : data;
663
+ invariant(this.handler, "WebsocketTransport handler should be set");
664
+ if (event.type === "ping") {
665
+ this.send({ type: "pong" });
666
+ return;
667
+ }
668
+ this.handler(event);
669
+ };
670
+ this.socket.onerror = (e) => {
671
+ if (onError) onError(e);
672
+ };
673
+ this.socket.onclose = (ev) => {
674
+ invariant(this.handler, "WebsocketTransport handler should be set");
675
+ this.handler({
676
+ type: CHANNEL_WS_DISCONNECT,
677
+ args: [{
678
+ reason: ev.reason,
679
+ code: ev.code
680
+ }],
681
+ from: page || "preview"
682
+ });
683
+ this.isClosed = true;
684
+ };
685
+ }
686
+ setHandler(handler) {
687
+ this.handler = handler;
688
+ }
689
+ send(event) {
690
+ if (!this.isClosed) {
691
+ if (!this.isReady) this.sendLater(event);
692
+ else this.sendNow(event);
693
+ }
694
+ }
695
+ sendLater(event) {
696
+ this.buffer.push(event);
697
+ }
698
+ sendNow(event) {
699
+ const data = stringify(event, {
700
+ maxDepth: 15,
701
+ ...CHANNEL_OPTIONS
702
+ });
703
+ this.socket.send(data);
704
+ }
705
+ flush() {
706
+ const { buffer } = this;
707
+ this.buffer = [];
708
+ buffer.forEach((event) => this.send(event));
709
+ }
710
+ };
711
+ })))();
712
+ }
713
+ //#endregion
714
+ //#region src/channels/channel-slot.ts
715
+ function syncGlobalSlot(next) {
716
+ globalThis.__STORYBOOK_ADDONS_CHANNEL__ = next;
717
+ }
718
+ /**
719
+ * Returns the installed addons channel, or `null` before one exists.
720
+ *
721
+ * The global slot wins over the module cache so duplicate copies of this module (e.g. dev-server
722
+ * preset code and `.forkbook` service registration loading different bundles) still observe
723
+ * `setChannel` from whichever copy installed the live websocket channel.
724
+ */
725
+ function getChannel() {
726
+ const fromGlobal = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
727
+ if (fromGlobal) channel = fromGlobal;
728
+ return channel ?? null;
729
+ }
730
+ /**
731
+ * Returns the installed addons channel.
732
+ *
733
+ * Callers assume each runtime has installed a channel at its entry boundary (builder iframe setup,
734
+ * manager boot, server `services` preset, or Node module bootstrap). Prefer this over nullable
735
+ * `getChannel()` when the channel must exist.
736
+ */
737
+ function requireChannel() {
738
+ const installed = getChannel();
739
+ if (!installed) throw new Error("Forkbook addons channel is not installed in this runtime. Install it via setChannel() or addons.setChannel() at the runtime entry point before registering services or emitting events.");
740
+ return installed;
741
+ }
742
+ /** Installs (or replaces) the shared addons channel. Pass `null` to clear. */
743
+ function setChannel(next) {
744
+ channel = next ?? void 0;
745
+ syncGlobalSlot(channel);
746
+ }
747
+ /** Clears the shared channel slot. Alias for `setChannel(null)`. */
748
+ function clearChannel() {
749
+ setChannel(null);
750
+ }
751
+ /** Installs a noop in-process channel — used by server presets and unit tests. */
752
+ function installNoopChannel() {
753
+ setChannel(new Channel({}));
754
+ }
755
+ /**
756
+ * Installs a noop channel when none is present yet.
757
+ *
758
+ * Prefer explicit `setChannel` / `installNoopChannel` at runtime entry points. This helper remains for
759
+ * tests and tooling that need an in-process channel without a mock transport.
760
+ */
761
+ function ensureChannel() {
762
+ if (!getChannel()) installNoopChannel();
763
+ }
764
+ var channel;
765
+ function init_channel_slot() {
766
+ return (init_channel_slot = __esmMin((() => {
767
+ init_main();
768
+ if (typeof window === "undefined") ensureChannel();
769
+ })))();
770
+ }
771
+ //#endregion
772
+ //#region src/channels/index.ts
773
+ var channels_exports = /* @__PURE__ */ __exportAll({
774
+ Channel: () => Channel,
775
+ HEARTBEAT_INTERVAL: () => HEARTBEAT_INTERVAL,
776
+ PostMessageTransport: () => PostMessageTransport,
777
+ SERVER_CHANNEL_PATH: () => SERVER_CHANNEL_PATH,
778
+ WebsocketTransport: () => WebsocketTransport,
779
+ clearChannel: () => clearChannel,
780
+ createBrowserChannel: () => createBrowserChannel,
781
+ default: () => channels_default,
782
+ ensureChannel: () => ensureChannel,
783
+ getChannel: () => getChannel,
784
+ installNoopChannel: () => installNoopChannel,
785
+ requireChannel: () => requireChannel,
786
+ setChannel: () => setChannel
787
+ });
788
+ /**
789
+ * Creates a new browser channel instance.
790
+ *
791
+ * @param {Options} options - The options object.
792
+ * @param {Page} options.page - Page identifier.
793
+ * @param {ChannelTransport[]} [options.extraTransports=[]] - An optional array of extra channel
794
+ * transports. Default is `[]`
795
+ * @returns {Channel} - The new channel instance.
796
+ */
797
+ function createBrowserChannel({ page, extraTransports = [] }) {
798
+ const transports = [new PostMessageTransport({ page }), ...extraTransports];
799
+ if (globalThis.CONFIG_TYPE === "DEVELOPMENT") {
800
+ const protocol = window.location.protocol === "http:" ? "ws" : "wss";
801
+ const { hostname, port } = window.location;
802
+ const { wsToken } = globalThis.CHANNEL_OPTIONS || {};
803
+ const channelUrl = `${protocol}://${hostname}:${port}${SERVER_CHANNEL_PATH}?token=${wsToken}&page=${page}`;
804
+ transports.push(new WebsocketTransport({
805
+ url: channelUrl,
806
+ onError: () => {},
807
+ page
808
+ }));
809
+ }
810
+ const channel = new Channel({ transports });
811
+ UniversalStore.__prepare(channel, page === "manager" ? UniversalStore.Environment.MANAGER : UniversalStore.Environment.PREVIEW);
812
+ return channel;
813
+ }
814
+ var channels_default;
815
+ function init_channels() {
816
+ return (init_channels = __esmMin((() => {
817
+ init_universal_store();
818
+ init_main();
819
+ init_postmessage();
820
+ init_websocket();
821
+ init_channel_slot();
822
+ channels_default = Channel;
823
+ })))();
824
+ }
825
+ //#endregion
826
+ //#region src/actions/constants.ts
827
+ var PARAM_KEY$3, ADDON_ID$2, PANEL_ID, EVENT_ID, CLEAR_ID, CYCLIC_KEY;
828
+ function init_constants() {
829
+ return (init_constants = __esmMin((() => {
830
+ PARAM_KEY$3 = "actions";
831
+ ADDON_ID$2 = "@aussieljk/forkbook/actions";
832
+ PANEL_ID = `${ADDON_ID$2}/panel`;
833
+ EVENT_ID = `${ADDON_ID$2}/action-event`;
834
+ CLEAR_ID = `${ADDON_ID$2}/action-clear`;
835
+ CYCLIC_KEY = "$___storybook.isCyclic";
836
+ })))();
837
+ }
838
+ //#endregion
839
+ //#region src/channels/mock-channel.ts
840
+ /** In-process channel with no transport — the default for unit tests and manager story mocks. */
841
+ function mockChannel() {
842
+ return new Channel({ transport: {
843
+ setHandler: () => {},
844
+ send: () => {}
845
+ } });
846
+ }
847
+ function init_mock_channel() {
848
+ return (init_mock_channel = __esmMin((() => {
849
+ init_main();
850
+ })))();
851
+ }
852
+ //#endregion
853
+ //#region src/csf/toStartCaseStr.ts
854
+ function toStartCaseStr(str) {
855
+ return str.replace(/_/g, " ").replace(/-/g, " ").replace(/\./g, " ").replace(/([^\n])([A-Z])([a-z])/g, (str2, $1, $2, $3) => `${$1} ${$2}${$3}`).replace(/([a-z])([A-Z])/g, (str2, $1, $2) => `${$1} ${$2}`).replace(/([a-z])([0-9])/gi, (str2, $1, $2) => `${$1} ${$2}`).replace(/([0-9])([a-z])/gi, (str2, $1, $2) => `${$1} ${$2}`).replace(/(\s|^)(\w)/g, (str2, $1, $2) => `${$1}${$2.toUpperCase()}`).replace(/ +/g, " ").trim();
856
+ }
857
+ //#endregion
858
+ //#region src/csf/export-story.ts
859
+ function matches(storyKey, arrayOrRegex) {
860
+ if (Array.isArray(arrayOrRegex)) return arrayOrRegex.includes(storyKey);
861
+ return storyKey.match(arrayOrRegex);
862
+ }
863
+ /** Does a named export match CSF inclusion/exclusion options? */
864
+ function isExportStory(key, { includeStories, excludeStories }) {
865
+ return key !== "__esModule" && (!includeStories || matches(key, includeStories)) && (!excludeStories || !matches(key, excludeStories));
866
+ }
867
+ var storyNameFromExport;
868
+ function init_export_story() {
869
+ return (init_export_story = __esmMin((() => {
870
+ storyNameFromExport = (key) => toStartCaseStr(key);
871
+ })))();
872
+ }
873
+ //#endregion
874
+ //#region src/csf/csf-utils.ts
875
+ var sanitize, sanitizeSafe, toId, toTestId, combineTags;
876
+ function init_csf_utils() {
877
+ return (init_csf_utils = __esmMin((() => {
878
+ sanitize = (string) => {
879
+ return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
880
+ };
881
+ sanitizeSafe = (string, part) => {
882
+ const sanitized = sanitize(string);
883
+ if (sanitized === "") throw new Error(`Invalid ${part} '${string}', must include alphanumeric characters`);
884
+ return sanitized;
885
+ };
886
+ toId = (kind, name) => `${sanitizeSafe(kind, "kind")}${name ? `--${sanitizeSafe(name, "name")}` : ""}`;
887
+ toTestId = (parentId, testName) => `${parentId}:${sanitizeSafe(testName, "test")}`;
888
+ combineTags = (...tags) => {
889
+ const result = tags.reduce((acc, tag) => {
890
+ if (tag.startsWith("!")) acc.delete(tag.slice(1));
891
+ else acc.add(tag);
892
+ return acc;
893
+ }, /* @__PURE__ */ new Set());
894
+ return Array.from(result);
895
+ };
896
+ })))();
897
+ }
898
+ //#endregion
899
+ //#region src/csf/includeConditionalArg.ts
900
+ var import_tiny_isequal, count, testValue, includeConditionalArg;
901
+ function init_includeConditionalArg() {
902
+ return (init_includeConditionalArg = __esmMin((() => {
903
+ import_tiny_isequal = require_tiny_isequal();
904
+ count = (vals) => vals.map((v) => typeof v !== "undefined").filter(Boolean).length;
905
+ testValue = (cond, value) => {
906
+ const { exists, eq, neq, truthy } = cond;
907
+ if (count([
908
+ exists,
909
+ eq,
910
+ neq,
911
+ truthy
912
+ ]) > 1) throw new Error(`Invalid conditional test ${JSON.stringify({
913
+ exists,
914
+ eq,
915
+ neq
916
+ })}`);
917
+ if (typeof eq !== "undefined") return (0, import_tiny_isequal.isEqual)(value, eq);
918
+ if (typeof neq !== "undefined") return !(0, import_tiny_isequal.isEqual)(value, neq);
919
+ if (typeof exists !== "undefined") {
920
+ const valueExists = typeof value !== "undefined";
921
+ return exists ? valueExists : !valueExists;
922
+ }
923
+ return (typeof truthy === "undefined" ? true : truthy) ? !!value : !value;
924
+ };
925
+ includeConditionalArg = (argType, args, globals) => {
926
+ if (!argType.if) return true;
927
+ const { arg, global } = argType.if;
928
+ if (count([arg, global]) !== 1) throw new Error(`Invalid conditional value ${JSON.stringify({
929
+ arg,
930
+ global
931
+ })}`);
932
+ const value = arg ? args[arg] : globals[global];
933
+ return testValue(argType.if, value);
934
+ };
935
+ })))();
936
+ }
937
+ //#endregion
938
+ //#region src/actions/addArgsHelpers.ts
939
+ var isInInitialArgs, inferActionsFromArgTypesRegex, addActionsFromArgTypes;
940
+ function init_addArgsHelpers() {
941
+ return (init_addArgsHelpers = __esmMin((() => {
942
+ init_action();
943
+ isInInitialArgs = (name, initialArgs) => typeof initialArgs[name] === "undefined" && !(name in initialArgs);
944
+ inferActionsFromArgTypesRegex = (context) => {
945
+ const { initialArgs, argTypes, id, parameters: { actions } } = context;
946
+ if (!actions || actions.disable || !actions.argTypesRegex || !argTypes) return {};
947
+ const argTypesRegex = new RegExp(actions.argTypesRegex);
948
+ return Object.entries(argTypes).filter(([name]) => !!argTypesRegex.test(name)).reduce((acc, [name, argType]) => {
949
+ if (isInInitialArgs(name, initialArgs)) acc[name] = action(name, {
950
+ implicit: true,
951
+ id
952
+ });
953
+ return acc;
954
+ }, {});
955
+ };
956
+ addActionsFromArgTypes = (context) => {
957
+ const { initialArgs, argTypes, parameters: { actions } } = context;
958
+ if (actions?.disable || !argTypes) return {};
959
+ return Object.entries(argTypes).filter(([name, argType]) => !!argType.action).reduce((acc, [name, argType]) => {
960
+ if (isInInitialArgs(name, initialArgs)) acc[name] = action(typeof argType.action === "string" ? argType.action : name);
961
+ return acc;
962
+ }, {});
963
+ };
964
+ })))();
965
+ }
966
+ //#endregion
967
+ //#region src/actions/addArgs.ts
968
+ var addArgs_exports = /* @__PURE__ */ __exportAll({ argsEnhancers: () => argsEnhancers });
969
+ var argsEnhancers;
970
+ function init_addArgs() {
971
+ return (init_addArgs = __esmMin((() => {
972
+ init_addArgsHelpers();
973
+ argsEnhancers = [addActionsFromArgTypes, inferActionsFromArgTypesRegex];
974
+ })))();
975
+ }
976
+ //#endregion
977
+ //#region src/instrumenter/EVENTS.ts
978
+ var EVENTS;
979
+ function init_EVENTS() {
980
+ return (init_EVENTS = __esmMin((() => {
981
+ EVENTS = {
982
+ CALL: "@aussieljk/forkbook/instrumenter/call",
983
+ SYNC: "@aussieljk/forkbook/instrumenter/sync",
984
+ START: "@aussieljk/forkbook/instrumenter/start",
985
+ BACK: "@aussieljk/forkbook/instrumenter/back",
986
+ GOTO: "@aussieljk/forkbook/instrumenter/goto",
987
+ NEXT: "@aussieljk/forkbook/instrumenter/next",
988
+ END: "@aussieljk/forkbook/instrumenter/end"
989
+ };
990
+ })))();
991
+ }
992
+ //#endregion
993
+ //#region src/instrumenter/preview-api.ts
994
+ var addons;
995
+ function init_preview_api() {
996
+ return (init_preview_api = __esmMin((() => {
997
+ addons = globalThis.__STORYBOOK_ADDONS_PREVIEW;
998
+ })))();
999
+ }
1000
+ //#endregion
1001
+ //#region src/instrumenter/instrumenter.ts
1002
+ /**
1003
+ * Instruments an object or module by traversing its properties, patching any functions (methods) to
1004
+ * enable debugging. Patched functions will emit a `call` event when invoked. When intercept = true,
1005
+ * patched functions will return a Promise when the debugger stops before this function. As such,
1006
+ * "interceptable" functions will have to be `await`-ed.
1007
+ */
1008
+ function instrument(obj, options = {}) {
1009
+ try {
1010
+ let forceInstrument = false;
1011
+ let skipInstrument = false;
1012
+ if (scope.window?.location?.search?.includes("instrument=true")) forceInstrument = true;
1013
+ else if (scope.window?.location?.search?.includes("instrument=false")) skipInstrument = true;
1014
+ if (scope.window?.parent === scope.window && !forceInstrument || skipInstrument) return obj;
1015
+ if (scope.window && !scope.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__) scope.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__ = new Instrumenter();
1016
+ return (scope.window?.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__).instrument(obj, options);
1017
+ } catch (e) {
1018
+ once.warn(e);
1019
+ return obj;
1020
+ }
1021
+ }
1022
+ function getPropertyDescriptor(obj, propName) {
1023
+ let target = obj;
1024
+ while (target != null) {
1025
+ const descriptor = Object.getOwnPropertyDescriptor(target, propName);
1026
+ if (descriptor) return descriptor;
1027
+ target = Object.getPrototypeOf(target);
1028
+ }
1029
+ }
1030
+ function isClass(obj) {
1031
+ if (typeof obj !== "function") return false;
1032
+ const descriptor = Object.getOwnPropertyDescriptor(obj, "prototype");
1033
+ if (!descriptor) return false;
1034
+ return !descriptor.writable;
1035
+ }
1036
+ var alreadyCompletedException, isObject, isModule, isInstrumentable, construct, getInitialState, getRetainedState, Instrumenter;
1037
+ function init_instrumenter() {
1038
+ return (init_instrumenter = __esmMin((() => {
1039
+ init_client_logger();
1040
+ init_core_events();
1041
+ init_dist$1();
1042
+ init_error();
1043
+ init_EVENTS();
1044
+ init_preview_api();
1045
+ alreadyCompletedException = /* @__PURE__ */ new Error(`This function ran after the play function completed. Did you forget to \`await\` it?`);
1046
+ isObject = (o) => Object.prototype.toString.call(o) === "[object Object]";
1047
+ isModule = (o) => Object.prototype.toString.call(o) === "[object Module]";
1048
+ isInstrumentable = (o) => {
1049
+ if (!isObject(o) && !isModule(o)) return false;
1050
+ if (o.constructor === void 0) return true;
1051
+ const proto = o.constructor.prototype;
1052
+ if (!isObject(proto)) return false;
1053
+ return true;
1054
+ };
1055
+ construct = (obj) => {
1056
+ try {
1057
+ return new obj.constructor();
1058
+ } catch {
1059
+ return {};
1060
+ }
1061
+ };
1062
+ getInitialState = () => ({
1063
+ renderPhase: "preparing",
1064
+ isDebugging: false,
1065
+ isPlaying: false,
1066
+ isLocked: false,
1067
+ cursor: 0,
1068
+ calls: [],
1069
+ shadowCalls: [],
1070
+ callRefsByResult: /* @__PURE__ */ new Map(),
1071
+ chainedCallIds: /* @__PURE__ */ new Set(),
1072
+ ancestors: [],
1073
+ playUntil: void 0,
1074
+ resolvers: {},
1075
+ syncTimeout: void 0
1076
+ });
1077
+ getRetainedState = (state, isDebugging = false) => {
1078
+ const calls = (isDebugging ? state.shadowCalls : state.calls).filter((call) => call.retain);
1079
+ if (!calls.length) return;
1080
+ const callRefsByResult = new Map(Array.from(state.callRefsByResult.entries()).filter(([, ref]) => ref.retain));
1081
+ return {
1082
+ cursor: calls.length,
1083
+ calls,
1084
+ callRefsByResult
1085
+ };
1086
+ };
1087
+ Instrumenter = class {
1088
+ constructor() {
1089
+ this.detached = false;
1090
+ this.initialized = false;
1091
+ this.state = {};
1092
+ this.loadParentWindowState = () => {
1093
+ try {
1094
+ this.state = scope.window?.parent?.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ || {};
1095
+ } catch {
1096
+ this.detached = true;
1097
+ }
1098
+ };
1099
+ this.updateParentWindowState = () => {
1100
+ try {
1101
+ scope.window.parent.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ = this.state;
1102
+ } catch {
1103
+ this.detached = true;
1104
+ }
1105
+ };
1106
+ this.loadParentWindowState();
1107
+ const resetState = ({ storyId, renderPhase, isPlaying = true, isDebugging = false }) => {
1108
+ const state = this.getState(storyId);
1109
+ this.setState(storyId, {
1110
+ ...getInitialState(),
1111
+ ...getRetainedState(state, isDebugging),
1112
+ renderPhase: renderPhase || state.renderPhase,
1113
+ shadowCalls: isDebugging ? state.shadowCalls : [],
1114
+ chainedCallIds: isDebugging ? state.chainedCallIds : /* @__PURE__ */ new Set(),
1115
+ playUntil: isDebugging ? state.playUntil : void 0,
1116
+ isPlaying,
1117
+ isDebugging
1118
+ });
1119
+ this.sync(storyId);
1120
+ };
1121
+ const start = (channel) => ({ storyId, playUntil }) => {
1122
+ if (!this.getState(storyId).isDebugging) this.setState(storyId, ({ calls }) => ({
1123
+ calls: [],
1124
+ shadowCalls: calls.map((call) => ({
1125
+ ...call,
1126
+ status: "waiting"
1127
+ })),
1128
+ isDebugging: true
1129
+ }));
1130
+ const log = this.getLog(storyId);
1131
+ this.setState(storyId, ({ shadowCalls }) => {
1132
+ if (playUntil || !log.length) return { playUntil };
1133
+ const firstRowIndex = shadowCalls.findIndex((call) => call.id === log[0].callId);
1134
+ return { playUntil: shadowCalls.slice(0, firstRowIndex).filter((call) => call.interceptable && !call.ancestors?.length).slice(-1)[0]?.id };
1135
+ });
1136
+ channel.emit(FORCE_REMOUNT, {
1137
+ storyId,
1138
+ isDebugging: true
1139
+ });
1140
+ };
1141
+ const back = (channel) => ({ storyId }) => {
1142
+ const log = this.getLog(storyId).filter((call) => !call.ancestors?.length);
1143
+ const last = log.reduceRight((res, item, index) => {
1144
+ if (res >= 0 || item.status === "waiting") return res;
1145
+ return index;
1146
+ }, -1);
1147
+ start(channel)({
1148
+ storyId,
1149
+ playUntil: log[last - 1]?.callId
1150
+ });
1151
+ };
1152
+ const goto = (channel) => ({ storyId, callId }) => {
1153
+ const { calls, shadowCalls, resolvers } = this.getState(storyId);
1154
+ const call = calls.find(({ id }) => id === callId);
1155
+ const shadowCall = shadowCalls.find(({ id }) => id === callId);
1156
+ if (!call && shadowCall && Object.values(resolvers).length > 0) {
1157
+ const nextId = this.getLog(storyId).find((c) => c.status === "waiting")?.callId;
1158
+ if (shadowCall.id !== nextId) this.setState(storyId, { playUntil: shadowCall.id });
1159
+ Object.values(resolvers).forEach((resolve) => resolve());
1160
+ } else start(channel)({
1161
+ storyId,
1162
+ playUntil: callId
1163
+ });
1164
+ };
1165
+ const next = (channel) => ({ storyId }) => {
1166
+ const { resolvers } = this.getState(storyId);
1167
+ if (Object.values(resolvers).length > 0) Object.values(resolvers).forEach((resolve) => resolve());
1168
+ else {
1169
+ const nextId = this.getLog(storyId).find((c) => c.status === "waiting")?.callId;
1170
+ if (nextId) start(channel)({
1171
+ storyId,
1172
+ playUntil: nextId
1173
+ });
1174
+ else end({ storyId });
1175
+ }
1176
+ };
1177
+ const end = ({ storyId }) => {
1178
+ this.setState(storyId, {
1179
+ playUntil: void 0,
1180
+ isDebugging: false
1181
+ });
1182
+ Object.values(this.getState(storyId).resolvers).forEach((resolve) => resolve());
1183
+ };
1184
+ const renderPhaseChanged = ({ storyId, newPhase }) => {
1185
+ const { isDebugging } = this.getState(storyId);
1186
+ if (newPhase === "preparing" && isDebugging) return resetState({
1187
+ storyId,
1188
+ renderPhase: newPhase,
1189
+ isDebugging
1190
+ });
1191
+ else if (newPhase === "playing") return resetState({
1192
+ storyId,
1193
+ renderPhase: newPhase,
1194
+ isDebugging
1195
+ });
1196
+ if (newPhase === "played") this.setState(storyId, {
1197
+ renderPhase: newPhase,
1198
+ isLocked: false,
1199
+ isPlaying: false,
1200
+ isDebugging: false
1201
+ });
1202
+ else if (newPhase === "errored") this.setState(storyId, {
1203
+ renderPhase: newPhase,
1204
+ isLocked: false,
1205
+ isPlaying: false
1206
+ });
1207
+ else if (newPhase === "aborted") this.setState(storyId, {
1208
+ renderPhase: newPhase,
1209
+ isLocked: true,
1210
+ isPlaying: false
1211
+ });
1212
+ else this.setState(storyId, { renderPhase: newPhase });
1213
+ this.sync(storyId);
1214
+ };
1215
+ if (addons) addons.ready().then(() => {
1216
+ this.channel = addons.getChannel();
1217
+ this.channel.on(FORCE_REMOUNT, resetState);
1218
+ this.channel.on(STORY_RENDER_PHASE_CHANGED, renderPhaseChanged);
1219
+ this.channel.on(SET_CURRENT_STORY, () => {
1220
+ if (this.initialized) this.cleanup();
1221
+ else this.initialized = true;
1222
+ });
1223
+ this.channel.on(EVENTS.START, start(this.channel));
1224
+ this.channel.on(EVENTS.BACK, back(this.channel));
1225
+ this.channel.on(EVENTS.GOTO, goto(this.channel));
1226
+ this.channel.on(EVENTS.NEXT, next(this.channel));
1227
+ this.channel.on(EVENTS.END, end);
1228
+ });
1229
+ }
1230
+ getState(storyId) {
1231
+ return this.state[storyId] || getInitialState();
1232
+ }
1233
+ setState(storyId, update) {
1234
+ if (storyId) {
1235
+ const state = this.getState(storyId);
1236
+ const patch = typeof update === "function" ? update(state) : update;
1237
+ this.state = {
1238
+ ...this.state,
1239
+ [storyId]: {
1240
+ ...state,
1241
+ ...patch
1242
+ }
1243
+ };
1244
+ this.updateParentWindowState();
1245
+ }
1246
+ }
1247
+ cleanup() {
1248
+ this.state = Object.entries(this.state).reduce((acc, [storyId, state]) => {
1249
+ const retainedState = getRetainedState(state);
1250
+ if (!retainedState) return acc;
1251
+ acc[storyId] = Object.assign(getInitialState(), retainedState);
1252
+ return acc;
1253
+ }, {});
1254
+ const payload = {
1255
+ controlStates: {
1256
+ detached: this.detached,
1257
+ start: false,
1258
+ back: false,
1259
+ goto: false,
1260
+ next: false,
1261
+ end: false
1262
+ },
1263
+ logItems: []
1264
+ };
1265
+ this.channel?.emit(EVENTS.SYNC, payload);
1266
+ this.updateParentWindowState();
1267
+ }
1268
+ getLog(storyId) {
1269
+ const { calls, shadowCalls } = this.getState(storyId);
1270
+ const merged = [...shadowCalls];
1271
+ calls.forEach((call, index) => {
1272
+ merged[index] = call;
1273
+ });
1274
+ const seen = /* @__PURE__ */ new Set();
1275
+ return merged.reduceRight((acc, call) => {
1276
+ call.args.forEach((arg) => {
1277
+ if (arg?.__callId__) seen.add(arg.__callId__);
1278
+ });
1279
+ call.path.forEach((node) => {
1280
+ if (node.__callId__) seen.add(node.__callId__);
1281
+ });
1282
+ if ((call.interceptable || call.exception) && !seen.has(call.id)) {
1283
+ acc.unshift({
1284
+ callId: call.id,
1285
+ status: call.status,
1286
+ ancestors: call.ancestors
1287
+ });
1288
+ seen.add(call.id);
1289
+ }
1290
+ return acc;
1291
+ }, []);
1292
+ }
1293
+ instrument(obj, options, depth = 0) {
1294
+ if (!isInstrumentable(obj)) return obj;
1295
+ const { mutate = false, path = [] } = options;
1296
+ const keys = options.getKeys ? options.getKeys(obj, depth) : Object.keys(obj);
1297
+ depth += 1;
1298
+ return keys.reduce((acc, key) => {
1299
+ const descriptor = getPropertyDescriptor(obj, key);
1300
+ if (typeof descriptor?.get === "function") {
1301
+ if (descriptor.configurable) {
1302
+ const getter = () => descriptor?.get?.bind(obj)?.();
1303
+ Object.defineProperty(acc, key, { get: () => {
1304
+ return this.instrument(getter(), {
1305
+ ...options,
1306
+ path: path.concat(key)
1307
+ }, depth);
1308
+ } });
1309
+ }
1310
+ return acc;
1311
+ }
1312
+ const value = obj[key];
1313
+ if (typeof value !== "function") {
1314
+ acc[key] = this.instrument(value, {
1315
+ ...options,
1316
+ path: path.concat(key)
1317
+ }, depth);
1318
+ return acc;
1319
+ }
1320
+ if ("__originalFn__" in value && typeof value.__originalFn__ === "function") {
1321
+ acc[key] = value;
1322
+ return acc;
1323
+ }
1324
+ acc[key] = (...args) => this.track(key, value, obj, args, options);
1325
+ acc[key].__originalFn__ = value;
1326
+ Object.defineProperty(acc[key], "name", {
1327
+ value: key,
1328
+ writable: false
1329
+ });
1330
+ if (Object.keys(value).length > 0) Object.assign(acc[key], this.instrument({ ...value }, {
1331
+ ...options,
1332
+ path: path.concat(key)
1333
+ }, depth));
1334
+ return acc;
1335
+ }, mutate ? obj : construct(obj));
1336
+ }
1337
+ track(method, fn, object, args, options) {
1338
+ const storyId = args?.[0]?.__storyId__ || scope.__STORYBOOK_PREVIEW__?.selectionStore?.selection?.storyId;
1339
+ const { cursor, ancestors } = this.getState(storyId);
1340
+ this.setState(storyId, { cursor: cursor + 1 });
1341
+ const id = `${ancestors.slice(-1)[0] || storyId} [${cursor}] ${method}`;
1342
+ const { path = [], intercept = false, retain = false } = options;
1343
+ const interceptable = typeof intercept === "function" ? intercept(method, path) : intercept;
1344
+ const call = {
1345
+ id,
1346
+ cursor,
1347
+ storyId,
1348
+ ancestors,
1349
+ path,
1350
+ method,
1351
+ args,
1352
+ interceptable,
1353
+ retain
1354
+ };
1355
+ const result = (interceptable && !ancestors.length ? this.intercept : this.invoke).call(this, fn, object, call, options);
1356
+ return this.instrument(result, {
1357
+ ...options,
1358
+ mutate: true,
1359
+ path: [{ __callId__: call.id }]
1360
+ });
1361
+ }
1362
+ intercept(fn, object, call, options) {
1363
+ const { chainedCallIds, isDebugging, playUntil } = this.getState(call.storyId);
1364
+ const isChainedUpon = chainedCallIds.has(call.id);
1365
+ if (!isDebugging || isChainedUpon || playUntil) {
1366
+ if (playUntil === call.id) this.setState(call.storyId, { playUntil: void 0 });
1367
+ return this.invoke(fn, object, call, options);
1368
+ }
1369
+ return new Promise((resolve) => {
1370
+ this.setState(call.storyId, ({ resolvers }) => ({
1371
+ isLocked: false,
1372
+ resolvers: {
1373
+ ...resolvers,
1374
+ [call.id]: resolve
1375
+ }
1376
+ }));
1377
+ }).then(() => {
1378
+ this.setState(call.storyId, (state) => {
1379
+ const { [call.id]: _, ...resolvers } = state.resolvers;
1380
+ return {
1381
+ isLocked: true,
1382
+ resolvers
1383
+ };
1384
+ });
1385
+ return this.invoke(fn, object, call, options);
1386
+ });
1387
+ }
1388
+ invoke(fn, object, call, options) {
1389
+ const { callRefsByResult, renderPhase } = this.getState(call.storyId);
1390
+ const maximumDepth = 25;
1391
+ const serializeValues = (value, depth, seen) => {
1392
+ if (seen.includes(value)) return "[Circular]";
1393
+ seen = [...seen, value];
1394
+ if (depth > maximumDepth) return "...";
1395
+ if (callRefsByResult.has(value)) return callRefsByResult.get(value);
1396
+ if (value instanceof Array) return value.map((it) => serializeValues(it, ++depth, seen));
1397
+ if (value instanceof Date) return { __date__: { value: value.toISOString() } };
1398
+ if (value instanceof Error) {
1399
+ const { name, message, stack } = value;
1400
+ return { __error__: {
1401
+ name,
1402
+ message,
1403
+ stack
1404
+ } };
1405
+ }
1406
+ if (value instanceof RegExp) {
1407
+ const { flags, source } = value;
1408
+ return { __regexp__: {
1409
+ flags,
1410
+ source
1411
+ } };
1412
+ }
1413
+ if (value instanceof scope.window?.HTMLElement) {
1414
+ const { prefix, localName, id, classList, innerText } = value;
1415
+ return { __element__: {
1416
+ prefix,
1417
+ localName,
1418
+ id,
1419
+ classNames: Array.from(classList),
1420
+ innerText
1421
+ } };
1422
+ }
1423
+ if (typeof value === "function") return { __function__: { name: "getMockName" in value ? value.getMockName() : value.name } };
1424
+ if (typeof value === "symbol") return { __symbol__: { description: value.description } };
1425
+ if (typeof value === "object" && value?.constructor?.name && value?.constructor?.name !== "Object") return { __class__: { name: value.constructor.name } };
1426
+ if (Object.prototype.toString.call(value) === "[object Object]") return Object.fromEntries(Object.entries(value).map(([key, val]) => [key, serializeValues(val, ++depth, seen)]));
1427
+ return value;
1428
+ };
1429
+ const info = {
1430
+ ...call,
1431
+ args: call.args.map((arg) => serializeValues(arg, 0, []))
1432
+ };
1433
+ call.path.forEach((ref) => {
1434
+ if (ref?.__callId__) this.setState(call.storyId, ({ chainedCallIds }) => ({ chainedCallIds: new Set(Array.from(chainedCallIds).concat(ref.__callId__)) }));
1435
+ });
1436
+ const handleException = (e) => {
1437
+ if (e instanceof Error) {
1438
+ const { name, message, stack, callId = call.id } = e;
1439
+ const { showDiff = void 0, diff = void 0, actual = void 0, expected = void 0 } = e.name === "AssertionError" ? processError(e) : e;
1440
+ const exception = {
1441
+ name,
1442
+ message,
1443
+ stack,
1444
+ callId,
1445
+ showDiff,
1446
+ diff,
1447
+ actual,
1448
+ expected
1449
+ };
1450
+ this.update({
1451
+ ...info,
1452
+ status: "error",
1453
+ exception
1454
+ });
1455
+ this.setState(call.storyId, (state) => ({ callRefsByResult: new Map([...Array.from(state.callRefsByResult.entries()), [e, {
1456
+ __callId__: call.id,
1457
+ retain: call.retain
1458
+ }]]) }));
1459
+ if (call.ancestors?.length) {
1460
+ if (!Object.prototype.hasOwnProperty.call(e, "callId")) Object.defineProperty(e, "callId", { value: call.id });
1461
+ throw e;
1462
+ }
1463
+ }
1464
+ throw e;
1465
+ };
1466
+ try {
1467
+ if (renderPhase === "played" && !call.retain) throw alreadyCompletedException;
1468
+ const finalArgs = (options.getArgs ? options.getArgs(call, this.getState(call.storyId)) : call.args).map((arg) => {
1469
+ if (typeof arg !== "function" || isClass(arg) || Object.keys(arg).length) return arg;
1470
+ return (...args) => {
1471
+ const { cursor, ancestors } = this.getState(call.storyId);
1472
+ this.setState(call.storyId, {
1473
+ cursor: 0,
1474
+ ancestors: [...ancestors, call.id]
1475
+ });
1476
+ const restore = () => this.setState(call.storyId, {
1477
+ cursor,
1478
+ ancestors
1479
+ });
1480
+ let willRestore = false;
1481
+ try {
1482
+ const res = arg(...args);
1483
+ if (res instanceof Promise) {
1484
+ willRestore = true;
1485
+ return res.finally(restore);
1486
+ }
1487
+ return res;
1488
+ } finally {
1489
+ if (!willRestore) restore();
1490
+ }
1491
+ };
1492
+ });
1493
+ const result = fn.apply(object, finalArgs);
1494
+ if (result && [
1495
+ "object",
1496
+ "function",
1497
+ "symbol"
1498
+ ].includes(typeof result)) this.setState(call.storyId, (state) => ({ callRefsByResult: new Map([...Array.from(state.callRefsByResult.entries()), [result, {
1499
+ __callId__: call.id,
1500
+ retain: call.retain
1501
+ }]]) }));
1502
+ this.update({
1503
+ ...info,
1504
+ status: result instanceof Promise ? "active" : "done"
1505
+ });
1506
+ if (result instanceof Promise) return result.then((value) => {
1507
+ this.update({
1508
+ ...info,
1509
+ status: "done"
1510
+ });
1511
+ return value;
1512
+ }, handleException);
1513
+ return result;
1514
+ } catch (e) {
1515
+ return handleException(e);
1516
+ }
1517
+ }
1518
+ update(call) {
1519
+ this.channel?.emit(EVENTS.CALL, call);
1520
+ this.setState(call.storyId, ({ calls }) => {
1521
+ const callsById = calls.concat(call).reduce((a, c) => Object.assign(a, { [c.id]: c }), {});
1522
+ return { calls: Object.values(callsById).sort((a, b) => a.id.localeCompare(b.id, void 0, { numeric: true })) };
1523
+ });
1524
+ this.sync(call.storyId);
1525
+ }
1526
+ sync(storyId) {
1527
+ const synchronize = () => {
1528
+ const { isLocked, isPlaying } = this.getState(storyId);
1529
+ const logItems = this.getLog(storyId);
1530
+ const pausedAt = logItems.filter(({ ancestors }) => !ancestors.length).find((item) => item.status === "waiting")?.callId;
1531
+ const hasActive = logItems.some((item) => item.status === "active");
1532
+ if (this.detached || isLocked || hasActive || logItems.length === 0) {
1533
+ const payload = {
1534
+ storyId,
1535
+ controlStates: {
1536
+ detached: this.detached,
1537
+ start: false,
1538
+ back: false,
1539
+ goto: false,
1540
+ next: false,
1541
+ end: false
1542
+ },
1543
+ logItems
1544
+ };
1545
+ this.channel?.emit(EVENTS.SYNC, payload);
1546
+ return;
1547
+ }
1548
+ const hasPrevious = logItems.some((item) => item.status === "done" || item.status === "error");
1549
+ const payload = {
1550
+ storyId,
1551
+ controlStates: {
1552
+ detached: this.detached,
1553
+ start: hasPrevious,
1554
+ back: hasPrevious,
1555
+ goto: true,
1556
+ next: isPlaying,
1557
+ end: isPlaying
1558
+ },
1559
+ logItems,
1560
+ pausedAt
1561
+ };
1562
+ this.channel?.emit(EVENTS.SYNC, payload);
1563
+ };
1564
+ this.setState(storyId, ({ syncTimeout }) => {
1565
+ clearTimeout(syncTimeout);
1566
+ return { syncTimeout: setTimeout(synchronize, 0) };
1567
+ });
1568
+ }
1569
+ };
1570
+ })))();
1571
+ }
1572
+ //#endregion
1573
+ //#region src/actions/loaders.ts
1574
+ var loaders_exports = /* @__PURE__ */ __exportAll({ loaders: () => loaders });
1575
+ var subscribed, logActionsWhenMockCalled, loaders;
1576
+ function init_loaders() {
1577
+ return (init_loaders = __esmMin((() => {
1578
+ init_test();
1579
+ init_action();
1580
+ subscribed = false;
1581
+ logActionsWhenMockCalled = (context) => {
1582
+ const { parameters } = context;
1583
+ if (parameters?.actions?.disable) return;
1584
+ if (!subscribed) {
1585
+ onMockCall((mock, args) => {
1586
+ const name = mock.getMockName();
1587
+ if (name === "spy") return;
1588
+ if (name === "vi.fn()") return;
1589
+ if (!/^next\/.*::/.test(name) || [
1590
+ "next/router::useRouter()",
1591
+ "next/navigation::useRouter()",
1592
+ "next/navigation::redirect",
1593
+ "next/link::Link",
1594
+ "next/cache::",
1595
+ "next/headers::cookies().set",
1596
+ "next/headers::cookies().delete",
1597
+ "next/headers::headers().set",
1598
+ "next/headers::headers().delete"
1599
+ ].some((prefix) => name.startsWith(prefix))) action(name)(args);
1600
+ });
1601
+ subscribed = true;
1602
+ }
1603
+ };
1604
+ loaders = [logActionsWhenMockCalled];
1605
+ })))();
1606
+ }
1607
+ //#endregion
1608
+ //#region src/actions/preview.ts
1609
+ var preview_default$5;
1610
+ function init_preview() {
1611
+ return (init_preview = __esmMin((() => {
1612
+ init_addArgs();
1613
+ init_loaders();
1614
+ preview_default$5 = () => definePreviewAddon({
1615
+ ...addArgs_exports,
1616
+ ...loaders_exports
1617
+ });
1618
+ })))();
1619
+ }
1620
+ //#endregion
1621
+ //#region src/backgrounds/constants.ts
1622
+ var PARAM_KEY$2;
1623
+ function init_constants$1() {
1624
+ return (init_constants$1 = __esmMin((() => {
1625
+ PARAM_KEY$2 = "backgrounds";
1626
+ })))();
1627
+ }
1628
+ //#endregion
1629
+ //#region src/backgrounds/defaults.ts
1630
+ var DEFAULT_BACKGROUNDS;
1631
+ function init_defaults() {
1632
+ return (init_defaults = __esmMin((() => {
1633
+ DEFAULT_BACKGROUNDS = {
1634
+ light: {
1635
+ name: "light",
1636
+ value: "#F8F8F8"
1637
+ },
1638
+ dark: {
1639
+ name: "dark",
1640
+ value: "#333"
1641
+ }
1642
+ };
1643
+ })))();
1644
+ }
1645
+ //#endregion
1646
+ //#region src/backgrounds/utils.ts
1647
+ var document$1, isReduceMotionEnabled, clearStyles$1, clearStyle$1, addGridStyle, addBackgroundStyle;
1648
+ function init_utils() {
1649
+ return (init_utils = __esmMin((() => {
1650
+ ({document: document$1} = globalThis);
1651
+ isReduceMotionEnabled = () => {
1652
+ if (!globalThis?.matchMedia) return false;
1653
+ return !!globalThis.matchMedia("(prefers-reduced-motion: reduce)")?.matches;
1654
+ };
1655
+ clearStyles$1 = (selector) => {
1656
+ (Array.isArray(selector) ? selector : [selector]).forEach(clearStyle$1);
1657
+ };
1658
+ clearStyle$1 = (selector) => {
1659
+ if (!document$1) return;
1660
+ const element = document$1.getElementById(selector);
1661
+ if (element && element.parentElement) element.parentElement.removeChild(element);
1662
+ };
1663
+ addGridStyle = (selector, css) => {
1664
+ if (!document$1) return;
1665
+ const existingStyle = document$1.getElementById(selector);
1666
+ if (existingStyle) {
1667
+ if (existingStyle.innerHTML !== css) existingStyle.innerHTML = css;
1668
+ } else {
1669
+ const style = document$1.createElement("style");
1670
+ style.setAttribute("id", selector);
1671
+ style.innerHTML = css;
1672
+ document$1.head.appendChild(style);
1673
+ }
1674
+ };
1675
+ addBackgroundStyle = (selector, css, storyId) => {
1676
+ if (!document$1) return;
1677
+ const existingStyle = document$1.getElementById(selector);
1678
+ if (existingStyle) {
1679
+ if (existingStyle.innerHTML !== css) existingStyle.innerHTML = css;
1680
+ } else {
1681
+ const style = document$1.createElement("style");
1682
+ style.setAttribute("id", selector);
1683
+ style.innerHTML = css;
1684
+ const gridStyleSelector = `addon-backgrounds-grid${storyId ? `-docs-${storyId}` : ""}`;
1685
+ const existingGridStyle = document$1.getElementById(gridStyleSelector);
1686
+ if (existingGridStyle) existingGridStyle.parentElement?.insertBefore(style, existingGridStyle);
1687
+ else document$1.head.appendChild(style);
1688
+ }
1689
+ };
1690
+ })))();
1691
+ }
1692
+ //#endregion
1693
+ //#region src/backgrounds/decorator.ts
1694
+ var defaultGrid, BG_SELECTOR_BASE, GRID_SELECTOR_BASE, transitionStyle, withBackgroundAndGrid;
1695
+ function init_decorator() {
1696
+ return (init_decorator = __esmMin((() => {
1697
+ init_preview_api$1();
1698
+ init_constants$1();
1699
+ init_defaults();
1700
+ init_utils();
1701
+ defaultGrid = {
1702
+ cellSize: 100,
1703
+ cellAmount: 10,
1704
+ opacity: .8
1705
+ };
1706
+ BG_SELECTOR_BASE = `addon-backgrounds`;
1707
+ GRID_SELECTOR_BASE = "addon-backgrounds-grid";
1708
+ transitionStyle = isReduceMotionEnabled() ? "" : "transition: background-color 0.3s;";
1709
+ withBackgroundAndGrid = (StoryFn, context) => {
1710
+ const { globals = {}, parameters = {}, viewMode, id } = context;
1711
+ const { options = DEFAULT_BACKGROUNDS, disable, grid = defaultGrid } = parameters["backgrounds"] || {};
1712
+ const data = globals["backgrounds"] || {};
1713
+ const backgroundName = typeof data === "string" ? data : data?.value;
1714
+ const item = backgroundName ? options[backgroundName] : void 0;
1715
+ const value = typeof item === "string" ? item : item?.value || "transparent";
1716
+ const showGrid = typeof data === "string" ? false : data.grid || false;
1717
+ const shownBackground = !!item && !disable;
1718
+ const backgroundSelector = viewMode === "docs" ? `#anchor--${id} .docs-story, #anchor--primary--${id} .docs-story` : ".sb-show-main";
1719
+ const gridSelector = viewMode === "docs" ? `#anchor--${id} .docs-story, #anchor--primary--${id} .docs-story` : ".sb-show-main";
1720
+ const isLayoutPadded = parameters.layout === void 0 || parameters.layout === "padded";
1721
+ const defaultOffset = viewMode === "docs" ? 20 : isLayoutPadded ? 16 : 0;
1722
+ const { cellAmount, cellSize, opacity, offsetX = defaultOffset, offsetY = defaultOffset } = grid;
1723
+ const backgroundSelectorId = viewMode === "docs" ? `${BG_SELECTOR_BASE}-docs-${id}` : `${BG_SELECTOR_BASE}-color`;
1724
+ const backgroundTarget = viewMode === "docs" ? id : null;
1725
+ useEffect(() => {
1726
+ const backgroundStyles = `
1727
+ ${backgroundSelector} {
1728
+ background: ${value} !important;
1729
+ ${transitionStyle}
1730
+ }`;
1731
+ if (!shownBackground) {
1732
+ clearStyles$1(backgroundSelectorId);
1733
+ return;
1734
+ }
1735
+ addBackgroundStyle(backgroundSelectorId, backgroundStyles, backgroundTarget);
1736
+ }, [
1737
+ backgroundSelector,
1738
+ backgroundSelectorId,
1739
+ backgroundTarget,
1740
+ shownBackground,
1741
+ value
1742
+ ]);
1743
+ const gridSelectorId = viewMode === "docs" ? `${GRID_SELECTOR_BASE}-docs-${id}` : `${GRID_SELECTOR_BASE}`;
1744
+ useEffect(() => {
1745
+ if (!showGrid) {
1746
+ clearStyles$1(gridSelectorId);
1747
+ return;
1748
+ }
1749
+ const gridSize = [
1750
+ `${cellSize * cellAmount}px ${cellSize * cellAmount}px`,
1751
+ `${cellSize * cellAmount}px ${cellSize * cellAmount}px`,
1752
+ `${cellSize}px ${cellSize}px`,
1753
+ `${cellSize}px ${cellSize}px`
1754
+ ].join(", ");
1755
+ const gridStyles = `
1756
+ ${gridSelector} {
1757
+ background-size: ${gridSize} !important;
1758
+ background-position: ${offsetX}px ${offsetY}px, ${offsetX}px ${offsetY}px, ${offsetX}px ${offsetY}px, ${offsetX}px ${offsetY}px !important;
1759
+ background-blend-mode: difference !important;
1760
+ background-image: linear-gradient(rgba(130, 130, 130, ${opacity}) 1px, transparent 1px),
1761
+ linear-gradient(90deg, rgba(130, 130, 130, ${opacity}) 1px, transparent 1px),
1762
+ linear-gradient(rgba(130, 130, 130, ${opacity / 2}) 1px, transparent 1px),
1763
+ linear-gradient(90deg, rgba(130, 130, 130, ${opacity / 2}) 1px, transparent 1px) !important;
1764
+ }
1765
+ `;
1766
+ addGridStyle(gridSelectorId, gridStyles);
1767
+ }, [
1768
+ cellAmount,
1769
+ cellSize,
1770
+ gridSelector,
1771
+ gridSelectorId,
1772
+ showGrid,
1773
+ offsetX,
1774
+ offsetY,
1775
+ opacity
1776
+ ]);
1777
+ return StoryFn();
1778
+ };
1779
+ })))();
1780
+ }
1781
+ //#endregion
1782
+ //#region src/backgrounds/preview.ts
1783
+ var decorators$2, parameters, initialGlobals$2, preview_default$4;
1784
+ function init_preview$1() {
1785
+ return (init_preview$1 = __esmMin((() => {
1786
+ init_constants$1();
1787
+ init_decorator();
1788
+ decorators$2 = globalThis.FEATURES?.backgrounds ? [withBackgroundAndGrid] : [];
1789
+ parameters = { [PARAM_KEY$2]: {
1790
+ grid: {
1791
+ cellSize: 20,
1792
+ opacity: .5,
1793
+ cellAmount: 5
1794
+ },
1795
+ disable: false
1796
+ } };
1797
+ initialGlobals$2 = { [PARAM_KEY$2]: {
1798
+ value: void 0,
1799
+ grid: false
1800
+ } };
1801
+ preview_default$4 = () => definePreviewAddon({
1802
+ decorators: decorators$2,
1803
+ parameters,
1804
+ initialGlobals: initialGlobals$2
1805
+ });
1806
+ })))();
1807
+ }
1808
+ //#endregion
1809
+ //#region src/component-testing/preview.ts
1810
+ var step, preview_default$3;
1811
+ function init_preview$2() {
1812
+ return (init_preview$2 = __esmMin((() => {
1813
+ init_instrumenter();
1814
+ ({step} = instrument({ step: async (label, play, context) => play(context) }, { intercept: true }));
1815
+ preview_default$3 = () => definePreviewAddon({
1816
+ parameters: { throwPlayFunctionExceptions: false },
1817
+ runStep: step
1818
+ });
1819
+ })))();
1820
+ }
1821
+ //#endregion
1822
+ //#region src/core-server/utils/ghost-stories/test-annotations.ts
1823
+ var isEmptyRender, afterEach, test_annotations_default;
1824
+ function init_test_annotations() {
1825
+ return (init_test_annotations = __esmMin((() => {
1826
+ isEmptyRender = (element) => {
1827
+ const style = getComputedStyle(element);
1828
+ const rect = element.getBoundingClientRect();
1829
+ return !(rect.width > 0 && rect.height > 0 && style.visibility !== "hidden" && Number(style.opacity) > 0 && style.display !== "none");
1830
+ };
1831
+ afterEach = async ({ reporting, canvasElement, globals }) => {
1832
+ try {
1833
+ if (!globals.renderAnalysis?.enabled) return;
1834
+ const emptyRender = isEmptyRender(canvasElement.firstElementChild ?? canvasElement);
1835
+ if (emptyRender) reporting.addReport({
1836
+ type: "render-analysis",
1837
+ version: 1,
1838
+ result: { emptyRender },
1839
+ status: "warning"
1840
+ });
1841
+ } catch {}
1842
+ };
1843
+ test_annotations_default = () => definePreviewAddon({ afterEach });
1844
+ })))();
1845
+ }
1846
+ //#endregion
1847
+ //#region src/highlight/constants.ts
1848
+ var ADDON_ID$1, HIGHLIGHT, REMOVE_HIGHLIGHT, RESET_HIGHLIGHT, SCROLL_INTO_VIEW, MAX_Z_INDEX;
1849
+ function init_constants$2() {
1850
+ return (init_constants$2 = __esmMin((() => {
1851
+ ADDON_ID$1 = "@aussieljk/forkbook/highlight";
1852
+ HIGHLIGHT = `${ADDON_ID$1}/add`;
1853
+ REMOVE_HIGHLIGHT = `${ADDON_ID$1}/remove`;
1854
+ RESET_HIGHLIGHT = `${ADDON_ID$1}/reset`;
1855
+ SCROLL_INTO_VIEW = `${ADDON_ID$1}/scroll-into-view`;
1856
+ `${ADDON_ID$1}`;
1857
+ MAX_Z_INDEX = 2147483647;
1858
+ })))();
1859
+ }
1860
+ //#endregion
1861
+ //#region src/highlight/icons.ts
1862
+ var iconPaths;
1863
+ function init_icons() {
1864
+ return (init_icons = __esmMin((() => {
1865
+ iconPaths = {
1866
+ chevronLeft: ["M9.10355 10.1464C9.29882 10.3417 9.29882 10.6583 9.10355 10.8536C8.90829 11.0488 8.59171 11.0488 8.39645 10.8536L4.89645 7.35355C4.70118 7.15829 4.70118 6.84171 4.89645 6.64645L8.39645 3.14645C8.59171 2.95118 8.90829 2.95118 9.10355 3.14645C9.29882 3.34171 9.29882 3.65829 9.10355 3.85355L5.95711 7L9.10355 10.1464Z"],
1867
+ chevronRight: ["M4.89645 10.1464C4.70118 10.3417 4.70118 10.6583 4.89645 10.8536C5.09171 11.0488 5.40829 11.0488 5.60355 10.8536L9.10355 7.35355C9.29882 7.15829 9.29882 6.84171 9.10355 6.64645L5.60355 3.14645C5.40829 2.95118 5.09171 2.95118 4.89645 3.14645C4.70118 3.34171 4.70118 3.65829 4.89645 3.85355L8.04289 7L4.89645 10.1464Z"],
1868
+ info: ["M7 5.5a.5.5 0 01.5.5v4a.5.5 0 01-1 0V6a.5.5 0 01.5-.5zM7 4.5A.75.75 0 107 3a.75.75 0 000 1.5z", "M7 14A7 7 0 107 0a7 7 0 000 14zm0-1A6 6 0 107 1a6 6 0 000 12z"],
1869
+ shareAlt: ["M2 1.004a1 1 0 00-1 1v10a1 1 0 001 1h10a1 1 0 001-1v-4.5a.5.5 0 00-1 0v4.5H2v-10h4.5a.5.5 0 000-1H2z", "M7.354 7.357L12 2.711v1.793a.5.5 0 001 0v-3a.5.5 0 00-.5-.5h-3a.5.5 0 100 1h1.793L6.646 6.65a.5.5 0 10.708.707z"]
1870
+ };
1871
+ })))();
1872
+ }
1873
+ //#endregion
1874
+ //#region src/highlight/utils.ts
1875
+ var svgElements, createElement, createIcon, normalizeOptions, isFunction, state$1, listeners, teardowns, useStore, mapElements, mapBoxes, isOverMenu, isTargeted, keepInViewport, showPopover, hidePopover, getEventDetails;
1876
+ function init_utils$1() {
1877
+ return (init_utils$1 = __esmMin((() => {
1878
+ init_constants$2();
1879
+ init_icons();
1880
+ svgElements = "svg,path,rect,circle,line,polyline,polygon,ellipse,text".split(",");
1881
+ createElement = (type, props = {}, children) => {
1882
+ const element = svgElements.includes(type) ? document.createElementNS("http://www.w3.org/2000/svg", type) : document.createElement(type);
1883
+ Object.entries(props).forEach(([key, val]) => {
1884
+ if (/[A-Z]/.test(key)) {
1885
+ if (key === "onClick") {
1886
+ element.addEventListener("click", val);
1887
+ element.addEventListener("keydown", (e) => {
1888
+ if (e.key === "Enter" || e.key === " ") {
1889
+ e.preventDefault();
1890
+ val();
1891
+ }
1892
+ });
1893
+ }
1894
+ if (key === "onMouseEnter") element.addEventListener("mouseenter", val);
1895
+ if (key === "onMouseLeave") element.addEventListener("mouseleave", val);
1896
+ } else element.setAttribute(key, val);
1897
+ });
1898
+ children?.forEach((child) => {
1899
+ if (child === null || child === void 0 || child === false) return;
1900
+ try {
1901
+ element.appendChild(child);
1902
+ } catch (e) {
1903
+ element.appendChild(document.createTextNode(String(child)));
1904
+ }
1905
+ });
1906
+ return element;
1907
+ };
1908
+ createIcon = (name) => iconPaths[name] && createElement("svg", {
1909
+ width: "14",
1910
+ height: "14",
1911
+ viewBox: "0 0 14 14",
1912
+ xmlns: "http://www.w3.org/2000/svg"
1913
+ }, iconPaths[name].map((d) => createElement("path", {
1914
+ fill: "currentColor",
1915
+ "fill-rule": "evenodd",
1916
+ "clip-rule": "evenodd",
1917
+ d
1918
+ })));
1919
+ normalizeOptions = (options) => {
1920
+ const { menu, ...rest } = options;
1921
+ return {
1922
+ priority: 0,
1923
+ styles: { outline: "2px dashed #029cfd" },
1924
+ ...rest,
1925
+ menu: Array.isArray(menu) ? menu.every(Array.isArray) ? menu : [menu] : void 0
1926
+ };
1927
+ };
1928
+ isFunction = (obj) => obj instanceof Function;
1929
+ state$1 = /* @__PURE__ */ new Map();
1930
+ listeners = /* @__PURE__ */ new Map();
1931
+ teardowns = /* @__PURE__ */ new Map();
1932
+ useStore = (initialValue) => {
1933
+ const key = Symbol();
1934
+ listeners.set(key, []);
1935
+ state$1.set(key, initialValue);
1936
+ const get = () => state$1.get(key);
1937
+ const set = (update) => {
1938
+ const current = state$1.get(key);
1939
+ const next = isFunction(update) ? update(current) : update;
1940
+ if (next !== current) {
1941
+ state$1.set(key, next);
1942
+ listeners.get(key)?.forEach((listener) => {
1943
+ teardowns.get(listener)?.();
1944
+ teardowns.set(listener, listener(next));
1945
+ });
1946
+ }
1947
+ };
1948
+ const subscribe = (listener) => {
1949
+ listeners.get(key)?.push(listener);
1950
+ return () => {
1951
+ const list = listeners.get(key);
1952
+ if (list) listeners.set(key, list.filter((l) => l !== listener));
1953
+ };
1954
+ };
1955
+ const teardown = () => {
1956
+ listeners.get(key)?.forEach((listener) => {
1957
+ teardowns.get(listener)?.();
1958
+ teardowns.delete(listener);
1959
+ });
1960
+ listeners.delete(key);
1961
+ state$1.delete(key);
1962
+ };
1963
+ return {
1964
+ get,
1965
+ set,
1966
+ subscribe,
1967
+ teardown
1968
+ };
1969
+ };
1970
+ mapElements = (highlights) => {
1971
+ const root = document.getElementById("storybook-root");
1972
+ const map = /* @__PURE__ */ new Map();
1973
+ for (const highlight of highlights) {
1974
+ const { priority = 0 } = highlight;
1975
+ for (const selector of highlight.selectors) {
1976
+ const elements = [...document.querySelectorAll(`:is(${selector}):not([id^="storybook-"], [id^="storybook-"] *, [class^="sb-"], [class^="sb-"] *)`), ...root?.querySelectorAll(selector) || []];
1977
+ for (const element of elements) {
1978
+ const existing = map.get(element);
1979
+ if (!existing || existing.priority <= priority) map.set(element, {
1980
+ ...highlight,
1981
+ priority,
1982
+ selectors: Array.from(new Set((existing?.selectors || []).concat(selector)))
1983
+ });
1984
+ }
1985
+ }
1986
+ }
1987
+ return map;
1988
+ };
1989
+ mapBoxes = (elements) => Array.from(elements.entries()).map(([element, { id, selectors, styles, hoverStyles, focusStyles, menu }]) => {
1990
+ const { top, left, width, height } = element.getBoundingClientRect();
1991
+ const { position } = getComputedStyle(element);
1992
+ return {
1993
+ element,
1994
+ id,
1995
+ selectors,
1996
+ styles,
1997
+ hoverStyles,
1998
+ focusStyles,
1999
+ menu,
2000
+ top: position === "fixed" ? top : top + window.scrollY,
2001
+ left: position === "fixed" ? left : left + window.scrollX,
2002
+ width,
2003
+ height
2004
+ };
2005
+ }).sort((a, b) => b.width * b.height - a.width * a.height);
2006
+ isOverMenu = (menuElement, coordinates) => {
2007
+ const menu = menuElement.getBoundingClientRect();
2008
+ const { x, y } = coordinates;
2009
+ return menu?.top && menu?.left && x >= menu.left && x <= menu.left + menu.width && y >= menu.top && y <= menu.top + menu.height;
2010
+ };
2011
+ isTargeted = (box, boxElement, coordinates) => {
2012
+ if (!boxElement || !coordinates) return false;
2013
+ let { left, top, width, height } = box;
2014
+ if (height < 28) {
2015
+ top = top - Math.round((28 - height) / 2);
2016
+ height = 28;
2017
+ }
2018
+ if (width < 28) {
2019
+ left = left - Math.round((28 - width) / 2);
2020
+ width = 28;
2021
+ }
2022
+ if (boxElement.style.position === "fixed") {
2023
+ left += window.scrollX;
2024
+ top += window.scrollY;
2025
+ }
2026
+ const { x, y } = coordinates;
2027
+ return x >= left && x <= left + width && y >= top && y <= top + height;
2028
+ };
2029
+ keepInViewport = (element, targetCoordinates, options = {}) => {
2030
+ const { x, y } = targetCoordinates;
2031
+ const { margin = 5, topOffset = 0, centered = false } = options;
2032
+ const { scrollX, scrollY, innerHeight: windowHeight, innerWidth: windowWidth } = window;
2033
+ const top = Math.min(element.style.position === "fixed" ? y - scrollY : y, windowHeight - element.clientHeight - margin - topOffset + scrollY);
2034
+ const leftOffset = centered ? element.clientWidth / 2 : 0;
2035
+ const left = element.style.position === "fixed" ? Math.max(Math.min(x - scrollX, windowWidth - leftOffset - margin), leftOffset + margin) : Math.max(Math.min(x, windowWidth - leftOffset - margin + scrollX), leftOffset + margin + scrollX);
2036
+ Object.assign(element.style, {
2037
+ ...left !== x && { left: `${left}px` },
2038
+ ...top !== y && { top: `${top}px` }
2039
+ });
2040
+ };
2041
+ showPopover = (element) => {
2042
+ if (window.HTMLElement.prototype.hasOwnProperty("showPopover")) element.showPopover();
2043
+ };
2044
+ hidePopover = (element) => {
2045
+ if (window.HTMLElement.prototype.hasOwnProperty("showPopover")) element.hidePopover();
2046
+ };
2047
+ getEventDetails = (target) => ({
2048
+ top: target.top,
2049
+ left: target.left,
2050
+ width: target.width,
2051
+ height: target.height,
2052
+ selectors: target.selectors,
2053
+ element: {
2054
+ localName: target.element.localName,
2055
+ tagName: target.element.tagName
2056
+ }
2057
+ });
2058
+ })))();
2059
+ }
2060
+ //#endregion
2061
+ //#region src/highlight/useHighlights.ts
2062
+ var menuId, rootId, storybookRootId, useHighlights;
2063
+ function init_useHighlights() {
2064
+ return (init_useHighlights = __esmMin((() => {
2065
+ init_client_logger();
2066
+ init_core_events();
2067
+ init_constants$2();
2068
+ init_utils$1();
2069
+ menuId = "storybook-highlights-menu";
2070
+ rootId = "storybook-highlights-root";
2071
+ storybookRootId = "storybook-root";
2072
+ useHighlights = (channel) => {
2073
+ if (globalThis.__STORYBOOK_HIGHLIGHT_INITIALIZED) return;
2074
+ globalThis.__STORYBOOK_HIGHLIGHT_INITIALIZED = true;
2075
+ const { document } = globalThis;
2076
+ const highlights = useStore([]);
2077
+ const elements = useStore(/* @__PURE__ */ new Map());
2078
+ const boxes = useStore([]);
2079
+ const clickCoords = useStore();
2080
+ const hoverCoords = useStore();
2081
+ const targets = useStore([]);
2082
+ const hovered = useStore([]);
2083
+ const focused = useStore();
2084
+ const selected = useStore();
2085
+ let root = document.getElementById(rootId);
2086
+ highlights.subscribe(() => {
2087
+ if (!root) {
2088
+ root = createElement("div", { id: rootId });
2089
+ document.body.appendChild(root);
2090
+ }
2091
+ });
2092
+ highlights.subscribe((value) => {
2093
+ const storybookRoot = document.getElementById(storybookRootId) ?? document.body;
2094
+ elements.set(mapElements(value));
2095
+ const observer = new MutationObserver((records) => {
2096
+ if (records.some((record) => !root?.contains(record.target))) elements.set(mapElements(value));
2097
+ });
2098
+ observer.observe(storybookRoot, {
2099
+ subtree: true,
2100
+ childList: true
2101
+ });
2102
+ return () => {
2103
+ observer.disconnect();
2104
+ };
2105
+ });
2106
+ elements.subscribe((value) => {
2107
+ const updateBoxes = () => requestAnimationFrame(() => boxes.set(mapBoxes(value)));
2108
+ const observer = new ResizeObserver(updateBoxes);
2109
+ observer.observe(document.body);
2110
+ Array.from(value.keys()).forEach((element) => observer.observe(element));
2111
+ const scrollers = Array.from(document.body.querySelectorAll("*")).filter((el) => {
2112
+ const { overflow, overflowX, overflowY } = window.getComputedStyle(el);
2113
+ return ["auto", "scroll"].some((o) => [
2114
+ overflow,
2115
+ overflowX,
2116
+ overflowY
2117
+ ].includes(o));
2118
+ });
2119
+ scrollers.forEach((element) => element.addEventListener("scroll", updateBoxes));
2120
+ return () => {
2121
+ observer.disconnect();
2122
+ scrollers.forEach((element) => element.removeEventListener("scroll", updateBoxes));
2123
+ };
2124
+ });
2125
+ elements.subscribe((value) => {
2126
+ const sticky = Array.from(value.keys()).filter(({ style }) => style.position === "sticky");
2127
+ const updateBoxes = () => requestAnimationFrame(() => {
2128
+ boxes.set((current) => current.map((box) => {
2129
+ if (sticky.includes(box.element)) {
2130
+ const { top, left } = box.element.getBoundingClientRect();
2131
+ return {
2132
+ ...box,
2133
+ top: top + window.scrollY,
2134
+ left: left + window.scrollX
2135
+ };
2136
+ }
2137
+ return box;
2138
+ }));
2139
+ });
2140
+ document.addEventListener("scroll", updateBoxes);
2141
+ return () => document.removeEventListener("scroll", updateBoxes);
2142
+ });
2143
+ elements.subscribe((value) => {
2144
+ targets.set((t) => t.filter(({ element }) => value.has(element)));
2145
+ });
2146
+ targets.subscribe((value) => {
2147
+ if (value.length) {
2148
+ selected.set((s) => value.some((t) => t.element === s?.element) ? s : void 0);
2149
+ focused.set((s) => value.some((t) => t.element === s?.element) ? s : void 0);
2150
+ } else {
2151
+ selected.set(void 0);
2152
+ focused.set(void 0);
2153
+ clickCoords.set(void 0);
2154
+ }
2155
+ });
2156
+ const styleElementByHighlight = /* @__PURE__ */ new Map(/* @__PURE__ */ new Map());
2157
+ highlights.subscribe((value) => {
2158
+ value.forEach(({ keyframes }) => {
2159
+ if (keyframes) {
2160
+ let style = styleElementByHighlight.get(keyframes);
2161
+ if (!style) {
2162
+ style = document.createElement("style");
2163
+ style.setAttribute("data-highlight", "keyframes");
2164
+ styleElementByHighlight.set(keyframes, style);
2165
+ document.head.appendChild(style);
2166
+ }
2167
+ style.innerHTML = keyframes;
2168
+ }
2169
+ });
2170
+ styleElementByHighlight.forEach((style, keyframes) => {
2171
+ if (!value.some((v) => v.keyframes === keyframes)) {
2172
+ style.remove();
2173
+ styleElementByHighlight.delete(keyframes);
2174
+ }
2175
+ });
2176
+ });
2177
+ const boxElementByTargetElement = /* @__PURE__ */ new Map(/* @__PURE__ */ new Map());
2178
+ boxes.subscribe((value) => {
2179
+ value.forEach((box) => {
2180
+ let boxElement = boxElementByTargetElement.get(box.element);
2181
+ if (root && !boxElement) {
2182
+ const props = {
2183
+ popover: "manual",
2184
+ "data-highlight-dimensions": `w${box.width.toFixed(0)}h${box.height.toFixed(0)}`,
2185
+ "data-highlight-coordinates": `x${box.left.toFixed(0)}y${box.top.toFixed(0)}`
2186
+ };
2187
+ boxElement = root.appendChild(createElement("div", props, [createElement("div")]));
2188
+ boxElementByTargetElement.set(box.element, boxElement);
2189
+ }
2190
+ });
2191
+ boxElementByTargetElement.forEach((box, element) => {
2192
+ if (!value.some(({ element: e }) => e === element)) {
2193
+ box.remove();
2194
+ boxElementByTargetElement.delete(element);
2195
+ }
2196
+ });
2197
+ });
2198
+ boxes.subscribe((value) => {
2199
+ const targetable = value.filter((box) => box.menu);
2200
+ if (!targetable.length) return;
2201
+ const onClick = (event) => {
2202
+ requestAnimationFrame(() => {
2203
+ const menu = document.getElementById(menuId);
2204
+ const coords = {
2205
+ x: event.pageX,
2206
+ y: event.pageY
2207
+ };
2208
+ if (menu && !isOverMenu(menu, coords)) {
2209
+ const results = targetable.filter((box) => {
2210
+ const boxElement = boxElementByTargetElement.get(box.element);
2211
+ return isTargeted(box, boxElement, coords);
2212
+ });
2213
+ clickCoords.set(results.length ? coords : void 0);
2214
+ targets.set(results);
2215
+ }
2216
+ });
2217
+ };
2218
+ document.addEventListener("click", onClick);
2219
+ return () => document.removeEventListener("click", onClick);
2220
+ });
2221
+ const updateHovered = () => {
2222
+ const menu = document.getElementById(menuId);
2223
+ const coords = hoverCoords.get();
2224
+ if (!coords || menu && isOverMenu(menu, coords)) return;
2225
+ hovered.set((current) => {
2226
+ const update = boxes.get().filter((box) => {
2227
+ const boxElement = boxElementByTargetElement.get(box.element);
2228
+ return isTargeted(box, boxElement, coords);
2229
+ });
2230
+ const existing = current.filter((box) => update.includes(box));
2231
+ const additions = update.filter((box) => !current.includes(box));
2232
+ const hasRemovals = current.length - existing.length;
2233
+ return additions.length || hasRemovals ? [...existing, ...additions] : current;
2234
+ });
2235
+ };
2236
+ hoverCoords.subscribe(updateHovered);
2237
+ boxes.subscribe(updateHovered);
2238
+ const updateBoxStyles = () => {
2239
+ const selectedElement = selected.get();
2240
+ const targetElements = selectedElement ? [selectedElement] : targets.get();
2241
+ const focusedElement = targetElements.length === 1 ? targetElements[0] : focused.get();
2242
+ const isMenuOpen = clickCoords.get() !== void 0;
2243
+ boxes.get().forEach((box) => {
2244
+ const boxElement = boxElementByTargetElement.get(box.element);
2245
+ if (boxElement) {
2246
+ const isFocused = focusedElement === box;
2247
+ const isHovered = isMenuOpen ? focusedElement ? isFocused : targetElements.includes(box) : hovered.get()?.includes(box);
2248
+ Object.assign(boxElement.style, {
2249
+ animation: "none",
2250
+ background: "transparent",
2251
+ border: "none",
2252
+ boxSizing: "border-box",
2253
+ outline: "none",
2254
+ outlineOffset: "0px",
2255
+ ...box.styles,
2256
+ ...isHovered ? box.hoverStyles : {},
2257
+ ...isFocused ? box.focusStyles : {},
2258
+ position: getComputedStyle(box.element).position === "fixed" ? "fixed" : "absolute",
2259
+ zIndex: MAX_Z_INDEX - 10,
2260
+ top: `${box.top}px`,
2261
+ left: `${box.left}px`,
2262
+ width: `${box.width}px`,
2263
+ height: `${box.height}px`,
2264
+ margin: 0,
2265
+ padding: 0,
2266
+ cursor: box.menu && isHovered ? "pointer" : "default",
2267
+ pointerEvents: box.menu ? "auto" : "none",
2268
+ display: "flex",
2269
+ alignItems: "center",
2270
+ justifyContent: "center",
2271
+ overflow: "visible"
2272
+ });
2273
+ Object.assign(boxElement.children[0].style, {
2274
+ width: "100%",
2275
+ height: "100%",
2276
+ minHeight: `28px`,
2277
+ minWidth: `28px`,
2278
+ boxSizing: "content-box",
2279
+ padding: boxElement.style.outlineWidth || "0px"
2280
+ });
2281
+ showPopover(boxElement);
2282
+ }
2283
+ });
2284
+ };
2285
+ boxes.subscribe(updateBoxStyles);
2286
+ targets.subscribe(updateBoxStyles);
2287
+ hovered.subscribe(updateBoxStyles);
2288
+ focused.subscribe(updateBoxStyles);
2289
+ selected.subscribe(updateBoxStyles);
2290
+ const renderMenu = () => {
2291
+ if (!root) return;
2292
+ let menu = document.getElementById(menuId);
2293
+ if (menu) menu.innerHTML = "";
2294
+ else {
2295
+ const props = {
2296
+ id: menuId,
2297
+ popover: "manual"
2298
+ };
2299
+ menu = root.appendChild(createElement("div", props));
2300
+ root.appendChild(createElement("style", {}, [`
2301
+ #${menuId} {
2302
+ position: absolute;
2303
+ z-index: ${MAX_Z_INDEX};
2304
+ width: 300px;
2305
+ padding: 0px;
2306
+ margin: 15px 0 0 0;
2307
+ transform: translateX(-50%);
2308
+ font-family: "Nunito Sans", -apple-system, ".SFNSText-Regular", "San Francisco", BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
2309
+ font-size: 12px;
2310
+ background: white;
2311
+ border: none;
2312
+ border-radius: 6px;
2313
+ box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.05), 0 5px 15px 0 rgba(0, 0, 0, 0.1);
2314
+ color: #2E3438;
2315
+ }
2316
+ #${menuId} ul {
2317
+ list-style: none;
2318
+ margin: 0;
2319
+ padding: 0;
2320
+ }
2321
+ #${menuId} > ul {
2322
+ max-height: 300px;
2323
+ overflow-y: auto;
2324
+ padding: 4px 0;
2325
+ }
2326
+ #${menuId} li {
2327
+ padding: 0 4px;
2328
+ margin: 0;
2329
+ }
2330
+ #${menuId} li > :not(ul) {
2331
+ display: flex;
2332
+ padding: 8px;
2333
+ margin: 0;
2334
+ align-items: center;
2335
+ gap: 8px;
2336
+ border-radius: 4px;
2337
+ }
2338
+ #${menuId} button {
2339
+ width: 100%;
2340
+ border: 0;
2341
+ background: transparent;
2342
+ color: inherit;
2343
+ text-align: left;
2344
+ font-family: inherit;
2345
+ font-size: inherit;
2346
+ }
2347
+ #${menuId} button:focus-visible {
2348
+ outline-color: #029CFD;
2349
+ }
2350
+ #${menuId} button:hover {
2351
+ background: rgba(2, 156, 253, 0.07);
2352
+ color: #029CFD;
2353
+ cursor: pointer;
2354
+ }
2355
+ #${menuId} li code {
2356
+ white-space: nowrap;
2357
+ overflow: hidden;
2358
+ text-overflow: ellipsis;
2359
+ line-height: 16px;
2360
+ font-size: 11px;
2361
+ }
2362
+ #${menuId} li svg {
2363
+ flex-shrink: 0;
2364
+ margin: 1px;
2365
+ color: #73828C;
2366
+ }
2367
+ #${menuId} li > button:hover svg, #${menuId} li > button:focus-visible svg {
2368
+ color: #029CFD;
2369
+ }
2370
+ #${menuId} .element-list li svg {
2371
+ display: none;
2372
+ }
2373
+ #${menuId} li.selectable svg, #${menuId} li.selected svg {
2374
+ display: block;
2375
+ }
2376
+ #${menuId} .menu-list {
2377
+ border-top: 1px solid rgba(38, 85, 115, 0.15);
2378
+ }
2379
+ #${menuId} .menu-list > li:not(:last-child) {
2380
+ padding-bottom: 4px;
2381
+ margin-bottom: 4px;
2382
+ border-bottom: 1px solid rgba(38, 85, 115, 0.15);
2383
+ }
2384
+ #${menuId} .menu-items, #${menuId} .menu-items li {
2385
+ padding: 0;
2386
+ }
2387
+ #${menuId} .menu-item {
2388
+ display: flex;
2389
+ }
2390
+ #${menuId} .menu-item-content {
2391
+ display: flex;
2392
+ flex-direction: column;
2393
+ flex-grow: 1;
2394
+ }
2395
+ `]));
2396
+ }
2397
+ const selectedElement = selected.get();
2398
+ const elementList = selectedElement ? [selectedElement] : targets.get();
2399
+ if (elementList.length) {
2400
+ menu.style.position = getComputedStyle(elementList[0].element).position === "fixed" ? "fixed" : "absolute";
2401
+ menu.appendChild(createElement("ul", { class: "element-list" }, elementList.map((target) => {
2402
+ const selectable = elementList.length > 1 && !!target.menu?.some((group) => group.some((item) => !item.selectors || item.selectors.some((s) => target.selectors.includes(s))));
2403
+ const props = selectable ? {
2404
+ class: "selectable",
2405
+ onClick: () => selected.set(target),
2406
+ onMouseEnter: () => focused.set(target),
2407
+ onMouseLeave: () => focused.set(void 0)
2408
+ } : selectedElement ? {
2409
+ class: "selected",
2410
+ onClick: () => selected.set(void 0)
2411
+ } : {};
2412
+ const asButton = selectable || selectedElement;
2413
+ return createElement("li", props, [createElement(asButton ? "button" : "div", asButton ? { type: "button" } : {}, [
2414
+ selectedElement ? createIcon("chevronLeft") : null,
2415
+ createElement("code", {}, [target.element.outerHTML]),
2416
+ selectable ? createIcon("chevronRight") : null
2417
+ ])]);
2418
+ })));
2419
+ }
2420
+ if (selected.get() || targets.get().length === 1) {
2421
+ const target = selected.get() || targets.get()[0];
2422
+ const menuGroups = target.menu?.filter((group) => group.some((item) => !item.selectors || item.selectors.some((s) => target.selectors.includes(s))));
2423
+ if (menuGroups?.length) menu.appendChild(createElement("ul", { class: "menu-list" }, menuGroups.map((menuItems) => createElement("li", {}, [createElement("ul", { class: "menu-items" }, menuItems.map(({ id, title, description, iconLeft, iconRight, clickable }) => {
2424
+ const onClick = clickable && (() => channel.emit("@aussieljk/forkbook/highlight/menu-click", target.id, id, getEventDetails(target)));
2425
+ return createElement("li", {}, [createElement(onClick ? "button" : "div", onClick ? {
2426
+ class: "menu-item",
2427
+ type: "button",
2428
+ onClick
2429
+ } : { class: "menu-item" }, [
2430
+ iconLeft ? createIcon(iconLeft) : null,
2431
+ createElement("div", { class: "menu-item-content" }, [createElement(description ? "strong" : "span", {}, [title]), description && createElement("span", {}, [description])]),
2432
+ iconRight ? createIcon(iconRight) : null
2433
+ ])]);
2434
+ }))]))));
2435
+ }
2436
+ const coords = clickCoords.get();
2437
+ if (coords) {
2438
+ Object.assign(menu.style, {
2439
+ display: "block",
2440
+ left: `${menu.style.position === "fixed" ? coords.x - window.scrollX : coords.x}px`,
2441
+ top: `${menu.style.position === "fixed" ? coords.y - window.scrollY : coords.y}px`
2442
+ });
2443
+ showPopover(menu);
2444
+ requestAnimationFrame(() => keepInViewport(menu, coords, {
2445
+ topOffset: 15,
2446
+ centered: true
2447
+ }));
2448
+ } else {
2449
+ hidePopover(menu);
2450
+ Object.assign(menu.style, { display: "none" });
2451
+ }
2452
+ };
2453
+ targets.subscribe(renderMenu);
2454
+ selected.subscribe(renderMenu);
2455
+ const addHighlight = (highlight) => {
2456
+ const info = highlight && normalizeOptions(highlight);
2457
+ if (typeof info?.id !== "string" || !info.id) {
2458
+ logger.warn("Ignoring highlight without an id", highlight);
2459
+ return;
2460
+ }
2461
+ highlights.set((value) => {
2462
+ const others = value.filter((h) => h.id !== info.id);
2463
+ return info.selectors?.length ? [...others, info] : others;
2464
+ });
2465
+ };
2466
+ const removeHighlight = (id) => {
2467
+ if (id) highlights.set((value) => value.filter((h) => h.id !== id));
2468
+ };
2469
+ const resetState = () => {
2470
+ highlights.set([]);
2471
+ elements.set(/* @__PURE__ */ new Map());
2472
+ boxes.set([]);
2473
+ clickCoords.set(void 0);
2474
+ hoverCoords.set(void 0);
2475
+ targets.set([]);
2476
+ hovered.set([]);
2477
+ focused.set(void 0);
2478
+ selected.set(void 0);
2479
+ };
2480
+ let removeTimeout;
2481
+ const scrollIntoView = (target, options) => {
2482
+ const id = "scrollIntoView-highlight";
2483
+ clearTimeout(removeTimeout);
2484
+ removeHighlight(id);
2485
+ const element = document.querySelector(target);
2486
+ if (!element) {
2487
+ logger.warn(`Cannot scroll into view: ${target} not found`);
2488
+ return;
2489
+ }
2490
+ element.scrollIntoView({
2491
+ behavior: "smooth",
2492
+ block: "center",
2493
+ ...options
2494
+ });
2495
+ const keyframeName = `kf-${Math.random().toString(36).substring(2, 15)}`;
2496
+ highlights.set((value) => [...value, {
2497
+ id,
2498
+ priority: 1e3,
2499
+ selectors: [target],
2500
+ styles: {
2501
+ outline: "2px solid #1EA7FD",
2502
+ outlineOffset: "-1px",
2503
+ animation: `${keyframeName} 3s linear forwards`
2504
+ },
2505
+ keyframes: `@keyframes ${keyframeName} {
2506
+ 0% { outline: 2px solid #1EA7FD; }
2507
+ 20% { outline: 2px solid #1EA7FD00; }
2508
+ 40% { outline: 2px solid #1EA7FD; }
2509
+ 60% { outline: 2px solid #1EA7FD00; }
2510
+ 80% { outline: 2px solid #1EA7FD; }
2511
+ 100% { outline: 2px solid #1EA7FD00; }
2512
+ }`
2513
+ }]);
2514
+ removeTimeout = setTimeout(() => removeHighlight(id), 3500);
2515
+ };
2516
+ const onMouseMove = (event) => {
2517
+ requestAnimationFrame(() => hoverCoords.set({
2518
+ x: event.pageX,
2519
+ y: event.pageY
2520
+ }));
2521
+ };
2522
+ document.body.addEventListener("mousemove", onMouseMove);
2523
+ channel.on(HIGHLIGHT, addHighlight);
2524
+ channel.on(REMOVE_HIGHLIGHT, removeHighlight);
2525
+ channel.on(RESET_HIGHLIGHT, resetState);
2526
+ channel.on(SCROLL_INTO_VIEW, scrollIntoView);
2527
+ channel.on(STORY_RENDER_PHASE_CHANGED, ({ newPhase }) => {
2528
+ if (newPhase === "loading") resetState();
2529
+ });
2530
+ };
2531
+ })))();
2532
+ }
2533
+ //#endregion
2534
+ //#region src/highlight/preview.ts
2535
+ var preview_default$2;
2536
+ function init_preview$3() {
2537
+ return (init_preview$3 = __esmMin((() => {
2538
+ init_preview_api$1();
2539
+ init_useHighlights();
2540
+ if (globalThis?.FEATURES?.highlight && addons$1?.ready) addons$1.ready().then(useHighlights);
2541
+ preview_default$2 = () => definePreviewAddon({});
2542
+ })))();
2543
+ }
2544
+ //#endregion
2545
+ //#region src/measure/constants.ts
2546
+ var PARAM_KEY$1;
2547
+ function init_constants$3() {
2548
+ return (init_constants$3 = __esmMin((() => {
2549
+ PARAM_KEY$1 = "measureEnabled";
2550
+ })))();
2551
+ }
2552
+ //#endregion
2553
+ //#region src/measure/box-model/canvas.ts
2554
+ function getDocumentWidthAndHeight() {
2555
+ const container = scope.document.documentElement;
2556
+ const height = Math.max(container.scrollHeight, container.offsetHeight);
2557
+ return {
2558
+ width: Math.max(container.scrollWidth, container.offsetWidth),
2559
+ height
2560
+ };
2561
+ }
2562
+ function createCanvas() {
2563
+ const canvas = scope.document.createElement("canvas");
2564
+ canvas.id = "storybook-addon-measure";
2565
+ const context = canvas.getContext("2d");
2566
+ invariant(context != null);
2567
+ const { width, height } = getDocumentWidthAndHeight();
2568
+ setCanvasWidthAndHeight(canvas, context, {
2569
+ width,
2570
+ height
2571
+ });
2572
+ canvas.style.position = "absolute";
2573
+ canvas.style.left = "0";
2574
+ canvas.style.top = "0";
2575
+ canvas.style.zIndex = "2147483647";
2576
+ canvas.style.pointerEvents = "none";
2577
+ scope.document.body.appendChild(canvas);
2578
+ return {
2579
+ canvas,
2580
+ context,
2581
+ width,
2582
+ height
2583
+ };
2584
+ }
2585
+ function setCanvasWidthAndHeight(canvas, context, { width, height }) {
2586
+ canvas.style.width = `${width}px`;
2587
+ canvas.style.height = `${height}px`;
2588
+ const scale = scope.window.devicePixelRatio;
2589
+ canvas.width = Math.floor(width * scale);
2590
+ canvas.height = Math.floor(height * scale);
2591
+ context.scale(scale, scale);
2592
+ }
2593
+ function init() {
2594
+ if (!state.canvas) state = createCanvas();
2595
+ }
2596
+ function clear() {
2597
+ if (state.context) state.context.clearRect(0, 0, state.width ?? 0, state.height ?? 0);
2598
+ }
2599
+ function draw(callback) {
2600
+ clear();
2601
+ callback(state.context);
2602
+ }
2603
+ function rescale() {
2604
+ invariant(state.canvas, "Canvas should exist in the state.");
2605
+ invariant(state.context, "Context should exist in the state.");
2606
+ setCanvasWidthAndHeight(state.canvas, state.context, {
2607
+ width: 0,
2608
+ height: 0
2609
+ });
2610
+ const { width, height } = getDocumentWidthAndHeight();
2611
+ setCanvasWidthAndHeight(state.canvas, state.context, {
2612
+ width,
2613
+ height
2614
+ });
2615
+ state.width = width;
2616
+ state.height = height;
2617
+ }
2618
+ function destroy() {
2619
+ if (state.canvas) {
2620
+ clear();
2621
+ state.canvas.parentNode?.removeChild(state.canvas);
2622
+ state = {};
2623
+ }
2624
+ }
2625
+ var state;
2626
+ function init_canvas() {
2627
+ return (init_canvas = __esmMin((() => {
2628
+ init_dist$1();
2629
+ init_tiny_invariant();
2630
+ state = {};
2631
+ })))();
2632
+ }
2633
+ //#endregion
2634
+ //#region src/measure/box-model/labels.ts
2635
+ function roundedRect(context, { x, y, w, h, r }) {
2636
+ x = x - w / 2;
2637
+ y = y - h / 2;
2638
+ if (w < 2 * r) r = w / 2;
2639
+ if (h < 2 * r) r = h / 2;
2640
+ context.beginPath();
2641
+ context.moveTo(x + r, y);
2642
+ context.arcTo(x + w, y, x + w, y + h, r);
2643
+ context.arcTo(x + w, y + h, x, y + h, r);
2644
+ context.arcTo(x, y + h, x, y, r);
2645
+ context.arcTo(x, y, x + w, y, r);
2646
+ context.closePath();
2647
+ }
2648
+ function positionCoordinate(position, { padding, border, width, height, top, left }) {
2649
+ const contentWidth = width - border.left - border.right - padding.left - padding.right;
2650
+ const contentHeight = height - padding.top - padding.bottom - border.top - border.bottom;
2651
+ let x = left + border.left + padding.left;
2652
+ let y = top + border.top + padding.top;
2653
+ if (position === "top") x += contentWidth / 2;
2654
+ else if (position === "right") {
2655
+ x += contentWidth;
2656
+ y += contentHeight / 2;
2657
+ } else if (position === "bottom") {
2658
+ x += contentWidth / 2;
2659
+ y += contentHeight;
2660
+ } else if (position === "left") y += contentHeight / 2;
2661
+ else if (position === "center") {
2662
+ x += contentWidth / 2;
2663
+ y += contentHeight / 2;
2664
+ }
2665
+ return {
2666
+ x,
2667
+ y
2668
+ };
2669
+ }
2670
+ /**
2671
+ * Offset the label based on how many layers appear before it For example: margin labels will shift
2672
+ * further outwards if there are padding labels
2673
+ */
2674
+ function offset(type, position, { margin, border, padding }, labelPaddingSize, external) {
2675
+ let shift = (dir) => 0;
2676
+ let offsetX = 0;
2677
+ let offsetY = 0;
2678
+ const locationMultiplier = external ? 1 : .5;
2679
+ const labelPaddingShift = external ? labelPaddingSize * 2 : 0;
2680
+ if (type === "padding") shift = (dir) => padding[dir] * locationMultiplier + labelPaddingShift;
2681
+ else if (type === "border") shift = (dir) => padding[dir] + border[dir] * locationMultiplier + labelPaddingShift;
2682
+ else if (type === "margin") shift = (dir) => padding[dir] + border[dir] + margin[dir] * locationMultiplier + labelPaddingShift;
2683
+ if (position === "top") offsetY = -shift("top");
2684
+ else if (position === "right") offsetX = shift("right");
2685
+ else if (position === "bottom") offsetY = shift("bottom");
2686
+ else if (position === "left") offsetX = -shift("left");
2687
+ return {
2688
+ offsetX,
2689
+ offsetY
2690
+ };
2691
+ }
2692
+ function collide(a, b) {
2693
+ return Math.abs(a.x - b.x) < Math.abs(a.w + b.w) / 2 && Math.abs(a.y - b.y) < Math.abs(a.h + b.h) / 2;
2694
+ }
2695
+ function overlapAdjustment(position, currentRect, prevRect) {
2696
+ if (position === "top") currentRect.y = prevRect.y - prevRect.h - labelPadding;
2697
+ else if (position === "right") currentRect.x = prevRect.x + prevRect.w / 2 + labelPadding + currentRect.w / 2;
2698
+ else if (position === "bottom") currentRect.y = prevRect.y + prevRect.h + labelPadding;
2699
+ else if (position === "left") currentRect.x = prevRect.x - prevRect.w / 2 - labelPadding - currentRect.w / 2;
2700
+ return {
2701
+ x: currentRect.x,
2702
+ y: currentRect.y
2703
+ };
2704
+ }
2705
+ function textWithRect(context, type, { x, y, w, h }, text) {
2706
+ roundedRect(context, {
2707
+ x,
2708
+ y,
2709
+ w,
2710
+ h,
2711
+ r: 3
2712
+ });
2713
+ context.fillStyle = `${colors$1[type]}dd`;
2714
+ context.fill();
2715
+ context.strokeStyle = colors$1[type];
2716
+ context.stroke();
2717
+ context.fillStyle = colors$1.text;
2718
+ context.fillText(text, x, y);
2719
+ roundedRect(context, {
2720
+ x,
2721
+ y,
2722
+ w,
2723
+ h,
2724
+ r: 3
2725
+ });
2726
+ context.fillStyle = `${colors$1[type]}dd`;
2727
+ context.fill();
2728
+ context.strokeStyle = colors$1[type];
2729
+ context.stroke();
2730
+ context.fillStyle = colors$1.text;
2731
+ context.fillText(text, x, y);
2732
+ return {
2733
+ x,
2734
+ y,
2735
+ w,
2736
+ h
2737
+ };
2738
+ }
2739
+ function configureText(context, text) {
2740
+ context.font = "600 12px monospace";
2741
+ context.textBaseline = "middle";
2742
+ context.textAlign = "center";
2743
+ const metrics = context.measureText(text);
2744
+ const actualHeight = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent;
2745
+ return {
2746
+ w: metrics.width + 12,
2747
+ h: actualHeight + 12
2748
+ };
2749
+ }
2750
+ function drawLabel(context, measurements, { type, position = "center", text }, prevRect, external = false) {
2751
+ let { x, y } = positionCoordinate(position, measurements);
2752
+ const { offsetX, offsetY } = offset(type, position, measurements, 7, external);
2753
+ x += offsetX;
2754
+ y += offsetY;
2755
+ const { w, h } = configureText(context, text);
2756
+ if (prevRect && collide({
2757
+ x,
2758
+ y,
2759
+ w,
2760
+ h
2761
+ }, prevRect)) {
2762
+ const adjusted = overlapAdjustment(position, {
2763
+ x,
2764
+ y,
2765
+ w,
2766
+ h
2767
+ }, prevRect);
2768
+ x = adjusted.x;
2769
+ y = adjusted.y;
2770
+ }
2771
+ return textWithRect(context, type, {
2772
+ x,
2773
+ y,
2774
+ w,
2775
+ h
2776
+ }, text);
2777
+ }
2778
+ function floatingOffset(alignment, { w, h }) {
2779
+ const deltaW = w * .5 + labelPadding;
2780
+ const deltaH = h * .5 + labelPadding;
2781
+ return {
2782
+ offsetX: (alignment.x === "left" ? -1 : 1) * deltaW,
2783
+ offsetY: (alignment.y === "top" ? -1 : 1) * deltaH
2784
+ };
2785
+ }
2786
+ function drawFloatingLabel(context, measurements, { type, text }) {
2787
+ const { floatingAlignment, extremities } = measurements;
2788
+ let x = extremities[floatingAlignment.x];
2789
+ let y = extremities[floatingAlignment.y];
2790
+ const { w, h } = configureText(context, text);
2791
+ const { offsetX, offsetY } = floatingOffset(floatingAlignment, {
2792
+ w,
2793
+ h
2794
+ });
2795
+ x += offsetX;
2796
+ y += offsetY;
2797
+ return textWithRect(context, type, {
2798
+ x,
2799
+ y,
2800
+ w,
2801
+ h
2802
+ }, text);
2803
+ }
2804
+ function drawStack(context, measurements, stack, external) {
2805
+ const rects = [];
2806
+ stack.forEach((l, idx) => {
2807
+ const rect = external && l.position === "center" ? drawFloatingLabel(context, measurements, l) : drawLabel(context, measurements, l, rects[idx - 1], external);
2808
+ rects[idx] = rect;
2809
+ });
2810
+ }
2811
+ function labelStacks(context, measurements, labels, externalLabels) {
2812
+ const stacks = labels.reduce((acc, l) => {
2813
+ if (!Object.prototype.hasOwnProperty.call(acc, l.position)) acc[l.position] = [];
2814
+ acc[l.position]?.push(l);
2815
+ return acc;
2816
+ }, {});
2817
+ if (stacks.top) drawStack(context, measurements, stacks.top, externalLabels);
2818
+ if (stacks.right) drawStack(context, measurements, stacks.right, externalLabels);
2819
+ if (stacks.bottom) drawStack(context, measurements, stacks.bottom, externalLabels);
2820
+ if (stacks.left) drawStack(context, measurements, stacks.left, externalLabels);
2821
+ if (stacks.center) drawStack(context, measurements, stacks.center, externalLabels);
2822
+ }
2823
+ var colors$1, labelPadding;
2824
+ function init_labels() {
2825
+ return (init_labels = __esmMin((() => {
2826
+ colors$1 = {
2827
+ margin: "#f6b26b",
2828
+ border: "#ffe599",
2829
+ padding: "#93c47d",
2830
+ content: "#6fa8dc",
2831
+ text: "#232020"
2832
+ };
2833
+ labelPadding = 6;
2834
+ })))();
2835
+ }
2836
+ //#endregion
2837
+ //#region src/measure/box-model/visualizer.ts
2838
+ function pxToNumber(px) {
2839
+ return parseInt(px.replace("px", ""), 10);
2840
+ }
2841
+ function round(value) {
2842
+ return Number.isInteger(value) ? value : value.toFixed(2);
2843
+ }
2844
+ function filterZeroValues(labels) {
2845
+ return labels.filter((l) => l.text !== 0 && l.text !== "0");
2846
+ }
2847
+ function floatingAlignment(extremities) {
2848
+ const windowExtremities = {
2849
+ top: scope.window.scrollY,
2850
+ bottom: scope.window.scrollY + scope.window.innerHeight,
2851
+ left: scope.window.scrollX,
2852
+ right: scope.window.scrollX + scope.window.innerWidth
2853
+ };
2854
+ const distances = {
2855
+ top: Math.abs(windowExtremities.top - extremities.top),
2856
+ bottom: Math.abs(windowExtremities.bottom - extremities.bottom),
2857
+ left: Math.abs(windowExtremities.left - extremities.left),
2858
+ right: Math.abs(windowExtremities.right - extremities.right)
2859
+ };
2860
+ return {
2861
+ x: distances.left > distances.right ? "left" : "right",
2862
+ y: distances.top > distances.bottom ? "top" : "bottom"
2863
+ };
2864
+ }
2865
+ function measureElement(element) {
2866
+ const style = scope.getComputedStyle(element);
2867
+ let { top, left, right, bottom, width, height } = element.getBoundingClientRect();
2868
+ const { marginTop, marginBottom, marginLeft, marginRight, paddingTop, paddingBottom, paddingLeft, paddingRight, borderBottomWidth, borderTopWidth, borderLeftWidth, borderRightWidth } = style;
2869
+ top = top + scope.window.scrollY;
2870
+ left = left + scope.window.scrollX;
2871
+ bottom = bottom + scope.window.scrollY;
2872
+ right = right + scope.window.scrollX;
2873
+ const margin = {
2874
+ top: pxToNumber(marginTop),
2875
+ bottom: pxToNumber(marginBottom),
2876
+ left: pxToNumber(marginLeft),
2877
+ right: pxToNumber(marginRight)
2878
+ };
2879
+ const padding = {
2880
+ top: pxToNumber(paddingTop),
2881
+ bottom: pxToNumber(paddingBottom),
2882
+ left: pxToNumber(paddingLeft),
2883
+ right: pxToNumber(paddingRight)
2884
+ };
2885
+ const border = {
2886
+ top: pxToNumber(borderTopWidth),
2887
+ bottom: pxToNumber(borderBottomWidth),
2888
+ left: pxToNumber(borderLeftWidth),
2889
+ right: pxToNumber(borderRightWidth)
2890
+ };
2891
+ const extremities = {
2892
+ top: top - margin.top,
2893
+ bottom: bottom + margin.bottom,
2894
+ left: left - margin.left,
2895
+ right: right + margin.right
2896
+ };
2897
+ return {
2898
+ margin,
2899
+ padding,
2900
+ border,
2901
+ top,
2902
+ left,
2903
+ bottom,
2904
+ right,
2905
+ width,
2906
+ height,
2907
+ extremities,
2908
+ floatingAlignment: floatingAlignment(extremities)
2909
+ };
2910
+ }
2911
+ function drawMargin(context, { margin, width, height, top, left, bottom, right }) {
2912
+ const marginHeight = height + margin.bottom + margin.top;
2913
+ context.fillStyle = colors.margin;
2914
+ context.fillRect(left, top - margin.top, width, margin.top);
2915
+ context.fillRect(right, top - margin.top, margin.right, marginHeight);
2916
+ context.fillRect(left, bottom, width, margin.bottom);
2917
+ context.fillRect(left - margin.left, top - margin.top, margin.left, marginHeight);
2918
+ return filterZeroValues([
2919
+ {
2920
+ type: "margin",
2921
+ text: round(margin.top),
2922
+ position: "top"
2923
+ },
2924
+ {
2925
+ type: "margin",
2926
+ text: round(margin.right),
2927
+ position: "right"
2928
+ },
2929
+ {
2930
+ type: "margin",
2931
+ text: round(margin.bottom),
2932
+ position: "bottom"
2933
+ },
2934
+ {
2935
+ type: "margin",
2936
+ text: round(margin.left),
2937
+ position: "left"
2938
+ }
2939
+ ]);
2940
+ }
2941
+ function drawPadding(context, { padding, border, width, height, top, left, bottom, right }) {
2942
+ const paddingWidth = width - border.left - border.right;
2943
+ const paddingHeight = height - padding.top - padding.bottom - border.top - border.bottom;
2944
+ context.fillStyle = colors.padding;
2945
+ context.fillRect(left + border.left, top + border.top, paddingWidth, padding.top);
2946
+ context.fillRect(right - padding.right - border.right, top + padding.top + border.top, padding.right, paddingHeight);
2947
+ context.fillRect(left + border.left, bottom - padding.bottom - border.bottom, paddingWidth, padding.bottom);
2948
+ context.fillRect(left + border.left, top + padding.top + border.top, padding.left, paddingHeight);
2949
+ return filterZeroValues([
2950
+ {
2951
+ type: "padding",
2952
+ text: padding.top,
2953
+ position: "top"
2954
+ },
2955
+ {
2956
+ type: "padding",
2957
+ text: padding.right,
2958
+ position: "right"
2959
+ },
2960
+ {
2961
+ type: "padding",
2962
+ text: padding.bottom,
2963
+ position: "bottom"
2964
+ },
2965
+ {
2966
+ type: "padding",
2967
+ text: padding.left,
2968
+ position: "left"
2969
+ }
2970
+ ]);
2971
+ }
2972
+ function drawBorder(context, { border, width, height, top, left, bottom, right }) {
2973
+ const borderHeight = height - border.top - border.bottom;
2974
+ context.fillStyle = colors.border;
2975
+ context.fillRect(left, top, width, border.top);
2976
+ context.fillRect(left, bottom - border.bottom, width, border.bottom);
2977
+ context.fillRect(left, top + border.top, border.left, borderHeight);
2978
+ context.fillRect(right - border.right, top + border.top, border.right, borderHeight);
2979
+ return filterZeroValues([
2980
+ {
2981
+ type: "border",
2982
+ text: border.top,
2983
+ position: "top"
2984
+ },
2985
+ {
2986
+ type: "border",
2987
+ text: border.right,
2988
+ position: "right"
2989
+ },
2990
+ {
2991
+ type: "border",
2992
+ text: border.bottom,
2993
+ position: "bottom"
2994
+ },
2995
+ {
2996
+ type: "border",
2997
+ text: border.left,
2998
+ position: "left"
2999
+ }
3000
+ ]);
3001
+ }
3002
+ function drawContent(context, { padding, border, width, height, top, left }) {
3003
+ const contentWidth = width - border.left - border.right - padding.left - padding.right;
3004
+ const contentHeight = height - padding.top - padding.bottom - border.top - border.bottom;
3005
+ context.fillStyle = colors.content;
3006
+ context.fillRect(left + border.left + padding.left, top + border.top + padding.top, contentWidth, contentHeight);
3007
+ return [{
3008
+ type: "content",
3009
+ position: "center",
3010
+ text: `${round(contentWidth)} x ${round(contentHeight)}`
3011
+ }];
3012
+ }
3013
+ function drawBoxModel(element) {
3014
+ return (context) => {
3015
+ if (element && context) {
3016
+ const measurements = measureElement(element);
3017
+ const marginLabels = drawMargin(context, measurements);
3018
+ const paddingLabels = drawPadding(context, measurements);
3019
+ const borderLabels = drawBorder(context, measurements);
3020
+ const contentLabels = drawContent(context, measurements);
3021
+ const externalLabels = measurements.width <= 90 || measurements.height <= SMALL_NODE_SIZE;
3022
+ labelStacks(context, measurements, [
3023
+ ...contentLabels,
3024
+ ...paddingLabels,
3025
+ ...borderLabels,
3026
+ ...marginLabels
3027
+ ], externalLabels);
3028
+ }
3029
+ };
3030
+ }
3031
+ function drawSelectedElement(element) {
3032
+ draw(drawBoxModel(element));
3033
+ }
3034
+ var colors, SMALL_NODE_SIZE;
3035
+ function init_visualizer() {
3036
+ return (init_visualizer = __esmMin((() => {
3037
+ init_dist$1();
3038
+ init_canvas();
3039
+ init_labels();
3040
+ colors = {
3041
+ margin: "#f6b26ba8",
3042
+ border: "#ffe599a8",
3043
+ padding: "#93c47d8c",
3044
+ content: "#6fa8dca8"
3045
+ };
3046
+ SMALL_NODE_SIZE = 30;
3047
+ })))();
3048
+ }
3049
+ //#endregion
3050
+ //#region src/measure/util.ts
3051
+ var deepElementFromPoint;
3052
+ function init_util() {
3053
+ return (init_util = __esmMin((() => {
3054
+ init_dist$1();
3055
+ deepElementFromPoint = (x, y) => {
3056
+ const element = scope.document.elementFromPoint(x, y);
3057
+ const crawlShadows = (node) => {
3058
+ if (node && node.shadowRoot) {
3059
+ const nestedElement = node.shadowRoot.elementFromPoint(x, y);
3060
+ if (node.isEqualNode(nestedElement)) return node;
3061
+ if (nestedElement.shadowRoot) return crawlShadows(nestedElement);
3062
+ return nestedElement;
3063
+ }
3064
+ return node;
3065
+ };
3066
+ return crawlShadows(element) || element;
3067
+ };
3068
+ })))();
3069
+ }
3070
+ //#endregion
3071
+ //#region src/measure/withMeasure.ts
3072
+ function findAndDrawElement(x, y) {
3073
+ nodeAtPointerRef = deepElementFromPoint(x, y);
3074
+ drawSelectedElement(nodeAtPointerRef);
3075
+ }
3076
+ var nodeAtPointerRef, pointer, withMeasure;
3077
+ function init_withMeasure() {
3078
+ return (init_withMeasure = __esmMin((() => {
3079
+ init_preview_api$1();
3080
+ init_canvas();
3081
+ init_visualizer();
3082
+ init_util();
3083
+ pointer = {
3084
+ x: 0,
3085
+ y: 0
3086
+ };
3087
+ withMeasure = (StoryFn, context) => {
3088
+ const { measureEnabled } = context.globals || {};
3089
+ const measureActive = measureEnabled && !context.parameters?.measure?.disable;
3090
+ useEffect(() => {
3091
+ if (typeof globalThis.document === "undefined") return;
3092
+ const onPointerMove = (event) => {
3093
+ window.requestAnimationFrame(() => {
3094
+ event.stopPropagation();
3095
+ pointer.x = event.clientX;
3096
+ pointer.y = event.clientY;
3097
+ });
3098
+ };
3099
+ globalThis.document.addEventListener("pointermove", onPointerMove);
3100
+ return () => {
3101
+ globalThis.document.removeEventListener("pointermove", onPointerMove);
3102
+ };
3103
+ }, []);
3104
+ useEffect(() => {
3105
+ const onPointerOver = (event) => {
3106
+ window.requestAnimationFrame(() => {
3107
+ event.stopPropagation();
3108
+ findAndDrawElement(event.clientX, event.clientY);
3109
+ });
3110
+ };
3111
+ const onResize = () => {
3112
+ window.requestAnimationFrame(() => {
3113
+ rescale();
3114
+ });
3115
+ };
3116
+ if (context.viewMode === "story" && measureActive) {
3117
+ globalThis.document.addEventListener("pointerover", onPointerOver);
3118
+ init();
3119
+ globalThis.window.addEventListener("resize", onResize);
3120
+ findAndDrawElement(pointer.x, pointer.y);
3121
+ }
3122
+ return () => {
3123
+ globalThis.window.removeEventListener("resize", onResize);
3124
+ destroy();
3125
+ };
3126
+ }, [measureActive, context.viewMode]);
3127
+ return StoryFn();
3128
+ };
3129
+ })))();
3130
+ }
3131
+ //#endregion
3132
+ //#region src/measure/preview.ts
3133
+ var decorators$1, initialGlobals$1, preview_default$1;
3134
+ function init_preview$4() {
3135
+ return (init_preview$4 = __esmMin((() => {
3136
+ init_constants$3();
3137
+ init_withMeasure();
3138
+ decorators$1 = globalThis.FEATURES?.measure ? [withMeasure] : [];
3139
+ initialGlobals$1 = { [PARAM_KEY$1]: false };
3140
+ preview_default$1 = () => definePreviewAddon({
3141
+ decorators: decorators$1,
3142
+ initialGlobals: initialGlobals$1
3143
+ });
3144
+ })))();
3145
+ }
3146
+ //#endregion
3147
+ //#region src/outline/constants.ts
3148
+ var PARAM_KEY;
3149
+ function init_constants$4() {
3150
+ return (init_constants$4 = __esmMin((() => {
3151
+ PARAM_KEY = "outline";
3152
+ })))();
3153
+ }
3154
+ //#endregion
3155
+ //#region src/outline/helpers.ts
3156
+ var clearStyles, clearStyle, addOutlineStyles;
3157
+ function init_helpers() {
3158
+ return (init_helpers = __esmMin((() => {
3159
+ init_dist$1();
3160
+ clearStyles = (selector) => {
3161
+ (Array.isArray(selector) ? selector : [selector]).forEach(clearStyle);
3162
+ };
3163
+ clearStyle = (input) => {
3164
+ const selector = typeof input === "string" ? input : input.join("");
3165
+ const element = scope.document.getElementById(selector);
3166
+ if (element && element.parentElement) element.parentElement.removeChild(element);
3167
+ };
3168
+ addOutlineStyles = (selector, css) => {
3169
+ const existingStyle = scope.document.getElementById(selector);
3170
+ if (existingStyle) {
3171
+ if (existingStyle.innerHTML !== css) existingStyle.innerHTML = css;
3172
+ } else {
3173
+ const style = scope.document.createElement("style");
3174
+ style.setAttribute("id", selector);
3175
+ style.innerHTML = css;
3176
+ scope.document.head.appendChild(style);
3177
+ }
3178
+ };
3179
+ })))();
3180
+ }
3181
+ //#endregion
3182
+ //#region src/outline/outlineCSS.ts
3183
+ function outlineCSS(selector) {
3184
+ return dedent`
3185
+ ${selector} body {
3186
+ outline: 1px solid #2980b9 !important;
3187
+ }
3188
+
3189
+ ${selector} article {
3190
+ outline: 1px solid #3498db !important;
3191
+ }
3192
+
3193
+ ${selector} nav {
3194
+ outline: 1px solid #0088c3 !important;
3195
+ }
3196
+
3197
+ ${selector} aside {
3198
+ outline: 1px solid #33a0ce !important;
3199
+ }
3200
+
3201
+ ${selector} section {
3202
+ outline: 1px solid #66b8da !important;
3203
+ }
3204
+
3205
+ ${selector} header {
3206
+ outline: 1px solid #99cfe7 !important;
3207
+ }
3208
+
3209
+ ${selector} footer {
3210
+ outline: 1px solid #cce7f3 !important;
3211
+ }
3212
+
3213
+ ${selector} h1 {
3214
+ outline: 1px solid #162544 !important;
3215
+ }
3216
+
3217
+ ${selector} h2 {
3218
+ outline: 1px solid #314e6e !important;
3219
+ }
3220
+
3221
+ ${selector} h3 {
3222
+ outline: 1px solid #3e5e85 !important;
3223
+ }
3224
+
3225
+ ${selector} h4 {
3226
+ outline: 1px solid #449baf !important;
3227
+ }
3228
+
3229
+ ${selector} h5 {
3230
+ outline: 1px solid #c7d1cb !important;
3231
+ }
3232
+
3233
+ ${selector} h6 {
3234
+ outline: 1px solid #4371d0 !important;
3235
+ }
3236
+
3237
+ ${selector} main {
3238
+ outline: 1px solid #2f4f90 !important;
3239
+ }
3240
+
3241
+ ${selector} address {
3242
+ outline: 1px solid #1a2c51 !important;
3243
+ }
3244
+
3245
+ ${selector} div {
3246
+ outline: 1px solid #036cdb !important;
3247
+ }
3248
+
3249
+ ${selector} p {
3250
+ outline: 1px solid #ac050b !important;
3251
+ }
3252
+
3253
+ ${selector} hr {
3254
+ outline: 1px solid #ff063f !important;
3255
+ }
3256
+
3257
+ ${selector} pre {
3258
+ outline: 1px solid #850440 !important;
3259
+ }
3260
+
3261
+ ${selector} blockquote {
3262
+ outline: 1px solid #f1b8e7 !important;
3263
+ }
3264
+
3265
+ ${selector} ol {
3266
+ outline: 1px solid #ff050c !important;
3267
+ }
3268
+
3269
+ ${selector} ul {
3270
+ outline: 1px solid #d90416 !important;
3271
+ }
3272
+
3273
+ ${selector} li {
3274
+ outline: 1px solid #d90416 !important;
3275
+ }
3276
+
3277
+ ${selector} dl {
3278
+ outline: 1px solid #fd3427 !important;
3279
+ }
3280
+
3281
+ ${selector} dt {
3282
+ outline: 1px solid #ff0043 !important;
3283
+ }
3284
+
3285
+ ${selector} dd {
3286
+ outline: 1px solid #e80174 !important;
3287
+ }
3288
+
3289
+ ${selector} figure {
3290
+ outline: 1px solid #ff00bb !important;
3291
+ }
3292
+
3293
+ ${selector} figcaption {
3294
+ outline: 1px solid #bf0032 !important;
3295
+ }
3296
+
3297
+ ${selector} table {
3298
+ outline: 1px solid #00cc99 !important;
3299
+ }
3300
+
3301
+ ${selector} caption {
3302
+ outline: 1px solid #37ffc4 !important;
3303
+ }
3304
+
3305
+ ${selector} thead {
3306
+ outline: 1px solid #98daca !important;
3307
+ }
3308
+
3309
+ ${selector} tbody {
3310
+ outline: 1px solid #64a7a0 !important;
3311
+ }
3312
+
3313
+ ${selector} tfoot {
3314
+ outline: 1px solid #22746b !important;
3315
+ }
3316
+
3317
+ ${selector} tr {
3318
+ outline: 1px solid #86c0b2 !important;
3319
+ }
3320
+
3321
+ ${selector} th {
3322
+ outline: 1px solid #a1e7d6 !important;
3323
+ }
3324
+
3325
+ ${selector} td {
3326
+ outline: 1px solid #3f5a54 !important;
3327
+ }
3328
+
3329
+ ${selector} col {
3330
+ outline: 1px solid #6c9a8f !important;
3331
+ }
3332
+
3333
+ ${selector} colgroup {
3334
+ outline: 1px solid #6c9a9d !important;
3335
+ }
3336
+
3337
+ ${selector} button {
3338
+ outline: 1px solid #da8301 !important;
3339
+ }
3340
+
3341
+ ${selector} datalist {
3342
+ outline: 1px solid #c06000 !important;
3343
+ }
3344
+
3345
+ ${selector} fieldset {
3346
+ outline: 1px solid #d95100 !important;
3347
+ }
3348
+
3349
+ ${selector} form {
3350
+ outline: 1px solid #d23600 !important;
3351
+ }
3352
+
3353
+ ${selector} input {
3354
+ outline: 1px solid #fca600 !important;
3355
+ }
3356
+
3357
+ ${selector} keygen {
3358
+ outline: 1px solid #b31e00 !important;
3359
+ }
3360
+
3361
+ ${selector} label {
3362
+ outline: 1px solid #ee8900 !important;
3363
+ }
3364
+
3365
+ ${selector} legend {
3366
+ outline: 1px solid #de6d00 !important;
3367
+ }
3368
+
3369
+ ${selector} meter {
3370
+ outline: 1px solid #e8630c !important;
3371
+ }
3372
+
3373
+ ${selector} optgroup {
3374
+ outline: 1px solid #b33600 !important;
3375
+ }
3376
+
3377
+ ${selector} option {
3378
+ outline: 1px solid #ff8a00 !important;
3379
+ }
3380
+
3381
+ ${selector} output {
3382
+ outline: 1px solid #ff9619 !important;
3383
+ }
3384
+
3385
+ ${selector} progress {
3386
+ outline: 1px solid #e57c00 !important;
3387
+ }
3388
+
3389
+ ${selector} select {
3390
+ outline: 1px solid #e26e0f !important;
3391
+ }
3392
+
3393
+ ${selector} textarea {
3394
+ outline: 1px solid #cc5400 !important;
3395
+ }
3396
+
3397
+ ${selector} details {
3398
+ outline: 1px solid #33848f !important;
3399
+ }
3400
+
3401
+ ${selector} summary {
3402
+ outline: 1px solid #60a1a6 !important;
3403
+ }
3404
+
3405
+ ${selector} command {
3406
+ outline: 1px solid #438da1 !important;
3407
+ }
3408
+
3409
+ ${selector} menu {
3410
+ outline: 1px solid #449da6 !important;
3411
+ }
3412
+
3413
+ ${selector} del {
3414
+ outline: 1px solid #bf0000 !important;
3415
+ }
3416
+
3417
+ ${selector} ins {
3418
+ outline: 1px solid #400000 !important;
3419
+ }
3420
+
3421
+ ${selector} img {
3422
+ outline: 1px solid #22746b !important;
3423
+ }
3424
+
3425
+ ${selector} iframe {
3426
+ outline: 1px solid #64a7a0 !important;
3427
+ }
3428
+
3429
+ ${selector} embed {
3430
+ outline: 1px solid #98daca !important;
3431
+ }
3432
+
3433
+ ${selector} object {
3434
+ outline: 1px solid #00cc99 !important;
3435
+ }
3436
+
3437
+ ${selector} param {
3438
+ outline: 1px solid #37ffc4 !important;
3439
+ }
3440
+
3441
+ ${selector} video {
3442
+ outline: 1px solid #6ee866 !important;
3443
+ }
3444
+
3445
+ ${selector} audio {
3446
+ outline: 1px solid #027353 !important;
3447
+ }
3448
+
3449
+ ${selector} source {
3450
+ outline: 1px solid #012426 !important;
3451
+ }
3452
+
3453
+ ${selector} canvas {
3454
+ outline: 1px solid #a2f570 !important;
3455
+ }
3456
+
3457
+ ${selector} track {
3458
+ outline: 1px solid #59a600 !important;
3459
+ }
3460
+
3461
+ ${selector} map {
3462
+ outline: 1px solid #7be500 !important;
3463
+ }
3464
+
3465
+ ${selector} area {
3466
+ outline: 1px solid #305900 !important;
3467
+ }
3468
+
3469
+ ${selector} a {
3470
+ outline: 1px solid #ff62ab !important;
3471
+ }
3472
+
3473
+ ${selector} em {
3474
+ outline: 1px solid #800b41 !important;
3475
+ }
3476
+
3477
+ ${selector} strong {
3478
+ outline: 1px solid #ff1583 !important;
3479
+ }
3480
+
3481
+ ${selector} i {
3482
+ outline: 1px solid #803156 !important;
3483
+ }
3484
+
3485
+ ${selector} b {
3486
+ outline: 1px solid #cc1169 !important;
3487
+ }
3488
+
3489
+ ${selector} u {
3490
+ outline: 1px solid #ff0430 !important;
3491
+ }
3492
+
3493
+ ${selector} s {
3494
+ outline: 1px solid #f805e3 !important;
3495
+ }
3496
+
3497
+ ${selector} small {
3498
+ outline: 1px solid #d107b2 !important;
3499
+ }
3500
+
3501
+ ${selector} abbr {
3502
+ outline: 1px solid #4a0263 !important;
3503
+ }
3504
+
3505
+ ${selector} q {
3506
+ outline: 1px solid #240018 !important;
3507
+ }
3508
+
3509
+ ${selector} cite {
3510
+ outline: 1px solid #64003c !important;
3511
+ }
3512
+
3513
+ ${selector} dfn {
3514
+ outline: 1px solid #b4005a !important;
3515
+ }
3516
+
3517
+ ${selector} sub {
3518
+ outline: 1px solid #dba0c8 !important;
3519
+ }
3520
+
3521
+ ${selector} sup {
3522
+ outline: 1px solid #cc0256 !important;
3523
+ }
3524
+
3525
+ ${selector} time {
3526
+ outline: 1px solid #d6606d !important;
3527
+ }
3528
+
3529
+ ${selector} code {
3530
+ outline: 1px solid #e04251 !important;
3531
+ }
3532
+
3533
+ ${selector} kbd {
3534
+ outline: 1px solid #5e001f !important;
3535
+ }
3536
+
3537
+ ${selector} samp {
3538
+ outline: 1px solid #9c0033 !important;
3539
+ }
3540
+
3541
+ ${selector} var {
3542
+ outline: 1px solid #d90047 !important;
3543
+ }
3544
+
3545
+ ${selector} mark {
3546
+ outline: 1px solid #ff0053 !important;
3547
+ }
3548
+
3549
+ ${selector} bdi {
3550
+ outline: 1px solid #bf3668 !important;
3551
+ }
3552
+
3553
+ ${selector} bdo {
3554
+ outline: 1px solid #6f1400 !important;
3555
+ }
3556
+
3557
+ ${selector} ruby {
3558
+ outline: 1px solid #ff7b93 !important;
3559
+ }
3560
+
3561
+ ${selector} rt {
3562
+ outline: 1px solid #ff2f54 !important;
3563
+ }
3564
+
3565
+ ${selector} rp {
3566
+ outline: 1px solid #803e49 !important;
3567
+ }
3568
+
3569
+ ${selector} span {
3570
+ outline: 1px solid #cc2643 !important;
3571
+ }
3572
+
3573
+ ${selector} br {
3574
+ outline: 1px solid #db687d !important;
3575
+ }
3576
+
3577
+ ${selector} wbr {
3578
+ outline: 1px solid #db175b !important;
3579
+ }`;
3580
+ }
3581
+ function init_outlineCSS() {
3582
+ return (init_outlineCSS = __esmMin((() => {
3583
+ init_esm();
3584
+ })))();
3585
+ }
3586
+ //#endregion
3587
+ //#region src/outline/withOutline.ts
3588
+ var withOutline;
3589
+ function init_withOutline() {
3590
+ return (init_withOutline = __esmMin((() => {
3591
+ init_preview_api$1();
3592
+ init_constants$4();
3593
+ init_helpers();
3594
+ init_outlineCSS();
3595
+ withOutline = (StoryFn, context) => {
3596
+ const globals = context.globals || {};
3597
+ const isActive = !context.parameters?.["outline"]?.disable && [true, "true"].includes(globals["outline"]);
3598
+ const isInDocs = context.viewMode === "docs";
3599
+ const outlineStyles = useMemo(() => {
3600
+ return outlineCSS(isInDocs ? `[data-story-block="true"]` : ".sb-show-main");
3601
+ }, [context]);
3602
+ useEffect(() => {
3603
+ const selectorId = isInDocs ? `addon-outline-docs-${context.id}` : `addon-outline`;
3604
+ if (!isActive) clearStyles(selectorId);
3605
+ else addOutlineStyles(selectorId, outlineStyles);
3606
+ return () => {
3607
+ clearStyles(selectorId);
3608
+ };
3609
+ }, [
3610
+ isActive,
3611
+ outlineStyles,
3612
+ context
3613
+ ]);
3614
+ return StoryFn();
3615
+ };
3616
+ })))();
3617
+ }
3618
+ //#endregion
3619
+ //#region src/outline/preview.ts
3620
+ var decorators, initialGlobals, preview_default;
3621
+ function init_preview$5() {
3622
+ return (init_preview$5 = __esmMin((() => {
3623
+ init_constants$4();
3624
+ init_withOutline();
3625
+ decorators = globalThis.FEATURES?.outline ? [withOutline] : [];
3626
+ initialGlobals = { [PARAM_KEY]: false };
3627
+ preview_default = () => definePreviewAddon({
3628
+ decorators,
3629
+ initialGlobals
3630
+ });
3631
+ })))();
3632
+ }
3633
+ //#endregion
3634
+ //#region src/docs-tools/shared.ts
3635
+ var ADDON_ID, SNIPPET_RENDERED;
3636
+ function init_shared() {
3637
+ return (init_shared = __esmMin((() => {
3638
+ ADDON_ID = "@aussieljk/forkbook/docs";
3639
+ SNIPPET_RENDERED = `${ADDON_ID}/snippet-rendered`;
3640
+ })))();
3641
+ }
3642
+ //#endregion
3643
+ //#region src/docs-tools/storyDocsCodePanel.ts
3644
+ /**
3645
+ * Whether the preview story-docs hook should skip emitting a snippet to the manager Code panel.
3646
+ *
3647
+ * The args/source shape logic mirrors {@link skipJsxRender} in the React `jsxDecorator`, so static
3648
+ * service snippets replace dynamic JSX rendering under the same conditions. It additionally skips
3649
+ * portable stories (vitest, playwright/jest portable): those have no manager Code panel and no OSA
3650
+ * server peer, so the `extractStoryDocs` remote command has no handler and would reject after the
3651
+ * ack timeout — there is nothing to emit to.
3652
+ */
3653
+ function shouldSkipStoryDocsEmit(parameters) {
3654
+ const sourceParams = parameters?.docs?.source;
3655
+ const isArgsStory = parameters?.__isArgsStory;
3656
+ if (parameters?.__isPortableStory) return true;
3657
+ if (sourceParams?.type === "dynamic") return false;
3658
+ return !isArgsStory || sourceParams?.code !== void 0 || sourceParams?.type === "code";
3659
+ }
3660
+ function init_storyDocsCodePanel() {
3661
+ return (init_storyDocsCodePanel = __esmMin((() => {
3662
+ init_shared();
3663
+ })))();
3664
+ }
3665
+ //#endregion
3666
+ //#region src/csf/core-annotations.ts
3667
+ /** Flag a project-annotations object as already containing the core annotations. */
3668
+ function markAsComposedWithCoreAnnotations(annotations) {
3669
+ Object.defineProperty(annotations, CORE_ANNOTATIONS_COMPOSED, {
3670
+ value: true,
3671
+ enumerable: false,
3672
+ configurable: true,
3673
+ writable: true
3674
+ });
3675
+ return annotations;
3676
+ }
3677
+ /** Whether a project-annotations object already contains the core annotations. */
3678
+ function hasCoreAnnotations(annotations) {
3679
+ return annotations != null && typeof annotations === "object" && annotations[CORE_ANNOTATIONS_COMPOSED] === true;
3680
+ }
3681
+ function getCoreAnnotations() {
3682
+ return [
3683
+ (preview_default$1.default ?? preview_default$1)(),
3684
+ (preview_default$4.default ?? preview_default$4)(),
3685
+ (preview_default$2.default ?? preview_default$2)(),
3686
+ (preview_default.default ?? preview_default)(),
3687
+ (preview_default$8.default ?? preview_default$8)(),
3688
+ (preview_default$5.default ?? preview_default$5)(),
3689
+ (preview_default$3.default ?? preview_default$3)(),
3690
+ (preview_default$9.default ?? preview_default$9)(),
3691
+ (test_annotations_default.default ?? test_annotations_default)(),
3692
+ (preview_default$6.default ?? preview_default$6)(),
3693
+ (preview_default$7.default ?? preview_default$7)()
3694
+ ];
3695
+ }
3696
+ var CORE_ANNOTATIONS_COMPOSED;
3697
+ function init_core_annotations() {
3698
+ return (init_core_annotations = __esmMin((() => {
3699
+ init_preview();
3700
+ init_preview$1();
3701
+ init_preview$2();
3702
+ init_test_annotations();
3703
+ init_preview$3();
3704
+ init_preview$4();
3705
+ init_preview$5();
3706
+ init_preview$6();
3707
+ init_preview$7();
3708
+ init_preview$9();
3709
+ init_preview$8();
3710
+ CORE_ANNOTATIONS_COMPOSED = Symbol.for("storybook.internal.composedWithCoreAnnotations");
3711
+ })))();
3712
+ }
3713
+ //#endregion
3714
+ //#region src/csf/csf-factories.ts
3715
+ function definePreviewAddon(preview) {
3716
+ return preview;
3717
+ }
3718
+ function isMeta(input) {
3719
+ return input != null && typeof input === "object" && "_tag" in input && input?._tag === "Meta";
3720
+ }
3721
+ function isStory(input) {
3722
+ return input != null && typeof input === "object" && "_tag" in input && input?._tag === "Story";
3723
+ }
3724
+ function getStoryChildren(story) {
3725
+ if ("__children" in story) return story.__children;
3726
+ return [];
3727
+ }
3728
+ function init_csf_factories() {
3729
+ return (init_csf_factories = __esmMin((() => {})))();
3730
+ }
3731
+ //#endregion
3732
+ //#region src/actions/runtime/configureActions.ts
3733
+ var config, configureActions;
3734
+ function init_configureActions() {
3735
+ return (init_configureActions = __esmMin((() => {
3736
+ config = {
3737
+ depth: 10,
3738
+ clearOnStoryChange: true,
3739
+ limit: 50
3740
+ };
3741
+ configureActions = (options = {}) => {
3742
+ Object.assign(config, options);
3743
+ };
3744
+ })))();
3745
+ }
3746
+ //#endregion
3747
+ //#region src/actions/runtime/action.ts
3748
+ function action(name, options = {}) {
3749
+ const actionOptions = {
3750
+ ...config,
3751
+ ...options
3752
+ };
3753
+ const handler = function actionHandler(...args) {
3754
+ if (options.implicit) {
3755
+ const storyRenderer = ("__STORYBOOK_PREVIEW__" in scope ? scope.__STORYBOOK_PREVIEW__ : void 0)?.storyRenders.find((render) => render.phase === "playing" || render.phase === "rendering");
3756
+ if (storyRenderer) {
3757
+ const deprecated = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8;
3758
+ const error = new ImplicitActionsDuringRendering({
3759
+ phase: storyRenderer.phase,
3760
+ name,
3761
+ deprecated
3762
+ });
3763
+ if (deprecated) console.warn(error);
3764
+ else throw error;
3765
+ }
3766
+ }
3767
+ const channel = addons$1.getChannel();
3768
+ const id = Date.now().toString(36) + Math.random().toString(36).substring(2);
3769
+ const minDepth = 5;
3770
+ const serializedArgs = args.map(serializeArg);
3771
+ const actionDisplayToEmit = {
3772
+ id,
3773
+ count: 0,
3774
+ data: {
3775
+ name,
3776
+ args: args.length > 1 ? serializedArgs : serializedArgs[0]
3777
+ },
3778
+ options: {
3779
+ ...actionOptions,
3780
+ maxDepth: minDepth + (actionOptions.depth || 3)
3781
+ }
3782
+ };
3783
+ channel.emit(EVENT_ID, actionDisplayToEmit);
3784
+ };
3785
+ handler.isAction = true;
3786
+ handler.implicit = options.implicit;
3787
+ return handler;
3788
+ }
3789
+ var findProto, isReactSyntheticEvent, serializeArg;
3790
+ function init_action() {
3791
+ return (init_action = __esmMin((() => {
3792
+ init_preview_errors();
3793
+ init_dist$1();
3794
+ init_preview_api$1();
3795
+ init_constants();
3796
+ init_configureActions();
3797
+ findProto = (obj, callback) => {
3798
+ const proto = Object.getPrototypeOf(obj);
3799
+ if (!proto || callback(proto)) return proto;
3800
+ return findProto(proto, callback);
3801
+ };
3802
+ isReactSyntheticEvent = (e) => Boolean(typeof e === "object" && e && findProto(e, (proto) => /^Synthetic(?:Base)?Event$/.test(proto.constructor.name)) && typeof e.persist === "function");
3803
+ serializeArg = (a) => {
3804
+ if (isReactSyntheticEvent(a)) {
3805
+ const e = Object.create(a.constructor.prototype, Object.getOwnPropertyDescriptors(a));
3806
+ e.persist();
3807
+ const viewDescriptor = Object.getOwnPropertyDescriptor(e, "view");
3808
+ const view = viewDescriptor?.value;
3809
+ if (typeof view === "object" && view?.constructor.name === "Window") Object.defineProperty(e, "view", {
3810
+ ...viewDescriptor,
3811
+ value: Object.create(view.constructor.prototype)
3812
+ });
3813
+ return e;
3814
+ }
3815
+ return a;
3816
+ };
3817
+ })))();
3818
+ }
3819
+ //#endregion
3820
+ //#region src/actions/runtime/actions.ts
3821
+ var actions;
3822
+ function init_actions() {
3823
+ return (init_actions = __esmMin((() => {
3824
+ init_action();
3825
+ init_configureActions();
3826
+ actions = (...args) => {
3827
+ let options = config;
3828
+ let names = args;
3829
+ if (names.length === 1 && Array.isArray(names[0])) [names] = names;
3830
+ if (names.length !== 1 && typeof names[names.length - 1] !== "string") options = {
3831
+ ...config,
3832
+ ...names.pop()
3833
+ };
3834
+ let namesObject = names[0];
3835
+ if (names.length !== 1 || typeof namesObject === "string") {
3836
+ namesObject = {};
3837
+ names.forEach((name) => {
3838
+ namesObject[name] = name;
3839
+ });
3840
+ }
3841
+ const actionsObject = {};
3842
+ Object.keys(namesObject).forEach((name) => {
3843
+ actionsObject[name] = action(namesObject[name], options);
3844
+ });
3845
+ return actionsObject;
3846
+ };
3847
+ })))();
3848
+ }
3849
+ //#endregion
3850
+ //#region src/actions/index.ts
3851
+ var actions_exports = /* @__PURE__ */ __exportAll({
3852
+ ADDON_ID: () => ADDON_ID$2,
3853
+ CLEAR_ID: () => CLEAR_ID,
3854
+ CYCLIC_KEY: () => CYCLIC_KEY,
3855
+ EVENT_ID: () => EVENT_ID,
3856
+ PANEL_ID: () => PANEL_ID,
3857
+ PARAM_KEY: () => PARAM_KEY$3,
3858
+ action: () => action,
3859
+ actions: () => actions,
3860
+ config: () => config,
3861
+ configureActions: () => configureActions
3862
+ });
3863
+ function init_actions$1() {
3864
+ return (init_actions$1 = __esmMin((() => {
3865
+ init_constants();
3866
+ init_action();
3867
+ init_actions();
3868
+ init_configureActions();
3869
+ })))();
3870
+ }
3871
+ //#endregion
3872
+ export { RESET_STORY_ARGS as $, channels_exports as A, init_manager_errors as At, CONFIG_ERROR as B, toId as C, deprecate as Ct, storyNameFromExport as D, OpenServiceStaticSnapshotInvalidError as Dt, isExportStory as E, once as Et, init_channel_slot as F, FORCE_RE_RENDER as G, DOCS_PREPARED as H, installNoopChannel as I, NAVIGATE_URL as J, GLOBALS_UPDATED as K, setChannel as L, clearChannel as M, ensureChannel as N, init_mock_channel as O, OpenServiceStaticSnapshotLoadError as Ot, getChannel as P, PREVIEW_KEYDOWN as Q, ARGTYPES_INFO_REQUEST as R, sanitize as S, client_logger_exports as St, init_export_story as T, logger as Tt, DOCS_RENDERED as U, CURRENT_STORY_WAS_SET as V, FORCE_REMOUNT as W, PRELOAD_ENTRIES as X, PLAY_FUNCTION_THREW_EXCEPTION as Y, PREVIEW_INITIALIZED as Z, instrument as _, UPDATE_GLOBALS as _t, init_csf_factories as a, STORY_FINISHED as at, combineTags as b, core_events_exports as bt, getCoreAnnotations as c, STORY_MISSING as ct, markAsComposedWithCoreAnnotations as d, STORY_RENDER_PHASE_CHANGED as dt, SET_CURRENT_STORY as et, init_storyDocsCodePanel as f, STORY_SPECIFIED as ft, init_instrumenter as g, UNHANDLED_ERRORS_WHILE_PLAYING as gt, init_shared as h, TELEMETRY_ERROR as ht, getStoryChildren as i, STORY_ERRORED as it, init_channels as j, mockChannel as k, UniversalStoreFollowerTimeoutError as kt, hasCoreAnnotations as l, STORY_PREPARED as lt, SNIPPET_RENDERED as m, STORY_UNCHANGED as mt, init_actions$1 as n, STORY_ARGS_UPDATED as nt, isMeta as o, STORY_HOT_UPDATED as ot, shouldSkipStoryDocsEmit as p, STORY_THREW_EXCEPTION as pt, MANAGER_INERT_ATTRIBUTE_CHANGED as q, definePreviewAddon as r, STORY_CHANGED as rt, isStory as s, STORY_INDEX_INVALIDATED as st, actions_exports as t, SET_GLOBALS as tt, init_core_annotations as u, STORY_RENDERED as ut, includeConditionalArg as v, UPDATE_QUERY_PARAMS as vt, toTestId as w, init_client_logger as wt, init_csf_utils as x, init_core_events as xt, init_includeConditionalArg as y, UPDATE_STORY_ARGS as yt, ARGTYPES_INFO_RESPONSE as z };