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ACxC,aAAa,EAAE;gBACb,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;gBACtB,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;aAC1C,GACD,CACH,CACG,CACI,EACZ;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gPCHc,UAAE;;;;;;;;;;;yEAsCqB,UAAE,uPAMA,UAAE,uQAOF,UAAE,iqBAkBF,UAAE,uSAOF,UAAE,gXAQA,UAAE,qlCA2BJ,UAAE;;;;;6CAmBvB,UAAE,qJAOW,UAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2PCrMqF,UAAE;;;;;;;;;;;;;;;;;;;2PAiBF,UAAE;;;;;;;;;;;iTAqBxG,UAAE,wRAUgC,UAAE,kCACpC,UAAE;+CACF,UAAE;;;;;iBAUF,UAAE,2WAKF,UAAE,iLAGF,UAAE;;;;;;;;;","names":[],"sources":["src/components/controllers/dashboard/sc-cancel-dialog/sc-cancel-dialog.scss?tag=sc-cancel-dialog&encapsulation=shadow","src/components/controllers/dashboard/sc-cancel-dialog/sc-cancel-dialog.tsx","src/components/controllers/dashboard/subscription-details/sc-subscription-next-payment.tsx","src/components/controllers/dashboard/subscription-reactivate/sc-subscription-reactivate.tsx"],"sourcesContent":[":host {\n display: block;\n font-size: var(--sc-font-size-medium);\n}\n\n\n.close__button {\n position: absolute;\n top: 0;\n right: 0;\n font-size: 22px;\n}\n","import { Component, Event, EventEmitter, h, Prop, State } from '@stencil/core';\nimport { __ } from '@wordpress/i18n';\nimport apiFetch from '../../../../functions/fetch';\n\nimport { CancellationReason, Subscription, SubscriptionProtocol } from '../../../../types';\n\n@Component({\n tag: 'sc-cancel-dialog',\n styleUrl: 'sc-cancel-dialog.scss',\n shadow: true,\n})\nexport class ScCancelDialog {\n @Prop() open: boolean;\n @Prop() protocol: SubscriptionProtocol;\n @Prop() subscription: Subscription;\n @State() reasons: CancellationReason[];\n @State() reason: CancellationReason;\n @State() step: 'cancel' | 'survey' | 'discount' | 'discount-complete' = 'cancel';\n @State() comment: string;\n @Event({ cancelable: true }) scRequestClose: EventEmitter<'close-button' | 'keyboard' | 'overlay'>;\n @Event() scRefresh: EventEmitter<void>;\n\n close() {\n this.reset();\n this.trackAttempt();\n this.scRequestClose.emit('close-button');\n }\n\n reset() {\n this.reason = null;\n this.step = this.protocol?.preservation_enabled ? 'survey' : 'cancel';\n }\n\n async trackAttempt() {\n if (!this.protocol?.preservation_enabled) return;\n await apiFetch({\n method: 'PATCH',\n path: `surecart/v1/subscriptions/${this.subscription?.id}/preserve`,\n });\n }\n\n componentWillLoad() {\n this.reset();\n }\n\n render() {\n return (\n <sc-dialog\n style={{\n '--width': this.step === 'survey' ? '675px' : '500px',\n '--body-spacing': 'var(--sc-spacing-xxx-large)',\n }}\n noHeader\n open={this.open}\n onScRequestClose={() => this.close()}\n >\n <div\n class={{\n cancel: true,\n }}\n >\n <sc-button class=\"close__button\" type=\"text\" circle onClick={() => this.close()}>\n <sc-icon name=\"x\" />\n </sc-button>\n\n {this.step === 'cancel' && (\n <sc-subscription-cancel\n subscription={this.subscription}\n protocol={this.protocol}\n reason={this.reason}\n comment={this.comment}\n onScAbandon={() => this.close()}\n onScCancelled={() => {\n this.scRefresh.emit();\n this.reset();\n this.scRequestClose.emit('close-button');\n }}\n >\n <slot name=\"cancel-popup-content\" slot=\"cancel-popup-content\" />\n </sc-subscription-cancel>\n )}\n\n {this.step === 'survey' && (\n <sc-cancel-survey\n protocol={this.protocol}\n onScAbandon={() => this.close()}\n onScSubmitReason={e => {\n const { comment, reason } = e.detail;\n this.reason = reason;\n this.comment = comment;\n this.step = reason?.coupon_enabled ? 'discount' : 'cancel';\n }}\n />\n )}\n\n {this.step === 'discount' && (\n <sc-cancel-discount\n protocol={this.protocol}\n subscription={this.subscription}\n reason={this.reason}\n comment={this.comment}\n onScCancel={() => (this.step = 'cancel')}\n onScPreserved={() => {\n this.scRefresh.emit();\n this.reset();\n this.scRequestClose.emit('close-button');\n }}\n />\n )}\n </div>\n </sc-dialog>\n );\n }\n}\n","import { Component, Fragment, h, Prop, State, Host, Watch } from '@stencil/core';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '../../../../functions/fetch';\nimport { formatTaxDisplay } from '../../../../functions/tax';\nimport { groupBundleLineItems } from '../../../../functions/line-items';\nimport { Checkout, LineItem, Period, Product, ResponseError, Subscription, ManualPaymentMethod } from '../../../../types';\n\n@Component({\n tag: 'sc-subscription-next-payment',\n shadow: true,\n})\nexport class ScSubscriptionNextPayment {\n @Prop() subscription: Subscription;\n /** Update the payment method url */\n @Prop() updatePaymentMethodUrl: string;\n\n @State() period: Period;\n @State() loading: boolean = true;\n @State() error: ResponseError;\n @State() details: boolean;\n\n componentWillLoad() {\n this.fetch();\n }\n\n @Watch('subscription')\n handleSubscriptionChange() {\n this.fetch();\n }\n\n async fetch() {\n if (this.subscription?.cancel_at_period_end && this.subscription.current_period_end_at) {\n this.loading = false;\n return;\n }\n if (this.subscription?.status === 'canceled') {\n this.loading = false;\n return;\n }\n try {\n this.loading = true;\n this.period = (await apiFetch({\n method: 'PATCH',\n path: addQueryArgs(`surecart/v1/subscriptions/${this.subscription?.id}/upcoming_period`, {\n skip_product_group_validation: true,\n expand: [\n 'period.checkout',\n 'checkout.line_items',\n 'checkout.checkout_fees',\n 'checkout.shipping_fees',\n 'checkout.payment_method',\n 'checkout.manual_payment_method',\n 'payment_method.card',\n 'payment_method.payment_instrument',\n 'payment_method.paypal_account',\n 'payment_method.bank_account',\n 'line_item.price',\n 'line_item.fees',\n 'line_item.component_line_items',\n 'price.product',\n 'period.subscription',\n ],\n }),\n data: {\n purge_pending_update: false,\n },\n })) as Period;\n } catch (e) {\n console.error(e);\n this.error = e;\n } finally {\n this.loading = false;\n }\n }\n\n render() {\n if (this.loading) {\n return (\n <sc-toggle borderless disabled>\n <sc-flex slot=\"summary\" flexDirection=\"column\">\n <sc-skeleton style={{ width: '200px' }}></sc-skeleton>\n <sc-skeleton style={{ width: '400px' }}></sc-skeleton>\n <sc-skeleton style={{ width: '300px' }}></sc-skeleton>\n </sc-flex>\n </sc-toggle>\n );\n }\n\n const checkout = this?.period?.checkout as Checkout;\n if (!checkout)\n return (\n <div style={{ padding: 'var(--sc-spacing-medium)' }}>\n <sc-subscription-details slot=\"summary\" subscription={this.subscription}></sc-subscription-details>\n </div>\n );\n\n const manualPaymentMethod = checkout?.manual_payment ? (checkout?.manual_payment_method as ManualPaymentMethod) : null;\n const paymentMethodExists = this?.subscription.payment_method || this?.subscription.manual_payment;\n\n const checkout_fees = checkout?.checkout_fees?.data;\n const shipping_fees = checkout?.shipping_fees?.data;\n\n return (\n <Host>\n <sc-toggle borderless shady>\n <span slot=\"summary\">\n <sc-subscription-details subscription={this.subscription}>\n <div style={{ fontSize: 'var(--sc-font-size-small)' }}>\n {__('Your next payment is', 'surecart')} <strong>{checkout?.amount_due_display_amount}</strong>{' '}\n {!!this.subscription?.remaining_period_text && `— ${this.subscription?.remaining_period_text}`}\n </div>\n </sc-subscription-details>\n </span>\n\n <sc-card noPadding borderless>\n {(() => {\n const items = (checkout?.line_items?.data || []) as LineItem[];\n const { regular, bundleParents, componentsByParent } = groupBundleLineItems(items);\n const orderedItems = [...bundleParents, ...regular];\n return orderedItems.map(item => {\n const product = item?.price?.product as Product;\n const isBundle = !!product?.bundle;\n return (\n <sc-product-line-item\n key={item.id}\n image={product?.line_item_image}\n name={product?.name}\n price={item?.price?.name}\n variant={item?.variant_display_options}\n editable={false}\n removable={false}\n note={item?.display_note}\n scratchDisplayAmount={item?.scratch_display_amount}\n displayAmount={item?.subtotal_display_amount}\n quantity={item?.quantity}\n amount={item?.subtotal_display_amount}\n interval={`${item?.price?.short_interval_text} ${item?.price?.short_interval_count_text}`}\n purchasableStatus={item?.purchasable_status_display}\n fees={item?.fees?.data}\n bundleComponents={isBundle ? componentsByParent[item.id] || [] : []}\n ></sc-product-line-item>\n );\n });\n })()}\n\n <sc-line-item>\n <span slot=\"description\">{__('Subtotal', 'surecart')}</span>\n <span slot=\"price-description\">{checkout?.subtotal_display_amount}</span>\n </sc-line-item>\n\n {!!checkout.proration_amount && (\n <sc-line-item>\n <span slot=\"description\">{__('Proration Credit', 'surecart')}</span>\n <span slot=\"price-description\">{checkout?.proration_display_amount}</span>\n </sc-line-item>\n )}\n\n {!!checkout.applied_balance_amount && (\n <sc-line-item>\n <span slot=\"description\">{__('Applied Balance', 'surecart')}</span>\n <span slot=\"price-description\">{checkout?.applied_balance_display_amount}</span>\n </sc-line-item>\n )}\n\n {checkout_fees?.length > 0 && (\n <Fragment>\n {checkout_fees?.map(fee => (\n <sc-line-item>\n <span slot=\"description\">{fee?.description}</span>\n <span slot=\"price\">{fee?.display_amount}</span>\n </sc-line-item>\n ))}\n </Fragment>\n )}\n\n {!!checkout.trial_amount && (\n <sc-line-item>\n <span slot=\"description\">{__('Trial', 'surecart')}</span>\n <span slot=\"price-description\">{checkout?.trial_display_amount}</span>\n </sc-line-item>\n )}\n\n {!!checkout?.discount_amount && (\n <sc-line-item>\n <span slot=\"description\">{__('Discounts', 'surecart')}</span>\n <span slot=\"price-description\">{checkout?.discounts_display_amount}</span>\n </sc-line-item>\n )}\n\n {!!checkout?.shipping_amount && (\n <Fragment>\n <sc-line-item style={{ marginTop: 'var(--sc-spacing-small)' }}>\n <span slot=\"description\">{__('Shipping', 'surecart')}</span>\n <span slot=\"price-description\">{checkout?.shipping_display_amount}</span>\n </sc-line-item>\n {shipping_fees?.length > 0 && (\n <Fragment>\n {shipping_fees?.map(fee => (\n <sc-line-item>\n <span slot=\"description\">{fee?.description}</span>\n <span slot=\"price\">{fee?.display_amount}</span>\n </sc-line-item>\n ))}\n </Fragment>\n )}\n </Fragment>\n )}\n\n {!!checkout.tax_amount && (\n <sc-line-item>\n <span slot=\"description\">{formatTaxDisplay(checkout?.tax_label)}</span>\n <span slot=\"price-description\">{checkout?.tax_display_amount}</span>\n </sc-line-item>\n )}\n\n <sc-divider style={{ '--spacing': '0' }}></sc-divider>\n\n {this?.subscription?.can_modify && (\n <sc-line-item>\n <span slot=\"description\">{__('Payment', 'surecart')}</span>\n {paymentMethodExists && (\n <a href={this.updatePaymentMethodUrl} slot=\"price-description\">\n <sc-flex justify-content=\"flex-start\" align-items=\"center\" style={{ '--spacing': '0.5em' }}>\n {manualPaymentMethod ? <sc-manual-payment-method paymentMethod={manualPaymentMethod} /> : <sc-payment-method paymentMethod={checkout?.payment_method} />}\n <sc-icon name=\"edit-3\"></sc-icon>\n </sc-flex>\n </a>\n )}\n {!paymentMethodExists && (\n <a\n href={addQueryArgs(window.location.href, {\n action: 'create',\n model: 'payment_method',\n id: this?.subscription.id,\n ...(this?.subscription?.live_mode === false ? { live_mode: false } : {}),\n })}\n slot=\"price-description\"\n >\n {__('Add Payment Method', 'surecart')}\n </a>\n )}\n </sc-line-item>\n )}\n\n <sc-line-item style={{ '--price-size': 'var(--sc-font-size-x-large)' }}>\n <span slot=\"title\">{__('Total Due', 'surecart')}</span>\n <span slot=\"price\">{checkout?.amount_due_display_amount}</span>\n <span slot=\"currency\">{checkout.currency}</span>\n </sc-line-item>\n </sc-card>\n </sc-toggle>\n </Host>\n );\n }\n}\n","import { Component, Event, EventEmitter, Fragment, Prop, State, Watch, h } from '@stencil/core';\nimport { __ } from '@wordpress/i18n';\nimport { Checkout, Period, Subscription } from 'src/types';\nimport apiFetch from '../../../../functions/fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n@Component({\n tag: 'sc-subscription-reactivate',\n shadow: true,\n})\nexport class ScSubscriptionReactivate {\n /** Whether it is open */\n @Prop() open: boolean;\n\n /** The subscription to reactivate */\n @Prop() subscription: Subscription;\n\n /** Reactivate modal closed */\n @Event({ cancelable: true }) scRequestClose: EventEmitter<'close-button' | 'keyboard' | 'overlay'>;\n\n /** Refresh subscriptions */\n @Event() scRefresh: EventEmitter<void>;\n\n @State() busy: boolean;\n @State() error: string;\n @State() upcomingPeriod: Period;\n @State() loading: boolean = false;\n\n @Watch('open')\n openChanged() {\n if (this.open) {\n this.fetchUpcoming();\n }\n }\n\n async fetchUpcoming() {\n this.loading = true;\n try {\n this.upcomingPeriod = await apiFetch({\n method: 'PATCH',\n path: addQueryArgs(`surecart/v1/subscriptions/${this.subscription?.id}/upcoming_period`, {\n skip_product_group_validation: true,\n expand: ['period.checkout'],\n }),\n data: {\n purge_pending_update: false,\n },\n });\n } catch (e) {\n this.error = e?.additional_errors?.length ? e.additional_errors.map(err => err.message).join(', ') : e?.message || __('Something went wrong', 'surecart');\n } finally {\n this.loading = false;\n }\n }\n\n async reactivateSubscription() {\n try {\n this.error = '';\n this.busy = true;\n await apiFetch({\n path: `surecart/v1/subscriptions/${this.subscription?.id}/restore`,\n method: 'PATCH',\n });\n this.scRefresh.emit();\n this.scRequestClose.emit('close-button');\n } catch (e) {\n this.error = e?.additional_errors?.length ? e.additional_errors.map(err => err.message).join(', ') : e?.message || __('Something went wrong', 'surecart');\n } finally {\n this.busy = false;\n }\n }\n\n renderLoading() {\n return (\n <sc-flex flexDirection=\"column\" style={{ gap: '1em' }}>\n <sc-skeleton style={{ width: '20%', display: 'inline-block' }}></sc-skeleton>\n <sc-skeleton style={{ width: '60%', display: 'inline-block' }}></sc-skeleton>\n <sc-skeleton style={{ width: '40%', display: 'inline-block' }}></sc-skeleton>\n </sc-flex>\n );\n }\n\n render() {\n return (\n <sc-dialog noHeader open={this.open} style={{ '--width': '600px', '--body-spacing': 'var(--sc-spacing-xxx-large)' }}>\n <sc-dashboard-module\n loading={this.loading}\n heading={__('Resubscribe', 'surecart')}\n class=\"subscription-reactivate\"\n error={this.error}\n style={{ '--sc-dashboard-module-spacing': '1em' }}\n >\n {this.loading ? (\n this.renderLoading()\n ) : (\n <Fragment>\n <div slot=\"description\">\n <sc-alert open type=\"warning\" title={__('Confirm Charge', 'surecart')}>\n {__('You will be charged', 'surecart')} {(this.upcomingPeriod?.checkout as Checkout)?.amount_due_display_amount}{' '}\n {__('immediately for your subscription.', 'surecart')}\n </sc-alert>\n <sc-text\n style={{\n '--font-size': 'var(--sc-font-size-medium)',\n '--color': 'var(--sc-input-label-color)',\n '--line-height': 'var(--sc-line-height-dense)',\n 'margin-top': 'var(--sc-spacing-medium)',\n }}\n >\n {__('Your subscription will be reactivated and will renew automatically on', 'surecart')} <strong>{this.upcomingPeriod?.end_at_date}</strong>\n </sc-text>\n </div>\n <sc-flex justifyContent=\"flex-start\">\n <sc-button type=\"primary\" loading={this.busy} disabled={this.busy} onClick={() => this.reactivateSubscription()}>\n {__('Yes, Reactivate', 'surecart')}\n </sc-button>\n <sc-button disabled={this.busy} style={{ color: 'var(--sc-color-gray-500)' }} type=\"text\" onClick={() => this.scRequestClose.emit()}>\n {__('No, Keep Inactive', 'surecart')}\n </sc-button>\n </sc-flex>\n </Fragment>\n )}\n {this.busy && <sc-block-ui></sc-block-ui>}\n </sc-dashboard-module>\n </sc-dialog>\n );\n }\n}\n"],"version":3}