"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 = (o, r, e, s) => {
  if (r && typeof r == "object" || typeof r == "function")
    for (let a of l(r))
      !v.call(o, a) && a !== e && i(o, a, { get: () => r[a], enumerable: !(s = h(r, a)) || s.enumerable });
  return o;
};
var k = (o, r, e) => (e = o != null ? y(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.
  r || !o || !o.__esModule ? i(e, "default", { value: o, enumerable: !0 }) : e,
  o
));

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

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

// src/bin/index.ts
var t = process.argv.slice(2);
if (["dev", "build", "index"].includes(t[0]))
  require("storybook/internal/cli/bin");
else {
  let o;
  if (t[0] === "init") {
    let e;
    try {
      e = require.resolve("create-storybook/package.json");
    } catch {
    }
    e ? JSON.parse((0, b.readFileSync)(e, "utf-8")).version === p["create-storybook"] && (o = [
      "node",
      (0, c.join)((0, c.dirname)(e), "bin", "index.cjs"),
      ...t.slice(1)
    ]) : o = ["npx", "--yes", `create-storybook@${p.storybook}`, ...t.slice(1)];
  } else {
    let e;
    try {
      e = require.resolve("@storybook/cli/package.json");
    } catch {
    }
    e ? JSON.parse((0, b.readFileSync)(e, "utf-8")).version === p["@storybook/cli"] && (o = ["node", (0, c.join)((0, c.dirname)(e), "bin", "\
index.cjs"), ...t]) : o = ["npx", "--yes", `@storybook/cli@${p.storybook}`, ...t];
  }
  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", (e) => {
    e != null && process.exit(e), process.exit(1);
  });
}
