"use strict";
var i = Object.create;
var h = Object.defineProperty;
var c = Object.getOwnPropertyDescriptor;
var d = Object.getOwnPropertyNames;
var l = Object.getPrototypeOf, v = Object.prototype.hasOwnProperty;
var u = (o, s, r, e) => {
  if (s && typeof s == "object" || typeof s == "function")
    for (let a of d(s))
      !v.call(o, a) && a !== r && h(o, a, { get: () => s[a], enumerable: !(e = c(s, a)) || e.enumerable });
  return o;
};
var y = (o, s, r) => (r = o != null ? i(l(o)) : {}, u(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  s || !o || !o.__esModule ? h(r, "default", { value: o, enumerable: !0 }) : r,
  o
));

// src/bin/index.ts
var n = require("node:child_process"), k = require("node:fs"), t = require("node:path");

// src/common/versions.ts
var p = {
  "@storybook/addon-a11y": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-actions": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-backgrounds": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-controls": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-docs": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-essentials": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-mdx-gfm": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-highlight": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-interactions": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-jest": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-links": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-measure": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-onboarding": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-outline": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-storysource": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-test": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-themes": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-toolbars": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/addon-viewport": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/builder-vite": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/builder-webpack5": "0.0.0-pr-30740-sha-04411b17",
  storybook: "0.0.0-pr-30740-sha-04411b17",
  "@storybook/angular": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/ember": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/experimental-nextjs-vite": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/html-vite": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/html-webpack5": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/nextjs": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preact-vite": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preact-webpack5": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/react-native-web-vite": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/react-vite": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/react-webpack5": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/server-webpack5": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/svelte-vite": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/svelte-webpack5": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/sveltekit": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/vue3-vite": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/vue3-webpack5": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/web-components-vite": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/web-components-webpack5": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/blocks": "0.0.0-pr-30740-sha-04411b17",
  sb: "0.0.0-pr-30740-sha-04411b17",
  "@storybook/cli": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/codemod": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/core-webpack": "0.0.0-pr-30740-sha-04411b17",
  "create-storybook": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/csf-plugin": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/react-dom-shim": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/source-loader": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/test": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preset-create-react-app": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preset-html-webpack": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preset-preact-webpack": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preset-react-webpack": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preset-server-webpack": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preset-svelte-webpack": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preset-vue3-webpack": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/html": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/preact": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/react": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/server": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/svelte": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/vue3": "0.0.0-pr-30740-sha-04411b17",
  "@storybook/web-components": "0.0.0-pr-30740-sha-04411b17"
};

// src/bin/index.ts
var b = process.argv.slice(2);
if (["dev", "build"].includes(b[0]))
  require("storybook/internal/cli/bin");
else {
  let o;
  if (b[0] === "init") {
    let r;
    try {
      r = require.resolve("create-storybook/package.json");
    } catch {
    }
    r ? JSON.parse((0, k.readFileSync)(r, "utf-8")).version === p["create-storybook"] && (o = [
      "node",
      (0, t.join)((0, t.dirname)(r), "bin", "index.cjs"),
      ...b.slice(1)
    ]) : o = ["npx", "--yes", `create-storybook@${p.storybook}`, ...b.slice(1)];
  } else {
    let r;
    try {
      r = require.resolve("@storybook/cli/package.json");
    } catch {
    }
    r ? JSON.parse((0, k.readFileSync)(r, "utf-8")).version === p["@storybook/cli"] && (o = ["node", (0, t.join)((0, t.dirname)(r), "bin", "\
index.cjs"), ...b]) : o = ["npx", "--yes", `@storybook/cli@${p.storybook}`, ...b];
  }
  o || (console.error("Could not run storybook cli, please report this as a bug"), process.exit(1)), (0, n.spawn)(o[0], o.slice(1), { stdio: "\
inherit", shell: !0 }).on("exit", (r) => {
    r != null && process.exit(r), process.exit(1);
  });
}
