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

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

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

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