1(function(global){var billingZeroDecimalCurrencies={JPY:!0,KRW:!0,CLP:!0};function getPricePreviewData(preview){if(!preview){return null} 2return preview.data||preview} 3function convertBillingAmountFromLowestUnit(amount,currencyCode){var numeric=parseFloat(String(amount||'0').replace(/[^\d.-]/g,''));if(isNaN(numeric)){return null} 4if(billingZeroDecimalCurrencies[currencyCode]){return numeric} 5return numeric/100} 6function stripBillingPriceDecimals(formattedPrice){return String(formattedPrice||'').replace(/([.,])(\d{1,2})(?!\d)/,'').trim()} 7function stripCurrencyPrefix(formattedValue){return String(formattedValue||'').replace(/^[^\d.-]+/,'').trim()} 8function formatBillingDisplayPrice(amount,currencyCode,formattedFallback){var majorAmount=convertBillingAmountFromLowestUnit(amount,currencyCode);if(majorAmount===null||!currencyCode){return stripBillingPriceDecimals(formattedFallback)} 9if(typeof Intl!=='undefined'&&typeof Intl.NumberFormat==='function'){return new Intl.NumberFormat(navigator.language||'en-US',{style:'currency',currency:currencyCode,minimumFractionDigits:0,maximumFractionDigits:0}).format(Math.ceil(majorAmount))} 10return stripBillingPriceDecimals(formattedFallback)} 11function formatAddonCardAmount(rawAmount,currencyCode,formattedFallback){return getAddonCardPriceParts(rawAmount,currencyCode,formattedFallback).amount} 12function getAddonCardPriceParts(rawAmount,currencyCode,formattedFallback){var majorAmount=convertBillingAmountFromLowestUnit(rawAmount,currencyCode);if(majorAmount!==null&&!isNaN(majorAmount)&¤cyCode&&typeof Intl!=='undefined'&&typeof Intl.NumberFormat==='function'&&typeof Intl.NumberFormat.prototype.formatToParts==='function'){var parts=new Intl.NumberFormat(navigator.language||'en-US',{style:'currency',currency:currencyCode,minimumFractionDigits:0,maximumFractionDigits:0}).formatToParts(Math.ceil(majorAmount));var currency='';var amount='';parts.forEach(function(part){if(part.type==='currency'){currency+=part.value} 13if(part.type==='integer'||part.type==='group'||part.type==='decimal'||part.type==='fraction'){amount+=part.value}});return{currency:currency.trim(),amount:amount.trim()}} 14return splitFormattedPrice(formatBillingDisplayPrice(rawAmount,currencyCode,formattedFallback))} 15function splitFormattedPrice(formattedPrice){var text=String(formattedPrice||'').trim();if(!text){return{currency:'',amount:''}} 16var match=text.match(/^([^\d]*?)\s*([\d][\d.,\s]*)\s*([^\d]*)$/);if(!match){return{currency:'',amount:stripCurrencyPrefix(text)}} 17var leadingCurrency=(match[1]||'').trim();var amount=(match[2]||'').trim();var trailingCurrency=(match[3]||'').trim();return{currency:leadingCurrency||trailingCurrency,amount:amount}} 18function hasBillingPreviewDiscount(totals,formattedTotals){var discount=(totals&&totals.discount)||(formattedTotals&&formattedTotals.discount)||'0';var numericDiscount=parseFloat(String(discount).replace(/[^0-9.-]/g,''));return!isNaN(numericDiscount)&&numericDiscount>0} 19function getDiscountedBillingSubtotal(subtotal,discount){var numericSubtotal=parseInt(String(subtotal||'0').replace(/[^\d-]/g,''),10);var numericDiscount=parseInt(String(discount||'0').replace(/[^\d-]/g,''),10);if(isNaN(numericSubtotal)){return subtotal} 20if(isNaN(numericDiscount)||numericDiscount<=0){return subtotal} 21return String(Math.max(numericSubtotal-numericDiscount,0))} 22function getLineItemUnitPriceAmount(item){var unitPrice=item.price&&(item.price.unitPrice||item.price.unit_price);if(!unitPrice){return null} 23return unitPrice.amount||null} 24function getLineItemCurrencyCode(item,fallbackCurrencyCode){var unitPrice=item.price&&(item.price.unitPrice||item.price.unit_price);if(unitPrice){return unitPrice.currencyCode||unitPrice.currency_code||fallbackCurrencyCode||'USD'} 25return fallbackCurrencyCode||'USD'} 26function getLineItemListAmount(item){var totals=item.totals||{};var unitTotals=item.unit_totals||item.unitTotals||{};return totals.subtotal||unitTotals.subtotal||totals.total||unitTotals.total||getLineItemUnitPriceAmount(item)||'0'} 27function getLineItemPurchaseAmount(item,listAmount,discountAmount){var totals=item.totals||{};var unitTotals=item.unit_totals||item.unitTotals||{};var discountedSubtotal=getDiscountedBillingSubtotal(listAmount,discountAmount);var tax=totals.tax||unitTotals.tax||'0';var numericTax=parseInt(String(tax).replace(/[^\d-]/g,''),10);if(!isNaN(numericTax)&&numericTax>0){return discountedSubtotal} 28return totals.total||unitTotals.total||discountedSubtotal} 29function buildLineItemPricePreview(item,currencyCode){var formattedTotals=item.formattedTotals||item.formatted_totals||{};var totals=item.totals||{};var unitTotals=item.unit_totals||item.unitTotals||{};var itemCurrencyCode=currencyCode||getLineItemCurrencyCode(item,'USD');var discountAmount=totals.discount||unitTotals.discount||formattedTotals.discount||'0';var listSubtotal=getLineItemListAmount(item);var originalAmount=listSubtotal;var currentAmount=getLineItemPurchaseAmount(item,listSubtotal,discountAmount);var hasDiscount=hasBillingPreviewDiscount(totals,formattedTotals)||hasBillingPreviewDiscount(unitTotals,formattedTotals);if(hasDiscount&&String(originalAmount)===String(currentAmount)){currentAmount=getDiscountedBillingSubtotal(originalAmount,discountAmount)} 30hasDiscount=hasDiscount&&String(originalAmount)!==String(currentAmount);var tax=totals.tax||unitTotals.tax||'0';var numericTax=parseInt(String(tax).replace(/[^\d-]/g,''),10);var originalFormatted=formattedTotals.subtotal||formattedTotals.total||'';var currentFormatted=formattedTotals.total||formattedTotals.subtotal||'';if(!isNaN(numericTax)&&numericTax>0){originalFormatted=formattedTotals.subtotal||'';currentFormatted=''} 31return{originalAmount:originalAmount,currentAmount:currentAmount,originalFormatted:originalFormatted,currentFormatted:currentFormatted,currencyCode:itemCurrencyCode,hasDiscount:hasDiscount}} 32function getDisplayPartsFromPreview(pricePreview,amountKey,formattedKey){var formatted=pricePreview[formattedKey];if(formatted){var formattedParts=splitFormattedPrice(stripBillingPriceDecimals(formatted)||formatted);if(formattedParts.amount){return formattedParts}} 33return getAddonCardPriceParts(pricePreview[amountKey],pricePreview.currencyCode,formatted)} 34function buildPreviewGroups(plans){var previewGroups={};plans.forEach(function(plan){if(!plan.priceId){return} 35var groupKey=plan.discountId||'base';if(!previewGroups[groupKey]){previewGroups[groupKey]={discountId:plan.discountId||null,priceIds:[],priceIdMap:{}}
35} 36if(!previewGroups[groupKey].priceIdMap[plan.priceId]){previewGroups[groupKey].priceIdMap[plan.priceId]=!0;previewGroups[groupKey].priceIds.push(plan.priceId)}});return previewGroups} 37function fetchGroupedPricePreviews(plans){if(typeof Paddle==='undefined'||typeof Paddle.PricePreview!=='function'){return Promise.resolve({})} 38var previewGroups=buildPreviewGroups(plans);var groupKeys=Object.keys(previewGroups);if(!groupKeys.length){return Promise.resolve({})} 39return Promise.all(groupKeys.map(function(groupKey){var group=previewGroups[groupKey];var request={items:group.priceIds.map(function(priceId){return{priceId:priceId,quantity:1}})};if(group.discountId){request.discountId=group.discountId} 40return Paddle.PricePreview(request).then(function(preview){var data=getPricePreviewData(preview);var details=data&&data.details?data.details:null;var previewCurrencyCode=(data&&(data.currencyCode||data.currency_code))||'';var lineItems=details?(details.lineItems||details.line_items||[]):[];var previewPrices={};lineItems.forEach(function(item){var priceId=(item.price&&item.price.id)||item.price_id;if(!priceId){return} 41previewPrices[priceId]=buildLineItemPricePreview(item,previewCurrencyCode||'USD')});return previewPrices})})).then(function(results){var merged={};results.forEach(function(groupPrices){Object.assign(merged,groupPrices)});return merged})} 42function fetchPlanPricePreview(plan){if(!plan||!plan.priceId){return Promise.resolve(null)} 43if(typeof Paddle==='undefined'||typeof Paddle.PricePreview!=='function'){return Promise.resolve(null)} 44var request={items:[{priceId:plan.priceId,quantity:1}]};if(plan.discountId){request.discountId=plan.discountId} 45return Paddle.PricePreview(request).then(function(preview){var data=getPricePreviewData(preview);var details=data&&data.details?data.details:null;var previewCurrencyCode=(data&&(data.currencyCode||data.currency_code))||'';var lineItems=details?(details.lineItems||details.line_items||[]):[];var item=lineItems[0];if(!item){return null} 46return buildLineItemPricePreview(item,previewCurrencyCode||'USD')})} 47function parsePreviewAmount(value){return parseInt(String(value||'0').replace(/[^\d-]/g,''),10)||0} 48function aggregateLineItemTotals(details){var lineItems=details.lineItems||details.line_items||[];var aggregated={subtotal:0,discount:0,tax:0,total:0};lineItems.forEach(function(item){var itemTotals=item.totals||{};aggregated.subtotal+=parsePreviewAmount(itemTotals.subtotal);aggregated.discount+=parsePreviewAmount(itemTotals.discount);aggregated.tax+=parsePreviewAmount(itemTotals.tax);aggregated.total+=parsePreviewAmount(itemTotals.total)});return{subtotal:String(aggregated.subtotal),discount:String(aggregated.discount),tax:String(aggregated.tax),total:String(aggregated.total)}} 49function resolvePreviewTotals(details){var totals=details.totals||{};if(parsePreviewAmount(totals.subtotal)>0||parsePreviewAmount(totals.total)>0){return totals} 50return aggregateLineItemTotals(details)} 51function getPricePreviewTaxTotals(preview){var data=getPricePreviewData(preview);var details=data&&data.details?data.details:{};var totals=resolvePreviewTotals(details);var formattedTotals=(details.totals&&(details.totals.formattedTotals||details.totals.formatted_totals))||{};return{tax:totals.tax||'0',formattedTax:formattedTotals.tax||''}} 52function getTransactionPreviewTotals(preview){var data=getPricePreviewData(preview);var details=data&&data.details?data.details:{};var totals=resolvePreviewTotals(details);var currencyCode=(data&&(data.currencyCode||data.currency_code))||totals.currencyCode||totals.currency_code||'USD';var subtotal=totals.subtotal||totals.total||'0';var total=totals.total||subtotal;var discount=totals.discount||'0';var savings=discount;if((!savings||savings==='0')&&subtotal!==total){savings=String(Math.max(0,parsePreviewAmount(subtotal)-parsePreviewAmount(total)))} 53return{currencyCode:currencyCode,subtotal:subtotal,total:total,savings:savings}} 54function updateAddonCardPrice(card,listParts,discountParts,hasDiscount){if(!card){return} 55var listCurrencyEl=card.querySelector('.tms-store-card-plan-price-currency');var amountEl=card.querySelector('.tms-store-card-plan-price-amount');var discountCurrencyEl=card.querySelector('.tms-store-card-plan-discount-price-currency');var discountEl=card.querySelector('.tms-store-card-plan-discount-price-amount');var discountDiv=card.querySelector('.tms-store-card-plan-discount');var loader=card.querySelector('.tms-store-card-loader');if(listCurrencyEl&&listParts&&listParts.currency!==''){listCurrencyEl.textContent=listParts.currency} 56if(amountEl&&listParts&&listParts.amount!==''){amountEl.textContent=listParts.amount} 57if(hasDiscount&&discountEl&&discountParts&&discountParts.amount!==''){if(discountCurrencyEl&&discountParts.currency!==''){discountCurrencyEl.textContent=discountParts.currency} 58discountEl.textContent=discountParts.amount;if(discountDiv){discountDiv.style.display=''}}else if(discountDiv){discountDiv.style.display='none'} 59if(loader){loader.style.display=''}} 60function applyAddonCardPricePreview(card,pricePreview){if(!card||!pricePreview){return} 61var listParts=getDisplayPartsFromPreview(pricePreview,'originalAmount','originalFormatted');var discountParts=getDisplayPartsFromPreview(pricePreview,'currentAmount','currentFormatted');var hasDiscount=pricePreview.hasDiscount;if(hasDiscount&&listParts.amount&&discountParts.amount){var listValue=parseFloat(String(listParts.amount).replace(/,/g,'').replace(/\s/g,''));var totalValue=parseFloat(String(discountParts.amount).replace(/,/g,'').replace(/\s/g,''));if(!isNaN(listValue)&&!isNaN(totalValue)&&listValue<totalValue){updateAddonCardPrice(card,discountParts,listParts,!0);return} 62updateAddonCardPrice(card,listParts,discountParts,!0);return} 63updateAddonCardPrice(card,discountParts.amount?discountParts:listParts,discountParts,!1)} 64global.wpdtPaddleBillingPreview={getPricePreviewData:getPricePreviewData,convertBillingAmountFromLowestUnit:convertBillingAmountFromLowestUnit,formatBillingDisplayPrice:formatBillingDisplayPrice,formatAddonCardAmount:formatAddonCardAmount,getAddonCardPriceParts:getAddonCardPriceParts,buildLineItemPricePreview:buildLineItemPricePreview,fetchGroupedPricePreviews:fetchGroupedPricePreviews,fetchPlanPricePreview:fetchPlanPricePreview,getTransactionPreviewTotals:getTransactionPreviewTotals,getPricePreviewTaxTotals:getPricePreviewTaxTotals,applyAddonCardPricePreview:applyAddonCardPricePreview,hasBillingPreviewDiscount:hasBillingPreviewDiscount}})(typeof window!=='undefined'?window:this)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.