// Metro module 6263 (f6264). import Record from "../lib/Record"; import { CountryListMode, PromotionTypes } from "../modules/premium/promotions/constants"; import * as _Module1384 from "../_bundle/Module1384"; class PromotionRecord extends Record { constructor(a0) { super(); this.id = a0.id; this.trialId = a0.trialId; this.startDate = a0.startDate; this.endDate = a0.endDate; this.outboundRedemptionEndDate = a0.outboundRedemptionEndDate; this.inboundHeaderText = a0.inboundHeaderText; this.inboundBodyText = a0.inboundBodyText; this.inboundHelpCenterLink = a0.inboundHelpCenterLink; this.outboundTitle = a0.outboundTitle; this.outboundRedemptionModalBody = a0.outboundRedemptionModalBody; this.outboundTermsAndConditions = a0.outboundTermsAndConditions; this.outboundRedemptionPageLink = a0.outboundRedemptionPageLink; this.outboundRedemptionUrlFormat = a0.outboundRedemptionUrlFormat; let flags = a0.flags; if (flags == null) { flags = 0; } this.flags = flags; let inboundRestrictedCountries = a0.inboundRestrictedCountries; if (inboundRestrictedCountries == null) { inboundRestrictedCountries = []; } this.inboundRestrictedCountries = inboundRestrictedCountries; let outboundRestrictedCountries = a0.outboundRestrictedCountries; if (outboundRestrictedCountries == null) { outboundRestrictedCountries = []; } this.outboundRestrictedCountries = outboundRestrictedCountries; let allowedCountries = a0.allowedCountries; if (allowedCountries == null) { allowedCountries = []; } this.allowedCountries = allowedCountries; let countryListMode = a0.countryListMode; if (countryListMode == null) { countryListMode = CountryListMode.BLOCKLIST; } this.countryListMode = countryListMode; this.promotionType = a0.promotionType; this.partnerId = a0.partnerId; this.marketingComponents = a0.marketingComponents; this.rewardSkuIds = a0.rewardSkuIds; let bogoRewardEnabled = a0.bogoRewardEnabled; if (bogoRewardEnabled == null) { bogoRewardEnabled = false; } this.bogoRewardEnabled = bogoRewardEnabled; this.promotionKey = a0.promotionKey; } static createFromServer(a0) { const r3 = { id: a0.id, trialId: a0.trial_id, startDate: new Date(a0.start_date), endDate: new Date(a0.end_date), outboundRedemptionEndDate: a0.outbound_redemption_end_date != null ? new Date(a0.outbound_redemption_end_date) : null, inboundHeaderText: null, inboundBodyText: null, inboundHelpCenterLink: null, outboundTitle: null, outboundRedemptionModalBody: null, outboundTermsAndConditions: null, outboundRedemptionPageLink: null, outboundRedemptionUrlFormat: null, flags: null, inboundRestrictedCountries: null, outboundRestrictedCountries: null, allowedCountries: null, countryListMode: null, promotionType: null, partnerId: null, marketingComponents: null, rewardSkuIds: null, bogoRewardEnabled: null, promotionKey: null }; let inbound_header_text = a0.inbound_header_text; if (inbound_header_text == null) { inbound_header_text = ""; } r3.inboundHeaderText = inbound_header_text; let inbound_body_text = a0.inbound_body_text; if (inbound_body_text == null) { inbound_body_text = ""; } r3.inboundBodyText = inbound_body_text; let inbound_help_center_link = a0.inbound_help_center_link; if (inbound_help_center_link == null) { inbound_help_center_link = ""; } r3.inboundHelpCenterLink = inbound_help_center_link; let outbound_title = a0.outbound_title; if (outbound_title == null) { outbound_title = ""; } r3.outboundTitle = outbound_title; let outbound_redemption_modal_body = a0.outbound_redemption_modal_body; if (outbound_redemption_modal_body == null) { outbound_redemption_modal_body = ""; } r3.outboundRedemptionModalBody = outbound_redemption_modal_body; let outbound_terms_and_conditions = a0.outbound_terms_and_conditions; if (outbound_terms_and_conditions == null) { outbound_terms_and_conditions = ""; } r3.outboundTermsAndConditions = outbound_terms_and_conditions; let outbound_redemption_page_link = a0.outbound_redemption_page_link; if (outbound_redemption_page_link == null) { outbound_redemption_page_link = ""; } r3.outboundRedemptionPageLink = outbound_redemption_page_link; let outbound_redemption_url_format = a0.outbound_redemption_url_format; if (outbound_redemption_url_format == null) { outbound_redemption_url_format = ""; } r3.outboundRedemptionUrlFormat = outbound_redemption_url_format; r3.flags = a0.flags; r3.inboundRestrictedCountries = a0.inbound_restricted_countries; r3.outboundRestrictedCountries = a0.outbound_restricted_countries; let allowed_countries = a0.allowed_countries; if (allowed_countries == null) { allowed_countries = []; } r3.allowedCountries = allowed_countries; let country_list_mode = a0.country_list_mode; if (country_list_mode == null) { country_list_mode = CountryListMode.BLOCKLIST; } r3.countryListMode = country_list_mode; r3.promotionType = a0.promotion_type; let partner_id = a0.partner_id; if (partner_id == null) { partner_id = null; } r3.partnerId = partner_id; let marketing_components = a0.marketing_components; if (marketing_components == null) { marketing_components = []; } r3.marketingComponents = marketing_components; const metadata = a0.metadata; let rewardSkuIds = metadata == null ? void 0 : metadata.premium_promotion?.reward_sku_ids; if (rewardSkuIds == null) { const metadata2 = a0.metadata; rewardSkuIds = metadata2 == null ? void 0 : metadata2.gift_promotion?.reward_sku_ids; } if (rewardSkuIds == null) { rewardSkuIds = []; } r3.rewardSkuIds = rewardSkuIds; const metadata3 = a0.metadata; const r61 = metadata3 == null; let r62 = void 0; if (!r61) { const premium_promotion = metadata3.premium_promotion; const r64 = premium_promotion == null; r62 = void 0; if (!r64) { const reward_config = premium_promotion.reward_config; r62 = reward_config == null ? void 0 : reward_config.bogo?.enabled; } } r3.bogoRewardEnabled = r62 === true; let promotion_key = a0.promotion_key; if (promotion_key == null) { promotion_key = ""; } r3.promotionKey = promotion_key; return new PromotionRecord(r3); } get isBogo() { return this.promotionType === PromotionTypes.BOGO; } get isMarketingMoment() { return this.promotionType === PromotionTypes.MARKETING_MOMENT; } get hasBogoReward() { return this.bogoRewardEnabled; } hasFlag(a0) { return _Module1384.hasFlag(this.flags, a0); } isCountryRestricted(a0) { if (this.countryListMode === CountryListMode.ALLOWLIST) { return !this.allowedCountries.includes(a0); } const promotionType = this.promotionType; if (PromotionTypes.THIRD_PARTY_INBOUND !== promotionType && PromotionTypes.THIRD_PARTY_DIRECT_FULFILLMENT !== promotionType) { if (PromotionTypes.THIRD_PARTY_OUTBOUND !== promotionType && PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING !== promotionType) { return false; } return this.outboundRestrictedCountries.includes(a0); } return this.inboundRestrictedCountries.includes(a0); } } export default PromotionRecord;