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AAW,IACnB,CAAC;;YACA,IAAI,MAAA,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,0CAAE,eAAe,EAAE;gBAC1C,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAA,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,0CAAE,eAAe,CAAC,CAAC;aACxE;YAED,IAAI,MAAA,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,0CAAE,aAAa,EAAE;gBACxC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAC;aAC9D;YAED,IAAI,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,0CAAE,MAAM,0CAAE,MAAM,EAAE;gBACzC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;aAC3B;YAED,OAAO,eAAQ,CAAC;SACjB,GAAG,CACC,EACP;KACH;;;;;;","names":["upsellState"],"sources":["src/components/controllers/product/sc-product-price/sc-product-price.scss?tag=sc-product-price&encapsulation=shadow","src/components/controllers/product/sc-product-price/sc-product-price.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","/**\n * External dependencies.\n */\nimport { Component, h, Prop, Host } from '@stencil/core';\nimport { __, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies.\n */\nimport { state } from '@store/product';\nimport { state as upsellState } from '@store/upsell';\nimport { Price, Variant } from '../../../../types';\n\n@Component({\n tag: 'sc-product-price',\n styleUrl: 'sc-product-price.scss',\n shadow: true,\n})\nexport class ScProductPrice {\n /** The product's prices. */\n @Prop() prices: Price[];\n\n /** The sale text */\n @Prop() saleText: string;\n\n /** The product id */\n @Prop() productId: string;\n\n renderRange() {\n return state[this.productId]?.range_display_amount;\n }\n\n renderVariantPrice(selectedVariant: Variant) {\n const variant = state[this.productId]?.variants?.find(variant => variant?.id === selectedVariant?.id);\n return this.renderPrice(state[this.productId].selectedPrice, variant);\n }\n\n renderPrice(price: Price, variant: Variant = null) {\n const originalAmount = variant?.display_amount ?? price?.display_amount ?? '';\n\n // maybe change for upsells.\n const amount = upsellState?.line_item?.subtotal_with_upsell_discount_amount || price?.amount;\n const upsellDisplayAmount = upsellState?.line_item?.subtotal_with_upsell_discount_display_amount;\n const displayAmount = upsellDisplayAmount ? upsellDisplayAmount : originalAmount;\n\n const scratchAmount = upsellState?.line_item?.subtotal_amount || price?.scratch_amount;\n const upsellScratchDisplayAmount = upsellState?.line_item?.subtotal_display_amount;\n const scratchDisplayAmount = upsellScratchDisplayAmount ? upsellScratchDisplayAmount : price?.scratch_display_amount;\n\n return (\n <sc-price\n currency={price?.currency}\n amount={amount}\n displayAmount={displayAmount}\n scratchAmount={scratchAmount}\n scratchDisplayAmount={scratchDisplayAmount}\n saleText={this.saleText}\n adHoc={price?.ad_hoc}\n trialDurationDays={price?.trial_duration_days}\n setupFeeText={price?.setup_fee_text}\n setupFeeAmount={price?.setup_fee_enabled ? price?.setup_fee_amount : null}\n setupFeeName={price?.setup_fee_enabled ? price?.setup_fee_name : null}\n recurringPeriodCount={price?.recurring_period_count}\n recurringInterval={price?.recurring_interval}\n recurringIntervalCount={price?.recurring_interval_count}\n />\n );\n }\n\n render() {\n return (\n <Host role=\"paragraph\">\n {(() => {\n if (state[this.productId]?.selectedVariant) {\n return this.renderVariantPrice(state[this.productId]?.selectedVariant);\n }\n\n if (state[this.productId]?.selectedPrice) {\n return this.renderPrice(state[this.productId].selectedPrice);\n }\n\n if (state[this.productId]?.prices?.length) {\n return this.renderRange();\n }\n\n return <slot />;\n })()}\n </Host>\n );\n }\n}\n"],"version":3}