{"version":3,"file":"getLabel.mjs","sources":[""],"sourcesContent":["import { selectEmptyOptions } from \"../config/constants\";\r\nimport type { TOptionType } from \"../config/types\";\r\n\r\n/**\r\n * Gets the label of an option by its value.\r\n * Supports nested option groups.\r\n * @returns {string}\r\n */\r\nexport const getLabel = (options: TOptionType[] = selectEmptyOptions, val: string = \"\"): string => {\r\n  let result = \"\";\r\n  for (const option of options) {\r\n    const { label, value, options: subOptions } = option;\r\n    if (Array.isArray(subOptions)) {\r\n      for (const subOption of subOptions) {\r\n        if (subOption.value === val) {\r\n          result = subOption.label || \"\";\r\n          break;\r\n        }\r\n      }\r\n    } else if (value === val) {\r\n      result = label || \"\";\r\n      break;\r\n    }\r\n    if (result) {\r\n      break;\r\n    }\r\n  }\r\n  return result;\r\n};\r\n"],"names":["getLabel","options","selectEmptyOptions","val","result","option","label","value","subOptions","Array","isArray","subOption"],"mappings":";;;;;GAQO,MAAMA,SAAW,CAACC,QAAyBC,mBAAoBC,IAAc,MAClF,IAAIC,OAAS,GACb,IAAK,MAAMC,UAAUJ,QAAS,CAC5B,MAAMK,MAAEA,MAAKC,MAAEA,MAAON,QAASO,YAAeH,OAC9C,GAAII,MAAMC,QAAQF,aAChB,IAAK,MAAMG,aAAaH,WACtB,GAAIG,UAAUJ,QAAUJ,IAAK,CAC3BC,OAASO,UAAUL,OAAS,GAC5B,KACF,OAEG,GAAIC,QAAUJ,IAAK,CACxBC,OAASE,OAAS,GAClB,KACF,CACA,GAAIF,OACF,KAEJ,CACA,OAAOA"}