1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1450],{1450:function(e,t,n){n.d(t,{X:function(){return b}});var a=n(5853),l=n(4254),s=n(9916),i=n(6173),r=n(1536),o=n(3393);let c="448651555650-qgpqqs6nkq1dtddt5al6b49ifdc1pnja.apps.googleusercontent.com",d="https://accounts.google.com/gsi/client";function u(e){let{onCredential:t,text:n="signin_with"}=e,s=(0,l.useRef)(null),i=(0,l.useRef)(t);i.current=t;let[r,o]=(0,l.useState)(!1);return((0,l.useEffect)(()=>{var e,t;if(!c)return;let a=!1;function l(){!a&&s.current&&window.google&&(window.google.accounts.id.initialize({client_id:c,callback:e=>(null==e?void 0:e.credential)&&i.current(e.credential)}),window.google.accounts.id.renderButton(s.current,{type:"standard",theme:"outline",size:"large",text:n,shape:"rectangular",logo_alignment:"left",width:320}),o(!0))}if(null===(t=window.google)||void 0===t?void 0:null===(e=t.accounts)||void 0===e?void 0:e.id){l();return}let r=document.querySelector('script[src="'.concat(d,'"]'));return r||((r=document.createElement("script")).src=d,r.async=!0,r.defer=!0,document.head.appendChild(r)),r.addEventListener("load",l),()=>{a=!0,null==r||r.removeEventListener("load",l)}},[n]),c)?(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsx)("div",{ref:s,className:"min-h-[42px]"}),r?null:(0,a.jsx)("span",{className:"text-xs text-slate-400",children:"Loading Googleâ¦"})]}):null}let p="com.pesoto.web",m="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js";function h(e){let{onResult:t,label:n="Sign in with Apple"}=e,[s,i]=(0,l.useState)(!1),[r,o]=(0,l.useState)(!1),[c,d]=(0,l.useState)(null);async function u(){if(window.AppleID&&!r){o(!0);try{var e,n,a,l,s;let i=await window.AppleID.auth.signIn(),r=null==i?void 0:null===(e=i.authorization)||void 0===e?void 0:e.id_token;r&&t({idToken:r,firstName:null==i?void 0:null===(a=i.user)||void 0===a?void 0:null===(n=a.name)||void 0===n?void 0:n.firstName,lastName:null==i?void 0:null===(s=i.user)||void 0===s?void 0:null===(l=s.name)||void 0===l?void 0:l.lastName})}catch(t){let e=null==t?void 0:t.error;e&&"popup_closed_by_user"!==e&&"user_cancelled_authorize"!==e&&d("invalid_request"===e?"".concat(e," â this domain is not registered in the Apple Services ID"):e)}finally{o(!1)}}}return((0,l.useEffect)(()=>{if(!p)return;let e=!1;function t(){!e&&window.AppleID&&(window.AppleID.auth.init({clientId:p,scope:"name email",redirectURI:"".concat(window.location.origin,"/login"),usePopup:!0}),i(!0))}if(window.AppleID){t();return}let n=document.querySelector('script[src="'.concat(m,'"]'));return n||((n=document.createElement("script")).src=m,n.async=!0,n.defer=!0,document.head.appendChild(n)),n.addEventListener("load",t),()=>{e=!0,null==n||n.removeEventListener("load",t)}},[]),p)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button",onClick:u,disabled:!s||r,className:"flex h-[42px] w-[320px] max-w-full items-center justify-center gap-2 rounded-md bg-black px-4 text-sm font-medium text-white transition hover:bg-black/85 disabled:opacity-60",children:[(0,a.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"currentColor","aria-hidden":"true",children:(0,a.jsx)("path",{d:"M16.36 12.78c.02 2.53 2.22 3.37 2.24 3.38-.02.06-.35 1.2-1.16 2.38-.7 1.02-1.42 2.03-2.57 2.05-1.12.02-1.48-.66-2.77-.66-1.28 0-1.69.64-2.75.68-1.1.04-1.94-1.1-2.65-2.12-1.44-2.08-2.54-5.88-1.06-8.45.73-1.28 2.04-2.09 3.46-2.11 1.08-.02 2.1.73 2.77.73.66 0 1.9-.9 3.2-.77.55.02 2.08.22 3.07 1.67-.08.05-1.83 1.07-1.81 3.19M14.2 4.6c.59-.72.99-1.72.88-2.72-.85.03-1.88.57-2.49 1.28-.55.63-1.03 1.65-.9 2.62.95.08 1.92-.48 2.51-1.18"})}),n]}),c?(0,a.jsx)("p",{className:"mt-2 w-[320px] max-w-full text-xs text-red-600",children:c}):null]}):null}var x=n(7331);let f="448651555650-qgpqqs6nkq1dtddt5al6b49ifdc1pnja.apps.googleusercontent.com",g="com.pesoto.web";function v(){var e;let t=(0,x.N)().auth.social,n=(0,s.useRouter)(),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(""),p=(0,l.useRef)(null);function m(e){let n;u("");let a=crypto.randomUUID().replace(/-/g,"");p.current=a;let l=window.location.origin;if("google"===e){if(!f){u(t.error);return}let e=new URLSearchParams({client_id:f,redirect_uri:"".concat(l,"/auth/native-callback"),response_type:"id_token",scope:"openid email profile",nonce:crypto.randomUUID(),state:a,prompt:"select_account"});n="https://accounts.google.com/o/oauth2/v2/auth?".concat(e)}else{if(!g){u(t.error);return}let e=new URLSearchParams({client_id:g,redirect_uri:"".concat(l,"/auth/native-callback/apple"),response_type:"code id_token",scope:"name email",response_mode:"form_post",state:a});n="https://appleid.apple.com/auth/authorize?".concat(e)}c(!0),(0,r.DL)(n)}return(0,l.useEffect)(()=>{var e;if(!o||!p.current)return;let t=p.current,a=Date.now(),l=!1,s=!1,d=async()=>
1{if(!l&&!s){s=!0;try{let e=await fetch("".concat(i.XJ,"/api/auth/native/handoff/").concat(t));if(!e.ok)return;let s=await e.json();s.accessToken?(l=!0,(0,i.o4)(s.accessToken),(0,r.li)(),n.push("/dashboard")):Date.now()-a>3e5&&(l=!0,c(!1))}catch(e){}finally{s=!1}}},u=window.setInterval(d,2500),m=()=>{"hidden"!==document.visibilityState&&d()};document.addEventListener("visibilitychange",m),window.addEventListener("focus",m),window.addEventListener("pageshow",m);let h=null===(e=window.Capacitor)||void 0===e?void 0:e.Plugins,x=[],f=(e,t,n)=>{var a;Promise.resolve(null==e?void 0:null===(a=e.addListener)||void 0===a?void 0:a.call(e,t,n)).then(e=>{e&&x.push(e)})};return f(null==h?void 0:h.Browser,"browserFinished",m),f(null==h?void 0:h.App,"appUrlOpen",()=>{(0,r.li)(),d()}),()=>{for(let e of(l=!0,window.clearInterval(u),document.removeEventListener("visibilitychange",m),window.removeEventListener("focus",m),window.removeEventListener("pageshow",m),x))e.remove()}},[o]),(0,a.jsxs)("div",{className:"mt-6",children:[d?(0,a.jsx)("div",{className:"mb-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700",children:d}):null,(0,a.jsxs)("div",{className:"flex w-full items-center gap-3 text-xs font-medium uppercase tracking-wide text-slate-300",children:[(0,a.jsx)("span",{className:"h-px flex-1 bg-slate-200"})," ",t.or," ",(0,a.jsx)("span",{className:"h-px flex-1 bg-slate-200"})]}),o?(0,a.jsxs)("div",{className:"mt-4 flex items-center justify-center gap-2.5 rounded-lg border border-brand/30 bg-brand-light/40 px-3 py-3 text-sm text-brand-dark",children:[(0,a.jsx)("span",{className:"h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-brand border-t-transparent"}),null!==(e=t.waitingBrowser)&&void 0!==e?e:"â¦",(0,a.jsx)("button",{type:"button",onClick:()=>c(!1),className:"ml-2 text-xs text-slate-400 underline",children:"â"})]}):(0,a.jsxs)("div",{className:"mt-4 flex flex-col gap-2.5",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>m("google"),className:"flex w-full items-center justify-center gap-2.5 rounded-lg border border-slate-200 bg-white px-4 py-2.5 text-sm font-semibold text-slate-700 hover:bg-slate-50",children:[(0,a.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-5 w-5","aria-hidden":"true",children:[(0,a.jsx)("path",{fill:"#4285F4",d:"M23.5 12.3c0-.9-.1-1.5-.3-2.2H12v4.1h6.5c-.1 1.1-.8 2.7-2.4 3.8l-.02.15 3.5 2.7.24.03c2.2-2.1 3.5-5.1 3.5-8.6z"}),(0,a.jsx)("path",{fill:"#34A853",d:"M12 24c3.2 0 5.9-1.1 7.9-2.9l-3.8-2.9c-1 .7-2.4 1.2-4.1 1.2-3.2 0-5.8-2.1-6.8-5l-.14.01-3.7 2.8-.05.14C3.3 21.3 7.3 24 12 24z"}),(0,a.jsx)("path",{fill:"#FBBC05",d:"M5.2 14.4c-.2-.7-.4-1.5-.4-2.4s.1-1.6.4-2.4l-.01-.16-3.7-2.9-.12.06C.5 8.2 0 10 0 12s.5 3.8 1.3 5.4l3.9-3z"}),(0,a.jsx)("path",{fill:"#EB4335",d:"M12 4.6c2.2 0 3.8 1 4.6 1.8l3.4-3.3C17.9 1.2 15.2 0 12 0 7.3 0 3.3 2.7 1.3 6.6l3.8 3C6.2 6.7 8.8 4.6 12 4.6z"})]}),"Google"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>m("apple"),className:"flex w-full items-center justify-center gap-2.5 rounded-lg bg-black px-4 py-2.5 text-sm font-semibold text-white hover:bg-slate-800",children:[(0,a.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-5 w-5","aria-hidden":"true",children:(0,a.jsx)("path",{d:"M16.7 12.9c0-2.4 2-3.6 2.1-3.7-1.1-1.7-2.9-1.9-3.5-1.9-1.5-.2-2.9.9-3.7.9-.8 0-1.9-.9-3.2-.9-1.6 0-3.2 1-4 2.5-1.7 3-.4 7.4 1.2 9.8.8 1.2
11.8 2.5 3.1 2.4 1.2 0 1.7-.8 3.2-.8s1.9.8 3.2.8c1.3 0 2.2-1.2 3-2.4.9-1.4 1.3-2.7 1.3-2.8 0 0-2.6-1-2.7-3.9zM14.4 5.6c.7-.8 1.1-1.9 1-3.1-1 0-2.2.7-2.9 1.5-.6.7-1.2 1.9-1 3 1.1.1 2.2-.6 2.9-1.4z"})}),"Apple"]})]})]})}var w=n(4820);function b(e){let{mode:t="signin"}=e,n=(0,x.N)().auth.social,c=(0,s.useRouter)(),d=(0,r.mK)(),[p,m]=(0,l.useState)(null),[f,g]=(0,l.useState)("ua"),[b,j]=(0,l.useState)(""),[N,y]=(0,l.useState)(!1);async function k(e,t){j(""),y(!0);try{let n=new URLSearchParams(window.location.search),a=(0,o.UD)(window.location.hostname,n.get("country")),l="google"===e.provider?await i.hi.googleAuth(e.credential,t,a):await i.hi.appleAuth(e.credential,{countryCode:t,expectedCountry:a,firstName:e.firstName,lastName:e.lastName});if("needsCountry"in l){m(e);return}(0,i.o4)(l.accessToken),c.push("/dashboard")}catch(e){j("WRONG_COUNTRY"===(e instanceof Error?e.message:"")?n.wrongCountry:n.error),m(null)}finally{y(!1)}}return d?(0,a.jsx)(v,{}):(0,a.jsxs)("div",{className:"mt-6",children:[b?(0,a.jsx)("div",{className:"mb-3",children:(0,a.jsx)(w.Tv,{message:b})}):null,(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,a.jsxs)("div",{className:"flex w-full items-center gap-3 text-xs font-medium uppercase tracking-wide text-slate-300",children:[(0,a.jsx)("span",{className:"h-px flex-1 bg-slate-200"})," ",n.or," ",(0,a.jsx)("span",{className:"h-px flex-1 bg-slate-200"})]}),(0,a.jsx)(u,{text:"signup"===t?"signup_with":"signin_with",onCredential:e=>k({provider:"google",credential:e})}),(0,a.jsx)(h,{label:n.apple,onResult:function(e){k({provider:"apple",credential:e.idToken,firstName:e.firstName,lastName:e.lastName})}})]}),p?(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-sm rounded-2xl bg-white p-6 shadow-xl",children:[(0,a.jsx)("h2",{className:"text-lg font-bold text-slate-900",children:n.chooseCountry}),(0,a.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:n.chooseCountrySub}),(0,a.jsxs)("select",{value:f,onChange:e=>g(e.target.value),className:"mt-4 w-full rounded-lg border border-slate-200 bg-white px-3.5 py-2.5 text-sm outline-none focus:border-brand focus:ring-2 focus:ring-brand/20",children:[(0,a.jsx)("option",{value:"ua",children:"Ukraine"}),(0,a.jsx)("option",{value:"md",children:"Moldova"})]}),(0,a.jsx)("button",{onClick:()=>k(p,f),disabled:N,className:"mt-4 w-full rounded-lg bg-brand px-4 py-2.5 text-sm font-semibold text-white transition hover:bg-brand-dark disabled:opacity-60",children:N?"â¦":n.continue})]})}):null]})}},9916:function(e,t,n){var a=n(2535);n.o(a,"useParams")&&n.d(t,{useParams:function(){return a.useParams}}),n.o(a,"usePathname")&&n.d(t,{usePathname:function(){return a.usePathname}}),n.o(a,"useRouter")&&n.d(t,{useRouter:function(){return a.useRouter}}),n.o(a,"useSearchParams")&&n.d(t,{useSearchParams:function(){return a.useSearchParams}})}}]);
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.