"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[2439,2655,3680],{2439:(e,t,n)=>{n.r(t),n.d(t,{default:()=>d});var r=n(51609),o=n(22926),i=n(82655),s=n(27723);const{PrimaryOutlinedButton:a,Text:c,Space:l,Spin:u}=window?.booktics?.components||{},d=()=>{const{handleSubmit:e,errorMessage:t,disabled:n,loading:d}=(0,i.default)();return(0,r.createElement)("form",{onSubmit:e},(0,r.createElement)(u,{spinning:n},(0,r.createElement)(l,{size:10,direction:"vertical",className:"bkt-w-100"},(0,r.createElement)(o.PaymentElement,null),(0,r.createElement)(a,{htmlType:"submit",text:(0,s.__)("Pay","booktics"),disabled:n,loading:d,size:"middle"}),(0,r.createElement)(c,{type:"danger",text:t}))))}},23680:(e,t,n)=>{n.r(t),n.d(t,{default:()=>j});var r,o=n(51609),i=n(47143),s=n(22926),a="basil",c="https://js.stripe.com",l="".concat(c,"/").concat(a,"/stripe.js"),u=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,p="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",m=function(e){return u.test(e)||d.test(e)},f=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(l).concat(t);var r=document.head||document.body;if(!r)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return r.appendChild(n),n},w=null,h=null,v=null,b=!1,S=function(){return r||(r=(e=null,null!==w?w:(w=new Promise(function(t,n){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(p),window.Stripe)t(window.Stripe);else try{var r=function(){for(var e=document.querySelectorAll('script[src^="'.concat(c,'"]')),t=0;t<e.length;t++){var n=e[t];if(m(n.src))return n}return null}();if(r&&e)console.warn(p);else if(r){if(r&&null!==v&&null!==h){var o;r.removeEventListener("load",v),r.removeEventListener("error",h),null===(o=r.parentNode)||void 0===o||o.removeChild(r),r=f(e)}}else r=f(e);v=function(e,t){return function(){window.Stripe?e(window.Stripe):t(new Error("Stripe.js not available"))}}(t,n),h=function(e){return function(t){e(new Error("Failed to load Stripe.js",{cause:t}))}}(n),r.addEventListener("load",v),r.addEventListener("error",h)}catch(e){return void n(e)}else t(null)})).catch(function(e){return w=null,Promise.reject(e)})).catch(function(e){return r=null,Promise.reject(e)}));var e};Promise.resolve().then(function(){return S()}).catch(function(e){b||console.warn(e)});var g=n(60532),y=n(2439),_=n(27723);const{wrapWithTheme:k,Alert:E}=window?.booktics?.components||{},j=k(()=>{const{bookingResponse:e,settings:t}=(0,i.useSelect)(e=>e(g.H).getFrontendState(),[]),{client_secret:n,payment_intent_id:r,total:c}=e||{};if(!n||!r)return(0,o.createElement)(E,{message:(0,_.__)("Something went wrong. Please try again later.","booktics"),type:"error"});const l=t?.stripe_publishable_key,u=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];b=!0;var r=Date.now();return S().then(function(e){return function(e,t,n){if(null===e)return null;var r=t[0].match(/^pk_test/),o=function(e){return 3===e?"v3":e}(e.version),i=a;r&&o!==i&&console.warn("Stripe.js@".concat(o," was loaded on the page, but @stripe/stripe-js@").concat("7.5.0"," expected Stripe.js@").concat(i,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var s=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"7.5.0",startTime:t})}(s,n),s}(e,t,r)})}(l),d={clientSecret:n};return(0,o.createElement)(s.Elements,{stripe:u,options:d},(0,o.createElement)(y.default,null))})},82655:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c});var r=n(47143),o=n(86087),i=n(22926),s=n(11534),a=n(60532);const c=()=>{const{bookingResponse:e,frontendStepsOrder:t}=(0,r.useSelect)(e=>e(a.H).getFrontendState(),[]),n=(0,i.useStripe)(),c=(0,i.useElements)(),[l,u]=(0,o.useState)(null),[d,p]=(0,o.useState)(!1),{setFrontendState:m}=(0,r.useDispatch)(a.H),f=e?.id;return{handleSubmit:async r=>{try{if(r.preventDefault(),p(!0),null==c)return;const{error:o}=await c.submit();if(o)return void u(o.message);const i=await n.confirmPayment({elements:c,clientSecret:e?.client_secret,confirmParams:{return_url:window.location.href},redirect:"if_required"}),{error:a}=i||{};if(a)u(a?.message);else{const n=e?.order_key;if(f&&n){try{sessionStorage.setItem(`booktics_order_key_${f}`,n)}catch(e){}try{await s.A.orders.makePayment(f,{order_id:parseInt(f,10),payment_method:"stripe"},{order_key:n})}catch(e){console.error("Payment status update failed:",e)}}m({currentStep:t.length-1,invoiceId:f})}}catch(e){console.log(e)}finally{p(!1)}},errorMessage:l,disabled:!n||!c,loading:d}}}}]);