(window.cbJsonP=window.cbJsonP||[]).push([[188],{168:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i="chargebee-business-entity-id"},185:function(e,t,n){"use strict";var i=n(21),r=n.n(i),a=n(24),o=n.n(a),s=n(8),c=n.n(s),u=n(2),d=n.n(u),l=n(5),f=n.n(l),m=n(4),h=n(31),p=n(1),A=n(6),g=n(19),y=n(26),w=n(15),E=n(7),v=n(46),R=n(17),M=window.addEventListener?"addEventListener":"attachEvent",S=window[M],T="attachEvent"==M?"onmessage":"message",b=function(){function e(t){d()(this,e),this.windowType=t,this.listen()}return f()(e,[{key:"listen",value:function(){var e=this;S(T,(function(t){if(Object(R.a)()&&console.log("message received",t.data),"object"==c()(t.data)&&null!=t.data&&t.data.cbEvent){var n=t.data;if((n.targetWindowName==window.name||e.windowType==p.o.Host&&n.targetWindowName==E.a.HOST_NAME)&&!(e.windowType==p.o.Component&&t.origin!=m.a.getJSDomainIframeCommunication()||e.windowType==p.o.Master&&t.origin!=m.a.getJSDomainIframeCommunication()&&t.source!==window.parent)){var i=n.replyId,r=n.srcWindowName,a=n.message;a&&a.action&&(h.a.notTrue((function(){return e.windowType!=p.o.Component||n.srcWindowName==E.a.MASTER_FRAME}),Object(y.d)(g.e.receiveMessageError)),A.a.resolve(a).then((function(o){if(!(a.options&&a.options.noReply||n.srcWindowName===n.targetWindowName)){var s={replyId:i,message:o,cbEvent:!0,targetWindowName:n.srcWindowName};e.postMessage(r,s,t.origin)}})).catch((function(o){if(!(a.options&&a.options.noReply||n.srcWindowName===n.targetWindowName)){var s=new g.a(o),c={replyId:i,error:Object(w.l)(s),message:o.message,cbEvent:!0,targetWindowName:n.srcWindowName};e.postMessage(r,c,t.origin)}})))}}}))}},{key:"postMessage",value:function(e,t,n){var i=this;h.a.notTrue((function(){return i.windowType!=p.o.Component||e==E.a.MASTER_FRAME}),Object(y.d)(g.e.responseError)),h.a.notTrue((function(){return i.windowType!=p.o.Component||n==m.a.getJSDomainIframeCommunication()}),Object(y.d)(g.e.responseMismatchError)),Object(R.a)()&&console.log("response to --\x3e "+e+" "+o()(t));var r=this.getTargetWindow(e,{target_iframe_name:e,message_action:t.targetWindowName});try{Object(w.m)({targetWindow:r,message:t,targetIframeName:e,windowType:this.windowType,handlerType:p.n.Receiver})}catch(e){console.error(e)}Object(w.e)(r,t,n,p.n.Receiver)}},{key:"getTargetWindow",value:function(e,t){try{return this.windowType==p.o.Host?window.frames[e]:e&&e!=E.a.HOST_NAME?window.parent.frames[e]:window.parent}catch(e){if(this.windowType===p.o.Component||this.windowType===p.o.Master){var n=r()({},t,window.cb_site_info);v.a.error(e,n)}}}}]),e}();t.a=b},231:function(e,t,n){"use strict";n.r(t);var i=n(2),r=n.n(i),a=n(5),o=n.n(a),s=n(61),c=n.n(s),u=n(83),d=n.n(u),l=n(3),f=n.n(l),m=n(21),h=n.n(m),p=n(13),A=n.n(p),g=n(7),y=n(1),w=n(4),E=n(19),v=n(376),R=n(26),M=function(){function e(){var t=this;r()(this,e),this.MASTER_IFRAME_TIMEOUT=1e4,this.MAX_RETRIES_MASTER_IFRAME=3,this.iframeLoad=new A.a((function(e,n){t.iframeLoadSuccess=e,t.iframeLoadFailed=n})),this.initialize=new A.a((function(e,n){t.initializeSuccess=e,t.initializeFailed=n}))}return o()(e,[{key:"insertInside",value:function(e,t,n,i){var r=this,a=document.createElement("iframe");a.id=e,a.name=this.name,a.src=this.srcUrl,a.instance=this;var o=h()({margin:"0",padding:"0",border:"none",overflow:"hidden",display:"block",minWidth:"100%",width:"1px",height:"1.2em"},i);f()(o).forEach((function(e){a.style[e]=o[e]}));var s=document.getElementById(e);if(n&&s){if(a.id=a.id+"_frame",s.classList.add("CbHosted"),n&&"1.2em"===o.height){n.container=s,this.componentField=n;var c="1.2em";try{var u=n.parent.options.style.base.fontSize;if(~u.indexOf("px"))c=1.2*parseInt(u.replace("px",""))+"px"||"1.2em"}catch(e){}a.style.height=c}s.appendChild(a)}else s&&s.remove(),t.insertBefore(a,null);return this.ref=a,new A.a((function(e,t){a.onload=function(){r.iframeLoadSuccess(),e(!0)},a.onerror=function(){if(!w.a.isSPA()){var e=a.name+" iframe load failed";r.iframeLoadFailed(e),t(e)}}}))}},{key:"insert",value:function(){var e=this,t=document.getElementById(g.a.CONTAINER);return new v.b(d()(c.a.mark((function n(){return c.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.insertInside(e.name,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,e)}))),{errors:{executionTimeout:Object(R.d)(E.e.errorMountingMaster),maxAttemptsReached:Object(R.d)(E.e.errorMountingMaster)}}).setExecutionTimeout(this.MASTER_IFRAME_TIMEOUT).setMaxRetries(this.MAX_RETRIES_MASTER_IFRAME).execute()}},{key:"destroy",value:function(){this.ref.innerHTML="",this.componentField.container.removeChild(this.ref),delete this.ref,delete this.componentField}}],[{key:"masterFrame",value:function(t,n){var i=new e;return i.name=t,i.type=y.o.Master,i.srcUrl=n,i}},{key:"componentFrame",value:function(t,n){var i=new e;return i.name=t,i.type=y.o.Component,i.srcUrl=n,i}}]),e}(),S=n(64),T=n(185),b=n(31),_=n(318),F=n(6),I=n(15),C=n(17);n.d(t,"CHILD_IFRAME_NAME",(function(){return k}));var k=function(e,t){return"cb-component-"+e+"-"+t},O=function(){return"#"+encodeURIComponent(window.location.host)},j=new(function(){function e(){var t;r()(this,e),this.childFrames=[],this.connectionClient=new S.c(y.o.Host,!0),new T.a(y.o.Host),t=this,F.a.registerAction(y.i.Actions.TriggerEvent,{handle:function(e){var t=_.a.registry[e.data.frame];return b.a.notTrue((function(){return!!t}),Object(R.d)(E.e.componentNotFound)),t.delegateEvent(e.data),new A.a((function(e,t){return e({acknowledged:!0})}))}}),F.a.registerAction(y.i.Actions.ReceiveStatusBroadcast,{handle:function(e){var t=_.a.registry[e.data.frame];return b.a.notTrue((function(){return!!t}),Object(R.d)(E.e.componentNotFound)),t.delegateEvent(e.data),new A.a((function(e,t){return e({acknowledged:!0})}))}}),F.a.registerAction(y.i.Actions.setTestCards,{handle:function(e){var t=_.a.registry[e.data.frame];return t&&t.delegateEvent(e.data),A.a.resolve({acknowledged:!0})}}),F.a.registerAction(y.i.Actions.SetPaymentIntent3DSResult,{handle:function(e){return t.send({action:y.m.Actions.SetPaymentIntent3DSResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetAdyen3DS1VerificationResult,{handle:function(e){return t.send({action:y.m.Actions.SetAdyen3DS1VerificationResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.m.Actions.SetCheckoutCom3DSVerificationResult,{handle:function(e){return t.send({action:y.m.Actions.SetCheckoutCom3DSVerificationResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.m.Actions.SetCybersource3DSVerificationResult,{handle:function(e){return t.send({action:y.m.Actions.SetCybersource3DSVerificationResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetAdyenIDealVerificationResult,{handle:function(e){try{t.send({action:y.m.Actions.CaptureKVL,data:h()({action:"iDeal_set_verification_result"},Object(I.l)(e.data))},g.a.MASTER_FRAME)}catch(e){}return t.send({action:y.m.Actions.SetAdyenIDealVerificationResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetStripeIDealVerificationResult,{handle:function(e){try{t.send({action:y.m.Actions.CaptureKVL,data:h()({action:"iDeal_set_verification_result"},Object(I.l)(e.data))},g.a.MASTER_FRAME)}catch(e){}return t.send({action:y.m.Actions.SetStripeIDealVerificationResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetAdyenSofortVerificationResult,{handle:function(e){return t.send({action:y.m.Actions.SetAdyenSofortVerificationResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetAdyenBancontactVerificationResult,{handle:function(e){return t.send({action:y.m.Actions.SetAdyenBancontactVerificationResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetAdyenGiropayVerificationResult,{handle:function(e){return t.send({action:y.m.Actions.SetAdyenGiropayVerificationResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetAdyenDotpayVerificationResult,{handle:function(e){return t.send({action:y.m.Actions.SetAdyenDotpayVerificationResult,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetFrameLoaded,{handle:function(e){return window["cb-"+e.data.frame+"-loaded"]=!0,A.a.resolve({acknowledged:!0})}}),F.a.registerAction(y.i.Actions.CaptureKVL,{handle:function(e){return t.send({action:y.m.Actions.CaptureKVL,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.CaptureException,{handle:function(e){return t.send({action:y.m.Actions.CaptureException,data:e.data},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetAuthToken,{handle:function(e){return t.send({action:y.m.Actions.SetHpData,data:{jwt:Object(I.q)(e,"data.jwt")||""}},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetCustomerHandle,{handle:function(e){return t.send({action:y.m.Actions.SetHpData,data:{customer_handle:Object(I.q)(e,"data.customer_handle")||""}},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.SetPreviewPortalEmail,{handle:function(e){var n=Object(I.q)(e,"data.email")||"";return t.send({action:y.m.Actions.SetHpData,data:{preview_portal_email:n}},g.a.MASTER_FRAME)}}),F.a.registerAction(y.i.Actions.GetPreviewPortalEmail,{handle:function(e){return t.send({action:y.m.Actions.GetHpData,data:{param:"preview_portal_email"}},g.a.MASTER_FRAME).then((function(e){var t=e.preview_portal_email,n=document.getElementById("cb-frame");return n&&t&&n.contentWindow.postMessage({action:"setPreviewPortalEmail",referrer:"chargebeejs",data:{preview_portal_email:t}},"*"),e}))}}),F.a.registerAction(y.i.Actions.ShowFrame,{handle:function(e){return document.querySelector("iframe[name="+e.data+"]").style.display="block",new A.a((function(e,t){return e({acknowledged:!0})}))}}),F.a.registerAction(y.i.Actions.HideFrame,{handle:function(e){return document.querySelector("iframe[name="+e.data+"]").style.display="none",new A.a((function(e,t){return e({acknowledged:!0})}))}})}return o()(e,[{key:"createMasterFrame",value:function(){var e=this;return this.checkMasterInitialized()||(this.masterFrame=M.masterFrame(S.b,C.b.ASSET_PATH+"/master.html"+O()),this.commMgrReady=this.masterFrame.insert().then((function(){var t=w.a.getCbInstance(),n={host:window.location.origin,site:t.site,publishableKey:t.publishableKey,businessEntityId:w.a.getBusinessEntityId(),options:t.options,window_url:window.location.href},i={action:y.m.Actions.RegisterMaster,data:n};return e.register(i,e.masterFrame)})).catch((function(t){e.masterFrame.initializeFailed(new Error(Object(R.d)(E.e.errorMountingMaster))),console.error(Object(R.d)(E.e.errorMountingMaster)),t&&console.error(t)}))),this.commMgrReady}},{key:"createCbFrame",value:function(e,t){var n=this,i=e.id,r=e.fieldType,a=(e.options,M.componentFrame(k.apply(null,[r,this.childFrames.length]),C.b.ASSET_PATH+"/component.html"+O()));return this.childFrames.push(a),a.insertInside(i,t,e).then((function(){return n.masterFrame.initialize})).then((function(){return a}))}},{key:"createIDealFrame",value:function(e,t,n){var i=this,r=e.id,a=e.fieldType,o=M.componentFrame(k.apply(null,[a,this.childFrames.length]),C.b.ASSET_PATH+"/component.html"+O());return this.childFrames.push(o),o.insertInside(r,t,e,n).then((function(){return i.masterFrame.initialize})).then((function(){return o}))}},{key:"register",value:function(e,t){var n=this;return this.masterFrame.iframeLoad.then((function(){return n.connectionClient.sendMessage(e,S.b,{timeout:1e4})})).then((function(){return t.initializeSuccess(),{registered:!0}})).catch((function(e){return t.initializeFailed(e),{registered:!1}}))}},{key:"checkMasterInitialized",value:function(){var e=document.getElementById(S.b);return!this.masterFrame&&e&&(this.masterFrame=e.instance),!!this.masterFrame&&!!e}},{key:"send",value:function(e,t,n){var i=this;return this.createMasterFrame().then((function(){return i.masterFrame.initialize})).then((function(){return i.connectionClient.sendMessage(e,t,n)}))}},{key:"listen",value:function(e){this.connectionClient.receiver.listen(e)}},{key:"deregister",value:function(e){this.childFrames=this.childFrames.filter((function(t){return t.name!==e}))}}]),e}());t.default=j},232:function(e,t,n){"use strict";n.d(t,"d",(function(){return l})),n.d(t,"e",(function(){return f})),n.d(t,"f",(function(){return m})),n.d(t,"c",(function(){return h})),n.d(t,"k",(function(){return p})),n.d(t,"i",(function(){return A})),n.d(t,"j",(function(){return g})),n.d(t,"h",(function(){return y})),n.d(t,"g",(function(){return w})),n.d(t,"b",(function(){return v})),n.d(t,"a",(function(){return R})),n.d(t,"l",(function(){return M}));var i=n(3),r=n.n(i),a=n(8),o=n.n(a),s=n(13),c=n.n(s),u=n(168),d=n(19),l=function(e,t){return f(e,(function(){return!!window[t]}))},f=function(e,t){return new c.a((function(n,i){if(1==t())n(!0);else{var r=window.setTimeout((function(){return i(d.e.scriptLoadError)}),5e4);m(e,(function e(){1==t()?(clearTimeout(r),window.setTimeout((function(){return n(!0)}),100)):window.setTimeout(e,100)}),(function(){i(d.e.scriptLoadError)}))}}))},m=function(e,t,n){var i=document.createElement("script");i.onload=t,i.onerror=n,document.head.appendChild(i),i.src=e},h=function(e){return new c.a((function(t,n){for(var i=document.styleSheets,r=0,a=i.length;re.MAX_RETRIES){clearTimeout(o);var i=new h.a(t||e.options.errors.maxAttemptsReached);return e.triggerErrorCallback(r-1,i),n(i)}e.triggerErrorCallback(r-1,t),u()},u=(i=s()(a.a.mark((function n(){var i;return a.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,clearTimeout(o),o=setTimeout((function(){return c(e.options.errors.executionTimeout)}),e.EXEC_TIMEOUT),n.next=4,e.callable();case 4:i=n.sent,r=i,clearTimeout(o),t(r),n.next=11;break;case 8:n.prev=8,n.t0=n.catch(0),c(n.t0);case 11:case"end":return n.stop()}var r}),n,e,[[0,8]])}))),function(){return i.apply(this,arguments)});u()}))),this.preparedPromise)}}]),e}();t.b=y},6:function(e,t,n){"use strict";var i=n(2),r=n.n(i),a=n(5),o=n.n(a),s=new(function(){function e(){r()(this,e),this.actionRegistry={}}return o()(e,[{key:"registerAction",value:function(e,t){this.actionRegistry[e]=t}},{key:"resolve",value:function(e){var t=this.actionRegistry[e.action];if(t&&t.handle)return t.handle(e);console.log("Unknown action: "+t)}}]),e}());t.a=s}}]); //# sourceMappingURL=188-f75816f1a38d7c79c307.js.map