!function(){function e(e,r,n,a,t,m,Z){try{var i=e[m](Z),o=i.value}catch(A){return void n(A)}i.done?r(o):Promise.resolve(o).then(a,t)}function r(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,a)}return n}function n(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function a(e,r){for(var n=0;ne.length)&&(r=e.length);for(var n=0,a=new Array(r);n2&&void 0!==arguments[2]?arguments[2]:[],a=document.createElement(e);return Object.entries(r).forEach((function(e){var r,n=m(e,2),Z=n[0],i=n[1];switch(Z){case"class":Array.isArray(i)?(r=a.classList).add.apply(r,t(i)):a.className=i;break;case"on":Object.entries(i).forEach((function(e){var r=m(e,2),n=r[0],t=r[1];a.addEventListener(n,t)}));break;default:a.setAttribute(Z,i)}})),n.forEach((function(e){return a.appendChild(e)})),a}function A(e,r,n){return o("button",{class:e,on:{click:n}},[document.createTextNode(r)])}var d=function(){function e(a){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.options=function(e){for(var a=1;a\n
').concat(r.content,"
\n ");var a=o("div",{class:"ptc-dialog__footer"},[r.showCancel&&A("ptc-dialog__cancel",r.cancelText,(function(){e.close(),r.onCancel&&r.onCancel()})),A("ptc-dialog__confirm",r.confirmText,(function(){e.close(),r.onConfirm&&r.onConfirm()}))].filter(Boolean));n.firstChild.appendChild(a),this.$el=n}},{key:"show",value:function(){document.body.appendChild(this.$el)}},{key:"close",value:function(){this.$el.classList.add("fade-out")}}])&&a(t.prototype,m),Z&&a(t,Z),Object.defineProperty(t,"prototype",{writable:!1}),e}();Promise.all([new Promise((function(e){var r=new XMLHttpRequest;r.open("GET","/api/user/info"),r.timeout=4e3,r.setRequestHeader("Cache-Control","no-cache"),r.onload=function(){if(200===r.status){var n=JSON.parse(r.response);e(n.results)}else e(null)},r.onerror=function(){return e(null)},r.ontimeout=function(){return e(null)},r.send()})),Promise.resolve(null)]).then((function(r){var n,a=m(r,2),t=a[0],o=a[1];(o&&(_.templateSettings.interpolate=/{{([\s\S]+?)}}/g,Z("#header").outerHTML=_.template(o.header)({userInfo:t,rebuyDiscount:10,couponInfo:{coupon_amount:1,coupon_num:10}}),Z("#footer").outerHTML=o.footer),t&&t.orders.length)&&(Z(".user-panel").classList.add("is-member"),null===(n=Z(".dot"))||void 0===n||n.classList.add("active"),new Swiper("#order-swiper",{slidesPerView:1.08,spaceBetween:15,on:{slideChange:function(e){i(".dot").forEach((function(r,n){n===e.realIndex?r.classList.add("active"):r.classList.remove("active")}))},click:function(e,r){for(var n=r.target;!n.classList.contains("swiper-slide")&&!n.classList.contains("swiper");)n=n.parentNode;var a=n.dataset.order_id;a&&(location.href="/ptc/order/"+a)}}}));var A,l=Z(".nav-dropdown");l&&document.addEventListener("click",(function(){!l.classList.contains("hidden")&&l.classList.add("fade-out")})),i("[data-toggle]").forEach((function(e){e.addEventListener("click",(function(r){if(r.stopPropagation(),e.hasAttribute("data-auth")&&!t)return location.href="/ptc/login";var n=Z(e.getAttribute("data-toggle")).classList;n.contains("hidden")?(n.remove("hidden"),n.add("fade-in"),window.innerWidth<768&&document.body.classList.add("lock-scroll")):n.add("fade-out")}))})),i("[data-fade]").forEach((function(e){e.addEventListener("animationend",(function(){var r=e.classList;r.contains("fade-out")&&(r.add("hidden"),r.remove("fade-in","fade-out"),document.body.classList.remove("lock-scroll"))}))})),null===(A=Z("#signOut"))||void 0===A||A.addEventListener("click",(function(){var r;r={title:"TIPS",content:"Are you sure you want to sign out?",confirmText:"YES",showCancel:!0,onConfirm:function(){return(r=regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,r){var n=new XMLHttpRequest;n.open("POST","/api/user/logout"),n.timeout=4e3,n.onload=function(){if(200===n.status){var a=JSON.parse(n.response);a.success?e(a):r(a)}else r(n)},n.onerror=r,n.ontimeout=r,n.send()}));case 2:t=null,Z(".user").innerHTML='LOGIN',l.remove();case 5:case"end":return e.stop()}}),e)})),function(){var n=this,a=arguments;return new Promise((function(t,m){var Z=r.apply(n,a);function i(r){e(Z,t,m,i,o,"next",r)}function o(r){e(Z,t,m,i,o,"throw",r)}i(void 0)}))})();var r}},new d(r).show()})),i("[data-action=buy]").forEach((function(e){e.addEventListener("click",(function(e){var r=e.target.dataset.id;location.href="/ptc/fill-order"+(r?"?pid=".concat(r):"")}))}))})),Z("#banner-swiper > .swiper-wrapper").children.length>1&&new Swiper("#banner-swiper",{loop:!0,autoplay:{delay:5e3},pagination:{el:".swiper-pagination",type:"bullets"},effect:"fade"}),Z(".services")&&document.addEventListener("scroll",(function(){var e=Z(".popup-buy").classList;document.scrollingElement.scrollTop>=1400?e.add("in"):e.remove("in")}))}}}))}();