{"version":3,"file":"strings.cjs","names":[],"sources":["../../src/utils/strings.ts"],"sourcesContent":["/**\n * Convert a string into a URL-safe slug.\n *\n * - Strips accents/diacritics.\n * - Lowercases.\n * - Replaces non-alphanumeric runs with `-`.\n * - Trims leading/trailing separators.\n *\n * @example\n * slugify(\"São Paulo / Centro\"); // \"sao-paulo-centro\"\n */\nexport function slugify(input: string): string {\n    return input\n        .normalize(\"NFD\")\n        .replace(/[̀-ͯ]/g, \"\")\n        .toLowerCase()\n        .replace(/[^a-z0-9]+/g, \"-\")\n        .replace(/^-+|-+$/g, \"\");\n}\n\n/**\n * Truncate a string to `max` characters, appending `suffix` when cut.\n * Returns the original when shorter than (or equal to) `max`.\n *\n * @example\n * truncate(\"The quick brown fox\", 12);              // \"The quick…\"\n * truncate(\"The quick brown fox\", 12, \" (more)\");   // \"The qu (more)\"\n */\nexport function truncate(input: string, max: number, suffix: string = \"…\"): string {\n    if (input.length <= max) return input;\n    const cut = Math.max(0, max - suffix.length);\n    return input.slice(0, cut).trimEnd() + suffix;\n}\n\n/**\n * Uppercase the first character of `value`, leaving the rest untouched.\n *\n * @example\n * capitalize(\"hello world\"); // \"Hello world\"\n * capitalize(\"\");            // \"\"\n */\nexport function capitalize(value: string): string {\n    if (value.length === 0) return value;\n    return value.charAt(0).toUpperCase() + value.slice(1);\n}\n\n/**\n * Convert `value` to `camelCase`.\n *\n * Splits on spaces, hyphens, underscores and other non-alphanumeric runs,\n * lowercases the first word, and capitalizes each subsequent word.\n *\n * @example\n * camelCase(\"hello world\");   // \"helloWorld\"\n * camelCase(\"foo-bar_baz\");   // \"fooBarBaz\"\n * camelCase(\"API response\");  // \"apiResponse\"\n */\nexport function camelCase(value: string): string {\n    const words = value\n        .replace(/[^a-zA-Z0-9]+/g, \" \")\n        .trim()\n        .split(/\\s+/)\n        .filter(Boolean);\n    if (words.length === 0) return \"\";\n    return words\n        .map((word, index) => {\n            const lower = word.toLowerCase();\n            return index === 0 ? lower : lower.charAt(0).toUpperCase() + lower.slice(1);\n        })\n        .join(\"\");\n}\n\n/**\n * Convert `value` to `kebab-case`.\n *\n * Splits camelCase boundaries and non-alphanumeric runs, then joins with `-`\n * and lowercases.\n *\n * @example\n * kebabCase(\"helloWorld\");   // \"hello-world\"\n * kebabCase(\"foo_bar baz\");  // \"foo-bar-baz\"\n * kebabCase(\"APIResponse\");  // \"api-response\"\n */\nexport function kebabCase(value: string): string {\n    return value\n        .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n        .replace(/([A-Z]+)([A-Z][a-z])/g, \"$1-$2\")\n        .replace(/[^a-zA-Z0-9]+/g, \"-\")\n        .replace(/^-+|-+$/g, \"\")\n        .toLowerCase();\n}\n\n/**\n * Pick the singular or plural form of a word based on `count`.\n *\n * Returns only the word (never the count). When `plural` is omitted it defaults\n * to `singular + \"s\"`.\n *\n * @example\n * pluralize(1, \"item\");            // \"item\"\n * pluralize(3, \"item\");            // \"items\"\n * pluralize(2, \"person\", \"people\"); // \"people\"\n */\nexport function pluralize(count: number, singular: string, plural?: string): string {\n    return count === 1 ? singular : (plural ?? `${singular}s`);\n}\n"],"mappings":"AAWA,SAAgB,EAAQ,EAAuB,CAC3C,OAAO,EACF,UAAU,KAAK,CAAC,CAChB,QAAQ,SAAU,EAAE,CAAC,CACrB,YAAY,CAAC,CACb,QAAQ,cAAe,GAAG,CAAC,CAC3B,QAAQ,WAAY,EAAE,CAC/B,CAUA,SAAgB,EAAS,EAAe,EAAa,EAAiB,IAAa,CAC/E,GAAI,EAAM,QAAU,EAAK,OAAO,EAChC,IAAM,EAAM,KAAK,IAAI,EAAG,EAAM,EAAO,MAAM,EAC3C,OAAO,EAAM,MAAM,EAAG,CAAG,CAAC,CAAC,QAAQ,EAAI,CAC3C,CASA,SAAgB,EAAW,EAAuB,CAE9C,OADI,EAAM,SAAW,EAAU,EACxB,EAAM,OAAO,CAAC,CAAC,CAAC,YAAY,EAAI,EAAM,MAAM,CAAC,CACxD,CAaA,SAAgB,EAAU,EAAuB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