var CRDV;!function(){"use strict";var t={56:function(t,e,o){t.exports=function(t){var e=o.nc;e&&t.setAttribute("nonce",e)}},72:function(t){var e=[];function o(t){for(var o=-1,n=0;n0?" ".concat(e[5]):""," {")),o+=t(e),n&&(o+="}"),e[2]&&(o+="}"),e[4]&&(o+="}"),o}).join("")},e.i=function(t,o,n,a,r){"string"==typeof t&&(t=[[null,t,void 0]]);var i={};if(n)for(var s=0;s0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=r),o&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=o):l[2]=o),a&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=a):l[4]="".concat(a)),e.push(l))}},e}},540:function(t){t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},601:function(t){t.exports=function(t){return t[1]}},659:function(t){var e={};t.exports=function(t,o){var n=function(t){if(void 0===e[t]){var o=document.querySelector(t);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(t){o=null}e[t]=o}return e[t]}(t);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(o)}},680:function(t,e,o){var n=o(601),a=o.n(n),r=o(314),i=o.n(r)()(a());i.push([t.id,".crdv-button{background-color:white;border-color:transparent;color:#555150;cursor:pointer;margin:0;padding:0;text-decoration:none}.crdv-text{background-color:white;border-color:transparent;color:#555150;margin:0;padding:0;text-decoration:none}.crdv-button .crdv-button-message:after{content:\" \"}.crdv-text .crdv-button-message:after{content:\" \"}.crdv-button .crdv-button-brand{display:inline-block;height:20px;width:78px}.crdv-text .crdv-button-brand{display:inline-block;height:20px;width:78px}.crdv-button .crdv-button-brand img,svg{vertical-align:baseline}.crdv-text .crdv-button-brand img,svg{vertical-align:baseline}.crdv-text-popup-blocked{font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif}.crdv-hide-modal-content{display:none}.crdv-btn-credova{height:3.5em;border-radius:0;max-width:18em;font-weight:500;text-transform:uppercase;transition:.5s;line-height:2.5em;margin-right:5px}.crdv-btn-credova-blue{background-color:#243547;color:#fff;padding-left:1.75em;padding-right:1.75em;border-radius:50px;height:2.8em;min-width:10em;font-weight:500;text-transform:capitalize;transition:.5s;line-height:2.5em;padding:.1rem 1.75rem}.crdv-btn-credova-grey{background-color:grey;color:#fff}.crdv-btn-credova-black{background-color:#000000;color:#fff;padding-left:1.75em;padding-right:1.75em;border-radius:50px;height:2.8em;min-width:10em;font-weight:500;text-transform:capitalize;transition:.5s;line-height:2.5em;padding:.1rem 1.75rem}.crdv-text-centered{text-align:center}.crdv-d-none{display:none}.crdv-popup-iframe{height:100vh;max-height:100vh;width:100%}@media screen and (min-width: 769px), print{.crdv-popup-iframe{height:100vh}}.crdv-popup-modal-content{background-color:transparent;height:100vh;margin:0;max-height:100vh;overflow:hidden !important}@media screen and (min-width: 769px), print{.crdv-popup-modal-content{width:800px}}@media screen and (min-width: 769px), print{.crdv-popup-blocked-modal-content{width:600px}}.crdv-modal-close::after{height:85%;width:2px;background-color:#243547}.crdv-modal-close::before{height:2px;width:85%;background-color:#243547}.crdv-link{font-size:0.8333rem;cursor:pointer}.crdv-brand-header{max-width:250px;margin:0px auto;text-align:center;padding:10px;position:relative}.crdv-text-dark{color:#000000}.crdv-text-blue{color:#243547}.crdv-text-grey{color:#525E66}.crdv-my-3{margin-top:1.5rem;margin-bottom:1.5rem}.crdv-py-4{padding-top:2rem;padding-bottom:2em}.crdv-learn-more{font-weight:bold;color:#293e56;text-decoration:underline}.crdv-modal-reminder-header{font-weight:bold;font-size:1.8333rem}.crdv-modal-reminder-message{font-size:0.9em;font-weight:600}\n",""]),i.locals={button:"crdv-button",text:"crdv-text","button-message":"crdv-button-message","button-brand":"crdv-button-brand","text-popup-blocked":"crdv-text-popup-blocked","hide-modal-content":"crdv-hide-modal-content","btn-credova":"crdv-btn-credova","btn-credova-blue":"crdv-btn-credova-blue","btn-credova-grey":"crdv-btn-credova-grey","btn-credova-black":"crdv-btn-credova-black","text-centered":"crdv-text-centered","d-none":"crdv-d-none","popup-iframe":"crdv-popup-iframe","popup-modal-content":"crdv-popup-modal-content","popup-blocked-modal-content":"crdv-popup-blocked-modal-content","modal-close":"crdv-modal-close",link:"crdv-link","brand-header":"crdv-brand-header","text-dark":"crdv-text-dark","text-blue":"crdv-text-blue","text-grey":"crdv-text-grey","my-3":"crdv-my-3","py-4":"crdv-py-4","learn-more":"crdv-learn-more","modal-reminder-header":"crdv-modal-reminder-header","modal-reminder-message":"crdv-modal-reminder-message"},e.A=i},825:function(t){t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(o){!function(t,e,o){var n="";o.supports&&(n+="@supports (".concat(o.supports,") {")),o.media&&(n+="@media ".concat(o.media," {"));var a=void 0!==o.layer;a&&(n+="@layer".concat(o.layer.length>0?" ".concat(o.layer):""," {")),n+=o.css,a&&(n+="}"),o.media&&(n+="}"),o.supports&&(n+="}");var r=o.sourceMap;r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(n,t,e.options)}(e,t,o)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}}},e={};function o(n){var a=e[n];if(void 0!==a)return a.exports;var r=e[n]={id:n,exports:{}};return t[n](r,r.exports,o),r.exports}o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,{a:e}),e},o.d=function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.nc=void 0;var n,a,r,i,s,c,d,l,m,u,p,h,f,v,g={};n=o(72),a=o.n(n),r=o(825),i=o.n(r),s=o(659),c=o.n(s),d=o(56),l=o.n(d),m=o(540),u=o.n(m),p=o(113),h=o.n(p),f=o(305),(v={}).styleTagTransform=h(),v.setAttributes=l(),v.insert=c().bind(null,"head"),v.domAPI=i(),v.insertStyleElement=u(),a()(f.A,v),f.A&&f.A.locals&&f.A.locals,function(){var t=o(72),e=o.n(t),n=o(825),a=o.n(n),r=o(659),i=o.n(r),s=o(56),c=o.n(s),d=o(540),l=o.n(d),m=o(113),u=o.n(m),p=o(680),h={};h.styleTagTransform=u(),h.setAttributes=c(),h.insert=i().bind(null,"head"),h.domAPI=a(),h.insertStyleElement=l(),e()(p.A,h),p.A&&p.A.locals&&p.A.locals}(),function(){o.r(g),o.d(g,{EVENT_USER_WAS_APPROVED:function(){return i},Environment:function(){return l},plugin:function(){return m}});var t=o(228),e=o.n(t);const n=new Map;function a(t,e){const o=`${t.apiRoot}/v2/stores/${e}/retailerHost`;if(n.has(o))return n.get(o);const a=new XMLHttpRequest;a.open("GET",o,!0),a.setRequestHeader("Content-type","application/json"),a.setRequestHeader("Accept","application/json");const r=new Promise((t,e)=>{a.onload=()=>200===a.status?t(JSON.parse(a.response)):e(new Error("Error getting the retailer host.")),a.onerror=()=>e(new Error("Error getting the retailer host.")),a.send()});return n.set(o,r),r}function r(t,e){const o=document.createElement(t);if(e){const{className:t,...n}=e;t&&(o.className=t);for(const t of Object.keys(n)){const e=n[t];o.setAttribute(t,e)}}for(var n=arguments.length,a=new Array(n>2?n-2:0),r=2;r1&&void 0!==arguments[1]?arguments[1]:"popup";this.notifyClose=!0,this.configurePluginBackground(e),c()?(this.window=window.open(t),null===this.window?this.openBlockedDialog(t):this.configureModalBackgroundForMobile()):"modal"===e.toLowerCase()?(this.configureModalBackground(),this.window=this.popupCenter(t)):(this.configurePopupBackground(),this.iframe.src=t)}close(){this.window&&(this.notifyClose=!1,this.window.close()),this.modal&&this.modal.classList.remove("x-bulma-is-active"),this.iframe&&(this.iframe.src="proxy.php?url=about:blank")}isOpen(){return c()?null!==this.window:this.modal&&this.modal.classList.contains("x-bulma-is-active")}popupCenter(t){var e=null!=window.screenLeft?window.screenLeft:screen.left,o=null!=window.screenTop?window.screenTop:screen.top,n=(window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width)/2-325+e,a=(window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height)/2-375+o,r=window.open(t,"popup","scrollbars=yes, width=650, height=750, top="+a+", left="+n),i=this,s=setInterval(function(){r.closed&&(i.notifyClose&&i.emitCloseEvent(),clearInterval(s))},1e3);return r.focus&&r.focus(),r}emitCloseEvent(){(this.window!==window.top?window.parent:window.opener).postMessage("crdv-close")}openBlockedDialog(t){const e=r("button",{className:"x-bulma-button"},"Continue"),o=r("div",{className:"x-bulma-modal x-bulma-is-active"},r("div",{className:"x-bulma-modal-background"}),r("div",{className:"x-bulma-modal-content crdv-popup-blocked-modal-content"},r("div",{className:"x-bulma-box x-bulma-is-radiusless"},r("p",null,"Your browser blocked our popup. Click on the button below to continue."),e)));e.addEventListener("click",e=>{e.preventDefault(),this.window=window.open(t),document.body.removeChild(o)}),document.body.appendChild(o)}configureModalBackgroundForMobile(){var t=this;setTimeout(function(){t.modal.classList.add("x-bulma-is-active"),t.modal.querySelector(".is-modal").classList.remove("crdv-hide-modal-content"),t.modal.querySelector(".is-iframe").classList.add("crdv-hide-modal-content")},500);var e=setInterval(function(){t.window.closed&&(t.notifyClose&&t.emitCloseEvent(),clearInterval(e))},1e3)}configureModalBackground(){var t=this;setTimeout(function(){t.modal.classList.add("x-bulma-is-active"),t.modal.querySelector(".is-modal").classList.remove("crdv-hide-modal-content"),t.modal.querySelector(".is-iframe").classList.add("crdv-hide-modal-content")},500)}configurePopupBackground(){this.modal.querySelector(".is-modal").classList.add("crdv-hide-modal-content"),this.modal.querySelector(".is-iframe").classList.remove("crdv-hide-modal-content"),this.modal.classList.add("x-bulma-is-active")}configurePluginBackground(t){const e=r("button",{className:"x-bulma-button crdv-btn-credova-blue"},"Continue"),o=r("button",{class:"x-bulma-modal-close crdv-modal-close","aria-label":"close"}),n=r("a",{class:"crdv-text-grey crdv-modal-close crdv-link","aria-label":"close"},r("strong",null,"Exit Credova")),a=r("span",null);a.innerHTML='\n \n \n \n \n \n \n \n \n \n',this.iframe=r("iframe",{className:"crdv-popup-iframe",frameborder:"0",src:"about:blank"}),this.modal=r("div",{className:"crdv-popup-modal x-bulma-modal modal-close"},r("div",{className:"x-bulma-modal-background"}),r("div",{className:"x-bulma-modal-content crdv-popup-modal-content is-iframe"},this.iframe),"modal"===t?r("div",{className:"x-bulma-modal-content crdv-popup-blocked-modal-content is-modal"},r("div",{className:"x-bulma-box crdv-text-centered crdv-text-popup-blocked crdv-py-4"},o,r("div",{className:"crdv-brand-header"},a),r("p",{className:"crdv-modal-reminder-header crdv-text-blue"},"You haven't completed your order."),r("p",{className:"crdv-modal-reminder-message crdv-text-grey"},"Please select the continue button to finish paying with Credova."),r("div",{className:"crdv-my-3"},e),n)):r("div",{className:"x-bulma-modal-content crdv-popup-blocked-modal-content is-modal"})),e.addEventListener("click",t=>{t.preventDefault(),this.window&&this.window.window?this.window.focus():this.emitCloseEvent()}),o.addEventListener("click",t=>{t.preventDefault(),this.emitCloseEvent()}),n.addEventListener("click",t=>{t.preventDefault(),this.emitCloseEvent()}),document.body.appendChild(this.modal)}}function c(){const t=navigator.userAgent||navigator.vendor||window.opera;return/mobi/i.test(t)}const d=Number.MAX_VALUE,l={LocalhostSSL:{apiRoot:"http://localhost:64890",websiteRoot:"https://localhost:44393",landingPageRoot:"http://localhost:52660",brandUrlRoot:"http://localhost:52657/Content/OrganizationBrand"},Localhost:{apiRoot:"http://localhost:64890",websiteRoot:"http://localhost:52651",landingPageRoot:"http://localhost:52660",brandUrlRoot:"http://localhost:52657/Content/OrganizationBrand"},Test:{apiRoot:"https://test-lending-api.credova.com",websiteRoot:"https://test-lending.credova.com",landingPageRoot:"https://test.credova.com",brandUrlRoot:"https://test-lending-admin.credova.com/Content/OrganizationBrand"},Staging:{apiRoot:"https://staging-lending-api.credova.com",websiteRoot:"https://staging-lending.credova.com",landingPageRoot:"https://staging.credova.com",brandUrlRoot:"https://staging-lending-admin.credova.com/Content/OrganizationBrand"},Sandbox:{apiRoot:"https://sandbox-lending-api.credova.com",websiteRoot:"https://sandbox-lending.credova.com",landingPageRoot:"https://sandbox.credova.com",brandUrlRoot:"https://sandbox-lending-admin.credova.com/Content/OrganizationBrand"},Production:{apiRoot:"https://lending-api.credova.com",websiteRoot:"https://lending.credova.com",landingPageRoot:"https://credova.com",brandUrlRoot:"https://lending-admin.credova.com/Content/OrganizationBrand"},TestExoscale:{apiRoot:"https://test-lending-api-exoscale.credova.com",websiteRoot:"https://test-lending-exoscale.credova.com",landingPageRoot:"https://test-exoscale.credova.com",brandUrlRoot:"https://test-lending-admin-exoscale.credova.com/Content/OrganizationBrand"},StagingExoscale:{apiRoot:"https://staging-lending-api-exoscale.credova.com",websiteRoot:"https://staging-lending-exoscale.credova.com",landingPageRoot:"https://staging-exoscale.credova.com",brandUrlRoot:"https://staging-lending-admin-exoscale.credova.com/Content/OrganizationBrand"},SandboxExoscale:{apiRoot:"https://sandbox-lending-api-exoscale.credova.com",websiteRoot:"https://sandbox-lending-exoscale.credova.com",landingPageRoot:"https://sandbox-exoscale.credova.com",brandUrlRoot:"https://sandbox-lending-admin-exoscale.credova.com/Content/OrganizationBrand"}},m=new class{constructor(){this.emitter=new(e()),this.popup=new s,this.isCheckout=!1,window.addEventListener("message",t=>{if("string"!=typeof t.data)return;if(!t.data.startsWith("crdv-"))return;if("crdv-ping"===t.data&&t.source&&this.isCheckout)return void t.source.postMessage("crdv-plugin-alive","*");this.isCheckout=!1,this.popup.close();const[e,...o]=t.data.split(":");this.emitter.emit(e,o)})}config(t){if(!t)throw new Error("configuration is required.");if(!t.environment)throw new Error("environment is required.");if(!t.store)throw new Error("store is required.");t.minAmount&&!isNaN(t.minAmount)||(t.minAmount=50),t.maxAmount&&!isNaN(t.maxAmount)||(t.maxAmount=d),this.configuration=t,this.configuration.minAmount=parseFloat(this.configuration.minAmount),this.configuration.maxAmount=parseFloat(this.configuration.maxAmount)}inject(t){if(!this.configuration)throw new Error("You must set the configuration first using the method `config`.");if(!t)throw new Error("classNames is required.");const e=document.getElementsByClassName(t),o=[];for(const t of e)o.push(this.injectButton(t));return Promise.all(o)}async injectButton(t){if(!this.configuration)throw new Error("You must set the configuration first using the method `config`.");if(!t)throw new Error("element is required.");if(!t.dataset.amount)throw new Error("amount is required.");const e=parseFloat(t.dataset.amount);if(Number.isNaN(e))throw new Error("amount is invalid.");if(ethis.configuration.maxAmount)throw new Error(`amount cannot be higher than ${this.configuration.maxAmount.toFixed(2)}.`);const o=r("span",{className:"crdv-button-message"},"Review financing options");let a="crdv-button-brand";t.dataset.hideBrand&&(a="crdv-d-none");const i=r("span",{className:a});let s="";if(void 0===this.lowestPaymentOptionParameters||null===this.lowestPaymentOptionParameters)try{this.lowestPaymentOptionParameters=await function(t,e){const o=`?invalidateCache=${(new Date).toISOString().slice(0,10)}`,a=`${t.apiRoot}/v3/calculator/store/${e}/lowestMonthlyPaymentParameters${o}`;if(n.has(a))return n.get(a);const r=new XMLHttpRequest;r.open("GET",a,!0);const i=new Promise((t,e)=>{r.onload=()=>200===r.status?t(JSON.parse(r.response)):e(new Error("Error getting the lowest payment option parameters.")),r.onerror=()=>e(new Error("Error getting the lowest payment option parameters.")),r.send()});return n.set(a,i),i}(this.configuration.environment,this.configuration.store)}catch(t){return}const c=t.dataset.type&&"text"===t.dataset.type.toLowerCase();if(t.innerHTML="",c){var d=r("span",{className:"crdv-text"},o,i);t.appendChild(d)}else{s=r("span",{class:"crdv-learn-more"},"Learn More").outerHTML;const n=r("a",{className:"crdv-button",href:this.configuration.environment.landingPageRoot},o);n.appendChild(i),t.appendChild(n);const a=`Application/Prequalify/Product/${this.configuration.store}/FinancedAmount/${e}/Welcome#plugin`;let c=`${this.configuration.environment.websiteRoot}/${a}`;this.lowestPaymentOptionParameters.retailerDashboardUrl&&(c=`${this.lowestPaymentOptionParameters.retailerDashboardUrl}${a}`),t.dataset.type&&"popup"===t.dataset.type.toLowerCase()||t.dataset.type&&"modal"===t.dataset.type.toLowerCase()?(n.setAttribute("href","#"),n.setAttribute("data-href",c),n.addEventListener("click",t=>{t.preventDefault(),this.popup.open(n.getAttribute("data-href"))})):n.setAttribute("href",c)}if(t.dataset.message&&-1===t.dataset.message.indexOf("%"))return void(o.textContent=t.dataset.message);if(!1===this.lowestPaymentOptionParameters.storeFound)return;if(!1===this.lowestPaymentOptionParameters.storeActive)return;if(!1===this.lowestPaymentOptionParameters.profilesFound)return;let l;if(c||ethis.lowestPaymentOptionParameters.defaultAlaFinancedAmountGreaterThan||e>this.lowestPaymentOptionParameters.maxFinancedAmount)l={alaText:this.lowestPaymentOptionParameters.defaultAlaText,minMonthlyPayment:0,maxMonthlyPayment:0,financePeriod:0};else if(this.lowestPaymentOptionParameters.payInFour&&e>=this.lowestPaymentOptionParameters.payInFourFinancedAmountGreateOrEqualTo&&e<=this.lowestPaymentOptionParameters.payInFourFinancedAmountLowerOrEqualTo){const t=e/4;l={alaText:this.lowestPaymentOptionParameters.payInFourAlaText.replace("",`$${t.toFixed(2)}`),minMonthlyPayment:t,maxMonthlyPayment:t,financePeriod:4}}if(this.lowestPaymentOptionParameters.brandContent?i.innerHTML=this.lowestPaymentOptionParameters.brandContent:i.innerHTML='\n \n \n \n \n\n',!l&&!c)try{l=await function(t,e,o){const a=`${t.apiRoot}/v3/calculator/store/${e}/amount/${o}/lowestMonthlyPayment`;if(n.has(a))return n.get(a);const r=new XMLHttpRequest;r.open("GET",a,!0);const i=new Promise((t,e)=>{r.onload=()=>200===r.status?t(JSON.parse(r.response)):e(new Error("Error getting the lowest payment option.")),r.onerror=()=>e(new Error("Error getting the lowest payment option.")),r.send()});return n.set(a,i),i}(this.configuration.environment,this.configuration.store,e)}catch(t){return}if(t.dataset.message){const e=[`$${l.minMonthlyPayment.toFixed(2)}`,`$${l.maxMonthlyPayment.toFixed(2)}`,l.financePeriod];o.innerHTML=e.reduce((t,e,o)=>t.replace(`%${o}`,e),t.dataset.message)}else if(l.alaText){i.remove();var m=l.alaText.replace("",s);t.dataset.hideBrand?o.innerHTML=m.replace(" with ","").replace(" with ",""):o.innerHTML=m.replace("",i.outerHTML).replace("",i.outerHTML)}}async prequalify(t){if(!this.configuration)throw new Error("You must set the configuration first using the method `config`.");if(!t)throw new Error("amount is required.");const e=parseFloat(t);if(Number.isNaN(e))throw new Error("amount is invalid.");if(ethis.configuration.maxAmount)throw new Error(`amount cannot be higher than ${this.configuration.maxAmount.toFixed(2)}.`);const o=`${(await a(this.configuration.environment,this.configuration.store)).retailerHostName}Application/Prequalify/Product/${this.configuration.store}/FinancedAmount/${e}/Welcome#plugin`;return this.popup.open(o),new Promise(t=>{this.emitter.once("crdv-close",()=>t({approved:!1})),this.emitter.once("crdv-approved",e=>t({approved:!0,publicId:e}))})}async checkout(t,e,o){if(!t)throw new Error("publicId is required.");if(!this.configuration)throw new Error("You must set the configuration first using the method `config`.");this.isCheckout=!0;const n=`${(await a(this.configuration.environment,this.configuration.store)).retailerHostName}Application/Cart/${this.configuration.store}/${t}/Identification/Back/true#plugin`;if(this.popup.open(n,this.configuration.type),!o&&!e)return new Promise(t=>{this.emitter.once("crdv-close",()=>t(!1)),this.emitter.once("crdv-complete",()=>t(!0))});o&&this.emitter.once("crdv-close",()=>{window.location.href=o}),e&&this.emitter.once("crdv-complete",()=>{window.location.href=e})}addEventListener(t){this.emitter.on("crdv-approved",e=>t({eventName:i,eventArgs:{publicId:e}}))}}}(),CRDV=g}();