{ "version": 3, "sources": ["../javascripts/models/branding.ts", "../javascripts/selectors/branding.ts"], "sourcesContent": ["import type { Branding as BrandingType, ParsedBranding } from '../@types/branding';\n\nclass Branding {\n static parse = ({\n baseDuration365,\n category,\n conversionUrl,\n createdAt,\n creditCheckApiIdentifier,\n defaultPaybackTime,\n description,\n environment,\n hasConversionParameterSupport,\n id,\n identifier,\n institute,\n logo,\n featuredImage,\n manufacturerFilter,\n name,\n residualMatrix,\n slug,\n telephone,\n termsUrl,\n updatedAt,\n website,\n uspTitle,\n uspList,\n }: BrandingType): ParsedBranding => {\n const logoUrl = logo && logo.file && logo.file.url ? logo.file.url : null;\n\n const featuredImageUrl =\n featuredImage && featuredImage.file && featuredImage.file.url ? featuredImage.file.url : null;\n\n return {\n baseDuration365,\n category,\n conversionUrl,\n createdAt,\n creditCheckApiIdentifier,\n defaultPaybackTime,\n description,\n environment,\n hasConversionParameterSupport,\n id,\n identifier,\n institute,\n logo: logoUrl,\n featuredImage: featuredImageUrl,\n manufacturerFilter,\n name,\n residualMatrix,\n slug,\n telephone,\n termsUrl,\n updatedAt,\n website,\n uspTitle,\n uspList,\n };\n };\n}\n\nexport default Branding;\n", "import { createSelector } from '@reduxjs/toolkit';\n\nimport type { ElasticVehicle } from '../@types/ElasticVehicle';\nimport type { ParsedBranding } from '../@types/branding';\nimport type Item from '../@types/item';\nimport Branding from '../models/branding';\nimport type { RootState } from '../reducers';\nimport { getQueryFilter } from '../utils/reselectors';\nimport { getItem } from './item';\n\nconst MANUFACTURER_PACKAGE_CATEGORY = 'Manufacture packaging';\nconst MRF_PACKAGE_CATEGORY = 'MRF packaging';\n\nconst getManufacturePackagings = createSelector(\n (state: RootState) => state.brandings.list,\n (list) => (list || []).filter((b) => b.category.includes(MANUFACTURER_PACKAGE_CATEGORY)),\n);\n\nconst getMrfPackagings = createSelector(\n (state: RootState) => state.brandings.list,\n (list) => (list || []).filter((b) => b.category.includes(MRF_PACKAGE_CATEGORY)),\n);\n\nexport const getItemManufacturerPackagings = createSelector(\n getManufacturePackagings,\n (_: RootState, item: Item | ElasticVehicle) => item,\n (packagings, item) => {\n if (!item || !item.hasManufacturerPackaging) {\n return [];\n }\n\n return packagings.filter((p) => p.identifier === item.manufacturer).map(Branding.parse);\n },\n);\n\nexport const getManufacturePackagingForCurrentItem = createSelector(\n getItem,\n getManufacturePackagings,\n (item, packagings) => {\n if (!item || !item.hasManufacturerPackaging) {\n return null;\n }\n const { manufacturer } = item;\n const result = packagings.filter((p) => p.identifier === manufacturer).map(Branding.parse);\n return result.length ? result.pop() : null;\n },\n);\n\nexport const getMrfPackagingForCurrentItem = createSelector(\n getItem,\n getMrfPackagings,\n (item, packagings) => {\n if (!item || !item.hasMrfPackaging) {\n return [];\n }\n\n return packagings;\n },\n);\n\nexport const getFirstItemManufacturerPackaging = createSelector(\n [getItemManufacturerPackagings],\n (brandings) => brandings?.[0] || null,\n);\n\nconst isSameBrand = (identifier: string, manufacturer?: string) => {\n if (!identifier || !manufacturer) {\n return false;\n }\n\n return identifier.toLowerCase() === manufacturer.toLowerCase();\n};\n\nexport const getSearchManufacturePackaging = createSelector(\n getManufacturePackagings,\n getQueryFilter,\n (packagings, queryFilter) => {\n if (queryFilter && (queryFilter.get('manufacturer') || []).length === 1) {\n const manufacturer = queryFilter.get('manufacturer').pop();\n const _package = packagings.find((p) => isSameBrand(p.identifier, manufacturer));\n\n if (_package) return Branding.parse(_package);\n }\n return null;\n },\n);\n\nexport const getBrandingList = createSelector(\n (state: RootState) => state.brandings.list,\n (list): ParsedBranding[] => (list || []).map(Branding.parse),\n);\n\nexport const shouldFetchBrandings = createSelector(\n getBrandingList,\n (brandings) => brandings.length === 0,\n);\n\nexport const hasBrandings = (state: RootState) => getBrandingList(state).length > 0;\n"], "mappings": "6IAEA,IAAMA,EAAN,KAAe,CACb,OAAO,MAAQ,CAAC,CACd,gBAAAC,EACA,SAAAC,EACA,cAAAC,EACA,UAAAC,EACA,yBAAAC,EACA,mBAAAC,EACA,YAAAC,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Y,EACAb,EACA,CAACQ,EAAMC,IAAe,CACpB,GAAI,CAACD,GAAQ,CAACA,EAAK,yBACjB,OAAO,KAET,GAAM,CAAE,aAAAM,CAAa,EAAIN,EACnBO,EAASN,EAAW,OAAQC,GAAMA,EAAE,aAAeI,CAAY,EAAE,IAAIH,EAAS,KAAK,EACzF,OAAOI,EAAO,OAASA,EAAO,IAAI,EAAI,IACxC,CACF,EAEaC,EAAgCf,EAC3CY,EACAR,EACA,CAACG,EAAMC,IACD,CAACD,GAAQ,CAACA,EAAK,gBACV,CAAC,EAGHC,CAEX,EAEaQ,EAAoChB,EAC/C,CAACK,CAA6B,EAC7BY,GAAcA,IAAY,CAAC,GAAK,IACnC,EAEMC,EAAc,CAACC,EAAoBN,IACnC,CAACM,GAAc,CAACN,EACX,GAGFM,EAAW,YAAY,IAAMN,EAAa,YAAY,EAGlDO,EAAgCpB,EAC3CD,EACAsB,EACA,CAACb,EAAYc,IAAgB,CAC3B,GAAIA,IAAgBA,EAAY,IAAI,cAAc,GAAK,CAAC,GAAG,SAAW,EAAG,CACvE,IAAMT,EAAeS,EAAY,IAAI,cAAc,EAAE,IAAI,EACnDC,EAAWf,EAAW,KAAMC,GAAMS,EAAYT,EAAE,WAAYI,CAAY,CAAC,EAE/E,GAAIU,EAAU,OAAOb,EAAS,MAAMa,CAAQ,CAC9C,CACA,OAAO,IACT,CACF,EAEaC,EAAkBxB,EAC5BC,GAAqBA,EAAM,UAAU,KACrCC,IAA4BA,GAAQ,CAAC,GAAG,IAAIQ,EAAS,KAAK,CAC7D,EAEae,EAAuBzB,EAClCwB,EACCP,GAAcA,EAAU,SAAW,CACtC,EAEaS,EAAgBzB,GAAqBuB,EAAgBvB,CAAK,EAAE,OAAS", "names": ["Branding", "baseDuration365", "category", "conversionUrl", "createdAt", "creditCheckApiIdentifier", "defaultPaybackTime", "description", "environment", "hasConversionParameterSupport", "id", "identifier", "institute", "logo", "featuredImage", "manufacturerFilter", "name", "residualMatrix", "slug", "telephone", "termsUrl", "updatedAt", "website", "uspTitle", "uspList", "logoUrl", "featuredImageUrl", "branding_default", "MANUFACTURER_PACKAGE_CATEGORY", "MRF_PACKAGE_CATEGORY", "getManufacturePackagings", "createSelector", "state", "list", "b", "getMrfPackagings", "getItemManufacturerPackagings", "_", "item", "packagings", "p", "branding_default", "getManufacturePackagingForCurrentItem", "getItem", "manufacturer", "result", "getMrfPackagingForCurrentItem", "getFirstItemManufacturerPackaging", "brandings", "isSameBrand", "identifier", "getSearchManufacturePackaging", "getQueryFilter", "queryFilter", "_package", "getBrandingList", "shouldFetchBrandings", "hasBrandings"] }