{"version":3,"file":"get-option-by-label.cjs","names":[],"sources":["../../../../src/components/Combobox/get-options-lockup/get-option-by-label.ts"],"sourcesContent":["import { Primitive } from '../../../core';\nimport { ComboboxItem } from '../Combobox.types';\n\n/**\n * Finds an enabled option by its label, ignoring casing and surrounding whitespace. Returns\n * `undefined` when the label is ambiguous: options with duplicate labels are valid data, and there\n * is no way to tell which of them was meant.\n */\nexport function getOptionByLabel<Value extends Primitive = string>(\n  optionsLockup: Record<PropertyKey, ComboboxItem<Value>>,\n  label: string\n): ComboboxItem<Value> | undefined {\n  const normalizedLabel = label.trim().toLowerCase();\n\n  if (normalizedLabel === '') {\n    return undefined;\n  }\n\n  const matchedOptions = Object.values(optionsLockup).filter(\n    (option) => !option.disabled && option.label.trim().toLowerCase() === normalizedLabel\n  );\n\n  return matchedOptions.length === 1 ? matchedOptions[0] : undefined;\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,iBACd,eACA,OACiC;CACjC,MAAM,kBAAkB,MAAM,KAAK,CAAC,CAAC,YAAY;CAEjD,IAAI,oBAAoB,IACtB;CAGF,MAAM,iBAAiB,OAAO,OAAO,aAAa,CAAC,CAAC,QACjD,WAAW,CAAC,OAAO,YAAY,OAAO,MAAM,KAAK,CAAC,CAAC,YAAY,MAAM,eACxE;CAEA,OAAO,eAAe,WAAW,IAAI,eAAe,KAAK,KAAA;AAC3D"}