{"version":3,"file":"decomposeSV.cjs","names":["DELIMITER","sortMap","_any","_unknown"],"sources":["../src/decomposeSV.ts"],"sourcesContent":["import _any from '#bemedev/features/common/castings/any';\nimport { _unknown } from '#bemedev/globals/utils/_unknown';\nimport { DELIMITER } from './constants/strings';\nimport { sortMap } from './sortMap';\nimport type { StateMatching, StateValue } from './types.types';\n\nfunction ddecompose(val: StateValue, prev = '') {\n  const output: string[] = [];\n\n  const _prev = prev ? prev + DELIMITER : '';\n  if (prev !== '') output.push(prev);\n\n  if (typeof val === 'string') {\n    output.push(`${_prev}${val}`);\n  } else {\n    const keys = Object.keys(val);\n    output.push(\n      ...keys.map(key => ddecompose(val[key], `${_prev}${key}`)).flat(),\n    );\n  }\n\n  return output;\n}\n\ntype DecomposeSV_F = <T extends StateValue>(\n  val: T,\n  sorter?: typeof sortMap,\n) => StateMatching<T>[];\n\ntype _DecomposeSV_F = (val: any, sorter?: typeof sortMap) => string[];\n\nexport type DecomposeSV = DecomposeSV_F & {\n  strict: DecomposeSV_F;\n  low: _DecomposeSV_F;\n};\n\nconst _decomposeSV: _DecomposeSV_F = (val, sorter = sortMap) => {\n  const output1 = ddecompose(val, '');\n  output1.sort(sorter);\n  const regex = new RegExp(DELIMITER, 'g');\n  return output1.map(value => value.replace(regex, '.'));\n};\n\nexport const decomposeSV: DecomposeSV = (val, sorter) => {\n  return _any(_decomposeSV(val, sorter));\n};\ndecomposeSV.low = _decomposeSV;\ndecomposeSV.strict = _unknown<DecomposeSV_F>(_decomposeSV);\n"],"mappings":";;;;;;AAMA,SAAS,WAAW,KAAiB,OAAO,IAAI;CAC9C,MAAM,SAAmB,CAAC;CAE1B,MAAM,QAAQ,OAAO,OAAOA,0BAAAA,YAAY;CACxC,IAAI,SAAS,IAAI,OAAO,KAAK,IAAI;CAEjC,IAAI,OAAO,QAAQ,UACjB,OAAO,KAAK,GAAG,QAAQ,KAAK;MACvB;EACL,MAAM,OAAO,OAAO,KAAK,GAAG;EAC5B,OAAO,KACL,GAAG,KAAK,KAAI,QAAO,WAAW,IAAI,MAAM,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,KAAK,CAClE;CACF;CAEA,OAAO;AACT;AAcA,MAAM,gBAAgC,KAAK,SAASC,gBAAAA,YAAY;CAC9D,MAAM,UAAU,WAAW,KAAK,EAAE;CAClC,QAAQ,KAAK,MAAM;CACnB,MAAM,QAAQ,IAAI,OAAOD,0BAAAA,WAAW,GAAG;CACvC,OAAO,QAAQ,KAAI,UAAS,MAAM,QAAQ,OAAO,GAAG,CAAC;AACvD;AAEA,MAAa,eAA4B,KAAK,WAAW;CACvD,OAAOE,kDAAK,aAAa,KAAK,MAAM,CAAC;AACvC;AACA,YAAY,MAAM;AAClB,YAAY,SAASC,4CAAAA,SAAwB,YAAY"}