(()=>{"use strict";var e,t,s,a;!function(e){e.BLOCKING="blocking",e.REPORT_ONLY="report-only"}(e||(e={})),function(e){e.NON_HTTP="non-http",e.SYSTEM="system",e.MARKETING="marketing",e.UNKNOWN="unknown"}(t||(t={})),function(e){e.SETUP="setup",e.PAUSE_MARKETING_BLOCKING="pause-marketing-blocking"}(s||(s={}));class o extends Error{constructor(e,t,s){super(`[${e}] Resource blocked: resourceUrl: ${t}, resourceType: ${s}`)}}!function(e){e.MARKETING_BLOCKING_PAUSED="marketing-blocking-paused",e.MARKETING_BLOCKING_RESUMED="marketing-blocking-resumed"}(a||(a={}));class i{constructor(t){this.guardFilter=t,this.mode=e.REPORT_ONLY,this.areMarketingRequestsAllowed=!0,this.marketingRequestsBlockingTimeoutId=null}handleInstallEvent(e){skipWaiting()}handleActivateEvent(e){e.waitUntil(clients.claim())}handleMessageEvent(e){switch(e.data.type){case s.SETUP:this.handleSetupMessageEvent(e);break;case s.PAUSE_MARKETING_BLOCKING:this.handlePauseMarketingBlockingMessageEvent(e)}}handleFetchEvent(e){const t=new URL(e.request.url),s=this.guardFilter.isResourceAllowed(t,{areMarketingRequestsAllowed:this.areMarketingRequestsAllowed});s.isResourceAllowed||this.handleBlockedFetchEvent(e,s)}handleBlockedFetchEvent(t,s){switch(this.mode){case e.REPORT_ONLY:break;case e.BLOCKING:t.respondWith(new Response(null,{status:200,headers:{"X-Campaign-Page-Guard":"true"}}))}throw new o(this.mode,t.request.url,s.resourceType)}handleSetupMessageEvent(e){const t=e.data;this.mode=t.mode}handlePauseMarketingBlockingMessageEvent(e){const t=e.source;this.pauseMarketingBlocking(t),this.setMarketingRequestsBlockingTimeout(t)}pauseMarketingBlocking(e){this.areMarketingRequestsAllowed=!0,this.notifyClient(e,{type:a.MARKETING_BLOCKING_PAUSED})}resumeMarketingBlocking(e){this.areMarketingRequestsAllowed=!1,this.notifyClient(e,{type:a.MARKETING_BLOCKING_RESUMED})}setMarketingRequestsBlockingTimeout(e){this.marketingRequestsBlockingTimeoutId&&clearTimeout(this.marketingRequestsBlockingTimeoutId),this.marketingRequestsBlockingTimeoutId=setTimeout((()=>{this.resumeMarketingBlocking(e)}),1e4)}notifyClient(e,t){e.postMessage(t)}}const n=(()=>{try{return window}catch(e){return self}})(),r=(n.FUN_ENV,n.FUN_HOST||"https://api.fundraiseup.com"),c=n.FUN_CDN||"https://cdn.fundraiseup.com",l=n.FUN_STATIC||"https://static.fundraiseup.com",u=n.FUN_STATIC_S3||"https://static.fundraiseup.com",h=[new URL(c).hostname,new URL(r).hostname,new URL(l).hostname,new URL(u).hostname,"1.1.1.1","sentry.fundraiseup.com",/\b(stripe)\b/i,/\b(stripecdn)\b/i,/\.paypal\.com$/i,"www.sandbox.paypal.com","www.paypalobjects.com","pay.google.com","play.google.com","www.gstatic.com","www.googletagmanager.com","ucarecdn.com","api.addressy.com","connect.facebook.net",{hostname:"www.youtube.com",pathname:"/iframe_api"},{hostname:"www.youtube.com",pathname:/^\/s\/player/}],m=[/\.google-analytics\.com$/i,/analytics\.google\.com$/i,{hostname:"crcdata.redcross.ca",pathname:"/g/collect"},{hostname:"tracker.rmh-newyork.org",pathname:"/g/collect"},{hostname:"metrics.smiletrain.org",pathname:"/g/collect"},{hostname:"alzheimerssocietysst.alzheimers.org.uk",pathname:"/g/collect"},"www.facebook.com","connect.facebook.net",/\.visualwebsiteoptimizer\.com$/i,"cdn.feathr.co","polo.feathr.co","marco.feathr.co",/^www\.google\./i,/^google\./i,"www.googleadservices.com","stats.g.doubleclick.net","googleads.g.doubleclick.net","td.doubleclick.net",/\.fls\.doubleclick\.net$/i,"ad.doubleclick.net","adservice.google.com","bat.bing.com","analytics.tiktok.com","business-api.tiktok.com","ads-twitter.com","static.ads-twitter.com","ads-api.twitter.com","analytics.twitter.com",/\.srv\.stackadapt\.com$/i,"snap.licdn.com","px.ads.linkedin.com",{hostname:/^.*\.?matomo\.cloud/,pathname:/^(?!.*\/HeatmapSessionRecording)/},{hostname:"js.adsrvr.org",pathname:/^\/up_loader\..*\.js$/},{hostname:"insight.adsrvr.org",pathname:/^\/track\/up.*$/},/\.prod\.uidapi\.com$/i,"prod.uidapi.com","cdn.prod.uidapi.com","apps.rokt.com"],d=["http:","https:"];class g{constructor(e){this.whitelist=e}isResourceAllowed(e){return this.whitelist.some((t=>"string"==typeof t||t instanceof RegExp?this.validateResource(e,{hostname:t}):this.validateResource(e,t)))}validateResource(e,t){return this.validateResourceHostname(e,t)&&this.validateResourcePathname(e,t)}validateResourceHostname(e,t){return!t.hostname||this.validateResourcePart(e.hostname,t.hostname)}validateResourcePathname(e,t){return!t.pathname||this.validateResourcePart(e.pathname,t.pathname)}validateResourcePart(e,t){return"string"==typeof t?e===t:t instanceof RegExp&&t.test(e)}}class p{constructor(e){this.currentPageHostname=e,this.systemWhitelistChecker=new g(h),this.marketingWhitelistChecker=new g(m)}isResourceAllowed(e,s){return this.isNonHttpResource(e)?{isResourceAllowed:!0,resourceType:t.NON_HTTP}:this.isSystemResource(e)?{isResourceAllowed:!0,resourceType:t.SYSTEM}:this.isMarketingResource(e)?{isResourceAllowed:s.areMarketingRequestsAllowed,resourceType:t.MARKETING}:{isResourceAllowed:!1,resourceType:t.UNKNOWN}}isNonHttpResource(e){return!d.includes(e.protocol)}isSystemResource(e){const t=this.currentPageHostname===e.hostname,s=this.systemWhitelistChecker.isResourceAllowed(e);return t||s}isMarketingResource(e){return this.marketingWhitelistChecker.isResourceAllowed(e)}}const k=function(){const e=self.location.hostname,t=new p(e);return new i(t)}();addEventListener("install",(e=>{k.handleInstallEvent(e)})),addEventListener("activate",(e=>{k.handleActivateEvent(e)})),addEventListener("message",(e=>{k.handleMessageEvent(e)})),addEventListener("fetch",(e=>{k.handleFetchEvent(e)}))})();