(function(){var timer;var ajax;PubSub.subscribe('recalcCart',function(e,params){ajax&&ajax.abort&&ajax.abort();clearTimeout(timer);app.updateStore({cartLoading:!0});var timeout=0;if(params.formData){timeout=500}
var payload={clear:params.clear||null,formData:params.formData||null,changeAmount:params.changeAmount||null,changePromocode:params.changePromocode||null,changeAddress:params.changeAddress||null,repeatCartId:params.repeatCartId||null,cartSwitchConfirmed:params.cartSwitchConfirmed||null,env:params.env||null};var target='/cart/recalc3';var fetchCart=function(){ajax=app.fetch(target,payload,function(response){app.updateStore({cartLoading:!1});if(response.error==='confirmCartSwitch'){if(window.confirm(response.message)){payload.cartSwitchConfirmed=!0;fetchCart();return}}else if(response.error==='promoLimitExceeded'){app.growl(response.message,'danger')}else{app.updateStore({cart:response.cart})}
params.cb&&params.cb(response)})};timer=setTimeout(fetchCart,timeout)})})();app.cartToggleComponent={props:['value'],computed:{isActive(){return!!this.value}},methods:{toggle(){this.$emit('input',this.value?'':1)}},template:`
        <div class="ctoggle" :class="{'ctoggle--active': isActive}" @click="toggle()">
            <i class="ctoggle__flag"></i>
        </div>
    `};app.cartBlockComponent={components:{cartToggle:app.cartToggleComponent},props:['withToggle','title','description','value'],computed:{isSlotVisible(){return!!this.value}},methods:{onInput(){this.$emit('input',this.value)}},template:`
    
        <div class="ctblock">
            
            <div v-if="title" class="ctblock__item">
                <div v-if="withToggle" class="ctblock__toggle">
                     <cartToggle v-model="value" @input="onInput"/>
                </div>
                
                <div class="ctblock__itemTitle">{{title}}</div>
                <div v-if="description" class="ctblock__itemDescription">{{description}}</div>
            </div>
        
            <div v-if="isSlotVisible" class="ctblock__slot">
                 <slot/>
            </div>
        </div>
    
    `};app.cartInputComponent={props:['value','caption','name','inputmode'],data(){return{autogrowFn:null,text:this.value}},computed:{isFilled(){return this.text.length>0}},mounted(){this.autogrowFn=app.autogrow(this.$refs.textarea);this.$watch('value',(value)=>{this.text=value},{immediate:!0});this.$watch('text',()=>{this.autogrowFn.recalc()},{immediate:!0})},methods:{focus(){this.$refs.textarea.focus()},onInput(){if(this.text.indexOf("\n")!==-1){this.text=this.text.replace(/\n/g,'')}
this.$emit('input',this.text)}},template:`
    <label class="ctinput2" :class="{'ctinput2--filled': isFilled}">
        <div class="ctinput2__caption">{{caption}}</div>
        <textarea class="ctinput2__text"
                  :name="name"
                  :inputmode="inputmode || 'text'"
                  ref="textarea"
                  v-model="text"
                  @input="onInput()"></textarea>
    </label>
    
    `};app.cartSuggestComponent={props:['options','el'],data:function(){return{visible:!1}},mounted:function(){document.body.addEventListener('click',this.clickOutside)},destroyed:function(){document.body.removeEventListener('click',this.clickOutside)},methods:{clickOutside:function(e){if(e.target.closest(this.el)){this.visible=!this.visible;if(this.visible){this.$emit('shown')}}else if(!this.$el.contains(e.target)){this.visible=!1}},select:function(option){this.$emit('selected',option);this.visible=!1}},template:'#csugg__template'};app.cartSpinnerComponent={template:'<div class="cspinner"></div>'};app.cartHeaderComponent={props:['title','clear','back','absolute'],methods:{action:function(event){this.$emit(event)}},template:'#cheader__template'};app.cartFooterComponent={inject:['store'],props:['text','withTotal','absolute','loading'],data:function(){return{isOverlap:!1,observer:null}},computed:Object.assign({isTotalVisible(){return this.withTotal},isLoading(){return this.cartLoading||this.loading||this.store.ordering},locTotal(){return this.loc['cart/total2']},total(){return this.cart.amount.totalFormatted},numberTotal(){return this.cart.amount.total/10000},totalCross(){return this.cart.amount.totalCrossFormatted},numberCross(){return parseFloat(this.cart.amount.totalCrossFormatted.replace(/[s,руб]+/g,'.'))}},Vuex.mapState(['cart','cartLoading','loc'])),destroyed:function(){if(this.observer){this.observer.disconnect()}},mounted:function(){var _this=this;if(window.IntersectionObserver){var options={root:this.$el.closest('.cart'),rootMargin:'0px 0px -100px 0px',threshold:0};this.observer=new IntersectionObserver(function(entries){_this.isOverlap=entries[0].isIntersecting},options);this.observer.observe(this.$refs.footer)}},methods:{submit:function(){if(!this.isLoading){this.$emit('submit')}}},template:'#cfooter__template'};app.cartPromoGradeProgressStepComponent={props:['step'],data(){return{prevLeftFormatted:''}},computed:{isFinished(){return this.step.percent===100},hint(){if(this.step.left){this.prevLeftFormatted=this.step.leftFormatted}
return this.prevLeftFormatted?`Ещё ${this.prevLeftFormatted}`:' '}},template:'#pstep__template'};app.cartPromoGradeProgressLineComponent={props:['steps'],computed:{lineStyle(){let percent=0;let piece=100/this.steps.length;let countFinished=0;for(let step of this.steps){let p=piece*step.percent/100;percent+=p;if(step.percent===100){countFinished++}}
percent=parseInt(percent);let offset=countFinished;if(countFinished===0){offset=-5}else if(countFinished===this.steps.length-1){offset=5}
if(percent===100){offset=0}
return{transform:`translateX(calc(${percent}% + ${offset}px))`}}},template:'#pline__template'};app.cartPromoGradeProgressComponent={props:['steps'],components:{progressStep:app.cartPromoGradeProgressStepComponent,progressLine:app.cartPromoGradeProgressLineComponent},template:'#gprog__template'};app.cartPromoGradeGiftComponent={props:['gift'],computed:{photo(){return this.gift.photo},name(){return this.gift.name},size(){return this.gift.sizeFormatted},isFinished(){return this.gift.percent===100},isSelected(){return this.gift.selected}},methods:{picked(){if(this.isFinished){this.$emit('picked',this.gift)}}},template:'#pgift__template'};app.cartPromoGradeGiftListComponent={components:{promoGift:app.cartPromoGradeGiftComponent},props:['steps'],data(){return{isOpened:!1}},mounted:function(){document.body.addEventListener('click',this.clickOutside)},destroyed:function(){document.body.removeEventListener('click',this.clickOutside)},methods:{clickOutside(e){if(!this.$el.contains(e.target)&&this.isOpened){this.isOpened=!1}},picked(gift){this.$emit('picked',gift);this.isOpened=!1},toggle(){this.isOpened=!this.isOpened}},template:'#giftlist__template'};app.cartPromoGradePreviewCircleComponent={props:['steps'],computed:{spaceSize(){return 5},fragmentSize(){return(100/this.steps.length)-this.spaceSize},bgOffset(){return(this.spaceSize/2)*-1},bgDasharray(){const list=[];for(let i=0;i<this.steps.length;i++){list.push(this.fragmentSize);list.push(this.spaceSize)}
return list},fragments(){const list=[];let i=0;for(let step of this.steps){let size=this.fragmentSize*step.percent/100;list.push({isHidden:step.percent===0,dasharray:[size,100-size],offset:(this.fragmentSize*i*-1)-(this.spaceSize/2)-(this.spaceSize*i)})
i++}
return list}},template:'#pgcircle__template'};app.cartPromoGradePreviewComponent={props:['steps'],components:{previewCircle:app.cartPromoGradePreviewCircleComponent},computed:{countGifts(){return this.steps.filter(step=>step.percent===100).length||1}},template:'#pgview__template'};app.cartPromoGradeComponent={components:{promoProgress:app.cartPromoGradeProgressComponent,promoGiftList:app.cartPromoGradeGiftListComponent,promoPreview:app.cartPromoGradePreviewComponent},props:['mode'],computed:Object.assign({isVisible(){return!!(this.cart&&this.cart.promo&&this.cart.promo.grade)},isPreviewVisible(){return this.mode==='preview'},isProgressVisible(){return this.mode==='cart'||this.mode==='progress'},isGiftListVisible(){return this.mode==='cart'},steps(){return this.cart.promo.grade.steps}},Vuex.mapState(['cart','loc','company'])),methods:{picked(gift){this.$emit('picked',gift)}},template:'#pgrade__template'};app.cartServiceComponent={computed:Object.assign({isVisible(){return!!this.cart.amount.serviceCharge},value(){return this.cart.amount.serviceChargeFormatted},numberValue(){return this.cart.amount.serviceCharge/10000},title(){return this.loc['cart/serviceCharge']},text(){return""}},Vuex.mapState(['cart','loc'])),template:'#ctservice__template'};app.cartClosedComponent={data(){return{isCollapsed:!0,observer:null}},computed:Object.assign({isVisible(){return this.text.length},text(){let text=this.cart.company&&this.cart.timeframe.closedText;if(!text){return''}
text=text.split(/ /);return `<span>${text.join('</span> <span>')}</span>`}},Vuex.mapState(['cart'])),watch:{text:{handler:function(val,oldVal){this.initObserver()},deep:!0}},destroyed(){this.destroyObserver()},mounted(){this.initObserver()},methods:{destroyObserver(){if(this.observer){this.observer.disconnect()}},initObserver(){this.destroyObserver()
const textRoot=this.$refs.textRoot;if(textRoot&&window.IntersectionObserver){const options={root:textRoot,rootMargin:'0px 0px -10px 0px',threshold:0};this.observer=new IntersectionObserver((entries)=>{const overlay=textRoot.querySelector('.cclosed__overlay')
if(overlay){overlay.classList.remove('cclosed__overlay')}
for(let i=0;i<entries.length;i++){const entry=entries[i];if(!entry.isIntersecting){const leftEntry=entry.target.previousElementSibling;if(leftEntry){leftEntry.classList.add('cclosed__overlay')}
break}}},options);textRoot.querySelectorAll('span').forEach(span=>this.observer.observe(span))}},toggle(){this.isCollapsed=!this.isCollapsed}},template:'#cclosed__template'};app.cartDeliveryComponent={computed:Object.assign({isVisible(){return this.types.length>1},pointerStyle:function(){var index=0;for(var i=0;i<this.types.length;i++){if(this.types[i].active){index=i;break}}
var x=index*100;return{"-webkit-transform":"translateX("+x+"%)",transform:"translateX("+x+"%)"}},typeStyle:function(){return{width:'calc(100% / '+this.types.length+')'}},types(){var items=[];if(this.company.enabledDeliveryTypes.courier){items.push({id:'delivery',name:this.loc['cart/delivery'],active:this.address.type==='delivery'})}
if(this.company.enabledDeliveryTypes.pickup){const discount=this.cart.amount.pickupDiscountPercentAvail;items.push({id:'pickup',name:this.loc['cart/pickup'],active:this.address.type==='pickup',discount:discount?`−${discount}%`:''})}
if(this.company.enabledDeliveryTypes.inside){items.push({id:'inside',name:this.loc['cart/inside'],active:this.address.type==='inside'})}
if(this.company.enabledDeliveryTypes.drive){items.push({id:'drive',name:this.loc['cart/drive'],active:this.address.type==='drive'})}
return items},isMany:function(){return this.types.length>=4}},Vuex.mapState(['cart','company','address','loc'])),methods:{select:function(type){if(type.off){return}
PubSub.publish('showUserAddress',{type:type.id==='courier'?'delivery':type.id})}},template:`
    
    <div v-if="isVisible"
         class="cdv"
         :class="{'cdv--many': isMany}">

        <div v-for="(type, i) in types"
             :key="type.id"
             class="cdv__item"
             @click="select(type)"
             :data-id="type.id"
             :style="typeStyle"
             :class="{'cdv__item--active': type.active, 'cdv__item--off': type.off}">

             <div class="cdv__name">{{type.name}}</div>

             <div v-if="type.discount"
                  class="cdv__discount">
                 {{type.discount}}
             </div>

            <div v-if="i === 0"
                 ref="pointer"
                 class="cdv__pointer"
                 :style="pointerStyle"></div>

        </div>

    </div>
    
    `};app.cartCutleryComponent={computed:Object.assign({isPersons(){return this.company.cutleryVisible==="visible"},name(){return this.isPersons?this.loc['cart/cutlery']:this.loc['cart/cutleryNum']},num(){let num=this.cart.amount.cutlery;if(this.isPersons&&num<=0){num=1}
return num},isVisible:function(){return this.company.cutleryVisible}},Vuex.mapState(['loc','cart','company'])),methods:{changeCount(sign){let count=this.num;let min=this.isPersons?1:0;if(sign==='minus'){count--}else{count++}
if(count<min){count=min}
if(this.cart.amount.cutlery!==count){this.cart.amount.cutlery=count;this.$root.recalc()}}},template:`
    
    <div v-if="isVisible"
         class="cutlery">

        <div class="cutlery__name">
            {{name}}
        </div>

        <div class="cutlery__controls">
            <div class="cutlery__control cutlery__control--minus" @click="changeCount('minus')"></div>
            <div class="cutlery__num">{{num}}</div>
            <div class="cutlery__control cutlery__control--plus" @click="changeCount('plus')"></div>
        </div>

    </div>
    
    `};app.cartZoneHintComponent={data(){return{isCollapsed:!0,observer:null}},computed:Object.assign({isVisible(){return this.address&&this.address.type==='delivery'&&this.hint},hint(){let hint;if(this.company.cartZoneHintVisibility){hint=this.address&&this.address.delivery&&this.address.delivery.currentZone&&this.address.delivery.currentZone.hint}
if(this.cart.amount.useReserveDeliveryFee){hint=this.store.loc['cart/fee/reserved']}
return hint},hintFormatted(){if(!this.hint){return''}
let hint=this.hint.split(/ /).filter(line=>!!line);return `<span>${hint.join('</span> <span>')}</span>`}},Vuex.mapState(['company','address','cart'])),watch:{hint:{handler:function(val,oldVal){this.initObserver()},deep:!0}},destroyed(){this.destroyObserver()},mounted(){this.initObserver()},methods:{destroyObserver(){if(this.observer){this.observer.disconnect()}},initObserver(){this.destroyObserver()
const textRoot=this.$refs.textRoot;if(textRoot&&window.IntersectionObserver){const options={root:textRoot,rootMargin:'0px 0px -10px 0px',threshold:0};this.observer=new IntersectionObserver((entries)=>{const overlay=textRoot.querySelector('.zhint__overlay')
if(overlay){overlay.classList.remove('zhint__overlay')}
for(let i=0;i<entries.length;i++){const entry=entries[i];if(!entry.isIntersecting){const leftEntry=entry.target.previousElementSibling;if(leftEntry){leftEntry.classList.add('zhint__overlay')}
break}}},options);textRoot.querySelectorAll('span').forEach(span=>this.observer.observe(span))}},toggle(){this.isCollapsed=!this.isCollapsed}},template:` 
    
    <div v-show="isVisible"
         class="zhint"
         :class="{'zhint--collapsed': isCollapsed}"
         @click="toggle()">

        <svg class="zhint__ico" width="24" height="24" viewBox="0 0 24 24" fill="none">
            <path d="M10.2679 3C11.0377 1.66667 12.9623 1.66667 13.7321 3L20.6603 15C21.4301 16.3333 20.4678 18 18.9282 18H5.0718C3.5322 18 2.56995 16.3333 3.33975 15L10.2679 3Z" fill="#F4CC5A"/>
            <rect x="11" y="6" width="2" height="7" rx="1" fill="white"/>
            <rect x="11" y="14" width="2" height="2" rx="1" fill="white"/>
        </svg>

        <div class="zhint__text" ref="textRoot" v-html="hintFormatted"></div>
    </div>
    
    `};app.cartFeeComponent={components:{'zone-hint':app.cartZoneHintComponent},computed:Object.assign({isVisible(){return this.address&&this.address.type==='delivery'},fee(){return this.cart.amount.feeFormatted},numberFee(){return this.cart.amount.fee/10000},title(){return this.loc['cart/fee']},info(){let address=this.$root.addressName(this.address.delivery,'streetHouse');let sub='';let warn=!1;let minPriceError=this.cart.amount.minPriceError;if(!address){address=this.loc['address3/needle']}
if(minPriceError){sub=minPriceError;warn=!0}else if(this.cart.amount.sumToFree){sub=this.cart.amount.sumToFreeText}
return{address:address,sub:sub,warn:warn}}},Vuex.mapState(['cart','loc','company','address'])),methods:{navigateAddresses:function(){PubSub.publish('showUserAddress',{type:'delivery'})}},template:'#cfee__template'};app.cartDishComponent={props:['dish'],computed:Object.assign({isVisible(){return this.dish.num>0},isControlsVisible(){return!this.dish.gift},isPlusDisabled(){return!!this.dish.promoLimited},discount(){if(!this.dish.discount){return null}
return this.dish.discountFormatted},numberDiscount(){return this.dish.discount/10000},giftText(){if(!this.dish.gift){return null}
let num=this.dish.num;let text=[];if(num>1){text.push('×'+num)}
text.push(this.loc['history/gift']);return text.join(' ')},name(){let name=this.dish.name.split('+')
return{text:name[0],sub:name[1]||''}},price(){let rub=this.company.currency;if(this.dish.gift){return'0'+rub}
let price=(this.dish.price*this.dish.num/10000);price=(price.toFixed(2)+'').replace('.00','').replace('.',',')+rub;return price},numberPrice(){return(this.dish.price*this.dish.num/10000)}},Vuex.mapState(['loc','company'])),methods:{changeAmount:function(sign){if(sign==='plus'){if(this.isPlusDisabled){return}
this.dish.num++}else{this.dish.num--;if(this.dish.num<0){this.dish.num=0}}
this.$root.recalc()}},template:'#cdish__template'};app.cartDishesComponent={components:{'cart-dish':app.cartDishComponent},inject:['store'],computed:Object.assign({dishes:function(){return this.cart.dishes}},Vuex.mapState(['cart'])),template:'#cdishes__template'};app.cartExtraDishesComponent={data(){return{scrollBusy:!1,isNavVisible:!0,prevVisible:!1,nextVisible:!1}},computed:Object.assign({isVisible(){return this.cart.extra&&this.cart.extra.dishes.length},locTitle(){return this.loc['cart/extra/title']}},Vuex.mapState(['cart','loc'])),mounted:function(){this.$watch('cart.extra',function(){this.syncNav()},{immediate:!0,deep:!0})},methods:{onScroll:function(){if(!this.scrollBusy){this.scrollBusy=!0;window.requestAnimationFrame(this.syncNav)}},syncNav:function(){var scrollable=this.$refs.scrollable;if(!scrollable){return}
var scrollableBounds=scrollable.getBoundingClientRect();var firstItemBounds=scrollable.querySelector('.cextra__item:first-child').getBoundingClientRect();var lastItemBounds=scrollable.querySelector('.cextra__item:last-child').getBoundingClientRect();this.prevVisible=firstItemBounds.left-10<scrollableBounds.left;this.nextVisible=(lastItemBounds.left+lastItemBounds.width)>(scrollableBounds.left+scrollableBounds.width);this.scrollBusy=!1},scroll:function(direction){this.$refs.scrollable.scrollBy({left:direction==='next'?130:-130,behavior:'smooth'})},add:function(dish){var dishes=this.cart.extra.dishes.filter(function(item){return item.dishId!==dish.dishId});this.cart.dishes.push(JSON.parse(JSON.stringify(dish)));this.cart.extra.dishes=dishes;this.$root.recalc()}},template:'#cextra__template'};app.cartPriorityComponent={computed:Object.assign({isVisible(){return this.cart.company.feePriorityFormatted&&(this.address&&this.address.type==='delivery')},isApplied(){return this.cart.amount.feePriority},value(){return(this.isApplied?'':'+')+this.cart.company.feePriorityFormatted},valueFeePriority(){return this.cart.amount.feePriority/10000},title(){return"Приоритетная доставка"},text(){return"Ваш заказ будет доставлен<br> в первую очередь"}},Vuex.mapState(['cart','address'])),methods:{toggle:function(){this.cart.amount.feePriority=!this.cart.amount.feePriority;this.$root.recalc()}},template:'#ctprior__template'};app.cartExchangeComponent={computed:Object.assign({isVisible:function(){return this.cart.exchange.maxDiscountFormatted},isApplied:function(){return this.cart.exchange.discountFormatted},value:function(){return this.cart.exchange.maxDiscountFormatted},maxPercent:function(){return this.cart.exchange.maxPercent},maxAllowedExchange:function(){return this.cart.exchange.maxAllowedExchange},userPoints:function(){return this.cart.exchange.userPoints},userPointsRound:function(){return this.cart.exchange.userPointsRound},title:function(){return this.cart.exchange.title},sub:function(){var error=this.cart.exchange.error;return{text:error||this.cart.exchange.maxPointsText,warn:!!error}}},Vuex.mapState(['cart'])),methods:{toggle:function(){if(this.cart.exchange.discountFormatted){this.cart.exchange.discountFormatted=''}else{this.cart.exchange.discountFormatted=this.cart.exchange.maxDiscountFormatted}
this.$root.recalc()}},template:'#cpoints__template'};app.cartPromocodeComponent={data(){return{inputShown:(this.$store.state.cart&&this.$store.state.cart.promo.code)||!1,code:(this.$store.state.cart&&this.$store.state.cart.promo.code)||'',}},computed:Object.assign({isVisible(){return!0},isGift(){let dishes=this.cart.dishes.filter(function(dish){return dish.gift})
return dishes&&dishes.length>0},smile(){if(!this.code){return null}
if(this.isApplied){return'😍'}
if(this.message.isError){return'😯'}
return null},isApplied(){return this.cart.promo.id&&this.code},title(){return this.loc['cart/promocode']},add(){return this.loc['cart/promocode/add']},inputStyle(){let percent=100;let len=this.code.length;if(len>13){percent=60}else if(len>12){percent=65}else if(len>11){percent=70}else if(len>10){percent=75}else if(len>9){percent=80}else if(len>8){percent=85}else if(len>7){percent=90}else if(len>6){percent=95}
return{'font-size':percent+'%'}},message(){let text=this.cart.promo.error;let isError=!!text;if(this.isApplied){if(this.cart.promo.discount){text=this.loc['cart/promocode/discount'].replace('{sum}',this.cart.promo.discountFormatted)}else{if(this.isGift){text=this.loc['cart/promocode/gift']}else{text=this.loc['cart/promocode/applied']}}}
return{text:text,isError:isError}},numberDiscount(){return this.cart.promo.discount/10000},errorMessage(){return this.cart.promo.error},},Vuex.mapState(['cart','loc'])),watch:{'cart.promo.code':function(cur){if(cur){this.inputShown=!0;this.code=cur}}},methods:{showInput:function(){this.inputShown=!0;var _this=this;this.$nextTick(function(){_this.$refs.input.focus()})},cancel:function(){this.code='';this.cart.promo.cancelled=!0;this.inputShown=!1;this.onInput()},onCancel:function(){if(window.confirm(this.loc['cart/promocode/cancel'])){this.cancel()}},onInput:function(){this.cart.promo.code=this.code;this.cart.promo.cancelled=!0;this.$root.recalc()},onBlur:function(){if(!this.code){this.inputShown=!1}}},template:'#cpromo__template'};app.cartScreenDishesComponent={components:{'cart-header':app.cartHeaderComponent,'cart-footer':app.cartFooterComponent,'cart-delivery':app.cartDeliveryComponent,'cart-dishes':app.cartDishesComponent,'cart-fee':app.cartFeeComponent,'cart-cutlery':app.cartCutleryComponent,'cart-closed':app.cartClosedComponent,'cart-priority':app.cartPriorityComponent,'cart-promocode':app.cartPromocodeComponent,'cart-extra-dishes':app.cartExtraDishesComponent,'cart-exchange':app.cartExchangeComponent,'cart-service':app.cartServiceComponent,'cart-promo-grade':app.cartPromoGradeComponent,'cart-banner':app.cartBanner},computed:Object.assign({locTitle:function(){if(this.company.aggregator){return this.cart.company.name}
return this.loc['tab/cart']},submitText:function(){return this.loc['btn/next']}},Vuex.mapState(['cart','loc','company'])),methods:{clear:function(){if(window.confirm(this.loc['cart/clear'])){this.$root.clear()}},navigateBack:function(){this.$root.close()},onSubmit:function(){if(this.cart.company.closedText&&this.cart.timeframe.types.preorder.off){app.alert(this.cart.company.closedText,'danger');return}
if(this.company.cutleryVisible==='cutlery-required'&&!this.cart.amount.cutlery){app.alert(this.loc['cart/err/cutlery'],'danger');return}
if(this.cart.extra.confirmText&&!this.cart.extra.confirmed){if(!window.confirm(this.cart.extra.confirmText)){return}
this.cart.extra.confirmed=!0;this.$root.recalc()}
this.navigate()},onGiftPicked(gift){this.cart.promo.code=this.cart.promo.grade.code;this.cart.promo.grade.forceGift=gift.posId.replace('gift','');this.$root.recalc()},navigate:function(){this.$root.navigate('form')}},template:`
    
    <div class="csdishes">

        <cart-header
                :title="locTitle"
                clear="true"
                @back="navigateBack()"
                @clear="clear()"/>

        <div class="csdishes__content">
            <cart-closed/>
            <cart-delivery/>
            <cart-banner/>
            <cart-promo-grade mode="cart" @picked="onGiftPicked"/>
            <cart-dishes/>
            <cart-extra-dishes/>
            <cart-fee/>
            <cart-service/>
            <cart-priority/>
            <cart-exchange/>
            <cart-promocode/>
            <cart-cutlery/>
        </div>

        <cart-footer :text="submitText"
                     withTotal="true"
                     @submit="onSubmit()"/>
    </div>
    
    `};app.cartScreenEmptyComponent={components:{'cart-header':app.cartHeaderComponent},inject:['store'],data:function(){return{animation:null,closing:!1}},computed:Object.assign({title:function(){return this.loc['cart/empty/title']},text:function(){return this.loc['cart/empty/hint']},go:function(){return this.loc['cart/empty/go']}},Vuex.mapState(['loc'])),directives:{animation:{inserted:function(el,a,vnode){var context=vnode.context;var animationData=JSON.parse(document.querySelector('#cempty__animation').innerHTML);context.animation=lottie.loadAnimation({container:el,animationData:animationData,renderer:'svg',loop:!1,autoplay:!1});context.animation.playSegments([0,100],!0)}}},methods:{close:function(){var _this=this;this.animation.playSegments([110,145],!0);this.animation.addEventListener('enterFrame',function(frame){if(frame.currentTime>frame.totalTime-3&&!_this.closing){_this.closing=!0;_this.$root.close()}})},navigate:function(){this.close();if(location.hostname.includes('qr')){return}
if(location.pathname&&location.pathname.length>1){location.href='/'}}},template:'#cempty__template'};app.cartScreenSuccessComponent={components:{'cart-header':app.cartHeaderComponent},inject:['store'],computed:Object.assign({successId(){return this.store.successId},title:function(){return this.loc['cart/thanks']},sub(){return this.store.successText}},Vuex.mapState(['loc','mobile','company'])),methods:{close:function(){if(this.company.qrMenu){window.location.reload()}else if(this.mobile){window.location.assign('/cabinet/order')}else{window.location.assign('/cabinet')}}},template:'#csuccess__template'};app.cartFormAddressComponent={components:{'zone-hint':app.cartZoneHintComponent},computed:Object.assign({isVisible:function(){return this.address.type==='delivery'},address:function(){return this.address.delivery},isExactVisible:function(){return!1},name:function(){return this.$root.addressName(this.address.delivery,'full')},info:function(){return null},locAddress:function(){return this.loc['cart/address']},locRoom:function(){return this.loc['cart/address/room']},locEntrance:function(){return this.loc['cart/address/entrance']},locFloor:function(){return this.loc['cart/address/floor']}},Vuex.mapState(['cart','loc','address'])),methods:{navigateAddresses:function(){PubSub.publish('showUserAddress',{type:'delivery'})}},template:'#cfaddr__template'};app.cartRestaurantComponent={computed:Object.assign({isVisible:function(){if(this.company.qrMenu){return!1}
return['pickup','inside','drive'].indexOf(this.address.type)!==-1},name:function(){return this.address.pickup.name},locTitle:function(){let title=this.loc['cart/restaurant'];if(this.company.isAirport){title=this.loc['address2/title/airport']}else if(this.address.type==='inside'){title=this.loc['address2/title/inside']}
return title}},Vuex.mapState(['address','loc','company'])),methods:{navigate:function(){PubSub.publish('showUserAddress',{type:this.address.type})}},template:'#crest__template'};app.cartInsideComponent={data:function(){var tableNumber=window.location.href.match(/&t=(\d+)/);if(tableNumber){tableNumber=tableNumber[1]}else{tableNumber=this.$store.state.cart.inside.tableNumber}
return{tableNumber:tableNumber}},computed:Object.assign({isVisible:function(){if(this.company.cartEatInTableNumberHidden){return!1}
return this.address.type==='inside'&&!this.cart.stadium},locTitle:function(){return this.loc['cart/table']}},Vuex.mapState(['loc','cart','address','company'])),mounted(){this.tableNumber&&this.onInput()},methods:{onInput:function(){this.cart.inside.tableNumber=this.tableNumber;this.$root.recalc()}},template:'#inside__template'};app.cartDriveComponent={data:function(){return{car:this.$store.state.cart.drive.car}},computed:Object.assign({isVisible:function(){return this.address.type==='drive'},locTitle:function(){return this.loc['cart/car']}},Vuex.mapState(['loc','cart','address'])),methods:{onInput:function(){this.cart.drive.car=this.car;this.$root.recalc()}},template:'#drive__template'};app.cartClientComponent={data:function(){return{name:this.$store.state.cart.client.name,phone:this.$store.state.cart.client.phone}},computed:Object.assign({isVisible(){if(this.company.qrMenu&&this.address.type==='inside'){return!this.company.cartHidePhoneInQr}
return!this.company.isAirport},locName:function(){return this.loc['cart/yourname']},locPhone:function(){return this.loc['cart/yourphone']},isPhoneReadOnly:function(){if(this.company.restrictPhone&&this.cart.client.isAuthorizedPhone){return!0}
return this.company.userSubscriptionIsRequired}},Vuex.mapState(['cart','loc','company','address'])),methods:{onInput:function(){this.cart.client.name=this.name;this.cart.client.phone=this.phone;this.$root.recalc()}},template:'#cclient__template'};app.cartPaymentComponent={data:function(){return{oddmoney:this.$store.state.cart.payment.oddmoney}},computed:Object.assign({oddmoneyVisible:function(){return this.cart.payment.activeType==='cash'&&this.cart.company.oddmoney&&this.address.type==='delivery'},merchantVisible:function(){return this.cart.payment.activeType==='online'&&this.cart.merchant&&this.cart.merchant.types&&this.cart.merchant.types.length},merchantValue:function(){var _this=this;var type=this.cart.merchant.types.find(function(item){return item.id===_this.cart.merchant.activeType});if(!type){return''}
if(type.name){return type.name}
var html=[];html.push('<div class="cpay__brand cpay__brand--'+type.info.brand+'"></div>');html.push(type.info.first6.substr(0,4));html.push('<span class="cpay__dots">···</span>');html.push('<span class="cpay__dots">···</span>');html.push(type.info.last4);return html.join('')},types(){const types=[];const onlineType=this.cart.payment.types.kaspiSecondary&&!this.cart.payment.types.kaspiSecondary.off?'kaspiSecondary':'online';for(let i in this.cart.payment.types){const type=this.cart.payment.types[i];if(!type.off){type.selected=type.id===this.cart.payment.activeType;type.appearance=type.id===onlineType?this.company.cartOnlineButtonAppearance:'default';types.push(type)}}
return types},locOddmoney:function(){return this.loc['cart/oddmoney']},locPickCard(){return this.loc['cart/onlinePayment/pickCard']}},Vuex.mapState(['cart','address','loc','company'])),methods:{navigateMerchant:function(){this.$root.navigate('merchant')},selectType:function(type){if(this.cart.payment.activeType!==type.id){this.cart.payment.activeType=type.id;this.$root.recalc()}},onInput:function(){this.cart.payment.oddmoney=this.oddmoney;this.$root.recalc()}},template:'#cpay__template'};app.cartPreorderComponent={components:{'cart-suggest':app.cartSuggestComponent,'cart-spinner':app.cartSpinnerComponent},data:function(){return{days:[],syncing:!1}},computed:Object.assign({timeframe:function(){return this.cart.timeframe},isVisible:function(){return this.timeframe.activeType==='preorder'},caption:function(){return this.loc['history/preorder']},currentDay:function(){return this.timeframe.activeDay},currentDayName:function(){return(this.currentDay&&this.currentDay.name)||''},currentTimeName:function(){var time=this.timeframe.activeTime;if(!time){return'__ : __'}
return time.name},times:function(){var currentDay=this.currentDay;if(!currentDay){return null}
var day=this.days.find(function(day){return day.id===currentDay.id});if(!day){return null}
return day.times}},Vuex.mapState(['cart','loc','address','company'])),mounted:function(){var _this=this;this.$watch('timeframe.activeType',function(activeType){if(activeType==='preorder'){_this.sync()}},{immediate:!0})},methods:{onDaySuggestShown:function(){this.sync()},sync:function(){this.syncing=!0;this.days=[];var _this=this;var payload={deliveryMethod:this.address.type==='pickup'?'pickup':'courier'};app.fetch('/timeframe/get2',payload,function(response){_this.syncing=!1;if(response.error){return}
_this.days=response.days;if(!_this.currentDay){return}
var day=_this.days.find(function(day){return day.id===_this.currentDay.id});if(!day){_this.timeframe.activeDay=null;_this.timeframe.activeTime=null;return}
if(!_this.timeframe.activeTime){return}
var time=_this.times.find(function(time){return time.id===_this.timeframe.activeTime.id});if(!time){_this.timeframe.activeTime=null}})},onDaySelected:function(day){this.timeframe.activeDay={id:day.id,name:day.name};this.timeframe.activeTime=null;this.$root.recalc()},onTimeSelected:function(time){this.timeframe.activeTime=time;this.$root.recalc()}},template:'#preorder__template'};app.cartPickupComponent={components:{'cart-suggest':app.cartSuggestComponent,'cart-spinner':app.cartSpinnerComponent},data(){return{times:[],syncing:!1}},computed:Object.assign({timeframe(){return this.cart.timeframe},isVisible(){return this.timeframe.activeType==='now'&&!this.timeframe.pickupTimeOff&&['pickup','inside','drive'].includes(this.address.type)},currentPickupTime:function(){return this.timeframe.activePickupTimeName||''},locPickup:function(){return this.loc['cart/pickup-time']}},Vuex.mapState(['cart','address','loc','company'])),methods:{onSuggestShown:function(){this.sync()},sync:function(){var _this=this;this.syncing=!0;this.times=[];app.fetch('/timeframe/getPickup',{},function(response){_this.syncing=!1;if(!response.error){_this.times=response.times}})},onSelected:function(time){this.timeframe.activePickupTime=time.id;this.timeframe.activePickupTimeName=time.name;this.$root.recalc()}},template:'#pickup__template'};app.cartTimeframeComponent={components:{'cart-preorder':app.cartPreorderComponent,'cart-pickup':app.cartPickupComponent},computed:Object.assign({isVisible(){if(this.company.isAirport){return!1}
if(this.address.type==='inside'){if(!this.company.cartEatInPreorderVisible){return!1}}
if(this.address.type==='drive'){if(!this.company.cartDrivePreorderVisible){return!1}}
return!0},timeframe:function(){return this.cart.timeframe},types:function(){var res=[];var types=this.timeframe.types;types=[types.now,types.preorder];for(var i=0;i<types.length;i++){res.push({name:types[i].name,id:types[i].id,off:types[i].off,selected:types[i].id===this.timeframe.activeType})}
return res},title:function(){return this.timeframe.needPreorderMessage},typesVisible:function(){if(this.address.type==='inside'){return!1}
if(this.timeframe.types.now.off||this.timeframe.types.preorder.off){return!1}
return!0}},Vuex.mapState(['cart','address','company'])),methods:{selectType:function(type){if(!type.off){this.timeframe.activeType=type.id;this.$root.recalc()}}},template:'#cpre__template'};app.cartComment2Component={data(){return{isFocus:!1,timer:null,comment:this.$store.state.cart.comment}},computed:{...Vuex.mapState(['cart','loc']),maxLength(){return 500},caption(){return this.loc['cart/comment']},isActive(){return this.isFocus||this.comment.trim()},blanks(){if(!this.cart.commentSnippets){return null}
const commentFormatted=this.comment.toLowerCase();return this.cart.commentSnippets.filter(({name})=>!commentFormatted.includes(name.toLowerCase()))}},methods:{toggleFocus(flag){this.isFocus=flag},addBlank(text){if(this.comment.trim().length){this.comment+='\n'}else{this.comment=''}
this.comment+=text;this.$nextTick(()=>{this.$refs.textarea.dispatchEvent(new Event('input',{bubbles:!1}));this.$refs.textarea.focus();this.save()})},save(){clearTimeout(this.timer);this.$root.recalc()},focusComment(){this.$refs.textarea.focus()},onInput(){this.cart.comment=this.comment;clearTimeout(this.timer);this.timer=setTimeout(()=>{this.save()},400)},onMousedown(e){if(e.target.closest('.cComment__textarea')){return}
e.preventDefault()}},directives:{autogrow:{inserted(el){el._autogrow=app.autogrow(el)}},spoiler(el){setTimeout(()=>{el.style.height=el.firstElementChild.offsetHeight+16+'px'},0)},},template:`
    <div class="cComment" @click="focusComment" @mousedown="onMousedown">
    
        <div class="cComment__text" 
             :class="{'cComment__text--active': isActive}">
             <textarea ref="textarea" 
                       v-model="comment"
                       class="cComment__textarea"
                       rows="1"
                       :maxlength="maxLength"
                       @focus="toggleFocus(true)"
                       @blur="toggleFocus(false)"
                       @input="onInput"
                       v-autogrow></textarea>
            <div class="cComment__caption">{{ caption }}</div>
        </div>
        
        <div class="cComment__blanks" v-spoiler>
            <transition-group name="cComment__list" tag="div" class="cComment__list">
                <div v-for="blank of blanks"
                     :key="blank.id"
                     class="cComment__blank"
                     @click.stop="addBlank(blank.value || blank.name)">{{ blank.name }}</div>
            </transition-group>
        </div>
        
    </div>
    
    `};app.cartCommentComponent={data:function(){return{comment:this.$store.state.cart.comment}},computed:Object.assign('cart',{maxLength:function(){return 500},locComment:function(){return this.loc['cart/comment']}},Vuex.mapState(['cart','loc'])),directives:{autogrow:{inserted(el){el._autogrow=app.autogrow(el)}}},methods:{onInput:function(){this.cart.comment=this.comment;this.$root.recalc()}},template:`
    
    <div class="ctinput__wrap ccm">
        <div class="ctinput__caption">{{locComment}}</div>
        <textarea class="ctinput"
                  name="comment"
                  v-model="comment"
                  :maxlength="maxLength"
                  v-autogrow
                  @input="onInput()"></textarea>
    </div>
    
    `};app.cartEmailComponent={data(){return{email:(this.$store.state.cart&&this.$store.state.cart.email)||''}},computed:Object.assign({isVisible(){return this.company.cartEmailAppearance==='onlinePaymentOnly'&&this.cart.payment.activeType==='online'}},Vuex.mapState(['company','cart'])),methods:{onInput(){this.cart.email=this.email;this.$root.recalc()}},template:'#cemail__template'};app.cartPolicyComponent={inject:['store'],computed:Object.assign({isVisible:function(){return this.company.isOfferRequired},selected:function(){return this.cart.policy},text:function(){return this.loc['cart/terms']}},Vuex.mapState(['cart','company','loc'])),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.cart.policy=!this.cart.policy;this.$root.recalc()}}},template:'#cpol__template'};app.cartCallmeComponent={inject:['store'],data(){return{checkboxInitialized:!1}},mounted(){setTimeout(()=>{this.checkboxInitialized=!0},500)},computed:Object.assign({isVisible(){return this.company.cartCallMeAppearance==='doNotCall'},selected(){return this.cart.callme},text(){return this.loc['cart/callme/doNotCall']}},Vuex.mapState(['cart','company','loc'])),methods:{toggle(){this.cart.callme=!this.cart.callme;this.$root.recalc()}},template:'#callme__template'};app.cartAirportComponent={components:{'cart-suggest':app.cartSuggestComponent},data:function(){return{firstName:this.$store.state.cart.airport?this.$store.state.cart.airport.firstName:'',lastName:this.$store.state.cart.airport?this.$store.state.cart.airport.lastName:'',flightNumber:this.$store.state.cart.airport?this.$store.state.cart.airport.flightNumber:'',arrivalDateTime:this.$store.state.cart.airport?this.$store.state.cart.airport.arrivalDateTime:'',messengerName:this.$store.state.cart.airport?this.$store.state.cart.airport.messengerName:'',messengerPhone:this.$store.state.cart.airport?this.$store.state.cart.airport.messengerPhone:'',messengers:[{id:'whatsapp',name:'WhatsApp'},{id:'telegram',name:'Telegram'},]}},computed:Object.assign({isVisible(){return this.company.isAirport},locFlightNumber(){return this.loc['cart/flightNumber']},locArrivalDateTime(){return this.loc['cart/arrivalDateTime']},locMessengerPhoneNumber(){return this.loc['cart/messengerPhoneNumber']},locMessengerName(){return this.loc['cart/messengerName']},locName:function(){return this.loc['cart/yourname']},locLastName(){return this.loc['cart/lastName']},locPhone:function(){return this.loc['cart/yourphone']}},Vuex.mapState(['cart','loc','company'])),methods:{onMessengerSelected(messenger){this.messengerName=messenger.name;this.onInput()},onInput:function(){this.cart.airport.firstName=this.firstName;this.cart.airport.lastName=this.lastName;this.cart.airport.flightNumber=this.flightNumber;this.cart.airport.arrivalDateTime=this.arrivalDateTime;this.cart.airport.messengerPhone=this.messengerPhone;this.cart.airport.messengerName=this.messengerName;this.$root.recalc()}},template:'#cair__template'};app.cartRecipientComponent={components:{cartBlock:app.cartBlockComponent,cartInput:app.cartInputComponent},computed:Object.assign({isVisible(){return this.company.useRecipient&&this.cart.delivery.activeType==='courier'},locTitle(){return this.loc['cart/recipient/title']},locSub(){return this.loc['cart/recipient/sub']},locName(){return this.loc['cart/recipient/name']},locPhone(){return this.loc['cart/recipient/phone']},locText(){return this.loc['cart/recipient/text']}},Vuex.mapState(['cart','loc','company'])),methods:{onInput(){this.$root.recalc()}},template:`

    <cartBlock v-if="isVisible" 
        :title="locTitle" 
        :description="locSub" 
        v-model="cart.recipient.active" 
        @input="onInput"
        withToggle="true">
   
        <div class="ctblock__item">
            <cartInput :caption="locName" name="name" v-model="cart.recipient.name" @input="onInput"/>
        </div>

        <div class="ctblock__item">
            <cartInput :caption="locPhone" inputmode="tel" name="phone" v-model="cart.recipient.phone" @input="onInput"/>
        </div>

        <div class="ctblock__item">
            <cartInput :caption="locText" name="text" v-model="cart.recipient.text" @input="onInput"/>
        </div>
    
    </cartBlock>

    
    `};app.cartScreenFormComponent={components:{'cart-header':app.cartHeaderComponent,'cart-footer':app.cartFooterComponent,'cart-address':app.cartFormAddressComponent,'cart-restaurant':app.cartRestaurantComponent,'cart-inside':app.cartInsideComponent,'cart-drive':app.cartDriveComponent,'cart-client':app.cartClientComponent,'cart-payment':app.cartPaymentComponent,'cart-timeframe':app.cartTimeframeComponent,'cart-contactless':app.cartContactlessComponent,'cart-comment':app.cartCommentComponent,'cart-comment2':app.cartComment2Component,'cart-stadium':app.cartStadiumComponent,'cart-airport':app.cartAirportComponent,'cart-recipient':app.cartRecipientComponent,'cart-policy':app.cartPolicyComponent,'cart-callme':app.cartCallmeComponent,'cart-email':app.cartEmailComponent},computed:Object.assign({title(){var activeType=this.address&&this.address.type;var title=this.loc['cart/delivery'];if(activeType==='pickup'){if(this.company.isAirport){title=this.loc['tab/cart']}else{title=this.loc['cart/pickup']}}else if(activeType==='inside'){title=this.loc['cart/inside']}else if(activeType==='drive'){title=this.loc['cart/drive']}
return title},submitText(){return this.loc['btn/order']},isShowNewComment(){return this.$store.state.cart.commentSnippets}},Vuex.mapState(['cart','address','loc','company'])),methods:{navigateBack(){this.$root.navigate('dishes')},submit(){this.$root.order()}},template:`
    <div class="csform">

        <cart-header :title="title"
                     back="true"
                     @back="navigateBack()"/>

        <div class="csform__content">
            <cart-address/>
            <cart-restaurant/>
            <cart-client/>
            <cart-recipient/>
            <cart-airport/>
            <cart-timeframe/>
            <cart-contactless/>
            <cart-payment/>
            <cart-email/>
            <cart-inside/>
            <cart-drive/>
            <cart-stadium/>
            <cart-comment2 v-if="isShowNewComment"/>
            <cart-comment v-else/>
            <cart-callme/>
            <cart-policy/>
        </div>

        <cart-footer :text="submitText"
                     withTotal="true"
                     @submit="submit()"/>

    </div>
    
    `};app.cartScreenSmsComponent={components:{'cart-header':app.cartHeaderComponent,'cart-footer':app.cartFooterComponent},inject:['store'],data:function(){return{timer:null,smsCode:''}},created:function(){this.storeSmsDateSent(this.store.smsDateSent)},computed:Object.assign({secondsLeft:function(){var seconds=this.store.smsSecondsLeft;if(seconds<=0){return null}
seconds=seconds<10?'00:0'+seconds:'00:'+seconds;return this.loc['phone/sms-sent2'].replace('{seconds}',seconds)},title:function(){return this.loc['cart/sms/title']},locPhone:function(){return this.loc['cart/yourphone']},locCode:function(){return this.loc['auth/code']},locReceived:function(){return this.loc['auth/repeat']},locRepeat:function(){return this.loc['auth/repeat2']},locConfirm:function(){return this.loc['btn/confirm']}},Vuex.mapState(['cart','loc'])),directives:{counter:{bind:function(el,binding,node){node.context.counting()},unbind:function(el,binding,node){clearTimeout(node.context.timer)}}},methods:{navigateBack:function(){this.$root.navigate('form')},storeSmsDateSent:function(smsDateSent){this.cart.client.smsDateSent=smsDateSent;app.updateStore({cart:this.cart})},counting:function(){this.store.smsSecondsLeft-=1;var _this=this;if(this.store.smsSecondsLeft>0){this.timer=setTimeout(function(){_this.counting()},1000)}},repeat:function(){var _this=this;this.$root.order({smsRepeat:!0,smsCode:this.smsCode,cb:function(response){_this.store.smsSecondsLeft=response.smsSecondsLeft}})},onPhoneInput:function(){this.$root.recalc()},onCodeInput:function(){if(this.smsCode.length===4){this.submit()}},submit:function(){this.$root.order({smsCode:this.smsCode})}},template:'#ctsms__template'};app.cartMerchantTypeComponent={props:['type'],computed:Object.assign({isCard:function(){return!!this.type.info},brand:function(){return this.type.info.brand},prefix:function(){return this.type.info.first6.substr(0,4)},name:function(){if(this.type.name){return this.type.name}
return this.type.info.last4},removeButtonVisible:function(){return this.type.info},selected:function(){return this.type.id===this.cart.merchant.activeType}},Vuex.mapState(['cart','loc'])),methods:{select:function(){this.cart.merchant.activeType=this.type.id;this.$root.recalc();this.$root.navigate('form')},remove:function(){if(!window.confirm(this.loc['cart/onlinePayment/deleteCard'])){return}
this.$parent.removeType(this.type)}},template:'#cmtype__template'};app.cartScreenMerchantComponent={components:{'cart-header':app.cartHeaderComponent,'cart-merchant-type':app.cartMerchantTypeComponent,'cart-spinner':app.cartSpinnerComponent},data:function(){return{loading:!1}},computed:Object.assign({types:function(){return this.cart.merchant.types}},Vuex.mapState(['cart'])),methods:{removeType:function(type){var _this=this;var payload={id:type.id};this.loading=!0;app.fetch('/merchant/card/remove',payload,function(){_this.$root.recalc({cb:function(){_this.loading=!1}})})},navigateBack:function(){this.$root.navigate('form')},},template:'#ctmerch__template'};app.addModule(function(){const show=function(){if(app.store.state.address&&app.store.state.address.warning){PubSub.publish('showUserAddress');return}
let addressChanged=!1;const vr=app.viewer({bgClose:!0,'class':'cart__viewer',html:'<div id="cart__module"></div>',onClose(){if(addressChanged){window.location.reload()}}});new Vue({components:{'cart-spinner':app.cartSpinnerComponent,'cart-screen-empty':app.cartScreenEmptyComponent,'cart-screen-dishes':app.cartScreenDishesComponent,'cart-screen-form':app.cartScreenFormComponent,'cart-screen-success':app.cartScreenSuccessComponent,'cart-screen-merchant':app.cartScreenMerchantComponent,'cart-screen-sms':app.cartScreenSmsComponent},provide(){return{store:this.store}},data(){return{store:{address:null,activeScreen:'dishes',activeScreenArgs:null,ordering:!1,successText:'',successId:'',smsDateSent:0,smsSecondsLeft:0}}},mounted(){PubSub.subscribe('addressChanged',()=>{addressChanged=!0})},computed:Object.assign({activeScreenComputed:function(){if(['success','loading'].indexOf(this.store.activeScreen)!==-1){return this.store.activeScreen}
var dishes=(this.cart&&this.cart.dishes)||[];dishes=dishes.filter(function(item){return item.num>0});if(!dishes.length){if(this.cartLoading){return'loading'}
return'empty'}
return this.store.activeScreen}},Vuex.mapState(['cart','cartLoading','loc','company'])),methods:{close(){vr.close()},clear(){var _this=this;this.store.activeScreen='loading';this.cart.dishes=[];this.recalc({clear:!0,cb:function(){_this.store.activeScreen='dishes'}});app.updateStore({cart:null})},navigate:function(screen,args){this.store.activeScreenArgs=args||null;this.store.activeScreen=screen},getFormData:function(){if(!this.cart){return null}
var formData=JSON.parse(JSON.stringify(this.cart));delete formData.timeframe.daysPreorder;delete formData.timeframe.needPreorderMessage;delete formData.timeframe.types;return formData},recalc:function(params){PubSub.publish('recalcCart',{formData:this.getFormData(),clear:params&&params.clear,cb:params&&params.cb})},order:function(params){let _this=this;this.store.ordering=!0;let payload={smsCode:(params&&params.smsCode)||'',smsRepeat:!!(params&&params.smsRepeat),screen:this.store.activeScreen,cutleryVisible:this.company.cutleryVisible,eatInTableNumberHidden:this.company.cartEatInTableNumberHidden,cartEatInPreorderVisible:this.company.cartEatInPreorderVisible,cartHidePhoneInQr:this.company.cartHidePhoneInQr,activeTimeframeType:this.cart.timeframe.activeType};app.fetch('/cart/order2',payload,function(response){if(response.error){_this.store.ordering=!1;app.alert(response.message,'danger');return}
if(response.needConfirmPhone){_this.store.ordering=!1;_this.store.smsSecondsLeft=response.smsSecondsLeft;_this.store.smsDateSent=response.smsDateSent;_this.navigate('sms')}else{PubSub.publish('gtmNotify',{event:'purchase',value:parseInt(_this.cart.amount.total/10000),cart:_this.cart});if(response.paymentUrl){setTimeout(function(){window.location.assign(response.paymentUrl)},1500)}else if(response.kaspiUrl){setTimeout(function(){window.location.assign(response.kaspiUrl)},1500)}else{_this.store.ordering=!1;app.updateStore({cart:null});_this.store.successText=response.successText;_this.store.successId=response.id;_this.navigate('success')}}})},addressName:function(address,format){var name=[];if(address.city){if(['cityStreetHouse','full'].indexOf(format)>=0){name.push(address.city)}}
if(['cityStreetHouse','withoutCity','full','streetHouse'].indexOf(format)>=0){if(address.district){name.push(address.district)}
if(address.street){var street=address.street;street=street.replace('улица','ул.').replace('проезд ','пр-д ').replace(' проезд',' пр-д').replace('переулок','пер.').replace('набережная','наб.').replace('площадь','пл.').replace('шоссе','ш.').replace('проспект','пр-т');name.push(street)}else{if(format==='streetHouse'&&address.city&&address.house){name.push(address.city)}}}
if(address.house){if(['cityStreetHouse','withoutCity','full','streetHouse'].indexOf(format)>=0){name.push(address.house)}}
if(address.flat){if(['withoutCity','full'].indexOf(format)>=0){name.push(this.loc['cart/address/room'].toLowerCase()+' '+address.flat)}}
if(address.entrance){if(['withoutCity','full'].indexOf(format)>=0){name.push(this.loc['cart/address/entrance'].toLowerCase()+' '+address.entrance)}}
if(address.floor){if(['withoutCity','full'].indexOf(format)>=0){name.push(this.loc['cart/address/floor'].toLowerCase()+' '+address.floor)}}
if(!name.length){return address.name}
name=name.join(', ');name=name.substr(0,1).toUpperCase()+name.substr(1);return name}},store:app.store,el:'#cart__module',template:'#cart__template'})};PubSub.subscribe('showCart',show)})