"use strict";
var import_slug = require("./slug");
const cases = [];
function test(name, run) {
  cases.push({ name, run });
}
function assertEqual(actual, expected, msg) {
  const a = JSON.stringify(actual);
  const e = JSON.stringify(expected);
  if (a !== e) throw new Error(`${msg ?? "assertEqual"} \u2014 expected ${e}, got ${a}`);
}
test("slug: lowercases and replaces spaces with underscores", () => {
  assertEqual((0, import_slug.slug)("Add Product"), "add_product");
});
test("slug: replaces punctuation with underscores", () => {
  assertEqual((0, import_slug.slug)("Next: Select Country"), "next_select_country");
});
test("slug: collapses runs of separators", () => {
  assertEqual((0, import_slug.slug)("Foo   ---   Bar"), "foo_bar");
});
test("slug: strips leading and trailing underscores", () => {
  assertEqual((0, import_slug.slug)("  Hello  "), "hello");
  assertEqual((0, import_slug.slug)("_leading"), "leading");
  assertEqual((0, import_slug.slug)("trailing_"), "trailing");
});
test("slug: empty input returns empty string", () => {
  assertEqual((0, import_slug.slug)(""), "");
});
test("slug: all-non-alphanumeric input returns empty string", () => {
  assertEqual((0, import_slug.slug)("---"), "");
  assertEqual((0, import_slug.slug)("   "), "");
});
test("slug: preserves digits", () => {
  assertEqual((0, import_slug.slug)("Order 12"), "order_12");
});
test("slug: is idempotent on already-slug-like input", () => {
  assertEqual((0, import_slug.slug)("already_slug"), "already_slug");
});
test("slug: preserves CJK (Japanese)", () => {
  assertEqual((0, import_slug.slug)("\u8CC7\u7523\u7BA1\u7406"), "\u8CC7\u7523\u7BA1\u7406");
  assertEqual((0, import_slug.slug)("\u8CC7\u7523\u60C5\u5831"), "\u8CC7\u7523\u60C5\u5831");
  assertEqual((0, import_slug.slug)("\u4E00\u62EC\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9"), "\u4E00\u62EC\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9");
});
test("slug: preserves Cyrillic and lowercases it", () => {
  assertEqual((0, import_slug.slug)("\u0420\u0443\u0441\u0441\u043A\u0438\u0439"), "\u0440\u0443\u0441\u0441\u043A\u0438\u0439");
});
test("slug: preserves Arabic", () => {
  assertEqual((0, import_slug.slug)("\u0627\u0644\u0639\u0631\u0628\u064A\u0629"), "\u0627\u0644\u0639\u0631\u0628\u064A\u0629");
});
test("slug: preserves Korean", () => {
  assertEqual((0, import_slug.slug)("\uD55C\uAD6D\uC5B4"), "\uD55C\uAD6D\uC5B4");
});
test("slug: preserves accented Latin", () => {
  assertEqual((0, import_slug.slug)("r\xE9sum\xE9 caf\xE9"), "r\xE9sum\xE9_caf\xE9");
});
test("slug: mixed CJK + ASCII digits and whitespace", () => {
  assertEqual((0, import_slug.slug)("\u901A\u77E5 (1063)"), "\u901A\u77E5_1063");
});
test("slug: emoji and symbols are still separators", () => {
  assertEqual((0, import_slug.slug)("\u{1F600} emoji test"), "emoji_test");
  assertEqual((0, import_slug.slug)("foo \u2192 bar"), "foo_bar");
});
test("slug: output cannot contain the :: separator used by collision groups", () => {
  assertEqual((0, import_slug.slug)("a::b"), "a_b");
  assertEqual((0, import_slug.slug)("foo:bar:baz"), "foo_bar_baz");
});
let failed = 0;
for (const { name, run } of cases) {
  try {
    run();
    console.log("  \u2713", name);
  } catch (e) {
    failed++;
    console.log("  \u2717", name);
    console.log("     ", e.message);
  }
}
if (failed > 0) {
  console.log(`
${failed}/${cases.length} failed`);
  process.exit(1);
}
console.log(`
${cases.length} passed`);
