{"version":3,"file":"PriceSavingsInPercentFi-f5eFU6Rg.js","sources":["../../src/components/atoms/price-savings-in-percent-fi/PriceSavingsInPercentFi.vue"],"sourcesContent":["<template>\n <div\n v-if=\"savingsInPercent\"\n :class=\"[\n 'price-savings-in-percent-fi',\n theme ? `price-savings-in-percent-fi--theme-${theme}` : '',\n ]\"\n >\n <span class=\"badge-fi\">\n {{ savingsInPercent }}\n </span>\n </div>\n</template>\n\n<script>\nexport default {\n name: 'PriceSavingsInPercentFi',\n props: {\n bestPrice: {\n type: Object,\n default: () => ({}),\n },\n small: {\n type: Boolean,\n default: false,\n },\n theme: {\n type: String,\n default: null,\n },\n },\n computed: {\n quantity() {\n let qty = 0;\n if (this.bestPrice) {\n qty =\n this.bestPrice.requestedQuantity > 0\n ? this.bestPrice.requestedQuantity\n : this.bestPrice.initialQuantity;\n }\n return qty;\n },\n savingsInPercent() {\n if (\n this.bestPrice &&\n this.bestPrice.price &&\n this.bestPrice.price.savingsInformation &&\n this.bestPrice.price.savingsInformation.savingsInPercent\n ) {\n return this.$dict.get('online-Shop.Product.Savings', [\n this.bestPrice.price.savingsInformation.savingsInPercent,\n ]);\n }\n\n if (this.resultPriceRowsSavings) {\n const activeSaving = this.resultPriceRowsSavings.find((el) => el.active);\n const value =\n activeSaving &&\n activeSaving.savingsInformation &&\n activeSaving.savingsInformation.savingsInPercent;\n if (value) {\n return this.$dict.get('online-Shop.Product.Price-Rows-Saving-Label', [value]);\n }\n }\n\n return null;\n },\n resultPriceRowsSavings() {\n if (this.bestPrice) {\n let activeIndex = 0;\n const savings = [\n {\n ...this.bestPrice.price,\n minQty: this.bestPrice.initialQuantity,\n savingsInformation: null,\n },\n ...(this.bestPrice.priceRowsIncludingSavings || []),\n ];\n\n savings.forEach((saving, index) => {\n saving.active = false;\n\n if (saving.minQty <= this.quantity) {\n activeIndex = index;\n }\n });\n\n savings[activeIndex].active = true;\n\n return savings;\n }\n\n return null;\n },\n },\n};\n</script>\n\n<style scoped lang=\"scss\">\n@import './price-savings-in-percent-fi';\n</style>\n"],"names":["_sfc_main","qty","activeSaving","el","value","activeIndex","savings","saving","index","_hoisted_1","$options","_createElementBlock","_normalizeClass","$props","_createElementVNode","_toDisplayString","_createCommentVNode"],"mappings":"iFAeA,MAAKA,EAAU,CACb,KAAM,0BACN,MAAO,CACL,UAAW,CACT,KAAM,OACN,QAAS,KAAO,CAAA,EACjB,EACD,MAAO,CACL,KAAM,QACN,QAAS,EACV,EACD,MAAO,CACL,KAAM,OACN,QAAS,IACV,CACF,EACD,SAAU,CACR,UAAW,CACT,IAAIC,EAAM,EACV,OAAI,KAAK,YACPA,EACE,KAAK,UAAU,kBAAoB,EAC/B,KAAK,UAAU,kBACf,KAAK,UAAU,iBAEhBA,CACR,EACD,kBAAmB,CACjB,GACE,KAAK,WACL,KAAK,UAAU,OACf,KAAK,UAAU,MAAM,oBACrB,KAAK,UAAU,MAAM,mBAAmB,iBAExC,OAAO,KAAK,MAAM,IAAI,8BAA+B,CACnD,KAAK,UAAU,MAAM,mBAAmB,gBAC1C,CAAC,EAGH,GAAI,KAAK,uBAAwB,CAC/B,MAAMC,EAAe,KAAK,uBAAuB,KAAMC,GAAOA,EAAG,MAAM,EACjEC,EACJF,GACAA,EAAa,oBACbA,EAAa,mBAAmB,iBAClC,GAAIE,EACF,OAAO,KAAK,MAAM,IAAI,8CAA+C,CAACA,CAAK,CAAC,CAEhF,CAEA,OAAO,IACR,EACD,wBAAyB,CACvB,GAAI,KAAK,UAAW,CAClB,IAAIC,EAAc,EAClB,MAAMC,EAAU,CACd,CACE,GAAG,KAAK,UAAU,MAClB,OAAQ,KAAK,UAAU,gBACvB,mBAAoB,IACrB,EACD,GAAI,KAAK,UAAU,2BAA6B,IAGlD,OAAAA,EAAQ,QAAQ,CAACC,EAAQC,IAAU,CACjCD,EAAO,OAAS,GAEZA,EAAO,QAAU,KAAK,WACxBF,EAAcG,EAElB,CAAC,EAEDF,EAAQD,CAAW,EAAE,OAAS,GAEvBC,CACT,CAEA,OAAO,IACR,CACF,CACH,EAvFUG,EAAA,CAAA,MAAM,UAAU,iCANhBC,EAAgB,sBADxBC,EAUM,MAAA,CAXR,IAAA,EAGK,MAHLC,EAAA,+BAGyDC,EAAA,4CAA8CA,EAAK,KAAA,GAAA,OAKxGC,EAEO,OAFPL,EAEOM,EADFL,EAAgB,gBAAA,EAAA,CAAA,OATzBM,EAAA,GAAA,EAAA"}