tweb/public/53.0848e83cc329eb6130be.chu...

2 lines
17 KiB
JavaScript

"use strict";(this.webpackChunktweb=this.webpackChunktweb||[]).push([[53,688,465,392,810],{4489:(e,t,n)=>{n.d(t,{Z:()=>a});var i=n(503);class a extends i.Z{constructor(e){super(Object.assign({plainText:!0},e));const t=this.input;t.type="tel",t.setAttribute("required",""),t.autocomplete="off";let n=0;this.input.addEventListener("input",(t=>{this.input.classList.remove("error"),this.setLabel();const i=this.value.replace(/\D/g,"").slice(0,e.length);this.setValueSilently(i);const a=this.value.length;if(a===e.length)e.onFill(this.value);else if(a===n)return;n=a}))}}},9638:(e,t,n)=>{n.d(t,{Z:()=>p});var i=n(3910),a=n(2738),o=n(4541),s=n(4727),r=n(9518),l=n(3512),d=n(4494),c=n(6858);let u,h=!1;function p(e){h||(u||(u=r.Z.getConfig().then((e=>e.suggested_lang_code!==s.default.lastRequestedLangCode?Promise.all([e,s.default.getStrings(e.suggested_lang_code,["Login.ContinueOnLanguage"]),s.default.getCacheLangPack()]):[])))).then((([t,n])=>{if(!t)return;const r=[];n.forEach((e=>{const t=s.default.strings.get(e.key);t&&(r.push(t),s.default.strings.set(e.key,e))}));const u=(0,d.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"Login.ContinueOnLanguage"});u.lastElementChild.classList.remove("i18n"),(0,o.Z)().then((()=>{window.requestAnimationFrame((()=>{e.append(u)}))})),l.default.addEventListener("language_change",(()=>{u.remove()}),{once:!0}),r.forEach((e=>{s.default.strings.set(e.key,e)})),(0,a.fc)(u,(e=>{(0,i.d)(e),h=!0,u.disabled=!0,(0,c.y7)(u),s.default.getLangPack(t.suggested_lang_code)}))}))}},3083:(e,t,n)=>{n.d(t,{Z:()=>a});var i=n(2897);class a{constructor(e,t){this.inputField=e,this.size=t,this.max=45,this.needFrame=0,this.container=document.createElement("div"),this.container.classList.add("media-sticker-wrapper");const n=e.input;n.addEventListener("blur",(()=>{this.playAnimation(0)})),n.addEventListener("input",(t=>{this.playAnimation(e.value.length)}))}playAnimation(e){if(!this.animation)return;let t;(e=Math.min(e,30))?(t=Math.round(Math.min(this.max,e)*(165/this.max)+11.33),this.idleAnimation&&(this.idleAnimation.stop(!0),this.idleAnimation.canvas.style.display="none"),this.animation.canvas.style.display=""):t=0;const n=this.needFrame>t?-1:1;this.animation.setDirection(n),0!==this.needFrame&&0===t&&this.animation.setSpeed(7),this.needFrame=t,this.animation.play()}load(){return this.loadPromise?this.loadPromise:this.loadPromise=Promise.all([i.Z.loadAnimationAsAsset({container:this.container,loop:!0,autoplay:!0,width:this.size,height:this.size},"TwoFactorSetupMonkeyIdle").then((e=>(this.idleAnimation=e,this.inputField.value.length||e.play(),i.Z.waitForFirstFrame(e)))),i.Z.loadAnimationAsAsset({container:this.container,loop:!1,autoplay:!1,width:this.size,height:this.size},"TwoFactorSetupMonkeyTracking").then((e=>(this.animation=e,this.inputField.value.length||(this.animation.canvas.style.display="none"),this.animation.addEventListener("enterFrame",(e=>{(1===this.animation.direction&&e>=this.needFrame||-1===this.animation.direction&&e<=this.needFrame)&&(this.animation.setSpeed(1),this.animation.pause()),0===e&&0===this.needFrame&&this.idleAnimation&&(this.idleAnimation.canvas.style.display="",this.idleAnimation.play(),this.animation.canvas.style.display="none")})),i.Z.waitForFirstFrame(e))))])}remove(){this.animation&&this.animation.remove(),this.idleAnimation&&this.idleAnimation.remove()}}},4484:(e,t,n)=>{function i(e,t){const n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;++i)if(e[i]!==t[i])return!1;return!0}n.d(t,{Z:()=>i})},8079:(e,t,n)=>{function i(e,t){return t?e.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,""):e.replace(/-/g,"+").replace(/_/g,"/")}n.d(t,{Z:()=>i})},8045:(e,t,n)=>{n.d(t,{Z:()=>r});var i=n(410),a=n(7487),o=n(9518);const s=new class{constructor(){this.serverTimeOffset=0,a.Z.get("server_time_offset").then((e=>{e&&(this.serverTimeOffset=e)})),o.Z.addTaskListener("applyServerTimeOffset",(e=>{this.serverTimeOffset=e.payload}))}};i.GO&&(i.GO.serverTimeManager=s);const r=s},6392:(e,t,n)=>{n.r(t),n.d(t,{default:()=>y});var i=n(4755),a=n(4687),o=n(9518),s=n(4874),r=n(810),l=n(3083),d=n(4489),c=n(4727),u=n(144),h=n(5565);let p,m=null,g=null,f=null;const v=new s.Z("page-authCode",!0,(()=>{const e=m.type.length,t=new d.Z({label:"Code",name:(0,u.a)(),length:e,onFill:e=>{s(e)}});p=t.input,v.pageEl.querySelector(".input-wrapper").append(t.container),v.pageEl.querySelector(".phone-edit").addEventListener("click",(function(){return r.default.mount()}));const a=()=>{setTimeout((()=>{y.remove()}),300)},s=e=>{p.setAttribute("disabled","true");const i={phone_number:m.phone_number,phone_code_hash:m.phone_code_hash,phone_code:e};o.Z.invokeApi("auth.signIn",i,{ignoreErrors:!0}).then((e=>{switch(e._){case"auth.authorization":o.Z.setUser(e.user),n.e(781).then(n.bind(n,5436)).then((e=>{e.default.mount()})),a();break;case"auth.authorizationSignUpRequired":Promise.all([n.e(765),n.e(339)]).then(n.bind(n,8339)).then((e=>{e.default.mount({phone_number:m.phone_number,phone_code_hash:m.phone_code_hash})})),a()}})).catch((e=>{return i=void 0,a=void 0,s=function*(){let i=!1;switch(e.type){case"SESSION_PASSWORD_NEEDED":i=!0,e.handled=!0,yield(yield n.e(774).then(n.bind(n,9437))).default.mount(),setTimeout((()=>{p.value=""}),300);break;case"PHONE_CODE_EXPIRED":p.classList.add("error"),(0,h.Z)(t.label,(0,c.i18n)("PHONE_CODE_EXPIRED"));break;case"PHONE_CODE_EMPTY":case"PHONE_CODE_INVALID":p.classList.add("error"),(0,h.Z)(t.label,(0,c.i18n)("PHONE_CODE_INVALID"));break;default:t.label.innerText=e.type}i||t.select(),p.removeAttribute("disabled")},new((o=void 0)||(o=Promise))((function(e,t){function n(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(n,r)}l((s=s.apply(i,a||[])).next())}));var i,a,o,s}))},g=v.pageEl.querySelector(".auth-image"),f=i.ZP.isMobile?100:166,y=new l.Z(t,f);return g.append(y.container),y.load()}),(e=>{if(m=e,g){p.value="";const e=document.createEvent("HTMLEvents");e.initEvent("input",!1,!0),p.dispatchEvent(e)}else g=v.pageEl.getElementsByClassName("phone")[0],f=v.pageEl.getElementsByClassName("sent-type")[0];let t,n;switch(g.innerText=m.phone_number,m.type._){case"auth.sentCodeTypeSms":t="Login.Code.SentSms";break;case"auth.sentCodeTypeApp":t="Login.Code.SentInApp";break;case"auth.sentCodeTypeCall":t="Login.Code.SentCall";break;default:t="Login.Code.SentUnknown",n=[m.type._]}(0,h.Z)(f,(0,c.i18n)(t,n)),a.default.pushToState("authState",{_:"authStateAuthCode",sentCode:e})}),(()=>{p.focus()})),y=v},810:(e,t,n)=>{n.r(t),n.d(t,{default:()=>H});var i=n(6858),a=n(8805),o=n(4687),s=n(9518),r=n(8598),l=n(4874),d=n(503),c=n(9807),u=n(4494),h=n(4789),p=n(5432),m=n(4159),g=n(4727),f=n(2897),v=n(1405),y=n(4668),E=n(8497),_=n(144),L=n(6947),w=n(8576),b=n(4465),Z=n(9638),S=n(3910),k=n(2738),T=n(5565),C=n(1656),P=n(7487),A=n(2398),x=n(671),O=n(6669),D=n(7922),N=n(3512),F=n(709),R=n(9976);let I,q=null;const M=new l.Z("page-sign",!0,(()=>{const e=()=>{t=g.default.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(),N.default.addEventListener("language_change",(()=>{e()}));const l=new Map;let v,H;const z=document.createElement("div");z.classList.add("input-wrapper");const Q=new d.Z({label:"Login.CountrySelectorLabel",name:(0,_.a)()});Q.container.classList.add("input-select");const B=Q.input,U=document.createElement("div");U.classList.add("select-wrapper","z-depth-3","hide");const V=document.createElement("span");V.classList.add("arrow","arrow-down"),Q.container.append(V);const $=document.createElement("ul");U.appendChild($),new a.ZP(U);let W=()=>{W=null,t.forEach((e=>{const t=(0,x.Ml)(e.iso2),n=[];e.country_codes.forEach((i=>{const a=document.createElement("li");let o=r.o.wrapEmojiText(t);if(R.Z){const e=document.createElement("span");e.innerHTML=o,a.append(e)}else a.innerHTML=o;const s=(0,g.i18n)(e.default_name);s.dataset.defaultName=e.default_name,a.append(s);const l=document.createElement("span");l.classList.add("phone-code"),l.innerText="+"+i.country_code,a.appendChild(l),n.push(a),$.append(a)})),l.set(e.iso2,n)})),$.addEventListener("mousedown",(e=>{if(0!==e.button)return;const t=(0,y.Z)(e.target,"LI");j(t)})),Q.container.appendChild(U)};const j=e=>{const n=e.childNodes[1].dataset.defaultName,i=e.querySelector(".phone-code").innerText,a=i.replace(/\D/g,"");(0,T.Z)(B,(0,g.i18n)(n)),(0,O.Z)(B,"input"),v=t.find((e=>e.default_name===n)),H=v.country_codes.find((e=>e.country_code===a)),J.value=J.lastValue=i,Y(),setTimeout((()=>{ee.focus(),(0,A.Z)(ee,!0)}),0)};let G;W(),B.addEventListener("focus",(function(e){W?W():t.forEach((e=>{l.get(e.iso2).forEach((e=>e.style.display=""))})),clearTimeout(G),G=void 0,U.classList.remove("hide"),U.offsetWidth,U.classList.add("active"),Q.select(),(0,h.Z)({container:M.pageEl.parentElement.parentElement,element:B,position:"start",margin:4}),setTimeout((()=>{K||(document.addEventListener("mousedown",X,{capture:!0}),K=!0)}),0)}));let K=!1;const X=e=>{(0,E.Z)(e.target,"input-select")||e.target!==B&&(Y(),document.removeEventListener("mousedown",X,{capture:!0}),K=!1)},Y=()=>{void 0===G&&(U.classList.remove("active"),G=window.setTimeout((()=>{U.classList.add("hide"),G=void 0}),200))};B.addEventListener("keyup",(e=>{const n=e.key;if(e.ctrlKey||"Control"===n)return!1;let i=Q.value.toLowerCase(),a=[];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(i)));l.get(e.iso2).forEach((e=>e.style.display=n?"":"none")),n&&a.push(e)})),0===a.length?t.forEach((e=>{l.get(e.iso2).forEach((e=>e.style.display=""))})):1===a.length&&"Enter"===n&&j(l.get(a[0].iso2)[0])})),V.addEventListener("mousedown",(function(e){e.cancelBubble=!0,e.preventDefault(),B.matches(":focus")?B.blur():B.focus()}));const J=new F.Z({onInput:e=>{f.Z.loadLottieWorkers();const{country:t,code:n}=e||{};let i=t?t.name||t.default_name:"";i===Q.value||v&&t&&n&&(v===t||H.country_code===n.country_code)||((0,T.Z)(B,t?(0,g.i18n)(t.default_name):i),v=t,H=n),t||J.value.length-1>1?q.style.visibility="":q.style.visibility="hidden"}}),ee=J.input;ee.addEventListener("keypress",(e=>{if(!q.style.visibility&&"Enter"===e.key)return ne()}));const te=new c.Z({text:"Login.KeepSigned",name:"keepSession",withRipple:!0,checked:!0});te.input.addEventListener("change",(()=>{const e=te.checked;o.default.pushToState("keepSigned",e),L.Z.toggleStorage(e),w.Z.toggleStorage(e),s.Z.toggleStorage(e),P.Z.toggleStorage(e)})),o.default.getState().then((e=>{o.default.storage.isAvailable()?te.checked=e.keepSigned:(te.checked=!1,te.label.classList.add("checkbox-disabled"))})),q=(0,u.Z)("btn-primary btn-color-primary",{text:"Login.Next"}),q.style.visibility="hidden";const ne=e=>{e&&(0,S.d)(e);const t=(0,C.Z)([q,I],!0);(0,T.Z)(q,(0,g.i18n)("PleaseWait")),(0,i.y7)(q);let a=J.value;s.Z.invokeApi("auth.sendCode",{phone_number:a,api_id:m.Z.id,api_hash:m.Z.hash,settings:{_:"codeSettings"}}).then((e=>{n.e(392).then(n.bind(n,6392)).then((t=>t.default.mount(Object.assign(e,{phone_number:a}))))})).catch((e=>{t(),"PHONE_NUMBER_INVALID"===e.type?(J.setError(),(0,T.Z)(J.label,(0,g.i18n)("Login.PhoneLabelInvalid")),ee.classList.add("error"),(0,T.Z)(q,(0,g.i18n)("Login.Next"))):(console.error("auth.sendCode error:",e),q.innerText=e.type)}))};(0,k.fc)(q,ne),I=(0,u.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"Login.QR.Login"}),I.addEventListener("click",(()=>{b.default.mount()})),z.append(Q.container,J.container,te.label,q,I);const ie=document.createElement("h4");ie.classList.add("text-center"),(0,g._i18n)(ie,"Login.Title");const ae=document.createElement("div");ae.classList.add("subtitle","text-center"),(0,g._i18n)(ae,"Login.StartText"),M.pageEl.querySelector(".container").append(ie,ae,z),p.IS_TOUCH_SUPPORTED||setTimeout((()=>{ee.focus()}),0),(0,Z.Z)(z),s.Z.invokeApi("help.getNearestDc").then((e=>{var t;const n=D.Z.getFromCache("langPack");n&&!(null===(t=n.countries)||void 0===t?void 0:t.hash)&&g.default.getLangPack(n.lang_code).then((()=>{(0,O.Z)(ee,"input")}));const i=new Set([1,2,3,4,5]),a=[e.this_dc];let o;return e.nearest_dc!==e.this_dc&&(o=s.Z.getNetworker(e.nearest_dc).then((()=>{a.push(e.nearest_dc)}))),(o||Promise.resolve()).then((()=>{a.forEach((e=>{i.delete(e)}));const e=[...i],t=()=>{return n=void 0,i=void 0,o=function*(){const n=e.shift();if(!n)return;const i=`dc${n}_auth_key`;if(yield P.Z.get(i))return t();setTimeout((()=>{s.Z.getNetworker(n).finally(t)}),3e3)},new((a=void 0)||(a=Promise))((function(e,t){function s(e){try{l(o.next(e))}catch(e){t(e)}}function r(e){try{l(o.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(s,r)}l((o=o.apply(n,i||[])).next())}));var n,i,a,o};t()})),e})).then((e=>{Q.value.length||J.value.length||j(l.get(e.country)[0])}))}),(()=>{q&&((0,T.Z)(q,(0,g.i18n)("Login.Next")),(0,v.ripple)(q,void 0,void 0,!0),q.removeAttribute("disabled")),I&&I.removeAttribute("disabled"),o.default.pushToState("authState",{_:"authStateSignIn"})})),H=M},4465:(e,t,n)=>{n.r(t),n.d(t,{default:()=>_});var i=n(9518),a=n(4874),o=n(8045),s=n(4159),r=n(4494),l=n(4727),d=n(4687),c=n(3512),u=n(6858),h=n(9638),p=n(5418),m=n(8079),g=n(4484);function f(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}var v=function(e,t,n,i){return new(n||(n=Promise))((function(a,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function r(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};let y;const E=new a.Z("page-signQR",!0,(()=>y),(()=>{y||(y=v(void 0,void 0,void 0,(function*(){const e=E.pageEl.querySelector(".auth-image");let t=(0,u.y7)(e,!0);const a=document.createElement("div");a.classList.add("input-wrapper");const d=(0,r.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"Login.QR.Cancel"});a.append(d),(0,h.Z)(a);const _=e.parentElement,L=document.createElement("h4");(0,l._i18n)(L,"Login.QR.Title");const w=document.createElement("ol");w.classList.add("qr-description"),["Login.QR.Help1","Login.QR.Help2","Login.QR.Help3"].forEach((e=>{const t=document.createElement("li");t.append((0,l.i18n)(e)),w.append(t)})),_.append(L,w,a),d.addEventListener("click",(()=>{Promise.all([n.e(458),n.e(325),n.e(810)]).then(n.bind(n,810)).then((e=>e.default.mount())),Z=!0}));const b=(yield Promise.all([n.e(630).then(n.t.bind(n,1915,23))]))[0].default;let Z=!1;c.default.addEventListener("user_auth",(()=>{Z=!0,y=null}),{once:!0});let S,k={ignoreErrors:!0};const T=a=>v(void 0,void 0,void 0,(function*(){try{let r=yield i.Z.invokeApi("auth.exportLoginToken",{api_id:s.Z.id,api_hash:s.Z.hash,except_ids:[]},{ignoreErrors:!0});if("auth.loginTokenMigrateTo"===r._&&(k.dcId||(k.dcId=r.dc_id,i.Z.setBaseDcId(r.dc_id)),r=yield i.Z.invokeApi("auth.importLoginToken",{token:r.token},k)),"auth.loginTokenSuccess"===r._){const e=r.authorization;return i.Z.setUser(e.user),n.e(781).then(n.bind(n,5436)).then((e=>e.default.mount())),!0}if(!S||!(0,g.Z)(S,r.token)){S=r.token;let n=function(e){let t,n="";for(let i=e.length,a=0,o=0;o<i;++o)t=o%3,a|=e[o]<<(16>>>t&24),2!==t&&i-o!=1||(n+=String.fromCharCode(f(a>>>18&63),f(a>>>12&63),f(a>>>6&63),f(63&a)),a=0);return n.replace(/A(?=A$|$)/g,"=")}(r.token),i="tg://login?token="+(0,m.Z)(n,!0);const a=window.getComputedStyle(document.documentElement),o=a.getPropertyValue("--surface-color").trim(),s=a.getPropertyValue("--primary-text-color").trim(),l=a.getPropertyValue("--primary-color").trim(),d=yield fetch("assets/img/logo_padded.svg").then((e=>e.text())).then((e=>{e=e.replace(/(fill:).+?(;)/,`$1${l}$2`);const t=new Blob([e],{type:"image/svg+xml;charset=utf-8"});return new Promise((e=>{const n=new FileReader;n.onload=t=>{e(t.target.result)},n.readAsDataURL(t)}))})),c=new b({width:240*window.devicePixelRatio,height:240*window.devicePixelRatio,data:i,image:d,dotsOptions:{color:s,type:"rounded"},cornersSquareOptions:{type:"extra-rounded"},imageOptions:{imageSize:1,margin:0},backgroundOptions:{color:o},qrOptions:{errorCorrectionLevel:"L"}});let u;c.append(e),e.lastChild.classList.add("qr-canvas"),u=c._drawingPromise?c._drawingPromise:Promise.race([(0,p.w)(1e3),new Promise((e=>{c._canvas._image.addEventListener("load",(()=>{window.requestAnimationFrame((()=>e()))}),{once:!0})}))]),yield u.then((()=>{if(t){t.style.animation="hide-icon .4s forwards";const n=e.children[1];n.style.display="none",n.style.animation="grow-icon .4s forwards",setTimeout((()=>{n.style.display=""}),150),setTimeout((()=>{n.style.animation=""}),500),t=void 0}else Array.from(e.children).slice(0,-1).forEach((e=>{e.remove()}))}))}if(a){let e=Date.now()/1e3,t=r.expires-e-o.Z.serverTimeOffset;yield(0,p.w)(t>3?3e3:1e3*t|0)}}catch(e){return"SESSION_PASSWORD_NEEDED"===e.type?(console.warn("pageSignQR: SESSION_PASSWORD_NEEDED"),e.handled=!0,Promise.all([n.e(458),n.e(442)]).then(n.bind(n,9437)).then((e=>e.default.mount())),Z=!0,y=null):(console.error("pageSignQR: default error:",e),Z=!0),!0}return!1}));return()=>v(void 0,void 0,void 0,(function*(){for(Z=!1;!Z&&!(yield T(!0)););}))}))),y.then((e=>{e()})),d.default.pushToState("authState",{_:"authStateSignQr"})})),_=E}}]);
//# sourceMappingURL=53.0848e83cc329eb6130be.chunk.js.map