PageSourceSearch

https://mathai.ai/_next/static/chunks/3507.883e1e53ebfc2c57.js

js mathai.ai collected 2026-10-05 12:17:27 UTC 7,233 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3507],{72141:function(e,n,t){t.d(n,{Z:function(){return a}});var r=t(85893);t(67294);function a(e){e=null!==e?e:function(e){throw e}(new TypeError("Cannot destructure undefined"));return(0,r.jsx)("div",{id:"all-in-one-component-button-loader-wrapper",className:"flex h-full w-full items-center justify-center",children:(0,r.jsx)("div",{className:"loader",id:"all-in-one-component-button-loader-wrapper"})})}},54584:function(e,n,t){t.d(n,{j:function(){return l}});var r=t(47568),a=t(97582),o=t(67294),u=t(9669),i=t.n(u),c=t(70455),s=function(){var e=(0,r.Z)((function(){var e;return(0,a.__generator)(this,(function(n){switch(n.label){case 0:if((0,c.pE)())return[2,{country:"IN",timezone:"Asia/Kolkata"}];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,i().get("/api/country",{timeout:3e3})];case 2:return[2,n.sent().data];case 3:return e=n.sent(),console.error("Error fetching /api/country:",e),[2,{country:"IN",timezone:"Asia/Kolkata"}];case 4:return[2]}}))}));return function(){return e.apply(this,arguments)}}(),l=function(e){var n=e.user,t=e.pricingDetails,u=e.currentCountry,c=e.autoApplyCouponCode,l="IMC_QRP"===(null===t||void 0===t?void 0:t.type),p=(0,o.useState)(""),d=p[0],f=p[1],h=(0,o.useState)(""),g=h[0],y=h[1],b=(0,o.useState)(""),_=b[0],m=b[1],P=(0,o.useState)(null),v=P[0],w=P[1],E=(0,o.useState)(!1),C=E[0],S=E[1],x=(0,o.useRef)(!1),k=(0,o.useState)(!1),M=k[0],A=k[1],z=(0,o.useState)({basePrice:0,discountAmount:0,taxPercentage:0,taxAmount:0,finalPrice:0}),j=z[0],O=z[1],R=(0,o.useState)(""),D=R[0],N=R[1],I=(0,o.useCallback)(function(){var e=(0,r.Z)((function(e){var r,o,c,l;return(0,a.__generator)(this,(function(a){switch(a.label){case 0:if(!n||!n.id)return[2,{success:!1,error:"User information not available"}];if(!(null===t||void 0===t?void 0:t.type))return[2,{success:!1,error:"Pricing information not available"}];a.label=1;case 1:return a.trys.push([1,6,,7]),(r=""!==D)?(c={timezone:D},[3,4]):[3,2];case 2:return[4,s()];case 3:c=a.sent(),a.label=4;case 4:return o=c,!r&&N(o.timezone),[4,i().post("".concat("https://api.eu.mathai.ai/test/ts","/v2/coupon/apply"),{data:{user_id:String(n.id),couponCode:e,plan:null===t||void 0===t?void 0:t.type,region:u,timezone:o.timezone}})];case 5:return[2,a.sent().data];case 6:return l=a.sent(),console.error("Error applying coupon:",l),l.response&&l.response.data?[2,l.response.data]:[2,null];case 7:return[2]}}
1))}));return function(n){return e.apply(this,arguments)}}(),[n,t,u,D]),Z=(0,o.useCallback)((function(e,n,t){if(n&&n.data&&n.data.pricing){var r=n.data.pricing;return{basePrice:r.base_price,discountAmount:r.discount_price,taxPercentage:r.tax_percentage,taxAmount:r.tax_amount,finalPrice:r.final_amount_with_tax}}return{basePrice:e,discountAmount:0,taxPercentage:t||18,taxAmount:Math.round(e*(t||18)/100),finalPrice:e+Math.round(e*(t||18)/100)}}),[]),G=(0,o.useCallback)((function(){A((function(e){return!e}))}),[]),T=(0,o.useCallback)((0,r.Z)((function(){var e;return(0,a.__generator)(this,(function(n){switch(n.label){case 0:if(!d.trim())return y("Please enter a coupon code"),m("error"),[2];S(!0),y(""),m(""),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,I(d)];case 2:return(e=n.sent())?(e.message?y(e.message):e.error?y(e.error):e.MESSAGE?y(e.MESSAGE):y("Coupon processed"),e.success&&e.data&&e.data.coupon_usage&&null===e.data.coupon_usage.order_id?(m("success"),w(e),O((function(n){return Z(n.basePrice,e,n.taxPercentage)}))):(m("error"),w(null),O((function(e){return Z(e.basePrice,null,e.taxPercentage)})))):(y("Failed to validate coupon. Please check and try again."),m("error"),w(null),O((function(e){return Z(e.basePrice,null,e.taxPercentage)}))),[3,5];case 3:return n.sent(),y("Error applying coupon. Please try again."),m("error"),w(null),O((function(e){return Z(e.basePrice,null,e.taxPercentage)})),[3,5];case 4:return S(!1),[7];case 5:return[2]}}
1))})),[d,I,Z]),B=(0,o.useCallback)((function(e,n){var t=n?n/100:Math.round(e/1.18*100)/100,r={basePrice:t,discountAmount:0,taxPercentage:18,taxAmount:Math.round(.18*t*100)/100,finalPrice:e};O(r)}),[]);return(0,o.useEffect)((function(){if(!x.current&&l&&0!==j.basePrice&&c){var e=c.trim();if(e){x.current=!0,f(e);var n=setTimeout((function(){(0,r.Z)((function(){var n,t;return(0,a.__generator)(this,(function(r){switch(r.label){case 0:S(!0),y(""),m(""),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,I(e)];case 2:return(n=r.sent())?(n.message?y(n.message):n.error?y(n.error):n.MESSAGE?y(n.MESSAGE):y("Coupon processed"),n.success&&n.data&&n.data.coupon_usage&&null===n.data.coupon_usage.order_id?(m("success"),w(n),O((function(e){return Z(e.basePrice,n,e.taxPercentage)}))):(m("error"),w(null),O((function(e){return Z(e.basePrice,null,e.taxPercentage)})))):(y("Failed to validate coupon. Please check and try again."),m("error"),w(null)),[3,5];case 3:return t=r.sent(),y("Error applying coupon. Please try again."),m("error"),w(null),console.error("Unhandled error in auto-apply:",t),[3,5];case 4:return S(!1),[7];case 5:return[2]}}
1))}))()}),100);return function(){return clearTimeout(n)}}}}),[c,l,j.basePrice,I,Z]),{enableDiscount:l,couponCode:d,setCouponCode:f,couponMessage:g,couponMessageType:_,appliedCoupon:v,isApplyingCoupon:C,showDetails:M,pricingBreakdown:j,setPricingBreakdown:O,applyCoupon:T,toggleDetails:G,calculatePricing:Z,initializePricing:B}}},20618:function(e,n,t){var r=this&&this.__createBinding||(Object.create?function(e,n,t,r){void 0===r&&(r=t);var a=Object.getOwnPropertyDescriptor(n,t);a&&!("get"in a?!n.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,r,a)}:function(e,n,t,r){void 0===r&&(r=t),e[r]=n[t]}),a=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&r(n,e,t);return a(n,e),n},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.useRazorpay=void 0;const i=o(t(67294)),c=u(t(19799));n.useRazorpay=()=>{const[e,n]=i.useState(!1),[t,r]=i.useState(),a="undefined"!==typeof window;return i.useEffect((()=>{var e;a&&(n(!0),a&&"Razorpay"in window||(e="https://checkout.razorpay.com/v1/checkout.js",new Promise(((n,t)=>{const r=window.document.createElement("script");r.src=e,r.onload=function(){n()},r.onerror=function(e){t(e.toString())},document.body.appendChild(r)}))).then((()=>{r(void 0)})).catch((e=>{e instanceof Error?r(e.message):r("Unknown Error")})).finally((()=>n(!1))))}),[]),{error:t,isLoading:e,Razorpay:c.default}}},19799:function(e,n){Object.defineProperty(n,"__esModule",{value:!0});n.default=class{constructor(e){this.instance=void 0,this.options=e,"undefined"!==typeof window&&(this.instance=new window.Razorpay(this.options))}on(e,n){if(!this.instance)throw new Error("Razorpay Instance in not ready");this.instance.on(e,n)}open(){if(!this.instance)throw new Error("Razorpay Instance in not ready");this.instance.open()}}}}]);
2//# sourceMappingURL=3507.883e1e53ebfc2c57.js.map

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.