app.authPolicyComponent={props:['policy','text'],computed:{selected(){return this.policy},},methods:{toggle:function(e){if(e.target.nodeName==='B'){window.open("/offer?version2","_blank")}else if(e.target.nodeName==='I'){window.open("/policy","_blank")}else{this.$emit('toggle')}}},template:`
        <div class="cpol"
             @click="toggle($event)">

        <div class="auth__box cpol__checkbox"
             :class="{'auth__box--selected': selected}"></div>

        <div class="cpol__label"
             :class="{'cpol__label--selected': selected}"
             v-html="text">
        </div>
    </div>
    `};app.addModule(function(){var dataStore=JSON.parse(document.querySelector('#auth2__template').dataset.store);var vr;var vm;var showWindow=function(){vr=app.viewer({bgClose:!0,html:'<div id="auth2__form"></div>'});vr.loading(!0);startVm()};var startVm=function(){vm=new Vue({components:{'auth-policy':app.authPolicyComponent,},data:{phone:dataStore.phonePrefix,loading:!1,code:'',codeSent:!1,loc:{locBtn:dataStore.locBtn,locCode:dataStore.locCode,locPhone:dataStore.locPhone,locRepeat:dataStore.locRepeat,locSent:dataStore.locSent,locPolicyText:dataStore.locPolicyText},animation:null,closing:!1,captchaCode:'',isPolicy:!1},computed:Object.assign({captcha(){if(this.ui.commonSkipCaptcha){return null}
const phone=this.phone.replace(/[^0-9]/g,'');if(phone.length<7){return null}
return dataStore.cdn+'?captcha='+phone}},Vuex.mapState(['ui'])),mounted:function(){vr.loading(!1)},directives:{animation:{inserted:function(el,a,vnode){var context=vnode.context;var animationData=JSON.parse(document.querySelector('#auth2__animation').innerHTML);context.animation=lottie.loadAnimation({container:el,animationData:animationData,renderer:'svg',loop:!1,autoplay:!1});context.animation.playSegments([0,75],!0)}}},methods:{togglePolicy(){this.isPolicy=!this.isPolicy},onKeyUp:function(event){if(event.which===13){this.login({repeat:!1})}},onCodeInput:function(){if(this.code.length===4){this.login({repeat:!1})}},login:function(data){var _this=this;this.loading=!0;vr.loading(!0);var payload={phone:this.phone,code:this.code,needCode:!this.codeSent||data.repeat,captcha:this.captchaCode,isPolicy:this.isPolicy,};app.fetch('/auth/login',payload,function(response){if(response.error){app.alert(response.message,'danger');vr.loading(!1);_this.loading=!1;return}
if(response.codeSent){_this.codeSent=!0;vr.loading(!1);_this.loading=!1;return}
if(response.logged){vr.loading(!1);_this.animation.playSegments([141,192],!0);_this.animation.addEventListener('enterFrame',function(frame){if(frame.currentTime>frame.totalTime-5&&!_this.closing){_this.closing=!0;window.location.reload()}})}})},},store:app.store,template:'#auth2__template',el:'#auth2__form'})};PubSub.subscribe('showLoginModalWindow',showWindow);PubSub.subscribe('showAuth',showWindow)})