tweb/public/53.71a42ea94f0ddd5cd1f3.chunk.js
Eduard Kuzmenko 019a7aa1e3 Build
2022-06-24 21:23:25 +04:00

2 lines
6.6 KiB
JavaScript

"use strict";(this.webpackChunktweb=this.webpackChunktweb||[]).push([[53,810],{810:(e,t,n)=>{n.r(t),n.d(t,{default:()=>O});var a=n(279),o=n(8805),s=n(4874),i=n(503),r=n(9807),c=n(4494),d=n(4789),l=n(5432),u=n(4159),p=n(2325),h=n(2384),m=n(1405),g=n(4668),f=n(8497),v=n(144),y=n(9709),Z=n(9638),L=n(3910),E=n(2738),b=n(5565),w=n(1656),_=n(7487),k=n(2398),S=n(671),x=n(6669),C=n(7922),T=n(3512),N=n(709),P=n(9976),M=n(130),A=n(8115),I=n(3789);let B,D=null;const V=new s.Z("page-sign",!0,(()=>{const e=()=>{t=p.ZP.countriesList.filter((e=>{var t;return!(null===(t=e.pFlags)||void 0===t?void 0:t.hidden)})).sort(((e,t)=>(e.name||e.default_name).localeCompare(t.name||t.default_name)))};let t;e(),T.Z.addEventListener("language_change",(()=>{e()}));const s=new Map;let m,O;const R=document.createElement("div");R.classList.add("input-wrapper");const W=new i.Z({label:"Login.CountrySelectorLabel",name:(0,v.a)()});W.container.classList.add("input-select");const $=W.input,j=document.createElement("div");j.classList.add("select-wrapper","z-depth-3","hide");const q=document.createElement("span");q.classList.add("arrow","arrow-down"),W.container.append(q);const F=document.createElement("ul");j.appendChild(F),new o.ZP(j);let K=()=>{K=null,t.forEach((e=>{const t=(0,S.Ml)(e.iso2),n=[];e.country_codes.forEach((a=>{const o=document.createElement("li");let s=(0,A.Z)(t);if(P.Z){const e=document.createElement("span");(0,M.Z)(e,s),o.append(e)}else(0,M.Z)(o,s);const i=(0,p.ag)(e.default_name);i.dataset.defaultName=e.default_name,o.append(i);const r=document.createElement("span");r.classList.add("phone-code"),r.innerText="+"+a.country_code,o.appendChild(r),n.push(o),F.append(o)})),s.set(e.iso2,n)})),F.addEventListener("mousedown",(e=>{if(0!==e.button)return;const t=(0,g.Z)(e.target,"LI");z(t)})),W.container.appendChild(j)};const z=e=>{const n=e.childNodes[1].dataset.defaultName,a=e.querySelector(".phone-code").innerText,o=a.replace(/\D/g,"");(0,b.Z)($,(0,p.ag)(n)),(0,x.Z)($,"input"),m=t.find((e=>e.default_name===n)),O=m.country_codes.find((e=>e.country_code===o)),J.value=J.lastValue=a,G(),setTimeout((()=>{X.focus(),(0,k.Z)(X,!0)}),0)};let H;K(),$.addEventListener("focus",(function(e){K?K():t.forEach((e=>{s.get(e.iso2).forEach((e=>e.style.display=""))})),clearTimeout(H),H=void 0,j.classList.remove("hide"),j.offsetWidth,j.classList.add("active"),W.select(),(0,d.Z)({container:V.pageEl.parentElement.parentElement,element:$,position:"start",margin:4}),setTimeout((()=>{Q||(document.addEventListener("mousedown",U,{capture:!0}),Q=!0)}),0)}));let Q=!1;const U=e=>{(0,f.Z)(e.target,"input-select")||e.target!==$&&(G(),document.removeEventListener("mousedown",U,{capture:!0}),Q=!1)},G=()=>{void 0===H&&(j.classList.remove("active"),H=window.setTimeout((()=>{j.classList.add("hide"),H=void 0}),200))};$.addEventListener("keyup",(e=>{const n=e.key;if(e.ctrlKey||"Control"===n)return!1;let a=W.value.toLowerCase(),o=[];t.forEach((e=>{const t=[e.name,e.default_name,e.iso2];t.filter(Boolean).forEach((e=>{const n=e.split(" ").filter((e=>/\w/.test(e))).map((e=>e[0])).join("");n.length>1&&t.push(n)}));let n=!!t.filter(Boolean).find((e=>-1!==e.toLowerCase().indexOf(a)));s.get(e.iso2).forEach((e=>e.style.display=n?"":"none")),n&&o.push(e)})),0===o.length?t.forEach((e=>{s.get(e.iso2).forEach((e=>e.style.display=""))})):1===o.length&&"Enter"===n&&z(s.get(o[0].iso2)[0])})),q.addEventListener("mousedown",(function(e){e.cancelBubble=!0,e.preventDefault(),$.matches(":focus")?$.blur():$.focus()}));const J=new N.Z({onInput:e=>{h.Z.loadLottieWorkers();const{country:t,code:n}=e||{};let a=t?t.name||t.default_name:"";a===W.value||m&&t&&n&&(m===t||O.country_code===n.country_code)||((0,b.Z)($,t?(0,p.ag)(t.default_name):a),m=t,O=n),t||J.value.length-1>1?D.style.visibility="":D.style.visibility="hidden"}}),X=J.input;X.addEventListener("keypress",(e=>{if(!D.style.visibility&&"Enter"===e.key)return ee()}));const Y=new r.Z({text:"Login.KeepSigned",name:"keepSession",withRipple:!0,checked:!0});Y.input.addEventListener("change",(()=>{const e=Y.checked;T.Z.managers.appStateManager.pushToState("keepSigned",e),I.Z.toggleStorages(e,!0)})),I.Z.getState().then((e=>{C.Z.isAvailable()?Y.checked=e.keepSigned:(Y.checked=!1,Y.label.classList.add("checkbox-disabled"))})),D=(0,c.Z)("btn-primary btn-color-primary",{text:"Login.Next"}),D.style.visibility="hidden";const ee=e=>{e&&(0,L.Z)(e);const t=(0,w.Z)([D,B],!0);(0,b.Z)(D,(0,p.ag)("PleaseWait")),(0,a.y)(D);let o=J.value;T.Z.managers.apiManager.invokeApi("auth.sendCode",{phone_number:o,api_id:u.Z.id,api_hash:u.Z.hash,settings:{_:"codeSettings"}}).then((e=>{n.e(392).then(n.bind(n,6392)).then((t=>t.default.mount(Object.assign(e,{phone_number:o}))))})).catch((e=>{t(),"PHONE_NUMBER_INVALID"===e.type?(J.setError(),(0,b.Z)(J.label,(0,p.ag)("Login.PhoneLabelInvalid")),X.classList.add("error"),(0,b.Z)(D,(0,p.ag)("Login.Next"))):(console.error("auth.sendCode error:",e),D.innerText=e.type)}))};(0,E.fc)(D,ee),B=(0,c.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"Login.QR.Login"}),B.addEventListener("click",(()=>{y.default.mount()})),R.append(W.container,J.container,Y.label,D,B);const te=document.createElement("h4");te.classList.add("text-center"),(0,p.$d)(te,"Login.Title");const ne=document.createElement("div");ne.classList.add("subtitle","text-center"),(0,p.$d)(ne,"Login.StartText"),V.pageEl.querySelector(".container").append(te,ne,R),l.Z||setTimeout((()=>{X.focus()}),0),(0,Z.Z)(R),T.Z.managers.apiManager.invokeApi("help.getNearestDc").then((e=>{var t;const n=C.Z.getFromCache("langPack");n&&!(null===(t=n.countries)||void 0===t?void 0:t.hash)&&p.ZP.getLangPack(n.lang_code).then((()=>{(0,x.Z)(X,"input")}));const a=new Set([1,2,3,4,5]),o=[e.this_dc];let s;return e.nearest_dc!==e.this_dc&&(s=T.Z.managers.apiManager.getNetworkerVoid(e.nearest_dc).then((()=>{o.push(e.nearest_dc)}))),(s||Promise.resolve()).then((()=>{o.forEach((e=>{a.delete(e)}));const e=[...a],t=()=>{return n=void 0,a=void 0,s=function*(){const n=e.shift();if(!n)return;const a=`dc${n}_auth_key`;if(yield _.Z.get(a))return t();setTimeout((()=>{T.Z.managers.apiManager.getNetworkerVoid(n).finally(t)}),3e3)},new((o=void 0)||(o=Promise))((function(e,t){function i(e){try{c(s.next(e))}catch(e){t(e)}}function r(e){try{c(s.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(i,r)}c((s=s.apply(n,a||[])).next())}));var n,a,o,s};t()})),e})).then((e=>{W.value.length||J.value.length||z(s.get(e.country)[0])}))}),(()=>{D&&((0,b.Z)(D,(0,p.ag)("Login.Next")),(0,m.Z)(D,void 0,void 0,!0),D.removeAttribute("disabled")),B&&B.removeAttribute("disabled"),T.Z.managers.appStateManager.pushToState("authState",{_:"authStateSignIn"})})),O=V}}]);
//# sourceMappingURL=53.71a42ea94f0ddd5cd1f3.chunk.js.map