var _a, _b, _c;
import { d as TreemapGrammarGeneratedModule, f as __name, g as createDefaultSharedCoreModule, h as createDefaultCoreModule, m as inject, n as AbstractMermaidValueConverter, p as EmptyFileSystem, s as MermaidGeneratedSharedModule, t as AbstractMermaidTokenBuilder } from "./chunk-TCCFYFTB-d3HOqL2I.js";
var TreemapTokenBuilder = (_a = class extends AbstractMermaidTokenBuilder {
  constructor() {
    super(["treemap"]);
  }
}, __name(_a, "TreemapTokenBuilder"), _a), classDefRegex = /classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/, TreemapValueConverter = (_b = class extends AbstractMermaidValueConverter {
  runCustomConverter(e, d, f) {
    if (e.name === "NUMBER2") return parseFloat(d.replace(/,/g, ""));
    if (e.name === "SEPARATOR" || e.name === "STRING2") return d.substring(1, d.length - 1);
    if (e.name === "INDENTATION") return d.length;
    if (e.name === "ClassDef") {
      if (typeof d != "string") return d;
      let e2 = classDefRegex.exec(d);
      if (e2) return {
        $type: "ClassDefStatement",
        className: e2[1],
        styleText: e2[2] || void 0
      };
    }
  }
}, __name(_b, "TreemapValueConverter"), _b);
function registerValidationChecks(e) {
  let d = e.validation.TreemapValidator, f = e.validation.ValidationRegistry;
  if (f) {
    let e2 = { Treemap: d.checkSingleRoot.bind(d) };
    f.register(e2, d);
  }
}
__name(registerValidationChecks, "registerValidationChecks");
var TreemapValidator = (_c = class {
  checkSingleRoot(e, d) {
    let f;
    for (let p of e.TreemapRows) p.item && (f === void 0 && p.indent === void 0 ? f = 0 : (p.indent === void 0 || f !== void 0 && f >= parseInt(p.indent, 10)) && d("error", "Multiple root nodes are not allowed in a treemap.", {
      node: p,
      property: "item"
    }));
  }
}, __name(_c, "TreemapValidator"), _c), TreemapModule = {
  parser: {
    TokenBuilder: /* @__PURE__ */ __name(() => new TreemapTokenBuilder(), "TokenBuilder"),
    ValueConverter: /* @__PURE__ */ __name(() => new TreemapValueConverter(), "ValueConverter")
  },
  validation: { TreemapValidator: /* @__PURE__ */ __name(() => new TreemapValidator(), "TreemapValidator") }
};
function createTreemapServices(d = EmptyFileSystem) {
  let m = inject(createDefaultSharedCoreModule(d), MermaidGeneratedSharedModule), h = inject(createDefaultCoreModule({ shared: m }), TreemapGrammarGeneratedModule, TreemapModule);
  return m.ServiceRegistry.register(h), registerValidationChecks(h), {
    shared: m,
    Treemap: h
  };
}
__name(createTreemapServices, "createTreemapServices");
export {
  createTreemapServices as n,
  TreemapModule as t
};
