@perevorot/shop 2.0.121 → 2.0.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),r=require("@perevorot/shop/dist/api"),o=require("simplebar"),n=require("secure-ls");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=a(o),c=a(n);var i=e.defineComponent({name:"search",props:{q:{type:String,default:""},placeholder:{type:String,default:""},placeholderMobile:{type:String,default:""},parameter:{type:String,default:"/q{separator}"},isHistory:{type:Boolean,default:!0},isToggleDropdownOnClose:{type:Boolean,default:!0},htmlClass:{type:String,default:""}},setup:function(o){var n=new c.default({isCompression:!1}),a=o.q;if(a){var i=document.createElement("textarea");i.innerHTML=a,a=i.value}var s=e.ref(!1),d=e.ref(a),u=e.ref([]),p=e.ref([]),m=e.ref(0),h=e.ref(-1),v=e.ref(!1),f=e.ref(),y=e.ref(""),g=e.ref(),w=e.ref(n.get("search")),k=e.ref([]),E=t.useStore(),C=e.computed((function(){return E.getters["auth/me"]})),B=e.ref(null),V=[],N=!1,_=function(){clearTimeout(void 0),h.value=-1,d.value.trim()?(s.value=!0,d.value.trim()&&r.shop.search(d.value).then((function(t){if(t.data){if(L(),u.value=t.data.products,m.value=t.data.total,y.value=t.data.separator,p.value=t.data.byCategory,new l.default(g.value),!N&&v.value){N=!0;var r={event:"search_start"};$env.debug.ecommerce&&console.log(r),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(r))}if(!u.value.length&&!M.value.length&&v.value){var o={event:"search_no_results",search_query:d.value};$env.debug.ecommerce&&console.log(o),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(o))}e.nextTick((function(){window.promoCodeCallback&&"function"==typeof window.promoCodeCallback&&window.promoCodeCallback(B.value,".dropdown-item:not(.products-list-title)")}))}})).finally((function(){s.value=!1}))):(u.value=[],s.value=!1)},L=function(){if(d.value.length>1){var e=n.get("search")?n.get("search"):[];-1!==e.indexOf(d.value)&&(e=e.filter((function(e){return e!==d.value}))),e.length>4&&(e=e.slice(0,4)),e.unshift(d.value),n.set("search",e),w.value=e}};e.onBeforeUpdate((function(){V=[]})),e.watch((function(){return d.value}),(function(){v.value=!0,h.value=-1,_()}));var S=e.computed((function(){return d.value?$env.locale.url+"/search"+D.value:$env.locale.url+"/search"})),D=e.computed((function(){return o.parameter.replace("{separator}",y.value)+d.value.toLowerCase()})),b=function(e){e.target.closest(".cart")||(o.isToggleDropdownOnClose&&(v.value=!1,o.htmlClass&&document.querySelector("html").classList.remove(o.htmlClass)),h.value=-1)};window.addEventListener("click",b);var q,M=e.computed((function(){return d.value.length>3?k.value.filter((function(e){return-1!==e.search.indexOf(d.value)})):[]})),x=(q=function(){var e,t,r,n=document.getElementById("menu");return n&&n.querySelectorAll("[data-search]").forEach((function(e){var t=e.textContent.trim(),r=e.dataset.search;k.value.push({name:(r?r+" / ":"")+t,search:t.toLowerCase(),href:e.closest("a").href})})),o.q&&_(),r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(q.apply(this,e))}catch(e){return Promise.reject(e)}});document.addEventListener("DOMContentLoaded",x,!1);var H=e.ref(o.placeholder);if(o.placeholderMobile){var T=function(){var e=window.matchMedia("(max-width: 768px)").matches;H.value=e?o.placeholderMobile:o.placeholder};window.addEventListener("resize",T,{passive:!0}),T()}return{isLoading:s,term:d,results:u,next:function(){h.value<u.value.length-1&&h.value++},prev:function(){h.value>=0&&h.value--},current:h,add:function(e){h.value>=0&&(e.preventDefault(),V[h.value].add())},cartRefs:function(e){e&&V.push(e)},isDropdown:v,preventCaret:function(e){(38==e.which||40==e.which||32==e.which&&h.value>=0)&&e.preventDefault()},esc:function(e){f.value.blur(),b(e)},input:f,dropdown:function(){v.value=!0,h.value=-1,o.htmlClass&&document.querySelector("html").classList.add(o.htmlClass)},total:m,searchUrl:S,searchHrefWithParameter:D,open:function(){h.value>=0?window.location.href=u.value[h.value].href:window.location.href=S.value},categories:M,byCategory:p,dropdownContent:g,history:w,clearSearchHistory:function(e){n.remove("search"),w.value=[],f.value.focus()},setSearchHistory:function(e){e.value=e},user:C,clear:function(){d.value="",f.value.focus()},placeholderMobilized:H,opener:function(e,t,r){!function(e,t){var r={event:"search_success",search_query:d.value,search_type:e,eventCallback:t};$env.debug.ecommerce&&console.log(r),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(r)),window.dataLayer&&!$env.debug.ecommerce||t&&setTimeout(t,300)}(t,r||function(){e&&(window.location.href=e)})},productsListElement:B}}}),s={class:"dropdown-trigger"},d=["placeholder"],u={class:"icon is-small is-right"},p=[e.createElementVNode("i",{class:"fas fa-search"},null,-1)],m={key:1,class:"dropdown-menu"},h={class:"dropdown-content"},v={class:"history-list"},f={class:"dropdown-item history-list-title"},y=["onClick"],g={class:"dropdown-item history-list-clear"},w={class:"dropdown-menu"},k={class:"dropdown-content",style:{"max-height":"600px",overflow:"auto"},ref:"dropdownContent"},E={key:0,class:"results-list"},C=["href","onClick"],B={key:0,class:"dropdown-divider"},V={key:1,class:"results-list-category"},N={class:"dropdown-item categories-list-title"},_=["href","onClick"],L={key:2,class:"results-list-total"},S={class:"dropdown-item mb-3 mt-2"},D=e.createElementVNode("br",null,null,-1),b=["href"],q={key:3,class:"products-list",ref:"productsListElement"},M={class:"dropdown-item products-list-title"},x={class:"columns"},H={class:"column"},T={class:"title"},$=["href","onClick"],P=["innerHTML"],K={key:0,class:"price_old"},z=["innerHTML"],O={class:"code"},W={key:1,class:"quantity"},F={key:2,class:"no-quantity"},R={key:0,class:"column is-narrow"},U={key:1,class:"column is-eol"},j={key:0,class:"dropdown-content"},A={class:"dropdown-item"},I=["innerHTML"];i.render=function(t,r,o,n,a,l){var c=e.resolveComponent("cart-add");return e.openBlock(),e.createElementBlock("div",{class:"shop-search",onClick:r[10]||(r[10]=function(e){return e.stopPropagation()})},[e.createElementVNode("div",{class:e.normalizeClass(["dropdown",{"is-active":t.isDropdown,"is-dropdown-visible":t.isDropdown&&(t.history.length&&!t.term||t.results.length||t.categories.length||t.term&&!t.isLoading&&!t.results.length&&!t.categories.length)}])},[t.htmlClass?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:"overlay search-overlay",onClick:r[0]||(r[0]=function(e){return t.esc(e)})})),e.createElementVNode("div",s,[e.createElementVNode("div",{class:e.normalizeClass(["control has-icons-right",{"is-loading":t.isLoading}])},[e.withDirectives(e.createElementVNode("input",{class:"input",type:"text","onUpdate:modelValue":r[1]||(r[1]=function(e){return t.term=e}),ref:"input",placeholder:t.placeholderMobilized,onKeyup:[r[2]||(r[2]=e.withKeys((function(){return t.next&&t.next.apply(t,arguments)}),["arrow-down"])),r[3]||(r[3]=e.withKeys((function(){return t.prev&&t.prev.apply(t,arguments)}),["arrow-up"])),r[4]||(r[4]=e.withKeys((function(e){return t.add(e)}),["space"])),r[5]||(r[5]=e.withKeys((function(e){return t.opener(null,"results_page",t.open)}),["enter"])),r[6]||(r[6]=e.withKeys((function(e){return t.esc(e)}),["esc"]))],onClick:r[7]||(r[7]=function(){return t.dropdown&&t.dropdown.apply(t,arguments)}),onKeydown:r[8]||(r[8]=function(e){return t.preventCaret(e)})},null,40,d),[[e.vModelText,t.term]]),e.renderSlot(t.$slots,"clear",{clear:t.clear,term:t.term}),e.renderSlot(t.$slots,"icon",{isLoading:t.isLoading},(function(){return[e.withDirectives(e.createElementVNode("span",u,p,512),[[e.vShow,!t.isLoading]])]}))],2)]),t.isHistory&&t.isDropdown&&t.history.length&&!t.term?(e.openBlock(),e.createElementBlock("div",m,[e.createElementVNode("div",h,[e.createElementVNode("div",v,[e.createElementVNode("div",f,[e.createElementVNode("p",null,e.toDisplayString(t.__("shop.search.history")),1)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.history,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.createElementVNode("a",{onClick:function(e){return t.term=r}},e.toDisplayString(r),9,y)])})),128)),e.createElementVNode("div",g,[e.createElementVNode("a",{onClick:r[9]||(r[9]=function(e){return t.clearSearchHistory(e)})},e.toDisplayString(t.__("shop.search.history_clear")),1)])])])])):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("div",w,[e.withDirectives(e.createElementVNode("div",k,[e.renderSlot(t.$slots,"results-header"),t.categories.length?(e.openBlock(),e.createElementBlock("div",E,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.categories,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href,onClick:e.withModifiers((function(e){return t.opener(r.href,"category")}),["prevent"])},e.toDisplayString(r.name),9,C)])])})),128)),t.byCategory.length?(e.openBlock(),e.createElementBlock("hr",B)):e.createCommentVNode("v-if",!0)])):e.createCommentVNode("v-if",!0),t.byCategory.length?(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",N,e.toDisplayString(t.__("shop.search.categories")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.byCategory,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.renderSlot(t.$slots,"item-category",{item:r,searchHrefWithParameter:t.searchHrefWithParameter,opener:t.opener},(function(){return[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href+t.searchHrefWithParameter,onClick:e.withModifiers((function(e){return t.opener(r.href+t.searchHrefWithParameter,"category")}),["prevent"])},e.toDisplayString(r.name),9,_)]),e.createElementVNode("div",null,e.toDisplayString(t.__("shop.search.category_found",{count:r.count})),1)]}))])})),128))])):e.createCommentVNode("v-if",!0),t.total?(e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("p",S,[e.createTextVNode(e.toDisplayString(t.__("shop.search.total_found",{total:t.total}))+" ",1),D,e.createElementVNode("a",{href:t.searchUrl},e.toDisplayString(t.__("shop.search.open_results")),9,b)])])):e.createCommentVNode("v-if",!0),t.results.length?(e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",M,e.toDisplayString(t.__("shop.search.products")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.results,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["dropdown-item",{"is-active":t.current==o}]),key:r.id},[e.renderSlot(t.$slots,"item",{user:t.user,item:r,cartRefs:t.cartRefs,opener:t.opener},(function(){return[e.createElementVNode("div",x,[e.createElementVNode("div",H,[e.createElementVNode("div",T,[e.createElementVNode("a",{href:r.href,onClick:e.withModifiers((function(e){return t.opener(r.href,"product")}),["prevent"])},e.toDisplayString(r.name),9,$)]),e.createElementVNode("div",{class:"price",innerHTML:r.price},null,8,P),r.price_old?(e.openBlock(),e.createElementBlock("div",K,[e.createElementVNode("span",{innerHTML:r.price_old},null,8,z)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",O,e.toDisplayString(r.code),1),r.quantity?(e.openBlock(),e.createElementBlock("div",W,e.toDisplayString(t.__("shop.search.in_stock")),1)):(e.openBlock(),e.createElementBlock("span",F,e.toDisplayString(t.__("shop.search.out_stock")),1))]),r.is_eol?(e.openBlock(),e.createElementBlock("div",U,e.toDisplayString(t.__("shop.search.eol")),1)):(e.openBlock(),e.createElementBlock("div",R,[e.createVNode(c,{id:r.id,"is-change-quantity":!1,"is-already-in-cart":!1,ref_for:!0,ref:t.cartRefs},null,8,["id"])]))])]}))],2)})),128))],512)):e.createCommentVNode("v-if",!0)],512),[[e.vShow,t.results.length||t.categories.length]]),t.isLoading||t.results.length||t.categories.length?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",A,[e.createElementVNode("div",{class:"no-results",innerHTML:t.__("shop.search.no_results")},null,8,I)])]))],512),[[e.vShow,t.results.length||t.term]])],2)])},module.exports=i;
1
+ "use strict";var e=require("vue"),t=require("vuex"),r=require("@perevorot/shop/dist/api"),o=require("simplebar"),n=require("secure-ls");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=l(o),c=l(n);var i=e.defineComponent({name:"search",props:{q:{type:String,default:""},placeholder:{type:String,default:""},placeholderMobile:{type:String,default:""},parameter:{type:String,default:"/q{separator}"},isHistory:{type:Boolean,default:!0},isToggleDropdownOnClose:{type:Boolean,default:!0},htmlClass:{type:String,default:""}},setup:function(o){var n=new c.default({isCompression:!1}),l=o.q;if(l){var i=document.createElement("textarea");i.innerHTML=l,l=i.value}var s=e.ref(!1),u=e.ref(l),d=e.ref([]),p=e.ref([]),m=e.ref(0),h=e.ref(-1),v=e.ref(!1),f=e.ref(),y=e.ref(""),g=e.ref(),w=e.ref(n.get("search")),k=e.ref([]),E=t.useStore(),C=e.computed((function(){return E.getters["auth/me"]})),B=e.ref(null),V=[],N=!1,_=function(){clearTimeout(void 0),h.value=-1,u.value.trim()?(s.value=!0,u.value.trim()&&r.shop.search(u.value).then((function(t){if(t.data){if(L(),d.value=t.data.products,m.value=t.data.total,y.value=t.data.separator,p.value=t.data.byCategory,new a.default(g.value),!N&&v.value){N=!0;var r={event:"search_start"};$env.debug.ecommerce&&console.log(r),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(r))}if(!d.value.length&&!M.value.length&&v.value){var o={event:"search_no_results",search_query:u.value};$env.debug.ecommerce&&console.log(o),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(o))}e.nextTick((function(){window.promoCodeCallback&&"function"==typeof window.promoCodeCallback&&window.promoCodeCallback(B.value,".dropdown-item:not(.products-list-title)")}))}})).finally((function(){s.value=!1}))):(d.value=[],s.value=!1)},L=function(){if(u.value.length>1){var e=n.get("search")?n.get("search"):[];-1!==e.indexOf(u.value)&&(e=e.filter((function(e){return e!==u.value}))),e.length>4&&(e=e.slice(0,4)),e.unshift(u.value),n.set("search",e),w.value=e}};e.onBeforeUpdate((function(){V=[]})),e.watch((function(){return u.value}),(function(){v.value=!0,h.value=-1,_()}));var S=e.computed((function(){return u.value?$env.locale.url+"/search"+D.value:$env.locale.url+"/search"})),D=e.computed((function(){return o.parameter.replace("{separator}",y.value)+u.value.toLowerCase()})),b=function(e){e.target.closest(".cart")||(o.isToggleDropdownOnClose&&(v.value=!1,o.htmlClass&&document.querySelector("html").classList.remove(o.htmlClass)),h.value=-1)};window.addEventListener("click",b);var q,M=e.computed((function(){return u.value.length>3?k.value.filter((function(e){return-1!==e.search.indexOf(u.value)})):[]})),x=(q=function(){var e,t,r,n=document.getElementById("menu");return n&&n.querySelectorAll("[data-search]").forEach((function(e){var t=e.textContent.trim(),r=e.dataset.search;k.value.push({name:(r?r+" / ":"")+t,search:t.toLowerCase(),href:e.closest("a").href})})),o.q&&_(),r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(q.apply(this,e))}catch(e){return Promise.reject(e)}});document.addEventListener("DOMContentLoaded",x,!1);var H=e.ref(o.placeholder);if(o.placeholderMobile){var T=function(){var e=window.matchMedia("(max-width: 768px)").matches;H.value=e?o.placeholderMobile:o.placeholder};window.addEventListener("resize",T,{passive:!0}),T()}return{isLoading:s,term:u,results:d,next:function(){h.value<d.value.length-1&&h.value++},prev:function(){h.value>=0&&h.value--},current:h,add:function(e){h.value>=0&&(e.preventDefault(),V[h.value].add())},cartRefs:function(e){e&&V.push(e)},isDropdown:v,preventCaret:function(e){(38==e.which||40==e.which||32==e.which&&h.value>=0)&&e.preventDefault()},esc:function(e){f.value.blur(),b(e)},input:f,dropdown:function(){v.value=!0,h.value=-1,o.htmlClass&&document.querySelector("html").classList.add(o.htmlClass)},total:m,searchUrl:S,searchHrefWithParameter:D,open:function(){h.value>=0?window.location.href=d.value[h.value].href:window.location.href=S.value},categories:M,byCategory:p,dropdownContent:g,history:w,clearSearchHistory:function(e){n.remove("search"),w.value=[],f.value.focus()},setSearchHistory:function(e){e.value=e},user:C,clear:function(){u.value="",f.value.focus()},placeholderMobilized:H,opener:function(e,t,r){!function(e){var t={event:d.value.length||M.value.length?"search_success":"search_no_results",search_query:u.value,search_type:e};$env.debug.ecommerce&&console.log(t),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t))}(t),"function"==typeof r&&r()},productsListElement:B}}}),s={class:"dropdown-trigger"},u=["placeholder"],d={class:"icon is-small is-right"},p=[e.createElementVNode("i",{class:"fas fa-search"},null,-1)],m={key:1,class:"dropdown-menu"},h={class:"dropdown-content"},v={class:"history-list"},f={class:"dropdown-item history-list-title"},y=["onClick"],g={class:"dropdown-item history-list-clear"},w={class:"dropdown-menu"},k={class:"dropdown-content",style:{"max-height":"600px",overflow:"auto"},ref:"dropdownContent"},E={key:0,class:"results-list"},C=["href","onClick"],B={key:0,class:"dropdown-divider"},V={key:1,class:"results-list-category"},N={class:"dropdown-item categories-list-title"},_=["href","onClick"],L={key:2,class:"results-list-total"},S={class:"dropdown-item mb-3 mt-2"},D=e.createElementVNode("br",null,null,-1),b=["href"],q={key:3,class:"products-list",ref:"productsListElement"},M={class:"dropdown-item products-list-title"},x={class:"columns"},H={class:"column"},T={class:"title"},$=["href","onClick"],P=["innerHTML"],K={key:0,class:"price_old"},z=["innerHTML"],O={class:"code"},W={key:1,class:"quantity"},F={key:2,class:"no-quantity"},R={key:0,class:"column is-narrow"},U={key:1,class:"column is-eol"},j={key:0,class:"dropdown-content"},A={class:"dropdown-item"},I=["innerHTML"];i.render=function(t,r,o,n,l,a){var c=e.resolveComponent("cart-add");return e.openBlock(),e.createElementBlock("div",{class:"shop-search",onClick:r[10]||(r[10]=function(e){return e.stopPropagation()})},[e.createElementVNode("div",{class:e.normalizeClass(["dropdown",{"is-active":t.isDropdown,"is-dropdown-visible":t.isDropdown&&(t.history.length&&!t.term||t.results.length||t.categories.length||t.term&&!t.isLoading&&!t.results.length&&!t.categories.length)}])},[t.htmlClass?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:"overlay search-overlay",onClick:r[0]||(r[0]=function(e){return t.esc(e)})})),e.createElementVNode("div",s,[e.createElementVNode("div",{class:e.normalizeClass(["control has-icons-right",{"is-loading":t.isLoading}])},[e.withDirectives(e.createElementVNode("input",{class:"input",type:"text","onUpdate:modelValue":r[1]||(r[1]=function(e){return t.term=e}),ref:"input",placeholder:t.placeholderMobilized,onKeyup:[r[2]||(r[2]=e.withKeys((function(){return t.next&&t.next.apply(t,arguments)}),["arrow-down"])),r[3]||(r[3]=e.withKeys((function(){return t.prev&&t.prev.apply(t,arguments)}),["arrow-up"])),r[4]||(r[4]=e.withKeys((function(e){return t.add(e)}),["space"])),r[5]||(r[5]=e.withKeys((function(e){return t.opener(null,"results_page",t.open)}),["enter"])),r[6]||(r[6]=e.withKeys((function(e){return t.esc(e)}),["esc"]))],onClick:r[7]||(r[7]=function(){return t.dropdown&&t.dropdown.apply(t,arguments)}),onKeydown:r[8]||(r[8]=function(e){return t.preventCaret(e)})},null,40,u),[[e.vModelText,t.term]]),e.renderSlot(t.$slots,"clear",{clear:t.clear,term:t.term}),e.renderSlot(t.$slots,"icon",{isLoading:t.isLoading},(function(){return[e.withDirectives(e.createElementVNode("span",d,p,512),[[e.vShow,!t.isLoading]])]}))],2)]),t.isHistory&&t.isDropdown&&t.history.length&&!t.term?(e.openBlock(),e.createElementBlock("div",m,[e.createElementVNode("div",h,[e.createElementVNode("div",v,[e.createElementVNode("div",f,[e.createElementVNode("p",null,e.toDisplayString(t.__("shop.search.history")),1)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.history,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.createElementVNode("a",{onClick:function(e){return t.term=r}},e.toDisplayString(r),9,y)])})),128)),e.createElementVNode("div",g,[e.createElementVNode("a",{onClick:r[9]||(r[9]=function(e){return t.clearSearchHistory(e)})},e.toDisplayString(t.__("shop.search.history_clear")),1)])])])])):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("div",w,[e.withDirectives(e.createElementVNode("div",k,[e.renderSlot(t.$slots,"results-header"),t.categories.length?(e.openBlock(),e.createElementBlock("div",E,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.categories,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href,onClick:e.withModifiers((function(e){return t.opener(r.href,"category")}),["prevent"])},e.toDisplayString(r.name),9,C)])])})),128)),t.byCategory.length?(e.openBlock(),e.createElementBlock("hr",B)):e.createCommentVNode("v-if",!0)])):e.createCommentVNode("v-if",!0),t.byCategory.length?(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",N,e.toDisplayString(t.__("shop.search.categories")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.byCategory,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.renderSlot(t.$slots,"item-category",{item:r,searchHrefWithParameter:t.searchHrefWithParameter,opener:t.opener},(function(){return[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href+t.searchHrefWithParameter,onClick:e.withModifiers((function(e){return t.opener(r.href+t.searchHrefWithParameter,"category")}),["prevent"])},e.toDisplayString(r.name),9,_)]),e.createElementVNode("div",null,e.toDisplayString(t.__("shop.search.category_found",{count:r.count})),1)]}))])})),128))])):e.createCommentVNode("v-if",!0),t.total?(e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("p",S,[e.createTextVNode(e.toDisplayString(t.__("shop.search.total_found",{total:t.total}))+" ",1),D,e.createElementVNode("a",{href:t.searchUrl},e.toDisplayString(t.__("shop.search.open_results")),9,b)])])):e.createCommentVNode("v-if",!0),t.results.length?(e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",M,e.toDisplayString(t.__("shop.search.products")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.results,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["dropdown-item",{"is-active":t.current==o}]),key:r.id},[e.renderSlot(t.$slots,"item",{user:t.user,item:r,cartRefs:t.cartRefs,opener:t.opener},(function(){return[e.createElementVNode("div",x,[e.createElementVNode("div",H,[e.createElementVNode("div",T,[e.createElementVNode("a",{href:r.href,onClick:e.withModifiers((function(e){return t.opener(r.href,"product")}),["prevent"])},e.toDisplayString(r.name),9,$)]),e.createElementVNode("div",{class:"price",innerHTML:r.price},null,8,P),r.price_old?(e.openBlock(),e.createElementBlock("div",K,[e.createElementVNode("span",{innerHTML:r.price_old},null,8,z)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",O,e.toDisplayString(r.code),1),r.quantity?(e.openBlock(),e.createElementBlock("div",W,e.toDisplayString(t.__("shop.search.in_stock")),1)):(e.openBlock(),e.createElementBlock("span",F,e.toDisplayString(t.__("shop.search.out_stock")),1))]),r.is_eol?(e.openBlock(),e.createElementBlock("div",U,e.toDisplayString(t.__("shop.search.eol")),1)):(e.openBlock(),e.createElementBlock("div",R,[e.createVNode(c,{id:r.id,"is-change-quantity":!1,"is-already-in-cart":!1,ref_for:!0,ref:t.cartRefs},null,8,["id"])]))])]}))],2)})),128))],512)):e.createCommentVNode("v-if",!0)],512),[[e.vShow,t.results.length||t.categories.length]]),t.isLoading||t.results.length||t.categories.length?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",A,[e.createElementVNode("div",{class:"no-results",innerHTML:t.__("shop.search.no_results")},null,8,I)])]))],512),[[e.vShow,t.results.length||t.term]])],2)])},module.exports=i;
2
2
  //# sourceMappingURL=Search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Search.js","sources":["../../../src/components/shop/Search.vue","../../../src/components/shop/Search.vue?vue&type=template&id=7fe35c3d&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-search\" @click=\"$event.stopPropagation()\">\n <div class=\"dropdown\" v-bind:class=\"{\n 'is-active': isDropdown,\n 'is-dropdown-visible': isDropdown && ((history.length && !term) || results.length || categories.length || (term && !isLoading && !results.length && !categories.length))\n }\">\n <div class=\"overlay search-overlay\" @click=\"esc($event)\" v-if=\"!htmlClass\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"opener(null, 'results_page', open)\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'category')\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\" :opener=\"opener\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\" @click.prevent=\"opener(item.href + searchHrefWithParameter, 'category')\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\" ref=\"productsListElement\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\" :opener=\"opener\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'product')\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed, nextTick } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n },\n htmlClass: {\n type: String,\n default: ''\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n const productsListElement = ref(null);\n\n let refs = [];\n let timeout;\n\n let isTrackingStartSend = false;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n\n if (!isTrackingStartSend && isDropdown.value) {\n isTrackingStartSend = true;\n\n let object = {\n event: 'search_start'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!results.value.length && !categories.value.length && isDropdown.value) {\n let object = {\n event: 'search_no_results',\n search_query: term.value,\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n nextTick(() => {\n if (window.promoCodeCallback && typeof window.promoCodeCallback === 'function') {\n window.promoCodeCallback(productsListElement.value, '.dropdown-item:not(.products-list-title)');\n }\n });\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n }\n };\n\n const trackSuccessSearch = (type, callback) => {\n let object = {\n event: 'search_success',\n search_query: term.value,\n search_type: type,\n eventCallback: callback\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n if (!window.dataLayer || $env.debug.ecommerce) {\n if (callback) {\n setTimeout(callback, 300);\n }\n }\n }\n\n const opener = (href, type, callback) => {\n const locationCallback = () => {\n if (href) {\n window.location.href = href;\n }\n }\n\n trackSuccessSearch(type, callback ? callback : locationCallback);\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n if (props.htmlClass) {\n document.querySelector('html').classList.remove(props.htmlClass);\n }\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n\n if (props.htmlClass) {\n document.querySelector('html').classList.add(props.htmlClass);\n }\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder, { passive: true });\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n opener,\n productsListElement,\n };\n }\n});\n</script>","<template>\n <div class=\"shop-search\" @click=\"$event.stopPropagation()\">\n <div class=\"dropdown\" v-bind:class=\"{\n 'is-active': isDropdown,\n 'is-dropdown-visible': isDropdown && ((history.length && !term) || results.length || categories.length || (term && !isLoading && !results.length && !categories.length))\n }\">\n <div class=\"overlay search-overlay\" @click=\"esc($event)\" v-if=\"!htmlClass\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"opener(null, 'results_page', open)\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'category')\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\" :opener=\"opener\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\" @click.prevent=\"opener(item.href + searchHrefWithParameter, 'category')\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\" ref=\"productsListElement\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\" :opener=\"opener\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'product')\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed, nextTick } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n },\n htmlClass: {\n type: String,\n default: ''\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n const productsListElement = ref(null);\n\n let refs = [];\n let timeout;\n\n let isTrackingStartSend = false;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n\n if (!isTrackingStartSend && isDropdown.value) {\n isTrackingStartSend = true;\n\n let object = {\n event: 'search_start'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!results.value.length && !categories.value.length && isDropdown.value) {\n let object = {\n event: 'search_no_results',\n search_query: term.value,\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n nextTick(() => {\n if (window.promoCodeCallback && typeof window.promoCodeCallback === 'function') {\n window.promoCodeCallback(productsListElement.value, '.dropdown-item:not(.products-list-title)');\n }\n });\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n }\n };\n\n const trackSuccessSearch = (type, callback) => {\n let object = {\n event: 'search_success',\n search_query: term.value,\n search_type: type,\n eventCallback: callback\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n if (!window.dataLayer || $env.debug.ecommerce) {\n if (callback) {\n setTimeout(callback, 300);\n }\n }\n }\n\n const opener = (href, type, callback) => {\n const locationCallback = () => {\n if (href) {\n window.location.href = href;\n }\n }\n\n trackSuccessSearch(type, callback ? callback : locationCallback);\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n if (props.htmlClass) {\n document.querySelector('html').classList.remove(props.htmlClass);\n }\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n\n if (props.htmlClass) {\n document.querySelector('html').classList.add(props.htmlClass);\n }\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder, { passive: true });\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n opener,\n productsListElement,\n };\n }\n});\n</script>"],"names":["defineComponent","name","props","q","type","String","placeholder","placeholderMobile","parameter","isHistory","Boolean","isToggleDropdownOnClose","htmlClass","setup","ls","SecureLS","isCompression","encoder","document","createElement","innerHTML","value","isLoading","ref","term","results","byCategory","total","current","isDropdown","input","separator","dropdownContent","history","get","menu","store","useStore","user","computed","getters","productsListElement","refs","isTrackingStartSend","search","clearTimeout","timeout","trim","api","then","response","data","saveSearch","products","SimpleBar","object","event","$env","debug","ecommerce","console","log","window","dataLayer","push","length","categories","search_query","nextTick","promoCodeCallback","indexOf","filter","item","slice","unshift","set","onBeforeUpdate","watch","searchUrl","locale","url","searchHrefWithParameter","replace","toLowerCase","close","target","closest","querySelector","classList","remove","addEventListener","load","direct","menuElement","getElementById","querySelectorAll","forEach","element","textContent","dataset","href","i","resolve","f","apply","reject","e","placeholderMobilized","switchPlaceholder","isMobile","matchMedia","matches","passive","next","prev","add","preventDefault","cartRefs","el","preventCaret","which","esc","blur","dropdown","open","location","clearSearchHistory","focus","setSearchHistory","clear","opener","callback","search_type","eventCallback","setTimeout","trackSuccessSearch","_createElementVNode","style","_createElementBlock","onClick","$event","stopPropagation","_ctx","_hoisted_1","onKeyup","onKeydown","_renderSlot","_hoisted_3","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","index","key","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_16","_hoisted_17","_hoisted_18","count","_hoisted_20","_hoisted_21","_hoisted_22","_hoisted_24","_hoisted_25","id","_hoisted_26","_hoisted_27","_hoisted_28","price","price_old","_hoisted_31","_hoisted_33","code","quantity","_hoisted_34","_hoisted_35","is_eol","_hoisted_37","_hoisted_36","_createVNode","_hoisted_38","_hoisted_39"],"mappings":"kOA0HA,MAA6BA,kBAAgB,CACzCC,KA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rC,6BAAMpH,UAAQoD,EAAKoG,wDAEvBpC,2BAAAsC,oBAAqBtG,EAAKuG,SACEvG,EAAKwG,wBAAjCtC,2BAAAuC,oBACOnC,iDAEPJ,4BAAAwC,oBACOpC,qCAG0BtE,EAAK2G,sBAG1CzC,2BAAA0C,oBACOtC,4CAJPJ,2BAAA2C,GACIC,iBAAWf,GAAI/F,EAAK+F,yBAAyB,wBAA4B,aAAQhJ,IAAKuH,wGA9DxEA,UAAQ7E,QAAU6E,aAAW7E,UAwE9B6E,aAAcA,UAAQ7E,QAAW6E,aAAW7E,sDAAjFyE,2BAAA6C,GACI/C,2BAAAgD,GACIhD,kCAAW,aAAapH,UAAQ0H,+DA3ETA,UAAQ7E,QAAU6E"}
1
+ {"version":3,"file":"Search.js","sources":["../../../src/components/shop/Search.vue","../../../src/components/shop/Search.vue?vue&type=template&id=94d89cb6&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-search\" @click=\"$event.stopPropagation()\">\n <div class=\"dropdown\" v-bind:class=\"{\n 'is-active': isDropdown,\n 'is-dropdown-visible': isDropdown && ((history.length && !term) || results.length || categories.length || (term && !isLoading && !results.length && !categories.length))\n }\">\n <div class=\"overlay search-overlay\" @click=\"esc($event)\" v-if=\"!htmlClass\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"opener(null, 'results_page', open)\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'category')\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\" :opener=\"opener\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\" @click.prevent=\"opener(item.href + searchHrefWithParameter, 'category')\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\" ref=\"productsListElement\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\" :opener=\"opener\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'product')\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed, nextTick } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n },\n htmlClass: {\n type: String,\n default: ''\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n const productsListElement = ref(null);\n\n let refs = [];\n let timeout;\n\n let isTrackingStartSend = false;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n\n if (!isTrackingStartSend && isDropdown.value) {\n isTrackingStartSend = true;\n\n let object = {\n event: 'search_start'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!results.value.length && !categories.value.length && isDropdown.value) {\n let object = {\n event: 'search_no_results',\n search_query: term.value,\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n nextTick(() => {\n if (window.promoCodeCallback && typeof window.promoCodeCallback === 'function') {\n window.promoCodeCallback(productsListElement.value, '.dropdown-item:not(.products-list-title)');\n }\n });\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n }\n };\n\n const trackSuccessSearch = (type) => {\n let object = {\n event: !results.value.length && !categories.value.length ? 'search_no_results' : 'search_success',\n search_query: term.value,\n search_type: type\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n const opener = (href, type, callback) => {\n trackSuccessSearch(type);\n\n if (typeof callback === 'function') {\n callback();\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n if (props.htmlClass) {\n document.querySelector('html').classList.remove(props.htmlClass);\n }\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n\n if (props.htmlClass) {\n document.querySelector('html').classList.add(props.htmlClass);\n }\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder, { passive: true });\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n opener,\n productsListElement,\n };\n }\n});\n</script>","<template>\n <div class=\"shop-search\" @click=\"$event.stopPropagation()\">\n <div class=\"dropdown\" v-bind:class=\"{\n 'is-active': isDropdown,\n 'is-dropdown-visible': isDropdown && ((history.length && !term) || results.length || categories.length || (term && !isLoading && !results.length && !categories.length))\n }\">\n <div class=\"overlay search-overlay\" @click=\"esc($event)\" v-if=\"!htmlClass\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"opener(null, 'results_page', open)\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'category')\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\" :opener=\"opener\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\" @click.prevent=\"opener(item.href + searchHrefWithParameter, 'category')\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\" ref=\"productsListElement\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\" :opener=\"opener\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'product')\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed, nextTick } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n },\n htmlClass: {\n type: String,\n default: ''\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n const productsListElement = ref(null);\n\n let refs = [];\n let timeout;\n\n let isTrackingStartSend = false;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n\n if (!isTrackingStartSend && isDropdown.value) {\n isTrackingStartSend = true;\n\n let object = {\n event: 'search_start'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!results.value.length && !categories.value.length && isDropdown.value) {\n let object = {\n event: 'search_no_results',\n search_query: term.value,\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n nextTick(() => {\n if (window.promoCodeCallback && typeof window.promoCodeCallback === 'function') {\n window.promoCodeCallback(productsListElement.value, '.dropdown-item:not(.products-list-title)');\n }\n });\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n }\n };\n\n const trackSuccessSearch = (type) => {\n let object = {\n event: !results.value.length && !categories.value.length ? 'search_no_results' : 'search_success',\n search_query: term.value,\n search_type: type\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n const opener = (href, type, callback) => {\n trackSuccessSearch(type);\n\n if (typeof callback === 'function') {\n callback();\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n if (props.htmlClass) {\n document.querySelector('html').classList.remove(props.htmlClass);\n }\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n\n if (props.htmlClass) {\n document.querySelector('html').classList.add(props.htmlClass);\n }\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder, { passive: true });\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n opener,\n productsListElement,\n };\n }\n});\n</script>"],"names":["defineComponent","name","props","q","type","String","placeholder","placeholderMobile","parameter","isHistory","Boolean","isToggleDropdownOnClose","htmlClass","setup","ls","SecureLS","isCompression","encoder","document","createElement","innerHTML","value","isLoading","ref","term","results","byCategory","total","current","isDropdown","input","separator","dropdownContent","history","get","menu","store","useStore","user","computed","getters","productsListElement","refs","isTrackingStartSend","search","clearTimeout","timeout","trim","api","then","response","data","saveSearch","products","SimpleBar","object","event","$env","debug","ecommerce","console","log","window","dataLayer","push","length","categories","search_query","nextTick","promoCodeCallback","indexOf","filter","item","slice","unshift","set","onBeforeUpdate","watch","searchUrl","locale","url","searchHrefWithParameter","replace","toLowerCase","close","target","closest","querySelector","classList","remove","addEventListener","load","direct","menuElement","getElementById","querySelectorAll","forEach","element","textContent","dataset","href","i","resolve","f","apply","reject","e","placeholderMobilized","switchPlaceholder","isMobile","matchMedia","matches","passive","next","prev","add","preventDefault","cartRefs","el","preventCaret","which","esc","blur","dropdown","open","location","clearSearchHistory","focus","setSearchHistory","clear","opener","callback","search_type","trackSuccessSearch","_createElementVNode","style","_createElementBlock","onClick","$event","stopPropagation","_ctx","_hoisted_1","onKeyup","onKeydown","_renderSlot","_hoisted_3","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","index","key","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_16","_hoisted_17","_hoisted_18","count","_hoisted_20","_hoisted_21","_hoisted_22","_hoisted_24","_hoisted_25","id","_hoisted_26","_hoisted_27","_hoisted_28","price","price_old","_hoisted_31","_hoisted_33","code","quantity","_hoisted_34","_hoisted_35","is_eol","_hoisted_37","_hoisted_36","_createVNode","_hoisted_38","_hoisted_39"],"mappings":"kOA0HA,MAA6BA,kBAAgB,CACzCC,KAAM,SACNC,MAAO,CACHC,EAAG,CACCC,KAAMC,eACG,IAEbC,YAAa,CACTF,KAAMC,eACG,IAEbE,kBAAmB,CACfH,KAAMC,eACG,IAEbG,UAAW,CACPJ,KAAMC,eACG,iBAEbI,UAAW,CACPL,KAAMM,iBACG,GAEbC,wBAAyB,CACrBP,KAAMM,iBACG,GAEbE,UAAW,CACPR,KAAMC,eACG,KAGjBQ,eAAMX,OACIY,EAAK,IAAIC,UAAS,CACpBC,eAAe,IAGfb,EAAID,EAAMC,KAEVA,EAAG,KACCc,EAAUC,SAASC,cAAc,YACrCF,EAAQG,UAAYjB,EACpBA,EAAIc,EAAQI,UAGVC,EAAYC,OAAI,GAChBC,EAAOD,MAAIpB,GACXsB,EAAUF,MAAI,IACdG,EAAaH,MAAI,IACjBI,EAAQJ,MAAI,GACZK,EAAUL,OAAK,GACfM,EAAaN,OAAI,GACjBO,EAAQP,QACRQ,EAAYR,MAAI,IAChBS,EAAkBT,QAClBU,EAAUV,MAAIT,EAAGoB,IAAI,WACrBC,EAAOZ,MAAI,IACXa,EAAQC,aACRC,EAAOC,YAAS,kBAAMH,EAAMI,QAAQ,cACpCC,EAAsBlB,MAAI,MAE5BmB,EAAO,GAGPC,GAAsB,EAEpBC,EAAS,WACXC,kBALAC,GAOAlB,EAAQP,OAAS,EAEZG,EAAKH,MAAM0B,QAIZzB,EAAUD,OAAQ,EAEdG,EAAKH,MAAM0B,QACXC,OAAIJ,OAAOpB,EAAKH,OACX4B,MAAK,SA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uB,WAAWV,OAAQU,WAA3E,kBACIN,2BAAAgC,GACIhC,2BAAAiC,GACIjC,2BAAAkC,GACIlC,0BAAIlC,KAAM5B,EAAK4B,KAAOqC,4CAAeG,SAAOpE,EAAK4B,kDAC1C5B,EAAKvE,aAGhBqI,kCAAW,QAAQlH,UAAQoD,EAAKiG,iBACHjG,EAAKkG,yBAAlClC,2BAAAmC,GACIrC,6BAAMlH,UAAQoD,EAAKkG,wDAEvBpC,2BAAAsC,oBAAqBpG,EAAKqG,SACErG,EAAKsG,wBAAjCtC,2BAAAuC,oBACOnC,iDAEPJ,4BAAAwC,oBACOpC,qCAG0BpE,EAAKyG,sBAG1CzC,2BAAA0C,oBACOtC,4CAJPJ,2BAAA2C,GACIC,iBAAWf,GAAI7F,EAAK6F,yBAAyB,wBAA4B,aAAQ9I,IAAKqH,wGA9DxEA,UAAQ3E,QAAU2E,aAAW3E,UAwE9B2E,aAAcA,UAAQ3E,QAAW2E,aAAW3E,sDAAjFuE,2BAAA6C,GACI/C,2BAAAgD,GACIhD,kCAAW,aAAalH,UAAQwH,+DA3ETA,UAAQ3E,QAAU2E"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),a=require("vue-toastification"),n={setup:function(){return{translate:window.__}}},r={class:"shop-cart-success-message"};n.render=function(t,a,n,o,i,c){return e.openBlock(),e.createElementBlock("div",r,e.toDisplayString(o.translate("shop.cart.message")),1)};var o=a.useToast(),i={name:"cart-add",props:{id:Number,isChangeQuantity:{type:Boolean,default:!0},isAlreadyInCart:{type:Boolean,default:!0},isSimple:{type:Boolean,default:!1},isPlusMinus:{type:Boolean,default:!1},after:{type:String,default:"modal"},property:{type:String,default:null},code:{type:String,default:null},name:{type:String,default:null},price:{type:Number,default:null}},setup:function(a){var r=t.useStore(),i=e.ref(!1),c=e.ref(1),l=e.ref(null),s=e.computed((function(){return r.getters["cart/productQuantity"](a.id)})),d=a.isAlreadyInCart,u=a.isChangeQuantity,m=a.isPlusMinus;a.isSimple&&(d=!1,u=!1,m=!1);return{button:l,loading:i,quantity:c,add:function(){i.value=!0;var e=[];l.value.closest(".product-main")&&document.querySelectorAll("#options input[type=checkbox]:checked").forEach((function(t){e.push(parseInt(t.value))}));var t={};window.getTrackingIndexProductsList&&"function"==typeof window.getTrackingIndexProductsList&&(t=window.getTrackingIndexProductsList(l.value));var s=Math.max(1,c.value),d=l.value.closest("[shop-product]"),u=a.name?a.name:d.querySelector("[shop-product-name]").textContent,m=a.price?a.price:d.querySelector("[shop-product-price]").childNodes[0].nodeValue.replace(/ /g,""),p=a.code?a.code:d.dataset.code,y=d.querySelector("[shop-product-category]").textContent,f=d.querySelector("[shop-product-brand]").textContent;r.dispatch("cart/add",{product:{id:a.id,quantity:s,options:e,extra:{trackingIndex:t}},finally:function(){(i.value=!1,c.value=1,"message"==a.after)&&o({component:n},{type:"success-cart"})},callback:function(){var e={ecommerce:{currency:"UAH",value:parseFloat(m)*s,items:[{item_name:u,item_id:p,price:parseFloat(m),quantity:s}]},event:"add_to_cart"};t.index&&(e.ecommerce.items[0].index=t.index),t.item_list_name&&(e.ecommerce.items[0].item_list_name=t.item_list_name),f&&(e.ecommerce.items[0].item_brand=f),y&&(-1!==y.indexOf("/")?y.split("/").forEach((function(t,a){e.ecommerce.items[0]["item_category"+(a?a+1:"")]=t.trim()})):e.ecommerce.items[0].item_category=y),a.property&&(e.ecommerce.items[0].item_variant=a.property),$env.debug.ecommerce&&console.log(e),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(e))}})},remove:function(){i.value=!0,r.dispatch("cart/remove",{id:a.id,finally:function(){i.value=!1}})},cart:s,increase:function(){c.value++},decrease:function(){c.value>1&&c.value--},isAlreadyInCart:d,isChangeQuantity:u,isPlusMinus:m}}},c={class:"cart-add",ref:"button"},l={class:"columns"},s={key:0,class:"column"},d={class:"cart-change-quantity"},u=["disabled"],m=["disabled"],p=["disabled"],y={class:"column is-narrow"},f=["disabled"],v=e.createElementVNode("svg",{class:"icon cart"},[e.createElementVNode("use",{"xlink:href":"#cart-add"})],-1),g={class:"cart-add-button-label"},h={key:0},b=e.createElementVNode("br",null,null,-1),k=["disabled","textContent"];i.render=function(t,a,n,r,o,i){return e.openBlock(),e.createElementBlock("div",c,[e.createElementVNode("div",l,[t.$env.shop.isCustomQuantity&&r.isChangeQuantity?(e.openBlock(),e.createElementBlock("div",s,[e.createElementVNode("div",d,[r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:0,class:"button is-small decrease",onClick:a[0]||(a[0]=function(){return r.decrease&&r.decrease.apply(r,arguments)}),disabled:r.loading||1==r.quantity},"-",8,u)):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":a[1]||(a[1]=function(e){return r.quantity=e}),disabled:r.loading},null,8,m),[[e.vModelText,r.quantity]]),r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:1,class:"button is-small increase",onClick:a[2]||(a[2]=function(){return r.increase&&r.increase.apply(r,arguments)}),disabled:r.loading},"+",8,p)):e.createCommentVNode("v-if",!0)])])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",y,[e.createElementVNode("button",{class:"button is-link is-small",onClick:a[3]||(a[3]=function(){return r.add&&r.add.apply(r,arguments)}),disabled:r.loading},[e.renderSlot(t.$slots,"default",{label:t.__("shop.cart.add")},(function(){return[v,e.createElementVNode("span",g,e.toDisplayString(t.__("shop.cart.add")),1)]}))],8,f)])]),t.$env.shop.isAlreadyInCart&&r.isAlreadyInCart&&r.cart>0?(e.openBlock(),e.createElementBlock("div",h,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.already",{quantity:r.cart}))+" ",1),b,e.createElementVNode("a",{onClick:a[4]||(a[4]=e.withModifiers((function(){return r.remove&&r.remove.apply(r,arguments)}),["prevent"])),disabled:r.loading,textContent:e.toDisplayString(t.__("shop.cart.remove"))},null,8,k)])):e.createCommentVNode("v-if",!0)],512)},module.exports=i;
1
+ "use strict";var e=require("vue"),t=require("vuex"),a=require("vue-toastification"),n={setup:function(){return{translate:window.__}}},r={class:"shop-cart-success-message"};n.render=function(t,a,n,o,i,c){return e.openBlock(),e.createElementBlock("div",r,e.toDisplayString(o.translate("shop.cart.message")),1)};var o=a.useToast(),i={name:"cart-add",props:{id:Number,isChangeQuantity:{type:Boolean,default:!0},isAlreadyInCart:{type:Boolean,default:!0},isSimple:{type:Boolean,default:!1},isPlusMinus:{type:Boolean,default:!1},after:{type:String,default:"modal"},property:{type:String,default:null},code:{type:String,default:null},name:{type:String,default:null},price:{type:Number,default:null}},setup:function(a){var r=t.useStore(),i=e.ref(!1),c=e.ref(1),l=e.ref(null),s=e.computed((function(){return r.getters["cart/productQuantity"](a.id)})),d=a.isAlreadyInCart,u=a.isChangeQuantity,m=a.isPlusMinus;a.isSimple&&(d=!1,u=!1,m=!1);return{button:l,loading:i,quantity:c,add:function(){i.value=!0;var e=[];l.value.closest(".product-main")&&document.querySelectorAll("#options input[type=checkbox]:checked").forEach((function(t){e.push(parseInt(t.value))}));var t={};window.getTrackingIndexProductsList&&"function"==typeof window.getTrackingIndexProductsList&&(t=window.getTrackingIndexProductsList(l.value));var s=Math.max(1,c.value),d=l.value.closest("[shop-product]"),u=a.name?a.name:d.querySelector("[shop-product-name]").textContent,m=a.price?a.price:d.querySelector("[shop-product-price]").childNodes[0].nodeValue.replace(/ /g,""),p=a.property?a.property:d.querySelector("[shop-product-property]").textContent,y=a.code?a.code:d.dataset.code,f=d.querySelector("[shop-product-category]").textContent,v=d.querySelector("[shop-product-brand]").textContent;r.dispatch("cart/add",{product:{id:a.id,quantity:s,options:e,extra:{trackingIndex:t}},finally:function(){(i.value=!1,c.value=1,"message"==a.after)&&o({component:n},{type:"success-cart"})},callback:function(){var e={ecommerce:{currency:"UAH",value:parseFloat(m)*s,items:[{item_name:u,item_id:y,price:parseFloat(m),quantity:s}]},event:"add_to_cart"};t.index&&(e.ecommerce.items[0].index=t.index),t.item_list_name&&(e.ecommerce.items[0].item_list_name=t.item_list_name),v&&(e.ecommerce.items[0].item_brand=v),f&&(-1!==f.indexOf("/")?f.split("/").forEach((function(t,a){e.ecommerce.items[0]["item_category"+(a?a+1:"")]=t.trim()})):e.ecommerce.items[0].item_category=f),p&&(e.ecommerce.items[0].item_variant=p),$env.debug.ecommerce&&console.log(e),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(e))}})},remove:function(){i.value=!0,r.dispatch("cart/remove",{id:a.id,finally:function(){i.value=!1}})},cart:s,increase:function(){c.value++},decrease:function(){c.value>1&&c.value--},isAlreadyInCart:d,isChangeQuantity:u,isPlusMinus:m}}},c={class:"cart-add",ref:"button"},l={class:"columns"},s={key:0,class:"column"},d={class:"cart-change-quantity"},u=["disabled"],m=["disabled"],p=["disabled"],y={class:"column is-narrow"},f=["disabled"],v=e.createElementVNode("svg",{class:"icon cart"},[e.createElementVNode("use",{"xlink:href":"#cart-add"})],-1),g={class:"cart-add-button-label"},h={key:0},b=e.createElementVNode("br",null,null,-1),k=["disabled","textContent"];i.render=function(t,a,n,r,o,i){return e.openBlock(),e.createElementBlock("div",c,[e.createElementVNode("div",l,[t.$env.shop.isCustomQuantity&&r.isChangeQuantity?(e.openBlock(),e.createElementBlock("div",s,[e.createElementVNode("div",d,[r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:0,class:"button is-small decrease",onClick:a[0]||(a[0]=function(){return r.decrease&&r.decrease.apply(r,arguments)}),disabled:r.loading||1==r.quantity},"-",8,u)):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":a[1]||(a[1]=function(e){return r.quantity=e}),disabled:r.loading},null,8,m),[[e.vModelText,r.quantity]]),r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:1,class:"button is-small increase",onClick:a[2]||(a[2]=function(){return r.increase&&r.increase.apply(r,arguments)}),disabled:r.loading},"+",8,p)):e.createCommentVNode("v-if",!0)])])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",y,[e.createElementVNode("button",{class:"button is-link is-small",onClick:a[3]||(a[3]=function(){return r.add&&r.add.apply(r,arguments)}),disabled:r.loading},[e.renderSlot(t.$slots,"default",{label:t.__("shop.cart.add")},(function(){return[v,e.createElementVNode("span",g,e.toDisplayString(t.__("shop.cart.add")),1)]}))],8,f)])]),t.$env.shop.isAlreadyInCart&&r.isAlreadyInCart&&r.cart>0?(e.openBlock(),e.createElementBlock("div",h,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.already",{quantity:r.cart}))+" ",1),b,e.createElementVNode("a",{onClick:a[4]||(a[4]=e.withModifiers((function(){return r.remove&&r.remove.apply(r,arguments)}),["prevent"])),disabled:r.loading,textContent:e.toDisplayString(t.__("shop.cart.remove"))},null,8,k)])):e.createCommentVNode("v-if",!0)],512)},module.exports=i;
2
2
  //# sourceMappingURL=CartAdd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartAdd.js","sources":["../../../../src/components/shop/cart/SuccessMessage.vue","../../../../src/components/shop/cart/SuccessMessage.vue?vue&type=template&id=75a41ddb&lang.js","../../../../src/components/shop/cart/CartAdd.vue","../../../../src/components/shop/cart/CartAdd.vue?vue&type=template&id=b103ae2e&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n\n const cart = computed(() => store.getters['cart/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]').textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '');\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]').textContent;\n const brand = product.querySelector('[shop-product-brand]').textContent;\n\n store.dispatch('cart/add', {\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.id,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n\n const cart = computed(() => store.getters['cart/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]').textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '');\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]').textContent;\n const brand = product.querySelector('[shop-product-brand]').textContent;\n\n store.dispatch('cart/add', {\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.id,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>"],"names":["setup","translate","window","__","_createElementBlock","_hoisted_1","$setup","toast","useToast","name","props","id","Number","isChangeQuantity","type","Boolean","isAlreadyInCart","isSimple","isPlusMinus","after","String","property","code","price","store","useStore","loading","ref","quantity","button","cart","computed","getters","add","value","options","closest","document","querySelectorAll","forEach","element","push","parseInt","trackingIndex","getTrackingIndexProductsList","q","Math","max","product","querySelector","textContent","childNodes","nodeValue","replace","dataset","category","brand","dispatch","extra","component","SuccessMessage","callback","object","ecommerce","currency","parseFloat","items","item_name","item_id","event","index","item_list_name","item_brand","indexOf","split","segment","trim","item_category","item_variant","$env","debug","console","log","dataLayer","remove","increase","decrease","_createElementVNode","_hoisted_2","_ctx","shop","isCustomQuantity","_hoisted_3","_hoisted_4","onClick","disabled","min","_hoisted_8","_renderSlot","label","_hoisted_10","_hoisted_11","_hoisted_13","_toDisplayString"],"mappings":"sFAMe,CACXA,uBAGW,CACHC,UAHcC,OAAOC,eCPlB,iFAAXC,2BAAAC,oBACOC,sCCkCX,IAAMC,EAAQC,eAEC,CACXC,KAAM,WACNC,MAAO,CACHC,GAAIC,OACJC,iBAAkB,CACdC,KAAMC,iBACG,GAEbC,gBAAiB,CACbF,KAAMC,iBACG,GAEbE,SAAU,CACNH,KAAMC,iBACG,GAEbG,YAAa,CACTJ,KAAMC,iBACG,GAEbI,MAAO,CACHL,KAAMM,eACG,SAEbC,SAAU,CACNP,KAAMM,eACG,MAEbE,KAAM,CACFR,KAAMM,eACG,MAEbX,KAAM,CACFK,KAAMM,eACG,MAEbG,MAAO,CACHT,KAAMF,eACG,OAGjBZ,eAAMU,OACIc,EAAQC,aACRC,EAAUC,OAAI,GACdC,EAAWD,MAAI,GACfE,EAASF,MAAI,MAEbG,EAAOC,YAAS,kBAAMP,EAAMQ,QAAQ,wBAAwBtB,EAAMC,OAEpEK,EAAkBN,EAAMM,gBACxBH,EAAmBH,EAAMG,iBACzBK,EAAcR,EAAMQ,YAEpBR,EAAMO,WACND,GAAkB,EAClBH,GAAmB,EACnBK,GAAc,SAoIX,CACHW,OAAAA,EACAH,QAAAA,EACAE,SAAAA,EACAK,IArIQ,WACRP,EAAQQ,OAAQ,MAEZC,EAAU,GAEVN,EAAOK,MAAME,QAAQ,kBACEC,SAASC,iBAAiB,yCAElCC,SAAQ,SAACC,GACpBL,EAAQM,KAAKC,SAASF,EAAQN,eAIlCS,EAAgB,GAEhBzC,OAAO0C,8BAA+E,mBAAxC1C,OAAO0C,+BACrDD,EAAgBzC,OAAO0C,6BAA6Bf,EAAOK,YAGzDW,EAAIC,KAAKC,IAAI,EAAGnB,EAAS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,aAAepE,EAAMW,UAG/C0D,KAAKC,MAAMjB,WACXkB,QAAQC,IAAIpB,IAGXiB,KAAKC,MAAMjB,WAAa7D,OAAOiF,YAChCjF,OAAOiF,UAAU1C,KAAK,CAClBsB,UAAW,OAGf7D,OAAOiF,UAAU1C,KAAKqB,QAgClCsB,OA1BW,WACX1D,EAAQQ,OAAQ,EAEhBV,EAAMiC,SAAS,cAAe,CAC1B9C,GAAID,EAAMC,WACD,WACLe,EAAQQ,OAAQ,MAqBxBJ,KAAAA,EACAuD,SAjBa,WACbzD,EAASM,SAiBToD,SAda,WACT1D,EAASM,MAAQ,GACjBN,EAASM,SAablB,gBAAAA,EACAH,iBAAAA,EACAK,YAAAA,cC5OG,WAAWS,IAAI,mBACX,0BACI,mBACI,8EAMJ,qCAGC4D,kCAAW,cACPA,yCAAgB,4BAER,qCASxBA,yHAxBRnF,2BAAAC,GACIkF,2BAAAC,GAC8BC,OAAKC,KAAKC,kBAAoBrF,kCAAxDF,2BAAAwF,GACIL,2BAAAM,GAC0GvF,6BAAtGF,2CAAc,2BAA4B0F,sCAAOxF,4CAAWyF,SAAUzF,cAAWA,YAAkC,2DACnHiF,oCAAa,iBAAiBzE,KAAK,SAASkF,IAAI,yDAAa1F,eAAWyF,SAAUzF,oCAArBA,cACwBA,6BAArFF,2CAAc,2BAA4B0F,sCAAOxF,4CAAWyF,SAAUzF,WAA4B,+EAG1GiF,2BAAAU,GACIV,qCAAc,0BAA+BO,sCAAOxF,kCAAMyF,SAAUzF,YAChE4F,iCAAOC,MAAOV,wBAAd,kBACIW,EAGAb,4BAAAc,oBACOZ,wCAMZA,OAAKC,KAAK1E,iBAAmBV,mBAAmBA,wBAA3DF,kEACOqF,mCAAoCnF,iBACvCgG,EACAf,0BAAQO,uDAAexF,sDAASyF,SAAUzF,sBAASiG,kBAAQd"}
1
+ {"version":3,"file":"CartAdd.js","sources":["../../../../src/components/shop/cart/SuccessMessage.vue","../../../../src/components/shop/cart/SuccessMessage.vue?vue&type=template&id=75a41ddb&lang.js","../../../../src/components/shop/cart/CartAdd.vue","../../../../src/components/shop/cart/CartAdd.vue?vue&type=template&id=1929818d&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n\n const cart = computed(() => store.getters['cart/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]').textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]').textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]').textContent;\n const brand = product.querySelector('[shop-product-brand]').textContent;\n\n store.dispatch('cart/add', {\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.id,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n\n const cart = computed(() => store.getters['cart/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]').textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]').textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]').textContent;\n const brand = product.querySelector('[shop-product-brand]').textContent;\n\n store.dispatch('cart/add', {\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.id,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>"],"names":["setup","translate","window","__","_createElementBlock","_hoisted_1","$setup","toast","useToast","name","props","id","Number","isChangeQuantity","type","Boolean","isAlreadyInCart","isSimple","isPlusMinus","after","String","property","code","price","store","useStore","loading","ref","quantity","button","cart","computed","getters","add","value","options","closest","document","querySelectorAll","forEach","element","push","parseInt","trackingIndex","getTrackingIndexProductsList","q","Math","max","product","querySelector","textContent","childNodes","nodeValue","replace","dataset","category","brand","dispatch","extra","component","SuccessMessage","callback","object","ecommerce","currency","parseFloat","items","item_name","item_id","event","index","item_list_name","item_brand","indexOf","split","segment","trim","item_category","item_variant","$env","debug","console","log","dataLayer","remove","increase","decrease","_createElementVNode","_hoisted_2","_ctx","shop","isCustomQuantity","_hoisted_3","_hoisted_4","onClick","disabled","min","_hoisted_8","_renderSlot","label","_hoisted_10","_hoisted_11","_hoisted_13","_toDisplayString"],"mappings":"sFAMe,CACXA,uBAGW,CACHC,UAHcC,OAAOC,eCPlB,iFAAXC,2BAAAC,oBACOC,sCCkCX,IAAMC,EAAQC,eAEC,CACXC,KAAM,WACNC,MAAO,CACHC,GAAIC,OACJC,iBAAkB,CACdC,KAAMC,iBACG,GAEbC,gBAAiB,CACbF,KAAMC,iBACG,GAEbE,SAAU,CACNH,KAAMC,iBACG,GAEbG,YAAa,CACTJ,KAAMC,iBACG,GAEbI,MAAO,CACHL,KAAMM,eACG,SAEbC,SAAU,CACNP,KAAMM,eACG,MAEbE,KAAM,CACFR,KAAMM,eACG,MAEbX,KAAM,CACFK,KAAMM,eACG,MAEbG,MAAO,CACHT,KAAMF,eACG,OAGjBZ,eAAMU,OACIc,EAAQC,aACRC,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kBAAoBrF,kCAAxDF,2BAAAwF,GACIL,2BAAAM,GAC0GvF,6BAAtGF,2CAAc,2BAA4B0F,sCAAOxF,4CAAWyF,SAAUzF,cAAWA,YAAkC,2DACnHiF,oCAAa,iBAAiBzE,KAAK,SAASkF,IAAI,yDAAa1F,eAAWyF,SAAUzF,oCAArBA,cACwBA,6BAArFF,2CAAc,2BAA4B0F,sCAAOxF,4CAAWyF,SAAUzF,WAA4B,+EAG1GiF,2BAAAU,GACIV,qCAAc,0BAA+BO,sCAAOxF,kCAAMyF,SAAUzF,YAChE4F,iCAAOC,MAAOV,wBAAd,kBACIW,EAGAb,4BAAAc,oBACOZ,wCAMZA,OAAKC,KAAK1E,iBAAmBV,mBAAmBA,wBAA3DF,kEACOqF,mCAAoCnF,iBACvCgG,EACAf,0BAAQO,uDAAexF,sDAASyF,SAAUzF,sBAASiG,kBAAQd"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),i={name:"CartItem",props:{item:Object},setup:function(i){var n=t.useStore(),o=e.ref(!1),a=e.ref(),r=e.ref(i.item.attributes.options&&i.item.attributes.options.length?i.item.attributes.options:[]),c=e.ref(!1),l=e.computed((function(){return n.getters["auth/is"]}));i.item.attributes.options&&i.item.attributes.options.length&&(c.value=!0);var s=i.item.name,m=i.item.attributes.price,d=i.item.attributes.code,u=i.item.attributes.categoryFull?i.item.attributes.categoryFull:i.item.attributes.category,p=i.item.attributes.brand,b=i.item.attributes.property,v=function(e){o.value=!0,n.dispatch("cart/add",{product:{id:i.item.id,quantity:e},finally:function(){o.value=!1},callback:function(){var e=i.item.quantity,t={ecommerce:{currency:"UAH",value:parseFloat(m)*e,items:[{item_name:s,item_id:d,price:parseFloat(m),quantity:e}]},event:"add_to_cart"};p&&(t.ecommerce.items[0].item_brand=p),i.item.attributes.index&&(t.ecommerce.items[0].index=i.item.attributes.index),i.item.attributes.itemListName&&(t.ecommerce.items[0].item_list_name=i.item.attributes.itemListName),u&&(-1!==u.indexOf("/")?u.split("/").forEach((function(e,i){t.ecommerce.items[0]["item_category"+(i?i+1:"")]=e.trim()})):t.ecommerce.items[0].item_category=u),b&&(t.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(t),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t))}})};i.item.options&&i.item.options.length&&e.watch(r,(function(e){o.value=!0,n.dispatch("cart/options",{product:{id:i.item.id,options:Object.values(e)},finally:function(){o.value=!1}})}));return{loading:o,increase:function(){v(1)},decrease:function(){v(-1)},remove:function(){o.value=!0,n.dispatch("cart/remove",{id:i.item.id,finally:function(){o.value=!1},callback:function(){var e=i.item.quantity,t={ecommerce:{currency:"UAH",value:parseFloat(m)*e,items:[{item_name:s,item_id:d,price:parseFloat(m),quantity:e}]},event:"remove_from_cart"};u&&(-1!==u.indexOf("/")?u.split("/").forEach((function(e,i){t.ecommerce.items[0]["item_category"+(i?i+1:"")]=e.trim()})):t.ecommerce.items[0].item_category=u),b&&(t.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(t),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t))}})},options:r,optionsToggled:c,input:a,gotoProduct:function(e){window.addEventListener("beforeunload",(function(){n.commit("cart/modal",null)})),window.addEventListener("pagehide",(function(){n.commit("cart/modal",null)})),window.location.href=e},auth:l}}},n={key:0,class:"column is-12"},o={class:"bundle-title"},a={class:"column name"},r={class:"column is-narrow cart-actions-parent"},c={class:"cart-actions"},l=["disabled"],s=[e.createElementVNode("svg",{class:"icon"},[e.createElementVNode("use",{"xlink:href":"#cart-remove"})],-1)],m={class:"column is-narrow image-parent"},d=["src"],u={key:1},p=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],b={class:"column"},v={class:"columns is-gapless mb-0"},g={class:"column"},k={key:0,class:"code"},f={class:"title"},E={key:0},y={key:0,class:"column is-narrow has-text-right is-relative quantity-parent"},N={class:"quantity"},V=["disabled"],h=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-minus"})],-1)],B=["disabled"],w=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-plus"})],-1)],C={key:0,class:"quantity-price"},_=["innerHTML"],x={class:"column is-2 has-text-right"},q=["innerHTML"],L=["innerHTML"],S=["innerHTML"],D=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#arrow-down"})],-1),T={class:"wrapper"},H={class:"column is-narrow"},M=["value","id"],$={class:"column"},P=["for"],z={key:0,class:"option-description"},F={class:"column is-2 has-text-right"},O=["innerHTML"],U={key:0,class:"bundle columns"},j=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("div",{class:"cart-bundle-spacer"})],-1),A={class:"column is-narrow"},I=e.createElementVNode("svg",{class:"bundle-icon"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1),G=["src"],J={key:1},K=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],Q={class:"column"},R={key:0,class:"code"},W={class:"title"},X={key:1,class:"bundle columns"},Y=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("div",{class:"cart-bundle-spacer"})],-1),Z={class:"column is-narrow"},ee=e.createElementVNode("svg",{class:"bundle-icon"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1),te=["src"],ie={key:1},ne=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],oe={class:"column"},ae={key:0,class:"code"},re={class:"title"};i.render=function(t,i,ce,le,se,me){var de=e.resolveComponent("wishlist-add");return ce.item.deleted?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["columns is-multiline shop-cart-item",{inactive:!1===ce.item.attributes.active,"is-bundle":ce.item.attributes.bundle}])},[ce.item.attributes.bundle?(e.openBlock(),e.createElementBlock("div",n,[e.createElementVNode("div",o,e.toDisplayString(t.__("shop.cart.bundle")),1)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",a,[e.createElementVNode("div",{class:e.normalizeClass(["columns",{"mb-0":ce.item.attributes.bundle}])},[e.createElementVNode("div",r,[e.createElementVNode("div",c,[e.createElementVNode("button",{class:"remove",onClick:i[0]||(i[0]=function(){return le.remove&&le.remove.apply(le,arguments)}),disabled:le.loading},s,8,l),le.auth&&!ce.item.attributes.bundle?(e.openBlock(),e.createBlock(de,{key:0,id:ce.item.id},null,8,["id"])):e.createCommentVNode("v-if",!0)])]),e.createElementVNode("div",m,[e.createElementVNode("a",{onClick:i[1]||(i[1]=function(e){return le.gotoProduct(ce.item.attributes.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!ce.item.attributes.image}])},[ce.item.attributes.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:ce.item.attributes.image},null,8,d)):(e.openBlock(),e.createElementBlock("svg",u,p))],2)])]),e.createElementVNode("div",b,[e.createElementVNode("div",v,[e.createElementVNode("div",g,[e.renderSlot(t.$slots,"item-name",{item:ce.item,gotoProduct:le.gotoProduct},(function(){return[ce.item.attributes.code?(e.openBlock(),e.createElementBlock("div",k,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(ce.item.attributes.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",f,[!1===ce.item.attributes.active?(e.openBlock(),e.createElementBlock("span",E,e.toDisplayString(ce.item.name),1)):(e.openBlock(),e.createElementBlock("a",{key:1,onClick:i[2]||(i[2]=function(e){return le.gotoProduct(ce.item.attributes.href)})},e.toDisplayString(ce.item.name),1))])]}))]),(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",N,[e.createElementVNode("button",{class:"button decrease",onClick:i[3]||(i[3]=function(){return le.decrease&&le.decrease.apply(le,arguments)}),disabled:le.loading||1==ce.item.quantity},h,8,V),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":i[4]||(i[4]=function(e){return ce.item.quantity=e}),disabled:""},null,512),[[e.vModelText,ce.item.quantity]]),e.createElementVNode("button",{class:"button increase",onClick:i[5]||(i[5]=function(){return le.increase&&le.increase.apply(le,arguments)}),disabled:le.loading},w,8,B)]),ce.item.quantity>1?(e.openBlock(),e.createElementBlock("div",C,[e.createElementVNode("span",{innerHTML:t.$filters.price(ce.item.attributes.price)},null,8,_),e.createTextVNode(" / "+e.toDisplayString(t.__("shop.cart.q")),1)])):e.createCommentVNode("v-if",!0)])),e.createElementVNode("div",x,[e.renderSlot(t.$slots,"item-price",{item:ce.item,filters:t.$filters},(function(){return[e.createElementVNode("div",{class:e.normalizeClass(["price",{"bundle-price":ce.item.attributes.bundle}])},[ce.item.attributes.priceOld?(e.openBlock(),e.createElementBlock("div",{key:0,class:"price-old",innerHTML:t.$filters.price(ce.item.attributes.priceOld*ce.item.quantity)},null,8,q)):e.createCommentVNode("v-if",!0),ce.item.attributes.bundle&&ce.item.attributes.amount?(e.openBlock(),e.createElementBlock("div",{key:1,class:"bundle-amount",innerHTML:t.__("shop.cart.bundle_amount")+(ce.item.attributes.amount.percent?ce.item.attributes.amount.percent+"%":t.$filters.price(ce.item.attributes.amount.sum*ce.item.quantity))},null,8,L)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",{innerHTML:t.$filters.price(ce.item.attributes.price*ce.item.quantity)},null,8,S)],2)]}))])]),ce.item.options&&ce.item.options.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["options",{"is-toggled":le.optionsToggled}])},[e.createElementVNode("div",{class:"toggler",onClick:i[6]||(i[6]=function(e){return le.optionsToggled=!le.optionsToggled})},[e.createElementVNode("span",null,e.toDisplayString(t.__("shop.cart.additional"))+" "+e.toDisplayString(ce.item.options.length),1),D]),e.withDirectives(e.createElementVNode("div",T,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ce.item.options,(function(n,o){return e.openBlock(),e.createElementBlock("div",{key:o,class:e.normalizeClass(["columns",{"is-checked":-1!==le.options.indexOf(n.id)}])},[e.createElementVNode("div",H,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"checkbox","onUpdate:modelValue":i[7]||(i[7]=function(e){return le.options=e}),value:n.id,id:"option-"+ce.item.id+"-"+n.id},null,8,M),[[e.vModelCheckbox,le.options]])]),e.createElementVNode("div",$,[e.createElementVNode("label",{class:"option-title is-clickable",for:"option-"+ce.item.id+"-"+n.id},e.toDisplayString(n.name),9,P),n.description?(e.openBlock(),e.createElementBlock("div",z,e.toDisplayString(n.description),1)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",F,[e.createTextVNode("+"),e.createElementVNode("span",{innerHTML:t.$filters.price(n.price)},null,8,O)])],2)})),128))],512),[[e.vShow,le.optionsToggled]])],2)):e.createCommentVNode("v-if",!0)])],2),ce.item.attributes.bundle?(e.openBlock(),e.createElementBlock("div",U,[j,e.createElementVNode("div",A,[I,e.createElementVNode("a",{onClick:i[8]||(i[8]=function(e){return le.gotoProduct(ce.item.attributes.second.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!ce.item.attributes.second.image}])},[ce.item.attributes.second.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:ce.item.attributes.second.image},null,8,G)):(e.openBlock(),e.createElementBlock("svg",J,K))],2)])]),e.createElementVNode("div",Q,[ce.item.attributes.second.code?(e.openBlock(),e.createElementBlock("div",R,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(ce.item.attributes.second.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",W,[e.createElementVNode("a",{onClick:i[9]||(i[9]=function(e){return le.gotoProduct(ce.item.attributes.second.href)})},e.toDisplayString(ce.item.attributes.second.name),1)])])])):e.createCommentVNode("v-if",!0),ce.item.attributes.bundle&&ce.item.attributes.third?(e.openBlock(),e.createElementBlock("div",X,[Y,e.createElementVNode("div",Z,[ee,e.createElementVNode("a",{onClick:i[10]||(i[10]=function(e){return le.gotoProduct(ce.item.attributes.third.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!ce.item.attributes.third.image}])},[ce.item.attributes.third.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:ce.item.attributes.third.image},null,8,te)):(e.openBlock(),e.createElementBlock("svg",ie,ne))],2)])]),e.createElementVNode("div",oe,[ce.item.attributes.third.code?(e.openBlock(),e.createElementBlock("div",ae,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(ce.item.attributes.third.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",re,[e.createElementVNode("a",{onClick:i[11]||(i[11]=function(e){return le.gotoProduct(ce.item.attributes.third.href)})},e.toDisplayString(ce.item.attributes.third.name),1)])])])):e.createCommentVNode("v-if",!0)])],2))},module.exports=i;
1
+ "use strict";var e=require("vue"),t=require("vuex"),i={name:"CartItem",props:{item:Object},setup:function(i){var o=t.useStore(),n=e.ref(!1),a=e.ref(),r=e.ref(i.item.attributes.options&&i.item.attributes.options.length?i.item.attributes.options:[]),c=e.ref(!1),l=e.computed((function(){return o.getters["auth/is"]}));i.item.attributes.options&&i.item.attributes.options.length&&(c.value=!0);var s=i.item.name,m=i.item.attributes.price,d=i.item.attributes.code,u=i.item.attributes.categoryFull?i.item.attributes.categoryFull:i.item.attributes.category,p=i.item.attributes.brand,b=i.item.attributes.property,v=i.item.attributes.index,g=i.item.attributes.itemListName,k=function(e){n.value=!0,o.dispatch("cart/add",{product:{id:i.item.id,quantity:e},finally:function(){n.value=!1},callback:function(){if(e>0){var t=i.item.quantity,o={ecommerce:{currency:"UAH",value:parseFloat(m)*t,items:[{item_name:s,item_id:d,price:parseFloat(m),quantity:1}]},event:"add_to_cart"};p&&(o.ecommerce.items[0].item_brand=p),i.item.attributes.index&&(o.ecommerce.items[0].index=i.item.attributes.index),i.item.attributes.itemListName&&(o.ecommerce.items[0].item_list_name=i.item.attributes.itemListName),u&&(-1!==u.indexOf("/")?u.split("/").forEach((function(e,t){o.ecommerce.items[0]["item_category"+(t?t+1:"")]=e.trim()})):o.ecommerce.items[0].item_category=u),b&&(o.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(o),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(o))}}})};i.item.options&&i.item.options.length&&e.watch(r,(function(e){n.value=!0,o.dispatch("cart/options",{product:{id:i.item.id,options:Object.values(e)},finally:function(){n.value=!1}})}));return{loading:n,increase:function(){k(1)},decrease:function(){k(-1)},remove:function(){n.value=!0,o.dispatch("cart/remove",{id:i.item.id,finally:function(){n.value=!1},callback:function(){var e=i.item.quantity,t={ecommerce:{currency:"UAH",value:parseFloat(m)*e,items:[{item_name:s,item_id:d,price:parseFloat(m),quantity:e}]},event:"remove_from_cart"};u&&(-1!==u.indexOf("/")?u.split("/").forEach((function(e,i){t.ecommerce.items[0]["item_category"+(i?i+1:"")]=e.trim()})):t.ecommerce.items[0].item_category=u),v&&(t.ecommerce.items[0].index=v),g&&(t.ecommerce.items[0].item_list_name=g),b&&(t.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(t),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t))}})},options:r,optionsToggled:c,input:a,gotoProduct:function(e){window.addEventListener("beforeunload",(function(){o.commit("cart/modal",null)})),window.addEventListener("pagehide",(function(){o.commit("cart/modal",null)})),window.location.href=e},auth:l}}},o=["data-code"],n={key:0,class:"column is-12"},a={class:"bundle-title"},r={class:"column name"},c={class:"column is-narrow cart-actions-parent"},l={class:"cart-actions"},s=["disabled"],m=[e.createElementVNode("svg",{class:"icon"},[e.createElementVNode("use",{"xlink:href":"#cart-remove"})],-1)],d={class:"column is-narrow image-parent"},u=["src"],p={key:1},b=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],v={class:"column"},g={class:"columns is-gapless mb-0"},k={class:"column"},f={key:0,class:"code"},E={class:"is-hidden","shop-product-category":""},y={class:"title"},N={key:0,"shop-product-name":""},V={key:0,class:"column is-narrow has-text-right is-relative quantity-parent"},h={class:"quantity"},B=["disabled"],w=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-minus"})],-1)],C=["disabled"],_=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-plus"})],-1)],x={key:0,class:"quantity-price"},L=["innerHTML"],q={class:"column is-2 has-text-right"},S=["innerHTML"],D=["innerHTML"],T=["innerHTML"],H=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#arrow-down"})],-1),M={class:"wrapper"},$={class:"column is-narrow"},P=["value","id"],z={class:"column"},F=["for"],O={key:0,class:"option-description"},U={class:"column is-2 has-text-right"},I=["innerHTML"],j={key:0,class:"bundle columns"},A=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("div",{class:"cart-bundle-spacer"})],-1),G={class:"column is-narrow"},J=e.createElementVNode("svg",{class:"bundle-icon"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1),K=["src"],Q={key:1},R=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],W={class:"column"},X={key:0,class:"code"},Y={class:"title"},Z={key:1,class:"bundle columns"},ee=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("div",{class:"cart-bundle-spacer"})],-1),te={class:"column is-narrow"},ie=e.createElementVNode("svg",{class:"bundle-icon"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1),oe=["src"],ne={key:1},ae=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],re={class:"column"},ce={key:0,class:"code"},le={class:"title"};i.render=function(t,i,se,me,de,ue){var pe=e.resolveComponent("wishlist-add");return se.item.deleted?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["columns is-multiline shop-cart-item",{inactive:!1===se.item.attributes.active,"is-bundle":se.item.attributes.bundle}]),"data-code":se.item.attributes.code,"shop-product":""},[se.item.attributes.bundle?(e.openBlock(),e.createElementBlock("div",n,[e.createElementVNode("div",a,e.toDisplayString(t.__("shop.cart.bundle")),1)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",r,[e.createElementVNode("div",{class:e.normalizeClass(["columns",{"mb-0":se.item.attributes.bundle}])},[e.createElementVNode("div",c,[e.createElementVNode("div",l,[e.createElementVNode("button",{class:"remove",onClick:i[0]||(i[0]=function(){return me.remove&&me.remove.apply(me,arguments)}),disabled:me.loading},m,8,s),me.auth&&!se.item.attributes.bundle?(e.openBlock(),e.createBlock(pe,{key:0,id:se.item.attributes.productId?se.item.attributes.productId:se.item.id,item:se.item},null,8,["id","item"])):e.createCommentVNode("v-if",!0)])]),e.createElementVNode("div",d,[e.createElementVNode("a",{onClick:i[1]||(i[1]=function(e){return me.gotoProduct(se.item.attributes.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!se.item.attributes.image}])},[se.item.attributes.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:se.item.attributes.image},null,8,u)):(e.openBlock(),e.createElementBlock("svg",p,b))],2)])]),e.createElementVNode("div",v,[e.createElementVNode("div",g,[e.createElementVNode("div",k,[e.renderSlot(t.$slots,"item-name",{item:se.item,gotoProduct:me.gotoProduct},(function(){return[se.item.attributes.code?(e.openBlock(),e.createElementBlock("div",f,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(se.item.attributes.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",E,e.toDisplayString(se.item.attributes.categoryFull),1),e.createElementVNode("div",y,[!1===se.item.attributes.active?(e.openBlock(),e.createElementBlock("span",N,e.toDisplayString(se.item.name),1)):(e.openBlock(),e.createElementBlock("a",{key:1,onClick:i[2]||(i[2]=function(e){return me.gotoProduct(se.item.attributes.href)})},e.toDisplayString(se.item.name),1))])]}))]),(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",h,[e.createElementVNode("button",{class:"button decrease",onClick:i[3]||(i[3]=function(){return me.decrease&&me.decrease.apply(me,arguments)}),disabled:me.loading||1==se.item.quantity},w,8,B),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":i[4]||(i[4]=function(e){return se.item.quantity=e}),disabled:""},null,512),[[e.vModelText,se.item.quantity]]),e.createElementVNode("button",{class:"button increase",onClick:i[5]||(i[5]=function(){return me.increase&&me.increase.apply(me,arguments)}),disabled:me.loading},_,8,C)]),se.item.quantity>1?(e.openBlock(),e.createElementBlock("div",x,[e.createElementVNode("span",{innerHTML:t.$filters.price(se.item.attributes.price)},null,8,L),e.createTextVNode(" / "+e.toDisplayString(t.__("shop.cart.q")),1)])):e.createCommentVNode("v-if",!0)])),e.createElementVNode("div",q,[e.renderSlot(t.$slots,"item-price",{item:se.item,filters:t.$filters},(function(){return[e.createElementVNode("div",{class:e.normalizeClass(["price",{"bundle-price":se.item.attributes.bundle}])},[se.item.attributes.priceOld?(e.openBlock(),e.createElementBlock("div",{key:0,class:"price-old",innerHTML:t.$filters.price(se.item.attributes.priceOld*se.item.quantity)},null,8,S)):e.createCommentVNode("v-if",!0),se.item.attributes.bundle&&se.item.attributes.amount?(e.openBlock(),e.createElementBlock("div",{key:1,class:"bundle-amount",innerHTML:t.__("shop.cart.bundle_amount")+(se.item.attributes.amount.percent?se.item.attributes.amount.percent+"%":t.$filters.price(se.item.attributes.amount.sum*se.item.quantity))},null,8,D)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",{innerHTML:t.$filters.price(se.item.attributes.price*se.item.quantity),"shop-product-price":""},null,8,T)],2)]}))])]),se.item.options&&se.item.options.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["options",{"is-toggled":me.optionsToggled}])},[e.createElementVNode("div",{class:"toggler",onClick:i[6]||(i[6]=function(e){return me.optionsToggled=!me.optionsToggled})},[e.createElementVNode("span",null,e.toDisplayString(t.__("shop.cart.additional"))+" "+e.toDisplayString(se.item.options.length),1),H]),e.withDirectives(e.createElementVNode("div",M,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(se.item.options,(function(o,n){return e.openBlock(),e.createElementBlock("div",{key:n,class:e.normalizeClass(["columns",{"is-checked":-1!==me.options.indexOf(o.id)}])},[e.createElementVNode("div",$,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"checkbox","onUpdate:modelValue":i[7]||(i[7]=function(e){return me.options=e}),value:o.id,id:"option-"+se.item.id+"-"+o.id},null,8,P),[[e.vModelCheckbox,me.options]])]),e.createElementVNode("div",z,[e.createElementVNode("label",{class:"option-title is-clickable",for:"option-"+se.item.id+"-"+o.id},e.toDisplayString(o.name),9,F),o.description?(e.openBlock(),e.createElementBlock("div",O,e.toDisplayString(o.description),1)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",U,[e.createTextVNode("+"),e.createElementVNode("span",{innerHTML:t.$filters.price(o.price)},null,8,I)])],2)})),128))],512),[[e.vShow,me.optionsToggled]])],2)):e.createCommentVNode("v-if",!0)])],2),se.item.attributes.bundle?(e.openBlock(),e.createElementBlock("div",j,[A,e.createElementVNode("div",G,[J,e.createElementVNode("a",{onClick:i[8]||(i[8]=function(e){return me.gotoProduct(se.item.attributes.second.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!se.item.attributes.second.image}])},[se.item.attributes.second.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:se.item.attributes.second.image},null,8,K)):(e.openBlock(),e.createElementBlock("svg",Q,R))],2)])]),e.createElementVNode("div",W,[se.item.attributes.second.code?(e.openBlock(),e.createElementBlock("div",X,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(se.item.attributes.second.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",Y,[e.createElementVNode("a",{onClick:i[9]||(i[9]=function(e){return me.gotoProduct(se.item.attributes.second.href)})},e.toDisplayString(se.item.attributes.second.name),1)])])])):e.createCommentVNode("v-if",!0),se.item.attributes.bundle&&se.item.attributes.third?(e.openBlock(),e.createElementBlock("div",Z,[ee,e.createElementVNode("div",te,[ie,e.createElementVNode("a",{onClick:i[10]||(i[10]=function(e){return me.gotoProduct(se.item.attributes.third.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!se.item.attributes.third.image}])},[se.item.attributes.third.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:se.item.attributes.third.image},null,8,oe)):(e.openBlock(),e.createElementBlock("svg",ne,ae))],2)])]),e.createElementVNode("div",re,[se.item.attributes.third.code?(e.openBlock(),e.createElementBlock("div",ce,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(se.item.attributes.third.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",le,[e.createElementVNode("a",{onClick:i[11]||(i[11]=function(e){return me.gotoProduct(se.item.attributes.third.href)})},e.toDisplayString(se.item.attributes.third.name),1)])])])):e.createCommentVNode("v-if",!0)])],10,o))},module.exports=i;
2
2
  //# sourceMappingURL=CartItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartItem.js","sources":["../../../../src/components/shop/cart/CartItem.vue","../../../../src/components/shop/cart/CartItem.vue?vue&type=template&id=39d21427&lang.js"],"sourcesContent":["<template>\n <div class=\"columns is-multiline shop-cart-item\" v-if=\"!item.deleted\" v-bind:class=\"{ inactive: item.attributes.active === false, 'is-bundle': item.attributes.bundle }\">\n <div class=\"column is-12\" v-if=\"item.attributes.bundle\">\n <div class=\"bundle-title\">{{ __('shop.cart.bundle') }}</div>\n </div>\n <div class=\"column name\">\n <div class=\"columns\" v-bind:class=\"{ 'mb-0': item.attributes.bundle }\">\n <div class=\"column is-narrow cart-actions-parent\">\n <div class=\"cart-actions\">\n <button class=\"remove\" @click=\"remove\" :disabled=\"loading\">\n <svg class=\"icon\">\n <use xlink:href=\"#cart-remove\" />\n </svg>\n </button>\n <wishlist-add :id=\"item.id\" v-if=\"auth && !item.attributes.bundle\"></wishlist-add>\n </div>\n </div>\n <div class=\"column is-narrow image-parent\">\n <a @click=\"gotoProduct(item.attributes.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.image }\">\n <img :src=\"item.attributes.image\" v-if=\"item.attributes.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"columns is-gapless mb-0\">\n <div class=\"column\">\n <slot name=\"item-name\" :item=\"item\" :gotoProduct=\"gotoProduct\">\n <div class=\"code\" v-if=\"item.attributes.code\">{{ __('shop.cart.code') }} {{ item.attributes.code }}</div>\n <div class=\"title\">\n <span v-if=\"item.attributes.active === false\">\n {{ item.name }}\n </span>\n <a @click=\"gotoProduct(item.attributes.href)\" v-else>{{ item.name }}</a>\n </div>\n </slot>\n </div>\n <div class=\"column is-narrow has-text-right is-relative quantity-parent\" v-if=\"true || $env.shop.isChangeQuantity\">\n <div class=\"quantity\">\n <button class=\"button decrease\" @click=\"decrease\" :disabled=\"loading || item.quantity == 1\">\n <svg>\n <use xlink:href=\"#cart-minus\" />\n </svg>\n </button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"item.quantity\" disabled />\n <button class=\"button increase\" @click=\"increase\" :disabled=\"loading\">\n <svg>\n <use xlink:href=\"#cart-plus\" />\n </svg>\n </button>\n </div>\n <div class=\"quantity-price\" v-if=\"item.quantity > 1\"><span v-html=\"$filters.price(item.attributes.price)\"></span> / {{ __('shop.cart.q') }}</div>\n </div>\n <div class=\"column is-narrow has-text-right\" v-else>{{ item.quantity }}✕</div>\n <div class=\"column is-2 has-text-right\">\n <slot name=\"item-price\" :item=\"item\" :filters=\"$filters\">\n <div class=\"price\" v-bind:class=\"{ 'bundle-price': item.attributes.bundle }\">\n <div v-if=\"item.attributes.priceOld\" class=\"price-old\" v-html=\"$filters.price(item.attributes.priceOld * item.quantity)\"></div>\n <div class=\"bundle-amount\" v-if=\"item.attributes.bundle && item.attributes.amount\" v-html=\"__('shop.cart.bundle_amount') + (item.attributes.amount.percent ? item.attributes.amount.percent + '%' : $filters.price(item.attributes.amount.sum * item.quantity))\"></div>\n <div v-html=\"$filters.price(item.attributes.price * item.quantity)\"></div>\n </div>\n </slot>\n </div>\n </div>\n <div class=\"options\" v-if=\"item.options && item.options.length\" v-bind:class=\"{ 'is-toggled': optionsToggled }\">\n <div class=\"toggler\" @click=\"optionsToggled = !optionsToggled\">\n <span>{{ __('shop.cart.additional') }} {{ item.options.length }}</span>\n <svg>\n <use xlink:href=\"#arrow-down\" />\n </svg>\n </div>\n <div class=\"wrapper\" v-show=\"optionsToggled\">\n <div v-for=\"(option, index) in item.options\" v-bind:key=\"index\" class=\"columns\" v-bind:class=\"{ 'is-checked': options.indexOf(option.id) !== -1 }\">\n <div class=\"column is-narrow\">\n <input type=\"checkbox\" class=\"checkbox\" v-model=\"options\" :value=\"option.id\" :id=\"'option-' + item.id + '-' + option.id\" />\n </div>\n <div class=\"column\">\n <label class=\"option-title is-clickable\" :for=\"'option-' + item.id + '-' + option.id\">{{ option.name }}</label>\n <div class=\"option-description\" v-if=\"option.description\">{{ option.description }}</div>\n </div>\n <div class=\"column is-2 has-text-right\">+<span v-html=\"$filters.price(option.price)\"></span></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class=\"bundle columns\" v-if=\"item.attributes.bundle\">\n <div class=\"column is-narrow\">\n <div class=\"cart-bundle-spacer\"></div>\n </div>\n <div class=\"column is-narrow\">\n <svg class=\"bundle-icon\">\n <use xlink:href=\"#bundle-plus\" />\n </svg>\n <a @click=\"gotoProduct(item.attributes.second.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.second.image }\">\n <img :src=\"item.attributes.second.image\" v-if=\"item.attributes.second.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"code\" v-if=\"item.attributes.second.code\">{{ __('shop.cart.code') }} {{ item.attributes.second.code }}</div>\n <div class=\"title\">\n <a @click=\"gotoProduct(item.attributes.second.href)\">{{ item.attributes.second.name }}</a>\n </div>\n </div>\n </div>\n <div class=\"bundle columns\" v-if=\"item.attributes.bundle && item.attributes.third\">\n <div class=\"column is-narrow\">\n <div class=\"cart-bundle-spacer\"></div>\n </div>\n <div class=\"column is-narrow\">\n <svg class=\"bundle-icon\">\n <use xlink:href=\"#bundle-plus\" />\n </svg>\n <a @click=\"gotoProduct(item.attributes.third.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.third.image }\">\n <img :src=\"item.attributes.third.image\" v-if=\"item.attributes.third.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"code\" v-if=\"item.attributes.third.code\">{{ __('shop.cart.code') }} {{ item.attributes.third.code }}</div>\n <div class=\"title\">\n <a @click=\"gotoProduct(item.attributes.third.href)\">{{ item.attributes.third.name }}</a>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, watch } from 'vue';\nimport { useStore } from 'vuex';\n\nexport default {\n name: 'CartItem',\n props: {\n item: Object\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const input = ref();\n const options = ref(props.item.attributes.options && props.item.attributes.options.length ? props.item.attributes.options : []);\n const optionsToggled = ref(false);\n const auth = computed(() => store.getters['auth/is']);\n\n if (props.item.attributes.options && props.item.attributes.options.length) {\n optionsToggled.value = true;\n }\n\n const name = props.item.name;\n const price = props.item.attributes.price;\n const code = props.item.attributes.code;\n const category = props.item.attributes.categoryFull ? props.item.attributes.categoryFull : props.item.attributes.category;\n const brand = props.item.attributes.brand;\n const property = props.item.attributes.property;\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.item.id,\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n const q = props.item.quantity;\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'remove_from_cart'\n };\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const increase = () => {\n quantity(+1);\n };\n\n const decrease = () => {\n quantity(-1);\n };\n\n const quantity = (difference) => {\n loading.value = true;\n\n store.dispatch('cart/add', {\n product: {\n id: props.item.id,\n quantity: difference\n },\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n const q = props.item.quantity;\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (props.item.attributes.index) {\n object.ecommerce.items[0].index = props.item.attributes.index;\n }\n\n if (props.item.attributes.itemListName) {\n object.ecommerce.items[0].item_list_name = props.item.attributes.itemListName;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n if (props.item.options && props.item.options.length) {\n watch(options, (options) => {\n loading.value = true;\n\n store.dispatch('cart/options', {\n product: {\n id: props.item.id,\n options: Object.values(options)\n },\n finally: () => {\n loading.value = false;\n }\n });\n });\n }\n\n const gotoProduct = (href) => {\n window.addEventListener('beforeunload', () => {\n store.commit('cart/modal', null);\n });\n\n window.addEventListener('pagehide', () => {\n store.commit('cart/modal', null);\n });\n\n window.location.href = href;\n };\n\n return {\n loading,\n increase,\n decrease,\n remove,\n options,\n optionsToggled,\n input,\n gotoProduct,\n auth\n };\n }\n};\n</script>","<template>\n <div class=\"columns is-multiline shop-cart-item\" v-if=\"!item.deleted\" v-bind:class=\"{ inactive: item.attributes.active === false, 'is-bundle': item.attributes.bundle }\">\n <div class=\"column is-12\" v-if=\"item.attributes.bundle\">\n <div class=\"bundle-title\">{{ __('shop.cart.bundle') }}</div>\n </div>\n <div class=\"column name\">\n <div class=\"columns\" v-bind:class=\"{ 'mb-0': item.attributes.bundle }\">\n <div class=\"column is-narrow cart-actions-parent\">\n <div class=\"cart-actions\">\n <button class=\"remove\" @click=\"remove\" :disabled=\"loading\">\n <svg class=\"icon\">\n <use xlink:href=\"#cart-remove\" />\n </svg>\n </button>\n <wishlist-add :id=\"item.id\" v-if=\"auth && !item.attributes.bundle\"></wishlist-add>\n </div>\n </div>\n <div class=\"column is-narrow image-parent\">\n <a @click=\"gotoProduct(item.attributes.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.image }\">\n <img :src=\"item.attributes.image\" v-if=\"item.attributes.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"columns is-gapless mb-0\">\n <div class=\"column\">\n <slot name=\"item-name\" :item=\"item\" :gotoProduct=\"gotoProduct\">\n <div class=\"code\" v-if=\"item.attributes.code\">{{ __('shop.cart.code') }} {{ item.attributes.code }}</div>\n <div class=\"title\">\n <span v-if=\"item.attributes.active === false\">\n {{ item.name }}\n </span>\n <a @click=\"gotoProduct(item.attributes.href)\" v-else>{{ item.name }}</a>\n </div>\n </slot>\n </div>\n <div class=\"column is-narrow has-text-right is-relative quantity-parent\" v-if=\"true || $env.shop.isChangeQuantity\">\n <div class=\"quantity\">\n <button class=\"button decrease\" @click=\"decrease\" :disabled=\"loading || item.quantity == 1\">\n <svg>\n <use xlink:href=\"#cart-minus\" />\n </svg>\n </button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"item.quantity\" disabled />\n <button class=\"button increase\" @click=\"increase\" :disabled=\"loading\">\n <svg>\n <use xlink:href=\"#cart-plus\" />\n </svg>\n </button>\n </div>\n <div class=\"quantity-price\" v-if=\"item.quantity > 1\"><span v-html=\"$filters.price(item.attributes.price)\"></span> / {{ __('shop.cart.q') }}</div>\n </div>\n <div class=\"column is-narrow has-text-right\" v-else>{{ item.quantity }}✕</div>\n <div class=\"column is-2 has-text-right\">\n <slot name=\"item-price\" :item=\"item\" :filters=\"$filters\">\n <div class=\"price\" v-bind:class=\"{ 'bundle-price': item.attributes.bundle }\">\n <div v-if=\"item.attributes.priceOld\" class=\"price-old\" v-html=\"$filters.price(item.attributes.priceOld * item.quantity)\"></div>\n <div class=\"bundle-amount\" v-if=\"item.attributes.bundle && item.attributes.amount\" v-html=\"__('shop.cart.bundle_amount') + (item.attributes.amount.percent ? item.attributes.amount.percent + '%' : $filters.price(item.attributes.amount.sum * item.quantity))\"></div>\n <div v-html=\"$filters.price(item.attributes.price * item.quantity)\"></div>\n </div>\n </slot>\n </div>\n </div>\n <div class=\"options\" v-if=\"item.options && item.options.length\" v-bind:class=\"{ 'is-toggled': optionsToggled }\">\n <div class=\"toggler\" @click=\"optionsToggled = !optionsToggled\">\n <span>{{ __('shop.cart.additional') }} {{ item.options.length }}</span>\n <svg>\n <use xlink:href=\"#arrow-down\" />\n </svg>\n </div>\n <div class=\"wrapper\" v-show=\"optionsToggled\">\n <div v-for=\"(option, index) in item.options\" v-bind:key=\"index\" class=\"columns\" v-bind:class=\"{ 'is-checked': options.indexOf(option.id) !== -1 }\">\n <div class=\"column is-narrow\">\n <input type=\"checkbox\" class=\"checkbox\" v-model=\"options\" :value=\"option.id\" :id=\"'option-' + item.id + '-' + option.id\" />\n </div>\n <div class=\"column\">\n <label class=\"option-title is-clickable\" :for=\"'option-' + item.id + '-' + option.id\">{{ option.name }}</label>\n <div class=\"option-description\" v-if=\"option.description\">{{ option.description }}</div>\n </div>\n <div class=\"column is-2 has-text-right\">+<span v-html=\"$filters.price(option.price)\"></span></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class=\"bundle columns\" v-if=\"item.attributes.bundle\">\n <div class=\"column is-narrow\">\n <div class=\"cart-bundle-spacer\"></div>\n </div>\n <div class=\"column is-narrow\">\n <svg class=\"bundle-icon\">\n <use xlink:href=\"#bundle-plus\" />\n </svg>\n <a @click=\"gotoProduct(item.attributes.second.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.second.image }\">\n <img :src=\"item.attributes.second.image\" v-if=\"item.attributes.second.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"code\" v-if=\"item.attributes.second.code\">{{ __('shop.cart.code') }} {{ item.attributes.second.code }}</div>\n <div class=\"title\">\n <a @click=\"gotoProduct(item.attributes.second.href)\">{{ item.attributes.second.name }}</a>\n </div>\n </div>\n </div>\n <div class=\"bundle columns\" v-if=\"item.attributes.bundle && item.attributes.third\">\n <div class=\"column is-narrow\">\n <div class=\"cart-bundle-spacer\"></div>\n </div>\n <div class=\"column is-narrow\">\n <svg class=\"bundle-icon\">\n <use xlink:href=\"#bundle-plus\" />\n </svg>\n <a @click=\"gotoProduct(item.attributes.third.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.third.image }\">\n <img :src=\"item.attributes.third.image\" v-if=\"item.attributes.third.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"code\" v-if=\"item.attributes.third.code\">{{ __('shop.cart.code') }} {{ item.attributes.third.code }}</div>\n <div class=\"title\">\n <a @click=\"gotoProduct(item.attributes.third.href)\">{{ item.attributes.third.name }}</a>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, watch } from 'vue';\nimport { useStore } from 'vuex';\n\nexport default {\n name: 'CartItem',\n props: {\n item: Object\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const input = ref();\n const options = ref(props.item.attributes.options && props.item.attributes.options.length ? props.item.attributes.options : []);\n const optionsToggled = ref(false);\n const auth = computed(() => store.getters['auth/is']);\n\n if (props.item.attributes.options && props.item.attributes.options.length) {\n optionsToggled.value = true;\n }\n\n const name = props.item.name;\n const price = props.item.attributes.price;\n const code = props.item.attributes.code;\n const category = props.item.attributes.categoryFull ? props.item.attributes.categoryFull : props.item.attributes.category;\n const brand = props.item.attributes.brand;\n const property = props.item.attributes.property;\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.item.id,\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n const q = props.item.quantity;\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'remove_from_cart'\n };\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const increase = () => {\n quantity(+1);\n };\n\n const decrease = () => {\n quantity(-1);\n };\n\n const quantity = (difference) => {\n loading.value = true;\n\n store.dispatch('cart/add', {\n product: {\n id: props.item.id,\n quantity: difference\n },\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n const q = props.item.quantity;\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (props.item.attributes.index) {\n object.ecommerce.items[0].index = props.item.attributes.index;\n }\n\n if (props.item.attributes.itemListName) {\n object.ecommerce.items[0].item_list_name = props.item.attributes.itemListName;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n if (props.item.options && props.item.options.length) {\n watch(options, (options) => {\n loading.value = true;\n\n store.dispatch('cart/options', {\n product: {\n id: props.item.id,\n options: Object.values(options)\n },\n finally: () => {\n loading.value = false;\n }\n });\n });\n }\n\n const gotoProduct = (href) => {\n window.addEventListener('beforeunload', () => {\n store.commit('cart/modal', null);\n });\n\n window.addEventListener('pagehide', () => {\n store.commit('cart/modal', null);\n });\n\n window.location.href = href;\n };\n\n return {\n loading,\n increase,\n decrease,\n remove,\n options,\n optionsToggled,\n input,\n gotoProduct,\n auth\n };\n }\n};\n</script>"],"names":["name","props","item","Object","setup","store","useStore","loading","ref","input","options","attributes","length","optionsToggled","auth","computed","getters","value","price","code","category","categoryFull","brand","property","quantity","difference","dispatch","product","id","callback","q","object","ecommerce","currency","parseFloat","items","item_name","item_id","event","item_brand","index","itemListName","item_list_name","indexOf","split","forEach","segment","trim","item_category","item_variant","$env","debug","console","log","window","dataLayer","push","watch","values","increase","decrease","remove","gotoProduct","href","addEventListener","commit","location","_createElementVNode","$props","deleted","_createElementBlock","active","bundle","_hoisted_1","_hoisted_2","_ctx","_hoisted_3","_hoisted_4","_hoisted_5","onClick","$setup","disabled","_createBlock","_hoisted_9","image","src","_hoisted_14","_hoisted_15","_hoisted_16","_renderSlot","_hoisted_17","_hoisted_18","_hoisted_20","_hoisted_21","type","min","_hoisted_28","innerHTML","_hoisted_31","filters","priceOld","amount","percent","sum","_hoisted_35","_hoisted_36","option","key","_hoisted_37","_hoisted_39","description","_hoisted_41","_hoisted_42","_hoisted_44","_hoisted_45","_hoisted_46","_hoisted_47","second","_hoisted_52","_hoisted_53","_hoisted_54","third","_hoisted_55","_hoisted_56","_hoisted_57","_hoisted_58","_hoisted_63","_hoisted_64","_hoisted_65"],"mappings":"sDAgJe,CACXA,KAAM,WACNC,MAAO,CACHC,KAAMC,QAEVC,eAAMH,OACII,EAAQC,aACRC,EAAUC,OAAI,GACdC,EAAQD,QACRE,EAAUF,MAAIP,EAAMC,KAAKS,WAAWD,SAAWT,EAAMC,KAAKS,WAAWD,QAAQE,OAASX,EAAMC,KAAKS,WAAWD,QAAU,IACtHG,EAAiBL,OAAI,GACrBM,EAAOC,YAAS,kBAAMV,EAAMW,QAAQ,cAEtCf,EAAMC,KAAKS,WAAWD,SAAWT,EAAMC,KAAKS,WAAWD,QAAQE,SAC/DC,EAAeI,OAAQ,OAGrBjB,EAAOC,EAAMC,KAAKF,KAClBkB,EAAQjB,EAAMC,KAAKS,WAAWO,MAC9BC,EAAOlB,EAAMC,KAAKS,WAAWQ,KAC7BC,EAAWnB,EAAMC,KAAKS,WAAWU,aAAepB,EAAMC,KAAKS,WAAWU,aAAepB,EAAMC,KAAKS,WAAWS,SAC3GE,EAAQrB,EAAMC,KAAKS,WAAWW,MAC9BC,EAAWtB,EAAMC,KAAKS,WAAWY,SAkEjCC,EAAW,SAAC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AW8G,MAAMtG,0CACxGgD,2BAAA6D,IACI7D,0BAAIY,yCAAOC,eAAYZ,QAAKzD,WAAW8G,MAAM1D,2BAAUK,QAAKzD,WAAW8G,MAAMzH"}
1
+ {"version":3,"file":"CartItem.js","sources":["../../../../src/components/shop/cart/CartItem.vue","../../../../src/components/shop/cart/CartItem.vue?vue&type=template&id=5cfe5641&lang.js"],"sourcesContent":["<template>\n <div class=\"columns is-multiline shop-cart-item\" v-if=\"!item.deleted\" v-bind:class=\"{ inactive: item.attributes.active === false, 'is-bundle': item.attributes.bundle }\" :data-code=\"item.attributes.code\" shop-product>\n <div class=\"column is-12\" v-if=\"item.attributes.bundle\">\n <div class=\"bundle-title\">{{ __('shop.cart.bundle') }}</div>\n </div>\n <div class=\"column name\">\n <div class=\"columns\" v-bind:class=\"{ 'mb-0': item.attributes.bundle }\">\n <div class=\"column is-narrow cart-actions-parent\">\n <div class=\"cart-actions\">\n <button class=\"remove\" @click=\"remove\" :disabled=\"loading\">\n <svg class=\"icon\">\n <use xlink:href=\"#cart-remove\" />\n </svg>\n </button>\n <wishlist-add :id=\"item.attributes.productId ? item.attributes.productId : item.id\" :item=\"item\" v-if=\"auth && !item.attributes.bundle\"></wishlist-add>\n </div>\n </div>\n <div class=\"column is-narrow image-parent\">\n <a @click=\"gotoProduct(item.attributes.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.image }\">\n <img :src=\"item.attributes.image\" v-if=\"item.attributes.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"columns is-gapless mb-0\">\n <div class=\"column\">\n <slot name=\"item-name\" :item=\"item\" :gotoProduct=\"gotoProduct\">\n <div class=\"code\" v-if=\"item.attributes.code\">{{ __('shop.cart.code') }} {{ item.attributes.code }}</div>\n <div class=\"is-hidden\" shop-product-category>{{ item.attributes.categoryFull }}</div>\n <div class=\"title\">\n <span v-if=\"item.attributes.active === false\" shop-product-name>\n {{ item.name }}\n </span>\n <a @click=\"gotoProduct(item.attributes.href)\" v-else>{{ item.name }}</a>\n </div>\n </slot>\n </div>\n <div class=\"column is-narrow has-text-right is-relative quantity-parent\" v-if=\"true || $env.shop.isChangeQuantity\">\n <div class=\"quantity\">\n <button class=\"button decrease\" @click=\"decrease\" :disabled=\"loading || item.quantity == 1\">\n <svg>\n <use xlink:href=\"#cart-minus\" />\n </svg>\n </button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"item.quantity\" disabled />\n <button class=\"button increase\" @click=\"increase\" :disabled=\"loading\">\n <svg>\n <use xlink:href=\"#cart-plus\" />\n </svg>\n </button>\n </div>\n <div class=\"quantity-price\" v-if=\"item.quantity > 1\"><span v-html=\"$filters.price(item.attributes.price)\"></span> / {{ __('shop.cart.q') }}</div>\n </div>\n <div class=\"column is-narrow has-text-right\" v-else>{{ item.quantity }}✕</div>\n <div class=\"column is-2 has-text-right\">\n <slot name=\"item-price\" :item=\"item\" :filters=\"$filters\">\n <div class=\"price\" v-bind:class=\"{ 'bundle-price': item.attributes.bundle }\">\n <div v-if=\"item.attributes.priceOld\" class=\"price-old\" v-html=\"$filters.price(item.attributes.priceOld * item.quantity)\"></div>\n <div class=\"bundle-amount\" v-if=\"item.attributes.bundle && item.attributes.amount\" v-html=\"__('shop.cart.bundle_amount') + (item.attributes.amount.percent ? item.attributes.amount.percent + '%' : $filters.price(item.attributes.amount.sum * item.quantity))\"></div>\n <div v-html=\"$filters.price(item.attributes.price * item.quantity)\" shop-product-price></div>\n </div>\n </slot>\n </div>\n </div>\n <div class=\"options\" v-if=\"item.options && item.options.length\" v-bind:class=\"{ 'is-toggled': optionsToggled }\">\n <div class=\"toggler\" @click=\"optionsToggled = !optionsToggled\">\n <span>{{ __('shop.cart.additional') }} {{ item.options.length }}</span>\n <svg>\n <use xlink:href=\"#arrow-down\" />\n </svg>\n </div>\n <div class=\"wrapper\" v-show=\"optionsToggled\">\n <div v-for=\"(option, index) in item.options\" v-bind:key=\"index\" class=\"columns\" v-bind:class=\"{ 'is-checked': options.indexOf(option.id) !== -1 }\">\n <div class=\"column is-narrow\">\n <input type=\"checkbox\" class=\"checkbox\" v-model=\"options\" :value=\"option.id\" :id=\"'option-' + item.id + '-' + option.id\" />\n </div>\n <div class=\"column\">\n <label class=\"option-title is-clickable\" :for=\"'option-' + item.id + '-' + option.id\">{{ option.name }}</label>\n <div class=\"option-description\" v-if=\"option.description\">{{ option.description }}</div>\n </div>\n <div class=\"column is-2 has-text-right\">+<span v-html=\"$filters.price(option.price)\"></span></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class=\"bundle columns\" v-if=\"item.attributes.bundle\">\n <div class=\"column is-narrow\">\n <div class=\"cart-bundle-spacer\"></div>\n </div>\n <div class=\"column is-narrow\">\n <svg class=\"bundle-icon\">\n <use xlink:href=\"#bundle-plus\" />\n </svg>\n <a @click=\"gotoProduct(item.attributes.second.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.second.image }\">\n <img :src=\"item.attributes.second.image\" v-if=\"item.attributes.second.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"code\" v-if=\"item.attributes.second.code\">{{ __('shop.cart.code') }} {{ item.attributes.second.code }}</div>\n <div class=\"title\">\n <a @click=\"gotoProduct(item.attributes.second.href)\">{{ item.attributes.second.name }}</a>\n </div>\n </div>\n </div>\n <div class=\"bundle columns\" v-if=\"item.attributes.bundle && item.attributes.third\">\n <div class=\"column is-narrow\">\n <div class=\"cart-bundle-spacer\"></div>\n </div>\n <div class=\"column is-narrow\">\n <svg class=\"bundle-icon\">\n <use xlink:href=\"#bundle-plus\" />\n </svg>\n <a @click=\"gotoProduct(item.attributes.third.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.third.image }\">\n <img :src=\"item.attributes.third.image\" v-if=\"item.attributes.third.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"code\" v-if=\"item.attributes.third.code\">{{ __('shop.cart.code') }} {{ item.attributes.third.code }}</div>\n <div class=\"title\">\n <a @click=\"gotoProduct(item.attributes.third.href)\">{{ item.attributes.third.name }}</a>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, watch } from 'vue';\nimport { useStore } from 'vuex';\n\nexport default {\n name: 'CartItem',\n props: {\n item: Object\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const input = ref();\n const options = ref(props.item.attributes.options && props.item.attributes.options.length ? props.item.attributes.options : []);\n const optionsToggled = ref(false);\n const auth = computed(() => store.getters['auth/is']);\n\n if (props.item.attributes.options && props.item.attributes.options.length) {\n optionsToggled.value = true;\n }\n\n const name = props.item.name;\n const price = props.item.attributes.price;\n const code = props.item.attributes.code;\n const category = props.item.attributes.categoryFull ? props.item.attributes.categoryFull : props.item.attributes.category;\n const brand = props.item.attributes.brand;\n const property = props.item.attributes.property;\n const index = props.item.attributes.index;\n const itemListName = props.item.attributes.itemListName;\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.item.id,\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n const q = props.item.quantity;\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'remove_from_cart'\n };\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (index) {\n object.ecommerce.items[0].index = index;\n }\n\n if (itemListName) {\n object.ecommerce.items[0].item_list_name = itemListName;\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const increase = () => {\n quantity(+1);\n };\n\n const decrease = () => {\n quantity(-1);\n };\n\n const quantity = (difference) => {\n loading.value = true;\n\n store.dispatch('cart/add', {\n product: {\n id: props.item.id,\n quantity: difference\n },\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n if (difference > 0) {\n const q = props.item.quantity;\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: 1,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (props.item.attributes.index) {\n object.ecommerce.items[0].index = props.item.attributes.index;\n }\n\n if (props.item.attributes.itemListName) {\n object.ecommerce.items[0].item_list_name = props.item.attributes.itemListName;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n }\n });\n };\n\n if (props.item.options && props.item.options.length) {\n watch(options, (options) => {\n loading.value = true;\n\n store.dispatch('cart/options', {\n product: {\n id: props.item.id,\n options: Object.values(options)\n },\n finally: () => {\n loading.value = false;\n }\n });\n });\n }\n\n const gotoProduct = (href) => {\n window.addEventListener('beforeunload', () => {\n store.commit('cart/modal', null);\n });\n\n window.addEventListener('pagehide', () => {\n store.commit('cart/modal', null);\n });\n\n window.location.href = href;\n };\n\n return {\n loading,\n increase,\n decrease,\n remove,\n options,\n optionsToggled,\n input,\n gotoProduct,\n auth\n };\n }\n};\n</script>","<template>\n <div class=\"columns is-multiline shop-cart-item\" v-if=\"!item.deleted\" v-bind:class=\"{ inactive: item.attributes.active === false, 'is-bundle': item.attributes.bundle }\" :data-code=\"item.attributes.code\" shop-product>\n <div class=\"column is-12\" v-if=\"item.attributes.bundle\">\n <div class=\"bundle-title\">{{ __('shop.cart.bundle') }}</div>\n </div>\n <div class=\"column name\">\n <div class=\"columns\" v-bind:class=\"{ 'mb-0': item.attributes.bundle }\">\n <div class=\"column is-narrow cart-actions-parent\">\n <div class=\"cart-actions\">\n <button class=\"remove\" @click=\"remove\" :disabled=\"loading\">\n <svg class=\"icon\">\n <use xlink:href=\"#cart-remove\" />\n </svg>\n </button>\n <wishlist-add :id=\"item.attributes.productId ? item.attributes.productId : item.id\" :item=\"item\" v-if=\"auth && !item.attributes.bundle\"></wishlist-add>\n </div>\n </div>\n <div class=\"column is-narrow image-parent\">\n <a @click=\"gotoProduct(item.attributes.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.image }\">\n <img :src=\"item.attributes.image\" v-if=\"item.attributes.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"columns is-gapless mb-0\">\n <div class=\"column\">\n <slot name=\"item-name\" :item=\"item\" :gotoProduct=\"gotoProduct\">\n <div class=\"code\" v-if=\"item.attributes.code\">{{ __('shop.cart.code') }} {{ item.attributes.code }}</div>\n <div class=\"is-hidden\" shop-product-category>{{ item.attributes.categoryFull }}</div>\n <div class=\"title\">\n <span v-if=\"item.attributes.active === false\" shop-product-name>\n {{ item.name }}\n </span>\n <a @click=\"gotoProduct(item.attributes.href)\" v-else>{{ item.name }}</a>\n </div>\n </slot>\n </div>\n <div class=\"column is-narrow has-text-right is-relative quantity-parent\" v-if=\"true || $env.shop.isChangeQuantity\">\n <div class=\"quantity\">\n <button class=\"button decrease\" @click=\"decrease\" :disabled=\"loading || item.quantity == 1\">\n <svg>\n <use xlink:href=\"#cart-minus\" />\n </svg>\n </button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"item.quantity\" disabled />\n <button class=\"button increase\" @click=\"increase\" :disabled=\"loading\">\n <svg>\n <use xlink:href=\"#cart-plus\" />\n </svg>\n </button>\n </div>\n <div class=\"quantity-price\" v-if=\"item.quantity > 1\"><span v-html=\"$filters.price(item.attributes.price)\"></span> / {{ __('shop.cart.q') }}</div>\n </div>\n <div class=\"column is-narrow has-text-right\" v-else>{{ item.quantity }}✕</div>\n <div class=\"column is-2 has-text-right\">\n <slot name=\"item-price\" :item=\"item\" :filters=\"$filters\">\n <div class=\"price\" v-bind:class=\"{ 'bundle-price': item.attributes.bundle }\">\n <div v-if=\"item.attributes.priceOld\" class=\"price-old\" v-html=\"$filters.price(item.attributes.priceOld * item.quantity)\"></div>\n <div class=\"bundle-amount\" v-if=\"item.attributes.bundle && item.attributes.amount\" v-html=\"__('shop.cart.bundle_amount') + (item.attributes.amount.percent ? item.attributes.amount.percent + '%' : $filters.price(item.attributes.amount.sum * item.quantity))\"></div>\n <div v-html=\"$filters.price(item.attributes.price * item.quantity)\" shop-product-price></div>\n </div>\n </slot>\n </div>\n </div>\n <div class=\"options\" v-if=\"item.options && item.options.length\" v-bind:class=\"{ 'is-toggled': optionsToggled }\">\n <div class=\"toggler\" @click=\"optionsToggled = !optionsToggled\">\n <span>{{ __('shop.cart.additional') }} {{ item.options.length }}</span>\n <svg>\n <use xlink:href=\"#arrow-down\" />\n </svg>\n </div>\n <div class=\"wrapper\" v-show=\"optionsToggled\">\n <div v-for=\"(option, index) in item.options\" v-bind:key=\"index\" class=\"columns\" v-bind:class=\"{ 'is-checked': options.indexOf(option.id) !== -1 }\">\n <div class=\"column is-narrow\">\n <input type=\"checkbox\" class=\"checkbox\" v-model=\"options\" :value=\"option.id\" :id=\"'option-' + item.id + '-' + option.id\" />\n </div>\n <div class=\"column\">\n <label class=\"option-title is-clickable\" :for=\"'option-' + item.id + '-' + option.id\">{{ option.name }}</label>\n <div class=\"option-description\" v-if=\"option.description\">{{ option.description }}</div>\n </div>\n <div class=\"column is-2 has-text-right\">+<span v-html=\"$filters.price(option.price)\"></span></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class=\"bundle columns\" v-if=\"item.attributes.bundle\">\n <div class=\"column is-narrow\">\n <div class=\"cart-bundle-spacer\"></div>\n </div>\n <div class=\"column is-narrow\">\n <svg class=\"bundle-icon\">\n <use xlink:href=\"#bundle-plus\" />\n </svg>\n <a @click=\"gotoProduct(item.attributes.second.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.second.image }\">\n <img :src=\"item.attributes.second.image\" v-if=\"item.attributes.second.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"code\" v-if=\"item.attributes.second.code\">{{ __('shop.cart.code') }} {{ item.attributes.second.code }}</div>\n <div class=\"title\">\n <a @click=\"gotoProduct(item.attributes.second.href)\">{{ item.attributes.second.name }}</a>\n </div>\n </div>\n </div>\n <div class=\"bundle columns\" v-if=\"item.attributes.bundle && item.attributes.third\">\n <div class=\"column is-narrow\">\n <div class=\"cart-bundle-spacer\"></div>\n </div>\n <div class=\"column is-narrow\">\n <svg class=\"bundle-icon\">\n <use xlink:href=\"#bundle-plus\" />\n </svg>\n <a @click=\"gotoProduct(item.attributes.third.href)\">\n <figure class=\"image is-square\" v-bind:class=\"{ 'no-thumb': !item.attributes.third.image }\">\n <img :src=\"item.attributes.third.image\" v-if=\"item.attributes.third.image\" />\n <svg v-else>\n <use xlink:href=\"#logo\" />\n </svg>\n </figure>\n </a>\n </div>\n <div class=\"column\">\n <div class=\"code\" v-if=\"item.attributes.third.code\">{{ __('shop.cart.code') }} {{ item.attributes.third.code }}</div>\n <div class=\"title\">\n <a @click=\"gotoProduct(item.attributes.third.href)\">{{ item.attributes.third.name }}</a>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, watch } from 'vue';\nimport { useStore } from 'vuex';\n\nexport default {\n name: 'CartItem',\n props: {\n item: Object\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const input = ref();\n const options = ref(props.item.attributes.options && props.item.attributes.options.length ? props.item.attributes.options : []);\n const optionsToggled = ref(false);\n const auth = computed(() => store.getters['auth/is']);\n\n if (props.item.attributes.options && props.item.attributes.options.length) {\n optionsToggled.value = true;\n }\n\n const name = props.item.name;\n const price = props.item.attributes.price;\n const code = props.item.attributes.code;\n const category = props.item.attributes.categoryFull ? props.item.attributes.categoryFull : props.item.attributes.category;\n const brand = props.item.attributes.brand;\n const property = props.item.attributes.property;\n const index = props.item.attributes.index;\n const itemListName = props.item.attributes.itemListName;\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.item.id,\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n const q = props.item.quantity;\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'remove_from_cart'\n };\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (index) {\n object.ecommerce.items[0].index = index;\n }\n\n if (itemListName) {\n object.ecommerce.items[0].item_list_name = itemListName;\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const increase = () => {\n quantity(+1);\n };\n\n const decrease = () => {\n quantity(-1);\n };\n\n const quantity = (difference) => {\n loading.value = true;\n\n store.dispatch('cart/add', {\n product: {\n id: props.item.id,\n quantity: difference\n },\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n if (difference > 0) {\n const q = props.item.quantity;\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: 1,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (props.item.attributes.index) {\n object.ecommerce.items[0].index = props.item.attributes.index;\n }\n\n if (props.item.attributes.itemListName) {\n object.ecommerce.items[0].item_list_name = props.item.attributes.itemListName;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n }\n });\n };\n\n if (props.item.options && props.item.options.length) {\n watch(options, (options) => {\n loading.value = true;\n\n store.dispatch('cart/options', {\n product: {\n id: props.item.id,\n options: Object.values(options)\n },\n finally: () => {\n loading.value = false;\n }\n });\n });\n }\n\n const gotoProduct = (href) => {\n window.addEventListener('beforeunload', () => {\n store.commit('cart/modal', null);\n });\n\n window.addEventListener('pagehide', () => {\n store.commit('cart/modal', null);\n });\n\n window.location.href = href;\n };\n\n return {\n loading,\n increase,\n decrease,\n remove,\n options,\n optionsToggled,\n input,\n gotoProduct,\n auth\n };\n }\n};\n</script>"],"names":["name","props","item","Object","setup","store","useStore","loading","ref","input","options","attributes","length","optionsToggled","auth","computed","getters","value","price","code","category","categoryFull","brand","property","index","itemListName","quantity","difference","dispatch","product","id","callback","q","object","ecommerce","currency","parseFloat","items","item_name","item_id","event","item_brand","item_list_name","indexOf","split","forEach","segment","trim","item_category","item_variant","$env","debug","console","log","window","dataLayer","push","watch","values","increase","decrease","remove","gotoProduct","href","addEventListener","commit","location","_createElementVNode","$props","deleted","_createElementBlock","active","bundle","_hoisted_2","_hoisted_3","_ctx","_hoisted_4","_hoisted_5","_hoisted_6","onClick","$setup","disabled","_createBlock","productId","_hoisted_10","image","src","_hoisted_15","_hoisted_16","_hoisted_17","_renderSlot","_hoisted_18","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","_hoisted_23","type","min","_hoisted_30","innerHTML","_hoisted_33","filters","priceOld","amount","percent","sum","_hoisted_37","_hoisted_38","option","key","_hoisted_39","_hoisted_41","description","_hoisted_43","_hoisted_44","_hoisted_46","_hoisted_47","_hoisted_48","_hoisted_49","second","_hoisted_54","_hoisted_55","_hoisted_56","third","_hoisted_57","_hoisted_58","_hoisted_59","_hoisted_60","_hoisted_65","_hoisted_66","_hoisted_67"],"mappings":"sDAiJe,CACXA,KAAM,WACNC,MAAO,CACHC,KAAMC,QAEVC,eAAMH,OACII,EAAQC,aACRC,EAAUC,OAAI,GACdC,EAAQD,QACRE,EAAUF,MAAIP,EAAMC,KAAKS,WAAWD,SAAWT,EAAMC,KAAKS,WAAWD,QAAQE,OAASX,EAAMC,KAAKS,WAAWD,QAAU,IACtHG,EAAiBL,OAAI,GACrBM,EAAOC,YAAS,kBAAMV,EAAMW,QAAQ,cAEtCf,EAAMC,KAAKS,WAAWD,SAAWT,EAAMC,KAAKS,WAAWD,QAAQE,SAC/DC,EAAeI,OAAQ,OAGrBjB,EAAOC,EAAMC,KAAKF,KAClBkB,EAAQjB,EAAMC,KAAKS,WAAWO,MAC9BC,EAAOlB,EAAMC,KAAKS,WAAWQ,KAC7BC,EAAWnB,EAAMC,KAAKS,WAAWU,aAAepB,EAAMC,KAAKS,WAAWU,aAAepB,EAAMC,KAAKS,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AAIY,uCAAOC,eAAYZ,QAAKzD,WAAW6G,OAAOzD,2BAAUK,QAAKzD,WAAW6G,OAAOxH,gDAIzDoE,QAAKzD,WAAW6D,QAAUJ,QAAKzD,WAAWiH,qBAA5EtD,2BAAAuD,GACIC,GAGA3D,2BAAA4D,IACIC,GAGA7D,0BAAIY,yCAAOC,eAAYZ,QAAKzD,WAAWiH,MAAM7D,UACzCI,uDAAc,+BAA+CC,QAAKzD,WAAWiH,MAAMvC,WACjCjB,QAAKzD,WAAWiH,MAAMvC,qBAApEf,kCAAMgB,IAAKlB,QAAKzD,WAAWiH,MAAMvC,kCACjCf,2CAMZH,2BAAA8D,IAC4B7D,QAAKzD,WAAWiH,MAAMzG,oBAA9CmD,2BAAA4D,qBAAuDvD,8CAA2BP,QAAKzD,WAAWiH,MAAMzG,0CACxGgD,2BAAAgE,IACIhE,0BAAIY,yCAAOC,eAAYZ,QAAKzD,WAAWiH,MAAM7D,2BAAUK,QAAKzD,WAAWiH,MAAM5H"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),r=e.defineComponent({name:"viewer",props:{slug:String,code:String,brand:String,category:String,property:String},setup:function(r){var t=e.ref(null);return $http.post($ziggy("api.viewed"),{action:"view",slug:r.slug}),e.onMounted((function(){var e=t.value.closest("[shop-product]"),o=e.querySelector("[shop-product-name]").textContent,i=e.querySelector("[shop-product-price]")?e.querySelector("[shop-product-price]").childNodes[0].nodeValue.replace(/ /g,""):null,c=r.code,n={ecommerce:{currency:"UAH",value:parseFloat(i),items:[{item_name:o,item_id:c,item_list_name:"Direct",index:1}]},event:"view_item"};if("undefined"!=typeof Storage){var m=sessionStorage.getItem("productIndex");m&&(m=JSON.parse(m),n.ecommerce.items[0].item_list_name=m.item_list_name,n.ecommerce.items[0].index=m.index)}i&&(n.ecommerce.items[0].price=parseFloat(i)),r.brand&&(n.ecommerce.items[0].item_brand=r.brand),r.category&&(-1!==r.category.indexOf("/")?r.category.split("/").forEach((function(e,r){n.ecommerce.items[0]["item_category"+(r?r+1:"")]=e.trim()})):n.ecommerce.items[0].item_category=r.category),r.property&&(n.ecommerce.items[0].item_variant=r.property),$env.debug.ecommerce&&console.log(n),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(n))})),{viewer:t}}}),t={class:"is-hidden",ref:"viewer"};r.render=function(r,o,i,c,n,m){return e.openBlock(),e.createElementBlock("span",t,null,512)},module.exports=r;
1
+ "use strict";var e=require("vue"),r=e.defineComponent({name:"viewer",props:{slug:String,code:String,brand:String,category:String,property:String},setup:function(r){var t=e.ref(null);return $http.post($ziggy("api.viewed"),{action:"view",slug:r.slug}),e.onMounted((function(){var e=t.value.closest("[shop-product]"),o=e.querySelector("[shop-product-name]").textContent,i=e.querySelector("[shop-product-price]")?e.querySelector("[shop-product-price]").childNodes[0].nodeValue.replace(/ /g,""):null,c=r.code,n=document.referrer,m={ecommerce:{currency:"UAH",value:parseFloat(i),items:[{item_name:o,item_id:c,item_list_name:n.includes("/post")?"Новини":"Direct",index:1}]},event:"view_item"};if("undefined"!=typeof Storage){var a=sessionStorage.getItem("productIndex");a&&(a=JSON.parse(a),m.ecommerce.items[0].item_list_name=a.item_list_name,m.ecommerce.items[0].index=a.index)}i&&(m.ecommerce.items[0].price=parseFloat(i)),r.brand&&(m.ecommerce.items[0].item_brand=r.brand),r.category&&(-1!==r.category.indexOf("/")?r.category.split("/").forEach((function(e,r){m.ecommerce.items[0]["item_category"+(r?r+1:"")]=e.trim()})):m.ecommerce.items[0].item_category=r.category),r.property&&(m.ecommerce.items[0].item_variant=r.property),$env.debug.ecommerce&&console.log(m),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(m))})),{viewer:t}}}),t={class:"is-hidden",ref:"viewer"};r.render=function(r,o,i,c,n,m){return e.openBlock(),e.createElementBlock("span",t,null,512)},module.exports=r;
2
2
  //# sourceMappingURL=Viewer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Viewer.js","sources":["../../../../src/components/shop/viewed/Viewer.vue","../../../../src/components/shop/viewed/Viewer.vue?vue&type=template&id=41ca80ef&lang.js"],"sourcesContent":["<template>\n <span class=\"is-hidden\" ref=\"viewer\"></span>\n</template>\n<script>\nimport { ref, onMounted, defineComponent } from 'vue';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'viewer',\n props: {\n slug: String,\n code: String,\n brand: String,\n category: String,\n property: String,\n },\n setup(props) {\n const viewer = ref(null);\n\n $http.post($ziggy('api.viewed'), {\n action: 'view',\n slug: props.slug\n });\n\n onMounted(() => {\n const product = viewer.value.closest('[shop-product]');\n const name = product.querySelector('[shop-product-name]').textContent;\n const price = product.querySelector('[shop-product-price]') ? product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '') : null;\n const code = props.code;\n\n let object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n item_list_name: 'Direct',\n index: 1,\n }\n ]\n },\n event: 'view_item'\n };\n\n if (typeof Storage !== 'undefined') {\n let productIndex = sessionStorage.getItem('productIndex');\n\n if (productIndex) {\n productIndex = JSON.parse(productIndex);\n\n object.ecommerce.items[0].item_list_name = productIndex.item_list_name;\n object.ecommerce.items[0].index = productIndex.index;\n }\n }\n\n if (price) {\n object.ecommerce.items[0].price = parseFloat(price);\n }\n\n if (props.brand) {\n object.ecommerce.items[0].item_brand = props.brand;\n }\n\n if (props.category) {\n if (props.category.indexOf('/') !== -1) {\n props.category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = props.category;\n }\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n });\n\n return {\n viewer\n };\n }\n});\n</script>","<template>\n <span class=\"is-hidden\" ref=\"viewer\"></span>\n</template>\n<script>\nimport { ref, onMounted, defineComponent } from 'vue';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'viewer',\n props: {\n slug: String,\n code: String,\n brand: String,\n category: String,\n property: String,\n },\n setup(props) {\n const viewer = ref(null);\n\n $http.post($ziggy('api.viewed'), {\n action: 'view',\n slug: props.slug\n });\n\n onMounted(() => {\n const product = viewer.value.closest('[shop-product]');\n const name = product.querySelector('[shop-product-name]').textContent;\n const price = product.querySelector('[shop-product-price]') ? product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '') : null;\n const code = props.code;\n\n let object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n item_list_name: 'Direct',\n index: 1,\n }\n ]\n },\n event: 'view_item'\n };\n\n if (typeof Storage !== 'undefined') {\n let productIndex = sessionStorage.getItem('productIndex');\n\n if (productIndex) {\n productIndex = JSON.parse(productIndex);\n\n object.ecommerce.items[0].item_list_name = productIndex.item_list_name;\n object.ecommerce.items[0].index = productIndex.index;\n }\n }\n\n if (price) {\n object.ecommerce.items[0].price = parseFloat(price);\n }\n\n if (props.brand) {\n object.ecommerce.items[0].item_brand = props.brand;\n }\n\n if (props.category) {\n if (props.category.indexOf('/') !== -1) {\n props.category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = props.category;\n }\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n });\n\n return {\n viewer\n };\n }\n});\n</script>"],"names":["defineComponent","name","props","slug","String","code","brand","category","property","setup","viewer","ref","$http","post","$ziggy","action","onMounted","product","value","closest","querySelector","textContent","price","childNodes","nodeValue","replace","object","ecommerce","currency","parseFloat","items","item_name","item_id","item_list_name","index","event","Storage","productIndex","sessionStorage","getItem","JSON","parse","item_brand","indexOf","split","forEach","segment","trim","item_category","item_variant","$env","debug","console","log","window","dataLayer","push","_createElementBlock","_hoisted_1"],"mappings":"oCAM6BA,kBAAgB,CACzCC,KAAM,SACNC,MAAO,CACHC,KAAMC,OACNC,KAAMD,OACNE,MAAOF,OACPG,SAAUH,OACVI,SAAUJ,QAEdK,eAAMP,OACIQ,EAASC,MAAI,aAEnBC,MAAMC,KAAKC,OAAO,cAAe,CAC7BC,OAAQ,OACRZ,KAAMD,EAAMC,OAGhBa,aAAU,eACAC,EAAUP,EAAOQ,MAAMC,QAAQ,kBAC/BlB,EAAOgB,EAAQG,cAAc,uBAAuBC,YACpDC,EAAQL,EAAQG,cAAc,wBAA0BH,EAAQG,cAAc,wBAAwBG,WAAW,GAAGC,UAAUC,QAAQ,KAAM,IAAM,KAClJpB,EAAOH,EAAMG,KAEfqB,EAAS,CACTC,UAAW,CACPC,SAAU,MACVV,MAAOW,WAAWP,GAClBQ,MAAO,CACH,CACIC,UAAW9B,EACX+B,QAAS3B,EACT4B,eAAgB,SAChBC,MAAO,KAInBC,MAAO,gBAGY,oBAAZC,QAAyB,KAC5BC,EAAeC,eAAeC,QAAQ,gBAEtCF,IACAA,EAAeG,KAAKC,MAAMJ,GAE1BX,EAAOC,UAAUG,MAAM,GAAGG,eAAiBI,EAAaJ,eACxDP,EAAOC,UAAUG,MAAM,GAAGI,MAAQG,EAAaH,OAInDZ,IACAI,EAAOC,UAAUG,MAAM,GAAGR,MAAQO,WAAWP,IAG7CpB,EAAMI,QACNoB,EAAOC,UAAUG,MAAM,GAAGY,WAAaxC,EAAMI,OAG7CJ,EAAMK,YAC+B,IAAjCL,EAAMK,SAASoC,QAAQ,KACvBzC,EAAMK,SAASqC,MAAM,KAAKC,SAAQ,SAACC,EAASZ,GACxCR,EAAOC,UAAUG,MAAM,GAAG,iBAAmBI,EAAQA,EAAQ,EAAI,KAAOY,EAAQC,UAGpFrB,EAAOC,UAAUG,MAAM,GAAGkB,cAAgB9C,EAAMK,UAIpDL,EAAMM,WACNkB,EAAOC,UAAUG,MAAM,GAAGmB,aAAe/C,EAAMM,UAG/C0C,KAAKC,MAAMxB,WACXyB,QAAQC,IAAI3B,IAGXwB,KAAKC,MAAMxB,WAAa2B,OAAOC,YAChCD,OAAOC,UAAUC,KAAK,CAClB7B,UAAW,OAGf2B,OAAOC,UAAUC,KAAK9B,OAIvB,CACHhB,OAAAA,eC3FI,YAAYC,IAAI,8DAA5B8C,4BAAAC"}
1
+ {"version":3,"file":"Viewer.js","sources":["../../../../src/components/shop/viewed/Viewer.vue","../../../../src/components/shop/viewed/Viewer.vue?vue&type=template&id=d2d3d3a4&lang.js"],"sourcesContent":["<template>\n <span class=\"is-hidden\" ref=\"viewer\"></span>\n</template>\n<script>\nimport { ref, onMounted, defineComponent } from 'vue';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'viewer',\n props: {\n slug: String,\n code: String,\n brand: String,\n category: String,\n property: String,\n },\n setup(props) {\n const viewer = ref(null);\n\n $http.post($ziggy('api.viewed'), {\n action: 'view',\n slug: props.slug\n });\n\n onMounted(() => {\n const product = viewer.value.closest('[shop-product]');\n const name = product.querySelector('[shop-product-name]').textContent;\n const price = product.querySelector('[shop-product-price]') ? product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '') : null;\n const code = props.code;\n const referer = document.referrer;\n\n let object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n item_list_name: referer.includes('/post') ? 'Новини' : 'Direct',\n index: 1,\n }\n ]\n },\n event: 'view_item'\n };\n\n if (typeof Storage !== 'undefined') {\n let productIndex = sessionStorage.getItem('productIndex');\n\n if (productIndex) {\n productIndex = JSON.parse(productIndex);\n\n object.ecommerce.items[0].item_list_name = productIndex.item_list_name;\n object.ecommerce.items[0].index = productIndex.index;\n }\n }\n\n if (price) {\n object.ecommerce.items[0].price = parseFloat(price);\n }\n\n if (props.brand) {\n object.ecommerce.items[0].item_brand = props.brand;\n }\n\n if (props.category) {\n if (props.category.indexOf('/') !== -1) {\n props.category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = props.category;\n }\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n });\n\n return {\n viewer\n };\n }\n});\n</script>","<template>\n <span class=\"is-hidden\" ref=\"viewer\"></span>\n</template>\n<script>\nimport { ref, onMounted, defineComponent } from 'vue';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'viewer',\n props: {\n slug: String,\n code: String,\n brand: String,\n category: String,\n property: String,\n },\n setup(props) {\n const viewer = ref(null);\n\n $http.post($ziggy('api.viewed'), {\n action: 'view',\n slug: props.slug\n });\n\n onMounted(() => {\n const product = viewer.value.closest('[shop-product]');\n const name = product.querySelector('[shop-product-name]').textContent;\n const price = product.querySelector('[shop-product-price]') ? product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '') : null;\n const code = props.code;\n const referer = document.referrer;\n\n let object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n item_list_name: referer.includes('/post') ? 'Новини' : 'Direct',\n index: 1,\n }\n ]\n },\n event: 'view_item'\n };\n\n if (typeof Storage !== 'undefined') {\n let productIndex = sessionStorage.getItem('productIndex');\n\n if (productIndex) {\n productIndex = JSON.parse(productIndex);\n\n object.ecommerce.items[0].item_list_name = productIndex.item_list_name;\n object.ecommerce.items[0].index = productIndex.index;\n }\n }\n\n if (price) {\n object.ecommerce.items[0].price = parseFloat(price);\n }\n\n if (props.brand) {\n object.ecommerce.items[0].item_brand = props.brand;\n }\n\n if (props.category) {\n if (props.category.indexOf('/') !== -1) {\n props.category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = props.category;\n }\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n });\n\n return {\n viewer\n };\n }\n});\n</script>"],"names":["defineComponent","name","props","slug","String","code","brand","category","property","setup","viewer","ref","$http","post","$ziggy","action","onMounted","product","value","closest","querySelector","textContent","price","childNodes","nodeValue","replace","referer","document","referrer","object","ecommerce","currency","parseFloat","items","item_name","item_id","item_list_name","includes","index","event","Storage","productIndex","sessionStorage","getItem","JSON","parse","item_brand","indexOf","split","forEach","segment","trim","item_category","item_variant","$env","debug","console","log","window","dataLayer","push","_createElementBlock","_hoisted_1"],"mappings":"oCAM6BA,kBAAgB,CACzCC,KAAM,SACNC,MAAO,CACHC,KAAMC,OACNC,KAAMD,OACNE,MAAOF,OACPG,SAAUH,OACVI,SAAUJ,QAEdK,eAAMP,OACIQ,EAASC,MAAI,aAEnBC,MAAMC,KAAKC,OAAO,cAAe,CAC7BC,OAAQ,OACRZ,KAAMD,EAAMC,OAGhBa,aAAU,eACAC,EAAUP,EAAOQ,MAAMC,QAAQ,kBAC/BlB,EAAOgB,EAAQG,cAAc,uBAAuBC,YACpDC,EAAQL,EAAQG,cAAc,wBAA0BH,EAAQG,cAAc,wBAAwBG,WAAW,GAAGC,UAAUC,QAAQ,KAAM,IAAM,KAClJpB,EAAOH,EAAMG,KACbqB,EAAUC,SAASC,SAErBC,EAAS,CACTC,UAAW,CACPC,SAAU,MACVb,MAAOc,WAAWV,GAClBW,MAAO,CACH,CACIC,UAAWjC,EACXkC,QAAS9B,EACT+B,eAAgBV,EAAQW,SAAS,SAAW,SAAW,SACvDC,MAAO,KAInBC,MAAO,gBAGY,oBAAZC,QAAyB,KAC5BC,EAAeC,eAAeC,QAAQ,gBAEtCF,IACAA,EAAeG,KAAKC,MAAMJ,GAE1BZ,EAAOC,UAAUG,MAAM,GAAGG,eAAiBK,EAAaL,eACxDP,EAAOC,UAAUG,MAAM,GAAGK,MAAQG,EAAaH,OAInDhB,IACAO,EAAOC,UAAUG,MAAM,GAAGX,MAAQU,WAAWV,IAG7CpB,EAAMI,QACNuB,EAAOC,UAAUG,MAAM,GAAGa,WAAa5C,EAAMI,OAG7CJ,EAAMK,YAC+B,IAAjCL,EAAMK,SAASwC,QAAQ,KACvB7C,EAAMK,SAASyC,MAAM,KAAKC,SAAQ,SAACC,EAASZ,GACxCT,EAAOC,UAAUG,MAAM,GAAG,iBAAmBK,EAAQA,EAAQ,EAAI,KAAOY,EAAQC,UAGpFtB,EAAOC,UAAUG,MAAM,GAAGmB,cAAgBlD,EAAMK,UAIpDL,EAAMM,WACNqB,EAAOC,UAAUG,MAAM,GAAGoB,aAAenD,EAAMM,UAG/C8C,KAAKC,MAAMzB,WACX0B,QAAQC,IAAI5B,IAGXyB,KAAKC,MAAMzB,WAAa4B,OAAOC,YAChCD,OAAOC,UAAUC,KAAK,CAClB9B,UAAW,OAGf4B,OAAOC,UAAUC,KAAK/B,OAIvB,CACHnB,OAAAA,eC5FI,YAAYC,IAAI,8DAA5BkD,4BAAAC"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),o=require("vue-toastification"),r={props:{last:null},setup:function(){return{translate:window.__}}},i={class:"shop-wishlist-success-message"},n=["href"];r.render=function(t,o,r,s,a,c){return e.openBlock(),e.createElementBlock("div",i,[e.createElementVNode("div",null,e.toDisplayString(s.translate("shop.wishlist.product_added_named",{product:r.last.name})),1),e.createElementVNode("a",{href:r.last.url,class:"mt-2 is-size-7",style:{color:"#fff","border-bottom":"1px solid #fff"}},e.toDisplayString(s.translate("shop.wishlist.goto")),9,n)])};var s=e.defineComponent({props:{id:Number,code:{type:String,default:null},property:{type:String,default:null}},setup:function(i){var n=e.ref(!1),s=o.useToast(),a=t.useStore(),c=e.computed((function(){return a.getters["wishlist/item"](i.id)})),l=e.computed((function(){return a.getters["auth/is"]})),u=e.computed((function(){return a.getters["wishlist/last"]})),d=e.ref(null);return{item:c,action:function(){if(!n.value)if(l.value){n.value=!0;var e={};window.getTrackingIndexProductsList&&"function"==typeof window.getTrackingIndexProductsList&&(e=window.getTrackingIndexProductsList(d.value));var t=d.value.closest("[shop-product]"),o=t.querySelector("[shop-product-name]").textContent,m=t.querySelector("[shop-product-price]").childNodes[0].nodeValue.replace(/ /g,""),p=i.code?i.code:t.dataset.code,f=t.querySelector("[shop-product-category]").textContent,h=t.querySelector("[shop-product-brand]").textContent;a.dispatch("wishlist/toggle",{id:i.id,finally:function(){var t="";if(c.value){var a={component:r,props:{last:{name:u,url:$ziggy("account.wish")}}};s(a,{type:"success"}),t="add_to_wish_list"}else s(__("shop.wishlist.product_deleted"),{type:"warning"}),t="remove_from_wish_list";var l={ecommerce:{currency:"UAH",value:parseFloat(m),items:[{item_name:o,item_id:p,price:parseFloat(m),quantity:1}]},event:t};e.index&&(l.ecommerce.items[0].index=e.index),e.item_list_name&&(l.ecommerce.items[0].item_list_name=e.item_list_name),h&&(l.ecommerce.items[0].item_brand=h),i.property&&(l.ecommerce.items[0].item_variant=i.property),f&&(-1!==f.indexOf("/")?f.split("/").forEach((function(e,t){l.ecommerce.items[0]["item_category"+(t?t+1:"")]=e.trim()})):l.ecommerce.items[0].item_category=f),i.property&&(l.ecommerce.items[0].item_variant=i.property),$env.debug.ecommerce&&console.log(l),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(l)),n.value=!1}})}else a.commit("auth/modal","login")},loading:n,button:d}}}),a=["title"],c=e.createElementVNode("svg",{class:"icon wishlist"},[e.createElementVNode("use",{"xlink:href":"#wishlist"})],-1);s.render=function(t,o,r,i,n,s){return e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["button wishlist",{"is-loading":t.loading,"is-transparent":!t.item}]),onClick:o[0]||(o[0]=function(){return t.action&&t.action.apply(t,arguments)}),title:t.__("shop.wishlist.add"),ref:"button"},[e.renderSlot(t.$slots,"default",{product:t.item},(function(){return[c]}))],10,a)},module.exports=s;
1
+ "use strict";var e=require("vue"),t=require("vuex"),i=require("vue-toastification"),r={props:{last:null},setup:function(){return{translate:window.__}}},o={class:"shop-wishlist-success-message"},n=["href"];r.render=function(t,i,r,s,a,c){return e.openBlock(),e.createElementBlock("div",o,[e.createElementVNode("div",null,e.toDisplayString(s.translate("shop.wishlist.product_added_named",{product:r.last.name})),1),e.createElementVNode("a",{href:r.last.url,class:"mt-2 is-size-7",style:{color:"#fff","border-bottom":"1px solid #fff"}},e.toDisplayString(s.translate("shop.wishlist.goto")),9,n)])};var s=e.defineComponent({props:{id:Number,code:{type:String,default:null},property:{type:String,default:null},item:{type:Object,default:null}},setup:function(o){var n=e.ref(!1),s=i.useToast(),a=t.useStore(),c=e.computed((function(){return a.getters["wishlist/item"](o.id)})),l=e.computed((function(){return a.getters["auth/is"]})),u=e.computed((function(){return a.getters["wishlist/last"]})),m=e.ref(null);return{item:c,action:function(){if(!n.value)if(l.value){n.value=!0;var e={};window.getTrackingIndexProductsList&&"function"==typeof window.getTrackingIndexProductsList&&(e=window.getTrackingIndexProductsList(m.value));var t=m.value.closest("[shop-product]"),i=t.querySelector("[shop-product-name]")?t.querySelector("[shop-product-name]").textContent:null,d=t.querySelector("[shop-product-price]")?t.querySelector("[shop-product-price]").childNodes[0].nodeValue.replace(/ /g,""):null,p=o.code?o.code:t.dataset.code,f=t.querySelector("[shop-product-category]")?t.querySelector("[shop-product-category]").textContent:null,h=t.querySelector("[shop-product-brand]")?t.querySelector("[shop-product-brand]").textContent:null;a.dispatch("wishlist/toggle",{id:o.id,finally:function(){var t="";if(c.value){var a={component:r,props:{last:{name:u,url:$ziggy("account.wish")}}};s(a,{type:"success"}),t="add_to_wish_list"}else s(__("shop.wishlist.product_deleted"),{type:"warning"}),t="remove_from_wish_list";var l={ecommerce:{currency:"UAH",value:parseFloat(d),items:[{item_name:i,item_id:p,price:parseFloat(d),quantity:1}]},event:t};o.item&&o.item.attributes.index?l.ecommerce.items[0].index=o.item.attributes.index:e.index&&(l.ecommerce.items[0].index=e.index),o.item&&o.item.attributes.itemListName?l.ecommerce.items[0].item_list_name=o.item.attributes.itemListName:e.item_list_name&&(l.ecommerce.items[0].item_list_name=e.item_list_name),h&&(l.ecommerce.items[0].item_brand=h),o.item&&o.item.attributes.property?l.ecommerce.items[0].item_variant=o.item.attributes.property:o.property&&(l.ecommerce.items[0].item_variant=o.property),f&&(-1!==f.indexOf("/")?f.split("/").forEach((function(e,t){l.ecommerce.items[0]["item_category"+(t?t+1:"")]=e.trim()})):l.ecommerce.items[0].item_category=f),$env.debug.ecommerce&&console.log(l),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(l)),n.value=!1}})}else a.commit("auth/modal","login")},loading:n,button:m}}}),a=["title"],c=e.createElementVNode("svg",{class:"icon wishlist"},[e.createElementVNode("use",{"xlink:href":"#wishlist"})],-1);s.render=function(t,i,r,o,n,s){return e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["button wishlist",{"is-loading":t.loading,"is-transparent":!t.item}]),onClick:i[0]||(i[0]=function(){return t.action&&t.action.apply(t,arguments)}),title:t.__("shop.wishlist.add"),ref:"button"},[e.renderSlot(t.$slots,"default",{product:t.item},(function(){return[c]}))],10,a)},module.exports=s;
2
2
  //# sourceMappingURL=WishlistAdd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WishlistAdd.js","sources":["../../../../src/components/shop/wishlist/SuccessMessage.vue","../../../../src/components/shop/wishlist/SuccessMessage.vue?vue&type=template&id=2780632f&lang.js","../../../../src/components/shop/wishlist/WishlistAdd.vue","../../../../src/components/shop/wishlist/WishlistAdd.vue?vue&type=template&id=6d683a1f&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-wishlist-success-message\">\n <div>\n {{\n translate(\"shop.wishlist.product_added_named\", {\n product: last.name,\n })\n }}\n </div>\n <a\n :href=\"last.url\"\n class=\"mt-2 is-size-7\"\n style=\"color: #fff; border-bottom: 1px solid #fff\"\n >{{ translate(\"shop.wishlist.goto\") }}</a\n >\n </div>\n</template>\n<script>\nexport default {\n props: {\n last: null,\n },\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"shop-wishlist-success-message\">\n <div>\n {{\n translate(\"shop.wishlist.product_added_named\", {\n product: last.name,\n })\n }}\n </div>\n <a\n :href=\"last.url\"\n class=\"mt-2 is-size-7\"\n style=\"color: #fff; border-bottom: 1px solid #fff\"\n >{{ translate(\"shop.wishlist.goto\") }}</a\n >\n </div>\n</template>\n<script>\nexport default {\n props: {\n last: null,\n },\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <button class=\"button wishlist\" @click=\"action\" v-bind:class=\"{ 'is-loading': loading, 'is-transparent': !item }\" :title=\"__('shop.wishlist.add')\" ref=\"button\">\n <slot :product=\"item\">\n <svg class=\"icon wishlist\">\n <use xlink:href=\"#wishlist\" />\n </svg>\n </slot>\n </button>\n</template>\n<script>\nimport { ref, computed, defineComponent } from \"vue\";\nimport { useStore } from \"vuex\";\nimport { useToast } from \"vue-toastification\";\nimport SuccessMessage from \"./SuccessMessage.vue\";\n\nexport default /*#__PURE__*/ defineComponent({\n props: {\n id: Number,\n code: {\n type: String,\n default: null\n },\n property: {\n type: String,\n default: null\n },\n },\n setup(props) {\n const loading = ref(false);\n const toast = useToast();\n const store = useStore();\n const item = computed(() => store.getters[\"wishlist/item\"](props.id));\n const auth = computed(() => store.getters[\"auth/is\"]);\n const last = computed(() => store.getters[\"wishlist/last\"]);\n const button = ref(null);\n\n const action = () => {\n if (!loading.value) {\n if (!auth.value) {\n store.commit(\"auth/modal\", \"login\");\n } else {\n loading.value = true;\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const product = button.value.closest('[shop-product]');\n const name = product.querySelector('[shop-product-name]').textContent;\n const price = product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '');\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]').textContent;\n const brand = product.querySelector('[shop-product-brand]').textContent;\n\n store.dispatch(\"wishlist/toggle\", {\n id: props.id,\n finally: () => {\n let eventName = '';\n\n if (item.value) {\n const component = {\n component: SuccessMessage,\n props: {\n last: {\n name: last,\n url: $ziggy(\"account.wish\"),\n },\n },\n };\n\n toast(component, {\n type: \"success\",\n });\n\n eventName = 'add_to_wish_list';\n } else {\n toast(__(\"shop.wishlist.product_deleted\"), {\n type: \"warning\",\n });\n\n eventName = 'remove_from_wish_list';\n }\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: 1,\n }\n ]\n },\n event: eventName\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n loading.value = false;\n },\n });\n }\n }\n };\n\n return {\n item,\n action,\n loading,\n button,\n };\n },\n});\n</script>","<template>\n <button class=\"button wishlist\" @click=\"action\" v-bind:class=\"{ 'is-loading': loading, 'is-transparent': !item }\" :title=\"__('shop.wishlist.add')\" ref=\"button\">\n <slot :product=\"item\">\n <svg class=\"icon wishlist\">\n <use xlink:href=\"#wishlist\" />\n </svg>\n </slot>\n </button>\n</template>\n<script>\nimport { ref, computed, defineComponent } from \"vue\";\nimport { useStore } from \"vuex\";\nimport { useToast } from \"vue-toastification\";\nimport SuccessMessage from \"./SuccessMessage.vue\";\n\nexport default /*#__PURE__*/ defineComponent({\n props: {\n id: Number,\n code: {\n type: String,\n default: null\n },\n property: {\n type: String,\n default: null\n },\n },\n setup(props) {\n const loading = ref(false);\n const toast = useToast();\n const store = useStore();\n const item = computed(() => store.getters[\"wishlist/item\"](props.id));\n const auth = computed(() => store.getters[\"auth/is\"]);\n const last = computed(() => store.getters[\"wishlist/last\"]);\n const button = ref(null);\n\n const action = () => {\n if (!loading.value) {\n if (!auth.value) {\n store.commit(\"auth/modal\", \"login\");\n } else {\n loading.value = true;\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const product = button.value.closest('[shop-product]');\n const name = product.querySelector('[shop-product-name]').textContent;\n const price = product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '');\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]').textContent;\n const brand = product.querySelector('[shop-product-brand]').textContent;\n\n store.dispatch(\"wishlist/toggle\", {\n id: props.id,\n finally: () => {\n let eventName = '';\n\n if (item.value) {\n const component = {\n component: SuccessMessage,\n props: {\n last: {\n name: last,\n url: $ziggy(\"account.wish\"),\n },\n },\n };\n\n toast(component, {\n type: \"success\",\n });\n\n eventName = 'add_to_wish_list';\n } else {\n toast(__(\"shop.wishlist.product_deleted\"), {\n type: \"warning\",\n });\n\n eventName = 'remove_from_wish_list';\n }\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: 1,\n }\n ]\n },\n event: eventName\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n loading.value = false;\n },\n });\n }\n }\n };\n\n return {\n item,\n action,\n loading,\n button,\n };\n },\n});\n</script>"],"names":["props","last","setup","translate","window","__","_createElementBlock","_hoisted_1","_createElementVNode","$setup","href","$props","url","style","defineComponent","id","Number","code","type","String","property","loading","ref","toast","useToast","store","useStore","item","computed","getters","auth","button","action","value","trackingIndex","getTrackingIndexProductsList","product","closest","name","querySelector","textContent","price","childNodes","nodeValue","replace","dataset","category","brand","dispatch","eventName","component","SuccessMessage","$ziggy","object","ecommerce","currency","parseFloat","items","item_name","item_id","quantity","event","index","item_list_name","item_brand","item_variant","indexOf","split","forEach","segment","trim","item_category","$env","debug","console","log","dataL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 {"version":3,"file":"WishlistAdd.js","sources":["../../../../src/components/shop/wishlist/SuccessMessage.vue","../../../../src/components/shop/wishlist/SuccessMessage.vue?vue&type=template&id=2780632f&lang.js","../../../../src/components/shop/wishlist/WishlistAdd.vue","../../../../src/components/shop/wishlist/WishlistAdd.vue?vue&type=template&id=45e2e67a&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-wishlist-success-message\">\n <div>\n {{\n translate(\"shop.wishlist.product_added_named\", {\n product: last.name,\n })\n }}\n </div>\n <a\n :href=\"last.url\"\n class=\"mt-2 is-size-7\"\n style=\"color: #fff; border-bottom: 1px solid #fff\"\n >{{ translate(\"shop.wishlist.goto\") }}</a\n >\n </div>\n</template>\n<script>\nexport default {\n props: {\n last: null,\n },\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"shop-wishlist-success-message\">\n <div>\n {{\n translate(\"shop.wishlist.product_added_named\", {\n product: last.name,\n })\n }}\n </div>\n <a\n :href=\"last.url\"\n class=\"mt-2 is-size-7\"\n style=\"color: #fff; border-bottom: 1px solid #fff\"\n >{{ translate(\"shop.wishlist.goto\") }}</a\n >\n </div>\n</template>\n<script>\nexport default {\n props: {\n last: null,\n },\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <button class=\"button wishlist\" @click=\"action\" v-bind:class=\"{ 'is-loading': loading, 'is-transparent': !item }\" :title=\"__('shop.wishlist.add')\" ref=\"button\">\n <slot :product=\"item\">\n <svg class=\"icon wishlist\">\n <use xlink:href=\"#wishlist\" />\n </svg>\n </slot>\n </button>\n</template>\n<script>\nimport { ref, computed, defineComponent } from \"vue\";\nimport { useStore } from \"vuex\";\nimport { useToast } from \"vue-toastification\";\nimport SuccessMessage from \"./SuccessMessage.vue\";\n\nexport default /*#__PURE__*/ defineComponent({\n props: {\n id: Number,\n code: {\n type: String,\n default: null\n },\n property: {\n type: String,\n default: null\n },\n item: {\n type: Object,\n default: null\n }\n },\n setup(props) {\n const loading = ref(false);\n const toast = useToast();\n const store = useStore();\n const item = computed(() => store.getters[\"wishlist/item\"](props.id));\n const auth = computed(() => store.getters[\"auth/is\"]);\n const last = computed(() => store.getters[\"wishlist/last\"]);\n const button = ref(null);\n\n const action = () => {\n if (!loading.value) {\n if (!auth.value) {\n store.commit(\"auth/modal\", \"login\");\n } else {\n loading.value = true;\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const product = button.value.closest('[shop-product]');\n const name = product.querySelector('[shop-product-name]') ? product.querySelector('[shop-product-name]').textContent : null;\n const price = product.querySelector('[shop-product-price]') ? product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '') : null;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]') ? product.querySelector('[shop-product-category]').textContent : null;\n const brand = product.querySelector('[shop-product-brand]') ? product.querySelector('[shop-product-brand]').textContent : null;\n\n store.dispatch(\"wishlist/toggle\", {\n id: props.id,\n finally: () => {\n let eventName = '';\n\n if (item.value) {\n const component = {\n component: SuccessMessage,\n props: {\n last: {\n name: last,\n url: $ziggy(\"account.wish\"),\n },\n },\n };\n\n toast(component, {\n type: \"success\",\n });\n\n eventName = 'add_to_wish_list';\n } else {\n toast(__(\"shop.wishlist.product_deleted\"), {\n type: \"warning\",\n });\n\n eventName = 'remove_from_wish_list';\n }\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: 1,\n }\n ]\n },\n event: eventName\n };\n\n if (props.item && props.item.attributes.index) {\n object.ecommerce.items[0].index = props.item.attributes.index;\n } else if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (props.item && props.item.attributes.itemListName) {\n object.ecommerce.items[0].item_list_name = props.item.attributes.itemListName;\n } else if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (props.item && props.item.attributes.property) {\n object.ecommerce.items[0].item_variant = props.item.attributes.property;\n } else if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n loading.value = false;\n },\n });\n }\n }\n };\n\n return {\n item,\n action,\n loading,\n button,\n };\n },\n});\n</script>","<template>\n <button class=\"button wishlist\" @click=\"action\" v-bind:class=\"{ 'is-loading': loading, 'is-transparent': !item }\" :title=\"__('shop.wishlist.add')\" ref=\"button\">\n <slot :product=\"item\">\n <svg class=\"icon wishlist\">\n <use xlink:href=\"#wishlist\" />\n </svg>\n </slot>\n </button>\n</template>\n<script>\nimport { ref, computed, defineComponent } from \"vue\";\nimport { useStore } from \"vuex\";\nimport { useToast } from \"vue-toastification\";\nimport SuccessMessage from \"./SuccessMessage.vue\";\n\nexport default /*#__PURE__*/ defineComponent({\n props: {\n id: Number,\n code: {\n type: String,\n default: null\n },\n property: {\n type: String,\n default: null\n },\n item: {\n type: Object,\n default: null\n }\n },\n setup(props) {\n const loading = ref(false);\n const toast = useToast();\n const store = useStore();\n const item = computed(() => store.getters[\"wishlist/item\"](props.id));\n const auth = computed(() => store.getters[\"auth/is\"]);\n const last = computed(() => store.getters[\"wishlist/last\"]);\n const button = ref(null);\n\n const action = () => {\n if (!loading.value) {\n if (!auth.value) {\n store.commit(\"auth/modal\", \"login\");\n } else {\n loading.value = true;\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const product = button.value.closest('[shop-product]');\n const name = product.querySelector('[shop-product-name]') ? product.querySelector('[shop-product-name]').textContent : null;\n const price = product.querySelector('[shop-product-price]') ? product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '') : null;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]') ? product.querySelector('[shop-product-category]').textContent : null;\n const brand = product.querySelector('[shop-product-brand]') ? product.querySelector('[shop-product-brand]').textContent : null;\n\n store.dispatch(\"wishlist/toggle\", {\n id: props.id,\n finally: () => {\n let eventName = '';\n\n if (item.value) {\n const component = {\n component: SuccessMessage,\n props: {\n last: {\n name: last,\n url: $ziggy(\"account.wish\"),\n },\n },\n };\n\n toast(component, {\n type: \"success\",\n });\n\n eventName = 'add_to_wish_list';\n } else {\n toast(__(\"shop.wishlist.product_deleted\"), {\n type: \"warning\",\n });\n\n eventName = 'remove_from_wish_list';\n }\n\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: 1,\n }\n ]\n },\n event: eventName\n };\n\n if (props.item && props.item.attributes.index) {\n object.ecommerce.items[0].index = props.item.attributes.index;\n } else if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (props.item && props.item.attributes.itemListName) {\n object.ecommerce.items[0].item_list_name = props.item.attributes.itemListName;\n } else if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (props.item && props.item.attributes.property) {\n object.ecommerce.items[0].item_variant = props.item.attributes.property;\n } else if (props.property) {\n object.ecommerce.items[0].item_variant = props.property;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n loading.value = false;\n },\n });\n }\n }\n };\n\n return {\n item,\n action,\n loading,\n button,\n };\n },\n});\n</script>"],"names":["props","last","setup","translate","window","__","_createElementBlock","_hoisted_1","_createElementVNode","$setup","href","$props","url","style","defineComponent","id","Number","code","type","String","property","item","Object","loading","ref","toast","useToast","store","useStore","computed","getters","auth","button","action","value","trackingIndex","getTrackingIndexProductsList","product","closest","name","querySelector","textContent","price","childNodes","nodeValue","replace","dataset","category","brand","dispatch","eventName","component","SuccessMessage","$ziggy","object","ecommerce","currency","parseFloat","items","item_name","item_id","quantity","event","attributes","index","itemListName","item_list_name","item_brand","item_variant","indexOf","split","forEach","segment","trim","item_category","$env","debug","console","log","dataLayer","push","commit","_ctx","onClick","title","_renderSlot","_hoisted_2"],"mappings":"sFAkBe,CACXA,MAAO,CACHC,KAAM,MAEVC,uBAGW,CACHC,UAHcC,OAAOC,eCtBlB,gGAAXC,2BAAAC,GACIC,kDAEQC,2EAKRD,0BACKE,KAAMC,OAAKC,UACN,iBACNC,MAAA,mEACIJ,2CCEhB,MAA6BK,kBAAgB,CACzCd,MAAO,CACHe,GAAIC,OACJC,KAAM,CACFC,KAAMC,eACG,MAEbC,SAAU,CACNF,KAAMC,eACG,MAEbE,KAAM,CACFH,KAAMI,eACG,OAGjBpB,eAAMF,OACIuB,EAAUC,OAAI,GACdC,EAAQC,aACRC,EAAQC,aACRP,EAAOQ,YAAS,kBAAMF,EAAMG,QAAQ,iBAAiB9B,EAAMe,OAC3DgB,EAAOF,YAAS,kBAAMF,EAAMG,QAAQ,cACpC7B,EAAO4B,YAAS,kBAAMF,EAAMG,QAAQ,oBACpCE,EAASR,MAAI,Y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