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AAU,8CAAE,KAAMC,GAAM,CAC7BA,EAAE,QAAQ,OAAM,CACjB,EACEC,GAAQA,EAAO,OAAO,EACzB,MACF,QACEzB,EAAQ,gBAAgB,UAAU,EAClCE,EAAY,OAAO,CAAC,IAAKoB,EAAS,CAAS,GAC3CF,EAAU,OAAO,EACjB,KACJ,EACD,EAAE,MAAOM,GAAa,CAIrB,OAHOT,IACYb,EAAA,MAAM,UAAU,IAAI,OAAO,EAEvCsB,EAAI,KAAM,CACf,QAEExB,EAAY,OAAO,CAAC,IAAK,uBAAwB,GACjDN,EAAc,OAAO,EACrB,KACJ,CAEAwB,EAAU,OAAO,EAERb,GAAA,CACV,GAGHoB,EAAiB3B,EAASc,CAAQ,EAEpBlB,EAAA,iBAAiB,WAAY,SAAemB,EAAG,CAIxD,GAHE,eAAU,OAAO,OAAO,EAC7Bb,EAAY,OAAO,CAAC,IAAK,YAAa,GAEnCa,EAAE,MAAQ,QACX,OAAOD,EAAS,CAClB,CACD,EAEK,MAAAc,EAAOC,EAAW,SAAW,IAAM,IACnCJ,EAAS,IAAIK,EAAe1B,EAAoBwB,CAAI,EAC1D9B,SAAK,SAAS,OAAO2B,EAAO,SAAS,EAC9B,QAAQ,IAAI,CACjBA,EAAO,KAAK,EACZlB,EAAS,EACV,CACH,EAEMT,EAAO,IAAIiC,EAAK,gBAAiB,GAAMlC,EAAc,KAAM,IAAM,CAErED,EAAc,MAAM,EAGpBY,EAAU,SAAS,gBAAgB,YAAY,YAAa,CAAC,EAAG,oBAAoB,CACtF,CAAC","names":["passwordInput","onFirstMount","page","LoginPage","btnNext","Button","btnNextI18n","I18n","passwordInputField","PasswordInputField","getStateInterval","getState","rootScope","_state","state","replaceContent","htmlToSpan","wrapEmojiText","onSubmit","e","cancelEvent","toggle","toggleDisability","value","preloader","putPreloader","response","__vitePreload","m","monkey","err","attachClickEvent","size","mediaSizes","PasswordMonkey","Page"],"ignoreList":[],"sources":["../src/pages/pagePassword.ts"],"sourcesContent":["/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nimport {putPreloader} from '../components/putPreloader';\nimport mediaSizes from '../helpers/mediaSizes';\nimport {AccountPassword} from '../layer';\nimport Page from './page';\nimport Button from '../components/button';\nimport PasswordInputField from '../components/passwordInputField';\nimport PasswordMonkey from '../components/monkeys/password';\nimport I18n from '../lib/langPack';\nimport LoginPage from './loginPage';\nimport cancelEvent from '../helpers/dom/cancelEvent';\nimport {attachClickEvent} from '../helpers/dom/clickEvent';\nimport htmlToSpan from '../helpers/dom/htmlToSpan';\nimport replaceContent from '../helpers/dom/replaceContent';\nimport toggleDisability from '../helpers/dom/toggleDisability';\nimport wrapEmojiText from '../lib/richTextProcessor/wrapEmojiText';\nimport rootScope from '../lib/rootScope';\n\nconst TEST = false;\nlet passwordInput: HTMLInputElement;\n\nconst onFirstMount = (): Promise<any> => {\n const page = new LoginPage({\n className: 'page-password',\n withInputWrapper: true,\n titleLangKey: 'Login.Password.Title',\n subtitleLangKey: 'Login.Password.Subtitle'\n });\n\n const btnNext = Button('btn-primary btn-color-primary');\n const btnNextI18n = new I18n.IntlElement({key: 'Login.Next'});\n\n btnNext.append(btnNextI18n.element);\n\n const passwordInputField = new PasswordInputField({\n label: 'LoginPassword',\n name: 'password'\n });\n\n passwordInput = passwordInputField.input as HTMLInputElement;\n\n page.inputWrapper.append(passwordInputField.container, btnNext);\n\n let getStateInterval: number;\n\n const getState = () => {\n // * just to check session relevance\n if(!getStateInterval) {\n getStateInterval = window.setInterval(getState, 10e3);\n }\n\n return !TEST && rootScope.managers.passwordManager.getState().then((_state) => {\n state = _state;\n\n if(state.hint) {\n replaceContent(passwordInputField.label, htmlToSpan(wrapEmojiText(state.hint)));\n } else {\n passwordInputField.setLabel();\n }\n });\n };\n\n let state: AccountPassword;\n\n const onSubmit = (e?: Event) => {\n if(e) {\n cancelEvent(e);\n }\n\n if(!passwordInput.value.length) {\n passwordInput.classList.add('error');\n return;\n }\n\n const toggle = toggleDisability([passwordInput, btnNext], true);\n const value = passwordInput.value;\n\n btnNextI18n.update({key: 'PleaseWait'});\n const preloader = putPreloader(btnNext);\n\n passwordInputField.setValueSilently('' + Math.random()); // prevent saving suggestion\n passwordInputField.setValueSilently(value); // prevent saving suggestion\n\n rootScope.managers.passwordManager.check(value, state).then((response) => {\n // console.log('passwordManager response:', response);\n\n switch(response._) {\n case 'auth.authorization':\n clearInterval(getStateInterval);\n import('./pageIm').then((m) => {\n m.default.mount();\n });\n if(monkey) monkey.remove();\n break;\n default:\n btnNext.removeAttribute('disabled');\n btnNextI18n.update({key: response._ as any});\n preloader.remove();\n break;\n }\n }).catch((err: any) => {\n toggle();\n passwordInputField.input.classList.add('error');\n\n switch(err.type) {\n default:\n // btnNext.innerText = err.type;\n btnNextI18n.update({key: 'PASSWORD_HASH_INVALID'});\n passwordInput.select();\n break;\n }\n\n preloader.remove();\n\n getState();\n });\n };\n\n attachClickEvent(btnNext, onSubmit);\n\n passwordInput.addEventListener('keypress', function(this, e) {\n this.classList.remove('error');\n btnNextI18n.update({key: 'Login.Next'});\n\n if(e.key === 'Enter') {\n return onSubmit();\n }\n });\n\n const size = mediaSizes.isMobile ? 100 : 166;\n const monkey = new PasswordMonkey(passwordInputField, size);\n page.imageDiv.append(monkey.container);\n return Promise.all([\n monkey.load(),\n getState()\n ]);\n};\n\nconst page = new Page('page-password', true, onFirstMount, null, () => {\n // if(!isAppleMobile) {\n passwordInput.focus();\n // }\n\n rootScope.managers.appStateManager.pushToState('authState', {_: 'authStatePassword'});\n});\n\nexport default page;\n"],"file":"pagePassword-BpefiXlr.js"} |