{"version":3,"file":"format-fields.cjs","names":["fields"],"sources":["../../src/utils/format-fields.ts"],"sourcesContent":["export const formatFields = (fields: (string | Record<string, any>)[]): string[] => {\n\ttype FieldItem = (typeof fields)[number];\n\n\tconst walkFields = (value: FieldItem, chain: string[] = []): string | string[] => {\n\t\tif (typeof value === 'object') {\n\t\t\tconst result = [];\n\n\t\t\tfor (const key in value) {\n\t\t\t\tconst nestedField = value[key as keyof typeof value] ?? [];\n\n\t\t\t\tif (Array.isArray(nestedField)) {\n\t\t\t\t\t// regular nested fields\n\t\t\t\t\tfor (const item of nestedField) {\n\t\t\t\t\t\tresult.push(walkFields(item as FieldItem, [...chain, key]));\n\t\t\t\t\t}\n\t\t\t\t} else if (typeof nestedField === 'object') {\n\t\t\t\t\t// many to any nested\n\t\t\t\t\tfor (const scope of Object.keys(nestedField)) {\n\t\t\t\t\t\tconst fields = (nestedField as Record<string, FieldItem[]>)[scope]!;\n\n\t\t\t\t\t\tfor (const item of fields) {\n\t\t\t\t\t\t\tresult.push(walkFields(item as FieldItem, [...chain, `${key}:${scope}`]));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result.flatMap((items) => items);\n\t\t}\n\n\t\treturn [...chain, String(value)].join('.');\n\t};\n\n\treturn fields.flatMap((value) => walkFields(value));\n};\n"],"mappings":"AAAA,MAAa,EAAgB,GAAuD,CAGnF,IAAM,GAAc,EAAkB,EAAkB,EAAE,GAAwB,CACjF,GAAI,OAAO,GAAU,SAAU,CAC9B,IAAM,EAAS,EAAE,CAEjB,IAAK,IAAM,KAAO,EAAO,CACxB,IAAM,EAAc,EAAM,IAA8B,EAAE,CAE1D,GAAI,MAAM,QAAQ,EAAY,CAE7B,IAAK,IAAM,KAAQ,EAClB,EAAO,KAAK,EAAW,EAAmB,CAAC,GAAG,EAAO,EAAI,CAAC,CAAC,SAElD,OAAO,GAAgB,SAEjC,IAAK,IAAM,KAAS,OAAO,KAAK,EAAY,CAAE,CAC7C,IAAMA,EAAU,EAA4C,GAE5D,IAAK,IAAM,KAAQA,EAClB,EAAO,KAAK,EAAW,EAAmB,CAAC,GAAG,EAAO,GAAG,EAAI,GAAG,IAAQ,CAAC,CAAC,EAM7E,OAAO,EAAO,QAAS,GAAU,EAAM,CAGxC,MAAO,CAAC,GAAG,EAAO,OAAO,EAAM,CAAC,CAAC,KAAK,IAAI,EAG3C,OAAO,EAAO,QAAS,GAAU,EAAW,EAAM,CAAC"}