spectatr-player-sdk
Version: 
A custom video player built with Stencil with Shaka Player integration
90 lines (89 loc) • 168 kB
JavaScript
const authHeaders = {
    'authorization': `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Im5pdGlzaEBzcGVjdGF0ci5haSIsImVudGl0eUlkIjoiNjc4NzZhM2Q4NmM0NGQ2MDJjNmQ1N2MxIiwidXNlcklkIjoiNjc4NzZhNzU4NmM0NGQ2MDJjNmQ1N2MyIiwidHlwZSI6IlVTRVIiLCJpYXQiOjE3NTk0ODQzOTMsImV4cCI6MTc2MjA3NjM5M30.JJm8kqlB_beHYxLAszt_V7Zc5xL4ZyHPEVyn0Uiqjqs`,
    'x-api-key': 'bak8zb8uwimo4pjdmyu3-basluiwthvn3u7qznfgy-2thtwws1764g3706xsoo',
};
async function fetchVideoSrc(component, isSetSrc = false) {
    try {
        if (!component.clientId)
            return;
        const response = await fetch(`${component.baseUrl}/sp-onboarding/video-streaming/${component.clientId}?userId=${component.userId}&${component.videoId && `videoId=${component.videoId}`}`, {
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json',
                ...authHeaders,
            },
        });
        const data = await response.json();
        if (data.success) {
            component.quizzes = data.payload.quiz ?? { quizQuestions: [] };
            component.polls = data.payload.polls ?? [];
            component.statistics = data.payload.statistics;
            component.totalLikes = data.payload.likeCount;
            component.isLiked = data.payload.userLiked;
            component.isDisliked = data.payload.userReacted ? !data.payload.userLiked : false;
            component.totalViews = data.payload.views;
            component.tempVideoId = data.payload.videoId;
            component.timelineEvents = data.payload.videoEventMarkers ?? [];
            if (isSetSrc) {
                component.src = data.payload.outputLink;
                component.scheduleTime = data.payload.scheduledStart;
                // component.src = 'https://live-hls-web-aje.getaj.net/AJE/index.m3u8';
                component.videoTitle = data.payload.title;
                component.videoDescription = data.payload.description;
                component.token = data.payload.token ?? '';
                component.poster = data.payload.thumbnailPath.replace('https://stg-highlights-storage.s3.ap-south-1.amazonaws.com', 'https://d20mh0n8ctk3v.cloudfront.net');
                component.createdAt = data.payload.createdAt;
                component.showFullDescription = (component.videoDescription ?? '').length <= 200;
            }
        }
    }
    catch (error) {
        console.error('Error loading video:', error);
    }
}
async function addReaction(component, reaction) {
    const response = await fetch(`${component.baseUrl}/sp-onboarding/reactions`, {
        body: JSON.stringify({
            userId: component.userId,
            videoId: component.videoId,
            reaction: reaction,
        }),
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            ...authHeaders,
        },
    });
    if (!response.ok) {
        const errorData = await response.json().catch(() => ({}));
        throw new Error(`Request failed with status ${response.status}: ${JSON.stringify(errorData)}`);
    }
    return response.json();
}
async function fetchSuggestions(component, page = 0, limit = 10) {
    try {
        const response = await fetch(`${component.baseUrl}/sp-onboarding/video-onboard/suggestions/${component.clientId}?limit=${limit}&page=${page}&transcodingStatus=complete`, {
            headers: { ...authHeaders },
        });
        const data = await response.json();
        if (!!data) {
            return { suggestions: data.payload.suggestions, totalCount: data.payload.totalCount };
        }
    }
    catch (error) {
        return { suggestions: [], totalCount: 0 };
    }
}
async function fetchAllVideos(clientId, baseUrl = 'https://api.staging.spectatr.ai/player-sdk') {
    const response = await fetch(`${baseUrl}/sp-onboarding/video-onboard/suggestions/${clientId}/no-pagination?transcodingStatus=complete`, {
        headers: { ...authHeaders },
    });
    if (!response.ok) {
        const errorData = await response.json().catch(() => ({}));
        throw new Error(`Request failed with status ${response.status}: ${JSON.stringify(errorData)}`);
    }
    const data = await response.json();
    return { suggestions: data.payload.suggestions, totalCount: data.payload.totalCount };
}
var t="undefined"!=typeof window?window:void 0,i="undefined"!=typeof globalThis?globalThis:t,e=Array.prototype,r=e.forEach,s=e.indexOf,n=null==i?void 0:i.navigator,o=null==i?void 0:i.document,a=null==i?void 0:i.location,l=null==i?void 0:i.fetch,u=null!=i&&i.XMLHttpRequest&&"withCredentials"in new i.XMLHttpRequest?i.XMLHttpRequest:void 0,h=null==i?void 0:i.AbortController,d=null==n?void 0:n.userAgent,v=null!=t?t:{},c={DEBUG:false,LIB_VERSION:"1.274.3"};function f(t,i,e,r,s,n,o){try{var a=t[n](o),l=a.value;}catch(t){return void e(t)}a.done?i(l):Promise.resolve(l).then(r,s);}function p(t){return function(){var i=this,e=arguments;return new Promise((function(r,s){var n=t.apply(i,e);function o(t){f(n,r,s,o,a,"next",t);}function a(t){f(n,r,s,o,a,"throw",t);}o(void 0);}))}}function g(){return g=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r]);}return t},g.apply(null,arguments)}function _(t,i){if(null==t)return {};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==i.indexOf(r))continue;e[r]=t[r];}return e}var m=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function y(t,i){return  -1!==t.indexOf(i)}var b=function(t){return t.trim()},w=function(t){return t.replace(/^\$/,"")};var S=Array.isArray,x=Object.prototype,E=x.hasOwnProperty,k=x.toString,P=S||function(t){return "[object Array]"===k.call(t)},I=t=>"function"==typeof t,R=t=>t===Object(t)&&!P(t),T=t=>{if(R(t)){for(var i in t)if(E.call(t,i))return  false;return  true}return  false},C=t=>void 0===t,O=t=>"[object String]"==k.call(t),F=t=>O(t)&&0===t.trim().length,M=t=>null===t,A=t=>C(t)||M(t),j=t=>"[object Number]"==k.call(t),D=t=>"[object Boolean]"===k.call(t),L=t=>t instanceof FormData,N=t=>y(m,t);function U(t){return null===t||"object"!=typeof t}function z(t,i){return Object.prototype.toString.call(t)==="[object "+i+"]"}function H(t){return !C(Event)&&function(t,i){try{return t instanceof i}catch(t){return  false}}(t,Event)}var B=[true,"true",1,"1","yes"],q=t=>y(B,t),W=[false,"false",0,"0","no"];function G(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),j(t)?t>e?(r.warn(" cannot be  greater than max: "+e+". Using max value instead."),e):t<i?(r.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(r.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+s),G(s||e,i,e,r))}class V{constructor(t){this.t=t,this.i={},this.o=()=>{Object.keys(this.i).forEach((t=>{var i=this.h(t)+this.m;i>=this.S?delete this.i[t]:this.$(t,i);}));},this.h=t=>this.i[String(t)],this.$=(t,i)=>{this.i[String(t)]=i;},this.consumeRateLimit=t=>{var i,e,r=null!==(i=this.h(t))&&void 0!==i?i:this.S;if(0===(r=Math.max(r-1,0)))return  true;this.$(t,r);var s=0===r;return s&&(null==(e=this.k)||e.call(this,t)),s},this.k=this.t.k,this.S=G(this.t.bucketSize,0,100,this.t.P),this.m=G(this.t.refillRate,0,this.S,this.t.P),this.I=G(this.t.refillInterval,0,864e5,this.t.P),this.R=setInterval((()=>{this.o();}),this.I);}stop(){this.R&&(clearInterval(this.R),this.R=void 0);}}var J,K,Y,X=t=>t instanceof Error;function Q(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return Y&&e.length===K||(K=e.length,Y=e.reduce(((e,r)=>{J||(J={});var s=J[r];if(s)e[s[0]]=s[1];else for(var n=t(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=i[r];if(l&&u){e[l]=u,J[r]=[l,u];break}}return e}),{})),Y}}var Z="?";function tt(t,i,e,r){var s={platform:"web:javascript",filename:t,function:"<anonymous>"===i?Z:i,in_app:true};return C(e)||(s.lineno=e),C(r)||(s.colno=r),s}var it=(t,i)=>{var e=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return e||r?[-1!==t.indexOf("@")?t.split("@")[0]:Z,e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},et=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,rt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,st=/\((\S*)(?::(\d+))(?::(\d+))\)/,nt=t=>{var i=et.exec(t);if(i){var[,e,r,s]=i;return tt(e,Z,+r,+s)}var n=rt.exec(t);if(n){if(n[2]&&0===n[2].indexOf("eval")){var o=st.exec(n[2]);o&&(n[2]=o[1],n[3]=o[2],n[4]=o[3]);}var[a,l]=it(n[1]||Z,n[2]);return tt(l,a,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},ot=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,at=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,lt=t=>{var i=ot.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var e=at.exec(i[3]);e&&(i[1]=i[1]||"eval",i[3]=e[1],i[4]=e[2],i[5]="");}var r=i[3],s=i[1]||Z;return [s,r]=it(s,r),tt(r,s,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},ut=/\(error: (.*)\)/,ht=50;function dt(){for(var t=arguments.length,i=new Array(t),e=0;e<t;e++)i[e]=arguments[e];return function(t,e){ void 0===e&&(e=0);for(var r=[],s=t.split("\n"),n=e;n<s.length;n++){var o=s[n];if(!(o.length>1024)){var a=ut.test(o)?o.replace(ut,"$1"):o;if(!a.match(/\S*Error: /)){for(var l of i){var u=l(a);if(u){r.push(u);break}}if(r.length>=ht)break}}}return function(t){if(!t.length)return [];var i=Array.from(t);return i.reverse(),i.slice(0,ht).map((t=>{return g({},t,{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||Z});var e;}))}(r)}}class vt{constructor(t,i,e){ void 0===t&&(t=[]),void 0===i&&(i=[]),void 0===e&&(e=[]),this.coercers=t,this.modifiers=e,this.stackParser=dt(...i);}buildFromUnknown(t,i){ void 0===i&&(i={});var e=i&&i.mechanism||{handled:true,type:"generic"},r=this.buildCoercingContext(e,i,0).apply(t),s=this.buildParsingContext(),n=this.parseStacktrace(r,s);return {$exception_list:this.convertToExceptionList(n,e),$exception_level:"error"}}modifyFrames(t){var i=this;return p((function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&P(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t}))()}coerceFallback(t){var i;return {type:"Error",value:"Unknown error",stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:true}}parseStacktrace(t,i){var e,r;return null!=t.cause&&(e=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack&&(r=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?1:0),i.chunkIdMap)),g({},t,{cause:e,stack:r})}applyChunkIds(t,i){return t.map((t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t)))}applyCoercers(t,i){for(var e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return p((function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e}))()}convertToExceptionList(t,i){var e,r,s,n={type:t.type,value:t.value,mechanism:{type:null!==(e=i.type)&&void 0!==e?e:"generic",handled:null===(r=i.handled)||void 0===r||r,synthetic:null!==(s=t.synthetic)&&void 0!==s&&s}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});var o=[n];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,g({},i,{handled:true}))),o}buildParsingContext(){return {chunkIdMap:Q(this.stackParser)}}buildCoercingContext(t,i,e){ void 0===e&&(e=0);var r=(e,r)=>{if(r<=4){var s=this.buildCoercingContext(t,i,r);return this.applyCoercers(e,s)}};return g({},i,{syntheticException:0==e?i.syntheticException:void 0,mechanism:t,apply:t=>r(t,e),next:t=>r(t,e+1)})}}class ct{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=O(t.stack);return {type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:false}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?i+": "+t.message:i}isDOMException(t){return z(t,"DOMException")}isDOMError(t){return z(t,"DOMError")}}class ft{match(t){return (t=>t instanceof Error)(t)}coerce(t,i){return {type:this.getType(t),value:this.getMessage(t,i),stack:this.getStack(t),cause:t.cause?i.next(t.cause):void 0,synthetic:false}}getType(t){return t.name||t.constructor.name}getMessage(t,i){var e=t.message;return e.error&&"string"==typeof e.error.message?String(e.error.message):String(e)}getStack(t){return t.stacktrace||t.stack||void 0}}class pt{constructor(){}match(t){return z(t,"ErrorEvent")&&null!=t.error}coerce(t,i){var e,r=i.apply(t.error);return r||{type:"ErrorEvent",value:t.message,stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:true}}}var gt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class _t{match(t){return "string"==typeof t}coerce(t,i){var e,[r,s]=this.getInfos(t);return {type:null!=r?r:"Error",value:null!=s?s:t,stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:true}}getInfos(t){var i="Error",e=t,r=t.match(gt);return r&&(i=r[1],e=r[2]),[i,e]}}var mt=["fatal","error","warning","log","info","debug"];function yt(t,i){ void 0===i&&(i=40);var e=Object.keys(t);if(e.sort(),!e.length)return "[object has no keys]";for(var r=e.length;r>0;r--){var s=e.slice(0,r).join(", ");if(!(s.length>i))return r===e.length||s.length<=i?s:s.slice(0,i)+"..."}return ""}class bt{match(t){return "object"==typeof t&&null!==t}coerce(t,i){var e,r=this.getErrorPropertyFromObject(t);return r?i.apply(r):{type:this.getType(t),value:this.getValue(t),stack:null==(e=i.syntheticException)?void 0:e.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:true}}getType(t){return H(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var i="'"+t.name+"' captured as exception";return "message"in t&&"string"==typeof t.message&&(i+=" with message: '"+t.message+"'"),i}if("message"in t&&"string"==typeof t.message)return t.message;var e=this.getObjectClassName(t);return (e&&"Object"!==e?"'"+e+"'":"Object")+" captured as exception with keys: "+yt(t)}isSeverityLevel(t){return O(t)&&!F(t)&&mt.indexOf(t)>=0}getErrorPropertyFromObject(t){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var e=t[i];if(X(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}}class wt{match(t){return H(t)}coerce(t,i){var e,r=t.constructor.name;return {type:r,value:r+" captured as exception with keys: "+yt(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:true}}}class St{match(t){return U(t)}coerce(t,i){var e;return {type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:true}}}class xt{match(t){return z(t,"PromiseRejectionEvent")}coerce(t,i){var e,r=this.getUnhandledRejectionReason(t);return U(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:true}:i.apply(r)}getUnhandledRejectionReason(t){if(U(t))return t;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var Et=i=>{var e={T:function(e){if(t&&(c.DEBUG||v.POSTHOG_DEBUG)&&!C(t.console)&&t.console){for(var r=("__rrweb_original__"in t.console[e]?t.console[e].__rrweb_original__:t.console[e]),s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];r(i,...n);}},info:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];e.T("log",...i);},warn:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];e.T("warn",...i);},error:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];e.T("error",...i);},critical:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];console.error(i,...e);},uninitializedWarning:t=>{e.error("You must initialize PostHog before calling "+t);},createLogger:t=>Et(i+" "+t)};return e},$t=Et("[PostHog.js]"),kt=$t.createLogger,Pt=kt("[ExternalScriptsLoader]"),It=(t,i,e)=>{if(t.config.disable_external_dependency_loading)return Pt.warn(i+" was requested but loading of external scripts is disabled."),e("Loading of external scripts is disabled");var r=null==o?void 0:o.querySelectorAll("script");if(r)for(var s,n=function(){if(r[a].src===i){var t=r[a];return t.__posthog_loading_callback_fired?{v:e()}:(t.addEventListener("load",(i=>{t.__posthog_loading_callback_fired=true,e(void 0,i);})),t.onerror=t=>e(t),{v:void 0})}},a=0;a<r.length;a++)if(s=n())return s.v;var l=()=>{if(!o)return e("document not found");var r=o.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=i,r.onload=t=>{r.__posthog_loading_callback_fired=true,e(void 0,t);},r.onerror=t=>e(t),t.config.prepare_external_dependency_script&&(r=t.config.prepare_external_dependency_script(r)),!r)return e("prepare_external_dependency_script returned null");var s,n=o.querySelectorAll("body > script");n.length>0?null==(s=n[0].parentNode)||s.insertBefore(r,n[0]):o.body.appendChild(r);};null!=o&&o.body?l():null==o||o.addEventListener("DOMContentLoaded",l);};v.__PosthogExtensions__=v.__PosthogExtensions__||{},v.__PosthogExtensions__.loadExternalDependency=(t,i,e)=>{var r="/static/"+i+".js?v="+t.version;if("remote-config"===i&&(r="/array/"+t.config.token+"/config.js"),"toolbar"===i){var s=3e5;r=r+"&t="+Math.floor(Date.now()/s)*s;}var n=t.requestRouter.endpointFor("assets",r);It(t,n,e);},v.__PosthogExtensions__.loadSiteApp=(t,i,e)=>{var r=t.requestRouter.endpointFor("api",i);It(t,r,e);};var Rt={};function Tt(t,i,e){if(P(t))if(r&&t.forEach===r)t.forEach(i,e);else if("length"in t&&t.length===+t.length)for(var s=0,n=t.length;s<n;s++)if(s in t&&i.call(e,t[s],s)===Rt)return}function Ct(t,i,e){if(!A(t)){if(P(t))return Tt(t,i,e);if(L(t)){for(var r of t.entries())if(i.call(e,r[1],r[0])===Rt)return}else for(var s in t)if(E.call(t,s)&&i.call(e,t[s],s)===Rt)return}}var Ot=function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;r<i;r++)e[r-1]=arguments[r];return Tt(e,(function(i){for(var e in i) void 0!==i[e]&&(t[e]=i[e]);})),t},Ft=function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;r<i;r++)e[r-1]=arguments[r];return Tt(e,(function(i){Tt(i,(function(i){t.push(i);}));})),t};function Mt(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}var At=function(t){try{return t()}catch(t){return}},jt=function(t){return function(){try{for(var i=arguments.length,e=new Array(i),r=0;r<i;r++)e[r]=arguments[r];return t.apply(this,e)}catch(t){$t.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),$t.critical(t);}}},Dt=function(t){var i={};return Ct(t,(function(t,e){(O(t)&&t.length>0||j(t))&&(i[e]=t);})),i};function Lt(t,i){return e=t,r=t=>O(t)&&!M(i)?t.slice(0,i):t,s=new Set,function t(i,e){return i!==Object(i)?r?r(i,e):i:s.has(i)?void 0:(s.add(i),P(i)?(n=[],Tt(i,(i=>{n.push(t(i));}))):(n={},Ct(i,((i,e)=>{s.has(i)||(n[e]=t(i,e));}))),n);var n;}(e);var e,r,s;}var Nt=["herokuapp.com","vercel.app","netlify.app"];function Ut(t){var i=null==t?void 0:t.hostname;if(!O(i))return  false;var e=i.split(".").slice(-2).join(".");for(var r of Nt)if(e===r)return  false;return  true}function zt(t,i){for(var e=0;e<t.length;e++)if(i(t[e]))return t[e]}function Ht(t,i,e,r){var{capture:s=false,passive:n=true}=null!=r?r:{};null==t||t.addEventListener(i,e,{capture:s,passive:n});}var Bt="$people_distinct_id",qt="__alias",Wt="__timers",Gt="$autocapture_disabled_server_side",Vt="$heatmaps_enabled_server_side",Jt="$exception_capture_enabled_server_side",Kt="$error_tracking_suppression_rules",Yt="$error_tracking_capture_extension_exceptions",Xt="$web_vitals_enabled_server_side",Qt="$dead_clicks_enabled_server_side",Zt="$web_vitals_allowed_metrics",ti="$session_recording_remote_config",ii="$sesid",ei="$session_is_sampled",ri="$enabled_feature_flags",si="$early_access_features",ni="$feature_flag_details",oi="$stored_person_properties",ai="$stored_group_properties",li="$surveys",ui="$surveys_activated",hi="$flag_call_reported",di="$user_state",vi="$client_session_props",ci="$capture_rate_limit",fi="$initial_campaign_params",pi="$initial_referrer_info",gi="$initial_person_info",_i="$epp",mi="__POSTHOG_TOOLBAR__",yi="$posthog_cookieless",bi=[Bt,qt,"__cmpns",Wt,"$session_recording_enabled_server_side",Vt,ii,ri,Kt,di,si,ni,ai,oi,li,hi,vi,ci,fi,pi,_i,gi];function wi(t){return t instanceof Element&&(t.id===mi||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Si(t){return !!t&&1===t.nodeType}function xi(t,i){return !!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Ei(t){return !!t&&3===t.nodeType}function $i(t){return !!t&&11===t.nodeType}function ki(t){return t?b(t).split(/\s+/):[]}function Pi(i){var e=null==t?void 0:t.location.href;return !!(e&&i&&i.some((t=>e.match(t))))}function Ii(t){var i="";switch(typeof t.className){case "string":i=t.className;break;case "object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i="";}return ki(i)}function Ri(t){return A(t)?null:b(t).split(/(\s+)/).filter((t=>Vi(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ti(t){var i="";return Ni(t)&&!Ui(t)&&t.childNodes&&t.childNodes.length&&Ct(t.childNodes,(function(t){var e;Ei(t)&&t.textContent&&(i+=null!==(e=Ri(t.textContent))&&void 0!==e?e:"");})),b(i)}function Ci(t){return C(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null;var i;}var Oi=["a","button","form","input","select","textarea","label"];function Fi(t,i){if(C(i))return  true;var e,r=function(t){if(i.some((i=>t.matches(i))))return {v:true}};for(var s of t)if(e=r(s))return e.v;return  false}function Mi(t){var i=t.parentNode;return !(!i||!Si(i))&&i}var Ai=[".ph-no-rageclick",".ph-no-capture"];var ji=t=>!t||xi(t,"html")||!Si(t),Di=(i,e)=>{if(!t||ji(i))return {parentIsUsefulElement:false,targetElementList:[]};for(var r=false,s=[i],n=i;n.parentNode&&!xi(n,"body");)if($i(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else {var o=Mi(n);if(!o)break;if(e||Oi.indexOf(o.tagName.toLowerCase())>-1)r=true;else {var a=t.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(r=true);}s.push(o),n=o;}return {parentIsUsefulElement:r,targetElementList:s}};function Li(i,e,r,s,n){var o,a,l,u;if(void 0===r&&(r=void 0),!t||ji(i))return  false;if(null!=(o=r)&&o.url_allowlist&&!Pi(r.url_allowlist))return  false;if(null!=(a=r)&&a.url_ignorelist&&Pi(r.url_ignorelist))return  false;if(null!=(l=r)&&l.dom_event_allowlist){var h=r.dom_event_allowlist;if(h&&!h.some((t=>e.type===t)))return  false}var{parentIsUsefulElement:d,targetElementList:v}=Di(i,s);if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(C(e))return  true;var r,s=function(t){if(e.some((i=>t.tagName.toLowerCase()===i)))return {v:true}};for(var n of t)if(r=s(n))return r.v;return  false}(v,r))return  false;if(!Fi(v,null==(u=r)?void 0:u.css_selector_allowlist))return  false;var c=t.getComputedStyle(i);if(c&&"pointer"===c.getPropertyValue("cursor")&&"click"===e.type)return  true;var f=i.tagName.toLowerCase();switch(f){case "html":return  false;case "form":return (n||["submit"]).indexOf(e.type)>=0;case "input":case "select":case "textarea":return (n||["change","click"]).indexOf(e.type)>=0;default:return d?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(Oi.indexOf(f)>-1||"true"===i.getAttribute("contenteditable"))}}function Ni(t){for(var i=t;i.parentNode&&!xi(i,"body");i=i.parentNode){var e=Ii(i);if(y(e,"ph-sensitive")||y(e,"ph-no-capture"))return  false}if(y(Ii(t),"ph-include"))return  true;var r=t.type||"";if(O(r))switch(r.toLowerCase()){case "hidden":case "password":return  false}var s=t.name||t.id||"";if(O(s)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,"")))return  false}return  true}function Ui(t){return !!(xi(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||xi(t,"select")||xi(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var zi="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",Hi=new RegExp("^(?:"+zi+")$"),Bi=new RegExp(zi),qi="\\d{3}-?\\d{2}-?\\d{4}",Wi=new RegExp("^("+qi+")$"),Gi=new RegExp("("+qi+")");function Vi(t,i){if(void 0===i&&(i=true),A(t))return  false;if(O(t)){if(t=b(t),(i?Hi:Bi).test((t||"").replace(/[- ]/g,"")))return  false;if((i?Wi:Gi).test(t))return  false}return  true}function Ji(t){var i=Ti(t);return Vi(i=(i+" "+Ki(t)).trim())?i:""}function Ki(t){var i="";return t&&t.childNodes&&t.childNodes.length&&Ct(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=Ti(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+Ki(t)).trim());}catch(t){$t.error("[AutoCapture]",t);}})),i}function Yi(t){return function(t){var i=t.map((t=>{var i,e,r="";if(t.tag_name&&(r+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))r+="."+s.replace(/"/g,"");var n=g({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return Mt(n).sort(((t,i)=>{var[e]=t,[r]=i;return e.localeCompare(r)})).forEach((t=>{var[i,e]=t;return o[Xi(i.toString())]=Xi(e.toString())})),r+=":",r+=Mt(o).map((t=>{var[i,e]=t;return i+'="'+e+'"'})).join("")}));return i.join(";")}(function(t){return t.map((t=>{var i,e,r={text:null==(i=t.$el_text)?void 0:i.slice(0,400),tag_name:t.tag_name,href:null==(e=t.attr__href)?void 0:e.slice(0,2048),attr_class:Qi(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Mt(t).filter((t=>{var[i]=t;return 0===i.indexOf("attr__")})).forEach((t=>{var[i,e]=t;return r.attributes[i]=e})),r}))}(t))}function Xi(t){return t.replace(/"|\\"/g,'\\"')}function Qi(t){var i=t.attr__class;return i?P(i)?i:ki(i):void 0}class Zi{constructor(){this.clicks=[];}isRageClick(t,i,e){var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(i-r.y)<30&&e-r.timestamp<1e3){if(this.clicks.push({x:t,y:i,timestamp:e}),3===this.clicks.length)return  true}else this.clicks=[{x:t,y:i,timestamp:e}];return  false}}var te="$copy_autocapture",ie=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),re=t=>{var i=null==o?void 0:o.createElement("a");return C(i)?null:(i.href=t,i)},se=function(t,i){var e,r;void 0===i&&(i="&");var s=[];return Ct(t,(function(t,i){C(t)||C(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e);})),s.join(i)},ne=function(t,i){for(var e,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<r.length;s++){var n=r[s].split("=");if(n[0]===i){e=n;break}}if(!P(e)||e.length<2)return "";var o=e[1];try{o=decodeURIComponent(o);}catch(t){$t.error("Skipping decoding for malformed query param: "+o);}return o.replace(/\+/g," ")},oe=function(t,i,e){if(!t||!i||!i.length)return t;for(var r=t.split("#"),s=r[0]||"",n=r[1],o=s.split("?"),a=o[1],l=o[0],u=(a||"").split("&"),h=[],d=0;d<u.length;d++){var v=u[d].split("=");P(v)&&(i.includes(v[0])?h.push(v[0]+"="+e):h.push(u[d]));}var c=l;return null!=a&&(c+="?"+h.join("&")),null!=n&&(c+="#"+n),c},ae=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},le=kt("[AutoCapture]");function ue(t,i){return i.length>t?i.slice(0,t)+"...":i}function he(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling;}while(i&&!Si(i));return i}function de(t,i,e,r){var s=t.tagName.toLowerCase(),n={tag_name:s};Oi.indexOf(s)>-1&&!e&&("a"===s.toLowerCase()||"button"===s.toLowerCase()?n.$el_text=ue(1024,Ji(t)):n.$el_text=ue(1024,Ti(t)));var o=Ii(t);o.length>0&&(n.classes=o.filter((function(t){return ""!==t}))),Ct(t.attributes,(function(e){var s;if((!Ui(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&((null==r||!r.includes(e.name))&&!i&&Vi(e.value)&&(s=e.name,!O(s)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7)))){var o=e.value;"class"===e.name&&(o=ki(o).join(" ")),n["attr__"+e.name]=ue(1024,o);}}));for(var a=1,l=1,u=t;u=he(u);)a++,u.tagName===t.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function ve(i,e){for(var r,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=e,h=[i],d=i;d.parentNode&&!xi(d,"body");)$i(d.parentNode)?(h.push(d.parentNode.host),d=d.parentNode.host):(h.push(d.parentNode),d=d.parentNode);var v,c=[],f={},p=false,g=false;if(Ct(h,(t=>{var i=Ni(t);"a"===t.tagName.toLowerCase()&&(p=t.getAttribute("href"),p=i&&p&&Vi(p)&&p),y(Ii(t),"ph-no-capture")&&(g=true),c.push(de(t,o,a,l));var e=function(t){if(!Ni(t))return {};var i={};return Ct(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var e=t.name.replace("data-ph-capture-attribute-",""),r=t.value;e&&r&&Vi(r)&&(i[e]=r);}})),i}(t);Ot(f,e);})),g)return {props:{},explicitNoCapture:g};if(a||("a"===i.tagName.toLowerCase()||"button"===i.tagName.toLowerCase()?c[0].$el_text=Ji(i):c[0].$el_text=Ti(i)),p){var _,m;c[0].attr__href=p;var b=null==(_=re(p))?void 0:_.host,w=null==t||null==(m=t.location)?void 0:m.host;b&&w&&b!==w&&(v=p);}return {props:Ot({$event_type:n.type,$ce_version:1},u?{}:{$elements:c},{$elements_chain:Yi(c)},null!=(r=c[0])&&r.$el_text?{$el_text:null==(s=c[0])?void 0:s.$el_text}:{},v&&"click"===n.type?{$external_click_url:v}:{},f)}}class ce{constructor(t){this.C=false,this.O=null,this.rageclicks=new Zi,this.F=false,this.instance=t,this.M=null;}get A(){var t,i,e=R(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=null==(t=e.url_allowlist)?void 0:t.map((t=>new RegExp(t))),e.url_ignorelist=null==(i=e.url_ignorelist)?void 0:i.map((t=>new RegExp(t))),e}j(){if(this.isBrowserSupported()){if(t&&o){var i=i=>{i=i||(null==t?void 0:t.event);try{this.D(i);}catch(t){le.error("Failed to capture event",t);}};if(Ht(o,"submit",i,{capture:true}),Ht(o,"change",i,{capture:true}),Ht(o,"click",i,{capture:true}),this.A.capture_copied_text){var e=i=>{i=i||(null==t?void 0:t.event),this.D(i,te);};Ht(o,"copy",e,{capture:true}),Ht(o,"cut",e,{capture:true});}}}else le.info("Disabling Automatic Event Collection because this browser is not supported");}startIfEnabled(){this.isEnabled&&!this.C&&(this.j(),this.C=true);}onRemoteConfig(t){t.elementsChainAsString&&(this.F=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Gt]:!!t.autocapture_opt_out}),this.O=!!t.autocapture_opt_out,this.startIfEnabled();}setElementSelectors(t){this.M=t;}getElementSelectors(t){var i,e=[];return null==(i=this.M)||i.forEach((i=>{var r=null==o?void 0:o.querySelectorAll(i);null==r||r.forEach((r=>{t===r&&e.push(i);}));})),e}get isEnabled(){var t,i,e=null==(t=this.instance.persistence)?void 0:t.props[Gt],r=this.O;if(M(r)&&!D(e)&&!this.instance.L())return  false;var s=null!==(i=this.O)&&void 0!==i?i:!!e;return !!this.instance.config.autocapture&&!s}D(i,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var r,s=Ci(i);if(Ei(s)&&(s=s.parentNode||null),"$autocapture"===e&&"click"===i.type&&i instanceof MouseEvent)this.instance.config.rageclick&&null!=(r=this.rageclicks)&&r.isRageClick(i.clientX,i.clientY,(new Date).getTime())&&function(i,e){if(!t||ji(i))return  false;var r,s;if(false===(r=D(e)?!!e&&Ai:null!==(s=null==e?void 0:e.css_selector_ignorelist)&&void 0!==s?s:Ai))return  false;var{targetElementList:n}=Di(i,false);return !Fi(n,r)}(s,this.instance.config.rageclick)&&this.D(i,"$rageclick");var n=e===te;if(s&&Li(s,i,this.A,n,n?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=ve(s,{e:i,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.A.element_attribute_ignorelist,elementsChainAsString:this.F});if(a)return  false;var l=this.getElementSelectors(s);if(l&&l.length>0&&(o.$element_selectors=l),e===te){var u,h=Ri(null==t||null==(u=t.getSelection())?void 0:u.toString()),d=i.type||"clipboard";if(!h)return  false;o.$selected_content=h,o.$copy_type=d;}return this.instance.capture(e,o),true}}}isBrowserSupported(){return I(null==o?void 0:o.querySelectorAll)}}Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return j(t)&&isFinite(t)&&Math.floor(t)===t});var fe="0123456789abcdef";class pe{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,e,r){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(r)||t<0||i<0||e<0||r<0||t>0xffffffffffff||i>4095||e>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/Math.pow(2,8),s[5]=t,s[6]=112|i>>>8,s[7]=i,s[8]=128|e>>>24,s[9]=e>>>16,s[10]=e>>>8,s[11]=e,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new pe(s)}toString(){for(var t="",i=0;i<this.bytes.length;i++)t=t+fe.charAt(this.bytes[i]>>>4)+fe.charAt(15&this.bytes[i]),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new pe(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var i=0;i<16;i++){var e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}}class ge{constructor(){this.N=0,this.U=0,this.H=new ye;}generate(){var t=this.generateOrAbort();if(C(t)){this.N=0;var i=this.generateOrAbort();if(C(i))throw new Error("Could not generate UUID after timestamp reset");return i}return t}generateOrAbort(){var t=Date.now();if(t>this.N)this.N=t,this.B();else {if(!(t+1e4>this.N))return;this.U++,this.U>4398046511103&&(this.N++,this.B());}return pe.fromFieldsV7(this.N,Math.trunc(this.U/Math.pow(2,30)),this.U&Math.pow(2,30)-1,this.H.nextUint32())}B(){this.U=1024*this.H.nextUint32()+(1023&this.H.nextUint32());}}var _e,me=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var i=0;i<t.length;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};t&&!C(t.crypto)&&crypto.getRandomValues&&(me=t=>crypto.getRandomValues(t));class ye{constructor(){this.q=new Uint32Array(8),this.W=1/0;}nextUint32(){return this.W>=this.q.length&&(me(this.q),this.W=0),this.q[this.W++]}}var be=()=>we().toString(),we=()=>(_e||(_e=new ge)).generate(),Se="";var xe=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ee(t,i){if(i){var e=function(t,i){if(void 0===i&&(i=o),Se)return Se;if(!i)return "";if(["localhost","127.0.0.1"].includes(t))return "";for(var e=t.split("."),r=Math.min(e.length,8),s="dmn_chk_"+be();!Se&&r--;){var n=e.slice(r).join("."),a=s+"=1;domain=."+n+";path=/";i.cookie=a+";max-age=3",i.cookie.includes(s)&&(i.cookie=a+";max-age=0",Se=n);}return Se}(t);if(!e){var r=(t=>{var i=t.match(xe);return i?i[0]:""})(t);r!==e&&$t.info("Warning: cookie subdomain discovery mismatch",r,e),e=r;}return e?"; domain=."+e:""}return ""}var $e={G:()=>!!o,V:function(t){$t.error("cookieStore error: "+t);},J:function(t){if(o){try{for(var i=t+"=",e=o.cookie.split(";").filter((t=>t.length)),r=0;r<e.length;r++){for(var s=e[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}},K:function(t){var i;try{i=JSON.parse($e.J(t))||{};}catch(t){}return i},Y:function(t,i,e,r,s){if(o)try{var n="",a="",l=Ee(o.location.hostname,r);if(e){var u=new Date;u.setTime(u.getTime()+24*e*60*60*1e3),n="; expires="+u.toUTCString();}s&&(a="; secure");var h=t+"="+encodeURIComponent(JSON.stringify(i))+n+"; SameSite=Lax; path=/"+l+a;return h.length>3686.4&&$t.warn("cookieStore warning: large cookie, len="+h.length),o.cookie=h,h}catch(t){return}},X:function(t,i){if(null!=o&&o.cookie)try{$e.Y(t,"",-1,i);}catch(t){return}}},ke=null,Pe={G:function(){if(!M(ke))return ke;var i=true;if(C(t))i=false;else try{var e="__mplssupport__";Pe.Y(e,"xyz"),'"xyz"'!==Pe.J(e)&&(i=false),Pe.X(e);}catch(t){i=false;}return i||$t.error("localStorage unsupported; falling back to cookie store"),ke=i,i},V:function(t){$t.error("localStorage error: "+t);},J:function(i){try{return null==t?void 0:t.localStorage.getItem(i)}catch(t){Pe.V(t);}return null},K:function(t){try{return JSON.parse(Pe.J(t))||{}}catch(t){}return null},Y:function(i,e){try{null==t||t.localStorage.setItem(i,JSON.stringify(e));}catch(t){Pe.V(t);}},X:function(i){try{null==t||t.localStorage.removeItem(i);}catch(t){Pe.V(t);}}},Ie=["distinct_id",ii,ei,_i,gi],Re=g({},Pe,{K:function(t){try{var i={};try{i=$e.K(t)||{};}catch(t){}var e=Ot(i,JSON.parse(Pe.J(t)||"{}"));return Pe.Y(t,e),e}catch(t){}return null},Y:function(t,i,e,r,s,n){try{Pe.Y(t,i,void 0,void 0,n);var o={};Ie.forEach((t=>{i[t]&&(o[t]=i[t]);})),Object.keys(o).length&&$e.Y(t,o,e,r,s,n);}catch(t){Pe.V(t);}},X:function(i,e){try{null==t||t.localStorage.removeItem(i),$e.X(i,e);}catch(t){Pe.V(t);}}}),Te={},Ce={G:function(){return  true},V:function(t){$t.error("memoryStorage error: "+t);},J:function(t){return Te[t]||null},K:function(t){return Te[t]||null},Y:function(t,i){Te[t]=i;},X:function(t){delete Te[t];}},Oe=null,Fe={G:function(){if(!M(Oe))return Oe;if(Oe=true,C(t))Oe=false;else try{var i="__support__";Fe.Y(i,"xyz"),'"xyz"'!==Fe.J(i)&&(Oe=false),Fe.X(i);}catch(t){Oe=false;}return Oe},V:function(t){$t.error("sessionStorage error: ",t);},J:function(i){try{return null==t?void 0:t.sessionStorage.getItem(i)}catch(t){Fe.V(t);}return null},K:function(t){try{return JSON.parse(Fe.J(t))||null}catch(t){}return null},Y:function(i,e){try{null==t||t.sessionStorage.setItem(i,JSON.stringify(e));}catch(t){Fe.V(t);}},X:function(i){try{null==t||t.sessionStorage.removeItem(i);}catch(t){Fe.V(t);}}},Me=function(t){return t[t.PENDING=-1]="PENDING",t[t.DENIED=0]="DENIED",t[t.GRANTED=1]="GRANTED",t}({});class Ae{constructor(t){this._instance=t;}get A(){return this._instance.config}get consent(){return this.Z()?Me.DENIED:this.tt}isOptedOut(){return "always"===this.A.cookieless_mode||(this.consent===Me.DENIED||this.consent===Me.PENDING&&(this.A.opt_out_capturing_by_default||"on_reject"===this.A.cookieless_mode))}isOptedIn(){return !this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Me.DENIED}optInOut(t){this.it.Y(this.et,t?1:0,this.A.cookie_expiration,this.A.cross_subdomain_cookie,this.A.secure_cookie);}reset(){this.it.X(this.et,this.A.cross_subdomain_cookie);}get et(){var{token:t,opt_out_capturing_cookie_prefix:i,consent_persistence_name:e}=this._instance.config;return e||(i?i+t:"__ph_opt_in_out_"+t)}get tt(){var t=this.it.J(this.et);return q(t)?Me.GRANTED:y(W,t)?Me.DENIED:Me.PENDING}get it(){if(!this.rt){var t=this.A.opt_out_capturing_persistence_type;this.rt="localStorage"===t?Pe:$e;var i="localStorage"===t?$e:Pe;i.J(this.et)&&(this.rt.J(this.et)||this.optInOut(q(i.J(this.et))),i.X(this.et,this.A.cross_subdomain_cookie));}return this.rt}Z(){return !!this.A.respect_dnt&&!!zt([null==n?void 0:n.doNotTrack,null==n?void 0:n.msDoNotTrack,v.doNotTrack],(t=>q(t)))}}var je=kt("[Dead Clicks]"),De=()=>true,Le=t=>{var i,e=!(null==(i=t.instance.persistence)||!i.get_property(Qt)),r=t.instance.config.capture_dead_clicks;return D(r)?r:e};class Ne{get lazyLoadedDeadClicksAutocapture(){return this.st}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabled();}onRemoteConfig(t){this.instance.persistence&&this.instance.persistence.register({[Qt]:null==t?void 0:t.captureDeadClicks}),this.startIfEnabled();}startIfEnabled(){this.isEnabled(this)&&this.nt((()=>{this.ot();}));}nt(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.initDeadClicksAutocapture&&t(),null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?je.error("failed to load script",i):t();}));}ot(){var t;if(o){if(!this.st&&null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=R(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};i.__onCapture=this.onCapture,this.st=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.st.start(o),je.info("starting...");}}else je.error("`document` not found. Cannot start.");}stop(){this.st&&(this.st.stop(),this.st=void 0,je.info("stopping..."));}}var Ue=kt("[ExceptionAutocapture]");class ze{constructor(i){var e,r,s;this.lt=()=>{var i;if(t&&this.isEnabled&&null!=(i=v.__PosthogExtensions__)&&i.errorWrappingFunctions){var e=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ut&&this.A.capture_unhandled_errors&&(this.ut=e(this.captureException.bind(this))),!this.ht&&this.A.capture_unhandled_rejections&&(this.ht=r(this.captureException.bind(this))),!this.dt&&this.A.capture_console_errors&&(this.dt=s(this.captureException.bind(this)));}catch(t){Ue.error("failed to start",t),this.vt();}}},this._instance=i,this.ct=!(null==(e=this._instance.persistence)||!e.props[Jt]),this.A=this.ft(),this.gt=new V({refillRate:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==r?r:1,bucketSize:null!==(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10,refillInterval:1e4,P:Ue}),this.startIfEnabled();}ft(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:false,capture_unhandled_rejections:false,capture_console_errors:false};return R(t)?i=g({},i,t):(C(t)?this.ct:t)&&(i=g({},i,{capture_unhandled_errors:true,capture_unhandled_rejections:true})),i}get isEnabled(){return this.A.capture_console_errors||this.A.capture_unhandled_errors||this.A.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(Ue.info("enabled"),this.nt(this.lt));}nt(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.errorWrappingFunctions&&t(),null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return Ue.error("failed to load script",i);t();}));}vt(){var t,i,e;null==(t=this.ut)||t.call(this),this.ut=void 0,null==(i=this.ht)||i.call(this),this.ht=void 0,null==(e=this.dt)||e.call(this),this.dt=void 0;}onRemoteConfig(t){var i=t.autocaptureExceptions;this.ct=!!i||false,this.A=this.ft(),this._instance.persistence&&this._instance.persistence.register({[Jt]:this.ct}),this.startIfEnabled();}captureException(t){var i,e,r=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";this.gt.consumeRateLimit(r)?Ue.info("Skipping exception capture because of client rate limiting.",{exception:r}):this._instance.exceptions.sendExceptionEvent(t);}}function He(t,i,e){try{if(!(i in t))return ()=>{};var r=t[i],s=e(r);return I(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:false,value:true}})),t[i]=s,()=>{t[i]=r;}}catch(t){return ()=>{}}}class Be{constructor(i){var e;this._instance=i,this._t=(null==t||null==(e=t.location)?void 0:e.pathname)||"";}get isEnabled(){return "history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&($t.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges());}stop(){this.yt&&this.yt(),this.yt=void 0,$t.info("History API monitoring stopped");}monitorHistoryChanges(){var i,e;if(t&&t.history){var r=this;null!=(i=t.history.pushState)&&i.__posthog_wrapped__||He(t.history,"pushState",(t=>function(i,e,s){t.call(this,i,e,s),r.bt("pushState");})),null!=(e=t.history.replaceState)&&e.__posthog_wrapped__||He(t.history,"replaceState",(t=>function(i,e,s){t.call(this,i,e,s),r.bt("replaceState");})),this.wt();}}bt(i){try{var e,r=null==t||null==(e=t.location)?void 0:e.pathname;if(!r)return;r!==this._t&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:i}),this._t=r;}catch(t){$t.error("Error capturing "+i+" pageview",t);}}wt(){if(!this.yt){var i=()=>{this.bt("popstate");};Ht(t,"popstate",i),this.yt=()=>{t&&t.removeEventListener("popstate",i);};}}}var qe=kt("[SegmentIntegration]");function We(t,i){var e=t.config.segment;if(!e)return i();!function(t,i){var e=t.config.segment;if(!e)return i();var r=e=>{var r=()=>e.anonymousId()||be();t.config.get_device_id=r,e.id()&&(t.register({distinct_id:e.id(),$device_id:r()}),t.persistence.set_property(di,"identified")),i();},s=e.user();"then"in s&&I(s.then)?s.then((t=>r(t))):r(s);}(t,(()=>{e.register((t=>{Promise&&Promise.resolve||qe.warn("This browser does not have Promise support, and can not use the segment integration");var i=(i,e)=>{if(!e)return i;i.event.userId||i.event.anonymousId===t.get_distinct_id()||(qe.info("No userId set, resetting PostHog"),t.reset()),i.event.userId&&i.event.userId!==t.get_distinct_id()&&(qe.info("UserId set, identifying with PostHog"),t.identify(i.event.userId));var r=t.calculateEventProperties(e,i.event.properties);return i.event.properties=Object.assign({},r,i.event.properties),i};return {name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>true,load:()=>Promise.resolve(),track:t=>i(t,t.event.event),page:t=>i(t,"$pageview"),identify:t=>i(t,"$identify"),screen:t=>i(t,"$screen")}})(t)).then((()=>{i();}));}));}var Ge="posthog-js";function Ve(t,i){var{organization:e,projectId:r,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:o=true}=void 0===i?{}:i;return i=>{var a,l,u,h,d;if(!("*"===n||n.includes(i.level))||!t.__loaded)return i;i.tags||(i.tags={});var v=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());i.tags["PostHog Person URL"]=v,t.sessionRecordingStarted()&&(i.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:true}));var c=(null==(a=i.exception)?void 0:a.values)||[],f=c.map((t=>g({},t,{stacktrace:t.stacktrace?g({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map((t=>g({},t,{platform:"web:javascript"})))}):void 0}))),p={$exception_message:(null==(l=c[0])?void 0:l.value)||i.message,$exception_type:null==(u=c[0])?void 0:u.type,$exception_personURL:v,$exception_level:i.level,$exception_list:f,$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:(null==(h=c[0])?void 0:h.value)||i.message,$sentry_exception_type:null==(d=c[0])?void 0:d.type,$sentry_tags:i.tags};return e&&r&&(p.$sentry_url=(s||"https://sentry.io/organizations/")+e+"/issues/?project="+r+"&query="+i.event_id),o&&t.exceptions.sendExceptionEvent(p),i}}class Je{constructor(t,i,e,r,s,n){this.name=Ge,this.setupOnce=function(o){o(Ve(t,{organization:i,projectId:e,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}));};}}var Ke=null!=t&&t.location?ae(t.location.hash,"__posthog")||ae(location.hash,"state"):null,Ye="_postHogToolbarParams",Xe=kt("[Toolbar]"),Qe=function(t){return t[t.UNINITIALIZED=0]="UNINITIALIZED",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED",t}(Qe||{});class Ze{constructor(t){this.instance=t;}St(t){v.ph_toolbar_state=t;}xt(){var t;return null!==(t=v.ph_toolbar_state)&&void 0!==t?t:Qe.UNINITIALIZED}maybeLoadToolbar(i,e,r){if(void 0===i&&(i=void 0),void 0===e&&(e=void 0),void 0===r&&(r=void 0),!t||!o)return  false;i=null!=i?i:t.location,r=null!=r?r:t.history;try{if(!e){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test");}catch(t){return  false}e=null==t?void 0:t.localStorage;}var s,n=Ke||ae(i.hash,"__posthog")||ae(i.hash,"state"),a=n?At((()=>JSON.parse(atob(decodeURIComponent(n)))))||At((()=>JSON.parse(decodeURIComponent(n)))):null;return a&&"ph_authorize"===a.action?((s=a).source="url",s&&Object.keys(s).length>0&&(a.desiredHash?i.hash=a.desiredHash:r?r.replaceState(r.state,"",i.pathname+i.search):i.hash="")):((s=JSON.parse(e.getItem(Ye)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),true)}catch(t){return  false}}Et(t){var i=v.ph_load_toolbar||v.ph_load_editor;!A(i)&&I(i)?i(t,this.instance):Xe.warn("No toolbar load function found");}loadToolbar(i){var e=!(null==o||!o.getElementById(mi));if(!t||e)return  false;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=g({token:this.instance.config.token},i,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:false}:{});if(t.localStorage.setItem(Ye,JSON.stringify(g({},s,{source:void 0}))),this.xt()===Qe.LOADED)this.Et(s);else if(this.xt()===Qe.UNINITIALIZED){var n;this.St(Qe.LOADING),null==(n=v.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return Xe.error("[Toolbar] Failed to load",t),void this.St(Qe.UNINITIALIZED);this.St(Qe.LOADED),this.Et(s);})),Ht(t,"turbolinks:load",(()=>{this.St(Qe.UNINITIALIZED),this.loadToolbar(s);}));}return  true}$t(t){return this.loadToolbar(t)}maybeLoadEditor(t,i,e){return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),this.maybeLoadToolbar(t,i,e)}}var tr=kt("[TracingHeaders]");class ir{constructor(t){this.kt=void 0,this.Pt=void 0,this.lt=()=>{var t,i;C(this.kt)&&(null==