1import{a as he}from"./chunk-WAOG7FJX.js";import{a as Ce}from"./chunk-TI72JHGT.js";import"./chunk-KKJNMPRR.js";import{b as ue}from"./chunk-CY2J3GIN.js";import{a as ce}from"./chunk-GEEZBLFF.js";import{a as me,b as _e}from"./chunk-QSU7KPBE.js";import{a as ye}from"./chunk-UGWMOECH.js";import{a as R,c as pe}from"./chunk-XLMGQL6R.js";import"./chunk-DNARELQY.js";import"./chunk-BXRAC3DS.js";import"./chunk-K7W62ZCE.js";import"./chunk-3KZXYTMJ.js";import"./chunk-6YK7OVIW.js";import{a as le}from"./chunk-WKNCGDTZ.js";import"./chunk-BYXBJQAS.js";import"./chunk-FPPPRB7P.js";import"./chunk-WRZIS6FN.js";import"./chunk-S2BRUCAV.js";import"./chunk-2ELNDHLL.js";import"./chunk-WOYGRYZN.js";import"./chunk-AHQ4I7ZQ.js";import"./chunk-YIWE7DUC.js";import"./chunk-3J6GJA2Y.js";import"./chunk-XUFD7S2X.js";import{e as te,f as ne,j as ie,l as ae,o as re,p as oe,v as se,x as de}from"./chunk-RIJG5WA2.js";import"./chunk-2M5DVCDA.js";import"./chunk-IFD5OJGK.js";import"./chunk-YV3MWMI4.js";import{Gc as Z,Xa as T,Z as Q,_c as ee,dc as W,ec as J,hc as X,s as Y,t as k,u as N}from"./chunk-VBK23MFK.js";import{c as I}from"./chunk-MNOAC44J.js";import"./chunk-ZSKOB7NA.js";import"./chunk-JH3O7FZY.js";import{E as H,G as $,H as j,i as U}from"./chunk-SD7HBRTT.js";import{$ as g,Ab as c,Bb as m,Eb as z,Fb as F,Gb as P,Hb as r,Ib as o,Ic as S,Jb as C,Nc as K,Qb as b,Ub as w,Va as d,W as v,Wb as l,aa as f,bc as V,cc as q,fa as A,gc as M,ib as B,ic as s,jc as h,kc as O,lc as L,ma as y,pa as G}from"./chunk-LFZB7MMP.js";import"./chunk-IMPBB4AK.js";function ge(i,t="USD"){let e=Number(i).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});return t==="USD"?`$${e}`:`${t} ${e}`}var D=(u=>(u.Loading="loading",u.Ready="ready",u.NotPayable="not_payable",u.SignInRequired="sign_in_required",u.BrokenLink="broken_link",u.Success="success",u.Error="error",u))(D||{});var xe=["stripeCardContainer"],ve=(i,t)=>t.id;function Pe(i,t){i&1&&(r(0,"div",3),C(1,"i",6),r(2,"p"),s(3,"Loading your order\u2026"),o()())}function Se(i,t){if(i&1&&(r(0,"div",4),C(1,"i",7),r(2,"h1",8),s(3,"This payment link is not valid"),o(),r(4,"p"),s(5),o(),r(6,"a",9),s(7,"Request a new payment link"),o()()),i&2){let e=l();d(5),h(e.errorMessage())}}function be(i,t){if(i&1){let e=b();r(0,"div",4),C(1,"i",10),r(2,"h1",8),s(3,"Sign in required"),o(),r(4,"p"),s(5),o(),r(6,"app-button",11),w("click",function(){g(e);let a=l();return f(a.goToLogin())}),s(7," Sign in "),o()()}if(i&2){let e=l();d(5),h(e.errorMessage()),d(),M(e.ButtonStyle.Primary),P("size",e.ButtonSize.Medium)}}function we(i,t){if(i&1&&(r(0,"p",13),s(1),o()),i&2){let e=t;d(),L("Order ",e.order_number," \xB7 ",e.status_label||e.status)}}function Oe(i,t){if(i&1){let e=b();r(0,"div",3),C(1,"i",12),r(2,"h1",8),s(3,"This order is not awaiting payment"),o(),r(4,"p"),s(5),o(),c(6,we,2,2,"p",13),r(7,"app-button",11),w("click",function(){g(e);let a=l();return f(a.reload())}),s(8," Refresh "),o()()}if(i&2){let e,n=l();d(5),h(n.errorMessage()),d(),m((e=n.order())?6:-1,e),d(),M(n.ButtonStyle.Secondary),P("size",n.ButtonSize.Medium)}}function Me(i,t){if(i&1){let e=b();r(0,"div",4),C(1,"i",14),r(2,"h1",8),s(3,"Something went wrong"),o(),r(4,"p"),s(5),o(),r(6,"app-button",11),w("click",function(){g(e);let a=l();return f(a.reload())}),s(7," Try again "),o()()}if(i&2){let e=l();d(5),h(e.errorMessage()),d(),M(e.ButtonStyle.Primary),P("size",e.ButtonSize.Medium)}}function Ee(i,t){i&1&&s(0," \xB7 Paid in full ")}function Ie(i,t){if(i&1&&(r(0,"p",13),s(1),c(2,Ee,1,0),o()),i&2){let e=t;d(),O(" Order ",e.order_number," "),d(),m(e.amount_due===0?2:-1)}}function ke(i,t){if(i&1&&(r(0,"div",5),C(1,"i",15),r(2,"h1",8),s(3,"Payment received"),o(),r(4,"p"),s(5),o(),c(6,Ie,3,2,"p",13),r(7,"a",16),s(8,"Back to home"),o()()),i&2){let e,n=l();d(5),h(n.successMessage()),d(),m((e=n.order())?6:-1,e)}}function Ne(i,t){if(i&1&&(r(0,"p",13),s(1),o()),i&2){let e=l();d(),O("Placed ",e.date_created)}}function Te(i,t){if(i&1&&(r(0,"li",22)(1,"div",32)(2,"span",33),s(3),o(),r(4,"span",34),s(5),o()(),r(6,"span",35),s(7),o()()),i&2){let e=t.$implicit,n=l(),a=l(2);d(3),h(e.name),d(2),O("\xD7",e.quantity),d(2),h(a.formatMoney(e.total,n.currency))}}function Re(i,t){i&1&&(r(0,"li",23),s(1,"No line items"),o())}function De(i,t){if(i&1&&(r(0,"div",25)(1,"span"),s(2,"Shipping"),o(),r(3,"span"),s(4),o()()),i&2){let e=l(),n=l(2);d(4),h(n.formatMoney(e.totals.shipping_total,e.currency))}}function Ae(i,t){if(i&1&&(r(0,"div",25)(1,"span"),s(2,"Tax"),o(),r(3,"span"),s(4),o()()),i&2){let e=l(),n=l(2);d(4),h(n.formatMoney(e.totals.total_tax,e.currency))}}function Ge(i,t){if(i&1&&(r(0,"div",26)(1,"span"),s(2,"Discount"),o(),r(3,"span"),s(4),o()()),i&2){let e=l(),n=l(2);d(4),O("-",n.formatMoney(e.totals.discount_total,e.currency))}}function Be(i,t){if(i&1&&(r(0,"div",25)(1,"span"),s(2,"Already paid"),o(),r(3,"span"),s(4),o()()),i&2){let e=l(),n=l(2);d(4),h(n.formatMoney(e.amount_paid,e.currency))}}function ze(i,t){if(i&1&&(r(0,"div",30),C(1,"app-radio",36),o()),i&2){let e=l(3);d(),P("options",e.storeGateways())("formControl",e.gatewayControl)}}function Fe(i,t){if(i&1){let e=b();r(0,"div",31)(1,"p",37),s(2," Finish payment with PayPal below. Do not close this page. "),o(),r(3,"app-paypal-buttons",38),w("busyChange",function(a){g(e);let p=l(3);return f(p.onPaypalBusyChange(a))})("settled",function(a){g(e);let p=l(3);return f(p.onPaypalCaptureSettled(a))})("cancelled",function(){g(e);let a=l(3);return f(a.onPaypalApprovalCancelled())})("failed",function(a){g(e);let p=l(3);return f(p.onPaypalApprovalFailed(a))}),o()()}if(i&2){let e=t;d(3),P("clientId",e.clientId)("gatewayTransactionId",e.gatewayTransactionId)("transactionId",e.transactionId)("currency",e.currency)}}function Ve(i,t){if(i&1){let e=b();r(0,"div",39)(1,"app-saved-card-selector",45),w("cardSelected",function(a){g(e);let p=l(4);return f(p.onSavedCardSelected(a))})("addCardInlineRequested",function(){g(e);let a=l(4);return f(a.onAddCardInlineRequested())}),o()()}if(i&2){let e=l(4);d(),P("gateway",e.selectedGateway())("inlineAddCard",!0)}}function qe(i,t){if(i&1&&(r(0,"span",51),s(1),o()),i&2){let e=l(6);d(),h(e.stripeError())}}function Le(i,t){if(i&1&&(r(0,"div",47)(1,"label",49),s(2,"Card details"),o(),C(3,"div",50,0),c(5,qe,2,1,"span",51),o()),i&2){let e=l(5);d(5),m(e.stripeError()?5:-1)}}function Ke(i,t){if(i&1&&(r(0,"div",47),C(1,"app-input",52),o(),r(2,"div",53)(3,"div",47),C(4,"app-input",54),o(),r(5,"div",47),C(6,"app-input",55),o()(),r(7,"div",47),C(8,"app-input",56),o()),i&2){let e=l(5);d(),P("iconPosition",e.InputIconPosition.Right)}}function Ue(i,t){i&1&&C(0,"app-checkbox",48)}function He(i,t){if(i&1){let e=b();r(0,"form",46),w("ngSubmit",function(){g(e);let a=l(4);return f(a.onPay())}),c(1,Le,6,1,"div",47)(2,Ke,9,1),c(3,Ue,1,0,"app-checkbox",48),o()}if(i&2){let e=l(4);P("formGroup",e.paymentForm),d(),m(e.isStripeGateway()?1:2),d(2),m(e.showSaveCardCheckbox()?3:-1)}}function $e(i,t){i&1&&(r(0,"p",37),s(1," Click Pay to create the PayPal payment, then approve it in the popup on this page. "),o())}function je(i,t){i&1&&s(0," Processing\u2026 ")}function Ye(i,t){if(i&1&&s(0),i&2){let e=l(2),n=l(2);O(" Pay ",n.formatMoney(e.amount_due,e.currency)," ")}}function Qe(i,t){if(i&1){let e=b();r(0,"p",44),s(1," Already have an account? "),r(2,"button",57),w("click",function(){g(e);let a=l(4);return f(a.goToLogin())}),s(3,"Sign in"),o(),s(4," to use a saved card. "),o()}}function We(i,t){if(i&1){let e=b();c(0,Ve,2,2,"div",39),c(1,He,4,3,"form",40),c(2,$e,2,0,"p",37),r(3,"app-button",41),w("click",function(){g(e);let a=l(3);return f(a.onPay())}),c(4,je,1,0)(5,Ye,1,1),o(),r(6,"p",42),C(7,"i",43),s(8),o(),c(9,Qe,5,0,"p",44)}if(i&2){let e=l(3);m(e.isAuthenticated()&&e.isCardGateway()?0:-1),d(),m(e.showCardEntry()?1:-1),d(),m(e.isPaypalGateway()?2:-1),d(),M(e.ButtonStyle.Primary),P("size",e.ButtonSize.Wide)("disabled",!e.canPay())("loading",e.isSubmitting()),d(),m(e.isSubmitting()?4:5),d(4),O(" ",e.secureCheckoutLabel()," "),d(),m(!e.isAuthenticated()&&e.isCardGateway()?9:-1)}}function Je(i,t){if(i&1&&(r(0,"header",17)(1,"h1",8),s(2,"Pay for your order"),o(),r(3,"p",13),s(4),o(),c(5,Ne,2,1,"p",13),o(),r(6,"div",18)(7,"section",19)(8,"h2",20),s(9,"Order summary"),o(),r(10,"ul",21),z(11,Te,8,3,"li",22,ve,!1,Re,2,0,"li",23),o(),r(14,"div",24)(15,"div",25)(16,"span"),s(17,"Subtotal"),o(),r(18,"span"),s(19),o()(),c(20,De,5,1,"div",25),c(21,Ae,5,1,"div",25),c(22,Ge,5,1,"div",26),c(23,Be,5,1,"div",25),r(24,"div",27)(25,"span"),s(26,"Amount due"),o(),r(27,"span"),s(28),o()()()(),r(29,"section",28)(30,"h2",29),s(31,"Payment"),o(),c(32,ze,2,2,"div",30),c(33,Fe,4,4,"div",31)(34,We,10,11),o()()),i&2){let e,n=t,a=l(2);d(4),O("Order ",n.order_number),d(),m(n.date_created?5:-1),d(6),F(n.items),d(8),h(a.formatMoney(n.totals.subtotal,n.currency)),d(),m(n.totals.shipping_total>0?20:-1),d(),m(n.totals.total_tax>0?21:-1),d(),m(n.totals.discount_total>0?22:-1),d(),m(n.amount_paid>0?23:-1),d(5),h(a.formatMoney(n.amount_due,n.currency)),d(4),m(a.storeGateways().length>1&&!a.paypalPendingApproval()?32:-1),d(),m((e=a.paypalPendingApproval())?33:34,e)}}function Xe(i,t){if(i&1&&c(0,Je,35,11),i&2){let e,n=l();
1m((e=n.order())?0:-1,e)}}var fe=class i{route=v(H);router=v($);fb=v(se);orderPayApi=v(ce);ordersApi=v(Z);checkoutApi=v(Q);authService=v(ee);notification=v(Y);destroyRef=v(A);ButtonStyle=J;ButtonSize=W;InputIconPosition=me;OrderPayPageState=D;formatMoney=ge;isAuthenticated=S(()=>this.authService.isLoggedIn());pageState=y("loading");errorMessage=y(null);order=y(null);orderKey=y("");customerOrderId=y(null);storeGateways=y([]);selectedGateway=y("stripe");gatewayControl=this.fb.control("stripe",{nonNullable:!0});selectedSavedCard=y(null);showNewCardForm=y(!1);savedCardInitialized=!1;stripeCardContainer=K("stripeCardContainer");stripeInstance=null;stripeCardElement=null;stripeReady=y(!1);stripeError=y(null);cardFilled=y(!1);isSubmitting=y(!1);successMessage=y(null);paypalPendingApproval=y(null);isPaypalBusy=y(!1);payIdempotencyKey=null;paymentForm=this.fb.group({cardNumber:[""],expiryDate:[""],cvv:[""],nameOnCard:[""],saveCard:[!1]});isStripeGateway=S(()=>this.selectedGateway()==="stripe");isPaypalGateway=S(()=>this.selectedGateway()==="paypal");isCardGateway=S(()=>R(this.selectedGateway()));showCardEntry=S(()=>this.isCardGateway()?this.isAuthenticated()?this.showNewCardForm():!0:!1);showSaveCardCheckbox=S(()=>this.isAuthenticated()&&this.showCardEntry());hasPayment=S(()=>this.isPaypalGateway()?!!this.storeGateways().find(t=>t.gateway==="paypal")?.client_id:this.isAuthenticated()&&this.selectedSavedCard()&&!this.showNewCardForm()?!0:this.showCardEntry()?this.isStripeGateway()?this.stripeReady():this.cardFilled():!1);canPay=S(()=>!(!this.order()?.is_payable||this.isSubmitting()||this.isPaypalBusy()||this.paypalPendingApproval()||!this.hasPayment()));secureCheckoutLabel=S(()=>{let t=this.storeGateways().find(e=>e.gateway===this.selectedGateway());return t?.display_name?`Secure payment powered by ${t.display_name}`:"Secure payment"});constructor(){G(()=>{let t=this.stripeCardContainer()?.nativeElement;if(this.pageState()==="ready"&&this.showCardEntry()&&this.isStripeGateway()&&t){this.initializeStripe(t);return}this.destroyStripeElement()})}ngOnInit(){let t=this.route.snapshot.paramMap.get("orderKey")??"",e=this.route.snapshot.queryParamMap.get("orderId"),n=e?Number(e):null;this.orderKey.set(t),this.customerOrderId.set(n&&Number.isFinite(n)?n:null),this.paymentForm.valueChanges.pipe(T(this.destroyRef)).subscribe(a=>{let p=(a.cardNumber||"").replace(/\s/g,""),x=a.expiryDate||"",u=a.cvv||"",_=(a.nameOnCard||"").trim();this.cardFilled.set(p.length>=13&&x.length>=4&&u.length>=3&&_.length>=2)}),this.gatewayControl.valueChanges.pipe(T(this.destroyRef)).subscribe(a=>{this.selectedGateway.set(a),this.destroyStripeElement()}),this.loadStoreGateways(),t?this.loadOrderByKey(t):n&&Number.isFinite(n)?this.loadOrderByCustomerId(n):(this.pageState.set("broken_link"),this.errorMessage.set("This payment link is not valid."))}onSavedCardSelected(t){this.selectedSavedCard.set(t),t!==null?(this.showNewCardForm.set(!1),this.savedCardInitialized=!0,this.gatewayControl.setValue(t.gateway)):this.savedCardInitialized&&this.showNewCardForm.set(!0)}onAddCardInlineRequested(){this.selectedSavedCard.set(null),this.savedCardInitialized=!0,this.showNewCardForm.set(!0)}reload(){let t=this.orderKey(),e=this.customerOrderId();t?this.loadOrderByKey(t):e&&this.loadOrderByCustomerId(e)}async onPay(){if(!this.canPay())return;if(this.isPaypalGateway()){this.submitPaypalPay();return}let t=this.selectedSavedCard(),e=this.isAuthenticated()&&t&&!this.showNewCardForm(),n=this.showCardEntry();if(!e&&!n){this.notification.error("Please provide payment information");return}if(n&&this.isStripeGateway()&&!this.stripeReady()){this.notification.error(this.stripeError()||"Please complete your card details");return}this.isSubmitting.set(!0);let a;try{if(e&&t)a={gateway:t.gateway,payment_method:t.payment_method||"credit_card",payment_token_id:t.id};else if(this.isStripeGateway()){let{paymentMethodId:_}=await this.tokenizeStripeCard();a=this.buildNewCardRequest("stripe",{payment_method_id:_})}else{let _=this.paymentForm.value,E=this.selectedGateway();a=this.buildNewCardRequest(E,pe(E,{cardNumber:String(_.cardNumber??""),expirationDate:String(_.expiryDate??""),securityCode:String(_.cvv??""),holderName:String(_.nameOnCard??"")}))}}catch(_){this.isSubmitting.set(!1);let E=_ instanceof Error?_.message:"Payment tokenization failed";this.notification.error(E);return}this.payIdempotencyKey||(this.payIdempotencyKey=crypto.randomUUID());let p=this.orderKey(),x=this.customerOrderId(),u=p?this.orderPayApi.payOrder(p,a,this.payIdempotencyKey):x?this.ordersApi.payOrder(x,a,this.payIdempotencyKey):null;if(!u){this.isSubmitting.set(!1),this.notification.error("Unable to submit payment for this order.");return}u.subscribe({next:_=>this.handlePaySuccess(_),error:_=>this.handlePayError(_)})}submitPaypalPay(){this.isSubmitting.set(!0);let t={gateway:"paypal",payment_method:"digital_wallet"};this.payIdempotencyKey||(this.payIdempotencyKey=crypto.randomUUID());let e=this.orderKey(),n=this.customerOrderId(),a=e?this.orderPayApi.payOrder(e,t,this.payIdempotencyKey):n?this.ordersApi.payOrder(n,t,this.payIdempotencyKey):null;if(!a){this.isSubmitting.set(!1),this.notification.error("Unable to submit payment for this order.");return}a.subscribe({next:p=>this.handlePaySuccess(p),error:p=>this.handlePayError(p)})}handlePaySuccess(t){if(this.isSubmitting.set(!1),!t.status||!t.data){this.payIdempotencyKey=null,this.notification.error(t.message||"Payment failed");return}let{payment_status:e,redirect_url:n,order:a,transaction_id:p,gateway_transaction_id:x}=t.data;if(e==="pending"){if(this.payIdempotencyKey=null,p&&x&&!n){let u=this.storeGateways().find(_=>_.gateway==="paypal")?.client_id?.trim()||"";if(!u){this.notification.error("PayPal is not configured for this store.");return}this.order.set(a),this.paypalPendingApproval.set({transactionId:p,gatewayTransactionId:x,clientId:u,currency:a.currency||"USD"}),this.notification.info("Complete payment with PayPal to finish your order.");return}if(n){window.location.href=n;return}this.notification.info(t.message||"Payment is waiting on confirmation from the payment provider. Do not close this page.");return}this.payIdempotencyKey=null,this.paypalPendingApproval.set(null),this.order.set(a),this.successMessage.set(t.message||"Payment received."),this.pageState.set("success")}onPaypalBusyChange(t){this.isPaypalBusy.set(t)}onPaypalCaptureSettled(t){this.paypalPendingApproval.set(null),this.isPaypalBusy.set(!1),t.orderStatus==="pending-payment"||t.orderStatus==="pending"?this.successMessage.set("Your payment is being processed. You will receive confirmation once it settles."):this.successMessage.set(t.message||"Payment received."),this.pageState.set("success")}onPaypalApprovalCancelled(){this.paypalPendingApproval.set(null),this.isPaypalBusy.set(!1),this.notification.info("PayPal payment was cancelled. You can try again.")}onPaypalApprovalFailed(t){if(this.isPaypalBusy.set(!1),t.status===409){this.notification.error("Another payment attempt is in progress. Please wait a moment and refresh \u2014 do not retry immediately.");return}this.notification.error(t.message);let e=t.message.toLowerCase();t.status===422&&(e.includes("sync")||e.includes("match"))&&this.paypalPendingApproval.set(null)}handlePayError(t){this.isSubmitting.set(!1);
1let e=t.status,n=t.error?.message||"Payment could not be completed. Please try again.";if((e===402||e===409||e===422||e===403||e===404)&&(this.payIdempotencyKey=null),e===402){this.notification.error(n);return}if(!(N(t)||k(t)||I(t))){if(e===403){this.pageState.set("sign_in_required"),this.errorMessage.set(n||"Sign in with the account that placed this order to continue.");return}if(e===404){this.pageState.set("broken_link"),this.errorMessage.set("This payment link is not valid.");return}if(e===409){this.notification.error(n),this.reload();return}if(e===422){this.notification.error(n);return}if(e===429){this.notification.error("Too many attempts \u2014 please wait a moment and try again.");return}this.notification.error(n)}}buildNewCardRequest(t,e){let n={gateway:t,payment_method:"credit_card",payment_method_data:e};return this.isAuthenticated()&&this.paymentForm.value.saveCard&&(n.save_card=!0),n}loadOrderByKey(t){this.pageState.set("loading"),this.errorMessage.set(null),this.orderPayApi.getPayableOrder(t).subscribe({next:e=>{if(!e.status||!e.data){this.pageState.set("error"),this.errorMessage.set(e.message||"Unable to load this order.");return}this.applyPayableOrder(e.data,e.message)},error:e=>this.handleLookupError(e)})}loadOrderByCustomerId(t){if(!this.isAuthenticated()){this.pageState.set("sign_in_required"),this.errorMessage.set("Sign in to pay this order from your account.");return}this.pageState.set("loading"),this.errorMessage.set(null),this.ordersApi.getOrder(t).subscribe({next:e=>{if(!e.status||!e.data){this.pageState.set("error"),this.errorMessage.set(e.message||"Unable to load this order.");return}let n=this.mapCustomerOrderToPayable(e.data);this.applyPayableOrder(n,null)},error:e=>this.handleLookupError(e)})}applyPayableOrder(t,e){if(this.order.set(t),!t.is_payable){this.pageState.set("not_payable"),this.errorMessage.set(e||"This order is not awaiting payment.");return}this.pageState.set("ready")}handleLookupError(t){if(!(N(t)||k(t)||I(t))){if(t.status===401||t.status===403){this.pageState.set("sign_in_required"),this.errorMessage.set(t.error?.message||"Sign in with the account that placed this order to continue.");return}if(t.status===404){this.pageState.set("broken_link"),this.errorMessage.set("This payment link is not valid.");return}if(t.status===429){this.pageState.set("error"),this.errorMessage.set("Too many requests \u2014 please wait a moment and refresh.");return}this.pageState.set("error"),this.errorMessage.set(t.error?.message||"Unable to load this order.")}}mapCustomerOrderToPayable(t){let e=t.status==="pending"||t.status==="pending-payment"||t.status==="on-hold",n=Math.max(0,Number(t.total)-Number(t.total_refunded||0));return{order_number:t.order_number,status:t.status,status_label:t.status,currency:t.currency,is_payable:e&&n>0,amount_due:n,amount_paid:t.date_paid?Number(t.total):0,fulfillment_type:t.fulfillment_type,order_processing_type:t.order_processing_type,delivery_at:t.delivery_at,date_created:t.date_created,date_paid:t.date_paid,totals:{currency:t.currency,subtotal:t.subtotal,total_tax:t.total_tax,cart_tax:t.cart_tax,shipping_total:t.shipping_total,shipping_tax:t.shipping_tax,fees_total:t.fees_total??0,service_fee_total:t.service_fee_total??0,handling_fee_total:t.handling_fee_total??0,discount_total:t.discount_total,coupon_amount:t.coupon_amount,gift_card_amount:t.gift_card_amount,points_discount_amount:t.points_discount_amount,tip_amount:t.tip_amount,total:t.total},pickup_location:t.pickup_location,shipping_address:null,shipping_line:t.shipping_lines?.[0]??null,fees:t.fees??[],items:ue(t).map(a=>({id:a.id,order_id:a.order_id,name:a.name,quantity:a.quantity,price:a.price,subtotal:a.subtotal,total:a.total,product_image:a.product_image,addons:a.addons,taxes:a.taxes})),notes:{customer_note:t.customer_note,food_note:t.food_note,dropoff_option:null,dropoff_note:null},contact:{first_name:t.contact_first_name,last_name:t.contact_last_name,email:t.contact_email,phone:t.contact_phone}}}loadStoreGateways(){this.checkoutApi.getPaymentMethods({isEnabledForPaymentLinks:!0}).subscribe({next:t=>{let e=t.filter(n=>R(n.gateway)||n.gateway==="paypal"&&!!n.client_id);this.storeGateways.set(e),e.length>0&&this.gatewayControl.setValue(e[0].gateway)},error:()=>{}})}initializeStripe(t){if(this.stripeCardElement)return;let e=this.storeGateways().find(p=>p.gateway==="stripe")?.publishable_key?.trim();if(!e){this.stripeError.set("Card payment is currently unavailable. Please choose another payment method.");return}let n=()=>{this.stripeInstance=Stripe(e);let p=this.stripeInstance.elements();
1this.stripeCardElement=p.create("card",{style:{base:{fontSize:"16px",color:"#424770",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',"::placeholder":{color:"#aab7c4"}},invalid:{color:"#9e2146"}}}),this.stripeCardElement.mount(t),this.stripeCardElement.on("change",x=>{this.stripeError.set(x.error?.message||null),this.stripeReady.set(x.complete)})};if(typeof Stripe<"u"){n();return}let a=document.createElement("script");a.src="https://js.stripe.com/v3/",a.async=!0,a.onload=()=>n(),a.onerror=()=>this.stripeError.set("Failed to load payment processor. Please refresh the page."),document.head.appendChild(a)}destroyStripeElement(){this.stripeCardElement&&(this.stripeCardElement.destroy(),this.stripeCardElement=null),this.stripeReady.set(!1),this.stripeError.set(null)}tokenizeStripeCard(){return!this.stripeInstance||!this.stripeCardElement?Promise.reject(new Error("Card entry is not ready. Please try again.")):this.stripeInstance.createPaymentMethod({type:"card",card:this.stripeCardElement}).then(t=>{if(t.error)throw new Error(t.error.message);if(!t.paymentMethod?.id)throw new Error("Failed to tokenize card");return{paymentMethodId:t.paymentMethod.id}})}goToLogin(){let t=this.router.url;this.router.navigate(["/login"],{queryParams:{returnUrl:t}})}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=B({type:i,selectors:[["app-order-pay"]],viewQuery:function(e,n){e&1&&V(n.stripeCardContainer,xe,5),e&2&&q()},decls:9,vars:1,consts:[["stripeCardContainer",""],[1,"order-pay"],[1,"order-pay__container"],[1,"order-pay__state"],[1,"order-pay__state","order-pay__state--error"],[1,"order-pay__state","order-pay__state--success"],["aria-hidden","true",1,"fa-solid","fa-spinner","fa-spin"],["aria-hidden","true",1,"fa-solid","fa-link-slash"],[1,"order-pay__title"],["routerLink","/orders/request-pay-link",1,"order-pay__link"],["aria-hidden","true",1,"fa-solid","fa-user-lock"],[3,"click","size"],["aria-hidden","true",1,"fa-solid","fa-circle-info"],[1,"order-pay__meta"],["aria-hidden","true",1,"fa-solid","fa-exclamation-circle"],["aria-hidden","true",1,"fa-solid","fa-circle-check"],["routerLink","/",1,"order-pay__link"],[1,"order-pay__header"],[1,"order-pay__layout"],["aria-labelledby","order-pay-summary-heading",1,"order-pay__summary"],["id","order-pay-summary-heading",1,"order-pay__section-title"],[1,"order-pay__items"],[1,"order-pay__item"],[1,"order-pay__item","order-pay__item--empty"],[1,"order-pay__totals"],[1,"order-pay__total-row"],[1,"order-pay__total-row","order-pay__total-row--discount"],[1,"order-pay__total-row","order-pay__total-row--due"],["aria-labelledby","order-pay-payment-heading",1,"order-pay__payment"],["id","order-pay-payment-heading",1,"order-pay__section-title"],[1,"order-pay__gateways"],[1,"order-pay__paypal-approve"],[1,"order-pay__item-info"],[1,"order-pay__item-name"],[1,"order-pay__item-qty"],[1,"order-pay__item-price"],["optionValueKey","gateway","optionLabelKey","display_name",3,"options","formControl"],[1,"order-pay__paypal-hint"],[3,"busyChange","settled","cancelled","failed","clientId","gatewayTransactionId","transactionId","currency"],[1,"order-pay__saved-cards"],[1,"order-pay__card-form",3,"formGroup"],[3,"click","size","disabled","loading"],[1,"order-pay__secure"],["aria-hidden","true",1,"fa-solid","fa-lock"],[1,"order-pay__login-hint"],[3,"cardSelected","addCardInlineRequested","gateway","inlineAddCard"],[1,"order-pay__card-form",3,"ngSubmit","formGroup"],[1,"order-pay__field"],["label","Save this card for future use","formControlName","saveCard"],[1,"order-pay__label"],[1,"order-pay__stripe-element"],[1,"order-pay__field-error"],["placeholder","Card number","icon","lock","mask","cardNumber","formControlName","cardNumber",3,"iconPosition"],[1,"order-pay__field-row"],["placeholder","MM / YY","mask","cardExpiry","formControlName","expiryDate"],["placeholder","CVV","mask","cardCvc","formControlName","cvv"],["placeholder","Name on card","formControlName","nameOnCard"],["type","button",1,"order-pay__text-btn",3,"click"]],template:function(e,n){if(e&1&&(r(0,"div",1)(1,"div",2),c(2,Pe,4,0,"div",3)(3,Se,8,1,"div",4)(4,be,8,4,"div",4)(5,Oe,9,5,"div",3)(6,Me,8,4,"div",4)(7,ke,9,2,"div",5)(8,Xe,1,1
1),o()()),e&2){let a;d(2),m((a=n.pageState())===n.OrderPayPageState.Loading?2:a===n.OrderPayPageState.BrokenLink?3:a===n.OrderPayPageState.SignInRequired?4:a===n.OrderPayPageState.NotPayable?5:a===n.OrderPayPageState.Error?6:a===n.OrderPayPageState.Success?7:a===n.OrderPayPageState.Ready?8:-1)}},dependencies:[U,de,ie,te,ne,ae,oe,re,j,X,_e,ye,le,Ce,he],styles:[".order-pay[_ngcontent-%COMP%]{min-height:60vh;padding:32px 16px 64px}.order-pay__container[_ngcontent-%COMP%]{max-width:960px;margin:0 auto}.order-pay__header[_ngcontent-%COMP%]{margin-bottom:24px}.order-pay__title[_ngcontent-%COMP%]{margin:0 0 8px;font-size:28px;font-weight:700;color:var(--text-primary, #1a1a1a)}.order-pay__meta[_ngcontent-%COMP%]{margin:0;font-size:14px;color:var(--text-secondary, #666)}.order-pay__section-title[_ngcontent-%COMP%]{margin:0 0 16px;font-size:18px;font-weight:600;color:var(--text-primary, #1a1a1a)}.order-pay__layout[_ngcontent-%COMP%]{display:grid;gap:24px}@media(min-width:768px){.order-pay__layout[_ngcontent-%COMP%]{grid-template-columns:1fr 1fr;align-items:start}}.order-pay__summary[_ngcontent-%COMP%], .order-pay__payment[_ngcontent-%COMP%]{background:var(--surface, #fff);border:1px solid var(--border-color, #e5e5e5);border-radius:8px;padding:24px}.order-pay__items[_ngcontent-%COMP%]{list-style:none;margin:0 0 16px;padding:0}.order-pay__item[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--border-color, #eee);font-size:14px}.order-pay__item--empty[_ngcontent-%COMP%]{color:var(--text-secondary, #666)}.order-pay__item-info[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:4px}.order-pay__item-name[_ngcontent-%COMP%]{font-weight:500;color:var(--text-primary, #1a1a1a)}.order-pay__item-qty[_ngcontent-%COMP%]{color:var(--text-secondary, #666);font-size:12px}.order-pay__totals[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px}.order-pay__total-row[_ngcontent-%COMP%]{display:flex;justify-content:space-between;font-size:14px;color:var(--text-primary, #1a1a1a)}.order-pay__total-row--discount[_ngcontent-%COMP%]{color:var(--success, #2e7d32)}.order-pay__total-row--due[_ngcontent-%COMP%]{margin-top:8px;padding-top:12px;border-top:1px solid var(--border-color, #e5e5e5);font-size:18px;font-weight:700}.order-pay__gateways[_ngcontent-%COMP%], .order-pay__saved-cards[_ngcontent-%COMP%], .order-pay__card-form[_ngcontent-%COMP%]{margin-bottom:16px}.order-pay__field[_ngcontent-%COMP%]{margin-bottom:12px}.order-pay__field-row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:12px}.order-pay__label[_ngcontent-%COMP%]{display:block;margin-bottom:6px;font-size:13px;font-weight:500;color:var(--text-primary, #1a1a1a)}.order-pay__stripe-element[_ngcontent-%COMP%]{width:100%;box-sizing:border-box;border:1px solid var(--border-color, #ddd);border-radius:6px;padding:12px;font-size:16px;background:var(--surface, #fff)}.order-pay__field-error[_ngcontent-%COMP%]{display:block;margin-top:6px;font-size:12px;color:var(--error, #c62828)}.order-pay__paypal-hint[_ngcontent-%COMP%]{margin:0 0 12px;font-size:14px;line-height:1.4;color:var(--text-secondary, #666)}.order-pay__paypal-approve[_ngcontent-%COMP%]{margin-top:8px}.order-pay__secure[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;margin:12px 0 0;font-size:12px;color:var(--text-secondary, #666)}.order-pay__login-hint[_ngcontent-%COMP%]{margin:16px 0 0;font-size:13px;color:var(--text-secondary, #666)}.order-pay__text-btn[_ngcontent-%COMP%], .order-pay__link[_ngcontent-%COMP%]{background:none;border:0;padding:0;color:var(--primary, #222);text-decoration:underline;cursor:pointer;font:inherit}.order-pay__state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;text-align:center;gap:12px;padding:48px 16px;background:var(--surface, #fff);border-radius:8px;border:1px solid var(--border-color, #e5e5e5)}.order-pay__state[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{font-size:40px;color:var(--text-secondary, #666)}.order-pay__state--error[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:var(--error, #c62828)}.order-pay__state--success[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:var(--success, #2e7d32)}.order-pay__state[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;max-width:420px;color:var(--text-secondary, #666);font-size:14px}"],changeDetection:0})};export{fe as OrderPayComponent};
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.