{"version":3,"file":"getAllowedFileTypes.mjs","sources":["../../../src/uploadInput/uploadButton/getAllowedFileTypes.ts"],"sourcesContent":["import { FileType } from '../../common';\n\nconst parseFileType = (fileType: string): string => {\n  if (fileType?.includes('.')) {\n    return fileType.replace('.', '').toUpperCase();\n  }\n\n  const mimeType = fileType?.split('/');\n  if (mimeType?.length > 1) {\n    let parsedType = mimeType[1];\n\n    if (parsedType.toLocaleLowerCase() === 'jpeg') {\n      parsedType = 'jpg, '.concat(parsedType).toUpperCase();\n    }\n\n    return parsedType.toUpperCase();\n  }\n\n  return fileType;\n};\n\nconst getAllowedFileTypes = (fileTypes: readonly FileType[] | readonly string[]): string[] =>\n  fileTypes.map((fileType: string) => {\n    const splittedFileTypes = fileType?.split(',');\n\n    if (splittedFileTypes?.length > 1) {\n      // If `fileType` contains `format` and `mime` types, remove mime types, proceed only with format types\n      return splittedFileTypes\n        .filter((splittedFileType: string) => !splittedFileType?.includes('/'))\n        .map((splittedFileType: string) => parseFileType(splittedFileType))\n        .join(', ');\n    }\n\n    // If `fileType` contains only `format` or `mime` type, parse the type\n    return parseFileType(fileType);\n  });\n\nexport default getAllowedFileTypes;\n"],"names":["parseFileType","fileType","includes","replace","toUpperCase","mimeType","split","length","parsedType","toLocaleLowerCase","concat","getAllowedFileTypes","fileTypes","map","splittedFileTypes","filter","splittedFileType","join"],"mappings":"AAEA,MAAMA,aAAa,GAAIC,QAAgB,IAAY;AACjD,EAAA,IAAIA,QAAQ,EAAEC,QAAQ,CAAC,GAAG,CAAC,EAAE;IAC3B,OAAOD,QAAQ,CAACE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAACC,WAAW,EAAE;AAChD,EAAA;AAEA,EAAA,MAAMC,QAAQ,GAAGJ,QAAQ,EAAEK,KAAK,CAAC,GAAG,CAAC;AACrC,EAAA,IAAID,QAAQ,EAAEE,MAAM,GAAG,CAAC,EAAE;AACxB,IAAA,IAAIC,UAAU,GAAGH,QAAQ,CAAC,CAAC,CAAC;AAE5B,IAAA,IAAIG,UAAU,CAACC,iBAAiB,EAAE,KAAK,MAAM,EAAE;MAC7CD,UAAU,GAAG,OAAO,CAACE,MAAM,CAACF,UAAU,CAAC,CAACJ,WAAW,EAAE;AACvD,IAAA;AAEA,IAAA,OAAOI,UAAU,CAACJ,WAAW,EAAE;AACjC,EAAA;AAEA,EAAA,OAAOH,QAAQ;AACjB,CAAC;AAED,MAAMU,mBAAmB,GAAIC,SAAkD,IAC7EA,SAAS,CAACC,GAAG,CAAEZ,QAAgB,IAAI;AACjC,EAAA,MAAMa,iBAAiB,GAAGb,QAAQ,EAAEK,KAAK,CAAC,GAAG,CAAC;AAE9C,EAAA,IAAIQ,iBAAiB,EAAEP,MAAM,GAAG,CAAC,EAAE;AACjC;AACA,IAAA,OAAOO,iBAAiB,CACrBC,MAAM,CAAEC,gBAAwB,IAAK,CAACA,gBAAgB,EAAEd,QAAQ,CAAC,GAAG,CAAC,CAAC,CACtEW,GAAG,CAAEG,gBAAwB,IAAKhB,aAAa,CAACgB,gBAAgB,CAAC,CAAC,CAClEC,IAAI,CAAC,IAAI,CAAC;AACf,EAAA;AAEA;EACA,OAAOjB,aAAa,CAACC,QAAQ,CAAC;AAChC,CAAC;;;;"}