"use strict";
var y = Object.create;
var i = Object.defineProperty;
var h = Object.getOwnPropertyDescriptor;
var l = Object.getOwnPropertyNames;
var d = Object.getPrototypeOf, v = Object.prototype.hasOwnProperty;
var u = (e, r, o, s) => {
  if (r && typeof r == "object" || typeof r == "function")
    for (let c of l(r))
      !v.call(e, c) && c !== o && i(e, c, { get: () => r[c], enumerable: !(s = h(r, c)) || s.enumerable });
  return e;
};
var k = (e, r, o) => (o = e != null ? y(d(e)) : {}, 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.
  r || !e || !e.__esModule ? i(o, "default", { value: e, enumerable: !0 }) : o,
  e
));

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

// src/common/versions.ts
var a = {
  "@storybook/addon-a11y": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/addon-docs": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/addon-jest": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/addon-links": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/addon-onboarding": "0.0.0-pr-31893-sha-9eb4ec95",
  "storybook-addon-pseudo-states": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/addon-themes": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/addon-vitest": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/builder-vite": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/builder-webpack5": "0.0.0-pr-31893-sha-9eb4ec95",
  storybook: "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/angular": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/ember": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/html-vite": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/nextjs": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/experimental-nextjs-rsc": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/nextjs-vite": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/preact-vite": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/react-native-web-vite": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/react-vite": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/react-webpack5": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/server-webpack5": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/svelte-vite": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/sveltekit": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/vue3-vite": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/web-components-vite": "0.0.0-pr-31893-sha-9eb4ec95",
  sb: "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/cli": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/codemod": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/core-webpack": "0.0.0-pr-31893-sha-9eb4ec95",
  "create-storybook": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/csf-plugin": "0.0.0-pr-31893-sha-9eb4ec95",
  "eslint-plugin-storybook": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/react-dom-shim": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/preset-create-react-app": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/preset-react-webpack": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/preset-server-webpack": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/html": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/preact": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/react": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/server": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/svelte": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/vue3": "0.0.0-pr-31893-sha-9eb4ec95",
  "@storybook/web-components": "0.0.0-pr-31893-sha-9eb4ec95"
};

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