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AI0D,KAAM,SACnC2B,YAAa,QACboB,iBAAiB,EACjBC,iBAAkB,sBAClBC,UAAW,CAAE3G,MAAO,GAAK0D,KAAM,cAC/BkD,yBAAyB,MD1D3BM,iCAMAhB,UADCiB,WACDD,iCAMAhB,YADCiB,SACDD,iDAMAhB,UADCiB,SACDD,mCAMAhB,UADCiB,WACDD,yCAmBQhB,QAAPkB,WAAOF,oEAIAhB,QAAPkB,WAAOF,gEEvDH,IAAMG,EAAb,MAAM,sDAAOA,8BAAgCC,WAH/BtB,kCACD,CAACuB,MAAMC,SAHT,CAACC,KAAcC,KAAaC,KAAaC,KAAeC,KAAgBC,SAKtET,GAAb,EAAaA","names":["CampaignProductCardFinlandService","constructor","http","environment","this","getCampaignProductCardFinland","productId","campaignCode","queryParameters","URLSearchParams","Object","entries","languageCode","language","filter","_key","value","toString","get","endpoints","finlandApi","i0","ENVIRONMENT","factory","TruncateComponent","changeDetectorRef","ngAfterViewInit","resizeObserver","ResizeObserver","truncate","disconnect","observe","text","nativeElement","getClampStyle","overflow","display","rows","countNumberOfLines","computedStyle","window","getComputedStyle","lineHeightStyle","contentHeightStyle","contentPaddingTop","contentPaddingBottom","parseInt","a","getPropertyValue","Math","round","lineHeight","assign","style","expanded","detectChanges","expandable","expand","textElement","clampStyle","keys","map","key","removeProperty","selectors","State","CampaignProductCardFinland","store","dataLayerService","campaignProductCardFinlandService","super","setStore","estimatedKwhConsumptionUnit","estimatedKwhConsumption","unit","estimatedCo2EmissionPerMonthUnit","estimatedKwhConsumptionPerMonth","estimatedElectricityPricePerMonthUnit","monthlyFee","electricityPriceFixed","t","i","electricityPrice","_a","_b","toFixed","_c","o","discountedMonthlyBaseFee","monthlyBaseFee","_d","isDiscountedProduct","ngOnInit","viewstate","setAction","toPromise","then","setState","catch","onSelected","agreementName","productType","ecommerce","add","id","name","variant","marketingCode","consumptionCode","location","href","redirectUrl","CampaignProductCardFinlandElement","ctx","__decorate","Viewstate","loading","action","errorred","completedFixedPrice","contractLength","hideMonthlyCost","energySourceName","originFee","hideElectricityPriceRow","completedFixedPriceWithDiscount","discountLength","completedSpotPrice","completedVariablePrice","completedHideMonthlyCost","c","Required","Slot","CampaignProductCardFinlandModule","bootstrap","Store","imports","CommonModule","PipesModule","ErrorModule","LoadingModule","TruncateModule","TooltipModule"],"sources":["./src/app/campaign-product-card-finland/campaign-product-card-finland.model.ts","./src/app/campaign-product-card-finland/campaign-product-card-finland.service.ts","../ui/src/lib/truncate/truncate.component.html","../ui/src/lib/truncate/truncate.component.ts","./src/app/campaign-product-card-finland/campaign-product-card-finland.element.html","./src/app/campaign-product-card-finland/campaign-product-card-finland.element.ts","./src/app/campaign-product-card-finland/campaign-product-card-finland.viewstates.ts","./src/app/campaign-product-card-finland/campaign-product-card-finland.module.ts"],"sourcesContent":["import { DecimalNullableMeasurementViewModel } from \"@vattenfall/self-service\";\n\nexport class CampaignProductCardFinland {\n productId?: string;\n agreementName?: string;\n productType?: ProductType;\n monthlyBaseFee?: DecimalNullableMeasurementViewModel;\n discountedMonthlyBaseFee?: DecimalNullableMeasurementViewModel | null;\n electricityPrice?: DecimalNullableMeasurementViewModel;\n contractLength?: DecimalNullableMeasurementViewModel;\n discountLength?: DecimalNullableMeasurementViewModel;\n hideMonthlyCost?: boolean;\n energySourceName?: string;\n originFee?: DecimalNullableMeasurementViewModel;\n hideElectricityPriceRow?: boolean;\n}\n\nexport const SECONDARY_COLORS = [\"darkgreen\", \"darkblue\", \"pink\", \"darkpurple\", \"green\", \"red\", \"purple\"];\nexport type SecondaryColor = typeof SECONDARY_COLORS[number];\nexport type ProductType = \"fixed\" | \"variable\" | \"spot\";\n","import { HttpClient } from \"@angular/common/http\";\nimport { Inject, Injectable, Optional } from \"@angular/core\";\nimport { ENVIRONMENT, Environment } from \"@vattenfall/core\";\n\nimport { CampaignProductCardFinland } from \"./campaign-product-card-finland.model\";\n\n@Injectable({\n providedIn: \"root\",\n})\nexport class CampaignProductCardFinlandService {\n constructor(\n private http: HttpClient,\n @Optional()\n @Inject(ENVIRONMENT)\n private environment: Environment\n ) {}\n public getCampaignProductCardFinland(productId: string, campaignCode = \"\") {\n const queryParameters = new URLSearchParams(\n Object.entries({\n languageCode: this.environment.language,\n campaignCode,\n }).filter(([_key, value]) => !!value)\n ).toString();\n return this.http.get(\n `${this.environment.endpoints.finlandApi}/api/acquisition/products/${productId}?${queryParameters}`\n );\n }\n}\n","

\n \n

\n\n \n \n \n \n \n \n\n","import {\n AfterViewInit,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ElementRef,\n Input,\n ViewChild,\n ViewEncapsulation,\n} from \"@angular/core\";\n/**\n * Vattenfall UI `ui-truncate` text truncation component.\n *\n * Wrapping a text with `ui-truncate` will collapse the text to the number of rows specified by the input. Default is 2 rows.\n * This component uses -webkit-box and -webkit-line-clamp to implement truncation.\n */\n@Component({\n selector: \"ui-truncate\",\n templateUrl: \"./truncate.component.html\",\n styleUrls: [\"./truncate.component.scss\"],\n encapsulation: ViewEncapsulation.Emulated,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class TruncateComponent implements AfterViewInit {\n constructor(protected changeDetectorRef: ChangeDetectorRef) {}\n /** Number of rows to show initaly Default is 2. */\n @Input() rows = 2;\n /**\n * The text element that we need to truncate.\n */\n @ViewChild(\"text\")\n private text!: ElementRef;\n /**\n * If content is exandable. Default is true.\n * If the number of rows in the text is less than the max rows to show, then we dont need to show expand and collapse buttons.\n */\n expandable = true;\n /**\n * Tracks the current state of the content.\n * Default value false.\n */\n expanded = false;\n\n ngAfterViewInit(): void {\n /**\n * We are using resize Observer to do the initial truncation of the text.\n * The reason being that we only want to truncate text after it has already been rendered and the height of the text element is now known to the borwser.\n * This observer was introduced to fix the bug of text not being truncated by default when loaded (usually the first time we use truncate component would not truncate in initialisation).\n * */\n const resizeObserver = new ResizeObserver(() => {\n this.truncate();\n // Disconnect as soon as we truncate for the first time. From now on, its the user interactions that truncates/expands text.\n resizeObserver.disconnect();\n });\n // Listen to resize of text element.\n resizeObserver.observe(this.text.nativeElement);\n }\n /**\n *\n * @returns the clamp style with a given number of lines to clamp.\n */\n private getClampStyle(): Record {\n return {\n overflow: \"hidden\",\n display: \"-webkit-box\",\n \"-webkit-box-orient\": \"vertical\",\n \"-webkit-line-clamp\": this.rows.toString(),\n };\n }\n /**\n * This function will count the total number of lines from a given html element.\n * @returns total number of lines as number\n */\n private countNumberOfLines(): number {\n const textElement: HTMLElement = this.text.nativeElement;\n const computedStyle: CSSStyleDeclaration = window.getComputedStyle(textElement);\n /**\n * By removing padding top/bottom - we can calculate the number of lines in a given element by measuring its height and dividing it by the line-height.\n */\n const [lineHeightStyle, contentHeightStyle, contentPaddingTop, contentPaddingBottom] = [\n parseInt(computedStyle?.getPropertyValue(\"line-height\")) || 1.2,\n parseInt(computedStyle?.getPropertyValue(\"height\")),\n parseInt(computedStyle?.getPropertyValue(\"padding-top\")),\n parseInt(computedStyle?.getPropertyValue(\"padding-bottom\")),\n ];\n const lineHeight: number = lineHeightStyle;\n const contentHeight = contentHeightStyle - contentPaddingTop - contentPaddingBottom;\n const totalNumberOrRows = Math.round(contentHeight / lineHeight);\n return totalNumberOrRows;\n }\n /**\n * This function will collapse the given element by adding\n */\n truncate() {\n const textElement = this.text.nativeElement;\n // set -webkit-line-clamp to the number of rows input value\n Object.assign(textElement.style, this.getClampStyle());\n this.expanded = false;\n this.changeDetectorRef.detectChanges();\n /** Set the flag expandable if the number of rows in the text is higher than the rows we want to show. */\n this.expandable = this.countNumberOfLines() > this.rows;\n }\n /**\n * Clean the inline style applied by the collapse() function above.\n */\n expand() {\n // clean the expand style added as style attribute.\n const textElement: HTMLElement = this.text.nativeElement;\n const clampStyle = this.getClampStyle();\n const properties: string[] = Object.keys(clampStyle);\n // loop over each property and remove it from the text element.\n properties.map((key) => {\n textElement.style.removeProperty(key);\n });\n this.expanded = true;\n this.changeDetectorRef.detectChanges();\n }\n}\n","\n
\n \n\n \n \n \n \n \n \n \n \n\n \n\n
\n {{ agreementName }}\n
\n\n \n\n \n \n \n \n \n \n \n \n \n\n \n\n
\n
\n \n \n {{ estimatedCo2EmissionPerMonthUnit | unit: \"1.1-1\" }}\n \n \n \n \n \n \n \n \n\n \n\n \n
\n \n
\n
\n \n
\n \n \n \n \n {{ monthlyBaseFee | unit: \"1.2-2\" }}\n \n \n {{ discountedMonthlyBaseFee | unit: \"1.2-2\" }}\n \n
\n\n \n
\n \n \n \n {{ discountLength | unit }}\n
\n\n \n
\n \n \n \n \n \n \n \n {{ electricityPrice | unit: \"1.2-2\" }}\n \n
\n\n \n
\n {{ energySourceName }}: \n \n {{ originFee | unit: \"1.2-2\" }}\n \n \n \n \n \n \n \n
\n\n \n
\n \n \n \n \n \n \n {{ contractLength | unit }}\n \n \n \n \n \n
\n\n \n \n \n {{ campaignProductCardFinlandPaymentTypeLabel }}\n \n \n {{ campaignProductCardFinlandPaymentTypeText }}\n \n
\n \n\n \n \n \n {{\n hideMonthlyCost === true\n ? \"\"\n : (estimatedElectricityPricePerMonthUnit | unit: \"1.2-2\") + \"*\"\n }}\n \n \n \n \n\n \n\n \n \n \n\n \n\n
\n \n
\n \n
\n","import { Component, Input, OnInit } from \"@angular/core\";\n\nimport { Store, State, Required, Viewstate, DataLayerService, Slot } from \"@vattenfall/core\";\nimport { DecimalNullableMeasurementViewModel } from \"@vattenfall/self-service\";\n\nimport { CampaignProductCardFinland, SecondaryColor } from \"./campaign-product-card-finland.model\";\nimport { CampaignProductCardFinlandService } from \"./campaign-product-card-finland.service\";\nimport { VIEWSTATES } from \"./campaign-product-card-finland.viewstates\";\n\n/**\n * Product card listing details such as price used for marketing purpose targeting Finnish customers.\n *\n * The editor is able to make customizations such as the choosing product image to use, change the sticker color and hide or display monthly cost. It will accept an arbitrary number of rows in its description.\n */\n@Component({\n selector: \"campaign-product-card-finland\",\n templateUrl: \"./campaign-product-card-finland.element.html\",\n styleUrls: [\"./campaign-product-card-finland.element.scss\"],\n})\nexport class CampaignProductCardFinlandElement extends State(CampaignProductCardFinland) implements OnInit {\n @Input()\n @Viewstate(VIEWSTATES)\n public viewstate?: string;\n /**\n * The product identifier to get prices from. Required.\n */\n @Input()\n @Required()\n public productId?: string;\n /**\n * The estimated kWh yearly consumption on which the prices and CO2 emissions are calculated. Required.\n */\n @Input()\n @Required()\n public estimatedKwhConsumption = 0;\n /**\n * The URL to redirect to after a product has been selected\n */\n @Input()\n @Required()\n public redirectUrl?: string;\n /**\n * The consumption code for this product\n */\n @Input()\n @Required()\n public consumptionCode?: string;\n /**\n * The campaign code that should be associated with the product.\n */\n @Input()\n public campaignCode?: string;\n /**\n * The marketing code that should be associated with the product.\n */\n @Input()\n public marketingCode?: string;\n /**\n * The background color of sticker. Default is `darkgreen`.\n */\n @Input()\n public stickerColor: SecondaryColor = \"darkgreen\";\n /**\n * The slot to display payment option label.\n */\n @Slot() readonly campaignProductCardFinlandPaymentTypeLabel?: string;\n /**\n * The slot to display payment option text.\n */\n @Slot() readonly campaignProductCardFinlandPaymentTypeText?: string;\n\n /**\n * Estimated kWh consumption expressed as a unit value\n */\n public get estimatedKwhConsumptionUnit(): DecimalNullableMeasurementViewModel {\n return {\n value: this.estimatedKwhConsumption,\n unit: \"KWH\",\n };\n }\n /**\n * Estimated Co2 emissions per month expressed as a unit value\n */\n public get estimatedCo2EmissionPerMonthUnit(): DecimalNullableMeasurementViewModel {\n const CO2_EMISSION_RATIO = 0.264;\n return {\n value: this.estimatedKwhConsumptionPerMonth * CO2_EMISSION_RATIO,\n unit: \"KG/MONTH\",\n };\n }\n /**\n * Estimated electricity price per month expressed as a unit value\n */\n public get estimatedElectricityPricePerMonthUnit(): DecimalNullableMeasurementViewModel {\n return {\n value: this.monthlyFee + this.estimatedKwhConsumptionPerMonth * (this.electricityPriceFixed / 100),\n unit: \"EURO/MONTH\",\n } as DecimalNullableMeasurementViewModel;\n }\n /**\n * Estimated kWh consumption per month\n */\n public get estimatedKwhConsumptionPerMonth(): number {\n return this.estimatedKwhConsumption / 12;\n }\n /**\n * Electricity price as a floating number with two digits\n */\n public get electricityPriceFixed(): number {\n return +(this.electricityPrice?.value?.toFixed(2) ?? 0);\n }\n /**\n * Monthly discounted or base fee, whichever is lower\n */\n public get monthlyFee(): number {\n return this.discountedMonthlyBaseFee?.value ?? this.monthlyBaseFee?.value ?? 0;\n }\n /**\n * Whether the price is discounted or not\n */\n public get isDiscountedProduct(): boolean {\n return this.discountedMonthlyBaseFee != null ? true : false;\n }\n\n constructor(\n private store: Store,\n private dataLayerService: DataLayerService,\n private campaignProductCardFinlandService: CampaignProductCardFinlandService\n ) {\n super();\n super.setStore(store);\n }\n\n ngOnInit() {\n // Do not fetch when reload is triggered by change in viewstate\n if (this.productId && this.viewstate == null) {\n this.store.setAction(\"loading\");\n this.campaignProductCardFinlandService\n .getCampaignProductCardFinland(this.productId, this.campaignCode)\n .toPromise()\n .then(this.store.setState(\"completed\"))\n .catch(this.store.setState(\"errorred\"));\n }\n }\n\n public onSelected() {\n // Dispatch add to cart\n if (this.productId && this.agreementName && this.productType)\n this.dataLayerService.ecommerce.add({\n id: this.productId,\n name: this.productType,\n variant: this.agreementName,\n });\n // Redirect to next page\n const queryParameters = new URLSearchParams(\n Object.entries({\n productId: this.productId as string,\n campaignCode: this.campaignCode as string,\n marketingCode: this.marketingCode as string,\n consumptionCode: this.consumptionCode as string,\n estimatedKwhConsumption: this.estimatedKwhConsumption?.toString(),\n }).filter(([_key, value]) => !!value) // Filter out undefined values.\n ).toString();\n window.location.href = `${this.redirectUrl}?${queryParameters}`;\n }\n}\n","import { Viewstates } from \"@vattenfall/core\";\n\nimport { CampaignProductCardFinland } from \"./campaign-product-card-finland.model\";\n\nexport const VIEWSTATES: Viewstates = {\n loading: {\n action: \"loading\",\n },\n errorred: {\n action: \"errorred\",\n },\n completedFixedPrice: {\n action: \"completed\",\n productId: \"1\",\n agreementName: \"Fixed price\",\n monthlyBaseFee: { value: 3.8, unit: \"EURO/MONTH\" },\n electricityPrice: { value: 0.5975, unit: \"EURO_CENT/KWH\" },\n contractLength: { value: 24, unit: \"MONTH\" },\n productType: \"fixed\",\n hideMonthlyCost: false,\n energySourceName: \"Aurinko alkuperä\",\n originFee: { value: 0.5, unit: \"EURO/MONTH\" },\n hideElectricityPriceRow: true,\n },\n completedFixedPriceWithDiscount: {\n action: \"completed\",\n productId: \"1\",\n agreementName: \"Fixed price w. discount\",\n monthlyBaseFee: { value: 3.8, unit: \"EURO/MONTH\" },\n discountedMonthlyBaseFee: { value: 2.6, unit: \"EURO/MONTH\" },\n electricityPrice: { value: 0.5975, unit: \"EURO_CENT/KWH\" },\n contractLength: { value: 24, unit: \"MONTH\" },\n discountLength: { value: 12, unit: \"MONTH\" },\n productType: \"fixed\",\n hideMonthlyCost: false,\n energySourceName: \"Tuulivoima\",\n originFee: { value: 0.5, unit: \"EURO/MONTH\" },\n hideElectricityPriceRow: true,\n },\n completedSpotPrice: {\n action: \"completed\",\n productId: \"1\",\n agreementName: \"Spot price\",\n monthlyBaseFee: { value: 4.9, unit: \"EURO/MONTH\" },\n electricityPrice: { value: 0.5975, unit: \"EURO_CENT/KWH\" },\n contractLength: { value: 24, unit: \"MONTH\" },\n discountLength: { value: 0, unit: \"MONTH\" },\n productType: \"spot\",\n hideMonthlyCost: false,\n energySourceName: \"Aurinko alkuperä\",\n originFee: { value: 0.5, unit: \"EURO/MONTH\" },\n hideElectricityPriceRow: true,\n },\n completedVariablePrice: {\n action: \"completed\",\n productId: \"1\",\n agreementName: \"Variable price\",\n monthlyBaseFee: { value: 4.9, unit: \"EURO/MONTH\" },\n electricityPrice: { value: 0.5975, unit: \"EURO_CENT/KWH\" },\n contractLength: { value: 24, unit: \"MONTH\" },\n discountLength: { value: 0, unit: \"MONTH\" },\n productType: \"variable\",\n hideMonthlyCost: false,\n energySourceName: \"Tuulivoima\",\n originFee: { value: 0.5, unit: \"EURO/MONTH\" },\n hideElectricityPriceRow: true,\n },\n completedHideMonthlyCost: {\n action: \"completed\",\n productId: \"1\",\n agreementName: \"Hide monthly cost\",\n monthlyBaseFee: { value: 3.8, unit: \"EURO/MONTH\" },\n discountedMonthlyBaseFee: null,\n electricityPrice: { value: 0.5975, unit: \"EURO_CENT/KWH\" },\n contractLength: { value: 24, unit: \"MONTH\" },\n discountLength: { value: 12, unit: \"MONTH\" },\n productType: \"fixed\",\n hideMonthlyCost: true,\n energySourceName: \"Aurinko alkuperä\",\n originFee: { value: 0.5, unit: \"EURO/MONTH\" },\n hideElectricityPriceRow: true,\n },\n};\n","import { CommonModule } from \"@angular/common\";\nimport { NgModule } from \"@angular/core\";\nimport { PipesModule, Store } from \"@vattenfall/core\";\nimport { ErrorModule, LoadingModule, TruncateModule, TooltipModule } from \"@vattenfall/ui\";\n\nimport { CampaignProductCardFinlandElement } from \"./campaign-product-card-finland.element\";\n\n@NgModule({\n declarations: [CampaignProductCardFinlandElement],\n imports: [CommonModule, PipesModule, ErrorModule, LoadingModule, TruncateModule, TooltipModule],\n exports: [CampaignProductCardFinlandElement],\n bootstrap: [CampaignProductCardFinlandElement],\n providers: [Store],\n})\nexport class CampaignProductCardFinlandModule {}\n"],"sourceRoot":"webpack:///","file":"35.js"}