!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";self.__sm_client_data={};const t="sw-client-data-v1",e=async t=>{let e={uuid:self.__sm_client_data.uuid,channel_id:self.__sm_client_data.channelId,invite_code:self.__sm_client_data.inviteCode,event_code:t,link_id:self.__sm_client_data.linkId,project_id:self.__sm_client_data.appid,version:self.__sm_client_data.eventVersion,package:self.__sm_client_data.appid,promote_url_id:self.__sm_client_data.promoteUrlId};if(!e.uuid||!e.link_id){const n=await s();n&&(e={...e,...n,event_code:t})}const n=new URL("https://event.bttzs.com/pixgif/r9.gif");for(const t in e)n.searchParams.set(t,e?.[t]??"");fetch(n.href,{method:"HEAD",mode:"no-cors",headers:{pragma:"no-cache","cache-control":"no-cache"}})},n=t=>{const e=[{condition:self.__sm_client_data?.isScanCodeOpen,transform:2},{condition:self.__sm_client_data?.isFromShareOpen,transform:3}];return{reportEventExtra:n=>{e?.forEach((({condition:e,transform:a})=>{if(e){const e=function(t,e){if(e>1){let n=t.toString();return n=n.slice(0,1)+(parseInt(n[1])+(e-1)).toString()+n.slice(2),parseInt(n)}return t}(n,a);t(e)}}))}}},a=t=>{const{reportEventExtra:a}=n(e);a(t)},i=(t,e={})=>{self.clients.matchAll().then((function(n){n.forEach((n=>{n.postMessage({type:t,data:e})}))}))};self.addEventListener("fetch",(t=>{})),self.addEventListener("push",(t=>{try{const n=JSON.parse(t.data.text());e(21028),a(21028),t.waitUntil((()=>{try{return self.registration.showNotification(n.title,n.options)}catch(t){return self.registration.showNotification(n.title,n.options)}})())}catch(t){}})),self.addEventListener("notificationclick",(function(t){e(21029),a(21029),t.waitUntil((t.notification.close(),t?.action?self.clients.openWindow(t?.action):t?.notification?.data?.url?self.clients.openWindow(t?.notification?.data?.url):void 0))})),self.addEventListener("pushsubscriptionchange",(t=>{t.waitUntil(self.registration?.pushManager.subscribe(t.oldSubscription.options).then((function(t){(t=>{const e=JSON.parse(JSON.stringify(t.subscription)),n={link_id:t.link_id,domain:"",push_subscription:{endpoint:e.endpoint,expirationTime:e.expirationTime,keys:e.keys}},a=new URL("https://pwa-backend-prod.roibest.com/push/subscribe");for(const t in n)a.searchParams.set(t,n[t]??"");fetch("https://pwa-backend-prod.roibest.com/push/subscribe",{method:"HEAD",mode:"no-cors",headers:{pragma:"no-cache","cache-control":"no-cache"}})})({link_id:self.__sm_client_data.linkId,subscription:t}),i("SUBSCRIPTION")})).catch((t=>{i("NOT_SUBSCRIPTION")})))})),self.addEventListener("message",(e=>{if("SET_SM_CLIENT_DATA"===e.data.type)self.__sm_client_data=e.data.data,"caches"in self&&caches.open(t).then((t=>{t.put("/client-data",new Response(JSON.stringify({uuid:e.data.data.uuid,channel_id:e.data.data.channelId,invite_code:e.data.data.inviteCode,link_id:e.data.data.linkId,project_id:e.data.data.appid,version:e.data.data.eventVersion,package:e.data.data.appid,promote_url_id:e.data.data.promoteUrlId})))}))}));const s=async()=>{try{const e=await caches.open(t),n=await e.match("/client-data");return n?await n.json():null}catch(t){return null}}}));
