import{n as e}from"./rolldown-runtime-Czos8NxU.js";import{Ax as t,Dx as n,Mx as r,Nx as i,Ox as a,kx as o}from"./app-initial~app-main~new-thread-panel-page-BZHGOlMi.js";import{t as s,u as c}from"./esm-NOev0D3e.js";import{f as l,p as u}from"./load-script-BifiZc4M.js";import{c as d,s as f}from"./middleware-BiS8oulZ.js";function p(){return u()?window.navigator.onLine:!0}function m(){return!p()}var h=e((()=>{l()})),g=e((()=>{s()}));function _(e){var t=C.getItem(e);return(t?JSON.parse(t):[]).map(function(e){return new f(e.event,e.id)})}function v(e,t){var i=_(e),a=r(r([],t,!0),i,!0).reduce(function(e,t){var r;return n(n({},e),(r={},r[t.id]=t,r))},{});C.setItem(e,JSON.stringify(Object.values(a)))}function y(e){var t=C.getItem(e);return t?JSON.parse(t):{}}function b(e,t){var r=y(e);C.setItem(e,JSON.stringify(n(n({},r),t)))}function x(e){C.removeItem(e)}function S(e,t,n){n===void 0&&(n=0);var r=50,i=`persisted-queue:v1:${e}:lock`,a=function(e){return new Date().getTime()>e},o=C.getItem(i),s=o?JSON.parse(o):null,c=s===null||a(s);if(c){C.setItem(i,JSON.stringify(w()+r)),t(),C.removeItem(i);return}!c&&n<3?setTimeout(function(){S(e,t,n+1)},r):console.error(`Unable to retrieve lock`)}var C,w,T,E=e((()=>{i(),g(),d(),l(),C={getItem:function(){},setItem:function(){},removeItem:function(){}};try{C=u()&&window.localStorage?window.localStorage:C}catch(e){console.warn(`Unable to access localStorage`,e)}w=function(){return new Date().getTime()},T=function(e){o(t,e);function t(t,i){var a=e.call(this,t,[])||this,o=`persisted-queue:v1:${i}:items`,s=`persisted-queue:v1:${i}:seen`,c=[],l={};return S(i,function(){try{c=_(o),l=y(s),x(o),x(s),a.queue=r(r([],c,!0),a.queue,!0),a.seen=n(n({},l),a.seen)}catch(e){console.error(e)}}),window.addEventListener(`pagehide`,function(){if(a.todo>0){var e=r(r([],a.queue,!0),a.future,!0);try{S(i,function(){v(o,e),b(s,a.seen)})}catch(e){console.error(e)}}}),a}return t}(c)})),D,O=e((()=>{i(),D=function(e,n){return a(void 0,void 0,void 0,function(){var r;return t(this,function(i){return r=function(i){return a(void 0,void 0,void 0,function(){var a;return t(this,function(t){switch(t.label){case 0:return e(i)?(a=r,[4,n()]):[3,2];case 1:return[2,a.apply(void 0,[t.sent()])];case 2:return[2]}})})},[2,r(void 0)]})})}}));function k(e,t){var r=Object.entries(t.integrations??{}).reduce(function(e,t){var r,i,a=t[0],o=t[1];return typeof o==`object`?n(n({},e),(r={},r[a]=o,r)):n(n({},e),(i={},i[a]={},i))},{});return Object.entries(e.integrations).reduce(function(e,t){var i,a=t[0],o=t[1];return n(n({},e),(i={},i[a]=n(n({},o),r[a]),i))},{})}var A=e((()=>{i()}));function j(e,t){var n=t.methodName,r=t.integrationName,i=t.type,a=t.didError,o=a===void 0?!1:a;e.stats.increment(`analytics_js.integration.invoke${o?`.error`:``}`,1,[`method:${n}`,`integration_name:${r}`,`type:${i}`])}var M=e((()=>{}));export{O as a,E as c,m as d,p as f,k as i,g as l,j as n,D as o,A as r,T as s,M as t,h as u};
//# sourceMappingURL=metric-helpers-JPhPDVoP.js.map