@getopenpay/openpay-js 0.1.16-alpha.d3a4efb → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +2 -2
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -20,4 +20,4 @@ ${r.message}`),r.message)}else return jt(r.message);if(typeof r=="object")try{re
|
|
|
20
20
|
`;const t=document.createElement("div"),n=t.attachShadow({mode:"open"});n.appendChild(e.content.cloneNode(!0));const s=n.querySelector("#three-ds-iframe"),i=n.querySelector(".cancel-button");return document.body.appendChild(t),{host:t,iframe:s,cancelButton:i}};function Po(r,e,t){const n=async()=>{try{const i=await so(r,t);i&&(clearInterval(s),e(i))}catch{}};n();const s=setInterval(n,Lr);return s}function Io({elements:r,pollingInterval:e,resolve:t}){const n=()=>{clearInterval(e),r.host.remove(),t(mt.CANCELLED)};return r.cancelButton.addEventListener("click",n),()=>{r.cancelButton.removeEventListener("click",n)}}async function Ao({url:r,baseUrl:e}){const t=Ro(r);return new Promise(n=>{const s=c=>{setTimeout(()=>{t.host.remove()},1e3),n(c),o==null||o()},i=Po(t.iframe,s,new URL(e).origin),o=Io({elements:t,pollingInterval:i,resolve:n})})}const{log__:P,err__:Wr}=ee("common-cc"),{log__:Gr}=ee("stripe-cc"),jo=Ft(async({context:r,checkoutPaymentMethod:e,nonCdeFormInputs:t,formCallbacks:n,customParams:s})=>{var d;P("├ Running common CC flow...",{checkoutPaymentMethod:e});const i=r.anyCdeConnection,o=await tt(i);P(`├ Validating non-CDE form fields [Mode: ${o.mode}]`);const c=zt(t,n.get.onValidationError);P(`├ Tokenizing card info in CDE [Session: ${r.elementsSessionId}]`);const l=await ro(s.currentCdeConnections,{session_id:r.elementsSessionId});bo(l,n.get.onValidationError);const u={session_id:r.elementsSessionId,checkout_payment_method:e,non_cde_form_fields:c};try{if(o.mode==="setup"){P(`├ Setting up payment method in CDE [Token: ${o.token}]`);const g=await no(i,u);return P(`╰ Setup completed successfully [PM ID: ${g.payment_method_id}]`),{mode:"setup",result:g}}else{P(`├ Initial checkout flow. Checking out card info in CDE [Session: ${r.elementsSessionId}]`);const g=await Nr(i,u);return P("╰ Checkout completed successfully."),{mode:"checkout",result:g}}}catch(g){if(g instanceof Ar&&g.originalErrorMessage==="3DS_REQUIRED"){P("├ Card requires 3DS, starting non-legacy payment flow"),P("error.response.headers",g.response.headers);const E=((d=g.response.headers)==null?void 0:d["op-should-use-new-flow"])==="true",m=await Qi(i,u);if(P(`├ op-should-use-new-flow: ${E}`),P("├ Payment flow result:",m),E?await Lo(m,r.baseUrl):await Do(m),o.mode==="setup"){P(`├ Confirming payment flow [cc_pm_id: ${m.cc_pm_id}]`);const _=await Lt(i,{secure_token:o.token,existing_cc_pm_id:m.cc_pm_id});P("├ Confirm payment flow result received Result:",_);const C=Vt(_);return P(`╰ Setup completed successfully [PM ID: ${C.payment_method_id}]`),{mode:"setup",result:C}}else{P(`├ Checking out after 3DS flow [Flow: ${E?"new":"legacy"}]`);const _=await Nr(i,{...u,existing_cc_pm_id:m.cc_pm_id,do_not_use_legacy_cc_flow:!E});return P("╰ Checkout completed successfully."),{mode:"checkout",result:_}}}throw Wr("╰ Error checking out card info in CDE"),Wr(g),g}}),No=r=>{const e=r.required_user_actions.find(t=>t.type==="stripe_3ds");if(!e)throw new Error("No stripe 3DS action found");return Js.parse(e)},Mo=r=>{const e=r.required_user_actions.find(t=>t.type==="airwallex_payment_consent");if(!e)throw new Error("No common 3DS action found");return Gs.parse(e)},Lo=async(r,e)=>{const t=Mo(r);P(`├ Using common 3DS flow [URL: ${t.redirect_url}]`);const n=await Ao({url:t.redirect_url,baseUrl:e});if(P(`╰ 3DS verification completed [Status: ${n}]`),n===mt.CANCELLED)throw new Error("3DS verification cancelled");if(n===mt.FAILURE)throw new Error("3DS verification failed")},Do=async r=>{const e=No(r);Gr(`├ Using stripe 3DS flow [Client Secret: ${e.client_secret.substring(0,8)}...]`),await ii(e),Gr("╰ Stripe 3DS flow completed successfully")},{log__:Z,err__:$o}=ee("stripe-pr"),Zo=a.object({provider:a.union([a.literal("apple_pay"),a.literal("google_pay")]),processor_name:a.literal("stripe"),metadata:a.object({stripe_pk:a.string()})}),Uo=Br(async({context:r})=>{Z("Checking if there are any CPMs for Stripe PR...");const e=qr(r.checkoutPaymentMethods,Zo);Z("Initializing Stripe PR flow...");const t=r.anyCdeConnection,n=await tt(t),s=n.mode==="setup";Z("Getting initial preview amount");const i=await jr(t,n.token,s,void 0),o=await ti(e.metadata.stripe_pk,i.amountAtom,i.currency,s);Z("Checking if can make payment");const c=await o.canMakePayment();return c===null?($o("canMakePayment returned null"),{isAvailable:!1,reason:"canMakePayment returned null"}):(Z("Stripe PR flow initialized successfully. Can make payment",c),{isAvailable:!0,pr:o,availableProviders:{applePay:c.applePay,googlePay:c.googlePay}})}),Fo=Ft(async({context:r,checkoutPaymentMethod:e,nonCdeFormInputs:t,formCallbacks:n,customParams:s,initResult:i})=>{if(Z("Running Stripe PR flow..."),s.provider!==e.provider)throw new Error(`Provider mismatch. Expected ${s.provider}, got ${e.provider}`);const o=r.anyCdeConnection,c=i.pr;if(s!=null&&s.overridePaymentRequest){const _=s.overridePaymentRequest;Z("Overriding PR amount with",_),zo(c,_.amount,_.pending)}Z("Showing PR dialog..."),c.show();const l=await ni(c);Z("Stripe PM added event:",l),Z("Merging PM fields with form fields...");const u=Vo(t,l),d=zt(u,n.get.onValidationError);Z("PR dialog finished. Starting payment flow...");const g=await eo(o,{fields:d,checkoutPaymentMethod:e}),E=Bo(g);Z("Confirming PR with Stripe..."),await si(E,l);const m=await tt(o);if(m.mode==="setup"){Z("Confirming payment flow for setup...");const _=await Lt(o,{secure_token:m.token});return{mode:"setup",result:Vt(_)}}else{Z("Performing checkout...");const _={secure_token:m.token,payment_input:{provider_type:e.provider},customer_email:d[x.EMAIL],customer_zip_code:d[x.ZIP_CODE],customer_country:d[x.COUNTRY],promotion_code:d[x.PROMOTION_CODE],line_items:m.line_items,total_amount_atom:m.amount_total_atom,cancel_at_end:!1,checkout_payment_method:e};return{mode:"checkout",result:await Mr(o,_)}}}),Vo=(r,e)=>{var o,c,l,u;const t={...r},[n,...s]=((c=(o=e.payerName)==null?void 0:o.trim())==null?void 0:c.split(/\s+/))??[],i=s.join(" ")||void 0;return t[x.FIRST_NAME]=t[x.FIRST_NAME]||n||"_OP_UNKNOWN",t[x.LAST_NAME]=t[x.LAST_NAME]||i||"_OP_UNKNOWN",t[x.EMAIL]=t[x.EMAIL]||e.payerEmail||"op_unfilled@getopenpay.com",t[x.ZIP_CODE]=t[x.ZIP_CODE]||((l=e.shippingAddress)==null?void 0:l.postalCode)||"00000",t[x.COUNTRY]=t[x.COUNTRY]||((u=e.shippingAddress)==null?void 0:u.country)||"US",Z("Final form inputs:",t),t},zo=(r,e,t)=>{r.update({total:{amount:e.amountAtom,label:"Total",pending:t},currency:e.currency})},Bo=r=>{if(r.required_user_actions.length!==1)throw new Error(`Error occurred.
|
|
21
21
|
Details: got ${r.required_user_actions.length} required user actions`);return Xs.parse(r.required_user_actions[0])},Kr=(r,e,t)=>{const n=r.filter(s=>s.provider===e);if(n.length===0)throw console.error("CPMs list",r),new Error(`No CPMs found with provider '${e}' and processor '${t}'`);if(n.length!==1)throw console.error("CPMs list",r),new Error(`More than one CPM found with provider '${e}' and processor '${t}'`);return n[0]},Oe={commonCC:{init:async()=>{},run:jo},stripePR:{init:Uo,run:Fo},stripeLink:{init:So,run:Co}};var Bt=function(r,e){return Bt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Bt(r,e)};function fe(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Bt(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function qo(r,e,t,n){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function c(d){try{u(n.next(d))}catch(g){o(g)}}function l(d){try{u(n.throw(d))}catch(g){o(g)}}function u(d){d.done?i(d.value):s(d.value).then(c,l)}u((n=n.apply(r,e||[])).next())})}function Jr(r,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,s,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(u){return function(d){return l([u,d])}}function l(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(t=0)),t;)try{if(n=1,s&&(i=u[0]&2?s.return:u[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,u[1])).done)return i;switch(s=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,s=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){t.label=u[1];break}if(u[0]===6&&t.label<i[1]){t.label=i[1],i=u;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(u);break}i[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(d){u=[6,d],s=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Re(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function bt(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return i}function wt(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return r.concat(i||Array.prototype.slice.call(e))}function Pe(r){return this instanceof Pe?(this.v=r,this):new Pe(r)}function Ho(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),s,i=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(m){return function(_){return Promise.resolve(_).then(m,g)}}function c(m,_){n[m]&&(s[m]=function(C){return new Promise(function(I,V){i.push([m,C,I,V])>1||l(m,C)})},_&&(s[m]=_(s[m])))}function l(m,_){try{u(n[m](_))}catch(C){E(i[0][3],C)}}function u(m){m.value instanceof Pe?Promise.resolve(m.value.v).then(d,g):E(i[0][2],m)}function d(m){l("next",m)}function g(m){l("throw",m)}function E(m,_){m(_),i.shift(),i.length&&l(i[0][0],i[0][1])}}function Yo(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Re=="function"?Re(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(i){t[i]=r[i]&&function(o){return new Promise(function(c,l){o=r[i](o),s(c,l,o.done,o.value)})}}function s(i,o,c,l){Promise.resolve(l).then(function(u){i({value:u,done:c})},o)}}typeof SuppressedError=="function"&&SuppressedError;function N(r){return typeof r=="function"}function kt(r){var e=function(n){Error.call(n),n.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var qt=kt(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
22
22
|
`+t.map(function(n,s){return s+1+") "+n.toString()}).join(`
|
|
23
|
-
`):"",this.name="UnsubscriptionError",this.errors=t}});function Et(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var st=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,n,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=Re(o),l=c.next();!l.done;l=c.next()){var u=l.value;u.remove(this)}}catch(C){e={error:C}}finally{try{l&&!l.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else o.remove(this);var d=this.initialTeardown;if(N(d))try{d()}catch(C){i=C instanceof qt?C.errors:[C]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var E=Re(g),m=E.next();!m.done;m=E.next()){var _=m.value;try{en(_)}catch(C){i=i??[],C instanceof qt?i=wt(wt([],bt(i)),bt(C.errors)):i.push(C)}}}catch(C){n={error:C}}finally{try{m&&!m.done&&(s=E.return)&&s.call(E)}finally{if(n)throw n.error}}}if(i)throw new qt(i)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)en(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Et(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&Et(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),Xr=st.EMPTY;function Qr(r){return r instanceof st||r&&"closed"in r&&N(r.remove)&&N(r.add)&&N(r.unsubscribe)}function en(r){N(r)?r():r.unsubscribe()}var tn={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},rn={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setTimeout.apply(void 0,wt([r,e],bt(t)))},clearTimeout:function(r){var e=rn.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(r)},delegate:void 0};function nn(r){rn.setTimeout(function(){throw r})}function sn(){}function St(r){r()}var Ht=function(r){fe(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,Qr(t)&&t.add(n)):n.destination=Jo,n}return e.create=function(t,n,s){return new Wt(t,n,s)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(st),Wo=Function.prototype.bind;function Yt(r,e){return Wo.call(r,e)}var Go=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){Ct(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){Ct(n)}else Ct(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Ct(t)}},r}(),Wt=function(r){fe(e,r);function e(t,n,s){var i=r.call(this)||this,o;if(N(t)||!t)o={next:t??void 0,error:n??void 0,complete:s??void 0};else{var c;i&&tn.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&Yt(t.next,c),error:t.error&&Yt(t.error,c),complete:t.complete&&Yt(t.complete,c)}):o=t}return i.destination=new Go(o),i}return e}(Ht);function Ct(r){nn(r)}function Ko(r){throw r}var Jo={closed:!0,next:sn,error:Ko,complete:sn},Gt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Xo(r){return r}function Qo(r){return r.length===0?Xo:r.length===1?r[0]:function(t){return r.reduce(function(n,s){return s(n)},t)}}var se=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var s=this,i=ta(e)?e:new Wt(e,t,n);return St(function(){var o=s,c=o.operator,l=o.source;i.add(c?c.call(i,l):l?s._subscribe(i):s._trySubscribe(i))}),i},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=on(t),new t(function(s,i){var o=new Wt({next:function(c){try{e(c)}catch(l){i(l),o.unsubscribe()}},error:i,complete:s});n.subscribe(o)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[Gt]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Qo(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=on(e),new e(function(n,s){var i;t.subscribe(function(o){return i=o},function(o){return s(o)},function(){return n(i)})})},r.create=function(e){return new r(e)},r}();function on(r){var e;return(e=r??tn.Promise)!==null&&e!==void 0?e:Promise}function ea(r){return r&&N(r.next)&&N(r.error)&&N(r.complete)}function ta(r){return r&&r instanceof Ht||ea(r)&&Qr(r)}function ra(r){return N(r==null?void 0:r.lift)}function na(r){return function(e){if(ra(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function sa(r,e,t,n,s){return new ia(r,e,t,n,s)}var ia=function(r){fe(e,r);function e(t,n,s,i,o,c){var l=r.call(this,t)||this;return l.onFinalize=o,l.shouldUnsubscribe=c,l._next=n?function(u){try{n(u)}catch(d){t.error(d)}}:r.prototype._next,l._error=i?function(u){try{i(u)}catch(d){t.error(d)}finally{this.unsubscribe()}}:r.prototype._error,l._complete=s?function(){try{s()}catch(u){t.error(u)}finally{this.unsubscribe()}}:r.prototype._complete,l}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Ht),oa=kt(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),an=function(r){fe(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var n=new cn(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new oa},e.prototype.next=function(t){var n=this;St(function(){var s,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=Re(n.currentObservers),c=o.next();!c.done;c=o.next()){var l=c.value;l.next(t)}}catch(u){s={error:u}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(s)throw s.error}}}})},e.prototype.error=function(t){var n=this;St(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var s=n.observers;s.length;)s.shift().error(t)}})},e.prototype.complete=function(){var t=this;St(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,s=this,i=s.hasError,o=s.isStopped,c=s.observers;return i||o?Xr:(this.currentObservers=null,c.push(t),new st(function(){n.currentObservers=null,Et(c,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,s=n.hasError,i=n.thrownError,o=n.isStopped;s?t.error(i):o&&t.complete()},e.prototype.asObservable=function(){var t=new se;return t.source=this,t},e.create=function(t,n){return new cn(t,n)},e}(se),cn=function(r){fe(e,r);function e(t,n){var s=r.call(this)||this;return s.destination=t,s.source=n,s}return e.prototype.next=function(t){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.next)===null||s===void 0||s.call(n,t)},e.prototype.error=function(t){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.error)===null||s===void 0||s.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,s;return(s=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&s!==void 0?s:Xr},e}(an),aa={now:function(){return Date.now()},delegate:void 0},ca=function(r){fe(e,r);function e(t,n){return r.call(this)||this}return e.prototype.schedule=function(t,n){return this},e}(st),un={setInterval:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setInterval.apply(void 0,wt([r,e],bt(t)))},clearInterval:function(r){return clearInterval(r)},delegate:void 0},ua=function(r){fe(e,r);function e(t,n){var s=r.call(this,t,n)||this;return s.scheduler=t,s.work=n,s.pending=!1,s}return e.prototype.schedule=function(t,n){var s;if(n===void 0&&(n=0),this.closed)return this;this.state=t;var i=this.id,o=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(o,i,n)),this.pending=!0,this.delay=n,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(o,this.id,n),this},e.prototype.requestAsyncId=function(t,n,s){return s===void 0&&(s=0),un.setInterval(t.flush.bind(t,this),s)},e.prototype.recycleAsyncId=function(t,n,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return n;n!=null&&un.clearInterval(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(t,n);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var s=!1,i;try{this.work(t)}catch(o){s=!0,i=o||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),i},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,n=t.id,s=t.scheduler,i=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Et(i,this),n!=null&&(this.id=this.recycleAsyncId(s,n,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(ca),ln=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return r.prototype.schedule=function(e,t,n){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},r.now=aa.now,r}(),la=function(r){fe(e,r);function e(t,n){n===void 0&&(n=ln.now);var s=r.call(this,t,n)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(t){var n=this.actions;if(this._active){n.push(t);return}var s;this._active=!0;do if(s=t.execute(t.state,t.delay))break;while(t=n.shift());if(this._active=!1,s){for(;t=n.shift();)t.unsubscribe();throw s}},e}(ln),da=new la(ua),fa=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function ha(r){return N(r==null?void 0:r.then)}function pa(r){return N(r[Gt])}function ma(r){return Symbol.asyncIterator&&N(r==null?void 0:r[Symbol.asyncIterator])}function ya(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ga(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var _a=ga();function va(r){return N(r==null?void 0:r[_a])}function ba(r){return Ho(this,arguments,function(){var t,n,s,i;return Jr(this,function(o){switch(o.label){case 0:t=r.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,Pe(t.read())];case 3:return n=o.sent(),s=n.value,i=n.done,i?[4,Pe(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,Pe(s)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function wa(r){return N(r==null?void 0:r.getReader)}function ka(r){if(r instanceof se)return r;if(r!=null){if(pa(r))return Ea(r);if(fa(r))return Sa(r);if(ha(r))return Ca(r);if(ma(r))return dn(r);if(va(r))return xa(r);if(wa(r))return Ta(r)}throw ya(r)}function Ea(r){return new se(function(e){var t=r[Gt]();if(N(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Sa(r){return new se(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}function Ca(r){return new se(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,nn)})}function xa(r){return new se(function(e){var t,n;try{for(var s=Re(r),i=s.next();!i.done;i=s.next()){var o=i.value;if(e.next(o),e.closed)return}}catch(c){t={error:c}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}e.complete()})}function dn(r){return new se(function(e){Oa(r,e).catch(function(t){return e.error(t)})})}function Ta(r){return dn(ba(r))}function Oa(r,e){var t,n,s,i;return qo(this,void 0,void 0,function(){var o,c;return Jr(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),t=Yo(r),l.label=1;case 1:return[4,t.next()];case 2:if(n=l.sent(),!!n.done)return[3,4];if(o=n.value,e.next(o),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=l.sent(),s={error:c},[3,11];case 6:return l.trys.push([6,,9,10]),n&&!n.done&&(i=t.return)?[4,i.call(t)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Ra(r,e,t,n,s){n===void 0&&(n=0),s===void 0&&(s=!1);var i=e.schedule(function(){t(),s?r.add(this.schedule(null,n)):this.unsubscribe()},n);if(r.add(i),!s)return i}function Pa(r,e){var t=N(r)?r:function(){return r},n=function(s){return s.error(t())};return new se(n)}var Ia=kt(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function Aa(r,e){return new Promise(function(t,n){var s=!1,i;r.subscribe({next:function(o){i=o,s=!0},error:n,complete:function(){s?t(i):n(new Ia)}})})}function ja(r){return r instanceof Date&&!isNaN(r)}var Na=kt(function(r){return function(t){t===void 0&&(t=null),r(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}});function Ma(r,e){var t=ja(r)?{first:r}:typeof r=="number"?{each:r}:r,n=t.first,s=t.each,i=t.with,o=i===void 0?La:i,c=t.scheduler,l=c===void 0?da:c,u=t.meta,d=u===void 0?null:u;if(n==null&&s==null)throw new TypeError("No timeout provided.");return na(function(g,E){var m,_,C=null,I=0,V=function(F){_=Ra(E,l,function(){try{m.unsubscribe(),ka(o({meta:d,lastValue:C,seen:I})).subscribe(E)}catch(A){E.error(A)}},F)};m=g.subscribe(sa(E,function(F){_==null||_.unsubscribe(),I++,E.next(C=F),s>0&&V(s)},void 0,void 0,function(){_!=null&&_.closed||_==null||_.unsubscribe(),C=null})),!I&&V(n!=null?typeof n=="number"?n:+n-l.now():s)})}function La(r){throw new Na(r)}class xt{constructor(){this.set=e=>{if(this._current.status==="success")throw new Error("LoadedOnce is already in success state");this._current={status:"success",isSuccess:!0,loadedValue:e},this._subject.next(e),this._subject.complete()},this.throw=(e,t)=>{if(this._current.status==="success")throw new Error("LoadedOnce is already in success state");this._current={status:"error",isSuccess:!1,error:e,errMsg:t},this._subject.error(e)},this.getValueIfLoadedElse=e=>this._current.status==="success"?this._current.loadedValue:e,this.subscribe=e=>{if(this._current.status==="success"){e(this._current);return}this._current.status==="error"&&e(this._current);const t=this._subject.subscribe({next:()=>{if(this._current.status!=="success")throw new Error("Invalid state (next): please make sure to update _current before the subject");e(this._current),t.unsubscribe()},error:()=>{if(this._current.status!=="error")throw new Error("Invalid state (error): please make sure to update _current before the subject");e(this._current)}})},this.waitForLoad=e=>{if(this._current.status==="success")return Promise.resolve(this._current.loadedValue);if(this._current.status==="error")return Promise.reject(this._current.error);this._current.status!=="initial"&&io(this._current);const t={first:e.timeoutSec*1e3,with:()=>Pa(()=>new Error(e.timeoutErrMsg))};return Aa(this._subject.pipe(Ma(t)))},this._current={status:"initial",isSuccess:!1},this._subject=new an}get current(){return this._current}}const{log__:Da,err__:$a}=ee("init-flows"),fn=(r,e)=>{const t=new xt;return{publisher:t,initialize:async n=>{try{if(t.current.isSuccess)throw new Error("This flow has already been initialized.");const s=await e(n);Da(`✔ ${r} flow initialized successfully. Result:`,s),t.set(s)}catch(s){$a(`𝙭 ${r} flow initialization failed. Error:`,Je(s),"Details:",s),t.throw(s,Je(s))}}}},Za=async(r,e,t)=>{await Promise.all(Object.values(r).map(n=>n.initialize({context:e,formCallbacks:t})))},Ua=()=>({stripePR:fn("Stripe PR",Oe.stripePR.init),stripeLink:fn("Stripe Link",Oe.stripeLink.init)}),{err__:Fa}=ee("form-callbacks"),W=a.function().optional(),hn=a.object({onFocus:W,onBlur:W,onChange:W,onLoad:W,onLoadError:W,onValidationError:W,onCheckoutStarted:W,onCheckoutSuccess:W,onSetupPaymentMethodSuccess:W,onCheckoutError:W,onPaymentRequestLoad:W}),te=class te{constructor(){this.setCallbacks=e=>{this._callbacks=te.createEmptyCallbacks(),Object.entries(e).forEach(([t,n])=>{const s=ks(t,n??te.NOOP,Fa);this._callbacks[t]=s})},this._callbacks=te.createEmptyCallbacks()}get get(){return{...this._callbacks}}};te.NOOP=()=>{},te.createEmptyCallbacks=()=>{const e={};return Object.keys(hn.keyof().enum).forEach(t=>{e[t]=te.NOOP}),e},te.fromObject=e=>{const t=new te;return t.setCallbacks(hn.parse(e)),t};let Kt=te;class Va{constructor(e,t,n,s){this.handleMessage=i=>{if(!i.source)throw new Error("No source found");if(pn(i.origin)!==pn(this.baseUrl)||typeof i.data=="object"&&i.data.penpal)return;const o=ai(JSON.parse(i.data));if(!this.validateEvent(o))return;const{elementId:l,payload:u}=o,d=u.type;switch(d){case"LAYOUT":this.internalCallbacks.setFormHeight(u.height?`${u.height}px`:"100%");break;case"FOCUS":this.formCallbacks.get.onFocus(l,u.elementType);break;case"BLUR":this.formCallbacks.get.onBlur(l,u.elementType);break;case"CHANGE":this.formCallbacks.get.onChange(l,u.elementType,u.errors);break;case"LOADED":this.eventTargets[l]=i.source,this.internalCallbacks.onCdeLoaded(u);break;case"LOAD_ERROR":this.internalCallbacks.onCdeLoadError(u.message);break;case"VALIDATION_ERROR":this.formCallbacks.get.onValidationError(u.elementType,u.errors,l);break;default:console.warn("[form] Unhandled event type:",d)}},this.validateEvent=i=>i.formId!==this.formId||!i.elementId?(console.log("[OJS] formId",this.formId,i.formId),console.warn("[form] Ignoring unknown event:",i),!1):this.nonces.has(i.nonce)?(console.warn("[form] Ignoring duplicate event:",i),!1):(this.nonces.add(i.nonce),!0),this.eventTargets={},this.nonces=new Set,this.formId=e,this.baseUrl=t,this.formCallbacks=n,this.internalCallbacks=s}}const pn=r=>new URL(r).origin;async function za(r,e){const n=await kr({iframe:r,debug:!1,childOrigin:e}).promise,s=await Ri(n);if(!Pi(n,s))throw new Error("Got invalid CDE connection object");return n}class Ba{constructor(){this.connections=new Map}addConnection(e,t){this.connections.set(e,t)}getConnection(){const e=this.connections.values().next().value;if(!e)throw new Error("Connection not found");return e}getAllConnections(){return this.connections}}const qa=(r,e,t)=>{const{stripePR:n}=r;n.publisher.subscribe(s=>{if(s.isSuccess){const i=s.loadedValue,o=i.isAvailable&&i.availableProviders.applePay,c=i.isAvailable&&i.availableProviders.googlePay,l={apple_pay:{isLoading:!1,isAvailable:o,startFlow:async u=>{o&&mn("apple_pay",i,e,t,u)}},google_pay:{isLoading:!1,isAvailable:c,startFlow:async u=>{c&&mn("google_pay",i,e,t,u)}}};t.get.onPaymentRequestLoad(l)}})},mn=(r,e,t,n,s)=>Oe.stripePR.run({context:t,checkoutPaymentMethod:Kr(t.checkoutPaymentMethods,r),nonCdeFormInputs:Nt(t.formDiv),formCallbacks:n,customParams:{provider:r,overridePaymentRequest:s==null?void 0:s.overridePaymentRequest},initResult:e}),yn="The secure form failed to load properly. Please check your internet connection, or try again later.",{log__:he,err__:Jt}=ee("op-form"),ie=class ie{constructor(e){this.cdeLoadEvent=new xt,this.anyCdeConn=new xt,this.context=new xt,this.initFlows=Ua(),this.startFormInit=async()=>{try{he("Initializing OpenPay form:"),he("├ Waiting for CDE load event...");const t=await this.cdeLoadEvent.waitForLoad({timeoutSec:120,timeoutErrMsg:yn});he("├ CDE load event received"),he("├ Waiting for CDE connection...");const n=await this.anyCdeConn.waitForLoad({timeoutSec:120,timeoutErrMsg:yn});he("├ CDE connection received"),he("├ Creating OJS context, setting up handlers...");const s=ie.buildOjsFlowContext(this.config,t,n,this.getFormDiv());this.context.set(s),qa(this.initFlows,s,this.formCallbacks),he("├ Starting OJS init flows..."),await Za(this.initFlows,s,this.formCallbacks),this.formCallbacks.get.onLoad(t.totalAmountAtoms,t.currency),he("╰ Done initializing OJS flows.")}catch(t){const n=Je(t);Jt("╰ Error initializing OP form:",n),this.formCallbacks.get.onLoadError(n)}},this.setFormHeight=t=>{this.formProperties.height=t,this.registeredElements&&Object.values(this.registeredElements).forEach(n=>{n&&(n.node.style.height=t)})},this.onCdeLoaded=t=>{this.cdeLoadEvent.current.isSuccess||this.cdeLoadEvent.set(t)},this.onCdeLoadError=t=>{this.cdeLoadEvent.current.isSuccess||this.cdeLoadEvent.throw(new Error(t),t)},this.createElement=(t,n={})=>{if(!this.config)throw new Error("OpenPay form not initialized");const s=Es.parse(t),i=document.createElement("iframe"),o=this.buildQueryString(n);i.name=`${s}-element`;const c=new URL(`/app/v1/${i.name}/`,this.config.baseUrl);return c.search=o.toString(),i.src=c.href,i.style.border="none",i.style.width="100%",this.registerIframe(s,i)},this.registerIframe=(t,n)=>{const s={type:t,node:n,mount:i=>{var o;return(o=document.querySelector(i))==null?void 0:o.appendChild(n)}};return this.connectToElement({type:s.type,node:s.node}),this.registeredElements||(this.registeredElements={[Ce.CARD]:void 0,[Ce.CARD_NUMBER]:void 0,[Ce.CARD_EXPIRY]:void 0,[Ce.CARD_CVC]:void 0}),this.registeredElements[t]=s,s},this.buildQueryString=t=>{const n=new URLSearchParams;return n.append("referer",this.referrer),n.append("formId",this.formId),t.styles&&n.append("styles",oi(t.styles)),n.append("secureToken",this.config.checkoutSecureToken),n},this.connectToElement=t=>{za(t.node).then(n=>{this.connectionManager.addConnection(t.type,n),this.anyCdeConn.current.isSuccess||this.anyCdeConn.set(n)}).catch(n=>Jt("[FORM] Error connecting to CDE iframe",n))},this.getFormDiv=()=>document.querySelector(this.formTarget)??document.body,this.submitCard=()=>{const t=this.context.getValueIfLoadedElse(null);if(!t){Jt("Please wait for the form to finish loading before submitting.");return}Oe.commonCC.run({context:t,checkoutPaymentMethod:Kr(t.checkoutPaymentMethods,"credit_card"),nonCdeFormInputs:Nt(t.formDiv),formCallbacks:this.formCallbacks,customParams:{currentCdeConnections:this.connectionManager.getAllConnections()},initResult:void 0})},this.submit=this.submitCard,this.destroy=()=>{for(const t of Object.values(this.registeredElements??{}))t&&t.node.remove();window.removeEventListener("message",this.eventHandler.handleMessage.bind(this.eventHandler))},ie.assignAsSingleton(this),this.ojsVersion="0.1.16",this.ojsReleaseVersion="0.1.16-alpha.d3a4efb",this.baseUrl=e.baseUrl??"https://cde.getopenpay.com",this.config={...e,baseUrl:this.baseUrl},this.formCallbacks=Kt.fromObject(e),this.registeredElements=null,this.formId=`opjs-form-${window.crypto.randomUUID()}`,this.referrer=window.location.origin,this.formTarget=e.formTarget??"body",this.formProperties={height:"1px"},this.connectionManager=new Ba,this.eventHandler=new Va(this.formId,this.baseUrl,this.formCallbacks,{setFormHeight:this.setFormHeight,onCdeLoaded:this.onCdeLoaded,onCdeLoadError:this.onCdeLoadError}),window.addEventListener("message",this.eventHandler.handleMessage.bind(this.eventHandler)),this.startFormInit()}get checkoutSecureToken(){return this.config.checkoutSecureToken}};ie.ojsFlows=Oe,ie.assignAsSingleton=e=>{if(ie.getInstance())throw new Error("OpenPay instance already exists. Only one instance is allowed.");window.ojs=e},ie.getInstance=()=>window.ojs??null,ie.buildOjsFlowContext=(e,t,n,s)=>({baseUrl:new URL(e.baseUrl??je).origin,formDiv:s,elementsSessionId:t.sessionId,checkoutPaymentMethods:t.checkoutPaymentMethods,anyCdeConnection:n,customInitParams:e.customInitParams??{}});let Xt=ie;pe.FieldName=x,pe.OpenPayForm=Xt,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})});
|
|
23
|
+
`):"",this.name="UnsubscriptionError",this.errors=t}});function Et(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var st=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,n,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=Re(o),l=c.next();!l.done;l=c.next()){var u=l.value;u.remove(this)}}catch(C){e={error:C}}finally{try{l&&!l.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else o.remove(this);var d=this.initialTeardown;if(N(d))try{d()}catch(C){i=C instanceof qt?C.errors:[C]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var E=Re(g),m=E.next();!m.done;m=E.next()){var _=m.value;try{en(_)}catch(C){i=i??[],C instanceof qt?i=wt(wt([],bt(i)),bt(C.errors)):i.push(C)}}}catch(C){n={error:C}}finally{try{m&&!m.done&&(s=E.return)&&s.call(E)}finally{if(n)throw n.error}}}if(i)throw new qt(i)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)en(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Et(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&Et(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),Xr=st.EMPTY;function Qr(r){return r instanceof st||r&&"closed"in r&&N(r.remove)&&N(r.add)&&N(r.unsubscribe)}function en(r){N(r)?r():r.unsubscribe()}var tn={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},rn={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setTimeout.apply(void 0,wt([r,e],bt(t)))},clearTimeout:function(r){var e=rn.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(r)},delegate:void 0};function nn(r){rn.setTimeout(function(){throw r})}function sn(){}function St(r){r()}var Ht=function(r){fe(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,Qr(t)&&t.add(n)):n.destination=Jo,n}return e.create=function(t,n,s){return new Wt(t,n,s)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(st),Wo=Function.prototype.bind;function Yt(r,e){return Wo.call(r,e)}var Go=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){Ct(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){Ct(n)}else Ct(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Ct(t)}},r}(),Wt=function(r){fe(e,r);function e(t,n,s){var i=r.call(this)||this,o;if(N(t)||!t)o={next:t??void 0,error:n??void 0,complete:s??void 0};else{var c;i&&tn.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&Yt(t.next,c),error:t.error&&Yt(t.error,c),complete:t.complete&&Yt(t.complete,c)}):o=t}return i.destination=new Go(o),i}return e}(Ht);function Ct(r){nn(r)}function Ko(r){throw r}var Jo={closed:!0,next:sn,error:Ko,complete:sn},Gt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Xo(r){return r}function Qo(r){return r.length===0?Xo:r.length===1?r[0]:function(t){return r.reduce(function(n,s){return s(n)},t)}}var se=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var s=this,i=ta(e)?e:new Wt(e,t,n);return St(function(){var o=s,c=o.operator,l=o.source;i.add(c?c.call(i,l):l?s._subscribe(i):s._trySubscribe(i))}),i},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=on(t),new t(function(s,i){var o=new Wt({next:function(c){try{e(c)}catch(l){i(l),o.unsubscribe()}},error:i,complete:s});n.subscribe(o)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[Gt]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Qo(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=on(e),new e(function(n,s){var i;t.subscribe(function(o){return i=o},function(o){return s(o)},function(){return n(i)})})},r.create=function(e){return new r(e)},r}();function on(r){var e;return(e=r??tn.Promise)!==null&&e!==void 0?e:Promise}function ea(r){return r&&N(r.next)&&N(r.error)&&N(r.complete)}function ta(r){return r&&r instanceof Ht||ea(r)&&Qr(r)}function ra(r){return N(r==null?void 0:r.lift)}function na(r){return function(e){if(ra(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function sa(r,e,t,n,s){return new ia(r,e,t,n,s)}var ia=function(r){fe(e,r);function e(t,n,s,i,o,c){var l=r.call(this,t)||this;return l.onFinalize=o,l.shouldUnsubscribe=c,l._next=n?function(u){try{n(u)}catch(d){t.error(d)}}:r.prototype._next,l._error=i?function(u){try{i(u)}catch(d){t.error(d)}finally{this.unsubscribe()}}:r.prototype._error,l._complete=s?function(){try{s()}catch(u){t.error(u)}finally{this.unsubscribe()}}:r.prototype._complete,l}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Ht),oa=kt(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),an=function(r){fe(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var n=new cn(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new oa},e.prototype.next=function(t){var n=this;St(function(){var s,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=Re(n.currentObservers),c=o.next();!c.done;c=o.next()){var l=c.value;l.next(t)}}catch(u){s={error:u}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(s)throw s.error}}}})},e.prototype.error=function(t){var n=this;St(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var s=n.observers;s.length;)s.shift().error(t)}})},e.prototype.complete=function(){var t=this;St(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,s=this,i=s.hasError,o=s.isStopped,c=s.observers;return i||o?Xr:(this.currentObservers=null,c.push(t),new st(function(){n.currentObservers=null,Et(c,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,s=n.hasError,i=n.thrownError,o=n.isStopped;s?t.error(i):o&&t.complete()},e.prototype.asObservable=function(){var t=new se;return t.source=this,t},e.create=function(t,n){return new cn(t,n)},e}(se),cn=function(r){fe(e,r);function e(t,n){var s=r.call(this)||this;return s.destination=t,s.source=n,s}return e.prototype.next=function(t){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.next)===null||s===void 0||s.call(n,t)},e.prototype.error=function(t){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.error)===null||s===void 0||s.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,s;return(s=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&s!==void 0?s:Xr},e}(an),aa={now:function(){return Date.now()},delegate:void 0},ca=function(r){fe(e,r);function e(t,n){return r.call(this)||this}return e.prototype.schedule=function(t,n){return this},e}(st),un={setInterval:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setInterval.apply(void 0,wt([r,e],bt(t)))},clearInterval:function(r){return clearInterval(r)},delegate:void 0},ua=function(r){fe(e,r);function e(t,n){var s=r.call(this,t,n)||this;return s.scheduler=t,s.work=n,s.pending=!1,s}return e.prototype.schedule=function(t,n){var s;if(n===void 0&&(n=0),this.closed)return this;this.state=t;var i=this.id,o=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(o,i,n)),this.pending=!0,this.delay=n,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(o,this.id,n),this},e.prototype.requestAsyncId=function(t,n,s){return s===void 0&&(s=0),un.setInterval(t.flush.bind(t,this),s)},e.prototype.recycleAsyncId=function(t,n,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return n;n!=null&&un.clearInterval(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(t,n);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var s=!1,i;try{this.work(t)}catch(o){s=!0,i=o||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),i},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,n=t.id,s=t.scheduler,i=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Et(i,this),n!=null&&(this.id=this.recycleAsyncId(s,n,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(ca),ln=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return r.prototype.schedule=function(e,t,n){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},r.now=aa.now,r}(),la=function(r){fe(e,r);function e(t,n){n===void 0&&(n=ln.now);var s=r.call(this,t,n)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(t){var n=this.actions;if(this._active){n.push(t);return}var s;this._active=!0;do if(s=t.execute(t.state,t.delay))break;while(t=n.shift());if(this._active=!1,s){for(;t=n.shift();)t.unsubscribe();throw s}},e}(ln),da=new la(ua),fa=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function ha(r){return N(r==null?void 0:r.then)}function pa(r){return N(r[Gt])}function ma(r){return Symbol.asyncIterator&&N(r==null?void 0:r[Symbol.asyncIterator])}function ya(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ga(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var _a=ga();function va(r){return N(r==null?void 0:r[_a])}function ba(r){return Ho(this,arguments,function(){var t,n,s,i;return Jr(this,function(o){switch(o.label){case 0:t=r.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,Pe(t.read())];case 3:return n=o.sent(),s=n.value,i=n.done,i?[4,Pe(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,Pe(s)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function wa(r){return N(r==null?void 0:r.getReader)}function ka(r){if(r instanceof se)return r;if(r!=null){if(pa(r))return Ea(r);if(fa(r))return Sa(r);if(ha(r))return Ca(r);if(ma(r))return dn(r);if(va(r))return xa(r);if(wa(r))return Ta(r)}throw ya(r)}function Ea(r){return new se(function(e){var t=r[Gt]();if(N(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Sa(r){return new se(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}function Ca(r){return new se(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,nn)})}function xa(r){return new se(function(e){var t,n;try{for(var s=Re(r),i=s.next();!i.done;i=s.next()){var o=i.value;if(e.next(o),e.closed)return}}catch(c){t={error:c}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}e.complete()})}function dn(r){return new se(function(e){Oa(r,e).catch(function(t){return e.error(t)})})}function Ta(r){return dn(ba(r))}function Oa(r,e){var t,n,s,i;return qo(this,void 0,void 0,function(){var o,c;return Jr(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),t=Yo(r),l.label=1;case 1:return[4,t.next()];case 2:if(n=l.sent(),!!n.done)return[3,4];if(o=n.value,e.next(o),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=l.sent(),s={error:c},[3,11];case 6:return l.trys.push([6,,9,10]),n&&!n.done&&(i=t.return)?[4,i.call(t)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Ra(r,e,t,n,s){n===void 0&&(n=0),s===void 0&&(s=!1);var i=e.schedule(function(){t(),s?r.add(this.schedule(null,n)):this.unsubscribe()},n);if(r.add(i),!s)return i}function Pa(r,e){var t=N(r)?r:function(){return r},n=function(s){return s.error(t())};return new se(n)}var Ia=kt(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function Aa(r,e){return new Promise(function(t,n){var s=!1,i;r.subscribe({next:function(o){i=o,s=!0},error:n,complete:function(){s?t(i):n(new Ia)}})})}function ja(r){return r instanceof Date&&!isNaN(r)}var Na=kt(function(r){return function(t){t===void 0&&(t=null),r(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}});function Ma(r,e){var t=ja(r)?{first:r}:typeof r=="number"?{each:r}:r,n=t.first,s=t.each,i=t.with,o=i===void 0?La:i,c=t.scheduler,l=c===void 0?da:c,u=t.meta,d=u===void 0?null:u;if(n==null&&s==null)throw new TypeError("No timeout provided.");return na(function(g,E){var m,_,C=null,I=0,V=function(F){_=Ra(E,l,function(){try{m.unsubscribe(),ka(o({meta:d,lastValue:C,seen:I})).subscribe(E)}catch(A){E.error(A)}},F)};m=g.subscribe(sa(E,function(F){_==null||_.unsubscribe(),I++,E.next(C=F),s>0&&V(s)},void 0,void 0,function(){_!=null&&_.closed||_==null||_.unsubscribe(),C=null})),!I&&V(n!=null?typeof n=="number"?n:+n-l.now():s)})}function La(r){throw new Na(r)}class xt{constructor(){this.set=e=>{if(this._current.status==="success")throw new Error("LoadedOnce is already in success state");this._current={status:"success",isSuccess:!0,loadedValue:e},this._subject.next(e),this._subject.complete()},this.throw=(e,t)=>{if(this._current.status==="success")throw new Error("LoadedOnce is already in success state");this._current={status:"error",isSuccess:!1,error:e,errMsg:t},this._subject.error(e)},this.getValueIfLoadedElse=e=>this._current.status==="success"?this._current.loadedValue:e,this.subscribe=e=>{if(this._current.status==="success"){e(this._current);return}this._current.status==="error"&&e(this._current);const t=this._subject.subscribe({next:()=>{if(this._current.status!=="success")throw new Error("Invalid state (next): please make sure to update _current before the subject");e(this._current),t.unsubscribe()},error:()=>{if(this._current.status!=="error")throw new Error("Invalid state (error): please make sure to update _current before the subject");e(this._current)}})},this.waitForLoad=e=>{if(this._current.status==="success")return Promise.resolve(this._current.loadedValue);if(this._current.status==="error")return Promise.reject(this._current.error);this._current.status!=="initial"&&io(this._current);const t={first:e.timeoutSec*1e3,with:()=>Pa(()=>new Error(e.timeoutErrMsg))};return Aa(this._subject.pipe(Ma(t)))},this._current={status:"initial",isSuccess:!1},this._subject=new an}get current(){return this._current}}const{log__:Da,err__:$a}=ee("init-flows"),fn=(r,e)=>{const t=new xt;return{publisher:t,initialize:async n=>{try{if(t.current.isSuccess)throw new Error("This flow has already been initialized.");const s=await e(n);Da(`✔ ${r} flow initialized successfully. Result:`,s),t.set(s)}catch(s){$a(`𝙭 ${r} flow initialization failed. Error:`,Je(s),"Details:",s),t.throw(s,Je(s))}}}},Za=async(r,e,t)=>{await Promise.all(Object.values(r).map(n=>n.initialize({context:e,formCallbacks:t})))},Ua=()=>({stripePR:fn("Stripe PR",Oe.stripePR.init),stripeLink:fn("Stripe Link",Oe.stripeLink.init)}),{err__:Fa}=ee("form-callbacks"),W=a.function().optional(),hn=a.object({onFocus:W,onBlur:W,onChange:W,onLoad:W,onLoadError:W,onValidationError:W,onCheckoutStarted:W,onCheckoutSuccess:W,onSetupPaymentMethodSuccess:W,onCheckoutError:W,onPaymentRequestLoad:W}),te=class te{constructor(){this.setCallbacks=e=>{this._callbacks=te.createEmptyCallbacks(),Object.entries(e).forEach(([t,n])=>{const s=ks(t,n??te.NOOP,Fa);this._callbacks[t]=s})},this._callbacks=te.createEmptyCallbacks()}get get(){return{...this._callbacks}}};te.NOOP=()=>{},te.createEmptyCallbacks=()=>{const e={};return Object.keys(hn.keyof().enum).forEach(t=>{e[t]=te.NOOP}),e},te.fromObject=e=>{const t=new te;return t.setCallbacks(hn.parse(e)),t};let Kt=te;class Va{constructor(e,t,n,s){this.handleMessage=i=>{if(!i.source)throw new Error("No source found");if(pn(i.origin)!==pn(this.baseUrl)||typeof i.data=="object"&&i.data.penpal)return;const o=ai(JSON.parse(i.data));if(!this.validateEvent(o))return;const{elementId:l,payload:u}=o,d=u.type;switch(d){case"LAYOUT":this.internalCallbacks.setFormHeight(u.height?`${u.height}px`:"100%");break;case"FOCUS":this.formCallbacks.get.onFocus(l,u.elementType);break;case"BLUR":this.formCallbacks.get.onBlur(l,u.elementType);break;case"CHANGE":this.formCallbacks.get.onChange(l,u.elementType,u.errors);break;case"LOADED":this.eventTargets[l]=i.source,this.internalCallbacks.onCdeLoaded(u);break;case"LOAD_ERROR":this.internalCallbacks.onCdeLoadError(u.message);break;case"VALIDATION_ERROR":this.formCallbacks.get.onValidationError(u.elementType,u.errors,l);break;default:console.warn("[form] Unhandled event type:",d)}},this.validateEvent=i=>i.formId!==this.formId||!i.elementId?(console.log("[OJS] formId",this.formId,i.formId),console.warn("[form] Ignoring unknown event:",i),!1):this.nonces.has(i.nonce)?(console.warn("[form] Ignoring duplicate event:",i),!1):(this.nonces.add(i.nonce),!0),this.eventTargets={},this.nonces=new Set,this.formId=e,this.baseUrl=t,this.formCallbacks=n,this.internalCallbacks=s}}const pn=r=>new URL(r).origin;async function za(r,e){const n=await kr({iframe:r,debug:!1,childOrigin:e}).promise,s=await Ri(n);if(!Pi(n,s))throw new Error("Got invalid CDE connection object");return n}class Ba{constructor(){this.connections=new Map}addConnection(e,t){this.connections.set(e,t)}getConnection(){const e=this.connections.values().next().value;if(!e)throw new Error("Connection not found");return e}getAllConnections(){return this.connections}}const qa=(r,e,t)=>{const{stripePR:n}=r;n.publisher.subscribe(s=>{if(s.isSuccess){const i=s.loadedValue,o=i.isAvailable&&i.availableProviders.applePay,c=i.isAvailable&&i.availableProviders.googlePay,l={apple_pay:{isLoading:!1,isAvailable:o,startFlow:async u=>{o&&mn("apple_pay",i,e,t,u)}},google_pay:{isLoading:!1,isAvailable:c,startFlow:async u=>{c&&mn("google_pay",i,e,t,u)}}};t.get.onPaymentRequestLoad(l)}})},mn=(r,e,t,n,s)=>Oe.stripePR.run({context:t,checkoutPaymentMethod:Kr(t.checkoutPaymentMethods,r),nonCdeFormInputs:Nt(t.formDiv),formCallbacks:n,customParams:{provider:r,overridePaymentRequest:s==null?void 0:s.overridePaymentRequest},initResult:e}),yn="The secure form failed to load properly. Please check your internet connection, or try again later.",{log__:he,err__:Jt}=ee("op-form"),ie=class ie{constructor(e){this.cdeLoadEvent=new xt,this.anyCdeConn=new xt,this.context=new xt,this.initFlows=Ua(),this.startFormInit=async()=>{try{he("Initializing OpenPay form:"),he("├ Waiting for CDE load event...");const t=await this.cdeLoadEvent.waitForLoad({timeoutSec:120,timeoutErrMsg:yn});he("├ CDE load event received"),he("├ Waiting for CDE connection...");const n=await this.anyCdeConn.waitForLoad({timeoutSec:120,timeoutErrMsg:yn});he("├ CDE connection received"),he("├ Creating OJS context, setting up handlers...");const s=ie.buildOjsFlowContext(this.config,t,n,this.getFormDiv());this.context.set(s),qa(this.initFlows,s,this.formCallbacks),he("├ Starting OJS init flows..."),await Za(this.initFlows,s,this.formCallbacks),this.formCallbacks.get.onLoad(t.totalAmountAtoms,t.currency),he("╰ Done initializing OJS flows.")}catch(t){const n=Je(t);Jt("╰ Error initializing OP form:",n),this.formCallbacks.get.onLoadError(n)}},this.setFormHeight=t=>{this.formProperties.height=t,this.registeredElements&&Object.values(this.registeredElements).forEach(n=>{n&&(n.node.style.height=t)})},this.onCdeLoaded=t=>{this.cdeLoadEvent.current.isSuccess||this.cdeLoadEvent.set(t)},this.onCdeLoadError=t=>{this.cdeLoadEvent.current.isSuccess||this.cdeLoadEvent.throw(new Error(t),t)},this.createElement=(t,n={})=>{if(!this.config)throw new Error("OpenPay form not initialized");const s=Es.parse(t),i=document.createElement("iframe"),o=this.buildQueryString(n);i.name=`${s}-element`;const c=new URL(`/app/v1/${i.name}/`,this.config.baseUrl);return c.search=o.toString(),i.src=c.href,i.style.border="none",i.style.width="100%",this.registerIframe(s,i)},this.registerIframe=(t,n)=>{const s={type:t,node:n,mount:i=>{var o;return(o=document.querySelector(i))==null?void 0:o.appendChild(n)}};return this.connectToElement({type:s.type,node:s.node}),this.registeredElements||(this.registeredElements={[Ce.CARD]:void 0,[Ce.CARD_NUMBER]:void 0,[Ce.CARD_EXPIRY]:void 0,[Ce.CARD_CVC]:void 0}),this.registeredElements[t]=s,s},this.buildQueryString=t=>{const n=new URLSearchParams;return n.append("referer",this.referrer),n.append("formId",this.formId),t.styles&&n.append("styles",oi(t.styles)),n.append("secureToken",this.config.checkoutSecureToken),n},this.connectToElement=t=>{za(t.node).then(n=>{this.connectionManager.addConnection(t.type,n),this.anyCdeConn.current.isSuccess||this.anyCdeConn.set(n)}).catch(n=>Jt("[FORM] Error connecting to CDE iframe",n))},this.getFormDiv=()=>document.querySelector(this.formTarget)??document.body,this.submitCard=()=>{const t=this.context.getValueIfLoadedElse(null);if(!t){Jt("Please wait for the form to finish loading before submitting.");return}Oe.commonCC.run({context:t,checkoutPaymentMethod:Kr(t.checkoutPaymentMethods,"credit_card"),nonCdeFormInputs:Nt(t.formDiv),formCallbacks:this.formCallbacks,customParams:{currentCdeConnections:this.connectionManager.getAllConnections()},initResult:void 0})},this.submit=this.submitCard,this.destroy=()=>{for(const t of Object.values(this.registeredElements??{}))t&&t.node.remove();window.removeEventListener("message",this.eventHandler.handleMessage.bind(this.eventHandler))},ie.assignAsSingleton(this),this.ojsVersion="0.1.16",this.ojsReleaseVersion="0.1.16",this.baseUrl=e.baseUrl??"https://cde.getopenpay.com",this.config={...e,baseUrl:this.baseUrl},this.formCallbacks=Kt.fromObject(e),this.registeredElements=null,this.formId=`opjs-form-${window.crypto.randomUUID()}`,this.referrer=window.location.origin,this.formTarget=e.formTarget??"body",this.formProperties={height:"1px"},this.connectionManager=new Ba,this.eventHandler=new Va(this.formId,this.baseUrl,this.formCallbacks,{setFormHeight:this.setFormHeight,onCdeLoaded:this.onCdeLoaded,onCdeLoadError:this.onCdeLoadError}),window.addEventListener("message",this.eventHandler.handleMessage.bind(this.eventHandler)),this.startFormInit()}get checkoutSecureToken(){return this.config.checkoutSecureToken}};ie.ojsFlows=Oe,ie.assignAsSingleton=e=>{if(ie.getInstance())throw new Error("OpenPay instance already exists. Only one instance is allowed.");window.ojs=e},ie.getInstance=()=>window.ojs??null,ie.buildOjsFlowContext=(e,t,n,s)=>({baseUrl:new URL(e.baseUrl??je).origin,formDiv:s,elementsSessionId:t.sessionId,checkoutPaymentMethods:t.checkoutPaymentMethods,anyCdeConnection:n,customInitParams:e.customInitParams??{}});let Xt=ie;pe.FieldName=x,pe.OpenPayForm=Xt,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED