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

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

// src/common/versions.ts
var b = {
  "@storybook/addon-a11y": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-actions": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-backgrounds": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-controls": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-docs": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-jest": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-links": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-measure": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-onboarding": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-outline": "0.0.0-pr-30601-sha-69ee7af2",
  "storybook-addon-pseudo-states": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-themes": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-toolbars": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-viewport": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/addon-vitest": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/builder-vite": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/builder-webpack5": "0.0.0-pr-30601-sha-69ee7af2",
  storybook: "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/angular": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/ember": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/html-vite": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/nextjs": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/nextjs-vite": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/preact-vite": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/react-native-web-vite": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/react-vite": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/react-webpack5": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/server-webpack5": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/svelte-vite": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/sveltekit": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/vue3-vite": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/web-components-vite": "0.0.0-pr-30601-sha-69ee7af2",
  sb: "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/cli": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/codemod": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/core-webpack": "0.0.0-pr-30601-sha-69ee7af2",
  "create-storybook": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/csf-plugin": "0.0.0-pr-30601-sha-69ee7af2",
  "eslint-plugin-storybook": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/react-dom-shim": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/preset-create-react-app": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/preset-react-webpack": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/preset-server-webpack": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/html": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/preact": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/react": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/server": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/svelte": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/vue3": "0.0.0-pr-30601-sha-69ee7af2",
  "@storybook/web-components": "0.0.0-pr-30601-sha-69ee7af2"
};

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