'use strict';

var chunkQXUST7PY = require('./chunk-QXUST7PY.js');
var chunkJZLCHNYA = require('./chunk-JZLCHNYA.js');
var chunkS3R3BYOJ = require('./chunk-S3R3BYOJ.js');
var chunkABZYJK2D = require('./chunk-ABZYJK2D.js');
var chunkAGHRB4JF = require('./chunk-AGHRB4JF.js');

// src/internals.ts
var internalHelpers = {
  common: chunkABZYJK2D.common_default,
  getConfig: chunkABZYJK2D.getConfig,
  insertCluster: chunkJZLCHNYA.insertCluster,
  insertEdge: chunkQXUST7PY.insertEdge,
  insertEdgeLabel: chunkQXUST7PY.insertEdgeLabel,
  insertMarkers: chunkQXUST7PY.markers_default,
  insertNode: chunkJZLCHNYA.insertNode,
  interpolateToCurve: chunkS3R3BYOJ.interpolateToCurve,
  labelHelper: chunkJZLCHNYA.labelHelper,
  log: chunkAGHRB4JF.log,
  positionEdgeLabel: chunkQXUST7PY.positionEdgeLabel
};

// src/rendering-util/render.ts
var layoutAlgorithms = {};
var registerLayoutLoaders = /* @__PURE__ */ chunkAGHRB4JF.__name((loaders) => {
  for (const loader of loaders) {
    layoutAlgorithms[loader.name] = loader;
  }
}, "registerLayoutLoaders");
var registerDefaultLayoutLoaders = /* @__PURE__ */ chunkAGHRB4JF.__name(() => {
  registerLayoutLoaders([
    {
      name: "dagre",
      loader: /* @__PURE__ */ chunkAGHRB4JF.__name(async () => await Promise.resolve().then(function () { return require('./dagre-6UL2VRFP.js'); }), "loader")
    },
    ...[
      {
        name: "cose-bilkent",
        loader: /* @__PURE__ */ chunkAGHRB4JF.__name(async () => await Promise.resolve().then(function () { return require('./cose-bilkent-S5V4N54A.js'); }), "loader")
      }
    ] 
  ]);
}, "registerDefaultLayoutLoaders");
registerDefaultLayoutLoaders();
var render = /* @__PURE__ */ chunkAGHRB4JF.__name(async (data4Layout, svg) => {
  if (!(data4Layout.layoutAlgorithm in layoutAlgorithms)) {
    throw new Error(`Unknown layout algorithm: ${data4Layout.layoutAlgorithm}`);
  }
  const layoutDefinition = layoutAlgorithms[data4Layout.layoutAlgorithm];
  const layoutRenderer = await layoutDefinition.loader();
  return layoutRenderer.render(data4Layout, svg, internalHelpers, {
    algorithm: layoutDefinition.algorithm
  });
}, "render");
var getRegisteredLayoutAlgorithm = /* @__PURE__ */ chunkAGHRB4JF.__name((algorithm = "", { fallback = "dagre" } = {}) => {
  if (algorithm in layoutAlgorithms) {
    return algorithm;
  }
  if (fallback in layoutAlgorithms) {
    chunkAGHRB4JF.log.warn(`Layout algorithm ${algorithm} is not registered. Using ${fallback} as fallback.`);
    return fallback;
  }
  throw new Error(`Both layout algorithms ${algorithm} and ${fallback} are not registered.`);
}, "getRegisteredLayoutAlgorithm");

exports.getRegisteredLayoutAlgorithm = getRegisteredLayoutAlgorithm;
exports.registerLayoutLoaders = registerLayoutLoaders;
exports.render = render;
