{"version":3,"file":"recomposeSV.cjs","names":[],"sources":["../../../src/utils/strings/recomposeSV.ts"],"sourcesContent":["import type { Fn } from '#bemedev/globals/types';\nimport { DEFAULT_DELIMITER } from '#constants';\nimport type { StateValue } from '#states';\n\nexport type RecomposeSV_F = Fn<\n  [arg: string, delimiter?: string],\n  StateValue\n>;\n\n/**\n * Recombines a string into a state value object.\n * The string is expected to be delimited by the default delimiter.\n * The first part of the string becomes the key, and the rest becomes the value.\n * If the string starts with the delimiter, it is removed before processing.\n * @param arg The string to recompose.\n * @param delimiter The delimiter used to split the string. Defaults to {@linkcode DEFAULT_DELIMITER}.\n * @returns An object with the first part as the key and the recomposed value as the value.\n *\n * @see {@linkcode RecomposeSV_F} for the type definition\n */\nexport const recomposeSV: RecomposeSV_F = (\n  arg,\n  delimiter = DEFAULT_DELIMITER,\n) => {\n  const arg1 = arg.startsWith(delimiter) ? arg.substring(1) : arg;\n\n  const splits = arg1.split(delimiter);\n\n  const check2 = splits.length === 1;\n  if (check2) return arg1;\n\n  const first = splits.shift()!;\n\n  const rest = splits.join(delimiter);\n  return { [first]: recomposeSV(rest) };\n};\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAa,eACX,KACA,YAAA,QACG;CACH,MAAM,OAAO,IAAI,WAAW,UAAU,GAAG,IAAI,UAAU,EAAE,GAAG;CAE5D,MAAM,SAAS,KAAK,MAAM,UAAU;AAGpC,KADe,OAAO,WAAW,EACrB,QAAO;CAEnB,MAAM,QAAQ,OAAO,OAAO;CAE5B,MAAM,OAAO,OAAO,KAAK,UAAU;AACnC,QAAO,GAAG,QAAQ,YAAY,KAAK,EAAE"}