var BreadSDK=function(e){"use strict";function n(e,n){return n.forEach((function(n){Object.keys(n).forEach((function(t){if("default"!==t&&!(t in e)){var r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:function(){return n[t]}})}}))})),Object.freeze(e)}function t(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,u)}c((r=r.apply(e,n||[])).next())}))}function r(e){return{currency:"USD",value:u(e)}}function i(e){return{currency:"CAD",value:u(e)}}function o(e,n){return{currency:n,value:u(e)}}function a(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:e.currency}).format(e.value/100)}const u=e=>{if(void 0!==e&&isNaN(e))return u(0);if(!c(e))throw new Error("value must be an integer");return e},c=e=>Number.isInteger(e)||e===1/0,s=(e,n)=>{const{rate:t,numberOfPayments:r,frequency:i}=e;if("W"===i.designator&&t>0)throw new Error(`Interest bearing loans with a weekly frequency are unsupported. ${JSON.stringify({paymentTerms:e},null,"\t")}`);const o=(({principal:e,rateBPS:n,periods:t,frequency:r})=>{if(0===n)return u(Math.ceil(e/t));const i=n/1e4/(12/r.length),o=e*i/(1-Math.pow(1+i,-t));return u(Math.ceil(o))})({principal:n.value,rateBPS:t,periods:r,frequency:i});return Object.assign({paymentAmount:o},e)};var d,f=function(e){return"Left"===e._tag},l=function(e){return{_tag:"Right",right:e}},p=(d=function(e,n){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])},d(e,n)},function(e,n){function t(){this.constructor=e}d(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}),h=function(){return h=Object.assign||function(e){for(var n,t=1,r=arguments.length;t"}function x(e,n,t,r){for(var i=e.length,o=Array(i+1),a=0;a"}function P(e){var n;if(F(e)){var t=e.value;if(Z.is(t))return(n={})[t]=null,n}else{if("KeyofType"===e._tag)return e.keys;if(N(e)){var r=e.types.map((function(e){return P(e)}));return r.some(K.is)?void 0:Object.assign.apply(Object,m([{}],r))}}}function _(e){return"("+e.map((function(e){return e.name})).join(" | ")+")"}function S(e,n){for(var t=!0,r=!0,i=!ce.is(e),o=0,a=n;o0)){t=T;break}t[r]=i}else t[r]=n[r];return t}(e,q(n))}),T);if(N(e))return e.types.slice(1).reduce((function(e,n){return function(e,n){if(e===T||n===T)return T;var t=T;for(var r in e)n.hasOwnProperty(r)&&0===U(e[r],n[r]).length&&(t===T&&(t={}),t[r]=e[r].concat(n[r]));return t}(e,q(n))}),q(e.types[0]));if(function(e){return"RecursiveType"===e._tag}(e)){j.push(e);var i=q(e.type);return j.pop(),i}return T}function z(e){for(var n=q(e[0]),t=Object.keys(n),r=e.length,i=function(t){for(var i=n[t].slice(),o=[n[t]],a=1;a"),new ve(n,(function(n){return ae.is(n)&&n.every(e.is)}),(function(n,t){var r=ae.validate(n,t);if(f(r))return r;for(var i=r.right,o=i.length,a=i,u=[],c=0;c0?g(u):y(a)}),e.encode===b?b:function(n){return n.map(e.encode)},e)}var we=function(e){function n(n,t,r,i,o){var a=e.call(this,n,t,r,i)||this;return a.props=o,a._tag="InterfaceType",a}return p(n,e),n}(w);function be(e,n){void 0===n&&(n=O(e));var t=Object.keys(e),r=t.map((function(n){return e[n]})),i=t.length;return new we(n,(function(e){if(ce.is(e)){for(var n=0;n0?g(c):y(u)}),D(r)?b:function(e){for(var n=h({},e),o=0;o0?g(c):y(u)}),D(r)?b:function(e){for(var n=h({},e),o=0;o0?g(c):y(s||Object.keys(a).length!==i?u:a)}),t.encode===b?b:function(n){for(var r={},o=0;o0?g(o):y(c?i:t)}return k(n)&&Array.isArray(t)?y(t):v(t,r)}),e.encode===b&&n.encode===b?b:function(t){for(var r={},i=Object.keys(t),o=i.length,a=0;a0){var r=t[0],i=t[1],o=i.length,a=function(e){for(var n=0;n0?g(o):y(S(n,i))},0===e.length?b:function(n){return S(n,e.map((function(e){return e.encode(n)})))},e)}var Pe=function(e){function n(n,t,r,i,o){var a=e.call(this,n,t,r,i)||this;return a.types=o,a._tag="TupleType",a}return p(n,e),n}(w);var _e=function(e){function n(n,t,r,i,o){var a=e.call(this,n,t,r,i)||this;return a.type=o,a._tag="ReadonlyType",a}return p(n,e),n}(w);var Se=function(e){function n(n,t,r,i,o){var a=e.call(this,n,t,r,i)||this;return a.type=o,a._tag="ReadonlyArrayType",a}return p(n,e),n}(w);var Ce=function(e){function n(n,t,r,i,o){var a=e.call(this,n,t,r,i)||this;return a.type=o,a._tag="ExactType",a}return p(n,e),n}(w);function Me(e,n){void 0===n&&(n=function(e){return L(e)?"{| "+W(e.props)+" |}":function(e){return"PartialType"===e._tag}(e)?A("{| "+W(e.props)+" |}"):"Exact<"+e.name+">"}(e));var t=C(e);return new Ce(n,e.is,(function(n,r){var i=ce.validate(n,r);if(f(i))return i;var o=e.validate(n,r);return f(o)?o:l(M(o.right,t))}),(function(n){return e.encode(M(n,t))}),e)}var Te=function(e){function n(){var n=e.call(this,"Function",(function(e){return"function"==typeof e}),(function(e,t){return n.is(e)?y(e):v(e,t)}),b)||this;return n._tag="FunctionType",n}return p(n,e),n}(w),Ue=new Te,ke=function(e){function n(n,t,r,i,o,a){var u=e.call(this,n,t,r,i,o)||this;return u.tag=a,u}return p(n,e),n}(We),Fe=function(e){function n(){var n=e.call(this,"never",(function(e){return!1}),(function(e,n){return v(e,n)}),(function(){throw new Error("cannot encode never")}))||this;return n._tag="NeverType",n}return p(n,e),n}(w),Le=new Fe,Ne=function(e){function n(){var n=e.call(this,"any",(function(e){return!0}),y,b)||this;return n._tag="AnyType",n}return p(n,e),n}(w),je=new Ne,qe=ce,ze=function(e){function n(){var n=e.call(this,"object",(function(e){return null!==e&&"object"==typeof e}),(function(e,t){return n.is(e)?y(e):v(e,t)}),b)||this;return n._tag="ObjectType",n}return p(n,e),n}(w),Be=new ze;function $e(e,n,t){return void 0===t&&(t="("+e.name+" | "+I(n)+")"),new pe(t,(function(t){return e.is(t)&&n(t)}),(function(t,r){var i=e.validate(t,r);if(f(i))return i;var o=i.right;return n(o)?y(o):v(o,r)}),e.encode,e,n)}var Ve=$e(ee,Number.isInteger,"Integer"),Ke=Re,Ye=function(e){function n(n,t,r,i,o){var a=e.call(this,n,t,r,i)||this;return a.props=o,a._tag="StrictType",a}return p(n,e),n}(w);var He=Object.freeze({__proto__:null,failures:g,failure:v,success:y,Type:w,identity:b,getFunctionName:I,getContextEntry:function(e,n){return{key:e,type:n}},appendContext:x,getDomainKeys:P,mergeAll:S,emptyTags:T,getTags:q,getIndex:z,NullType:B,nullType:$,UndefinedType:V,VoidType:Y,voidType:H,UnknownType:J,unknown:G,StringType:X,string:Z,NumberType:Q,number:ee,BigIntType:ne,bigint:te,BooleanType:re,boolean:ie,AnyArrayType:oe,UnknownArray:ae,AnyDictionaryType:ue,UnknownRecord:ce,null:$,undefined:K,void:H,LiteralType:se,literal:de,KeyofType:fe,keyof:le,RefinementType:pe,brand:he,Int:me,RecursiveType:ge,recursion:function(e,n){var t,r=function(){return t||((t=n(i)).name=e),t},i=new ge(e,(function(e){return r().is(e)}),(function(e,n){return r().validate(e,n)}),(function(e){return r().encode(e)}),r);return i},ArrayType:ve,array:ye,InterfaceType:we,type:be,PartialType:Ie,partial:xe,DictionaryType:Ee,record:Re,UnionType:We,union:De,IntersectionType:Oe,intersection:Ae,TupleType:Pe,tuple:function(e,n){void 0===n&&(n="["+e.map((function(e){return e.name})).join(", ")+"]");var t=e.length;return new Pe(n,(function(n){return ae.is(n)&&n.length===t&&e.every((function(e,t){return e.is(n[t])}))}),(function(n,r){var i=ae.validate(n,r);if(f(i))return i;for(var o=i.right,a=o.length>t?o.slice(0,t):o,u=[],c=0;c0?g(u):y(a)}),D(e)?b:function(n){return e.map((function(e,t){return e.encode(n[t])}))},e)},ReadonlyType:_e,readonly:function(e,n){return void 0===n&&(n="Readonly<"+e.name+">"),new _e(n,e.is,e.validate,e.encode,e)},ReadonlyArrayType:Se,readonlyArray:function(e,n){void 0===n&&(n="ReadonlyArray<"+e.name+">");var t=ye(e);return new Se(n,t.is,t.validate,t.encode,e)},strict:function(e,n){return Me(be(e),n)},ExactType:Ce,exact:Me,FunctionType:Te,Function:Ue,TaggedUnionType:ke,taggedUnion:function(e,n,t){void 0===t&&(t=_(n));var r=De(n,t);return r instanceof ke?r:(console.warn("[io-ts] Cannot build a tagged union for "+t+", returning a de-optimized union"),new ke(t,r.is,r.validate,r.encode,n,e))},Array:ae,interface:be,getValidationError:function(e,n){return{value:e,context:n}},getDefaultContext:function(e){return[{key:"",type:e}]},NeverType:Fe,never:Le,AnyType:Ne,any:je,Dictionary:qe,ObjectType:ze,object:Be,refinement:$e,Integer:Ve,dictionary:Ke,StrictType:Ye,clean:function(e){return e},alias:function(e){return function(){return e}}});be({code:ee,domain:Z,message:Z,metadata:Re(Z,Z),reason:Z}),be({code:ee,error:Z,message:Z,details:ye(be({reason:Z,domain:Z,metadata:Re(Z,Z)}))});var Je="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ge(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Xe(e){if(e.__esModule)return e;var n=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}function Ze(e){var n={exports:{}};return e(n,n.exports),n.exports}var Qe=Ze((function(e,n){Object.defineProperty(n,"__esModule",{value:!0}),n.tailRec=void 0,n.tailRec=function(e,n){for(var t=n(e);"Left"===t._tag;)t=n(t.left);return t.right}})),en=Ze((function(e,n){function t(e){return e}function r(e){return function(){return e}}function i(e){throw new Error("Called `absurd` function which should be uncallable")}Object.defineProperty(n,"__esModule",{value:!0}),n.bindTo_=n.bind_=n.hole=n.pipe=n.untupled=n.tupled=n.absurd=n.decrement=n.increment=n.tuple=n.flow=n.flip=n.constVoid=n.constUndefined=n.constNull=n.constFalse=n.constTrue=n.constant=n.not=n.unsafeCoerce=n.identity=void 0,n.identity=t,n.unsafeCoerce=t,n.not=function(e){return function(n){return!e(n)}},n.constant=r,n.constTrue=r(!0),n.constFalse=r(!1),n.constNull=r(null),n.constUndefined=r(void 0),n.constVoid=n.constUndefined,n.flip=function(e){return function(n,t){return e(t,n)}},n.flow=function(e,n,t,r,i,o,a,u,c){switch(arguments.length){case 1:return e;case 2:return function(){return n(e.apply(this,arguments))};case 3:return function(){return t(n(e.apply(this,arguments)))};case 4:return function(){return r(t(n(e.apply(this,arguments))))};case 5:return function(){return i(r(t(n(e.apply(this,arguments)))))};case 6:return function(){return o(i(r(t(n(e.apply(this,arguments))))))};case 7:return function(){return a(o(i(r(t(n(e.apply(this,arguments)))))))};case 8:return function(){return u(a(o(i(r(t(n(e.apply(this,arguments))))))))};case 9:return function(){return c(u(a(o(i(r(t(n(e.apply(this,arguments)))))))))}}},n.tuple=function(){for(var e=[],n=0;n"string"==typeof e&&sn.test(e),fn=new w("URL",dn,((e,n)=>dn(e)?y(e):v(e,n)),(function(e){return e})),ln=De([de("Visa"),de("Mastercard"),de("Discover"),de("Amex")]);be({appID:Z,addressValidationSchemaName:De([de("USAddressSchema"),de("CanadaAddressSchema")]),allowDirectSDKPageAccess:ie,apiUrl:fn,buyerIdentityAttributes:ye(De([de("birthDate"),de("hasIIN"),de("iinShort"),de("name")])),datadogAppID:Z,datadogClientToken:Z,datadogEnabled:ie,datadogEnv:Z,datadogSite:Z,splunkEventCollectorToken:Z,splunkEventCollectorUrl:Z,datePickerFormat:De([de("DMY"),de("MDY")]),defaultMerchantConfig:cn,ecommExperiencePath:Z,enableIDVerification:ie,environment:Z,footerComponent:De([de("ADSFooter"),de("RBCFooter")]),googleApiKey:Z,hostUrl:Z,iovationBlackboxSubkey:Z,locales:ye(De([de("en"),de("fr")])),requiresIIN:ie,shippingCountry:De([de("US"),de("CA")]),tenantID:Z,tenantDisplayName:Ae([be({en:Z}),xe({fr:Z})]),demoHost:be({integrationKey:Z,dynamicIntegrationKeys:De([$,Re(Z,Z)]),currency:De([de("USD"),de("CAD")]),sdkNamespace:De([de("BreadPayments"),de("RBCPayPlan")])}),linkUrls:De([Re(Z,Re(Z,Z)),$]),themeStyles:be({dangerColor:Z,warningColor:Z,warningColorSecondary:Z,fontFamily:Z}),featureFlagsEnabled:ie,helpPhone:Z,faqUrl:Z,supportUrl:Z,availableCardTypes:ye(ln),useConsoleLogging:ie});const pn=be({apiUrl:fn,ecommExperiencePath:Z,hostUrl:fn,placementText:De([$,be({en:Z,fr:Z})]),shippingCountry:De([de("US"),de("CA")])}),hn=be({annualIncome:De([ee,$]),companyAddress:Z,companyName:Z,currency:Z,occupation:Z,occupationDescription:Z,type:Z}),mn=Ae([be({familyName:Z,givenName:Z}),xe({additionalName:Z})]),gn=Ae([be({email:Z,name:mn,phone:Z}),xe({birthDate:Z,emailDuplicate:ie,emailVerified:ie,phoneDuplicate:ie,phoneVerified:ie,iinShort:Z,iin:Z,hasIIN:ie})]),vn=be({address1:Z,address2:Z,country:Z,locality:Z,postalCode:Z,region:Z}),yn=Ae([be({address:vn,email:Z,name:mn,phone:Z}),be({id:Z,buyerID:Z,createdAt:Z,updatedAt:Z})]),wn=be({contacts:Re(Z,yn),createdAt:Z,employment:hn,id:Z,primaryContactID:Z,doNotSellOrShare:ie,updatedAt:Z}),bn=be({identity:gn,languagePreference:Z});Ae([wn,bn]),Ae([bn,xe(wn.props)]),be({email:Z,phone:Z});const In=De([ye(Ae([be({type:Z}),xe({acceptedAt:Z,checksum:Z})])),$]);be({disclosures:In});const xn=be({currency:Z,value:me}),En=be({id:Z,dueDate:Z,amount:xn,interest:xn,principal:xn}),Rn=be({id:Z,schedule:be({installments:ye(En)}),balanceSummary:be({totalInterestEstimate:xn})});var Wn;be({paymentAgreement:Rn}),function(e){e.INSTALLMENTS="INSTALLMENTS",e.SPLITPAY="SPLITPAY"}(Wn||(Wn={}));const Dn=be({originalPrincipal:xn,interval:De([de("MONTHLY"),de("BIWEEKLY")]),length:ee,rate:ee}),On=be({value:Z,expiresAt:Z}),An=be({createdAt:Z,expiresAt:Z,id:Z,paymentAmount:xn,status:Z,terms:Dn,updatedAt:Z}),Pn=be({capacity:xn,createdAt:Z,id:Z,overflowCapacity:De([xn,K]),paymentAgreement:An,paymentProduct:be({id:Z,type:le(Wn)}),shortCode:De([On,K]),status:Z,statusCodes:De([ye(Z),$]),updatedAt:Z,schedule:be({installments:ye(En)}),interest:xn}),_n=Ae([be({name:Z,quantity:ee,shippingCost:xn,shippingDescription:De([Z,on]),unitPrice:xn,unitTax:xn}),xe({category:Z,itemUrl:Z,sku:Z,shippingProvider:Z,shippingTrackingNumber:Z,shippingTrackingURL:Z})]),Sn=be({items:De([ye(_n),K]),subTotal:xn,totalDiscounts:xn,totalPrice:xn,totalShipping:xn,totalTax:xn}),Cn=be({address:vn,email:Z,name:mn,phone:Z});var Mn;!function(e){e.APPROVED="APPROVED",e.ATTEMPTED_CHECKOUT="ATTEMPTED_CHECKOUT",e.ATTEMPTED_PREPARE_CHECKOUT="ATTEMPTED_PREPARE_CHECKOUT",e.CANCELLED="CANCELLED",e.CHECKOUT_COMPLETED="CHECKOUT_COMPLETED",e.CHECKOUT_PREPARED="CHECKOUT_PREPARED",e.DENIED="DENIED",e.EXPIRED="EXPIRED",e.INELIGIBLE="INELIGIBLE",e.NEEDS_ACTION="NEEDS_ACTION",e.STARTED="STARTED",e.UPDATED="UPDATED"}(Mn||(Mn={}));const Tn=be({key:Z,value:Z}),Un=be({type:Z,value:Z}),kn=be({buyerShippingContactID:Z,ipAddress:Z,paymentAgreementID:De([Z,K]),status:le(Mn),statusCodes:De([ye(Z),$]),transactionID:Z,shippingContact:Cn,paymentMethodID:Z}),Fn=be({billingContact:Cn,buyerID:Z,capacity:xn,createdAt:Z,expiresAt:Z,id:Z,merchantID:Z,programID:Z,offers:De([ye(Pn),K]),clientInfo:De([ye(Un),K]),extensions:De([ye(Tn),K])}),Ln=be({order:Sn,disclosures:In}),Nn=Ae([Fn,Ln,xe(kn.props)]);Ae([Ln,xe(Fn.props)]),ye(Nn),Ae([be({merchantID:Z,programID:Z,referenceID:Z,credentials:Ae([be({code:Z}),xe({dob:Z,iin:Z,firstName:Z,lastName:Z})])}),xe({buyerID:Z})]),be({token:Z,tokenExpiresAt:Z,buyerID:Z}),be({token:Z});const jn=be({id:Z,paymentMethodType:Z,scopeID:Z,scopeType:G,cardAccount:xe({cardType:Z,cardName:Z,last4:Z,expirationMonth:Z,expirationYear:Z,nonce:Z,provider:Z,disabled:ie})});var qn;be({paymentMethod:Ae([jn,be({name:Z})])}),be({paymentMethods:ye(jn)}),be({paymentMethod:jn}),function(e){e.DEBIT="DEBIT",e.CREDIT="CREDIT"}(qn||(qn={})),Ae([be({id:Z,programID:Z,merchantID:Z,appID:Z}),xe({externalID:Z,locationID:Z,locationShortCode:De([Z,$])})]);const zn=de("APPLICATION");be({buyerID:Z,image:Z}),be({buyerID:Z,imageID:Z});const Bn=De([de("04"),de("05")]);be({frontImageID:Z,backImageID:Z,origin:Bn,scopeType:zn,scopeID:Z}),be({buyerID:Z,metadata:be({attempts:ee,maxAttempts:ee,failReasons:De([ye(Z),K])}),statusCode:Z});const $n=be({enabled:ie,provider:Z}),Vn=be({downPayment:be({installments:ie})}),Kn=be({id:Z,merchantID:Z,programID:Z,defaultOTPMethod:Z,fundingPaymentMethodID:De([Z,$]),defaultCartAmount:xn,policies:De([K,be({virtualCardSettings:De([K,$n])})]),createdAt:Z,capabilities:Vn,deletedAt:De([Z,$])}),Yn=De([de("INSTALLMENTS"),de("SPLITPAY")]),Hn=be({id:Z,programID:Z,name:Z,description:Z,numPayments:ee,paymentFrequency:Z,minInterestRateBPS:ee,maxInterestRateBPS:ee,paymentMethodTypes:ye(Z),autopayRequired:ie,type:Yn,requiredDownPaymentBPS:ee,legalAgreements:Re(Z,G),policies:Re(Z,G),workflowIDs:Re(Z,G),createdAt:Z,deletedAt:De([Z,$])}),Jn=be({minCartSize:xn,maxCartSize:xn}),Gn=be({paymentProduct:Hn,merchantValues:Jn});be({merchantPaymentProducts:ye(Gn)});const Xn=De([de("TapToPay"),de("KeyEntry")]),Zn=be({id:Z,name:Z,url:Z,merchantLogo:Z,phoneNumber:Z,hipaaRestricted:ie,posCheckoutCapability:De([ye(Xn),$,K]),borrowRatioBPS:De([ee,K])});be({merchant:Zn});const Qn=De([de("USD"),de("CAD")]),et=be({id:Z,tenantID:Z,name:Z,currency:Qn,defaultLanguage:Z,displayInterestRateBPS:ee,policies:be({application:be({tof:be({disclosures:De([ye(be({type:Z,requiresChecksum:ie})),K])})})}),capabilities:Vn}),nt=be({program:et,merchantPaymentProducts:ye(Gn),merchantProgramValues:Kn,merchantConfig:cn,merchantDetails:Zn});be({checksum:Z,text:Z}),new w("string",(e=>"string"==typeof e),((e,n)=>"string"==typeof e?y(e):v(e,n)),b);const tt=De([de("SMS"),de("EMAIL")]),rt=be({auth:be({token:Z})});be({email:De([Z,K,$]),phone:De([Z,K,$]),deliveryMethod:tt,disclosures:In,uat:De([rt,K])}),be({referenceID:Z});be({scopeType:le({APPLICATION:null}),scopeID:Z,programID:Z,buyerID:Z});const it=be({applicationID:Z,merchantID:Z,merchantLocationID:Z,offerID:Z});var ot;!function(e){e.REQUESTED="REQUESTED",e.PROCESSING="PROCESSING",e.ISSUED="ISSUED",e.FAILED="FAILED",e.CLOSED="CLOSED"}(ot||(ot={}));const at=Ae([be({id:Z,status:le(ot),scopeType:Z,scopeID:Z}),xe({inStore:it,buyerID:Z,programID:Z,tenantID:Z,paymentProductID:Z})]),ut=be({currency:Z,value:ee});var ct;be({serverSessionId:Z,clientSessionId:Z,tokenSetting:ee,cardSetting:ee,publicWalletId:Z,publicDeviceId:Z,integratorId:Z}),Ae([be({walletID:Z}),xe({state:Z})]),function(e){e.NOT_CREATED="NOT_CREATED",e.REQUESTED="REQUESTED",e.PROVISIONING="PROVISIONING",e.PROVISIONED="PROVISIONED",e.ACTIVE="ACTIVE",e.FAILED="FAILED"}(ct||(ct={}));const st=Ae([be({cardID:Z,status:le(ct)}),xe({capacity:ut,lastFour:Z,issuanceDate:Z,expiry:Z,pan:Z,cvv:Z})]);var dt,ft;!function(e){e.APPLEPAY="APPLEPAY",e.GOOGLEPAY="GOOGLEPAY"}(dt||(dt={})),function(e){e.PROVISIONING="PROVISIONING",e.ACTIVE="ACTIVE",e.FAILED="FAILED",e.SUSPENDED="SUSPENDED",e.TERMINATED="TERMINATED"}(ft||(ft={}));const lt=be({state:Z}),pt=be({publicWalletId:Z,publicDeviceId:Z}),ht=Ae([be({id:Z,type:le(dt),status:le(ft)}),xe({pan:Z,applePay:lt,googlePay:pt,error:ie})]),mt=be({authorized:ee,settled:ee,refunded:ee});Ae([be({issuance:at}),xe({card:st,wallets:ye(ht),summary:mt})]);const gt=be({kid:Z}),vt=be({header:gt,protected:Z,payload:Z,signature:Z});be({}),Ae([be({walletID:Z}),xe({state:Z,jws:vt})]),be({level:le({error:"error",warn:"warn",info:"info",debug:"debug"}),message:Z,context:Re(Z,G)});const yt=be({shippingAddress:De([vn,K]),billingAddress:De([vn,K]),name:De([mn,K])}),wt=Ae([be({email:Z,phone:Z}),xe(yt.props)]),bt=De([ye(be({name:Z,acceptedAt:Z})),$]);var It;be({id:Z,checkoutCompleteURL:Z,checkoutErrorURL:Z,createdAt:Z,updatedAt:Z,expiresAt:Z,merchantID:Z,programID:Z,status:De([de("ACTIVE"),de("EXPIRED"),de("DELETED"),de("COMPLETED"),de("VISITED"),de("NOTIFIED")]),orderReference:Z,contact:wt,order:Sn,disclosures:bt,isHipaaRestricted:ie}),Wn.INSTALLMENTS,r(2e6),r(3e4),function(e,n="alliance"){const{amount:t=1e6,shippingCost:o=0,tax:a=0,totalDiscounts:u=0}=e,c=t+o+a,s="alliance"===n?r:i;s(o),s(t),s(a),s(t),s(u),s(c-u),s(o),s(a)}({amount:1e5}),(new Date).toISOString(),function(e){e["INSTALLMENT:APPLICATION_DECISIONED"]="onApproved",e["INSTALLMENT:ONETRUST_CONSENT"]="onOneTrustConsent",e["INSTALLMENT:APPLICATION_CHECKOUT"]="onCheckout",e["INSTALLMENT:ADD_TO_CART"]="onAddToCart",e["INSTALLMENT:CUSTOMER_OPEN"]="onCustomerOpen",e["INSTALLMENT:CUSTOMER_CLOSE"]="onCustomerClose",e["INSTALLMENT:INITIALIZED"]="onInitialized",e["INSTALLMENT:LOG"]="onLog"}(It||(It={}));var xt={openapi:"3.0.3",info:{title:"Status codes",description:"Defines shared status codes for the bread payments api",version:"2.0.0"},paths:{},components:{schemas:{ApplicationExpired:{type:"string",description:"Application expired",enum:["010200"],"x-enum-constant":!0},ApplicationCancelledBuyerHashCheckFailed:{type:"string",description:"Buyer hash check failed",enum:["010101"],"x-enum-constant":!0},ApplicationCancelledPaymentProductNotAvailable:{type:"string",description:"Payment product not available",enum:["010102"],"x-enum-constant":!0},EligibilityEligibleEligible:{type:"string",description:"Buyer is eligible",enum:["020101"],"x-enum-constant":!0},EligibilityIneligibleBuyerStatus:{type:"string",description:"Buyer is ineligible (status)",enum:["020202"],"x-enum-constant":!0},EligibilityIneligibleBuyerCountry:{type:"string",description:"Buyer is ineligible (country)",enum:["020203"],"x-enum-constant":!0},EligibilityIneligibleBuyerRegion:{type:"string",description:"Buyer is ineligible (region)",enum:["020204"],"x-enum-constant":!0},EligibilityIneligibleBuyerAge:{type:"string",description:"Buyer is ineligible (age)",enum:["020205"],"x-enum-constant":!0},EligibilityIneligibleBuyerAgeAL:{type:"string",description:"Buyer is ineligible (age - AL)",enum:["020206"],"x-enum-constant":!0},EligibilityIneligibleInvalidAddressPOBox:{type:"string",description:"Buyer is ineligible due to invalid PO box address",enum:["020207"],"x-enum-constant":!0},FraudPass:{type:"string",description:"Fraud pass",enum:["040100"],"x-enum-constant":!0},FraudIncompleteLowRisk:{type:"string",description:"Fraud Stopped - Low risk tags",enum:["040201"],"x-enum-constant":!0},FraudIncompleteHighRisk:{type:"string",description:"Fraud Stopped - High risk tags",enum:["040202"],"x-enum-constant":!0},FraudDeniedPreciseIDDenied:{type:"string",description:"Fraud - Precise ID Denied",enum:["040307"],"x-enum-constant":!0},FraudIncompleteExtendedFraudAlert:{type:"string",description:"Fraud Stopped - Extended fraud alert",enum:["040204"],"x-enum-constant":!0},FraudDenied:{type:"string",description:"Fraud Failed - user on blocklist (+ generic fail)",enum:["040300"],"x-enum-constant":!0},FraudDeniedFraudFail:{type:"string",description:"Fraud Failed",enum:["040303"],"x-enum-constant":!0},FraudDeniedIDDenial:{type:"string",description:"Applicant fails ID verification",enum:["040305"],"x-enum-constant":!0},FraudDeniedManualDenial:{type:"string",description:"Fraud Failed - Applicant fails manual review",enum:["040306"],"x-enum-constant":!0},FraudFailed:{type:"string",description:"Fraud Failed",enum:["040400"],"x-enum-constant":!0},KYCPassed:{type:"string",description:"KYC Pass",enum:["050100"],"x-enum-constant":!0},KYCIncompleteCreditFreeze:{type:"string",description:"KYC Incomplete credit freeze on file",enum:["050305"],"x-enum-constant":!0},KYCIncompleteNeedsMoreInfo:{type:"string",description:"KYC Incomplete need more info",enum:["050303"],"x-enum-constant":!0},KYCIncompleteFailed:{type:"string",description:"KYC Incomplete failed",enum:["050301"],"x-enum-constant":!0},KYCFailed:{type:"string",description:"KYC failed",enum:["050400"],"x-enum-constant":!0},SanctionsPassed:{type:"string",description:"Sanctions Pass",enum:["060100"],"x-enum-constant":!0},SanctionsIncompleteFailed:{type:"string",description:"Sanctions (OFAC) Stopped",enum:["060301"],"x-enum-constant":!0},SanctionsFailed:{type:"string",description:"Sanctions Stopped",enum:["060400"],"x-enum-constant":!0},DownPaymentAuth:{type:"string",description:"SplitPay Checkout Complete",enum:["070100"],"x-enum-constant":!0},DownPaymentAuthAuthorized:{type:"string",description:"SplitPay Checkout Complete",enum:["070101"],"x-enum-constant":!0},DownPaymentAuthDeclined:{type:"string",description:"SplitPay payment auth failed, retry not allowed",enum:["070201"],"x-enum-constant":!0},DownPaymentAuthDeclinedDeclinedRetryPaymentMethod:{type:"string",description:"SplitPay payment auth failed, retry allowed",enum:["070202"],"x-enum-constant":!0},DecisionApprovedApprovedFull:{type:"string",description:"Application approved for checkout",enum:["030101"],"x-enum-constant":!0},DecisionApprovedApprovedPartial:{type:"string",description:"Application partially approved for checkout",enum:["030102"],"x-enum-constant":!0},DecisionApprovedApprovedContingent:{type:"string",description:"Application contingent approved for checkout",enum:["030103"],"x-enum-constant":!0},DecisionDeniedInsufficientData:{type:"string",description:"Full SSN mismatch or credit no hit (with full SSN)",enum:["030404"],"x-enum-constant":!0},DecisionIneligibleIneligibleCart:{type:"string",description:"Merchant/payment product configured cart size doesn't fit",enum:["030205"],"x-enum-constant":!0},DecisionIncompleteIncompleteCreditFreeze:{type:"string",description:"Credit Freeze",enum:["030306"],"x-enum-constant":!0},DecisionIncompleteNeedsFullIIN:{type:"string",description:"DOB, short SSN mismatch or Credit No Hit",enum:["030307"],"x-enum-constant":!0},DecisionDeniedDeniedCredit:{type:"string",description:"Credit Denial",enum:["030408"],"x-enum-constant":!0},DecisionIneligiblePreviousDenial:{type:"string",description:"Ineligible denied in last 90 Days",enum:["030209"],"x-enum-constant":!0},DecisionDeniedDeniedFraudAlert:{type:"string",description:"Credit freeze denial",enum:["030410"],"x-enum-constant":!0},DecisionIneligibleIneligibleSkippedInstallments:{type:"string",description:"Participating in Skip Payments",enum:["030211"],"x-enum-constant":!0},DecisionDeniedDeniedNoCreditFile:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030412"],"x-enum-constant":!0},DecisionDeniedDeniedNoCreditScore:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030413"],"x-enum-constant":!0},DecisionDeniedDeniedThinFile:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030414"],"x-enum-constant":!0},DecisionDeniedDeniedRepossessions:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030415"],"x-enum-constant":!0},DecisionDeniedDeniedForeclosure:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030416"],"x-enum-constant":!0},DecisionDeniedDeniedDerogatoryRecord:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030417"],"x-enum-constant":!0},DecisionDeniedDeniedTradePastDue:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030418"],"x-enum-constant":!0},DecisionDeniedDeniedCollections:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030419"],"x-enum-constant":!0},DecisionDeniedDeniedRevolvingCreditUtilization:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030420"],"x-enum-constant":!0},DecisionDeniedDeniedInsufficientCapacity:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030421"],"x-enum-constant":!0},DecisionDeniedDeniedAuthorizedTradelines:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030422"],"x-enum-constant":!0},DecisionDeniedDeniedLowFICO:{type:"string",description:"Denied low FICO",enum:["030423"],"x-enum-constant":!0},DecisionDeniedDeniedCrust:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030424"],"x-enum-constant":!0},DecisionDeniedDeniedBreadChargeOff:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030425"],"x-enum-constant":!0},DecisionDeniedDeniedPastLoanOverdue:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030426"],"x-enum-constant":!0},DecisionDeniedDeniedLoanCurrentlyOverdue:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030427"],"x-enum-constant":!0},DecisionDeniedDeniedChargeOff:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030428"],"x-enum-constant":!0},DecisionDeniedDeniedAccountPastDue:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030429"],"x-enum-constant":!0},DecisionDeniedDeniedInquiries:{type:"string",description:"ADS Credit file denial from underwriting service",enum:["030430"],"x-enum-constant":!0},DecisionIneligibleMaxCardAttempt:{type:"string",description:"Max card attempts last 30 days",enum:["030231"],"x-enum-constant":!0},DecisionIneligibleOutstandingLoans:{type:"string",description:"Unpaid outstanding loans",enum:["030232"],"x-enum-constant":!0},DecisionDeniedLowCreditLimit:{type:"string",description:"Denied low credit limit",enum:["030433"],"x-enum-constant":!0},DecisionDeniedLowFicoLowCreditLimit:{type:"string",description:"SplitPay Denied Low Credit Limit & Low FICO",enum:["030434"],"x-enum-constant":!0},DecisionDeniedDeniedRevolvingDebtTooHigh:{type:"string",description:"Credit card debt (bankcard + retail) >50k",enum:["030435"],"x-enum-constant":!0},DecisionDeniedDeniedRevolvingDebtTooLow:{type:"string",description:"Credit card debt (bankcard + retail) <2k",enum:["030436"],"x-enum-constant":!0},DecisionDeniedDeniedSelfReportedIncome:{type:"string",description:"Self reported income <20,000",enum:["030437"],"x-enum-constant":!0},DecisionDeniedDeniedLowVantage:{type:"string",description:"Low vantage (<660)",enum:["030438"],"x-enum-constant":!0},DecisionDeniedDenied:{type:"string",description:"Buyer status is insolvent",enum:["030439"],"x-enum-constant":!0},DecisionIneligibleMaxBureauAttempts:{type:"string",description:"Credit pulled 5 or more times within 24 hours",enum:["030240"],"x-enum-constant":!0},DecisionDeniedDeniedCreditAbuse:{type:"string",description:"Buyer has previous credit abuse",enum:["030441"],"x-enum-constant":!0},DecisionDeniedDeniedCreditopticsDeceased:{type:"string",description:"Buyer is deceased per Credit Optics",enum:["030442"],"x-enum-constant":!0},DecisionDeniedDeniedCreditopticsDecline:{type:"string",description:"Buyer is declined per Credit Optics",enum:["030443"],"x-enum-constant":!0},DecisionDeniedDeniedBureauDeceased:{type:"string",description:"Buyer is deceased",enum:["030444"],"x-enum-constant":!0},DecisionDeniedDeniedPreciseidDeceased:{type:"string",description:"Buyer is deceased per Precise ID",enum:["030445"],"x-enum-constant":!0},DecisionDeniedDeniedPreciseidDecline:{type:"string",description:"Buyer is declined per Precise ID",enum:["030446"],"x-enum-constant":!0},DecisionDeniedDeniedEquifaxDeceased:{type:"string",description:"Buyer is deceased per Equifax",enum:["030447"],"x-enum-constant":!0},DecisionDeniedDeniedBureauData:{type:"string",description:"Miscellaneous Denials for Bureau Data reasons",enum:["030448"],"x-enum-constant":!0},DecisionDeniedDeniedLowBureau:{type:"string",description:"Buyer credit score denial",enum:["030449"],"x-enum-constant":!0}}}};function Et(e){if(!e.order)return{allowCheckout:e.allowCheckout,domID:e.domID,locationType:e.locationType};const n=e.order,{items:t}=n,r=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i(e[n]=xt.components.schemas[n].enum[0],e)),{});const Pt=["M","W"],_t={M:{singular:()=>"mo",plural:e=>`${e} months`},W:{singular:()=>"week",plural:e=>`${e} weeks`}};function St(e){var n;const t=1===e.length?"singular":"plural",r=null===(n=null==_t?void 0:_t[e.designator])||void 0===n?void 0:n[t];if(!r)throw new Error("No singularCall.");return r(e.length)}function Ct(e){const n=/P(?\d+)(?[A-Z])/.exec(e),t=null==n?void 0:n.groups;if(!t||!t.length||!t.designator)throw new Error("Unable to parse ISO8601 Duration");if(r=t.designator,!Pt.includes(r))throw new Error(`Duration designator must be M (month) or W (week). Received: ${t.designator}`);var r;return{length:parseInt(t.length),designator:t.designator}}function Mt(e){return function(n){if(!function(e){return Object.keys(Wn).includes(e)}(n.paymentProduct.type))throw new Error(`Payment Product type is not valid: received ${n.paymentProduct.type}`);return{frequency:Ct(n.paymentProduct.paymentFrequency),rate:"INSTALLMENTS"===n.paymentProduct.type?e:0,type:n.paymentProduct.type,numberOfPayments:n.paymentProduct.numPayments}}}const Tt=/^(?(http(s)?:\/\/([a-z,A-Z,:]|\d|\.|-)+))\/(unified.)?sdk(\.dev)?(\.umd)?.js$/,Ut=e=>{if(!e)return!1;try{return new URL(e),!0}catch(e){return!1}},kt=e=>!!e&&e.startsWith("/"),Ft=["jpg","jpeg","png","gif","svg"],Lt=e=>{const n=e.split(".").pop();return!!n&&Ft.includes(n)},Nt=new RegExp(/^#(?:[0-9A-Fa-f]{3}){1,2}$/i),jt=e=>!!e&&Nt.test(e);var qt,zt;!function(e){e.FORM_BODY="application/x-www-form-urlencoded",e.FORM_DATA="multipart/form-data",e.JSON="application/json",e.TEXT="text/plain"}(qt||(qt={})),function(e){e.Check="check",e.Decrement="decrement",e.Distribution="distribution",e.Event="event",e.Gauge="gauge",e.Histogram="histogram",e.Increment="increment",e.Set="set",e.Timing="timing",e.Unique="unique"}(zt||(zt={}));var Bt=function(){function e(e){var n=this;this.host=e.host,this.contentType=e.contentType,this.mock=!0===e.mock;var t=this;Object.values(zt).forEach((function(e){t[e]=t[e].bind(n)}))}var n=e.prototype;return n.send=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r2?t-2:0),i=2;i2?t-2:0),i=2;i2?t-2:0),i=2;i=0;t--){var r=e[t];if(null!=r){n=t+1;break}}return e.slice(0,n)}function Vt(e,n){return void 0===n&&(n=qt.JSON),new Blob([JSON.stringify(e)],{type:n})}function Kt(e){return void 0===e&&(e=0),performance.now()-e}var Yt=Ze((function(e,n){"undefined"!=typeof self&&self,e.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(r,i,function(n){return e[n]}.bind(null,i));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return{}.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){function r(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function i(){return(i=Object.assign||function(e){for(var n=1;n>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var e=new WeakMap,n={};return Object.freeze(n),e.set(n,"__testvalue__"),"__testvalue__"===e.get(n)}catch(e){return!1}}())try{this.weakmap=new WeakMap}catch(e){}this.keys=[],this.values=[]}var n=e.prototype;return n._cleanupClosedWindows=function(){for(var e=this.weakmap,n=this.keys,t=0;t=3)return"stringifyError stack overflow";try{if(!e)return"";if("string"==typeof e)return e;if(e instanceof Error){var t=e&&e.stack,r=e&&e.message;if(t&&r)return-1!==t.indexOf(r)?t:r+"\n"+t;if(t)return t;if(r)return r}return e&&e.toString&&"function"==typeof e.toString?e.toString():{}.toString.call(e)}catch(e){return"Error while stringifying error: "+pe(e,n+1)}}function he(e){return"string"==typeof e?e:e&&e.toString&&"function"==typeof e.toString?e.toString():{}.toString.call(e)}function me(e,n){if(!n)return e;if(Object.assign)return Object.assign(e,n);for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e}function ge(e){return e}function ve(e,n){var t;return function r(){t=setTimeout((function(){e(),r()}),n)}(),{cancel:function(){clearTimeout(t)}}}function ye(e,n,t){if(Array.isArray(e)){if("number"!=typeof n)throw new TypeError("Array key must be number")}else if("object"==typeof e&&null!==e&&"string"!=typeof n)throw new TypeError("Object key must be string");Object.defineProperty(e,n,{configurable:!0,enumerable:!0,get:function(){delete e[n];var r=t();return e[n]=r,r},set:function(t){delete e[n],e[n]=t}})}function we(e){return[].slice.call(e)}function be(e){return"object"==typeof(n=e)&&null!==n&&"[object Object]"==={}.toString.call(e);var n}function Ie(e){if(!be(e))return!1;var n=e.constructor;if("function"!=typeof n)return!1;var t=n.prototype;return!!be(t)&&!!t.hasOwnProperty("isPrototypeOf")}function xe(e,n,t){if(void 0===t&&(t=""),Array.isArray(e)){for(var r=e.length,i=[],o=function(r){ye(i,r,(function(){var i=t?t+"."+r:""+r,o=n(e[r],r,i);return(Ie(o)||Array.isArray(o))&&(o=xe(o,n,i)),o}))},a=0;a { ... }":"<"+typeof e+">"})).join(", ")+") failed\n\n")+e.stack),e}))})).then((function(e){return{result:e,id:i,name:o}}))}))}));var c=t.__id__||re();e=qn.unwrap(e);var s=t.__name__||t.name||r;return"string"==typeof s&&"function"==typeof s.indexOf&&0===s.indexOf("anonymous::")&&(s=s.replace("anonymous::",r+"::")),qn.isProxyWindow(e)?(zn(c,t,s,e,n),e.awaitWindow().then((function(e){zn(c,t,s,e,n)}))):zn(c,t,s,e,n),bn("cross_domain_function",{id:c,name:s})}function Vn(e,n,t,r){var i,o=r.on,a=r.send;return function(e,n){void 0===n&&(n=En);var t=JSON.stringify(e,(function(e){var t=this[e];if(yn(this))return t;var r=wn(t);if(!r)return t;var i=n[r]||xn[r];return i?i(t,e):t}));return void 0===t?"undefined":t}(t,((i={}).promise=function(t,r){return function(e,n,t,r,i){return bn("cross_domain_zalgo_promise",{then:$n(e,n,(function(e,n){return t.then(e,n)}),r,{on:i.on,send:i.send})})}(e,n,t,r,{on:o,send:a})},i.function=function(t,r){return $n(e,n,t,r,{on:o,send:a})},i.object=function(e){return B(e)||qn.isProxyWindow(e)?bn("cross_domain_window",qn.serialize(e,{send:a})):e},i))}function Kn(e,n,t,r){var i,o=r.send;return function(e,n){if(void 0===n&&(n=Wn),"undefined"!==e)return JSON.parse(e,(function(e,t){if(yn(this))return t;var r,i;if(yn(t)?(r=t.__type__,i=t.__val__):(r=wn(t),i=t),!r)return i;var o=n[r]||Rn[r];return o?o(i,e):i}))}(t,((i={}).cross_domain_zalgo_promise=function(e){return function(e,n,t){return new p(t.then)}(0,0,e)},i.cross_domain_function=function(t){return function(e,n,t,r){var i=t.id,o=t.name,a=r.send,u=function(t){function r(){var u=arguments;return qn.toProxyWindow(e,{send:a}).awaitWindow().then((function(e){var c=Bn(e,i);if(c&&c.val!==r)return c.val.apply({source:window,origin:x()},u);var s=[].slice.call(u);return t.fireAndForget?a(e,"postrobot_method",{id:i,name:o,args:s},{domain:n,fireAndForget:!0}):a(e,"postrobot_method",{id:i,name:o,args:s},{domain:n,fireAndForget:!1}).then((function(e){return e.data.result}))})).catch((function(e){throw e}))}return void 0===t&&(t={}),r.__name__=o,r.__origin__=n,r.__source__=e,r.__id__=i,r.origin=n,r},c=u();return c.fireAndForget=u({fireAndForget:!0}),c}(e,n,t,{send:o})},i.cross_domain_window=function(e){return qn.deserialize(e,{send:o})},i))}var Yn={};function Hn(e,n,t,r){var i=r.on,o=r.send;return p.try((function(){var r=fn().getOrSet(e,(function(){return{}}));return r.buffer=r.buffer||[],r.buffer.push(t),r.flush=r.flush||p.flush().then((function(){if(C(e))throw new Error("Window is closed");var t,a=Vn(e,n,((t={}).__post_robot_10_0_42__=r.buffer||[],t),{on:i,send:o});delete r.buffer;for(var u=Object.keys(Yn),c=[],s=0;s1?n-1:0),r=1;r1?n-1:0),i=1;i",inputs:["props"]}).Class({constructor:[a,u,function(e,n){this._props={},this.elementRef=e,this.zone=n}],ngOnInit:function(){var e=this.elementRef.nativeElement;this.parent=t(c(this)),this.parent.render(e,ht.IFRAME)},ngDoCheck:function(){this.parent&&!function(e,n){var t={};for(var r in e)if(e.hasOwnProperty(r)&&(t[r]=!0,e[r]!==n[r]))return!1;for(var i in n)if(!t[i])return!1;return!0}(this._props,this.props)&&(this._props=i({},this.props),this.parent.updateProps(c(this)))}});return o({declarations:[s],exports:[s]}).Class({constructor:function(){}})}};function At(e){var n=e.uid,t=e.frame,r=e.prerenderFrame,i=e.doc,o=e.props,a=e.event,u=e.dimensions,c=u.width,s=u.height;if(t&&r){var d=i.createElement("div");d.setAttribute("id",n);var f=i.createElement("style");return o.cspNonce&&f.setAttribute("nonce",o.cspNonce),f.appendChild(i.createTextNode("\n #"+n+" {\n display: inline-block;\n position: relative;\n width: "+c+";\n height: "+s+";\n }\n\n #"+n+" > iframe {\n display: inline-block;\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n transition: opacity .2s ease-in-out;\n }\n\n #"+n+" > iframe.zoid-invisible {\n opacity: 0;\n }\n\n #"+n+" > iframe.zoid-visible {\n opacity: 1;\n }\n ")),d.appendChild(t),d.appendChild(r),d.appendChild(f),r.classList.add("zoid-visible"),t.classList.add("zoid-invisible"),a.on(mt.RENDERED,(function(){r.classList.remove("zoid-visible"),r.classList.add("zoid-invisible"),t.classList.remove("zoid-invisible"),t.classList.add("zoid-visible"),setTimeout((function(){Ke(r)}),1)})),a.on(mt.RESIZE,(function(e){var n=e.width,t=e.height;"number"==typeof n&&(d.style.width=tn(n)),"number"==typeof t&&(d.style.height=tn(t))})),d}}function Pt(e){var n=e.doc,t=e.props,r=n.createElement("html"),i=n.createElement("body"),o=n.createElement("style"),a=n.createElement("div");return a.classList.add("spinner"),t.cspNonce&&o.setAttribute("nonce",t.cspNonce),r.appendChild(i),i.appendChild(a),i.appendChild(o),o.appendChild(n.createTextNode("\n html, body {\n width: 100%;\n height: 100%;\n }\n\n .spinner {\n position: fixed;\n max-height: 60vmin;\n max-width: 60vmin;\n height: 40px;\n width: 40px;\n top: 50%;\n left: 50%;\n box-sizing: border-box;\n border: 3px solid rgba(0, 0, 0, .2);\n border-top-color: rgba(33, 128, 192, 0.8);\n border-radius: 100%;\n animation: rotation .7s infinite linear;\n }\n\n @keyframes rotation {\n from {\n transform: translateX(-50%) translateY(-50%) rotate(0deg);\n }\n to {\n transform: translateX(-50%) translateY(-50%) rotate(359deg);\n }\n }\n ")),r}var _t=function(){return fe},St=function(e){return le(e.value)},Ct=De(),Mt=De();function Tt(e){var n,t,r=function(e){var n=e.tag,t=e.url,r=e.domain,o=e.bridgeUrl,a=e.props,u=void 0===a?{}:a,c=e.dimensions,s=void 0===c?{}:c,d=e.autoResize,f=void 0===d?{}:d,l=e.allowedParentDomains,p=void 0===l?"*":l,h=e.attributes,m=void 0===h?{}:h,g=e.defaultContext,v=void 0===g?ht.IFRAME:g,y=e.containerTemplate,w=void 0===y?At:y,b=e.prerenderTemplate,I=void 0===b?Pt:b,x=e.validate,R=e.eligible,W=void 0===R?function(){return{eligible:!0}}:R,D=e.logger,O=void 0===D?{info:fe}:D,A=n.replace(/-/g,"_"),P=s.width,_=void 0===P?"300px":P,S=s.height,M=void 0===S?"150px":S;if(u=i({},{window:{type:"object",sendToChild:!1,required:!1,allowDelegate:!0,validate:function(e){var n=e.value;if(!B(n)&&!qn.isProxyWindow(n))throw new Error("Expected Window or ProxyWindow");if(B(n)){if(C(n))throw new Error("Window is closed");if(!E(n))throw new Error("Window is not same domain")}},decorate:function(e){return ct(e.value)}},timeout:{type:"number",required:!1,sendToChild:!1},close:{type:"function",required:!1,sendToChild:!1,childDecorate:function(e){return e.close}},focus:{type:"function",required:!1,sendToChild:!1,childDecorate:function(e){return e.focus}},resize:{type:"function",required:!1,sendToChild:!1,childDecorate:function(e){return e.resize}},uid:{type:"string",required:!1,sendToChild:!1,childDecorate:function(e){return e.uid}},cspNonce:{type:"string",required:!1},getParent:{type:"function",required:!1,sendToChild:!1,childDecorate:function(e){return e.getParent}},getParentDomain:{type:"function",required:!1,sendToChild:!1,childDecorate:function(e){return e.getParentDomain}},show:{type:"function",required:!1,sendToChild:!1,childDecorate:function(e){return e.show}},hide:{type:"function",required:!1,sendToChild:!1,childDecorate:function(e){return e.hide}},onDisplay:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:_t,decorate:St},onRendered:{type:"function",required:!1,sendToChild:!1,default:_t,decorate:St},onRender:{type:"function",required:!1,sendToChild:!1,default:_t,decorate:St},onClose:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:_t,decorate:St},onDestroy:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:_t,decorate:St},onResize:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:_t},onFocus:{type:"function",required:!1,sendToChild:!1,allowDelegate:!0,default:_t},onError:{type:"function",required:!1,sendToChild:!1,childDecorate:function(e){return e.onError}},onProps:{type:"function",required:!1,sendToChild:!1,default:_t,childDecorate:function(e){return e.onProps}}},u),!w)throw new Error("Container template required");return{name:A,tag:n,url:t,domain:r,bridgeUrl:o,propsDef:u,dimensions:{width:_,height:M},autoResize:f,allowedParentDomains:p,attributes:m,defaultContext:v,containerTemplate:w,prerenderTemplate:I,validate:x,logger:O,eligible:W}}(e),o=r.name,a=r.tag,u=r.defaultContext,c=r.propsDef,s=r.eligible,d=dt(),f={},l=[],h=function(){var e=yt();return Boolean(e&&e.tag===a&&e.childDomain===x())},m=ce((function(){if(h()){if(window.xprops)throw delete d.components[a],new Error("Can not register "+o+" as child - child already registered");var e=function(e){var n,t=e.propsDef,r=e.autoResize,i=e.allowedParentDomains,o=[],a=yt();if(!a)throw new Error("No child payload found");if("9_0_63"!==a.version)throw new Error("Parent window has zoid version "+a.version+", child window has version 9_0_63");var u=a.uid,c=a.parentDomain,s=a.exports,d=a.context,f=a.props,l=function(e){var n,t,r=e.type;if("opener"===r)return Oe("opener",w(window));if("parent"===r&&"number"==typeof e.distance)return Oe("parent",(n=window,void 0===(t=e.distance)&&(t=1),function(e,n){void 0===n&&(n=1);for(var t=e,r=0;r\n :host {\n all: initial;\n }\n button {\n height: 64px;\n width: ${t}px;\n padding: 16px;\n background-color: ${e.backgroundColor};\n border: ${e.borderWidth}px solid ${e.borderColor};\n color: ${e.textColor};\n font-size: 14px;\n display: flex;\n align-items: center;\n gap: 10px;\n cursor: pointer;\n text-align: left;\n }\n button:hover {\n filter: drop-shadow(0 5px 10px rgb(51 51 51 / .2));\n }\n svg {\n fill: currentColor;\n color: ${e.logoColor};\n height: 32px;\n flex-shrink: 0;\n }\n \n \n `,n.addEventListener("click",this.handleClick.bind(this)))}handleClick(){this.dispatchEvent(new CustomEvent("bread-button-clicked",{bubbles:!0,composed:!0,detail:{placementID:this.placementID}}))}}const or='\n \n Bread\n \n \n \n \n \n \n';var ar=Ze((function(e,n){Object.defineProperty(n,"__esModule",{value:!0}),n.getApplySemigroup=n.getOrd=n.getEq=n.getShow=n.URI=n.wilt=n.wither=n.sequence=n.traverse=n.partitionMap=n.partition=n.filterMap=n.filter=n.separate=n.compact=n.reduceRight=n.foldMap=n.reduce=n.duplicate=n.extend=n.throwError=n.zero=n.alt=n.altW=n.flatten=n.chainFirst=n.chain=n.of=n.apSecond=n.apFirst=n.ap=n.map=n.chainNullableK=n.mapNullable=n.fromNullableK=n.getOrElse=n.getOrElseW=n.toUndefined=n.toNullable=n.fold=n.fromEither=n.getRight=n.getLeft=n.tryCatch=n.fromPredicate=n.fromNullable=n.some=n.none=n.isNone=n.isSome=void 0,n.sequenceArray=n.traverseArray=n.traverseArrayWithIndex=n.apS=n.bind=n.bindTo=n.Do=n.getRefinement=n.exists=n.elem=n.option=n.MonadThrow=n.Witherable=n.Traversable=n.Filterable=n.Compactable=n.Extend=n.Alternative=n.Alt=n.Foldable=n.Monad=n.Applicative=n.Functor=n.getMonoid=n.getLastMonoid=n.getFirstMonoid=n.getApplyMonoid=void 0;n.isSome=function(e){return"Some"===e._tag};n.isNone=function(e){return"None"===e._tag},n.none={_tag:"None"};function t(e){return null==e?n.none:n.some(e)}function r(e){return"Right"===e._tag?n.none:n.some(e.left)}function i(e){return"Left"===e._tag?n.none:n.some(e.right)}n.some=function(e){return{_tag:"Some",value:e}},n.fromNullable=t,n.fromPredicate=function(e){return function(t){return e(t)?n.some(t):n.none}},n.tryCatch=function(e){try{return n.some(e())}catch(e){return n.none}},n.getLeft=r,n.getRight=i,n.fromEither=i,n.fold=function(e,t){return function(r){return n.isNone(r)?e():t(r.value)}},n.toNullable=function(e){return n.isNone(e)?null:e.value},n.toUndefined=function(e){return n.isNone(e)?void 0:e.value};function o(e){return function(r){return n.isNone(r)?n.none:t(e(r.value))}}n.getOrElseW=function(e){return function(t){return n.isNone(t)?e():t.value}},n.getOrElse=n.getOrElseW,n.fromNullableK=function(e){return function(){for(var n=[],r=0;r=1?1:0},n.eqOrdering={equals:function(e,n){return e===n}},n.semigroupOrdering={concat:function(e,n){return 0!==e?e:n}},n.monoidOrdering={concat:n.semigroupOrdering.concat,empty:0},n.invert=function(e){switch(e){case-1:return 1;case 1:return-1;default:return 0}}})),cr=ur,sr=Ze((function(e,n){function t(e,n){return en?1:0}function r(e,n){return e===n}function i(e){return function(n,t){return-1===e.compare(n,t)}}function o(e){return function(n,t){return 1===e.compare(n,t)}}function a(e){return function(n,t){return 1===e.compare(n,t)?t:n}}function u(e){return function(n,t){return-1===e.compare(n,t)?t:n}}function c(e){var n=function(n,t){return n===t?0:e(n,t)};return{equals:function(e,t){return 0===n(e,t)},compare:n}}function s(){return{concat:function(e,n){return c((function(t,r){return cr.monoidOrdering.concat(e.compare(t,r),n.compare(t,r))}))}}}Object.defineProperty(n,"__esModule",{value:!0}),n.ord=n.Contravariant=n.ordDate=n.URI=n.contramap=n.getDualOrd=n.getTupleOrd=n.getMonoid=n.getSemigroup=n.fromCompare=n.between=n.clamp=n.max=n.min=n.geq=n.leq=n.gt=n.lt=n.ordBoolean=n.ordNumber=n.ordString=void 0,n.ordString={equals:r,compare:t},n.ordNumber={equals:r,compare:t},n.ordBoolean={equals:r,compare:t},n.lt=i,n.gt=o,n.leq=function(e){return function(n,t){return 1!==e.compare(n,t)}},n.geq=function(e){return function(n,t){return-1!==e.compare(n,t)}},n.min=a,n.max=u,n.clamp=function(e){var n=a(e),t=u(e);return function(e,r){return function(i){return t(n(i,r),e)}}},n.between=function(e){var n=i(e),t=o(e);return function(e,r){return function(i){return!n(i,e)&&!t(i,r)}}},n.fromCompare=c,n.getSemigroup=s,n.getMonoid=function(){return{concat:s().concat,empty:c((function(){return 0}))}},n.getTupleOrd=function(){for(var e=[],n=0;n0}function d(e,n){return e<0||e>=n.length}function f(e,n){return void 0===n?function(n){return f(e,n)}:d(e,n)?o.none:o.some(n[e])}function l(e,n){if(void 0===n)return function(n){return l(e,n)};for(var t=n.length,r=Array(t+1),i=0;i=0;o--)i[o]=n(t[o],i[o+1]);return i}},n.isEmpty=c,n.isNonEmpty=s,n.isOutOfBound=d,n.lookup=f,n.cons=l,n.snoc=p,n.head=function(e){return c(e)?o.none:o.some(e[0])},n.last=function(e){return f(e.length-1,e)},n.tail=function(e){return c(e)?o.none:o.some(e.slice(1))},n.init=function(e){var n=e.length;return 0===n?o.none:o.some(e.slice(0,n-1))},n.takeLeft=function(e){return function(n){return n.slice(0,e)}},n.takeRight=function(e){return function(t){return 0===e?n.empty:t.slice(-e)}},n.takeLeftWhile=function(e){return function(n){for(var t=h(n,e),r=Array(t),i=0;i=0;t--)if(e(n[t]))return o.some(n[t]);return o.none}},n.findLastMap=function(e){return function(n){for(var t=n.length-1;t>=0;t--){var r=e(n[t]);if(o.isSome(r))return r}return o.none}},n.findLastIndex=function(e){return function(n){for(var t=n.length-1;t>=0;t--)if(e(n[t]))return o.some(t);return o.none}},n.insertAt=function(e,n){return function(t){return e<0||e>t.length?o.none:o.some(z(e,n,t))}},n.updateAt=function(e,n){return function(t){return d(e,t)?o.none:o.some(B(e,n,t))}},n.deleteAt=function(e){return function(n){return d(e,n)?o.none:o.some($(e,n))}},n.modifyAt=function(e,n){return function(t){return d(e,t)?o.none:o.some(B(e,n(t[e]),t))}},n.reverse=function(e){return c(e)?e:e.slice().reverse()},n.rights=function(e){for(var n=[],t=e.length,r=0;r=0;a--){var u=o[a];i=n(u,r[u],i)}return i}}function h(e){return function(r){return function(i){var o=t(i);if(0===o.length)return e.of(n.empty);for(var a=e.of({}),u=function(n){a=e.ap(e.map(a,(function(e){return function(t){return e[n]=t,e}})),r(n,i[n]))},c=0,s=o;cn.TYPE_MAX_LEN?e.slice(0,n.TYPE_MAX_LEN-3)+"...":e},c=function(e){return _r.pipe(e,Or.findIndex(t),dr.chain((function(n){return Or.lookup(n+1,e)})))},s=function(e,n,t){var i=_r.pipe(n,Or.map(a),Or.map(c),Or.compact),o=_r.pipe(i,Or.head,dr.map((function(e){return e.actual})),dr.getOrElse((function(){}))),s=i.map((function(e){return e.type.name}));return s.length>0?dr.some(function(e,n,t,i){return["Expecting one of:\n",e.map((function(e){return" "+u(e,i)})).join("\n"),""===n?"\n":"\nat "+n+" ","but instead got: "+r(t)].filter(Boolean).join("")}(s,e,o,t)):dr.none},d=function(e,n,t){return _r.pipe(n,o,dr.map((function(i){return function(e,n,t,i){return["Expecting "+u(e,i),""===n?"":"at "+n,"but instead got: "+r(t.value),t.message?"("+t.message+")":""].filter(Boolean).join(" ")}(i.type.name,e,n,t)})))},f=Ar.groupBy((function(e){return _r.pipe(e.context,Cr.takeUntil(t),i)}));n.formatValidationError=function(e,n){return d(i(e.context),e,n)},n.formatValidationErrors=function(e,n){return _r.pipe(e,f,Pr.mapWithIndex((function(e,t){return function(e,n,t){return Ar.tail(n).length>0?s(e,n,t):d(e,Ar.head(n),t)}(e,t,n)})),Pr.compact,Pr.toArray,Or.map((function(e){return e[0],e[1]})))},n.reporter=function(e,t){return _r.pipe(e,rn.mapLeft((function(e){return n.formatValidationErrors(e,t)})),rn.fold((function(e){return e}),(function(){return[]})))};var l={report:n.reporter};n.default=l})),Tr=Ge(Mr);const Ur=be({cookieSet:ie}),kr=be({canCookie:ie});class Fr{constructor(e){this.hostURL=e}setExperienceIDs(e,n){this.programID=e,this.merchantID=n}fetchAppConfig(){return t(this,void 0,void 0,(function*(){const e=`${this.hostURL}/api/config`,{responseBody:n}=yield this.fetch(e,pn,{});return n}))}fetchAggregatedMerchantProgramConfiguration(e,n){return t(this,void 0,void 0,(function*(){const t=`${this.hostURL}/api/programs/${e}/merchants/${n}`,{responseBody:r}=yield this.fetch(t,nt,{});return r}))}fetchOffers(){return t(this,void 0,void 0,(function*(){const e=`${this.hostURL}/api/offers`;try{const{responseBody:n}=yield this.fetch(e,ye(Pn),{});return n}catch(e){return void console.debug("Unable to access offers"+e)}}))}verifyCanCookie(){return t(this,void 0,void 0,(function*(){const{responseBody:e}=yield this.fetch(`${this.hostURL}/api/set-cookie`,Ur,{});if(e.cookieSet){const{responseBody:e}=yield this.fetch(`${this.hostURL}/api/verify-cookie`,kr,{});return e.canCookie}return!1}))}sendLog(e){this.sendBeacon(`${this.hostURL}/log`,e)}sendBeacon(e,n){navigator.sendBeacon(e,JSON.stringify(n))}fetch(e,n,{method:r="GET",credentials:i=!0,body:o}){return t(this,void 0,void 0,(function*(){const t=new Headers;this.merchantID&&t.append("X-Bread-Merchant-ID",this.merchantID),this.programID&&t.append("X-Bread-Program-ID",this.programID);const a={method:r,headers:t};i&&(a.credentials="include"),o&&(a.body=JSON.stringify(o));const u=yield fetch(e,a);if(200!==u.status)throw new Error(`Error accessing resource. Returned ${u.status}`);const c=yield u.text(),s=JSON.parse(c),d=n.decode(s);if(f(d)){const n=Tr.report(d).join(", ");throw new Error(`Error accessing ${e}: ${n}`)}return{responseBody:d.right}}))}}class Lr{constructor(e,n,t){this.experienceConfig=t,this.integrationKey=n,this.apiService=new Fr(e),this.cLogger=new Nr}log({message:e,context:n,level:r}){return t(this,void 0,void 0,(function*(){const t=this.enhanceContext(n);try{this.apiService.sendLog({level:r,message:e,context:t})}catch(e){return void console.debug("Unable to send log"+e)}}))}enhanceContext(e={}){return e=Object.assign(Object.assign({},e),{experienceConfig:this.experienceConfig||{},integrationKey:this.integrationKey,locationHref:window.location.href,userAgent:window.navigator.userAgent})}setExperienceConfig(e){this.experienceConfig=e}error(e,n={}){this.log({level:"error",message:e,context:n}),this.cLogger.error(e,n)}warn(e,n={}){this.log({level:"warn",message:e,context:n}),this.cLogger.warn(e,n)}info(e,n={}){this.log({level:"info",message:e,context:n})}debug(e,n={}){this.log({level:"debug",message:e,context:n}),this.cLogger.debug(e,n)}}class Nr{error(e,n={}){console.error({message:e,context:n})}warn(e,n={}){console.warn({message:e,context:n})}info(e,n={}){console.info({message:e,context:n})}debug(e,n={}){console.debug({message:e,context:n})}}const jr=["MONTHLY","BIWEEKLY"];function qr(e){const{interval:n}=e.paymentAgreement.terms;if(!function(e){return jr.includes(e)}(n))throw new Error(`Not a valid terms interval: ${n}`);const t=function(e){return"MONTHLY"===e?{designator:"M",length:1}:{designator:"W",length:2}}(n);return{frequency:t,rate:(r=e.paymentAgreement.terms.rate,1e4*r),numberOfPayments:e.paymentAgreement.terms.length,type:e.paymentProduct.type};var r}function zr(e,n,t,r){let i;if(null==r?void 0:r.length)i=r.map(qr);else{const e=Mt(n);i=t.map(e)}return function({order:{totalPrice:e},paymentTerms:n}){const t=n.map((n=>s(n,e))).sort(((e,n)=>e.paymentAmount-n.paymentAmount)).reduce(((e,n)=>{var t;const{type:r}=n;return null===(t=e[r])||void 0===t||t.push(n),e}),{INSTALLMENTS:[],SPLITPAY:[]});return Object.values(t).map((e=>null==e?void 0:e[0])).filter((e=>!!e))}({order:e,paymentTerms:i})}const Br=/(?:^merchant|localhost|breadgateway.net)/g,$r=["subTotal","totalDiscounts","totalPrice","totalShipping","totalTax"],Vr=["shippingCost","unitPrice","unitTax"];function Kr(e,n){const t="true"===n,r=function(){const e=new URL(window.location.href);return Br.test(e.hostname)}();if(e&&!(t||r))throw new Error("invalid access to embedded feature.")}function Yr(e){if(e.order){const n=Sn.decode(e.order);if(f(n)){const e=Tr.report(n).join(", ");throw new Error(`Error decoding Order: ${e}`)}const{subTotal:{value:t},totalShipping:{value:r},totalTax:{value:i},totalDiscounts:{value:o},totalPrice:{value:a}}=e.order;if([t,r,i,-1*o].reduce(((e,n)=>e+n),0)!==a)throw new Error("Order total price does not equal subTotal + totalTax + totalShipping - totalDiscounts")}}function Hr(e,n){var t;if(e.order){const r=$r.filter((t=>{if(e.order){return e.order[t].currency!==n}})),i=(null===(t=e.order.items)||void 0===t?void 0:t.reduce(((e,t,r)=>{const i=Vr.filter((e=>{if(t){return t[e].currency!==n}}));return i.length>0&&e.push({index:r,errorFields:i}),e}),[]))||[],o=r.length>1||i.length>1;let a="";if(r.length>0&&(a+=`The order currency does not match the program currency for following field${o?"s: ":": "}${r.join(", ")}.${i.length>0?"\n":""}`),i.length>0&&(a+=`The following order items have fields whose currency doesn't match the program currency: ${i.map((e=>`item at index ${e.index}: ${e.errorFields.join(", ")}.`))}`),a.length>0)throw new Error(a)}}function Jr(e,n,t){if(e.allowCheckout&&!e.order)throw new Error('Order required when "allowCheckout" is set to true');if(e.allowCheckout){if(!n.shippingAddress)throw new Error("Shipping address required for checkout");const e=vn.decode(n.shippingAddress);if(f(e)){const n=Tr.report(e).join(", ");throw new Error(`Error decoding Address: ${n}`)}const{country:r}=n.shippingAddress;if(r!==t)throw new Error(`Error: Shipping address country must be ${t}`)}} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var Gr=function(){return Gr=Object.assign||function(e){for(var n,t=1,r=arguments.length;t0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]{var n;return Tt.test(null!==(n=e.getAttribute("src"))&&void 0!==n?n:"")})),r=null!==(e=null==t?void 0:t.getAttribute("src"))&&void 0!==e?e:"",i=Tt.exec(r),o=null===(n=null==i?void 0:i.groups)||void 0===n?void 0:n.hostURL;if(!o)throw new Error("Could not find hostURL from our script tag");return o}(),this.containerID=e.containerID,this.experienceConfig=n,this.apiService=new Fr(this.apiURL),this.statsClient=new Bt({host:`${this.apiURL}/stats`,contentType:qt.TEXT,mock:"function"!=typeof window.navigator.sendBeacon}),this.logger=new Lr(this.apiURL,e.integrationKey,this.experienceConfig),this.publicOptions=e,this.privateOptions={appID:"",merchantID:"",programID:"",locationID:"",modal:!0},this.init=this.statsClient.asyncTimer(this.init.bind(this),"bread_sdk.init.time"),this.update=this.statsClient.asyncTimer(this.update.bind(this),"bread_sdk.update.time");const t=this.openExperienceForPlacement.bind(this);this.openExperienceForPlacement=e=>{const n=`${!this.checkoutComponentRendered}`;return this.statsClient.asyncTimer(t,"bread_sdk.open_experience_for_placement.time",{first:n})(e)},this.renderPlacements=this.statsClient.timer(this.renderPlacements.bind(this),"bread_sdk.render_placements.time"),this.statsClient.timing("bread_sdk.instantiated",performance.now()),this.logger.info("Bread SDK instantiated")}setContact(e){this.publicOptions.billingAddress=e.billingAddress,this.publicOptions.shippingAddress=e.shippingAddress,this.publicOptions.name=e.name,this.publicOptions.email=e.email,this.publicOptions.phone=e.phone,this.publicOptions.buyerID=e.buyerID,this.update(),this.logger.info("Bread SDK setContact called")}setAutoRender(e){this.autoRender=e,this.logger.info("Bread SDK setAutoRender called",{autoRender:e})}setEmbedded(e){var n,t,r;try{Kr(e,null!==(r=null===(t=null===(n=this.featureFlags)||void 0===n?void 0:n.embedded_checkout)||void 0===t?void 0:t.result)&&void 0!==r?r:""),this.embedded=e,this.logger.info("Bread SDK setEmbedded called",{embedded:e})}catch(e){const n=e instanceof Error?e:{message:e};this.warn(`Error setting embedded: ${n.message}`)}}overrideMerchantUICustomizations(e){return t(this,void 0,void 0,(function*(){const n=this.privateOptions.merchantConfig;let t=null==n?void 0:n.logoUrl,r=null==n?void 0:n.checkoutPrimaryColor,i=null==n?void 0:n.checkoutSecondaryColor;const o=window.navigator.language.substring(0,2);if(an(o)){const n=function(e){if(!e)return!1;const n=on.decode(e);return rn.isRight(n)}(e.logoUrl)?e.logoUrl[o]:e.logoUrl;(e=>{if(!e)return!1;if(!kt(e)&&!Ut(e))return!1;const n=e.split("/").pop();return!!n&&Lt(n)})(n)?t=n:this.logger.warn(`Invalid logoUrl: ${e.logoUrl}`)}jt(e.checkoutPrimaryColor)?r=e.checkoutPrimaryColor:this.warn(`Invalid checkoutPrimaryColor: ${e.checkoutPrimaryColor}`),jt(e.checkoutSecondaryColor)?i=e.checkoutSecondaryColor:this.warn(`Invalid checkoutSecondaryColor: ${e.checkoutSecondaryColor}`),this.preview=!0,this.privateOptions.merchantConfig=Object.assign(Object.assign({},n),{logoUrl:t,checkoutPrimaryColor:r,checkoutSecondaryColor:i,disclosureSymbolInstallments:e.disclosureSymbolInstallments||(null==n?void 0:n.disclosureSymbolInstallments),disclosureSymbolSplitpay:e.disclosureSymbolSplitpay||(null==n?void 0:n.disclosureSymbolSplitpay),disclosureSymbolSplitpayInterest:e.disclosureSymbolSplitpayInterest||(null==n?void 0:n.disclosureSymbolSplitpayInterest)}),this.update(),this.logger.info("Bread SDK overrideMerchantUICustomizations called",{options:e})}))}overrideButtonUICustomizations(e){return t(this,void 0,void 0,(function*(){this.privateOptions.merchantConfig=Object.assign(Object.assign({},this.privateOptions.merchantConfig),{buttonConfig:e}),this.renderPlacements(),this.logger.info("Bread SDK overrideButtonUIConfig called",{config:e})}))}registerPlacements(e){var n;try{if(!this.sdkAppConfig)throw new Error("Cannot register placements without app config");const t=[];for(const r of e)try{const e=Et(r);Yr(e),Hr(e,this.currency),Jr(e,this.publicOptions,null===(n=this.sdkAppConfig)||void 0===n?void 0:n.shippingCountry),t.push(e)}catch(e){const n=e instanceof Error?e:{message:e};this.warn(`Error registering placements: ${n.message}`,{placement:r})}this.placements=t,this.setPlacementMap(),this.autoRender&&this.renderPlacements(),this.logger.info("Bread SDK registerPlacements called")}catch(n){const t=n instanceof Error?n:{message:n};this.warn(`Error registering placements: ${t.message}`,{placementsCompat:e})}}init(){return t(this,void 0,void 0,(function*(){try{const{programID:r,merchantID:i,appID:o}=this.experienceConfig?this.experienceConfig:yield(e=this.apiURL,n=this.publicOptions.integrationKey,t(void 0,void 0,void 0,(function*(){try{const t=`${e}/api/experience-keys/${n}`,r=yield fetch(t);if(200!==r.status)throw new Error("Did not get successful response for experience keys");const i=yield r.json(),{id:o,programID:a,appID:u,locationID:c,merchantID:s}=i;return{id:o,programID:a,appID:u,locationID:c,merchantID:s}}catch(e){throw new Error("Unable to fetch experience keys:\n"+e)}})));this.privateOptions.merchantID=i,this.privateOptions.programID=r,this.privateOptions.appID=o,this.apiService.setExperienceIDs(r,i),this.logger.setExperienceConfig({programID:r,merchantID:i,appID:o}),this.sdkAppConfig=yield this.apiService.fetchAppConfig();const a=function(e,n,r,i){return t(this,void 0,void 0,(function*(){try{const t=new ai({apiOrigin:e,clientSideId:"Checkout",context:{merchantId:n,programId:r}});return yield t.bulkEvaluate({tag:"CheckoutExperience"})}catch(e){return i("Error fetching feature flags",{err:e}),{}}}))}(this.sdkAppConfig.apiUrl,i,r,this.error.bind(this)),u=this.apiService.verifyCanCookie();this.buyerOffers=yield this.apiService.fetchOffers();const c=this.apiService.fetchAggregatedMerchantProgramConfiguration(this.privateOptions.programID,this.privateOptions.merchantID),[s,d,f]=yield Promise.all([a,u,c]),{merchantConfig:l,program:p,merchantPaymentProducts:h,merchantProgramValues:m,merchantDetails:g}=f,v=Object.assign({disclosureSymbolInstallments:"*",disclosureSymbolSplitpay:"**",disclosureSymbolSplitpayInterest:"ยง"},l);this.featureFlags=s,this.canCookie=d,this.currency=p.currency,this.privateOptions.displayInterestRateBPS=p.displayInterestRateBPS,this.privateOptions=Object.assign(Object.assign({},this.privateOptions),{merchantPaymentProducts:h,merchantProgramValues:m,merchantConfig:v,program:p,merchantDetails:g}),this.logger.info("Bread SDK init called")}catch(e){const n=e instanceof Error?e:{message:e};throw this.error(`Error initializing: ${n.message}`,{integrationKey:this.publicOptions.integrationKey,apiURL:this.apiURL}),new Error("Error initializing BreadSDK!")}var e,n}))}get noOrderPlacementText(){var e;return(null===(e=this.privateOptions.merchantConfig)||void 0===e?void 0:e.noOrderPromoTextInstallments)?this.privateOptions.merchantConfig.noOrderPromoTextInstallments:"Low monthly payments"}setPlacementMap(){if(!this.placements)throw new Error("Could not find any registered placements");this.placementsMap.clear();const e=[];if(this.placements.forEach((n=>{let t=[];this.buyerOffers&&this.privateOptions.merchantPaymentProducts&&(t=function(e,n){const t=function(e,n){const t={validOffers:[],invalidOffers:[]};return e.reduce(((e,t)=>{var r;return(null===(r=n.find((e=>e.paymentProduct.id===t.paymentProduct.id)))||void 0===r?void 0:r.paymentProduct.type)?e.validOffers.push(t):e.invalidOffers.push(t),e}),t)}(e,n);if(t.invalidOffers.length>0){const e=t.invalidOffers.map((e=>e.paymentProduct.id)),r=null==n?void 0:n.map((e=>e.paymentProduct.id));console.warn(`Could not find matching product types for all buyer offers.\n Available merchant payment products ${r}\n Buyer offers with payment products that do not match ${e}`)}return t.validOffers}(this.buyerOffers,this.privateOptions.merchantPaymentProducts));const r=this.availablePaymentProductsForPlacement(n);if(r.length||e.push(n),!this.privateOptions.displayInterestRateBPS)throw new Error("Can't render placement without displayInterestRateBPS");const i=n.order?zr(n.order,this.privateOptions.displayInterestRateBPS,r,t):[];this.placementsMap.set(n.domID,Object.assign(Object.assign({},n),{promoOffers:i,isOrderWithinCartBoundaries:this.isOrderWithinCartBoundaries(n)}))})),e.length){const n=e.map((e=>e.domID)).join(", ");this.warn(`The following placements did not match any of the available payment products: [${n}]`)}}renderPlacements(){this.placementsMap.forEach((e=>{var n,t;const r=document.querySelector(`div#${e.domID}`);try{if(!this.sdkAppConfig)throw new Error("Cannot register placements without app config");Yr(e),Jr(e,this.publicOptions,null===(n=this.sdkAppConfig)||void 0===n?void 0:n.shippingCountry)}catch(n){const t=n instanceof Error?n:{message:n};return this.warn(`Error invalid placement. Not rendering: ${t.message}`,{placement:e}),void(r&&(r.innerHTML=""))}const i=this.getPlacementText(e);r?(null===(t=this.privateOptions.merchantConfig)||void 0===t?void 0:t.buttonConfig)?this.renderBreadButton(r,i,e):this.renderTextPlacement(r,i,e):this.warn(`Could not find placementContainer with DOM ID: ${e.domID}. Placement cannot be rendered.`)}))}renderTextPlacement(e,n,t){const r=document.createElement("div"),i=document.createElement("a");n&&(i.innerHTML=n,i.href="#",i.dataset.testid=`bread-placement-${t.domID}`,i.dataset.placementID=t.domID,i.addEventListener("click",(e=>{if(e.preventDefault(),!(e.target instanceof HTMLAnchorElement))throw new Error("Not an anchor element on placement click");const n=e.target.dataset.placementID;if(!n)throw new Error("No domID found in anchor data attribute");this.openExperienceForPlacement(n)})),r.appendChild(i),e.innerHTML="",e.append(r))}renderBreadButton(e,n,t){var r;if(!n)return;customElements.get("bread-button")||customElements.define("bread-button",ir);const i=document.createElement("bread-button");i.buttonUIConfig=(null===(r=this.privateOptions.merchantConfig)||void 0===r?void 0:r.buttonConfig)||null,i.placementID=t.domID;const o=document.createElement("span");o.setAttribute("slot","text"),o.setAttribute("data-testid","text-slot"),o.textContent=n,i.append(o),i.addEventListener("bread-button-clicked",(e=>{e.preventDefault(),this.openExperienceForPlacement(e.detail.placementID)})),i.dataset.testid=`bread-placement-${t.domID}`,e.innerHTML="",e.append(i)}getPlacementText(e){var n;return(null===(n=this.sdkAppConfig)||void 0===n?void 0:n.placementText)?this.getStaticPlacementText(e):e.order?e.isOrderWithinCartBoundaries?this.getDynamicPlacementTextByAvailablePromoOfferType(e):this.getDynamicPromoTextForOrderOutOfBounds(e):this.noOrderPlacementText}getDynamicPlacementTextByAvailablePromoOfferType(e){var n,t;const i=e.promoOffers.some((e=>"SPLITPAY"===e.type)),o=null===(n=this.privateOptions.merchantConfig)||void 0===n?void 0:n.disclosureSymbolSplitpay,u=e.promoOffers.some((e=>"INSTALLMENTS"===e.type)),c=null===(t=this.privateOptions.merchantConfig)||void 0===t?void 0:t.disclosureSymbolInstallments,s=e.promoOffers.map((e=>`${a(r(e.paymentAmount))}/${St(e.frequency)}`));if(!e.promoOffers[0])return this.noOrderPlacementText;if(i&&u){return`As low as ${s.join(`${c} or `)}${o}`}return i?`4 interest free payments of ${a(r(e.promoOffers[0].paymentAmount))}${o}`:u?`As low as ${a(r(e.promoOffers[0].paymentAmount))}/${St(e.promoOffers[0].frequency)}${c}`:""}getDynamicPromoTextForOrderOutOfBounds(e){if(!e.isOrderWithinCartBoundaries&&e.allowCheckout)return"";if(!e.isOrderWithinCartBoundaries&&!e.allowCheckout){const n=(this.privateOptions.merchantPaymentProducts||[]).filter((e=>"INSTALLMENTS"===e.paymentProduct.type)),t=(this.privateOptions.merchantPaymentProducts||[]).filter((e=>"SPLITPAY"===e.paymentProduct.type)),i=r(0),o=n.length>0,u=t.length>0,c=n.filter((e=>e.merchantValues.maxCartSize.value>0)).map((e=>e.merchantValues.maxCartSize)).sort(((e,n)=>n.value-e.value)),s=n.filter((e=>e.merchantValues.minCartSize.value>0)).map((e=>e.merchantValues.minCartSize)).sort(((e,n)=>e.value-n.value)),d=t.filter((e=>e.merchantValues.maxCartSize.value>0)).map((e=>e.merchantValues.maxCartSize)).sort(((e,n)=>n.value-e.value)),f=t.filter((e=>e.merchantValues.minCartSize.value>0)).map((e=>e.merchantValues.minCartSize)).sort(((e,n)=>e.value-n.value)),l=c[0]||i,p=s[0]||i,h=d[0]||i,m=f[0]||i,{order:g}=e;if(g){const e=g.totalPrice.value,n=e>l.value,t=e>h.value,i=n&&t,c=ethis.orderWithinCartBoundaries(r,e))))&&void 0!==t?t:[]}isOrderWithinCartBoundaries(e){const{order:n}=this.getOrderForPlacement(e);return(this.privateOptions.merchantPaymentProducts||[]).some((e=>this.orderWithinCartBoundaries(n,e)))}update(){return t(this,void 0,void 0,(function*(){if(this.setPlacementMap(),this.checkoutComponent){if(!this.currentPlacementID)throw new Error("Can't update without a placement ID");const e=this.placementsMap.get(this.currentPlacementID);if(!e)throw new Error("No placement options found");const n=this.optionsFromPlacement(e);return new Promise(((e,t)=>{var r;null===(r=this.checkoutComponent)||void 0===r||r.updateProps({options:n}).then((()=>{e()})).catch((e=>{t(e)})),this.checkoutComponentRendered||e()}))}}))}get checkoutURL(){if(!this.sdkAppConfig)throw new Error("Cannot register placements without app config");return`${this.apiURL}${this.sdkAppConfig.ecommExperiencePath}`}handleDestroyed(){this.checkoutComponentRendered=!1,this.checkoutComponent=void 0}getContext(){const e=window.navigator.standalone,n=window.navigator.userAgent.toLowerCase(),t=/safari/.test(n),r=/iphone|ipod|ipad/.test(n)&&!t&&!1===e,i=ui.test(n);return r||i||this.canCookie?"iframe":"popup"}openExperienceForPlacement(e){var n;return t(this,void 0,void 0,(function*(){try{const t=this.getContext();this.currentPlacementID=e;const r=this.placementsMap.get(e);if(!r)throw new Error(`Could not find placement for ID: ${e}`);this.checkoutComponent&&(yield this.update());const i=this.optionsFromPlacement(r);if(this.checkoutComponentRendered)yield null===(n=this.checkoutComponent)||void 0===n?void 0:n.show().then((()=>{var e;return null===(e=this.checkoutComponent)||void 0===e?void 0:e.focus()})).catch((e=>this.error(`Error opening placement: ${e}`)));else try{yield this.renderCheckout(t,i)}catch(e){if("popup"===t)try{yield this.renderCheckout("iframe",i)}catch(e){this.error(`Error opening placement: ${e}`)}else this.error(`Error opening placement: ${e}`)}this.logger.info("Bread SDK openExperienceForPlacement called",{domID:e})}catch(e){const n=e instanceof Error?e:{message:e};this.error(`Error opening placement: ${n.message}`)}}))}renderCheckout(e,n){var r;return t(this,void 0,void 0,(function*(){const t=()=>{this.handleDestroyed()},i=((e,n,t)=>{const r=n?{width:"100%",height:"100%"}:{width:"480px",height:"600px"};return Yt.create({tag:"checkout-component",url:`${e}`,autoResize:{width:!1,height:!0},dimensions:r,props:{options:{type:"object"},context:{type:"string"}},containerTemplate:function({uid:e,frame:r,prerenderFrame:i,doc:o,props:a,event:u}){if(u.on(Gt.DESTROY,(()=>{null==t||t.onDestroy(),Xt()})),r){const t=o.createElement("div");t.setAttribute("id",e);const c=o.createElement("style");if(a.cspNonce&&c.setAttribute("nonce",a.cspNonce),n)t.dataset.testid="embedded-rendering",c.appendChild(o.createTextNode(`\n #${e} {\n display: inline-block;\n position: relative;\n width: 100%;\n }\n\n #${e} iframe {\n width: 100%;\n height: 100%;\n display: inline-block;\n position: absolute;\n top: 0;\n left: 0;\n transition: opacity .2s ease-in-out;\n }\n `)),t.classList.add("bread-payments-embedded"),t.appendChild(r),t.appendChild(i);else{c.appendChild(o.createTextNode(`\n #${e} {\n position: fixed;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n z-index: 2147483647;\n }\n\n #${e} .${rr} {\n display: flex;\n justify-content: center;\n min-height: 100vh;\n }\n #${e} .${rr} .${tr} {\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n background-color: #000;\n opacity: 0.5;\n }\n\n #${e} iframe {\n display: block;\n position: fixed;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n transition: opacity .2s ease-in-out;\n }\n #${e} iframe.${Qt} {\n opacity: 0;\n }\n #${e} iframe.${Zt} {\n opacity: 1;\n }\n `));const n=o.createElement("div");n.className=rr;const a=o.createElement("div");a.className=tr,n.appendChild(a),t.appendChild(n),n.appendChild(r),n.appendChild(i)}return t.appendChild(c),i.classList.add(Zt),r.classList.add(Qt),u.on(Gt.RENDERED,(()=>{i.classList.remove(Zt),i.classList.add(Qt),r.classList.remove(Qt),r.classList.add(Zt),setTimeout((()=>{var e;null===(e=null==i?void 0:i.parentNode)||void 0===e||e.removeChild(i)}),1)})),u.on(Gt.RESIZE,(({width:e,height:n})=>{"number"==typeof e&&(t.style.width=nr(e)),"number"==typeof n&&(t.style.height=nr(n))})),t}}})})(this.checkoutURL,this.embedded,{onDestroy:t,onClose:t});this.checkoutComponent=i({options:n,context:e});const o=this.containerID?`#${this.containerID}`:"body";yield null===(r=this.checkoutComponent)||void 0===r?void 0:r.render(o,e).then((()=>{var e;this.checkoutComponentRendered=!0,null===(e=this.checkoutComponent)||void 0===e||e.focus()})).catch((e=>{throw e}))}))}optionsFromPlacement(e){const{promoOffers:n,allowCheckout:t,domID:r}=e,{isDefaultOrder:i,order:o}=e.isOrderWithinCartBoundaries?this.getOrderForPlacement(e):this.getOrderForPlacement(Object.assign(Object.assign({},e),{order:void 0})),a=Object.assign(Object.assign(Object.assign({},this.publicOptions),this.privateOptions),{isDefaultOrder:i,isPreview:this.preview,isEmbedded:this.embedded,order:o,promoOffers:n,allowCheckout:t,domID:r,analytics:{experienceEntrypoint:document.URL,locationType:e.locationType}});return void 0!==this.overrideAllowCheckout&&a.allowCheckout!==this.overrideAllowCheckout&&(a.allowCheckout=this.overrideAllowCheckout),a}createDefaultOrder(){var e;if(!this.currency)throw new Error("Cannot assign an order");if(!(null===(e=this.privateOptions.merchantProgramValues)||void 0===e?void 0:e.defaultCartAmount))throw new Error("Can't fetch options for placement without defaultCartAmount");const n=this.currency,t=this.privateOptions.merchantProgramValues.defaultCartAmount;return{totalPrice:t,items:[],subTotal:t,totalDiscounts:o(0,n),totalShipping:o(0,n),totalTax:o(0,n)}}orderWithinCartBoundaries(e,n){var t,r,i;try{const{minCartSize:{value:o},maxCartSize:{value:a}}=n.merchantValues,u="INSTALLMENTS"===n.paymentProduct.type&&(null===(t=this.privateOptions.merchantProgramValues)||void 0===t?void 0:t.capabilities.downPayment.installments)&&(null===(r=this.privateOptions.program)||void 0===r?void 0:r.capabilities.downPayment.installments),c=null===(i=this.privateOptions.merchantDetails)||void 0===i?void 0:i.borrowRatioBPS,s=u?a*((c||100)/100):a,{value:d}=e.totalPrice,f=s<0||d<=s;return o<=d&&f}catch(e){const n=e instanceof Error?e:{message:e};return this.warn(`orderWithinCartBoundaries error ${n.message}`),!1}}error(e,n={}){this.logger.error(e,n),this.publicOptions.onLog&&this.publicOptions.onLog("ERROR",e,n)}warn(e,n={}){this.logger.warn(e,n),this.publicOptions.onLog&&this.publicOptions.onLog("WARN",e,n)}}const si="USE_MIRAGE",di="4.0.201";return function(){let e;function n(){return t(this,void 0,void 0,(function*(){if(function(){if("undefined"==typeof window)return!1;try{return"true"===window.localStorage.getItem(si)}catch(e){return console.debug("Unable to read from localStorage.",e),!1}}()){console.debug("Using Mirage");const{makeServer:e}=yield import("../../../../../../mirage.js");e({environment:"development"})}else console.debug("Using real Bread REST APIs");const n=window.BreadPayments.options;if(!function(e){return"function"==typeof e.onCheckout}(n))throw new Error("Missing callbacks registered from .on method");const t=new ci(n);try{yield t.init()}catch(e){return}yield new Promise((i=>{var o;e=t,e.setAutoRender(window.BreadPayments.__internal__.autoRender),e.setEmbedded(window.BreadPayments.__internal__.embedded);const a=window.BreadPayments.placements||[];r(a),window.BreadPayments.__internal__.autoRender||window.BreadPayments.__internal__.openExperienceForPlacement(a),i(!0),null===(o=n.onInitialized)||void 0===o||o.call(n)}))}))}function r(n){null==e||e.registerPlacements(n)}!function(){const i=window.BreadPayments||{};window.BreadPayments=i,window.BreadPayments.options=window.BreadPayments.options||{},i.setup=e=>{var n,t,r,o,a,u,c,s,d;const f=(null===(n=e.buyer)||void 0===n?void 0:n.familyName)&&(null===(t=e.buyer)||void 0===t?void 0:t.givenName)&&{familyName:null===(r=e.buyer)||void 0===r?void 0:r.familyName,givenName:null===(o=e.buyer)||void 0===o?void 0:o.givenName,additionalName:null===(a=e.buyer)||void 0===a?void 0:a.additionalName};i.options={integrationKey:e.integrationKey,containerID:e.containerID,buyerID:e.buyerID,email:null===(u=e.buyer)||void 0===u?void 0:u.email,phone:null===(c=e.buyer)||void 0===c?void 0:c.phone,billingAddress:null===(s=e.buyer)||void 0===s?void 0:s.billingAddress,shippingAddress:null===(d=e.buyer)||void 0===d?void 0:d.shippingAddress,onInitialized:e.onInitialized},f&&(i.options.name=f)},window.BreadPayments.openExperienceForPlacement=e=>{i.__internal__.openExperienceForPlacement(e)},window.BreadPayments.registerPlacements=n=>{window.BreadPayments.placements=n,e&&r(n)},window.BreadPayments.on=(e,n)=>{window.BreadPayments.options[It[e]]=n},window.BreadPayments.setInitMode=e=>{window.BreadPayments.__internal__.setInitMode(e)},window.BreadPayments.setEmbedded=e=>{window.BreadPayments.__internal__.setEmbedded(e)},window.BreadPayments.init=()=>t(this,void 0,void 0,(function*(){yield window.BreadPayments.__internal__.init()})),i.__internal__={initMode:"auto",autoRender:!0,embedded:!1,version:di,setBuyer(n){let t;n.familyName&&n.givenName&&(t={familyName:n.familyName,givenName:n.givenName,additionalName:n.additionalName}),null==e||e.setContact({name:t,billingAddress:n.billingAddress,shippingAddress:n.shippingAddress,email:n.email,phone:n.phone,buyerID:n.buyerID})},update(){window.BreadPayments.placements&&r(window.BreadPayments.placements),null==e||e.update()},setInitMode(e){window.BreadPayments.__internal__.initMode=e},init(){return t(this,void 0,void 0,(function*(){if(!window.BreadPayments.options)throw new Error("No breadFinance options");yield n()}))},setAutoRender(e){window.BreadPayments.__internal__.autoRender=e},setEmbedded(n){window.BreadPayments.__internal__.embedded=n,null==e||e.setEmbedded(n)},overrideMerchantUICustomizations(n){null==e||e.overrideMerchantUICustomizations(n)},overrideButtonUICustomizations(n){null==e||e.overrideButtonUICustomizations(n)},openExperienceForPlacement(n){var t;if(0===n.length)throw new Error("No registered placement found");if(n.length>1)throw new Error("Multiple placements exist, only one required to render modal without rendering as-low-as links");const r=null===(t=null==n?void 0:n[0])||void 0===t?void 0:t.domID;r&&(null==e||e.openExperienceForPlacement(r))}}}(),document.addEventListener("DOMContentLoaded",(()=>t(this,void 0,void 0,(function*(){if(!window.BreadPayments.options)throw new Error("No breadFinance options");"auto"===window.BreadPayments.__internal__.initMode&&(yield n())}))))}(),e.STORAGE_KEY=si,Object.defineProperty(e,"__esModule",{value:!0}),e}({});