import CJS_COMPAT_NODE_URL_owuguwme69 from 'node:url';
import CJS_COMPAT_NODE_PATH_owuguwme69 from 'node:path';
import CJS_COMPAT_NODE_MODULE_owuguwme69 from "node:module";

var __filename = CJS_COMPAT_NODE_URL_owuguwme69.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_owuguwme69.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_owuguwme69.createRequire(import.meta.url);

// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
import {
  NODE_TARGET
} from "../_node-chunks/chunk-E3KXH4MU.js";
import {
  __name
} from "../_node-chunks/chunk-3YJXPC6V.js";

// src/bin/loader.ts
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { transform } from "esbuild";
var load = /* @__PURE__ */ __name(async (url, context, nextLoad) => {
  if (url.endsWith(".ts") || url.endsWith(".tsx") || url.endsWith(".mts") || url.endsWith(".cts") || url.endsWith(".mtsx") || url.endsWith(".ctsx")) {
    const rawSource = await readFile(fileURLToPath(url), "utf-8");
    const transformedSource = await transform(rawSource, {
      loader: "ts",
      target: NODE_TARGET,
      format: "esm",
      platform: "neutral"
    });
    return {
      format: "module",
      shortCircuit: true,
      source: transformedSource.code
    };
  }
  return nextLoad(url, context);
}, "load");
export {
  load
};
