1function ownKeys(t,e){var n,a=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,n)),a}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _callSuper(e,t,n){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,n||[],_getPrototypeOf(e).constructor):t.apply(e,n))}function _possibleConstructorReturn(e,t){if(t&&("object"==_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}function _superPropGet(e,t,n,a){var r=_get(_getPrototypeOf(1&a?e.prototype:e),t,n);return 2&a&&"function"==typeof r?function(e){return r.apply(n,e)}:r}function _get(){return(_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var a=_superPropBase(e,t);if(a)return(a=Object.getOwnPropertyDescriptor(a,t)).get?a.get.call(arguments.length<3?e:n):a.value}).apply(null,arguments)}function _superPropBase(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function _regenerator(){var p,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function a(e,t,n,a){var r,s,i,o,c,l,u,d,_,t=t&&t.prototype instanceof y?t:y,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(r=e,s=n,u=a||[],d=!1,_={p:l=0,n:0,v:p,a:h,f:h.bind(p,4),d:function(e,t){return i=e,o=0,c=p,_.n=t,m}},function(e,t,n){if(1<l)throw TypeError("Generator is already running");for(d&&1===t&&h(t,n),o=t,c=n;(f=o<2?p:c)||!d;){i||(o?o<3?(1<o&&(_.n=-1),h(o,c)):_.n=c:_.v=c);try{if(l=2,i){if(f=i[e=o?e:"next"]){if(!(f=f.call(i,c)))throw TypeError("iterator result is not an object");if(!f.done)return f;c=f.value,o<2&&(o=0)}else 1===o&&(f=i.return)&&f.call(i),o<2&&(c=TypeError("The iterator does not provide a '"+e+"' method"),o=1);i=p}else if((f=(d=_.n<0)?c:r.call(s,_))!==m)break}catch(e){i=p,o=1,c=e}finally{l=1}}return{value:f,done:d}}),!0),t;function h(e,t){for(o=e,c=t,f=0;!d&&l&&!n&&f<u.length;f++){var n,a=u[f],r=_.p,s=a[2];3<e?(n=s===t)&&(c=a[(o=a[4])?5:o=3],a[4]=a[5]=p):a[0]<=r&&((n=e<2&&r<a[1])?(o=0,_.v=t,_.n=a[1]):r<s&&(n=e<3||a[0]>t||s<t)&&(a[4]=e,a[5]=t,_.n=s,o=0))}if(n||1<e)return m;throw d=!0,t}}var m={};function y(){}function r(){}function s(){}var f=Object.getPrototypeOf,e=[][t]?f(f([][t]())):(_regeneratorDefine2(f={},t,function(){return this}),f),i=s.prototype=y.prototype=Object.create(e);function o(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,_regeneratorDefine2(e,n,"GeneratorFunction")),e.prototype=Object.create(i),e}return _regeneratorDefine2(i,"constructor",r.prototype=s),_regeneratorDefine2(s,"constructor",r),_regeneratorDefine2(s,n,r.displayName="GeneratorFunction"),_regeneratorDefine2(i),_regeneratorDefine2(i,n,"Generator"),_regeneratorDefine2(i,t,function(){return this}),_regeneratorDefine2(i,"toString",function(){return"[object Generator]"}),(_regenerator=function(){return{w:a,m:o}})()}function _regeneratorDefine2(e,t,n,a){var s=Object.defineProperty;try{s({},"",{})}catch(e){s=0}(_regeneratorDefine2=function(e,t,n,a){function r(t,n){_regeneratorDefine2(e,t,function(e){return this._invoke(t,n,e)})}t?s?s(e,t,{value:n,enumerable:!a,configurable:!a,writable:!a}):e[t]=n:(r("next",0),r("throw",1),r("return",2))})(e,t,n,a)}function asyncGeneratorStep(e,t,n,a,r,s,i){try{var o=e[s](i),c=o.value}catch(e){return void n(e)}o.done?t(c):Promise.resolve(c).then(a,r)}function _asyncToGenerator(o){return function(){var e=this,i=arguments;return new Promise(function(t,n){var a=o.apply(e,i);function r(e){asyncGeneratorStep(a,t,n,r,s,"next",e)}function s(e){asyncGeneratorStep(a,t,n,r,s,"throw",e)}r(void 0)})}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,_toPropertyKey(a.key),a)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}jQuery(function(o){var s=fkwcs_data.common_style,i=(window.fkwcsIsDomLoaded=!1,o("form.woocommerce-checkout")),c=fkwcs_data.get_home_url,n=fkwcs_data.stripe_localized;function r(e,t){void 0===t&&(t=0),0!==jQuery(e).length&&jQuery("html, body").animate({scrollTop:jQuery(e).offset().top-t},500)}function l(e,t){return null!=n[e]?n[e]:t}var e=(()=>{return _createClass(function e(t,n){_classCallCheck(this,e),this.gateway_id=n,this.error_container=".fkwcs-credit-card-error",this.gateway_container="",this.stripe=t,this.mode="test",this.fragments={},this.setup_ready=!1,this.mountable=!1,this.element_type="",this.gateway_wallet_wrapper_class=".fkwcs_wallet_gateways",this.prepareStripe()},[{key:"prepareStripe",value:function(){this.elements=this.stripe.elements({appearance:this.getAppearance()}),this.setupGateway(),this.wc_events()}},{key:"getAppearance",value:function(){return{}}},{key:"wc_events",value:function(){var n=this,a=o("input[name='wc-".concat(n.gateway_id,"-payment-token']:checked")),e=o("form#add_payment_method"),e=(o("form.checkout").on("checkout_place_order_"+this.gateway_id,this.processingSubmit.bind(this)),0<o("form#order_review").length&&(o("form#order_review").on("submit",this.processOrderReview.bind(this)),i=o("form#order_review")),0<e.length&&(e.on("submit",this.add_payment_method.bind(this)),i=e),o("#createaccount").on("change",function(){o(this).is(":checked")?o("#fkwcs-save-cc-fieldset").show():o("#fkwcs-save-cc-fieldset").hide()}),o(document.body).on("change",'input[name="payment_method"]',function(){var e;n.showError(),n.unsetGateway(o(this).val()),n.gateway_id===o(this).val()&&(e=o(this).val(),n.showPlaceOrder(),setTimeout(function(){n.setGateway(e)},100))}),o(document.body).on("updated_checkout",function(e,t){null!=t&&n.update_fragment_data(t.fragments),n.gateway_id===n.selectedGateway()&&(a.trigger("change"),n.mou
1ntGateway())}),o(document).ready(function(){n.gateway_id===n.selectedGateway()&&n.mountGateway(),n.ready(),n.handleOrderPayPageAndChangePaymentPage(),window.fkwcsIsDomLoaded=!0}),o(window).on("load",function(){window.fkwcsIsDomLoaded||(n.gateway_id===n.selectedGateway()&&n.mountGateway(),n.ready(),n.handleOrderPayPageAndChangePaymentPage())}),o("#payment_method_"+this.gateway_id));0<e.length&&e.is(":checked")&&n.fastRender(),o(window).on("fkwcs_on_hash_change",this.onHashChange.bind(this)),o(document.body).on("change","input[name='wc-".concat(this.gateway_id,"-payment-token']"),function(){"new"!==o(this).val()?n.hideGatewayContainer():n.showGatewayContainer()}),a.trigger("change"),o(document).on("checkout_error",function(){var e=o(".fkwcs_source");0<e.length&&e.remove()}),o(document.body).trigger("wc-credit-card-form-init")}},{key:"handleOrderPayPageAndChangePaymentPage",value:function(){var e,t,n,a,r;"yes"!==fkwcs_data.is_change_payment_page&&"yes"!==fkwcs_data.is_pay_for_order_page||(r=null==(r=window.location.hash.match(/^#?fkwcs-confirm-(pi|si)-([^:]+):(.+):(.+):(.+):(.+)$/))?window.location.hash.match(/^#?fkwcs-confirm-(pi|si)-([^:]+):(.+)$/):r)&&(e=r[1],t=r[2],n=decodeURIComponent(r[3]),a=decodeURIComponent(r[4]),r=decodeURIComponent(r[5]),this.gateway_id===r)&&(o('input[name="payment_method"][value="'+r+'"]').prop("checked",!0).trigger("click"),this.confirmStripePayment(t,n,e,a))}},{key:"ready",value:function(){}},{key:"fastRender",value:function(){}},{key:"setupGateway",value:function(){}},{key:"showPlaceOrder",value:function(){var e;null!=(e=o("#place_order"))&&e.show(),null!=(e=o("#place_order"))&&e.removeClass("fkwcs_hidden"),this.hideGatewayWallets()}},{key:"hidePlaceOrder",value:function(){var e;null!=(e=o("#place_order"))&&e.hide(),null!=(e=o("#place_order"))&&e.addClass("fkwcs_hidden")}},{key:"hideGatewayWallets",value:function(){var e;null!=(e=o(this.gateway_wallet_wrapper_class))&&e.hide()}},{key:"setGateway",value:function(){}},{key:"unsetGateway",value:function(e){e.indexOf("fkwcs_")<0&&this.showPlaceOrder()}},{key:"mountGateway",value:function(){}},{key:"createSource",value:function(){}},{key:"processingSubmit",value:function(e){}},{key:"processOrderReview",value:function(e){}},{key:"add_payment_method",value:function(e){}},{key:"hideGatewayContainer",value:function(){0<o(this.gateway_container).length&&o(this.gateway_container).hide()}},{key:"showGatewayContainer",value:function(){0<o(this.gateway_container).length&&o(this.gateway_container).show()}},{key:"get_fragment_data",value:function(){return this.fragments}},{key:"update_fragment_data",value:function(e){this.fragments=e}},{key:"appendMethodId",value:function(e){var t=o(".fkwcs_source");0<t.length&&t.remove(),i.append("<input type='hidden' name='fkwcs_source' class='fkwcs_source' value='".concat(e,"'>"))}},{key:"getMethodId",value:function(e){return o(".fkwcs_source").val()}},{key:"getAddress",value:function(){var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"billing",n=document.getElementById(t+"_country"),a=document.getElementById(t+"_postcode"),r=document.getElementById(t+"_city"),s=document.getElementById(t+"_state"),i=document.getElementById(t+"_address_1"),t=document.getElementById(t+"_address_2"),o={country:null!==n&&""!==n?n.value:fkwcs_data.country_code,city:null!==r&&""!==r?r.value:void 0,postal_code:null!==a&&""!==a?a.value:void 0,state:null!==s&&""!==s?s.value:void 0,line1:null!==i&&""!==i?i.value:void 0,line2:null!==t&&""!==t?t.value:void 0};for(e in o)null!=o[e]&&""!==o[e]||(o[e]=null);return void 0!==this.prevent_empty_line_address&&!0===this.prevent_empty_line_address&&null===o.line1?[]:o}},{key:"getBillingAddress",value:function(e){var t,n,a;return 0<o("form#order_review").length?fkwcs_data.current_user_billing_for_order:void 0!==_typeof(e)&&"add_payment"===e?{name:fkwcs_data.current_user_billing.name||void 0,email:fkwcs_data.current_user_billing.email||void 0,address:{country:null!==fkwcs_data.current_user_billing.address.country&&""!==fkwcs_data.current_user_billing.address.country?fkwcs_data.current_user_billing.address.country:void 0,city:null!==fkwcs_data.current_user_billing.address.city&&""!==fkwcs_data.current_user_billing.address.city?fkwcs_data.current_user_billing.address.city:void 0,postal_code:null!==fkwcs_data.current_user_billing.address.postal_code&&""!==fkwcs_data.current_user_billing.address.postal_code?fkwcs_data.current_user_billing.address.postal_code:void 0,state:null!==fkwcs_data.current_user_billing.address.state&&""!==fkwcs_data.current_user_billing.address.state?fkwcs_data.current_user_billing.address.state:void 0,line1:null!==fkwcs_data.current_user_billing.address.line1&&""!==fkwcs_data.current_user_billing.address.line1?fkwcs_data.current_user_billing.address.line1:void 0,line2:null!==fkwcs_data.current_user_billing.address.line2&&""!==fkwcs_data.current_user_billing.address.line2?fkwcs_data.current_user_billing.address.line2:void 0}}:(e=document.getElementById("billing_first_name"),t=document.getElementById("billing_last_name"),n=document.getElementById("billing_email"),a=document.getElementById("billing_phone"),{name:(null!==e?e.value:void 0)+" "+(null!==t?t.value:void 0),email:null!==n?n.value:"",phone:null!==a?a.value:"",address:this.getAddress()})}},{key:"getShippingAddress",value:function(){var e,t=o("#ship-to-different-address-checkbox"),n=this.getAddress(),a=document.getElementById("billing_first_name"),r=document.getElementById("billing_last_name");return 0<t.length&&t.is(":checked")&&(n=this.getAddress("shipping"),t=document.getElementById("shipping_first_name"),e=document.getElementById("shipping_last_name"),null!==t)&&null!==e&&(a=t,r=e),{name:(null!==a?a.value:"")+" "+(null!==r?r.value:""),address:n}}},{key:"selectedGateway",value:function(){var e=o('input[name="payment_method"]:checked');return 0<e.length?e.val():""}},{key:"confirmStripePayment",value:function(e,t,n){console.log("Please override in child class")}},{key:"onHashChange",value:function(e,t){var n=t[1],a=t[2],r=decodeURIComponent(t[3]),s=decodeURIComponent(t[4]),i=decodeURIComponent(t[5]),t=decodeURIComponent(t[6]);this.gateway_id===i&&this.confirmStripePayment(a,r,n,s,t)}},{key:"showError",value:function(e){i.removeClass("processing"),this.unblockElement(),e?o(this.error_container).html(e.message):o(this.error_container).html("")}},{key:"showNotice",value:function(e){if("object"===_typeof(e)){if("validation_error"===e.type)return i.removeClass("processing"),r(".fkwcs-stripe-elements-wrapper",100),void this.unblockElement();e=e.message}i.removeClass("processing"),o(".woocommerce-error").remove(),o(".woocommerce-notices-wrapper").eq(0).html('<div class="woocommerce-error fkwcs-errors">'+e+"</div>").show(),this.unblockElement(),r(".woocommerce-notices-wrapper")}},{key:"unblockElement",value:function(){o("form.woocommerce-checkout").unblock(),o("form#order_review").unblock(),o("form#add_payment_method").unblock()}},{key:"getOrderKeyFromUrl",value:function(){return new URLSearchParams(window.location.search).get("key")||""}},{key:"logError",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=o("body"),a=t?this.getOrderKeyFromUrl():"",t={action:"fkwcs_js_errors",_security:fkwcs_data.js_nonce,order_id:t,error:e};a&&(t.order_key=a),o.ajax({type:"POST",url:fkwcs_data.admin_ajax,data:t,beforeSend:function(){n.css("cursor","progress")},success:function(e){if(!1===e.success)return e.message;n.css("cursor","default")},error:function(){n.css("cursor","default")}})}},{key:"createPaymentIntent",value:(e=_asyncToGenerator(_regenerator().m(function e(){var t;return _regenerator().w(function(e){for(;;)switch(e.n){case 0:return(t=new FormData).append("action","fkwcs_create_payment_intent"),t.append("fkwcs_nonce",fkwcs_data.fkwcs_nonce),e.n=1,fetch(fkwcs_data.admin_ajax,{method:"POST",cac
1he:"no-cache",body:t});case 1:return t=e.v,e.a(2,t.json())}},e)})),function(){return e.apply(this,arguments)})},{key:"getAmountCurrency",value:function(){var e=(null==(e=this.fragments)?void 0:e.fkwcs_paylater_data)||(null==(e=fkwcs_data)?void 0:e.fkwcs_paylater_data);return e?{amount:parseFloat(e.amount),currency:e.currency.toUpperCase()}:{amount:0,currency:"USD"}}},{key:"isAvailable",value:function(){return 0<o("#payment_method_".concat(this.gateway_id)).length}}]);var e})(),t=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).mountable=!0,e.error_container=".fkwcs_stripe_".concat(t,"_error"),e.confirmCallBack="",e.current_amount=0,e.message_element=!1,e.element=null,e}return _inherits(n,e),_createClass(n,[{key:"wc_events",value:function(){_superPropGet(n,"wc_events",this,3)([])}},{key:"getAppearance",value:function(){var e=o("li.wc_payment_method label"),t=e.css("font-family"),n=e.css("color"),a=e.css("font-weight"),r="14px";return{variables:{colorText:n,colorTextSecondary:"rgb(28, 198, 255)",fontSizeBase:r,fontSizeSm:r,fontSizeXs:r,fontSize2Xs:r,fontLineHeight:e.css("line-height"),spacingUnit:"10px",fontWeightMedium:a,fontFamily:t}}}},{key:"update_fragment_data",value:function(e){_superPropGet(n,"update_fragment_data",this,3)([e]),this.updateElements(e)}},{key:"updateElements",value:function(e){try{var t,n;e.hasOwnProperty("fkwcs_paylater_data")&&(t=e.fkwcs_paylater_data.amount,n=e.fkwcs_paylater_data.currency,t!==this.current_amount&&null!==this.element&&(this.element.update({currency:n.toUpperCase(),amount:t}),this.current_amount=t),!0===this.message_element)&&(this.unmount(),this.createMessage(t,n),this.mountGateway(!1))}catch(e){console.log(e)}}},{key:"ready",value:function(){try{this.mountGateway()}catch(e){console.log("exception",e)}}},{key:"createMessage",value:function(e,t){this.isSupportedCountries()&&(this.element=this.elements.create("paymentMethodMessaging",{amount:e,currency:t.toUpperCase(),paymentMethodTypes:this.paymentMethodTypes(),countryCode:o("#billing_country").val()}))}},{key:"confirmStripePayment",value:function(e,t,n){var a=this,r=3<arguments.length&&void 0!==arguments[3]&&arguments[3];""!==this.confirmCallBack&&this.stripe.hasOwnProperty(this.confirmCallBack)&&this.gateway_id===this.selectedGateway()&&this.stripe[this.confirmCallBack](e,this.stripePaymentMethodOptions(t)).then(function(e){e.error?(a.logError(e.error,r),a.showError(e.error)):a.successResponse(e,t)}).catch(function(){a.showError("user cancelled")})}},{key:"stripePaymentMethodOptions",value:function(e){return{payment_method:this.paymentMethods(),payment_method_options:this.paymentMethodOptions(),return_url:c+e}}},{key:"paymentMethodTypes",value:function(){return[]}},{key:"paymentMethodOptions",value:function(){return{}}},{key:"paymentMethods",value:function(){return{billing_details:this.getBillingAddress()}}},{key:"unmount",value:function(){var e=o(".".concat(this.gateway_id,"_select"));null!==this.element&&""!==e.html()&&this.element.unmount()}},{key:"setGateway",value:function(){!1!==this.mountable&&this.mountGateway()}},{key:"mountGateway",value:function(){var e,t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];!1!==this.mountable&&null!=this.element&&0!==(e=o(".".concat(this.gateway_id,"_form"))).length&&(e.show(),e=".".concat(this.gateway_id,"_form .").concat(this.gateway_id,"_select"),0===o(e).children().length&&this.element.mount(e),o(e).css({backgroundColor:"#fff"}),!0===t)&&(e=this.getAmountCurrency(),this.element.update({currency:e.currency,amount:e.amount}))}},{key:"successResponse",value:function(e,t){var n=e.error,e=e.paymentIntent;n?(this.showError(n),this.logError(n,order_id),this.showNotice(l(n.code,n.message))):"succeeded"===e.status?window.location=t:e.status}},{key:"isSupportedCountries",value:function(){return!1}},{key:"createIntent",value:function(){var r,s,e;this.processingSubmit()&&(i.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),s=(r=this).getOrderIdFromUrl(),e=r.getOrderKeyFromUrl(),e={action:"fkwcs_create_payment_intent",order_id:s,order_key:e,gateway_id:this.gateway_id,security:fkwcs_data.nonce},o.ajax({url:fkwcs_data.ajax_url,method:"POST",dataType:"json",data:e}).done(function(e){var t,n,a;e.success&&e.data.client_secret&&e.data.payment_id?(t=e.data.payment_id,n=e.data.client_secret,a=e.data.redirect_url,i.append("<input type='hidden' name='payment_intent' class='payment_intent' value='".concat(t,"'>")),i.append("<input type='hidden' name='payment_intent_client_secret' class='payment_intent_client_secret' value='".concat(n,"'>")),i.append("<input type='hidden' name='fkwcs_source' class='fkwcs_source' value='".concat(t,"'>")),r.elements.submit().then(function(){r.stripe.confirmPayment({elements:r.elements,clientSecret:n,confirmParams:{return_url:"".concat(c).concat(a),payment_method_data:{billing_details:r.getBillingAddress()}}}).then(function(e){e.error?(r.showError(e.error),r.showNotice(e.error.message),r.logError(e.error,s),i.unblock()):i.trigger("submit")}).catch(function(e){console.error("Error confirming payment:",e)})}).catch(function(e){console.error("Error submitting elements:",e)})):console.error("Server Error:",e.message||"Error creating payment intent.")}).fail(function(e,t,n){console.error("AJAX Error:",t,n),console.error("Response Text:",e.responseText)}).always(function(){i.unblock()}))}},{key:"getOrderIdFromUrl",value:function(){var e=new URLSearchParams(window.location.search).get("order_id");if(!e){var t=window.location.pathname.split("/"),n=t.indexOf("order-pay");if(-1!==n&&t.length>n+1)return t[n+1]}return e||null}}])})(),a=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs-credit-card-error",e.mountable=!0,e.amount_to_small=!1,e}return _inherits(n,e),_createClass(n,[{key:"setupGateway",value:function(){this.payment_data={},this.element_data={},this.gateway_container=".fkwcs-stripe-elements-form","payment"===fkwcs_data.card_form_type?this.setupUPEGateway():this.isInlineGateway()?this.inLineFields():this.separateFields()}},{key:"isInlineGateway",value:function(){return"yes"===fkwcs_data.inline_cc}},{key:"inLineFields",value:function(){var n=this;this.card=this.elements.create("card",o.extend({style:fkwcs_data.inline_style,hidePostalCode:!0,iconStyle:"solid"},fkwcs_data.card_element_options)),this.card.on("change",function(e){var t=e.brand,e=e.error;n.showError(),e?n.showError(e):t&&(n.isAllowedBrand(t)||"unknown"===t?n.showError():n.showError({message:fkwcs_data.default_cards[t]+" "+fkwcs_data.not_allowed_string}))})}},{key:"separateFields",value:function(){var r=this,e=JSON.stringify(s),e=JSON.parse(e);delete e.base.padding,void 0!==e.base.iconColor&&delete e.base.iconColor,this.cardNumber=this.elements.create("cardNumber",o.extend({style:e},fkwcs_data.card_element_options)),this.cardExpiry=this.elements.create("cardExpiry",{style:e}),this.cardCvc=this.elements.create("cardCvc",{style:e}),this.cardNumber.on("change",function(e){var t=e.brand,e=e.error,n=o("#fkwcs-stripe-elements-wrapper .fkwcs-credit-card-number"),a=o(".fkwcs-stripe-elements-field");r.showError(),e?(n.addClass("haserror"),r.showError(e)):(n.removeClass("haserror"),fkwcs_data.assets_url,"unknown"===t?a.removeClass("fkwcs_brand"):t&&(r.isAllowedBrand(t)?0<n.length&&(fkwcs_data.assets_url,a.addClass("fkwcs_brand")):"unknown"===t?a.removeClass("fkwcs_brand"):o(".fkwcs-credit-card-error").html(fkwcs_data.default_cards[t]+" "+fkwcs_data.not_allowed_string)))}),this.cardExpiry.on("change",function(e){e=e.error;
1e?(o(".fkwcs-credit-expiry").addClass("haserror"),o(".fkwcs-credit-expiry-error").html(e.message)):o(".fkwcs-credit-expiry-error").html("").removeClass("haserror")}),this.cardCvc.on("change",function(e){e=e.error;e?(o(".fkwcs-credit-cvc-error").html(e.message),o(".fkwcs-credit-cvc").addClass("haserror")):o(".fkwcs-credit-cvc-error").html("").removeClass("haserror")})}},{key:"setGateway",value:function(){"payment"===fkwcs_data.card_form_type?null!==this.payment&&this.payment.unmount():this.isInlineGateway()?null!==this.card&&this.card.unmount():null!==this.cardNumber&&(this.cardNumber.unmount(),this.cardExpiry.unmount(),this.cardCvc.unmount()),this.mountGateway()}},{key:"mountGateway",value:function(){"payment"===fkwcs_data.card_form_type?this.mountElements():this.mountCard()}},{key:"mountCard",value:function(){o(".fkwcs-stripe-elements-wrapper").show(),this.isInlineGateway()?o(".fkwcs-stripe-elements-wrapper .fkwcs-credit-card-field").html()||null===this.card||this.card.mount(".fkwcs-stripe-elements-wrapper .fkwcs-credit-card-field"):this.isInlineGateway()||null===this.cardNumber||(this.cardNumber.mount(".fkwcs-stripe-elements-wrapper .fkwcs-credit-card-number"),this.cardExpiry.mount(".fkwcs-stripe-elements-wrapper .fkwcs-credit-expiry"),this.cardCvc.mount(".fkwcs-stripe-elements-wrapper .fkwcs-credit-cvc"))}},{key:"getCardElement",value:function(){return this.isInlineGateway()?this.card:this.cardNumber}},{key:"createSource",value:function(e){var t=this;i.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),"payment"===fkwcs_data.card_form_type?this.createUPESource(e):0<o(".fkwcs-credit-card-error.fkwcs-error-text").length&&""!==o(".fkwcs-credit-card-error.fkwcs-error-text").text()?(r(o(".fkwcs-credit-card-error.fkwcs-error-text"),100),i.unblock()):this.stripe.createPaymentMethod({type:"card",card:this.getCardElement(),billing_details:this.getBillingAddress(e)}).then(function(e){t.handleSourceResponse(e)})}},{key:"handleSourceResponse",value:function(e){e.error?(this.showNotice(e.error),this.logError(e.error)):e.paymentMethod&&(this.appendMethodId(e.paymentMethod.id),o("form#order_review").length&&"yes"===fkwcs_data.is_change_payment_page?this.create_setup_intent(e.paymentMethod.id,o("form#order_review"),e.paymentMethod.type):o("form#add_payment_method").length?this.create_setup_intent(e.paymentMethod.id,o("form#add_payment_method"),e.paymentMethod.type):(0<o("form#order_review").length?o("form#order_review"):o("form.checkout")).trigger("submit"))}},{key:"create_setup_intent",value:function(n,a,r){var e=fkwcs_data,t=e.fkwcs_nonce,e=e.admin_ajax,t={action:"fkwcs_create_setup_intent",fkwcs_nonce:t,fkwcs_source:n,gateway_id:this.selectedGateway()},s=this;o.ajax({type:"POST",dataType:"json",url:e,data:t,beforeSend:function(){o("body").css("cursor","progress")},success:function(e){if("success"!==e.status)return o("body").css("cursor","default"),!1;var e=e.data.client_secret,t={elements:s.elements,clientSecret:e,confirmParams:{return_url:c},redirect:"if_required"},t="link"===r?s.stripe.confirmSetup(t):s.stripe.confirmCardSetup(e,{payment_method:n});s.handleConfirmation(t,a)},error:function(){o("body").css("cursor","default"),alert("Something went wrong!")},complete:function(){o("body").css("cursor","default")}})}},{key:"handleConfirmation",value:(a=_asyncToGenerator(_regenerator().m(function e(t,n){var a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t;case 1:if((a=e.v).error)return n.unblock(),this.showNotice(a.error),e.a(2);e.n=2;break;case 2:n.trigger("submit"),e.n=4;break;case 3:e.p=3,a=e.v,n.unblock(),console.error("Error in handleConfirmation:",a);case 4:return e.a(2)}},e,this,[[0,3]])})),function(e,t){return a.apply(this,arguments)})},{key:"confirmStripePayment",value:function(e,n,a){var r=this,s=3<arguments.length&&void 0!==arguments[3]&&arguments[3];"payment"===fkwcs_data.card_form_type&&"no"===(4<arguments.length&&void 0!==arguments[4]?arguments[4]:"no")?this.confirmStripePaymentEl(e,n,a,s):("si"===a?this.stripe.handleCardSetup(e,{}):this.stripe.confirmCardPayment(e,{})).then(function(e){var t;e.error?(r.showNotice(e.error),0<(t=o(".fkwcs_source")).length&&t.remove(),e.error.hasOwnProperty("type")&&"api_connection_error"===e.error.type||r.logError(e.error,s)):"requires_capture"!==(t=e["si"===a?"setupIntent":"paymentIntent"]).status&&"succeeded"!==t.status||(window.location=n)}).catch(function(e){o.get(n+"&is_ajax")})}},{key:"hasSource",value:function(){var e=o('input[name="wc-fkwcs_stripe-payment-token"]:checked');return 0<e.length&&"new"!==e.val()||0<(e=o(".fkwcs_source")).length?e.val():""}},{key:"processingSubmit",value:function(e){if(""===this.hasSource())return this.createSource("submit"),e.preventDefault(),!1}},{key:"processOrderReview",value:function(e){if(this.gateway_id===this.selectedGateway()&&""===this.hasSource())return this.createSource("order_review"),e.preventDefault(),!1}},{key:"add_payment_method",value:function(e){if(this.gateway_id===this.selectedGateway()&&""===this.hasSource())return this.createSource("add_payment"),e.preventDefault(),!1}},{key:"onEarlyRenewalSubmit",value:function(e){var t=this;return e.preventDefault(),o.ajax({url:o("#early_renewal_modal_submit").attr("href"),method:"get",complete:function(e){e=JSON.parse(e.responseText);e.fkwcs_stripe_sca_required?t.confirmStripePayment(e.intent_secret,e.redirect_url):window.location=e.redirect_url}}),!1}},{key:"isAllowedBrand",value:function(e){return 0!==fkwcs_data.allowed_cards.length&&-1!==o.inArray(e,fkwcs_data.allowed_cards)}},{key:"wc_events",value:function(){_superPropGet(n,"wc_events",this,3)([]),(o("#early_renewal_modal_submit[data-payment-method]").length?o("#early_renewal_modal_submit[data-payment-method=fkwcs_stripe]"):o("#early_renewal_modal_submit")).on("click",this.onEarlyRenewalSubmit.bind(this)),o(document.body).on("change",".woocommerce-SavedPaymentMethods-tokenInput",function(){var e=o(this).attr("name"),t=o(".fkwcs-stripe-elements-wrapper");
1"wc-fkwcs_stripe-payment-token"!==e||"new"===o(this).val()?t.show():t.hide()})}},{key:"setupUPEGateway",value:function(){this.setup_ready=!0;var e=fkwcs_data.fkwcs_payment_data;this.element_data=e.element_data,this.element_options=e.element_options,this.element_options.fields.billingDetails=e.element_options.fields.billingDetails,"object"!==_typeof(this.element_options.fields.billingDetails)&&(this.element_options.fields.billingDetails={},this.element_options.fields.billingDetails.address="never"),this.element_options.fields.billingDetails.name=jQuery("#billing_first_name").length?"never":"auto",this.element_options.fields.billingDetails.email=jQuery("#billing_email").length?"never":"auto",this.element_options.fields.billingDetails.phone=jQuery("#billing_phone").length?"never":"auto","yes"===fkwcs_data.is_add_payment_page?this.element_options.defaultValues={billingDetails:{name:fkwcs_data.current_user_billing.name||void 0,email:fkwcs_data.current_user_billing.email||void 0}}:this.element_options.defaultValues={billingDetails:{name:jQuery("#billing_first_name").val()+" "+jQuery("#billing_last_name").val(),email:jQuery("#billing_email").val(),phone:jQuery("#billing_phone").val()}},this.createStripeElements()}},{key:"createStripeElements",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0];this.elements=this.stripe.elements(this.element_data),this.payment=this.elements.create("payment",this.element_options),this.payment.on("change",function(e){e.value.type}),this.payment.on("ready",function(e){t.amount_to_small=!1}),this.payment.on("loaderror",function(e){"amount_too_small"===e.error.code&&(t.amount_to_small=!0),console.log("Stripe PaymentElement is unable to load ",e.error)}),!1===e&&this.link(this.elements)}},{key:"mountElements",value:function(){try{0===o(".fkwcs-stripe-payment-elements-field.StripeElement .__PrivateStripeElement iframe").length?(this.createStripeElements(),this.payment.mount(".fkwcs-stripe-payment-elements-field")):null===this.payment&&console.log("Payment object is not initialized.")}catch(e){console.log("Error in mountElements():",e)}}},{key:"updatableElementKeys",value:function(){return["mode","currency","amount","setup_future_usage","capture_method","payment_method_types","appearance","on_behalf_of"]}},{key:"update_fragment_data",value:function(e){_superPropGet(n,"update_fragment_data",this,3)([e]),this.updateElements()}},{key:"updateElements",value:function(){if("payment"===fkwcs_data.card_form_type&&0!==Object.keys(this.element_data).length){var e=this.get_fragment_data();if(!e.hasOwnProperty("fkwcs_payment_data"))return!1;this.payment_data=e.fkwcs_payment_data;var t=this.payment_data.element_data;if(JSON.stringify(t)!==JSON.stringify(this.element_data))if(this.element_data=t,!0===this.amount_to_small)this.mountElements();else{var n,a,r=this.updatableElementKeys();for(n in t)r.indexOf(n)<0||((a={})[n]=t[n],this.elements.update(a))}}}},{key:"createUPESource",value:function(e){var t=this;i.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),this.elements.submit().then(function(e){t.stripe.createPaymentMethod({elements:t.elements,params:{billing_details:t.getBillingAddress()}}).then(function(e){e.error?("validation_error"!==e.error.type?t.showError(e.error):t.showError(!1),r("li.payment_method_fkwcs_stripe")):t.handleSourceResponse(e)}).catch(function(e){console.log("error",e)})})}},{key:"confirmStripePaymentEl",value:function(e,n,a){var r=this,s=3<arguments.length&&void 0!==arguments[3]&&arguments[3],e={elements:this.elements,clientSecret:e,confirmParams:{return_url:c+n},redirect:"if_required"};"yes"!==fkwcs_data.is_change_payment_page&&"yes"!==fkwcs_data.is_pay_for_order_page||delete e.elements;("si"===a?this.stripe.confirmSetup(e):this.stripe.confirmPayment(e)).then(function(e){var t;e.error?(r.showNotice(e.error),0<(t=o(".fkwcs_source")).length&&t.remove(),e.error.hasOwnProperty("type")&&"api_connection_error"===e.error.type||(r.logError(e.error,s),r.showError(e.error))):"requires_capture"!==(t=e["si"===a?"setupIntent":"paymentIntent"]).status&&"succeeded"!==t.status&&"processing"!==t.status||(window.location=n)}).then(function(e){e&&(r.showError(e),r.logError(e,s),r.showNotice(l(e.code,e.message)))})}},{key:"link",value:function(e){try{var t,n=this;"yes"===fkwcs_data.link_authentication&&"payment"===fkwcs_data.card_form_type&&(t=this.stripe.linkAutofillModal(e),o(document.body).on("keyup","#billing_email",function(){t.launch({email:o(this).val()})}),t.on("autofill",function(e){var t=null==(t=e.value)?void 0:t.billingAddress,e=null==(e=e.value)?void 0:e.shippingAddress,e=(null===t&&null!==e&&(t=e),null===e&&null!==t&&(e=t),"object"==_typeof(t)&&null!=t&&n.prefillFields(t,"billing"),"object"==_typeof(e)&&null!=t&&n.prefillFields(e,"shipping"),o('[n
1ame="terms"]').prop("checked",!0),null!=(t=o("#wc-fkwcs_stripe-payment-token-new"))&&t.prop("checked",!0).trigger("change"),o("#payment_method_"+n.gateway_id));e.trigger("click"),e.trigger("change"),i.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),setTimeout(function(){i.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),o("#place_order").trigger("click")},1e3)}))}catch(e){console.log(e)}}},{key:"prefillFields",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"billing",n=e.name,a=n.split(" "),r=a[0],a=a.slice(1).join(" "),s=o("#".concat(t,"_last_name")),i=o("#".concat(t,"_first_name")),n=(0===s.length?i.val(n):(i.val(r),s.val(a)),e.address),a=(null!=(i=o("#".concat(t,"_city")))&&i.val(n.city),null!=(r=o("#".concat(t,"_country")))&&r.val(n.country).trigger("change"),null!=(s=o("#".concat(t,"_postcode")))&&s.val(n.postal_code),o("#".concat(t,"_address_1"))),e=o("#".concat(t,"_address_2"));0<e.length?(a.val(n.line1),e.val(n.line2)):a.val(n.line1+" "+n.line2),setTimeout(function(e,t){var a=e.state,r=o("#".concat(t,"_state"));0<r.length&&(0<(e=r.find("option")).length?e.each(function(){var e=o(this).text(),t=o(this).val(),n=(a=a.toLowerCase(),e=e.toLowerCase(),t.toLowerCase());a!=e&&a!=n||r.val(t)}):r.val(a),r.trigger("change"))},2e3,n,t)}}]);var a})(),u=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).selectedP24Bank="",e.error_container=".fkwcs_stripe_p24_error",e}return _inherits(n,e),_createClass(n,[{key:"setupGateway",value:function(){var t=this;this.p24=this.elements.create("p24Bank",{style:s}),this.p24.on("change",function(e){t.selectedP24Bank=e.value,t.showError()})}},{key:"setGateway",value:function(){this.p24.unmount(),this.mountGateway()}},{key:"mountGateway",value:function(){var e=o(".".concat(this.gateway_id,"_form"));0!==e.length&&(e.show(),e=".".concat(this.gateway_id,"_form .").concat(this.gateway_id,"_select"),this.p24.mount(e),o(e).css({backgroundColor:"#fff"}))}},{key:"processingSubmit",value:function(e){if(""===this.selectedP24Bank)return this.showError({message:fkwcs_data.empty_bank_message}),this.showNotice(fkwcs_data.empty_bank_message),!1;this.showError("")}},{key:"confirmStripePayment",value:function(e,t,n){this.gateway_id===this.selectedGateway()&&this.stripe.confirmP24Payment(e,{payment_method:{billing_details:this.getBillingAddress()},return_url:c+t})}}])})(),d=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_sepa_error",e.sepaIBAN=!1,e.paymentMethod="",e.emptySepaIBANMessage=fkwcs_data.empty_sepa_iban_message,e}return _inherits(n,e),_createClass(n,[{key:"setupGateway",value:function(){var t=this,n=this,e=(this.gateway_container=".fkwcs_stripe_sepa_payment_form",Object.keys(fkwcs_data.sepa_options).length?fkwcs_data.sepa_options:{});this.sepa=this.elements.create("iban",e),this.sepa.on("change",function(e){e=e.error;if(t.isSepaSaveCardChosen())return!0;e?(n.sepaIBAN=!1,n.emptySepaIBANMessage=e.message,n.showError(e),n.logError(e)):(t.sepaIBAN=!0,n.showError(""))}),this.setup_ready=!0}},{key:"setGateway",value:function(){this.sepa.unmount(),this.mountGateway()}},{key:"mountGateway",value:function(){if(!1!==this.setup_ready){if(0===o(".payment_method_fkwcs_stripe_sepa").length)return!1;this.sepa.mount(".fkwcs_stripe_sepa_iban_element_field"),o(".fkwcs_stripe_sepa_payment_form .fkwcs_stripe_sepa_iban_element_field").css({backgroundColor:"#fff",borderRadius:"3px"})}}},{key:"isSepaSaveCardChosen",value:function(){return o("#payment_method_fkwcs_stripe_sepa").is(":checked")&&o('input[name="wc-fkwcs_stripe_sepa-payment-token"]').is(":checked")&&"new"!==o('input[name="wc-fkwcs_stripe_sepa-payment-token"]:checked').val()}},{key:"processingSubmit",value:function(e){if(""===this.paymentMethod&&!this.isSepaSaveCardChosen())return!1===this.sepaIBAN?this.showError(this.emptySepaIBANMessage):this.createPaymentMethod(),!1}},{key:"processOrderReview",value:function(e){if(this.gateway_id===this.selectedGateway()&&""===this.paymentMethod&&!this.isSepaSaveCardChosen())return this.createPaymentMethod("order_review"),!1}},{key:"add_payment_method",value:function(e){if(this.gateway_id===this.selectedGateway()){var t=o(".fkwcs_source");if(!(0<t.length))return this.createPaymentMethod("add_payment"),e.preventDefault(),!1}}},{key:"createPaymentMethod",value:function(){var t=this;this.stripe.createPaymentMethod({type:"sepa_debit",sepa_debit:this.sepa,billing_details:this.getBillingAddress(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"submit")}).then(function(e){e.error?(t.logError(e.error),t.showNotice(l(e.error.code,e.error.message))):e.paymentMethod&&(i.find(".fkwcs_payment_method").remove(),t.paymentMethod=e.paymentMethod.id,t.appendMethodId(t.paymentMethod),i.trigger("submit"))})}},{key:"confirmStripePayment",value:function(e,t,n){var a=this,r=3<arguments.length&&void 0!==arguments[3]&&arguments[3],s=4<arguments.length&&void 0!==arguments[4]&&arguments[4];this.gateway_id===this.selectedGateway()&&("si"===n?this.isSepaSaveCardChosen()||r?this.stripe.confirmSepaDebitSetup(e,{}).then(function(e){e.error?(a.logError(e.error,s),a.showNotice(l(e.error.code,e.error.message))):"succeeded"!==e.setupIntent.status&&"processing"!==e.setupIntent.status||(o(".woocommerce-error").remove(),window.location=t)}):this.stripe.confirmSepaDebitSetup(e,{payment_method:{sepa_debit:this.sepa,billing_details:this.getBillingAddress()}}).then(function(e){e.error?(a.logError(e.error),a.showNotice(l(e.error.code,e.error.message))):"succeeded"!==e.setupIntent.status&&"processing"!==e.setupIntent.status||(o(".woocommerce-error").remove(),window.location=t)}):this.isSepaSaveCardChosen()||r?this.stripe.confirmSepaDebitPayment(e,{}).then(function(e){e.error?(a.logError(e.error,s),a.showNotice(l(e.error.code,e.error.message))):"succeeded"!==e.paymentIntent.status&&"processing"!==e.paymentIntent.status||(o(".woocommerce-error").remove(),window.location=t)}):this.stripe.confirmSepaDebitPayment(e,{payment_method:{sepa_debit:this.sepa,billing_details:this.getBillingAddress()}}).then(function(e){e.error?(a.logError(e.error),a.showNotice(l(e.error.code,e.error.message))):"succeeded"!==e.paymentIntent.status&&"processing"!==e.paymentIntent.status||(o(".woocommerce-error").remove(),window.location=t)}))}}])})(),_=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_ideal_error",e}return _inherits(n,t),_createClass(n,[{key:"setupGateway",value:function(){var e;void 0===fkwcs_data.fkwcs_payment_data_ideal||(e=this.getAmountCurrency()).amount<=0||(this.elements=this.stripe.elements({mode:"payment",currency:e.currency.toLowerCase(),amount:e.amount,payment_method_types:["ideal"]}),e=fkwcs_data.fkwcs_payment_data_ideal,this.element_data=e.element_data,this.element_options=e.element_options,this.element_options.fields.billingDetails=e.element_options.fields.billingDetails,"object"!==_typeof(this.element_options.fields.billingDetails)&&
1(this.element_options.fields.billingDetails={},this.element_options.fields.billingDetails.address="never"),this.element_options.fields.billingDetails.name=jQuery("#billing_first_name").length?"never":"auto",this.element_options.fields.billingDetails.email=jQuery("#billing_email").length?"never":"auto",this.element_options.fields.billingDetails.phone=jQuery("#billing_phone").length?"never":"auto",this.element_options.defaultValues={billingDetails:{name:jQuery("#billing_first_name").length?jQuery("#billing_first_name").val()+" "+jQuery("#billing_last_name").val():"",email:jQuery("#billing_email").val(),phone:jQuery("#billing_phone").val()}},this.ideal=this.elements.create("payment",this.element_options))}},{key:"setGateway",value:function(){this.ideal.unmount(),this.mountGateway()}},{key:"mountGateway",value:function(){var e;void 0!==fkwcs_data.fkwcs_payment_data_ideal&&0!==o(".".concat(this.gateway_id,"_form")).length&&(e=".".concat(this.gateway_id,"_form .").concat(this.gateway_id,"_select"),this.ideal.mount(e),o(e).css({backgroundColor:"#fff"}))}},{key:"processingSubmit",value:function(e){return!0}},{key:"hasSource",value:function(){return""}},{key:"processOrderReview",value:function(e){if(this.gateway_id===this.selectedGateway()&&""===this.hasSource())return this.createIntent(),e.preventDefault(),!1}},{key:"confirmStripePayment",value:function(e,t,n){var a=this;this.gateway_id===this.selectedGateway()&&this.elements.submit().then(function(){a.stripe.confirmPayment({elements:a.elements,clientSecret:e,confirmParams:{return_url:"".concat(c).concat(t),payment_method_data:{billing_details:a.getBillingAddress()}}})})}}])})(),h=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_bancontact_error",e.confirmCallBack="confirmBancontactPayment",e}return _inherits(n,t),_createClass(n,[{key:"confirmStripePayment",value:function(e,t,n){var a=this,r=4<arguments.length&&void 0!==arguments[4]&&arguments[4];this.gateway_id===this.selectedGateway()&&this.stripe.confirmBancontactPayment(e,{payment_method:{billing_details:this.getBillingAddress()},return_url:c+t}).then(function(e){e=e.error;e&&(a.showError(e),a.logError(e,r),a.showNotice(l(e.code,e.message)))})}}])})(),p=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_affirm_error",e.confirmCallBack="confirmAffirmPayment",e.mountable=!0,e.message_element=!0,e.prevent_empty_line_address=!0,e}return _inherits(n,t),_createClass(n,[{key:"setupGateway",value:function(){this.setup_ready=!0;var e=this.getAmountCurrency();this.createMessage(e.amount,e.currency)}},{key:"paymentMethodTypes",value:function(){return["affirm"]}},{key:"isSupportedCountries",value:function(){var e=o("#billing_country").val();return-1<["US","CA"].indexOf(e)}}])})(),m=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_klarna_error",e.confirmCallBack="confirmKlarnaPayment",e.mountable=!0,e.message_element=!0,e}return _inherits(n,t),_createClass(n,[{key:"setupGateway",value:function(){this.setup_ready=!0;var e=this.getAmountCurrency();this.createMessage(e.amount,e.currency)}},{key:"paymentMethodTypes",value:function(){return["klarna"]}},{key:"isSupportedCountries",value:function(){var e=o("#billing_country").val();return-1<["AU","CA","US","DK","NO","SE","GB","PL","CH","NZ","AT","BE","DE","ES","FI","FR","GR","IE","IT","NL","PT"].indexOf(e)}}])})(),y=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_afterpay_error",e.confirmCallBack="confirmAfterpayClearpayPayment",e.mountable=!0,e.message_element=!0,e.prevent_empty_line_address=!0,e}return _inherits(n,t),_createClass(n,[{key:"setupGateway",value:function(){this.setup_ready=!0;var e=this.getAmountCurrency();this.createMessage(e.amount,e.currency)}},{key:"paymentMethodTypes",value:function(){return["afterpay_clearpay"]}},{key:"isSupportedCountries",value:function(){var e=o("#billing_country").val();return-1<["US"].indexOf(e)}},{key:"stripePaymentMethodOptions",value:function(e){return{payment_method:this.paymentMethods(),payment_method_options:this.paymentMethodOptions(),return_url:c+e}}}])})(),f=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_mobilepay_error",e.confirmCallBack="confirmMobilepayPayment",e.mountable=!0,e}return _inherits(n,t),_createClass(n,[{key:"setupGateway",value:function(){this.setup_ready=!0;var e=this.getAmountCurrency();this.createMessage(e.amount,e.currency)}},{key:"paymentMethodTypes",value:function(){return["mobilepay"]}},{key:"stripePaymentMethodOptions",value:function(e){return{payment_method:this.paymentMethods(),payment_method_options:this.paymentMethodOptions(),return_url:c+e}}}])})(),N=(()=>{function n(e,t){_classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_apple_pay_error",e.mountable=!0,e.gateway_class="li.payment_method_fkwcs_stripe_apple_pay",e.apple_place_btn_wrapper=".fkwcs_apple_pay_gateway_wrap",e.apple_pay_btn="",e.payment_request_options=null,e.shipping_options=[],e.request_data={},e.express_btn_click=!1;var a=e;return o(document.body).on("fkwcs_smart_buttons_showed",function(e,t,n){n.applePay&&
10<o("li.payment_method_fkwcs_stripe_apple_pay").length&&(o("li.payment_method_fkwcs_stripe_apple_pay").show(),a.mountGateway())}),e}return _inherits(n,e),_createClass(n,[{key:"setGateway",value:function(){this.hidePlaceOrder()}},{key:"mountGateway",value:function(){this.hidePlaceOrder(),this.showButton()}},{key:"showButton",value:function(){this.PrepareButton()}},{key:"PrepareButton",value:function(){var e=o(this.apple_place_btn_wrapper);e.hide(),this.apple_pay_btn=e,this.apple_pay_btn.addClass("fkwcs-apple-button-container"),o("#place_order").after(this.apple_pay_btn),this.gateway_id===this.selectedGateway()&&(this.hideGatewayWallets(),e.show())}},{key:"hidePlaceOrder",value:function(){var e;this.gateway_id===this.selectedGateway()&&(this.hideGatewayWallets(),null!=(e=o(".fkwcs-apple-button-container"))&&e.show(),null!=(e=o("#place_order"))&&e.hide(),null!=(e=o("#place_order")))&&e.addClass("fkwcs_hidden")}},{key:"showPlaceOrder",value:function(){this.hideGatewayWallets()}}])})(),T=(()=>{function n(e,t){return _classCallCheck(this,n),e=_callSuper(this,n,[e,t]),fkwcs_data.hasOwnProperty("google_pay")?(e.error_container=".fkwcs_stripe_google_pay_error",e.mountable=!0,e.gateway_class="li.payment_method_fkwcs_stripe_google_pay",e.gpay_button_html="",e.google_pay_client=null,e.payment_request_options=null,e.shipping_options=[],e.request_data={},e.google_is_ready=null,e.express_gpay_available=!1,e.express_btn_click=!1,e.createPaymentClient(),o(document.body).on("fkwcs_smart_buttons_showed",e.checkexpressSmartButtonAvailable.bind(e)),o(document.body).on("fkwcs_smart_buttons_not_available",e.hideGatewayForExpressButtons.bind(e)),e):_possibleConstructorReturn(e)}return _inherits(n,e),_createClass(n,[{key:"isModeLiveMerchantIDNotAvailable",value:function(){return"live"==fkwcs_data.mode&&""==fkwcs_data.google_pay.merchant_id}},{key:"checkexpressSmartButtonAvailable",value:function(e,t,n){this.express_gpay_available=n.googlePay,!1===this.express_gpay_available&&this.isModeLiveMerchantIDNotAvailable()&&o(this.gateway_class).hide()}},{key:"hideGatewayForExpressButtons",value:function(){var e;this.isModeLiveMerchantIDNotAvailable()&&(o(this.gateway_class).hide(),null!=(e=o('input[name="payment_method"]')))&&e.eq(0).trigger("click")}},{key:"createPaymentClient",value:function(){var e=this;if("live"!=fkwcs_data.mode||""!=fkwcs_data.google_pay.merchant_id)try{this.google_pay_client=new google.payments.api.PaymentsClient(this.getMerchantData());var t=this.googlePayVersion();t.allowedPaymentMethods=[this.getBaseCardBrand()],this.google_pay_client.isReadyToPay(t).then(function(){e.google_is_ready=!0,o(document.body).trigger("fkwcs_google_ready_pay",[e.google_pay_client]),e.createCheckoutExpressBtn(),o(e.gateway_class).show()}).catch(function(e){console.log("error",e)})}catch(e){console.log(e)}}},{key:"googlePayVersion",value:function(){return{apiVersion:2,apiVersionMinor:0}}},{key:"getBaseCardBrand",value:function(){return{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],assuranceDetailsRequired:!0},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":"2018-10-31","stripe:publishableKey":fkwcs_data.pub_key}}}}},{key:"getMerchantData",value:function(){var e={environment:"test"===fkwcs_data.mode?"TEST":"PRODUCTION",merchantId:fkwcs_data.google_pay.merchant_id,merchantName:fkwcs_data.google_pay.merchant_name,locale:fkwcs_data.locale,paymentDataCallbacks:{onPaymentAuthorized:function(){return new Promise(function(e){e({transactionState:"SUCCESS"})}.bind(this))}}};return"test"===fkwcs_data.mode&&delete e.merchantId,this.shippingAddressRequired()&&(e.paymentDataCallbacks.onPaymentDataChanged=this.paymentDataChanged.bind(this)),e}},{key:"setGateway",value:function(){this.hidePlaceOrder(),this.showGpayButton()}},{key:"mountGateway",value:function(){this.hidePlaceOrder(),this.showGpayButton()}},{key:"update_fragment_data",value:function(e){_superPropGet(n,"update_fragment_data",this,3)([e]),this.update_transaction_data(null==e?void 0:e.fkwcs_google_pay_data),this.google_is_ready&&null!=(e=o(this.gateway_class))&&e.show()}},{key:"billingAddressRequired",value:function(){return!(0<o("form.checkout").length&&!this.field_required("billing_phone")&&!this.field_required("billing_email"))}},{key:"showGpayButton",value:function(){!0===this.google_is_ready?(this.createGpayButton(),o(this.gateway_class).show()):this.isModeLiveMerchantIDNotAvailable()?this.appendGpayBrowserBased():this.showPlaceOrder()}},{key:"paymentDataChanged",value:function(n){var a=this;return new Promise(function(t){if(a.isCheckoutPage()){var e=a.get_shipping_prefix();if(a.is_valid_address(a.get_address_object(e),e,["email","phone"]))return void t({newTransactionInfo:{totalPrice:a.get_total_price().toString(),totalPriceStatus:"ESTIMATED",displayItems:a.get_display_items()}})}
1a.update_payment_data(n).then(function(e){"fail"===e.result?t({error:{reason:"SHIPPING_ADDRESS_UNSUPPORTED",message:fkwcs_data.shipping_error||"Shipping address not supported",intent:"SHIPPING_ADDRESS"}}):(t(e.paymentRequestUpdate),a.set_selected_shipping_methods(e.shipping_methods),a.payment_data_updated(e,n.shippingAddress),o("body").trigger("update_checkout",{update_shipping_method:!1}))}).catch(function(e){t({error:{reason:"SHIPPING_ADDRESS_UNSUPPORTED",message:fkwcs_data.shipping_error||"Unable to process shipping address",intent:"SHIPPING_ADDRESS"}})})})}},{key:"map_google_pay_address",value:function(e){return{country:e.countryCode,postcode:e.postalCode,city:e.locality,state:e.administrativeArea}}},{key:"update_payment_data",value:function(t,r){var s=this;return new Promise(function(n,a){var e=t.shippingOptionData&&"default"===t.shippingOptionData.id?null:null==(e=t.shippingOptionData)?void 0:e.id;o.ajax({url:fkwcs_data.wc_endpoints.fkwcs_gpay_update_shipping_address,dataType:"json",method:"POST",data:o.extend({fkwcs_nonce:fkwcs_data.fkwcs_nonce},{shipping_address:s.map_google_pay_address(t.shippingAddress),shipping_method:[e]},r),success:function(e){var t;("fail"===e.result?(t=e.data&&e.data.message?e.data.message:"Shipping address is invalid or no shipping methods are available. Please update your address and try again.",s.showError({message:t}),a):n)(e)},error:function(e,t,n){console.error("Error in shipping address update:",t,n);s.showError({message:"There was an error processing the shipping address. Please try again later."}),a(n)}})})}},{key:"createGooglePayButton",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";return e.buttonSizeMode="fill",t+=" fkwcs_google_button_theme_"+fkwcs_data.google_pay_btn_color,"yes"!==fkwcs_data.is_change_payment_page&&"yes"!==fkwcs_data.is_pay_for_order_page||this.update_transaction_data(fkwcs_data.gpay_cart_data),o("<div class='fkwcs_google_pay_wrapper fkwcs_smart_product_button ".concat(t,"'></div>")).html(this.google_pay_client.createButton(e))}},{key:"createGpayButton",value:function(){this.gpay_button_html&&this.gpay_button_html.remove(),"yes"===fkwcs_data.google_pay_as_regular&&(this.gpay_button_html=this.createGooglePayButton(this.getGatewayOptions(),"fkwcs-gpay-button-container fkwcs_wallet_gateways"),o("#place_order").after(this.gpay_button_html))}},{key:"appendGpayBrowserBased",value:function(){var t=this;!1===this.express_gpay_available&&o(this.gateway_class).hide(),0<o(".woocommerce-checkout-payment").find(".fkwcs_wallet_gateways_gpay").length?o(".fkwcs_wallet_gateways_gpay").show():setTimeout(function(){o(".fkwcs_wallet_gateways_gpay").remove();var e=o("#place_order");0<o("#fkwcs_custom_express_button .fkwcs_express_google_pay").length&&(e.after(o("#fkwcs_custom_express_button").clone().addClass("fkwcs_wallet_gateways fkwcs_wallet_gateways_gpay")),o(".fkwcs_wallet_gateways_gpay").show(),o(t.gateway_class).show())},300)}},{key:"createCheckoutExpressBtn",value:function(){var e;"yes"===fkwcs_data.google_pay_as_express&&"yes"===fkwcs_data.is_checkout&&(0<(e=o("#wfacp_smart_button_fkwcs_google_pay")).length?(e.html(this.createGooglePayButton(this.getExpressOptions(),"fkwcs-express-wfacp")),this.hidePaymentRequestBtn(),e.show()):0<(e=jQuery(".fkwcs_custom_express_button").eq(0)).length&&(e.after(this.createGooglePayButton(this.getExpressOptions(),"fkwcs-express-native")),this.hidePaymentRequestBtn()))}},{key:"hidePaymentRequestBtn",value:function(){var e=o(".fkwcs_express_payment_request_api"),t=o(".fkwcs_express_apple_pay"),n=o(".fkwcs_express_google_pay");0<t.length||(0<e.length||0<n.length)&&(null!=n&&n.hide(),null!=e)&&e.hide()}},{key:"getExpressOptions",value:function(){return{buttonColor:fkwcs_data.google_pay_btn_color,buttonType:fkwcs_data.google_pay_btn_theme,onClick:this.startExpressGpayPayment.bind(this),buttonLocale:fkwcs_data.locale}}},{key:"getGatewayOptions",value:function(){return{buttonColor:fkwcs_data.google_pay_btn_color,buttonType:fkwcs_data.google_pay_btn_theme,onClick:this.startGpayPayment.bind(this),buttonLocale:fkwcs_data.locale}}},{key:"startExpressGpayPayment",value:function(){this.express_btn_click=!0,this.startGpayPayment()}},{key:"startGpayPayment",value:function(){var t=this;this.google_pay_client.loadPaymentData(this.buildGpayPaymentData()).then(this.processGpayData.bind(this)).catch(function(e){"CANCELED"!==e.statusCode&&(e.statusMessage&&-1<e.statusMessage.indexOf("paymentDataRequest.callbackIntent")?t.showError({message:"DEVELOPER_ERROR_WHITELIST"}):t.showError({message:e.statusMessage}))})}},{key:"processGpayData",value:function(e){var t=this,n=JSON.parse(e.paymentMethodData.tokenizationData.token);this.updateAddress(e),this.stripe.createPaymentMethod({type:"card",card:{token:n.id},billing_details:this.getBillingAddress()}).then(function(e){if(e.error)return t.showError(e.error);t.appendMethodId(e.paymentMethod.id)})}},{key:"shippingAddressRequired",value:function(){if("yes"!==fkwcs_data.shipping_required)return!1;if("yes"===fkwcs_data.is_change_payment_page||"yes"===fkwcs_data.is_pay_for_order_page)return"yes"===fkwcs_data.gpay_cart_data.shipping_required;if(this.isCheckoutPage())for(var e="billing",t=(o("#ship-to-different-address-checkbox").is(":checked")&&(e="shipping"),["address_1","city","postcode","state","country"]),n=0;n<t.length;n++){var a=t[n];if(this.field_required("".concat(e,"_").concat(a)))return!0}return!0}},{key:"isCheckoutPage",value:function(){return 0<o("form.checkout").length}},{key:"get_shipping_prefix",value:function(){var e="billing";return e=o("#ship-to-different-address-checkbox").is(":checked")?"shipping":e}},{key:"get_address_object",value:function(e){for(var t={},n=["address_1","city","postcode","state","country"],a=0;a<n.length;a++){var r=n[a],s=o("#".concat(e,"_").concat(r));s.length&&(t[r]=s.val())}return t}},{key:"is_valid_address",value:function(e,t,n){for(var a=["address_1","city","postcode","state","country"],r=0;r<a.length;r++){var s=a[r];if((!n||-1===n.indexOf(s))&&(!e[s]||""===e[s].trim()))return!1}return!0}},{key:"set_selected_shipping_methods",value:function(e){e&&0<e.length&&o("body").trigger("update_checkout",{update_shipping_method:!0})}},{key:"payment_data_updated",value:function(e,t){t&&this.populate_shipping_fields(t),o("body").trigger("fkwcs_google_pay_shipping_updated",e)}},{key:"populate_shipping_fields",value:function(e){var t,n={locality:"shipping_city",postalCode:"shipping_postcode",administrativeArea:"shipping_state",countryCode:"shipping_country"};for(t in n){var a=o("#".concat(n[t]));a.length&&e[t]&&a.val(e[t]).trigger("change")}}},{key:"get_total_price",value:function(){var e=o(".woocommerce-Price-amount.amount bdi");
1if(e.length){e=e.text().match(/[\d,]+\.?\d*/);if(e)return parseFloat(e[0].replace(/,/g,""))}return 0}},{key:"get_display_items",value:function(){var e=[],t=o(".cart-subtotal .woocommerce-Price-amount.amount"),t=(t.length&&(t=t.text().match(/[\d,]+\.?\d*/))&&e.push({label:"Subtotal",price:t[0].replace(/,/g,""),type:"TOTAL"}),o(".shipping .woocommerce-Price-amount.amount"));return t.length&&(t=t.text().match(/[\d,]+\.?\d*/))&&e.push({label:"Shipping",price:t[0].replace(/,/g,""),type:"TOTAL"}),e}},{key:"buildGpayPaymentData",value:function(){var e=o.extend({},this.googlePayVersion(),{emailRequired:this.field_required("billing_email")||!this.isCheckoutPage(),environment:"test"===fkwcs_data.mode?"TEST":"PRODUCTION",merchantInfo:{merchantName:fkwcs_data.google_pay.merchant_name,merchantId:fkwcs_data.google_pay.merchant_id},allowedPaymentMethods:[this.getBaseCardBrand()]});return e.shippingAddressRequired=this.shippingAddressRequired(),e.callbackIntents=["PAYMENT_AUTHORIZATION"],e.allowedPaymentMethods[0].parameters.billingAddressRequired=this.billingAddressRequired(),e.allowedPaymentMethods[0].parameters.billingAddressRequired&&(e.allowedPaymentMethods[0].parameters.billingAddressParameters={format:"FULL",phoneNumberRequired:this.field_required("billing_phone")||!this.isCheckoutPage()}),(e=o.extend(e,this.request_data)).shippingAddressRequired&&(e.shippingAddressParameters={},e.shippingOptionRequired=!0,e.shippingOptionParameters={shippingOptions:this.shipping_options},e.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"]),e}},{key:"update_transaction_data",value:function(e){var t=e.order_data.displayItems;this.request_data={transactionInfo:{countryCode:e.order_data.country_code.toUpperCase(),currencyCode:e.order_data.currency.toUpperCase(),totalPriceStatus:"ESTIMATED",totalPrice:e.order_data.total.amount.toString(),displayItems:t,totalPriceLabel:e.order_data.total.label}},null!=e&&e.shipping_options&&(this.shipping_options=null==e?void 0:e.shipping_options)}},{key:"field_required",value:function(e){var t;return 0<o("form.checkout").length&&0<(null==(t=o("#".concat(e,"_field")))?void 0:t.length)&&o("#".concat(e,"_field")).hasClass("val
1idate-required")&&""==o("#".concat(e)).val()}},{key:"hidePlaceOrder",value:function(){var e;null!=(e=o(".fkwcs-gpay-button-container"))&&e.show(),null!=(e=o("#place_order"))&&e.hide(),null!=(e=o("#place_order"))&&e.addClass("fkwcs_hidden")}},{key:"showPlaceOrder",value:function(){this.hideGatewayWallets()}},{key:"appendMethodId",value:function(e){_superPropGet(n,"appendMethodId",this,3)([e]),this.express_btn_click&&null!=(e=o("#terms"))&&e.prop("checked",!0),null!=(e=o("#payment_method_fkwcs_stripe_google_pay"))&&e.trigger("click"),(0<o("form#order_review").length?o("form#order_review"):o("form.checkout")).trigger("submit")}},{key:"mapAddress",value:function(e,t){var n,a,r={};return t.hasOwnProperty("address1")&&(null!=(a=o("#".concat(e,"_address_1")))&&a.val(null==t?void 0:t.address1),r.line_1=null==t?void 0:t.address1),t.hasOwnProperty("address2")&&(null!=(a=o("#".concat(e,"_address_2")))&&a.val((null==t?void 0:t.address2)+(null==t?void 0:t.address3)),r.line_2=(null==t?void 0:t.address2)+(null==t?void 0:t.address3)),t.hasOwnProperty("locality")&&(null!=(a=o("#".concat(e,"_city")))&&a.val(null==t?void 0:t.locality),r.city=null==t?void 0:t.locality),t.hasOwnProperty("postalCode")&&(null!=(a=o("#".concat(e,"_postcode")))&&a.val(null==t?void 0:t.postalCode),r.postal_code=null==t?void 0:t.postalCode),t.hasOwnProperty("administrativeArea")&&(null!=(a=o("#".concat(e,"_state")))&&a.val(null==t?void 0:t.administrativeArea),r.state=null==t?void 0:t.administrativeArea),t.hasOwnProperty("countryCode")&&(null!=(a=o("#".concat(e,"_country")))&&a.val(null==t?void 0:t.countryCode),r.country=null==t?void 0:t.countryCode),t.hasOwnProperty("name")&&(r.name=t.name,0<o("#".concat(e,"_last_name")).length?(n=(a=t.name.split(" "))[0],a=a.slice(1).join(" "),o("#".concat(e,"_first_name")).val(n),o("#".concat(e,"_last_name")).val(a)):o("#".concat(e,"_first_name")).val(t.name)),r}},{key:"confirmStripePayment",value:function(n,a,r){var s=this,i=3<arguments.length&&void 0!==arguments[3]&&arguments[3];("si"==r?this.stripe.handleCardSetup(n,{payment_method:this.getMethodId()},{handleActions:!1}):this.stripe.confirmCardPayment(n,{payment_method:this.getMethodId()},{handleActions:!1})).then(function(e){var t;e.error?(s.showNotice(e.error),0<(t=o(".fkwcs_source")).length&&t.remove(),e.error.hasOwnProperty("type")&&"api_connection_error"===e.error.type||s.logError(e.error,i)):"requires_action"===(t=e["si"===r?"setupIntent":"paymentIntent"]).status||"requires_source_action"===t.status?("si"==r?s.stripe.handleCardSetup(n):s.stripe.confirmCardPayment(n)).then(function(e){var t;e.error?(s.showNotice(e.error),0<(t=o(".fkwcs_source")).length&&t.remove(),e.error.hasOwnProperty("type")&&"api_connection_error"===e.error.type||s.logError(e.error,i)):window.location=a}):window.location=a}).catch(function(e){o.get(a+"&is_ajax")})}},{key:"updateAddress",value:function(e){var t={},n=e.hasOwnProperty("shippingAddress")?e.shippingAddress:null,a=(null!==n&&(t.shipping=this.mapAddress("shipping",n),t.shipping.shipping_method=null==e?void 0:e.shippingOptionData,o("#ship_to_different_address").prop("checked",!0)),e.hasOwnProperty("paymentMethodData")&&e.paymentMethodData.hasOwnProperty("info")&&e.paymentMethodData.info.hasOwnProperty("billingAddress")?e.paymentMethodData.info.billingAddress:null);return null!==a&&(t.billing=this.mapAddress("billing",a)),null==a&&null!==n&&(t.billing=this.mapAddress("billing",n)),null!==a&&a.hasOwnProperty("phoneNumber")&&(t.phone=null==a?void 0:a.phoneNumber),null!=e&&e.email&&(null!=(n=o("#billing_email"))&&n.val(null==e?void 0:e.email),t.email=null==e?void 0:e.email),null!=e&&e.phone&&(t.phone=null==e?void 0:e.phone,null!=(a=o("#billing_phone"))&&a.val(null==e?void 0:e.phone),null!=(n=o("#shipping_phone")))&&n.val(null==e?void 0:e.phone),t}}])})(),R=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_alipay_error",e.confirmCallBack="confirmAlipayPayment",e}return _inherits(n,t),_createClass(n)})(),g=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_cashapp_error",e.payment_method="",e.setup_intent_processing=!1,e.setup_intent_created=!1,e.element_mounted=!1,e}return _inherits(n,t),_createClass(n,[{key:"isZeroDollarPayment",value:function(){return 0===this.getAmountCurrency().amount}},{key:"isOrderPayPage",value:function(){return"yes"===fkwcs_data.is_pay_for_order_page||window.location.pathname.includes("/order-pay/")||window.location.search.includes("pay_for_order=true")}},{key:"isChangePaymentPage",value:function(){return"yes"===fkwcs_data.is_change_payment_page}},{key:"isCashAppSaveCardChosen",value:function(){return o("#payment_method_fkwcs_stripe_cashapp").is(":checked")&&o('input[name="wc-fkwcs_stripe_cashapp-payment-token"]').is(":checked")&&"new"!==o('input[name="wc-fkwcs_stripe_cashapp-payment-token"]:checked').val()}},{key:"isAddPaymentMethodPage",value:function(){return o("body").hasClass("woocommerce-a
1dd-payment-method")}},{key:"setupGateway",value:function(){var e,t,n=this;void 0!==fkwcs_data.fkwcs_payment_data_cashapp&&(e=this.getAmountCurrency(),t=this.isZeroDollarPayment(),this.isAddPaymentMethodPage()||this.isChangePaymentPage()?this.elements=this.stripe.elements({mode:"setup",currency:e.currency.toLowerCase(),payment_method_types:["cashapp"]}):t?this.elements=this.stripe.elements({mode:"setup",currency:e.currency.toLowerCase(),payment_method_types:["cashapp"],paymentMethodCreation:"manual"}):this.isOrderPayPage()?this.elements=this.stripe.elements({mode:"payment",currency:e.currency.toLowerCase(),amount:e.amount,payment_method_types:["cashapp"],setup_future_usage:"off_session"}):this.elements=this.stripe.elements({mode:"payment",currency:e.currency.toLowerCase(),amount:e.amount,payment_method_types:["cashapp"],paymentMethodCreation:"manual"}),this.element_options={fields:{billingDetails:"never"}},fkwcs_data.fkwcs_payment_data_cashapp&&(t=fkwcs_data.fkwcs_payment_data_cashapp).element_options&&(this.element_options=_objectSpread(_objectSpread({},this.element_options),t.element_options)),this.cashapp=this.elements.create("payment",this.element_options),this.cashapp.on("change",function(e){n.empty=e.empty,n.showError()}),this.setupSavedPaymentMethodListeners())}},{key:"setupSavedPaymentMethodListeners",value:function(){var e=this;o(document).on("change",'input[name="wc-fkwcs_stripe_cashapp-payment-token"]',function(){e.resetSetupIntentState(),e.handlePaymentMethodSelection()}),o(document).on("change",'input[name="payment_method"]',function(){e.selectedGateway()===e.gateway_id&&(e.resetSetupIntentState(),e.handlePaymentMethodSelection())})}},{key:"resetSetupIntentState",value:function(){this.setup_intent_processing=!1,this.setup_intent_created=!1,this.payment_method=""}},{key:"setGateway",value:function(){if(this.element_mounted&&this.cashapp)try{this.cashapp.unmount(),this.element_mounted=!1}catch(e){console.log("Element unmount failed or already unmounted:",e.message)}this.mountGateway()}},{key:"handlePaymentMethodSelection",value:function(){var t=this;setTimeout(function(){if(t.isCashAppSaveCardChosen()){if(o(".fkwcs_stripe_cashapp_select").hide(),t.element_mounted&&t.cashapp)try{t.cashapp.unmount(),t.element_mounted=!1}catch(e){console.log("Element unmount failed:",e.message)}}else{o(".fkwcs_stripe_cashapp_select").show();var e=".".concat(t.gateway_id,"_form .").concat(t.gateway_id,"_select");if(!t.element_mounted&&0<o(e).length)try{t.cashapp.mount(e),t.element_mounted=!0,o(e).css({backgroundColor:"#fff"})}catch(e){console.log("Element mount failed:",e.message),t.element_mounted=!1}}},100)}},{key:"mountGateway",value:function(){var e=o(".".concat(this.gateway_id,"_form"));if(0!==e.length&&(e.show(),!this.isCashAppSaveCardChosen())){var e=".".concat(this.gateway_id,"_form .").concat(this.gateway_id,"_select"),t=o(e),n=0<t.length&&0<t.children().length;if(0<t.length&&!n)try{this.cashapp.mount(e),this.element_mounted=!0,o(e).css({backgroundColor:"#fff"})}catch(e){console.log("Element mount failed:",e.message),this.element_mounted=!1}}}},{key:"add_payment_method",value:function(e){if(this.gateway_id===this.selectedGateway()){var t=o(".fkwcs_source");if(!(0<t.length))return this.setup_intent_processing||this.setup_intent_created?this.setup_intent_created&&this.payment_method&&(this.appendMethodId(this.payment_method),o("#add_payment_method").trigger("submit")):this.create_setup_intent("add_payment"),e.preventDefault(),!1}}},{key:"create_setup_intent",value:function(){var e,t,a,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"add_payment";this.setup_intent_processing||(this.isChangePaymentPage()&&this.isCashAppSaveCardChosen()?this.submitChangePaymentWithToken():this.isZeroDollarPayment()&&this.isCashAppSaveCardChosen()?this.isChangePaymentPage()?this.submitChangePaymentWithToken():(this.isAddPaymentMethodPage()?o("#add_payment_method"):i).trigger("submit"):this.setup_intent_created&&this.payment_method?this.handleExistingPaymentMethod(n):this.element_mounted||this.isCashAppSaveCardChosen()?(this.setup_intent_processing=!0,t=(e=fkwcs_data).fkwcs_nonce,t={action:"fkwcs_create_setup_intent",gateway_id:this.gateway_id,fkwcs_nonce:t},a=this,o.ajax({type:"POST",dataType:"json",url:e.admin_ajax,data:t,beforeSend:function(){o("body").css("cursor","progress")},success:function(e){if(a.setup_intent_processing=!1,"success"!==e.status)return o("body").css("cursor","default"),a.showNotice("Error creating setup intent"),!1;var t=e.data.client_secret;a.elements.submit().then(function(){return a.stripe.confirmSetup({elements:a.elements,clientSecret:t,confirmParams:{return_url:c,payment_method_data:{billing_details:a.getBillingAddress()}},redirect:"if_required"})}).then(function(e){o("body").css("cursor","default"),e.error?(console.log("Setup confirmation error:",e.error),a.showNotice(l(e.error.code,e.error.message))):e.setupIntent&&e.setupIntent.payment_method?(a.payment_method=e.setupIntent.payment_method,a.setup_intent_created=!0,a.handleSuccessfulSetupIntent(n)):a.showNotice("Setup intent completed but no payment method found")}).catch(function(e){console.log("Error in setup process:",e),o("body").css("cursor","default"),a.setup_intent_processing=!1,a.showNotice("An error occurred during setup")})},error:function(e,t,n){console.log("AJAX error:",n),o("body").css("cursor","default"),a.setup_intent_processing=!1,a.showNotice("Communication error occurred")},complete:function(){o("body").css("cursor","default")}})):this.showNotice("Payment element not ready. Please try again."))}},{key:"handleSuccessfulSetupIntent",value:function(e){this.isChangePaymentPage()?this.handleChangePaymentMethodWithNewSource():(this.isAddPaymentMethodPage()||"add_payment"===e?(o("#add_payment_method").find(".fkwcs_payment_method").remove(),this.appendMethodId(this.payment_method),o("#add_payment_method")):(i.find(".fkwcs_payment_method").remove(),this.appendMethodId(this.payment_method),i)).trigger("submit")}},{key:"handleExistingPaymentMethod",value:function(e){this.isChangePaymentPage()?this.handleChangePaymentMethodWithNewSource():(this.isAddPaymentMethodPage()||"add_payment"===e?(this.appendMethodId(this.payment_method),o("#add_payment_method")):(this.appendMethodId(this.payment_method),i.find(".fkwcs_payment_method").remove(),i)).trigger("submit")}},{key:"handleChangePaymentMethodWithNewSource",value:function(){var t=this;if(!this.isProcessingPaymentChange){this.isProcessingPaymentChange=!0;try{for(var e,n,a,r=null,s=0,i=["#order_review"];s<i.length;s++)if((r=o(i[s]).first()).length)break;r&&r.length?(r.find('input[name="fkwcs_source"]').remove(),e='<input type="hidden" name="fkwcs_source" value="'.concat(this.payment_method,'">'),r.append(e),(n=r.find('input[name="payment_method"][value="'+this.gateway_id+'"]')).length&&n.prop("checked",!0),(a=r.find('input[name="wc-fkwcs_stripe_cashapp-payment-token"][value="new"]')).length&&a.prop("checked",!0),setTimeout(function(){var e;null!=(e=r.data("events"))&&e.submit;r[0].submit(),setTimeout(function(){t.isProcessingPaymentChange=!1},1e3)},10)):(console.log("Could not find change payment method form"),this.isProcessingPaymentChange=!1)}catch(e){console.log("Error in handleChangePaymentMethodWithNewSource:",e),this.isProcessingPaymentChange=!1,this.showNotice("An error occurred while changing payment method - please try again")}}}},{key:"submitChangePaymentWithToken",value:function(){var e=o('input[name="wc-fkwcs_stripe_cashapp-payment-token"]:checked').val();
1e&&"new"!==e&&this.submitChangePaymentForm()}},{key:"submitChangePaymentForm",value:function(){for(var e,t=null,n=0,a=["#change_payment_method_form",".woocommerce-MyAccount-content form",'form[action*="change_payment_method"]','form[action*="subscription"]',"form.woocommerce-form"];n<a.length&&!(t=o(a[n]).first()).length;n++);t&&t.length?t.trigger("submit"):(console.log("Could not find change payment method form for existing token"),(e=o("form").first()).length?(console.log("Using fallback form submission"),e.trigger("submit")):this.showNotice("Unable to find payment method form - please refresh and try again"))}},{key:"processingSubmit",value:function(e){return this.isCashAppSaveCardChosen()||this.isOrderPayPage()||this.isZeroDollarPayment()&&this.isCashAppSaveCardChosen()||""!==this.payment_method?(this.showError(""),!0):(this.createPaymentMethod(),!1)}},{key:"createPaymentMethod",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"submit";this.isCashAppSaveCardChosen()||(this.element_mounted?"add_payment_method"===e||this.isAddPaymentMethodPage()?this.elements.submit().then(function(){t.stripe.createPaymentMethod({elements:t.elements,params:{billing_details:t.getBillingAddress(e)}}).then(function(e){e.error?(t.logError(e.error),t.showNotice(l(e.error.code,e.error.message))):e.paymentMethod&&(t.payment_method=e.paymentMethod.id,t.appendMethodId(t.payment_method),o("#add_payment_method").trigger("submit"))})}):this.elements.submit().then(function(){t.stripe.createPaymentMethod({elements:t.elements,params:{billing_details:t.getBillingAddress(e)}}).then(function(e){e.error?(t.logError(e.error),t.showNotice(l(e.error.code,e.error.message))):e.paymentMethod&&(i.find(".fkwcs_payment_method").remove(),t.payment_method=e.paymentMethod.id,t.appendMethodId(t.payment_method),i.trigger("submit"))})}):this.showNotice("Payment element not ready. Please try again."))}},{key:"hasSource",value:function(){var e=o(".fkwcs_source");return 0<e.length?e.val():""}},{key:"processOrderReview",value:function(e){if(this.gateway_id===this.selectedGateway()){if(this.isChangePaymentPage()){if(this.isCashAppSaveCardChosen())return!0;if(""===this.hasSource())return this.setup_intent_processing||this.setup_intent_created?this.setup_intent_created&&this.payment_method&&this.handleChangePaymentMethodWithNewSource():this.create_setup_intent("change_payment"),e.preventDefault(),!1}return this.isCashAppSaveCardChosen()?!0:this.isZeroDollarPayment()?""!==this.hasSource()||(this.create_setup_intent("order_review"),e.preventDefault(),!1):""===this.hasSource()?(this.createIntent(),e.preventDefault(),!1):void 0}}},{key:"confirmStripePayment",value:function(t,n,a){var r=this,e=3<arguments.length&&void 0!==arguments[3]&&arguments[3],s=4<arguments.length&&void 0!==arguments[4]&&arguments[4];this.gateway_id===this.selectedGateway()&&(this.isOrderPayPage()&&!e?this.stripe.confirmPayment({clientSecret:t,confirmParams:{return_url:"".concat(c).concat(n)}}).then(function(e){e.error?(r.logError(e.error,s),r.showError(e.error),r.unblockElement()):e.paymentIntent&&["succeeded","processing"].includes(e.paymentIntent.status)?(o(".woocommerce-error").remove(),window.location=n):e.paymentIntent&&e.paymentIntent.next_action&&(window.location.href=e.paymentIntent.next_action.redirect_to_url.url)}).catch(function(e){r.logError(e,s),r.showError(e),r.unblockElement()}):this.element_mounted||this.isCashAppSaveCardChosen()?this.elements.submit().then(function(){var e={elements:r.elements,clientSecret:t,confirmParams:{return_url:"".concat(c).concat(n),payment_method_data:{billing_details:r.getBillingAddress()}}};"si"===a?r.stripe.confirmSetup(e).then(function(e){r.handleConfirmationResult(e,n,s,"setupIntent")}).catch(function(e){r.handleConfirmationError(e,s)}):r.stripe.confirmPayment(e).then(function(e){r.handleConfirmationResult(e,n,s,"paymentIntent")}).catch(function(e){r.handleConfirmationError(e,s)})}).catch(function(e){r.handleConfirmationError(e,s)}):(this.showNotice("Payment element not ready. Please try again."),this.unblockElement()))}},{key:"handleConfirmationResult",value:function(e,t,n,a){e.error?(this.logError(e.error,n),this.showError(e.error),this.unblockElement()):["succeeded","processing"].includes((e=e[a]).status)?(o(".woocommerce-error").remove(),window.location=t):e.next_action&&e.next_action.redirect_to_url?window.location.href=e.next_action.redirect_to_url.url:(console.log("Unexpected intent status:",e.status),this.logError({message:"Unexpected intent status: ".concat(e.status)},n),this.unblockElement())}},{key:"handleConfirmationError",value:function(e,t){console.log("Cash App Pay confirmation error:",e),this.logError(e,t),this.showError(e),this.unblockElement()}}])})(),w=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_multibanco_error",e}return _inherits(n,t),_createClass(n,[{key:"setupGateway",value:function(){var e;void 0===fkwcs_data.fkwcs_payment_data_multibanco||(e=this.getAmountCurrency()).amount<=0||(this.elements=this.stripe.elements({mode:"payment",currency:e.currency.toLowerCase(),amount:e.amount,payment_method_types:["multibanco"]}),this.element_options={fields:{billingDetails:{address:"never",n
1ame:jQuery("#billing_first_name").length?"never":"auto",email:jQuery("#billing_email").length?"never":"auto",phone:jQuery("#billing_phone").length?"never":"auto"}},defaultValues:{billingDetails:{name:jQuery("#billing_first_name").length?jQuery("#billing_first_name").val()+" "+jQuery("#billing_last_name").val():"",email:jQuery("#billing_email").val(),phone:jQuery("#billing_phone").val()}}},fkwcs_data.fkwcs_payment_data_multibanco&&(e=fkwcs_data.fkwcs_payment_data_multibanco).element_options&&(this.element_options=_objectSpread(_objectSpread({},this.element_options),e.element_options)),this.multibanco=this.elements.create("payment",this.element_options))}},{key:"setGateway",value:function(){this.multibanco.unmount(),this.mountGateway()}},{key:"mountGateway",value:function(){var e=o(".".concat(this.gateway_id,"_form"));0!==e.length&&(e.show(),e=".".concat(this.gateway_id,"_form .").concat(this.gateway_id,"_select"),this.multibanco.mount(e),o(e).css({backgroundColor:"#fff"}))}},{key:"processingSubmit",value:function(e){return this.showError(""),!0}},{key:"hasSource",value:function(){return""}},{key:"processOrderReview",value:function(e){if(this.gateway_id===this.selectedGateway()&&""===this.hasSource())return this.createIntent(),e.preventDefault(),!1}},{key:"confirmStripePayment",value:function(e,t,n){var a=this;this.gateway_id===this.selectedGateway()&&this.elements.submit().then(function(){a.stripe.confirmPayment({elements:a.elements,clientSecret:e,confirmParams:{return_url:"".concat(c).concat(t),payment_method_data:{billing_details:a.getBillingAddress()}}})})}}])})(),k=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_pix_error",e}return _inherits(n,t),_createClass(n,[{key:"setupGateway",value:function(){var e;void 0===fkwcs_data.fkwcs_payment_data_pix||(e=this.getAmountCurrency()).amount<=0||(this.elements=this.stripe.elements({mode:"payment",currency:e.currency.toLowerCase(),amount:e.amount,payment_method_types:["pix"]}),this.element_options={fields:{billingDetails:"never"}},fkwcs_data.fkwcs_payment_data_pix&&(e=fkwcs_data.fkwcs_payment_data_pix).element_options&&(this.element_options=_objectSpread(_objectSpread({},this.element_options),e.element_options)),this.pix=this.elements.create("payment",this.element_options))}},{key:"setGateway",value:function(){this.pix.unmount(),this.mountGateway()}},{key:"mountGateway",value:function(){var e=o(".".concat(this.gateway_id,"_form"));0!==e.length&&(e.show(),e=".".concat(this.gateway_id,"_form .").concat(this.gateway_id,"_select"),this.pix.mount(e),o(e).css({backgroundColor:"#fff"}))}},{key:"processingSubmit",value:function(e){return this.showError(""),!0}},{key:"hasSource",value:function(){return""}},{key:"processOrderReview",value:function(e){if(this.gateway_id===this.selectedGateway()&&""===this.hasSource())return this.createIntent(),e.preventDefault(),!1}},{key:"confirmStripePayment",value:function(e,t,n){var a=this,r=4<arguments.length&&void 0!==arguments[4]&&arguments[4];this.gateway_id===this.selectedGateway()&&this.elements.submit().then(function(){a.stripe.confirmPayment({elements:a.elements,clientSecret:e,confirmParams:{return_url:"".concat(c).concat(t),payment_method_data:{billing_details:a.getBillingAddress()}}}).then(function(e){e.error?(a.logError(e.error,r),a.showError(e.error),a.unblockElement()):window.location.href=e.payment_intent.next_action.redirect_to_url.url}).catch(function(e){a.logError(e,r),a.showError(e),a.unblockElement()})})}}])})(),v=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_ach_error",e}return _inherits(n,e),_createClass(n,[{key:"getSavedPaymentMethod",value:function(){var e;return(null==(e=document.querySelector("input[name='wc-fkwcs_stripe_ach-payment-token']:checked"))?void 0:e.value)||!1}},{key:"isZeroDollarPayment",value:function(){return 0===this.getAmountCurrency().amount}},{key:"setupGateway",value:function(){var e,t=this;void 0!==fkwcs_data.fkwcs_ach_payment_data&&(this.element_data=fkwcs_data.fkwcs_ach_payment_data.element_data,e=this.isZeroDollarPayment(),this.elements=e?this.stripe.elements({mode:"setup",currency:this.element_data.currency,payment_method_types:["us_bank_account"],paymentMethodCreation:"manual"}):this.stripe.elements(this.element_data),this.ach=this.elements.create("payment",{fields:{billingDetails:{name:"never",email:"never"}}}),this.ach.on("change",function(e){t.empty=e.empty,t.showError()}))}},{key:"setGateway",value:function(){this.ach.unmount(),this.mountGateway()}},{key:"mountGateway",value:function(){var e=o(".".concat(this.gateway_id,"_form"));0!==e.length&&(e.show(),e=".".concat(this.gateway_id,"_form"),this.ach.mount(e),o(e).css({backgroundColor:"#fff"}))}}
1,{key:"processingSubmit",value:function(e){return this.getSavedPaymentMethod()&&"new"!==this.getSavedPaymentMethod()||!0!==this.empty?(this.showError(""),!0):(this.showError({message:fkwcs_data.empty_bank_message}),this.showNotice(fkwcs_data.empty_bank_message),!1)}},{key:"add_payment_method",value:function(e){if(this.gateway_id===this.selectedGateway()){var t=o(".fkwcs_source");if(!(0<t.length))return this.create_setup_intent("add_payment"),e.preventDefault(),!1}}},{key:"create_setup_intent",value:function(e){var t=fkwcs_data,n=t.fkwcs_nonce,n={action:"fkwcs_create_setup_intent",gateway_id:this.gateway_id,fkwcs_nonce:n},a=this;o.ajax({type:"POST",dataType:"json",url:t.admin_ajax,data:n,beforeSend:function(){o("body").css("cursor","progress")},success:function(e){var t=this;if("success"!==e.status)return o("body").css("cursor","default"),!1;var n=e.data.client_secret;a.elements.submit().then(function(){a.stripe.confirmSetup({elements:a.elements,clientSecret:n,confirmParams:{return_url:c,payment_method_data:{billing_details:a.getBillingAddress()}},redirect:"if_required"}).then(function(e){e.error?a.showNotice(l(e.error.code,e.error.message)):e.setupIntent.payment_method&&(i.find(".fkwcs_payment_method").remove(),t.payment_method=e.setupIntent.payment_method,a.appendMethodId(t.payment_method),i.trigger("submit"))})}).catch(function(e){console.error("Error submitting elements:",e)})},error:function(){o("body").css("cursor","default"),alert("Something went wrong!")},complete:function(){o("body").css("cursor","default")}})}},{key:"hasSource",value:function(){var e=o('input[name="wc-fkwcs_stripe-payment-token"]:checked');return 0<e.length&&"new"!==e.val()||0<(e=o(".fkwcs_source")).length?e.val():""}},{key:"processOrderReview",value:function(e){if(this.gateway_id===this.selectedGateway()){var t=this.hasSource();if(""===t&&(!this.getSavedPaymentMethod()||"new"===this.getSavedPaymentMethod()))return"yes"===fkwcs_data.is_change_payment_page?this.create_setup_intent("add_payment"):this.createIntent(),e.preventDefault(),!1}}},{key:"createIntent",value:function(){var r,e;this.processingSubmit()?(i.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),e={action:"fkwcs_create_payment_intent",order_id:(r=this).getOrderIdFromUrl(),order_key:r.getOrderKeyFromUrl(),gateway_id:this.gateway_id,security:fkwcs_data.nonce},o.ajax({url:fkwcs_data.ajax_url,method:"POST",dataType:"json",data:e}).done(function(e){var t,n,a;e.success&&e.data.client_secret&&e.data.payment_id?(t=e.data.payment_id,n=e.data.client_secret,a=e.data.redirect_url,i.append("<input type='hidden' name='payment_intent' class='payment_intent' value='".concat(t,"'>")),i.append("<input type='hidden' name='payment_intent_client_secret' class='payment_intent_client_secret' value='".concat(n,"'>")),i.append("<input type='hidden' name='fkwcs_source' class='fkwcs_source' value='".concat(t,"'>")),r.elements.submit().then(function(){r.stripe.confirmPayment({elements:r.elements,clientSecret:n,confirmParams:{return_url:"".concat(c).concat(a),payment_method_data:{billing_details:r.getBillingAddress()}}}).then(function(){i.trigger("submit")}).catch(function(e){console.error("Error confirming payment:",e)})}).catch(function(e){console.error("Error submitting elements:",e)})):console.error("Server Error:",e.message||"Error creating payment intent.")}).fail(function(e,t,n){console.error("AJAX Error:",t,n),console.error("Response Text:",e.responseText)}).always(function(){i.unblock()})):setTimeout(function(){var e=document.querySelector(".blockUI.blockOverlay");e&&e.remove()},100)}},{key:"getOrderIdFromUrl",value:function(){var e=new URLSearchParams(window.location.search).get("order_id");if(!e){var t=window.location.pathname.split("/"),n=t.indexOf("order-pay");if(-1!==n&&t.length>n+1)return t[n+1]}return e||null}},{key:"confirmStripePayment",value:function(t,n,a){var r=this;this.gateway_id===this.selectedGateway()&&this.elements.submit().then(function(){var e={clientSecret:t,confirmParams:{return_url:"".concat(c).concat(n),payment_method_data:{billing_details:r.getBillingAddress()}}};r.getSavedPaymentMethod()&&"new"!==r.getSavedPaymentMethod()||(e.elements=r.elements),"si"===a?r.stripe.confirmSetup(e).then(function(e){e.error?console.error("setup confirmation error:",e.error):console.log("setup confirmation success:",e)}):r.stripe.confirmPayment(e).then(function(e){e.error?console.error("Payment c
1onfirmation error:",e.error):console.log("Payment confirmation success:",e)})}).catch(function(e){console.error("Error submitting elements:",e)})}}])})(),b=(()=>{function n(e,t){return _classCallCheck(this,n),(e=_callSuper(this,n,[e,t])).error_container=".fkwcs_stripe_eps_error",e}return _inherits(n,t),_createClass(n,[{key:"setupGateway",value:function(){var e;void 0!==fkwcs_data.fkwcs_payment_data_eps&&(e=this.getAmountCurrency(),this.elements=this.stripe.elements({mode:"payment",currency:e.currency.toLowerCase(),amount:e.amount,payment_method_types:["eps"]}),this.element_options={fields:{billingDetails:{name:jQuery("#billing_first_name").length?"never":"auto"}},defaultValues:{billingDetails:{name:jQuery("#billing_first_name").length?jQuery("#billing_first_name").val()+" "+jQuery("#billing_last_name").val():""}}},fkwcs_data.fkwcs_payment_data_eps&&(e=fkwcs_data.fkwcs_payment_data_eps).element_options&&(this.element_options=_objectSpread(_objectSpread({},this.element_options),e.element_options)),this.eps=this.elements.create("payment",this.element_options))}},{key:"setGateway",value:function(){this.eps.unmount(),this.mountGateway()}},{key:"mountGateway",value:function(){var e=o(".".concat(this.gateway_id,"_form"));0!==e.length&&(e.show(),e=".".concat(this.gateway_id,"_form .").concat(this.gateway_id,"_select"),this.eps.mount(e),o(e).css({backgroundColor:"#fff"}))}},{key:"processingSubmit",value:function(e){return this.showError(""),!0}},{key:"hasSource",value:function(){return""}},{key:"processOrderReview",value:function(e){if(this.gateway_id===this.selectedGateway()&&""===this.hasSource())return this.createIntent(),e.preventDefault(),!1}},{key:"confirmStripePayment",value:function(e,t,n){var a=this;this.gateway_id===this.selectedGateway()&&this.elements.submit().then(function(){a.stripe.confirmPayment({elements:a.elements,clientSecret:e,confirmParams:{return_url:"".concat(c).concat(t),payment_method_data:{billing_details:a.getBillingAddress()}}})})}}])})();var P=fkwcs_data.pub_key;if(""===P||"live"===fkwcs_data.mode&&!fkwcs_data.is_ssl)console.log("Live Payment Mode only work only https protocol ");else{try{var C,S,E,O,A,G,I,M,D,x,j,U,q,F,L,Q,W,K=["link_beta_2"],B=("yes"===fkwcs_data.link_authentication&&"payment"===fkwcs_data.card_form_type&&(K=["link_autofill_modal_beta_1"]),Stripe(P,{locale:fkwcs_data.locale,betas:K}));"yes"===(null==(C=fkwcs_data.enable_gateways)?void 0:C.fkwcs_stripe)&&new a(B,"fkwcs_stripe"),"yes"===(null==(S=fkwcs_data.enable_gateways)?void 0:S.fkwcs_stripe_p24)&&new u(B,"fkwcs_stripe_p24"),"yes"===(null==(E=fkwcs_data.enable_gateways)?void 0:E.fkwcs_stripe_ach)&&new v(B,"fkwcs_stripe_ach"),"yes"===(null==(O=fkwcs_data.enable_gateways)?void 0:O.fkwcs_stripe_sepa)&&new d(B,"fkwcs_stripe_sepa"),"yes"===(null==(A=fkwcs_data.enable_gateways)?void 0:A.fkwcs_stripe_ideal)&&new _(B,"fkwcs_stripe_ideal"),"yes"===(null==(G=fkwcs_data.enable_gateways)?void 0:G.fkwcs_stripe_pix)&&new k(B,"fkwcs_stripe_pix"),"yes"===(null==(I=fkwcs_data.enable_gateways)?void 0:I.fkwcs_stripe_bancontact)&&new h(B,"fkwcs_stripe_bancontact"),"yes"===(null==(M=fkwcs_data.enable_gateways)?void 0:M.fkwcs_stripe_multibanco)&&new w(B,"fkwcs_stripe_multibanco"),"yes"===(null==(D=fkwcs_data.enable_gateways)?void 0:D.fkwcs_stripe_eps)&&new b(B,"fkwcs_stripe_eps"),"yes"===(null==(x=fkwcs_data.enable_gateways)?void 0:x.fkwcs_stripe_affirm)&&new p(B,"fkwcs_stripe_affirm"),"yes"===(null==(j=fkwcs_data.enable_gateways)?void 0:j.fkwcs_stripe_klarna)&&new m(B,"fkwcs_stripe_klarna"),"yes"===(null==(U=fkwcs_data.enable_gateways)?void 0:U.fkwcs_stripe_afterpay)&&new y(B,"fkwcs_stripe_afterpay"),"yes"===(null==(q=fkwcs_data.enable_gateways)?void 0:q.fkwcs_stripe_mobilepay)&&new f(B,"fkwcs_stripe_mobilepay"),"yes"===(null==(F=fkwcs_data.enable_gateways)?void 0:F.fkwcs_stripe_cashapp)&&new g(B,"fkwcs_stripe_cashapp"),"yes"===(null==(L=fkwcs_data.enable_gateways)?void 0:L.fkwcs_stripe_google_pay)&&new T(B,"fkwcs_stripe_google_pay"),"yes"===(null==(Q=fkwcs_data.enable_gateways)?void 0:Q.fkwcs_stripe_apple_pay)&&new N(B,"fkwcs_stripe_apple_pay"),"yes"===(null==(W=fkwcs_data.enable_gateways)?void 0:W.fkwcs_stripe_alipay)&&new R(B,"fkwcs_stripe_alipay"),o(document).trigger("fkwcs_gateway_loaded",{Gateway:e,LocalGateway:t,FKWCS_Stripe:a,FKWCS_P24:u,FKWCS_ach:v,FKWCS_Sepa:d,FKWCS_Ideal:_,FKWCS_BanContact:h,FKWCS_Multibanco:w,FKWCS_EPS:b,FKWCS_AFFIRM:p,FKWCS_KLARNA:m,FKWCS_AFTERPAY:y,FKWCS_MOBILEPAY:f,FKWCS_PIX:k,FKWCS_CASHAPP:g,stripe_object:B})}catch(e){console.log(e)}window.addEventListener("hashchange",function(){var e=window.location.hash.match(/^#?fkwcs-confirm-(pi|si)-([^:]+):(.+):(.+):(.+):(.+)$/);!(e=null==e?window.location.hash.match(/^#?fkwcs-confirm-(pi|si)-([^:]+):(.+)$/):e)||e.length<4||(history.pushState({},"",window.location.pathname),o(window).trigger("fkwcs_on_hash_change",[e]))})}});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.