"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([["ui_packages_alive_alive_ts"],{49395:(e,t,r)=>{let n;r.d(t,{G:()=>S});var o=r(21461);let AliveSession=class AliveSession extends o.a2{getUrlFromRefreshUrl(){return a(this.refreshUrl)}constructor(e,t,r,n){super(e,()=>this.getUrlFromRefreshUrl(),r,n),this.refreshUrl=t}};async function a(e){let t=await i(e);return t&&t.url&&t.token?s(t.url,t.token):null}async function i(e){let t=await fetch(e,{headers:{Accept:"application/json"}});if(t.ok)return t.json();if(404===t.status)return null;throw Error("fetch error")}async function s(e,t){let r=await fetch(e,{method:"POST",mode:"same-origin",headers:{"Scoped-CSRF-Token":t}});if(r.ok)return r.text();throw Error("fetch error")}var c=r(46263),l=r(87274),u=r(56363),d=r(47940),h=r(43786),f=r(50655);let p="alive";let InvalidSourceRelError=class InvalidSourceRelError extends f.d{};let y=d.ZO.createPolicy(p,{createScriptURL:e=>f.O.apply({policy:()=>{if(!(0,h.B)())return e;if(!e.startsWith("/"))throw new InvalidSourceRelError("Alive worker src URL must start with a slash");return e},policyName:p,fallback:e,fallbackOnError:!0})});function m(e,{channel:t,type:r,data:n}){for(let o of e)o.dispatchEvent(new CustomEvent(`socket:${r}`,{bubbles:!1,cancelable:!1,detail:{name:t,data:n}}))}let w=class AliveSessionProxy{subscribe(e){let t=this.subscriptions.add(...e);t.length&&this.worker.port.postMessage({subscribe:t});let r=new Set(t.map(e=>e.name)),n=e.reduce((e,t)=>{let n=t.topic.name;return(0,o.A)(n)&&!r.has(n)&&e.add(n),e},new Set);n.size&&this.worker.port.postMessage({requestPresence:Array.from(n)})}unsubscribeAll(...e){let t=this.subscriptions.drain(...e);t.length&&this.worker.port.postMessage({unsubscribe:t});let r=this.presenceMetadata.removeSubscribers(e);this.sendPresenceMetadataUpdate(r)}updatePresenceMetadata(e){let t=new Set;for(let r of e)this.presenceMetadata.setMetadata(r),t.add(r.channelName);this.sendPresenceMetadataUpdate(t)}sendPresenceMetadataUpdate(e){if(!e.size)return;let t=[];for(let r of e)t.push({channelName:r,metadata:this.presenceMetadata.getChannelMetadata(r)});this.worker.port.postMessage({updatePresenceMetadata:t})}online(){this.worker.port.postMessage({online:!0})}offline(){this.worker.port.postMessage({online:!1})}hangup(){this.worker.port.postMessage({hangup:!0})}receive(e){let{channel:t}=e;if("presence"===e.type){let r=this.notifyPresenceDebouncedByChannel.get(t);r||(r=(0,c.D)((e,r)=>{this.notify(e,r),this.notifyPresenceDebouncedByChannel.delete(t)},100),this.notifyPresenceDebouncedByChannel.set(t,r)),r(this.subscriptions.subscribers(t),e);return}this.notify(this.subscriptions.subscribers(t),e)}constructor(e,t,r,n,a){this.subscriptions=new o.vk,this.presenceMetadata=new o.ah,this.notifyPresenceDebouncedByChannel=new Map,this.notify=a,this.worker=new SharedWorker(e,`github-socket-worker-v2-${n}`),this.worker.port.onmessage=({data:e})=>this.receive(e),this.worker.port.postMessage({connect:{url:t,refreshUrl:r}})}};async function b(){let e=function(){let e=document.head.querySelector("link[rel=shared-web-socket-src]")?.getAttribute("href")??"";try{return y.createScriptURL(e)}catch(e){if(e instanceof InvalidSourceRelError)return null;throw e}}();if(!e)return;let t=document.head.querySelector("link[rel=shared-web-socket]")?.href??null;if(!t)return;let r=document.head.querySelector("link[rel=shared-web-socket]")?.getAttribute("data-refresh-url")??null;if(!r)return;let n=document.head.querySelector("link[rel=shared-web-socket]")?.getAttribute("data-session-id")??null;if(!n)return;let o=(()=>{if("SharedWorker"in window&&"true"!==(0,u.Z)("localStorage").getItem("bypassSharedWorker"))try{return new w(e,t,r,n,m)}catch(e){}return new AliveSession(t,r,!1,m)})();return window.addEventListener("online",()=>o.online()),window.addEventListener("offline",()=>o.offline()),window.addEventListener("pagehide",()=>{"hangup"in o&&o.hangup()}),o}async function g(){return await l.x,b()}function S(){return n||(n=g())}},65809:(e,t,r)=>{r.d(t,{eK:()=>m});var n=r(82918),o=r(21630),a=r(28382);function i(e){let t=document.querySelectorAll(e);if(t.length>0)return t[t.length-1]}var s=r(54508),c=r(71207),l=r(18515),u=r(58374);let d=!1,h=0,f=Date.now(),p=new Set(["Failed to fetch","NetworkError when attempting to fetch resource."]);function y(e){return!!("AbortError"===e.name||"TypeError"===e.name&&p.has(e.message)||e.name.startsWith("ApiError")&&p.has(e.message))}function m(e,t={}){if((0,l.c)("FAILBOT_HANDLE_NON_ERRORS")){if(!(e instanceof Error||"object"==typeof e&&null!==e&&"name"in e&&"string"==typeof e.name&&"message"in e&&"string"==typeof e.message)){if(function(e){if(!e||"boolean"==typeof e||"number"==typeof e)return!0;if("string"==typeof e){if(k.some(t=>e.includes(t)))return!0}else if("object"==typeof e&&"string"==typeof e.message&&"number"==typeof e.code)return!0;return!1}(e))return;let r=Error(),n=function(e){try{return JSON.stringify(e)}catch{return"Unserializable"}}(e),o={type:"UnknownError",value:`Unable to report error, due to a thrown non-Error type: ${typeof e}, with value ${n}`,stacktrace:S(r),catalogService:void 0};w(g(o,t));return}y(e)||w(g(b(e),t))}else y(e)||w(g(b(e),t))}async function w(e){if(!(!T&&!d&&h<10&&(0,o.Gb)()))return;let t=document.head?.querySelector('meta[name="browser-errors-url"]')?.content;if(t){if(e.error.stacktrace.some(e=>E.test(e.filename)||E.test(e.function))){d=!0;return}h++;try{await fetch(t,{method:"post",body:JSON.stringify(e)})}catch{}}}function b(e){return{type:e.name,value:e.message,stacktrace:S(e),catalogService:e.catalogService}}function g(e,t={}){return Object.assign({error:e,sanitizedUrl:`${window.location.protocol}//${window.location.host}${function(){let e=i("meta[name=analytics-location]");return e?e.content:window.location.pathname}()+function(){let e=i("meta[name=analytics-location-query-strip]"),t="";e||(t=window.location.search);let r=i("meta[name=analytics-location-params]");for(let e of(r&&(t+=(t?"&":"?")+r.content),document.querySelectorAll("meta[name=analytics-param-rename]"))){let r=e.content.split(":",2);t=t.replace(RegExp(`(^|[?&])${r[0]}($|=)`,"g"),`$1${r[1]}$2`)}return t}()}`||window.location.href,readyState:document.readyState,referrer:(0,u.wP)(),timeSinceLoad:Math.round(Date.now()-f),user:function(){let e=document.head?.querySelector('meta[name="user-login"]')?.content;if(e)return e;let t=(0,n.b)();return`anonymous-${t}`}()||void 0,bundler:s.A,ui:!!document.querySelector('meta[name="ui"]')},t)}function S(e){return(0,a.Q)(e.stack||"").map(e=>({filename:e.file||"",function:String(e.methodName),lineno:(e.lineNumber||0).toString(),colno:(e.column||0).toString()}))}let E=/(chrome|moz|safari)-extension:\/\//,T=!1;if(c.iG?.addEventListener("pageshow",()=>T=!1),c.iG?.addEventListener("pagehide",()=>T=!0),"function"==typeof BroadcastChannel){let e=new BroadcastChannel("shared-worker-error");e.addEventListener("message",e=>{m(e.data.error)})}let k=["Object Not Found Matching Id","Not implemented on this platform","provider because it's not your default extension"]},50655:(e,t,r)=>{r.d(t,{O:()=>l,d:()=>TrustedTypesPolicyError});var n=r(18515),o=r(43786),a=r(65809),i=r(27856),s=r.n(i),c=r(79697);let TrustedTypesPolicyError=class TrustedTypesPolicyError extends Error{};let l={apply:function({policy:e,policyName:t,fallback:r,fallbackOnError:i=!1,sanitize:l,silenceErrorReporting:u=!1}){try{if((0,n.c)("BYPASS_TRUSTED_TYPES_POLICY_RULES"))return r;(0,o.b)({incrementKey:"TRUSTED_TYPES_POLICY_CALLED",trustedTypesPolicyName:t},!1,.1);let a=e();return l&&new Promise(e=>{let r=window.performance.now(),n=s().sanitize(a,{FORBID_ATTR:[]}),o=window.performance.now();if(a.length!==n.length){let i=Error("Trusted Types policy output sanitized"),s=i.stack?.slice(0,1e3),l=a.slice(0,250);(0,c.qP)("trusted_types_policy.sanitize",{policyName:t,output:l,stack:s,outputLength:a.length,sanitizedLength:n.length,executionTime:o-r}),e(a)}}),a}catch(e){if(e instanceof TrustedTypesPolicyError||(u||(0,a.eK)(e),(0,o.b)({incrementKey:"TRUSTED_TYPES_POLICY_ERROR",trustedTypesPolicyName:t}),!i))throw e}return r}}},47940:(e,t,r)=>{r.d(t,{ZO:()=>u});var n,o=r(71207),a=r(43786);function i(e){return()=>{throw TypeError(`The policy does not implement the function ${e}`)}}let s={createHTML:i("createHTML"),createScript:i("createScript"),createScriptURL:i("createScriptURL")},c=(n=globalThis).__TRUSTED_TYPE_POLICIES__??(n.__TRUSTED_TYPE_POLICIES__=new Map),l=globalThis.trustedTypes??{createPolicy:(e,t)=>({name:e,...s,...t})},u={createPolicy:(e,t)=>{if(c.has(e))return(0,a.b)({incrementKey:"TRUSTED_TYPES_POLICY_INITIALIZED_TWICE"}),c.get(e);{let r=Object.freeze(l.createPolicy(e,t));return c.set(e,r),r}}},d=!1;o.n4?.addEventListener("securitypolicyviolation",e=>{"require-trusted-types-for"!==e.violatedDirective||d||(console.warn(`Hi fellow Hubber! You're probably seeing a Report Only Trusted Types error near this message. This is intended behaviour, staff-only, does not impact application control flow, and is used solely for statistic collection. Unfortunately we can't gather these statistics without adding the above warnings to your console. Sorry about that! Feel free to drop by #pse-architecture if you have any additional questions about Trusted Types or CSP.`),d=!0)})}}]); //# sourceMappingURL=ui_packages_alive_alive_ts-4fb55e1b2c9b.js.map