{"version":3,"file":"get-parsed-combobox-data.cjs","names":[],"sources":["../../../../src/components/Combobox/get-parsed-combobox-data/get-parsed-combobox-data.ts"],"sourcesContent":["import { Primitive } from '../../../core';\nimport {\n  ComboboxData,\n  ComboboxGenericData,\n  ComboboxGenericItem,\n  ComboboxItem,\n  ComboboxItemGroup,\n  ComboboxParsedItem,\n  ComboboxParsedItemGroup,\n} from '../Combobox.types';\n\nfunction parseItem<Value extends Primitive = string>(\n  item:\n    | Primitive\n    | ComboboxItem<Value>\n    | ComboboxGenericItem<Value>\n    | ComboboxItemGroup<Value | ComboboxGenericItem<Value> | ComboboxItem<Value>>\n): ComboboxItem<Value> | ComboboxParsedItemGroup<Value> {\n  if (typeof item === 'string') {\n    return { value: item as Value, label: item };\n  }\n\n  if (typeof item === 'object' && 'value' in item && !('label' in item)) {\n    return { value: item.value, label: `${item.value}`, disabled: item.disabled };\n  }\n\n  if (typeof item === 'object' && 'group' in item) {\n    return {\n      group: item.group,\n      items: item.items.map((i) => parseItem<Value>(i) as ComboboxItem<Value>),\n    };\n  }\n\n  if (typeof item === 'number' || typeof item === 'bigint' || typeof item === 'boolean') {\n    return { value: item as Value, label: `${item}` };\n  }\n\n  return item;\n}\n\nexport function getParsedComboboxData<Value extends Primitive = string>(\n  data: ComboboxData<Value> | ComboboxGenericData<Value> | undefined\n): ComboboxParsedItem<Value>[] {\n  if (!data) {\n    return [];\n  }\n\n  return data.map((item) => parseItem<Value>(item));\n}\n"],"mappings":";;AAWA,SAAS,UACP,MAKsD;CACtD,IAAI,OAAO,SAAS,UAClB,OAAO;EAAE,OAAO;EAAe,OAAO;CAAK;CAG7C,IAAI,OAAO,SAAS,YAAY,WAAW,QAAQ,EAAE,WAAW,OAC9D,OAAO;EAAE,OAAO,KAAK;EAAO,OAAO,GAAG,KAAK;EAAS,UAAU,KAAK;CAAS;CAG9E,IAAI,OAAO,SAAS,YAAY,WAAW,MACzC,OAAO;EACL,OAAO,KAAK;EACZ,OAAO,KAAK,MAAM,KAAK,MAAM,UAAiB,CAAC,CAAwB;CACzE;CAGF,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY,OAAO,SAAS,WAC1E,OAAO;EAAE,OAAO;EAAe,OAAO,GAAG;CAAO;CAGlD,OAAO;AACT;AAEA,SAAgB,sBACd,MAC6B;CAC7B,IAAI,CAAC,MACH,OAAO,CAAC;CAGV,OAAO,KAAK,KAAK,SAAS,UAAiB,IAAI,CAAC;AAClD"}