mcard-studio 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/astro.config.mjs +6 -1
  2. package/bin/mcard-studio.mjs +1 -1
  3. package/dist/client/_astro/{ChartAnalyticsViewlet.Cevj0EOs.js → ChartAnalyticsViewlet.jrwIemvb.js} +1 -1
  4. package/dist/client/_astro/ClmPcardViewlet.C-fU7oZf.js +3 -0
  5. package/dist/client/_astro/D3GraphViewlet.BCZl0b2U.js +2 -0
  6. package/dist/client/_astro/DockviewSpatialWorkbench.B_I1GJHw.js +12 -0
  7. package/dist/client/_astro/{DocumentViewlets.Dm_GL3AL.js → DocumentViewlets.B53IqmpY.js} +1 -1
  8. package/dist/client/_astro/ExcalidrawWhiteboardViewlet.CFpPYSdn.js +1 -0
  9. package/dist/client/_astro/{FaroVCardSpanInstrumenter.BIk2NhJY.js → FaroVCardSpanInstrumenter.un8kDMWv.js} +1 -1
  10. package/dist/client/_astro/{FontSpecimenViewlet.CpONhJh0.js → FontSpecimenViewlet.D7Aw2xBZ.js} +1 -1
  11. package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.VDRYJCM-.js +1 -0
  12. package/dist/client/_astro/{ImageViewlet.CHeNvX6L.js → ImageViewlet.D4FN87n_.js} +1 -1
  13. package/dist/client/_astro/{KatexFormulaViewlet.Cy_InWOK.js → KatexFormulaViewlet.CzhdIOw8.js} +1 -1
  14. package/dist/client/_astro/KoishiChatViewlet.5mepQvLX.js +16 -0
  15. package/dist/client/_astro/MCardLibraryHarness.DE8KeghO.js +2 -0
  16. package/dist/client/_astro/{MarkdownViewlet.qoPlM-TZ.js → MarkdownViewlet.CRuuXXmF.js} +1 -1
  17. package/dist/client/_astro/{MermaidDiagramViewlet.RnwDfQl6.js → MermaidDiagramViewlet.eW6sk-rF.js} +1 -1
  18. package/dist/client/_astro/PCardRendererBridge.oxVKc0gN.js +1 -0
  19. package/dist/client/_astro/RendererPCardRegistry.CWjYZs2H.js +1 -0
  20. package/dist/client/_astro/{SchemaYamlViewlet.D6HVdmrq.js → SchemaYamlViewlet.ZJBvxItR.js} +1 -1
  21. package/dist/client/_astro/{ShellContainer.astro_astro_type_script_index_0_lang.2oi8fhQo.js → ShellContainer.astro_astro_type_script_index_0_lang.j_ELcN5d.js} +1 -1
  22. package/dist/client/_astro/{Spatial3dViewlet.CCYBSSib.js → Spatial3dViewlet.DnVMBENJ.js} +1 -1
  23. package/dist/client/_astro/StudioWorkbench.Blo5oSIw.js +7 -0
  24. package/dist/client/_astro/{SvgViewlet.BxlWQ-JX.js → SvgViewlet.BCje7Qqb.js} +1 -1
  25. package/dist/client/_astro/{TerminalView.DWZR-hUa.js → TerminalView.C_Ksz6lT.js} +4 -4
  26. package/dist/client/_astro/{ThemeSettingsViewlet.Cb1r8fWw.js → ThemeSettingsViewlet.DJpjQQ0Z.js} +1 -1
  27. package/dist/client/_astro/{TikzDiagramViewlet.CqY7VTeP.js → TikzDiagramViewlet.CXb1A8nf.js} +1 -1
  28. package/dist/client/_astro/{VideoPlayerViewlet.DoSYmmoQ.js → VideoPlayerViewlet.CmECt7yT.js} +1 -1
  29. package/dist/client/_astro/{WebappZenViewlet.CQW50OhX.js → WebappZenViewlet.whCmGVHR.js} +1 -1
  30. package/dist/client/_astro/{WelcomeViewport.LwKTA6h7.js → WelcomeViewport.BiYwLh6l.js} +1 -1
  31. package/dist/client/_astro/__vite-browser-external.CQZnr-r3.js +1 -0
  32. package/dist/client/_astro/{agentIdentityCredentialService.BtKVsl2C.js → agentIdentityCredentialService.UzMMwBwv.js} +5 -5
  33. package/dist/client/_astro/cardTypeDetector.Ci4APwhX.js +1 -0
  34. package/dist/client/_astro/disposable.Dsb0sbRP.js +1 -0
  35. package/dist/client/_astro/{markdownService.D-tM2RYx.js → markdownService.BgWjyJ57.js} +1 -1
  36. package/dist/client/_astro/{mcardStore.BiAvqM-D.js → mcardStore.CT-ollfl.js} +2 -2
  37. package/dist/client/_astro/mcardVfs.2UOw9Z-r.js +3 -0
  38. package/dist/client/_astro/polyfills._3wYPjZf.js +1 -0
  39. package/dist/client/_astro/rendererEventBus.DMH9afq9.js +1 -0
  40. package/dist/client/_astro/themeStore.CEt0e54l.js +1 -0
  41. package/dist/client/_astro/{tikzCompiler.DFojjdxR.js → tikzCompiler.fe3qomFY.js} +1 -1
  42. package/dist/client/_astro/{useMCardHydration.Co47OH3D.js → useMCardHydration.7Z-HfBh5.js} +1 -1
  43. package/dist/client/_astro/vendor-ai.D6NcJ6lu.js +69 -0
  44. package/dist/client/_astro/vendor-clm-kernel.Bvk3XHk2.js +116 -0
  45. package/dist/client/_astro/vfsHandles.IX_wTpw_.js +1 -0
  46. package/dist/client/_astro/vfsPersistence.BuhXYeSb.js +1 -0
  47. package/dist/client/_astro/vfsTransactions.C_IQQg0s.js +1 -0
  48. package/dist/client/_astro/{workspaceStore.CXakha4Y.js → workspaceStore.CD0kAVAl.js} +1 -1
  49. package/dist/client/js/buffer-polyfill.js +14 -0
  50. package/dist/server/chunks/{StudioLayout_D163irJ0.mjs → StudioLayout_B5ZnlqjF.mjs} +2 -2
  51. package/dist/server/chunks/{_.._ZXsz792-.mjs → _.._5gPhVOLM.mjs} +1 -1
  52. package/dist/server/chunks/{mcard-library_DvPPUs9_.mjs → mcard-library_7Wzoihkm.mjs} +1 -1
  53. package/dist/server/chunks/{ws-server-init_CkcgcI5V.mjs → ws-server-init_DUjuR2-o.mjs} +3 -3
  54. package/dist/server/entry.mjs +8 -4
  55. package/dist/server/entry2.mjs +3 -3
  56. package/dist/server/virtual_astro_middleware.mjs +1 -1
  57. package/package.json +1 -1
  58. package/public/js/buffer-polyfill.js +14 -0
  59. package/src/layouts/StudioLayout.astro +1 -0
  60. package/src/pages/index.astro +75 -0
  61. package/src/services/inBrowserLlm/engines/litertEngine.ts +1 -1
  62. package/dist/client/_astro/ClmPcardViewlet.DW5Yft0E.js +0 -3
  63. package/dist/client/_astro/D3GraphViewlet.DAjPz1DP.js +0 -2
  64. package/dist/client/_astro/DockviewSpatialWorkbench.DyQjSoHd.js +0 -12
  65. package/dist/client/_astro/ExcalidrawWhiteboardViewlet.DrlW7B6G.js +0 -1
  66. package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.DGXU-3Lu.js +0 -1
  67. package/dist/client/_astro/KoishiChatViewlet.B0eDEMnT.js +0 -16
  68. package/dist/client/_astro/MCardLibraryHarness.CUJLJFBt.js +0 -2
  69. package/dist/client/_astro/PCardRendererBridge.BnyaE05I.js +0 -1
  70. package/dist/client/_astro/RendererPCardRegistry.CLr4j1Ub.js +0 -1
  71. package/dist/client/_astro/StudioWorkbench.CF0SOYwy.js +0 -7
  72. package/dist/client/_astro/cardTypeDetector.C9kGObMh.js +0 -1
  73. package/dist/client/_astro/disposable.66apX1Q2.js +0 -1
  74. package/dist/client/_astro/empty.DOwCrGXH.js +0 -1
  75. package/dist/client/_astro/mcardVfs.Bj-RA0p7.js +0 -2
  76. package/dist/client/_astro/path.CR60mj9W.js +0 -1
  77. package/dist/client/_astro/polyfills.DcBkS56X.js +0 -1
  78. package/dist/client/_astro/rendererEventBus.CyFnSRLk.js +0 -1
  79. package/dist/client/_astro/themeStore.zUMFLo3Q.js +0 -1
  80. package/dist/client/_astro/vendor-ai.CZe7UVVK.js +0 -69
  81. package/dist/client/_astro/vfsHandles.B-nczBRy.js +0 -1
  82. package/dist/client/_astro/vfsPersistence.D6zRzVML.js +0 -1
  83. package/dist/client/_astro/vfsTransactions.04mkEHxD.js +0 -1
@@ -1,4 +1,4 @@
1
- import{t as e}from"./rolldown-runtime.Dd_uD5pT.js";import{_ as t,g as n}from"./themeStore.zUMFLo3Q.js";import"./workspaceStore.CXakha4Y.js";import{AgentDid as r,MCard as i}from"clm-kernel";var a=5,o=6,s=10,c=(e,t,n,r)=>(e.events=e.events||{},e.events[n+s]||(e.events[n+s]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);~i&&(r.splice(i,1),r.length||(e.events[n+s](),delete e.events[n+s]))}),l=1e3,u=(e,t)=>c(e,n=>{let r=t(n);r&&e.events[o].push(r)},a,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[o]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[o])t();e.events[o]=[]}},l)},()=>{e.listen=n,e.off=r}}),d=(e,r,i)=>{Array.isArray(e)||(e=[e]);let a,o,s=()=>{if(o===t.epoch)return;o=t.epoch;let n=e.map(e=>e.get());if(!a?.every((t,r)=>e[r].eq(t,n[r]))){a=n;let e=r(...n);e&&e.then&&e.t?e.then(e=>{a===n&&c.set(e)}):(c.set(e),o=t.epoch)}},c=n(),l=c.get;c.get=()=>(s(),l());let d,f=i?()=>{clearTimeout(d),d=setTimeout(s)}:s;return u(c,()=>{let t=e.map(e=>e.listen(f));return s(),()=>{for(let e of t)e()}}),c},f=(e,t)=>d(e,t),p=(e={})=>{let t=n(e);return t.eqKey=Object.is,t.setKey=function(e,n){let r=t.value;n===void 0&&e in t.value?(t.value={...t.value},delete t.value[e],t.notify(r,e)):t.eqKey(t.value[e],n,e)||(t.value={...t.value,[e]:n},t.notify(r,e))},t},m=`browser`,h=`com.grafana.faro.session`,g=144e5,_=9e5,v=1e3,y={enabled:!0,persistent:!1,maxSessionPersistenceTime:_},b=`unknown`;function x(e){return Math.min(1,Math.max(0,e))}function S(e,t){return typeof e===t}function C(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function ee(e,t){try{return e instanceof t}catch{return!1}}var te=(e=>S(e,`null`)),ne=(e=>S(e,`string`)),re=(e=>S(e,`number`)&&!isNaN(e)||S(e,`bigint`)),ie=(e=>S(e,`boolean`)),w=(e=>!te(e)&&S(e,`object`)),T=(e=>S(e,`function`)),E=(e=>C(e,`Array`)),ae=(e=>!w(e)&&!T(e)),oe=typeof Event<`u`,se=(e=>oe&&ee(e,Event)),ce=typeof Error<`u`,le=(e=>ce&&ee(e,Error)),ue=(e=>C(e,`ErrorEvent`)),de=(e=>C(e,`DOMError`)),fe=(e=>C(e,`DOMException`));function D(e){return e==null?!0:E(e)||ne(e)?e.length===0:w(e)?Object.keys(e).length===0:!1}function O(e,t){if(e===t)return!0;if(S(e,`number`)&&isNaN(e))return S(t,`number`)&&isNaN(t);let n=E(e),r=E(t);if(n!==r)return!1;if(n&&r){let n=e.length;if(n!==t.length)return!1;for(let r=n;r--!==0;)if(!O(e[r],t[r]))return!1;return!0}let i=w(e),a=w(t);if(i!==a)return!1;if(e&&t&&i&&a){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!O(e[r],t[r]))return!1;return!0}return!1}function k(){return Date.now()}function pe(){return typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now()}function me(){return new Date().toISOString()}function he(e){return new Date(e).toISOString()}var ge=function(e){return e.TRACE=`trace`,e.DEBUG=`debug`,e.INFO=`info`,e.LOG=`log`,e.WARN=`warn`,e.ERROR=`error`,e}({}),_e=[`trace`,`debug`,`info`,`log`,`warn`,`error`];function A(){}function ve(e){let{size:t,concurrency:n}=e,r=[],i=0,a=()=>{if(i<n&&r.length){let{producer:e,resolve:t,reject:n}=r.shift();i++,e().then(e=>{i--,a(),t(e)},e=>{i--,a(),n(e)})}};return{add:e=>{if(r.length+i>=t)throw Error(`Task buffer full`);return new Promise((t,n)=>{r.push({producer:e,resolve:t,reject:n}),a()})}}}var ye=`abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789`;function be(e=10){let t=new Uint32Array(e),n=typeof globalThis<`u`?globalThis.crypto:void 0;if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*4294967296);let r=``;for(let n=0;n<e;n++)r+=ye[t[n]%59];return r}var j=typeof globalThis<`u`||typeof globalThis<`u`?globalThis:typeof self<`u`?self:void 0;function xe(){let e=new WeakSet;return function(t,n){if(w(n)&&n!==null){if(e.has(n))return null;e.add(n)}return n}}function M(e={}){return JSON.stringify(e??{},xe())}function Se(e={}){let t={};for(let[n,r]of Object.entries(e))t[n]=w(r)&&r!==null?M(r):String(r);return t}var N=class e{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter(t=>t!==e)}notify(e){this.subscribers.forEach(t=>t(e))}first(){let t=new e,n=e=>{t.notify(e),r.unsubscribe()},r=this.subscribe(n),i=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,i,n)}takeWhile(t){let n=new e,r=e=>{t(e)?n.notify(e):n.unsubscribe(r)};this.subscribe(r);let i=n.unsubscribe.bind(n);return this.withUnsubscribeOverride(n,i,r)}filter(t){let n=new e,r=e=>{t(e)&&n.notify(e)};this.subscribe(r);let i=n.unsubscribe.bind(n);return this.withUnsubscribeOverride(n,i,r)}merge(...t){let n=new e,r=[];t.forEach(e=>{let t=e.subscribe(e=>{n.notify(e)});r.push(t)});let i=n.unsubscribeAll.bind(n);return n.unsubscribe=()=>{r.forEach(e=>e.unsubscribe()),i()},n}withUnsubscribeOverride(e,t,n){return e.unsubscribe=e=>{t(e),this.unsubscribe(n)},e}unsubscribeAll(){this.subscribers=[]}},Ce=new WeakSet;function P(e){return Ce.add(e),e}function we(e){return Ce.has(e)}function Te(e,t){if(e.capture)return P(e.capture(t));let n=P(e.value);return t?.(),n}var F=`2.12.1`,I={exception:`exceptions`,log:`logs`,measurement:`measurements`,trace:`traces`,event:`events`},Ee={debug:A,error:A,info:A,prefix:`Faro`,warn:A};function L(e){"@babel/helpers - typeof";return L=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},L(e)}function De(e,t){if(L(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(L(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Oe(e){var t=De(e,`string`);return L(t)==`symbol`?t:t+``}function ke(e,t,n){return(t=Oe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ae(Object(n),!0).forEach(function(t){ke(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ae(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var je=R({},console);function Me(e=je,t=1){let n=Ee;return t>0&&(n.error=t>=1?function(...t){e.error(`${n.prefix}\n`,...t)}:A,n.warn=t>=2?function(...t){e.warn(`${n.prefix}\n`,...t)}:A,n.info=t>=3?function(...t){e.info(`${n.prefix}\n`,...t)}:A,n.debug=t>=4?function(...t){e.debug(`${n.prefix}\n`,...t)}:A),n}var Ne=class{constructor(){this.unpatchedConsole=je,this.internalLogger=Ee,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}},Pe=class extends Ne{isBatched(){return!1}getIgnoreUrls(){return[]}};function Fe(e,t){var n;if(t===void 0)return e;if(e===void 0)return{resourceSpans:t};let r=e.resourceSpans?.[0];if(r===void 0)return e;let i=r?.scopeSpans||[],a=(t==null||(n=t[0])==null?void 0:n.scopeSpans)||[];return R(R({},e),{},{resourceSpans:[R(R({},r),{},{scopeSpans:[...i,...a]})]})}function Ie(e){let t={meta:{}};return e[0]!==void 0&&(t.meta=e[0].meta),e.forEach(e=>{switch(e.type){case`log`:case`event`:case`exception`:case`measurement`:{let n=I[e.type],r=t[n];t=R(R({},t),{},{[n]:r===void 0?[e.payload]:[...r,e.payload]});break}case`trace`:t=R(R({},t),{},{traces:Fe(t.traces,e.payload.resourceSpans)})}}),t}var Le=`user_action_start`,Re={Normal:`normal`,Critical:`critical`},ze=`faro.user.action`,z=function(e){return e[e.Started=0]=`Started`,e[e.Halted=1]=`Halted`,e[e.Cancelled=2]=`Cancelled`,e[e.Ended=3]=`Ended`,e}({}),Be=class{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(T(e))for(let t of this.buffer)e(t);this.buffer.length=0}size(){return this.buffer.length}},Ve=class extends N{constructor({name:e,parentId:t,trigger:n,transports:r,attributes:i,trackUserActionsExcludeItem:a,importance:o=Re.Normal,pushEvent:s}){super(),this.name=e,this.attributes=i,this.id=be(),this.trigger=n,this.parentId=t??this.id,this.trackUserActionsExcludeItem=a,this.importance=o,this._pushEvent=s,this._itemBuffer=new Be,this._transports=r,this._state=0,this._start()}addItem(e){return this._state===0&&(this._itemBuffer.addItem(e),!0)}_start(){this._state=0,this._state===0&&(this.startTime=k(),this._startTimeMono=pe())}halt(){this._state===0&&(this._state=1,this.notify(this._state))}cancel(){this._state===0&&this._itemBuffer.flushBuffer(e=>{this._transports.execute(e)}),this._state=2,this.notify(this._state)}end(){if(this._state===2)return;let e=k(),t=pe()-this._startTimeMono;this._state=3,this._itemBuffer.flushBuffer(e=>{if(He(e,this.trackUserActionsExcludeItem)){this._transports.execute(e);return}let t=R(R({},e),{},{payload:R(R({},e.payload),{},{action:{parentId:this.id,name:this.name}})});this._transports.execute(t)}),this._state=3,this.notify(this._state),this._pushEvent(ze,R({userActionName:this.name,userActionStartTime:this.startTime.toString(),userActionEndTime:e.toString(),userActionDuration:t.toString(),userActionTrigger:this.trigger,userActionImportance:this.importance},Se(this.attributes)),void 0,{timestampOverwriteMs:this.startTime,customPayloadTransformer:e=>(e.action={id:this.id,name:this.name},e)})}getState(){return this._state}};function He(e,t){return t?.(e)||e.type===`measurement`&&e.payload.type===`web-vitals`}var Ue=new N;function We({transports:e,internalLogger:t,config:n,pushEvent:r}){let i=n.userActionsInstrumentation?.excludeItem,a,o=(n,o,c)=>{if(s()===void 0){let t=new Ve({name:n,transports:e,attributes:o,trigger:c?.triggerName||`faroApiCall`,importance:c?.importance||Re.Normal,trackUserActionsExcludeItem:i,pushEvent:r});return t.filter(e=>[3,2].includes(e)).first().subscribe(()=>{a=void 0}),Ue.notify({type:Le,userAction:t,initialActivityTimeout:c?.initialActivityTimeout}),a=t,a}t.error(`Attempted to create a new user action while one is already running. This is not possible.`)},s=()=>a;return{startUserAction:o,getActiveUserAction:s}}function Ge(e,t){return!e||e?.getState()!==0?!1:(e.addItem(t),!0)}var Ke=`Error`,qe=e=>e.map(e=>w(e)?M(e):String(e)).join(` `),Je=e=>e.map(e=>{try{return String(e)}catch{return``}}).join(` `),B=class extends Ne{constructor(...e){super(...e),this.api={},this.transports={}}},Ye=`_faroInternal`;function Xe(e){e.config.isolate?e.internalLogger.debug(`Skipping registering internal Faro instance on global object`):(e.internalLogger.debug(`Registering internal Faro instance on global object`),Object.defineProperty(j,Ye,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function Ze(){return Ye in j}function Qe(){return{pushLog:()=>{},pushError:()=>{},changeStacktraceParser:()=>{},getStacktraceParser:()=>void 0,pushMeasurement:()=>{},pushTraces:()=>{},getOTEL:()=>void 0,getTraceContext:()=>void 0,initOTEL:()=>{},isOTELInitialized:()=>!1,setUser:()=>{},resetUser:()=>{},setSession:()=>{},resetSession:()=>{},getSession:()=>void 0,setView:()=>{},getView:()=>void 0,setPage:()=>{},getPage:()=>void 0,pushEvent:()=>{},startUserAction:()=>void 0,getActiveUserAction:()=>void 0}}function $e(e){if(e.config.preventGlobalExposure)e.internalLogger.debug(`Skipping registering public Faro instance in the global scope`);else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in j){e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);return}Object.defineProperty(j,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}var V={api:Qe()};function et(e,t,n,r,i,a,o){return t.debug(`Initializing Faro`),V={api:a,config:n,instrumentations:o,internalLogger:t,metas:r,pause:i.pause,transports:i,unpatchedConsole:e,unpause:i.unpause},Xe(V),$e(V),V}function tt(e,t,n){let r=[],i=[],a=[],o,s=0,c=0,l=()=>r.reduce((e,t)=>Object.assign(e,T(t)?t():t),{}),u=()=>{if(i.length){let e=l();i.forEach(t=>t(e))}};return{add:(...e)=>{t.debug(`Adding metas
1
+ import{t as e}from"./rolldown-runtime.Dd_uD5pT.js";import{F as t,M as n}from"./vendor-clm-kernel.Bvk3XHk2.js";import{_ as r,g as i}from"./themeStore.CEt0e54l.js";import"./workspaceStore.CD0kAVAl.js";var a=5,o=6,s=10,c=(e,t,n,r)=>(e.events=e.events||{},e.events[n+s]||(e.events[n+s]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);~i&&(r.splice(i,1),r.length||(e.events[n+s](),delete e.events[n+s]))}),l=1e3,u=(e,t)=>c(e,n=>{let r=t(n);r&&e.events[o].push(r)},a,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[o]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[o])t();e.events[o]=[]}},l)},()=>{e.listen=n,e.off=r}}),d=(e,t,n)=>{Array.isArray(e)||(e=[e]);let a,o,s=()=>{if(o===r.epoch)return;o=r.epoch;let n=e.map(e=>e.get());if(!a?.every((t,r)=>e[r].eq(t,n[r]))){a=n;let e=t(...n);e&&e.then&&e.t?e.then(e=>{a===n&&c.set(e)}):(c.set(e),o=r.epoch)}},c=i(),l=c.get;c.get=()=>(s(),l());let d,f=n?()=>{clearTimeout(d),d=setTimeout(s)}:s;return u(c,()=>{let t=e.map(e=>e.listen(f));return s(),()=>{for(let e of t)e()}}),c},f=(e,t)=>d(e,t),p=(e={})=>{let t=i(e);return t.eqKey=Object.is,t.setKey=function(e,n){let r=t.value;n===void 0&&e in t.value?(t.value={...t.value},delete t.value[e],t.notify(r,e)):t.eqKey(t.value[e],n,e)||(t.value={...t.value,[e]:n},t.notify(r,e))},t},m=`browser`,h=`com.grafana.faro.session`,g=144e5,_=9e5,v=1e3,y={enabled:!0,persistent:!1,maxSessionPersistenceTime:_},b=`unknown`;function x(e){return Math.min(1,Math.max(0,e))}function S(e,t){return typeof e===t}function C(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function ee(e,t){try{return e instanceof t}catch{return!1}}var te=(e=>S(e,`null`)),ne=(e=>S(e,`string`)),re=(e=>S(e,`number`)&&!isNaN(e)||S(e,`bigint`)),ie=(e=>S(e,`boolean`)),w=(e=>!te(e)&&S(e,`object`)),T=(e=>S(e,`function`)),E=(e=>C(e,`Array`)),ae=(e=>!w(e)&&!T(e)),oe=typeof Event<`u`,se=(e=>oe&&ee(e,Event)),ce=typeof Error<`u`,le=(e=>ce&&ee(e,Error)),ue=(e=>C(e,`ErrorEvent`)),de=(e=>C(e,`DOMError`)),fe=(e=>C(e,`DOMException`));function D(e){return e==null?!0:E(e)||ne(e)?e.length===0:w(e)?Object.keys(e).length===0:!1}function O(e,t){if(e===t)return!0;if(S(e,`number`)&&isNaN(e))return S(t,`number`)&&isNaN(t);let n=E(e),r=E(t);if(n!==r)return!1;if(n&&r){let n=e.length;if(n!==t.length)return!1;for(let r=n;r--!==0;)if(!O(e[r],t[r]))return!1;return!0}let i=w(e),a=w(t);if(i!==a)return!1;if(e&&t&&i&&a){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!O(e[r],t[r]))return!1;return!0}return!1}function k(){return Date.now()}function pe(){return typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now()}function me(){return new Date().toISOString()}function he(e){return new Date(e).toISOString()}var ge=function(e){return e.TRACE=`trace`,e.DEBUG=`debug`,e.INFO=`info`,e.LOG=`log`,e.WARN=`warn`,e.ERROR=`error`,e}({}),_e=[`trace`,`debug`,`info`,`log`,`warn`,`error`];function A(){}function ve(e){let{size:t,concurrency:n}=e,r=[],i=0,a=()=>{if(i<n&&r.length){let{producer:e,resolve:t,reject:n}=r.shift();i++,e().then(e=>{i--,a(),t(e)},e=>{i--,a(),n(e)})}};return{add:e=>{if(r.length+i>=t)throw Error(`Task buffer full`);return new Promise((t,n)=>{r.push({producer:e,resolve:t,reject:n}),a()})}}}var ye=`abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789`;function be(e=10){let t=new Uint32Array(e),n=typeof globalThis<`u`?globalThis.crypto:void 0;if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*4294967296);let r=``;for(let n=0;n<e;n++)r+=ye[t[n]%59];return r}var j=typeof globalThis<`u`||typeof globalThis<`u`?globalThis:typeof self<`u`?self:void 0;function xe(){let e=new WeakSet;return function(t,n){if(w(n)&&n!==null){if(e.has(n))return null;e.add(n)}return n}}function M(e={}){return JSON.stringify(e??{},xe())}function Se(e={}){let t={};for(let[n,r]of Object.entries(e))t[n]=w(r)&&r!==null?M(r):String(r);return t}var N=class e{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter(t=>t!==e)}notify(e){this.subscribers.forEach(t=>t(e))}first(){let t=new e,n=e=>{t.notify(e),r.unsubscribe()},r=this.subscribe(n),i=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,i,n)}takeWhile(t){let n=new e,r=e=>{t(e)?n.notify(e):n.unsubscribe(r)};this.subscribe(r);let i=n.unsubscribe.bind(n);return this.withUnsubscribeOverride(n,i,r)}filter(t){let n=new e,r=e=>{t(e)&&n.notify(e)};this.subscribe(r);let i=n.unsubscribe.bind(n);return this.withUnsubscribeOverride(n,i,r)}merge(...t){let n=new e,r=[];t.forEach(e=>{let t=e.subscribe(e=>{n.notify(e)});r.push(t)});let i=n.unsubscribeAll.bind(n);return n.unsubscribe=()=>{r.forEach(e=>e.unsubscribe()),i()},n}withUnsubscribeOverride(e,t,n){return e.unsubscribe=e=>{t(e),this.unsubscribe(n)},e}unsubscribeAll(){this.subscribers=[]}},Ce=new WeakSet;function P(e){return Ce.add(e),e}function we(e){return Ce.has(e)}function Te(e,t){if(e.capture)return P(e.capture(t));let n=P(e.value);return t?.(),n}var F=`2.12.1`,I={exception:`exceptions`,log:`logs`,measurement:`measurements`,trace:`traces`,event:`events`},Ee={debug:A,error:A,info:A,prefix:`Faro`,warn:A};function L(e){"@babel/helpers - typeof";return L=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},L(e)}function De(e,t){if(L(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(L(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Oe(e){var t=De(e,`string`);return L(t)==`symbol`?t:t+``}function ke(e,t,n){return(t=Oe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ae(Object(n),!0).forEach(function(t){ke(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ae(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var je=R({},console);function Me(e=je,t=1){let n=Ee;return t>0&&(n.error=t>=1?function(...t){e.error(`${n.prefix}\n`,...t)}:A,n.warn=t>=2?function(...t){e.warn(`${n.prefix}\n`,...t)}:A,n.info=t>=3?function(...t){e.info(`${n.prefix}\n`,...t)}:A,n.debug=t>=4?function(...t){e.debug(`${n.prefix}\n`,...t)}:A),n}var Ne=class{constructor(){this.unpatchedConsole=je,this.internalLogger=Ee,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}},Pe=class extends Ne{isBatched(){return!1}getIgnoreUrls(){return[]}};function Fe(e,t){var n;if(t===void 0)return e;if(e===void 0)return{resourceSpans:t};let r=e.resourceSpans?.[0];if(r===void 0)return e;let i=r?.scopeSpans||[],a=(t==null||(n=t[0])==null?void 0:n.scopeSpans)||[];return R(R({},e),{},{resourceSpans:[R(R({},r),{},{scopeSpans:[...i,...a]})]})}function Ie(e){let t={meta:{}};return e[0]!==void 0&&(t.meta=e[0].meta),e.forEach(e=>{switch(e.type){case`log`:case`event`:case`exception`:case`measurement`:{let n=I[e.type],r=t[n];t=R(R({},t),{},{[n]:r===void 0?[e.payload]:[...r,e.payload]});break}case`trace`:t=R(R({},t),{},{traces:Fe(t.traces,e.payload.resourceSpans)})}}),t}var Le=`user_action_start`,Re={Normal:`normal`,Critical:`critical`},ze=`faro.user.action`,z=function(e){return e[e.Started=0]=`Started`,e[e.Halted=1]=`Halted`,e[e.Cancelled=2]=`Cancelled`,e[e.Ended=3]=`Ended`,e}({}),Be=class{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(T(e))for(let t of this.buffer)e(t);this.buffer.length=0}size(){return this.buffer.length}},Ve=class extends N{constructor({name:e,parentId:t,trigger:n,transports:r,attributes:i,trackUserActionsExcludeItem:a,importance:o=Re.Normal,pushEvent:s}){super(),this.name=e,this.attributes=i,this.id=be(),this.trigger=n,this.parentId=t??this.id,this.trackUserActionsExcludeItem=a,this.importance=o,this._pushEvent=s,this._itemBuffer=new Be,this._transports=r,this._state=0,this._start()}addItem(e){return this._state===0&&(this._itemBuffer.addItem(e),!0)}_start(){this._state=0,this._state===0&&(this.startTime=k(),this._startTimeMono=pe())}halt(){this._state===0&&(this._state=1,this.notify(this._state))}cancel(){this._state===0&&this._itemBuffer.flushBuffer(e=>{this._transports.execute(e)}),this._state=2,this.notify(this._state)}end(){if(this._state===2)return;let e=k(),t=pe()-this._startTimeMono;this._state=3,this._itemBuffer.flushBuffer(e=>{if(He(e,this.trackUserActionsExcludeItem)){this._transports.execute(e);return}let t=R(R({},e),{},{payload:R(R({},e.payload),{},{action:{parentId:this.id,name:this.name}})});this._transports.execute(t)}),this._state=3,this.notify(this._state),this._pushEvent(ze,R({userActionName:this.name,userActionStartTime:this.startTime.toString(),userActionEndTime:e.toString(),userActionDuration:t.toString(),userActionTrigger:this.trigger,userActionImportance:this.importance},Se(this.attributes)),void 0,{timestampOverwriteMs:this.startTime,customPayloadTransformer:e=>(e.action={id:this.id,name:this.name},e)})}getState(){return this._state}};function He(e,t){return t?.(e)||e.type===`measurement`&&e.payload.type===`web-vitals`}var Ue=new N;function We({transports:e,internalLogger:t,config:n,pushEvent:r}){let i=n.userActionsInstrumentation?.excludeItem,a,o=(n,o,c)=>{if(s()===void 0){let t=new Ve({name:n,transports:e,attributes:o,trigger:c?.triggerName||`faroApiCall`,importance:c?.importance||Re.Normal,trackUserActionsExcludeItem:i,pushEvent:r});return t.filter(e=>[3,2].includes(e)).first().subscribe(()=>{a=void 0}),Ue.notify({type:Le,userAction:t,initialActivityTimeout:c?.initialActivityTimeout}),a=t,a}t.error(`Attempted to create a new user action while one is already running. This is not possible.`)},s=()=>a;return{startUserAction:o,getActiveUserAction:s}}function Ge(e,t){return!e||e?.getState()!==0?!1:(e.addItem(t),!0)}var Ke=`Error`,qe=e=>e.map(e=>w(e)?M(e):String(e)).join(` `),Je=e=>e.map(e=>{try{return String(e)}catch{return``}}).join(` `),B=class extends Ne{constructor(...e){super(...e),this.api={},this.transports={}}},Ye=`_faroInternal`;function Xe(e){e.config.isolate?e.internalLogger.debug(`Skipping registering internal Faro instance on global object`):(e.internalLogger.debug(`Registering internal Faro instance on global object`),Object.defineProperty(j,Ye,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function Ze(){return Ye in j}function Qe(){return{pushLog:()=>{},pushError:()=>{},changeStacktraceParser:()=>{},getStacktraceParser:()=>void 0,pushMeasurement:()=>{},pushTraces:()=>{},getOTEL:()=>void 0,getTraceContext:()=>void 0,initOTEL:()=>{},isOTELInitialized:()=>!1,setUser:()=>{},resetUser:()=>{},setSession:()=>{},resetSession:()=>{},getSession:()=>void 0,setView:()=>{},getView:()=>void 0,setPage:()=>{},getPage:()=>void 0,pushEvent:()=>{},startUserAction:()=>void 0,getActiveUserAction:()=>void 0}}function $e(e){if(e.config.preventGlobalExposure)e.internalLogger.debug(`Skipping registering public Faro instance in the global scope`);else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in j){e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);return}Object.defineProperty(j,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}var V={api:Qe()};function et(e,t,n,r,i,a,o){return t.debug(`Initializing Faro`),V={api:a,config:n,instrumentations:o,internalLogger:t,metas:r,pause:i.pause,transports:i,unpatchedConsole:e,unpause:i.unpause},Xe(V),$e(V),V}function tt(e,t,n){let r=[],i=[],a=[],o,s=0,c=0,l=()=>r.reduce((e,t)=>Object.assign(e,T(t)?t():t),{}),u=()=>{if(i.length){let e=l();i.forEach(t=>t(e))}};return{add:(...e)=>{t.debug(`Adding metas
2
2
  `,e),r.push(...e),u()},remove:(...e)=>{t.debug(`Removing metas
3
3
  `,e),r=r.filter(t=>!e.includes(t)),u()},addListener:e=>{t.debug(`Adding metas listener
4
4
  `,e),i.push(e)},removeListener:e=>{t.debug(`Removing metas listener
@@ -17,4 +17,4 @@ import{t as e}from"./rolldown-runtime.Dd_uD5pT.js";import{_ as t,g as n}from"./t
17
17
  `,n),i.execute(n)}catch(e){t.error(`Error pushing trace
18
18
  `,e)}}}}function Et(e,t,n,r,i){t.debug(`Initializing API`);let a=null,o=We({transports:i,config:n,internalLogger:t,pushEvent:(e,n,r,i)=>{a?a(e,n,r,i):t.warn(`pushEventImpl is not initialized. Event dropped:`,{name:e,attributes:n,domain:r,options:i})}}),s=Tt(e,t,n,r,i),c={unpatchedConsole:e,internalLogger:t,userActionsApi:o,config:n,metas:r,transports:i,tracesApi:s},l=gt(c);return a=l.pushEvent,R(R(R(R(R(R(R({},s),yt(c)),wt(c)),St(c)),Ct(c)),l),o)}function Dt(e,t,n,r,i,a){t.debug(`Initializing instrumentations`);let o=[];return{add:(...s)=>{t.debug(`Adding instrumentations`),s.forEach(s=>{if(t.debug(`Adding "${s.name}" instrumentation`),o.some(e=>e.name===s.name)){t.warn(`Instrumentation ${s.name} is already added`);return}s.unpatchedConsole=e,s.internalLogger=t,s.config=n,s.metas=r,s.transports=i,s.api=a,o.push(s),s.initialize()})},get instrumentations(){return[...o]},remove:(...e)=>{t.debug(`Removing instrumentations`),e.forEach(e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);let i=o.reduce((t,n,r)=>t===null&&n.name===e.name?r:null,null);if(i===null){t.warn(`Instrumentation "${e.name}" is not added`);return}(n=(r=o[i]).destroy)==null||n.call(r),o.splice(i,1)})}}}function Ot(e){e.instrumentations.add(...e.config.instrumentations)}function kt(e){let t=ft(e),n=mt(t,e);if(Ze()&&!e.isolate){n.error(`Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property`);return}n.debug(`Initializing`);let r=tt(t,n,e),i=lt(t,n,e,r),a=Et(t,n,e,r,i),o=et(t,n,e,r,i,a,Dt(t,n,e,r,i,a));return it(o),ht(o),Ot(o),o}var At=`faro`,jt={enabled:!0,sendTimeout:250,itemLimit:50},Mt=`view_changed`,Nt=`session_start`,Pt=`session_resume`,Ft=`session_extend`,It=`service_name_override`;function Lt(){return V.transports.transports.flatMap(e=>e.getIgnoreUrls())}function Rt(e=``){return Lt().some(t=>e&&e.match(t)!=null)}function zt(e){if(ne(e))return e;if(e instanceof URL)return e.href;if(!D(e)&&T(e?.toString))return e.toString()}var U={session:`sessionStorage`,local:`localStorage`};function Bt(e){try{let t;t=window[e];let n=`__faro_storage_test__`;return t.setItem(n,n),t.removeItem(n),!0}catch(n){var t;return(t=V.internalLogger)==null||t.info(`Web storage of type ${e} is not available. Reason: ${n}`),!1}}function Vt(e,t){return Kt(t)?window[t].getItem(e):null}function Ht(e,t,n){if(Kt(n))try{window[n].setItem(e,t)}catch{}}function Ut(e,t){Kt(t)&&window[t].removeItem(e)}var Wt=Bt(U.local),Gt=Bt(U.session);function Kt(e){return e===U.local?Wt:e===U.session&&Gt}function qt(e){"@babel/helpers - typeof";return qt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},qt(e)}function Jt(e,t){if(qt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(qt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Yt(e){var t=Jt(e,`string`);return qt(t)==`symbol`?t:t+``}function Xt(e,t,n){return(t=Yt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Zt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Zt(Object(n),!0).forEach(function(t){Xt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qt(e=V){var t;let n=e.config.sessionTracking,r=(n==null||(t=n.sampler)==null?void 0:t.call(n,{metas:e.metas.value}))??n?.samplingRate??1,i=typeof r==`number`?x(r):0;if(!(i>0))return!1;if(i===1)return!0;try{let e=typeof window<`u`?window.crypto:void 0;if(typeof e?.getRandomValues==`function`){let t=new Uint32Array(1);return e.getRandomValues(t),t[0]/2**32<i}}catch{}return Math.random()<i}function $t({sessionId:e,started:t,lastActivity:n,isSampled:r=!0}={},i=V){var a;let o=k(),s=(a=i.config)==null||(a=a.sessionTracking)==null?void 0:a.generateSessionId;return e??=typeof s==`function`?s():be(),{sessionId:e,lastActivity:n??o,started:t??o,isSampled:r}}function en(e){if(e==null)return!1;let t=k();return t-e.started<144e5&&t-e.lastActivity<_}function tn({fetchUserSession:e,storeUserSession:t,adoptSession:n,updateInterval:r=0},i=V){let a=0;return function({forceSessionExtend:o=!1,refreshActivity:s=!0}={}){if(!e||!t)return;let c=k();if(!o&&c<a&&a-c<=r)return;let l=i.config.sessionTracking,u=l?.persistent;if(u&&!Wt||!u&&!Gt)return;let d=e();if(a=Math.min(c+r,(d?.started??c)+g,(d?.lastActivity??c)+_),o===!1&&en(d)){s&&t(W(W({},d),{},{lastActivity:c}));let e=i.metas.value.session?.id;n!=null&&d.sessionMeta!=null&&d.sessionId!==e&&n(d.sessionMeta)}else{var f,p;let e=rn($t({isSampled:Qt(i)},i),d,i);a=c+r,t(e),(f=i.api)==null||f.setSession(e.sessionMeta),l==null||(p=l.onSessionChange)==null||p.call(l,d?.sessionMeta??null,e.sessionMeta)}}}function nn({fetchUserSession:e,storeUserSession:t,updateInterval:n=0}){let r,i=0;return a=>{let o=k();if(a===r&&o<i&&i-o<=n)return;r=a,i=o+n;let s=e();s?.sessionId===a&&en(s)&&t(W(W({},s),{},{lastActivity:o}))}}function rn(e,t,n=V){var r,i;let a=W(W({},e),{},{sessionMeta:{id:e.sessionId,attributes:on(W(W(W({},(r=n.config.sessionTracking)==null||(r=r.session)==null?void 0:r.attributes),n.metas.value.session?.attributes??{}),{},{isSampled:e.isSampled.toString()}))}}),o=n.metas.value.session?.overrides??(t==null||(i=t.sessionMeta)==null?void 0:i.overrides);D(o)||(a.sessionMeta.overrides=o);let s=t?.sessionId;return s!=null&&(a.sessionMeta.attributes.previousSession=s),a}function an({fetchUserSession:e,storeUserSession:t},n=V){let r=!1;return function(i){if(r)return;let a=i.session,o=e(),s=a?.id,c=a?.attributes,l=a?.overrides,u=o?.sessionMeta,d=u?.overrides,f=!!l&&!O(l,d),p=!!c&&!O(c,u?.attributes);if(a&&s!==o?.sessionId||p||f){var m;let e=o!=null&&s===o.sessionId,i=rn(e?o:$t({sessionId:s,isSampled:Qt(n)},n),o,n),a=o==null||(m=o.sessionMeta)==null||(m=m.attributes)==null?void 0:m.previousSession;e&&a!=null&&a!==i.sessionId&&(i.sessionMeta.attributes.previousSession=a),i.sessionMeta.attributes?.previousSession===i.sessionId&&delete i.sessionMeta.attributes.previousSession,t(i),sn(n,f,l,d),r=!0;try{n.api.setSession(i.sessionMeta)}finally{r=!1}}}}function on(e){let t={};for(let n of Object.keys(e)){let r=e[n];r!==void 0&&(t[n]=r)}return t}function sn(e,t,n={},r={}){if(!t)return;let i=n.serviceName,a=r.serviceName??e.metas.value.app?.name??``;i&&i!==a&&e.api.pushEvent(It,{serviceName:i,previousServiceName:a})}var cn=class e{constructor(t=V){this.context=t,this.adopting=!1,this.isAdopting=()=>this.adopting,this.adoptSession=e=>{this.adopting=!0;try{var t;(t=this.context.api)==null||t.setSession(e)}finally{this.adopting=!1}},this.updateSession=({refreshActivity:e=!0}={})=>this.updateUserSession({refreshActivity:e}),this.recordActivity=nn({fetchUserSession:e.fetchUserSession,storeUserSession:e.storeUserSession,updateInterval:v}),this.updateUserSession=tn({fetchUserSession:e.fetchUserSession,storeUserSession:e.storeUserSession,adoptSession:this.adoptSession,updateInterval:v},t),this.init()}static removeUserSession(){Ut(h,e.storageTypeLocal)}static storeUserSession(t){Ht(h,M(t),e.storageTypeLocal)}static fetchUserSession(){let t=Vt(h,e.storageTypeLocal);return t?JSON.parse(t):null}init(){document.addEventListener(`visibilitychange`,()=>{if(document.visibilityState===`visible`){var e;this.updateSession({refreshActivity:!1});let t=(e=this.context.api)==null||(e=e.getSession())==null?void 0:e.id;t&&this.recordActivity(t)}}),this.context.metas.addListener(an({fetchUserSession:e.fetchUserSession,storeUserSession:e.storeUserSession},this.context))}};cn.storageTypeLocal=U.local;var ln=class e{constructor(t=V){this.context=t,this.isAdopting=()=>!1,this.updateSession=({refreshActivity:e=!0}={})=>this.updateUserSession({refreshActivity:e}),this.recordActivity=nn({fetchUserSession:e.fetchUserSession,storeUserSession:e.storeUserSession,updateInterval:v}),this.updateUserSession=tn({fetchUserSession:e.fetchUserSession,storeUserSession:e.storeUserSession,updateInterval:v},t),this.init()}static removeUserSession(){Ut(h,e.storageTypeSession)}static storeUserSession(t){Ht(h,M(t),e.storageTypeSession)}static fetchUserSession(){let t=Vt(h,e.storageTypeSession);return t?JSON.parse(t):null}init(){document.addEventListener(`visibilitychange`,()=>{if(document.visibilityState===`visible`){var e;this.updateSession({refreshActivity:!1});let t=(e=this.context.api)==null||(e=e.getSession())==null?void 0:e.id;t&&this.recordActivity(t)}}),this.context.metas.addListener(an({fetchUserSession:e.fetchUserSession,storeUserSession:e.storeUserSession},this.context))}};ln.storageTypeSession=U.session;var un=class{constructor(e,t,n){this.metas=e,this.transports=t,this.onActivate=n,this.waiting=!1,this.shouldCapture=()=>!document.prerendering,this.discard=()=>null,this.recordUpdate=e=>{let t=this.pending;if(e.type===`overrides`){this.pending={reset:t?.reset??!1,inheritOverrides:t?.inheritOverrides??!0,session:W(W({},t?.session),{},{overrides:W(W({},t?.session.overrides),e.overrides)})};return}let n=e.session,r=D(n)||n!=null&&`id`in n&&!n.id,i=n?.overrides??t?.session.overrides;this.pending={reset:r||!n?.id&&(t?.reset??!1),inheritOverrides:!e.overrides&&n?.overrides!==void 0?!1:t?.inheritOverrides??!0,session:{id:n?.id,attributes:n?.attributes&&W({},n.attributes),overrides:e.overrides?W(W({},t?.session.overrides),e.overrides):i&&W({},i)}}},this.activate=()=>{this.waiting&&this.shouldCapture()&&(this.destroy(),this.onActivate(this.pending))}}initialize(){var e,t;this.waiting=!0,H(this.metas).addSessionUpdateListener(this.recordUpdate),H(this.metas).addCaptureFilter(this.shouldCapture),this.transports.addBeforeSendHooks(this.discard),document.addEventListener(`prerenderingchange`,this.activate),(e=(t=this.metas).addCaptureListener)==null||e.call(t,this.activate),this.activate()}destroy(){var e,t;this.waiting=!1,document.removeEventListener(`prerenderingchange`,this.activate),H(this.metas).removeSessionUpdateListener(this.recordUpdate),(e=(t=this.metas).removeCaptureListener)==null||e.call(t,this.activate),H(this.metas).removeCaptureFilter(this.shouldCapture),this.transports.removeBeforeSendHooks(this.discard)}};function dn(e){return e?.persistent?cn:ln}var fn=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-session`,this.version=F,this.isAdoptingSession=()=>!1}sendSessionStartEvent(e){let t=e.session;if(t&&t.id!==this.notifiedSession?.id){if(this.isAdoptingSession()){this.notifiedSession=t;return}if(this.notifiedSession&&this.notifiedSession.id===t.attributes?.previousSession){this.api.pushEvent(Ft,{},void 0,{skipDedupe:!0}),this.notifiedSession=t;return}this.notifiedSession=t,this.api.pushEvent(Nt,{},void 0,{skipDedupe:!0})}}createInitialSession(e,t,n){let r=n?.session,i=e.fetchUserSession();if(t.persistent&&t.maxSessionPersistenceTime&&i){let e=k();i.lastActivity<e-t.maxSessionPersistenceTime&&(cn.removeUserSession(),i=null)}let a,o,s=en(i);if(!n?.reset&&s&&(!r?.id||r.id===i?.sessionId)){let e=i?.sessionId;o=$t({sessionId:e,isSampled:i.isSampled||!1,started:i?.started},this);let n=i?.sessionMeta,r=W(W({},t.session?.overrides),n?.overrides);o.sessionMeta=W(W({},t.session),{},{id:e,attributes:W(W(W({},t.session?.attributes),n?.attributes),{},{isSampled:o.isSampled.toString()}),overrides:r}),a=Pt}else{var c;o=$t({sessionId:n?.reset?void 0:r?.id??t.session?.id,isSampled:Qt(this)},this);let e=o.sessionId,l=n&&s?i==null||(c=i.sessionMeta)==null?void 0:c.overrides:void 0,u=l?W(W({},t.session?.overrides),l):t.session?.overrides;o.sessionMeta=W({id:e,attributes:W({isSampled:o.isSampled.toString()},t.session?.attributes)},u?{overrides:u}:{}),a=Nt}if(r&&(o.sessionMeta=W(W({},o.sessionMeta),{},{attributes:W(W(W({},o.sessionMeta?.attributes),r.attributes),{},{isSampled:o.isSampled.toString()})}),r.overrides)){let e=n?.inheritOverrides?W(W({},o.sessionMeta.overrides),r.overrides):r.overrides;Object.keys(e).length>0?o.sessionMeta.overrides=e:delete o.sessionMeta.overrides}return{initialSession:o,lifecycleType:a}}registerBeforeSendHook(e){var t;this.beforeSendHook=t=>{let n=t.meta.session?.id;n&&!this.transports.isPaused()&&e(n);let r=t.meta.session?.attributes;if(r&&r?.isSampled===`true`){let e=JSON.parse(JSON.stringify(t)),n=e.meta.session?.attributes;if(n==null||delete n.isSampled,Object.keys(n??{}).length===0){var i;(i=e.meta.session)==null||delete i.attributes}return e}return null},(t=this.transports)==null||t.addBeforeSendHooks(this.beforeSendHook)}initialize(){this.logDebug(`init session instrumentation`);let e=document.prerendering;if(this.config.sessionTracking?.enabled&&(e||this.prerenderSession)){this.prerenderSession??=new un(this.metas,this.transports,e=>{this.prerenderSession=void 0,this.initializeSession(e)}),this.prerenderSession.initialize();return}this.initializeSession()}initializeSession(e){let t=this.config.sessionTracking;if(t?.enabled){var n,r;let i=dn(t),a=new i(this);this.isAdoptingSession=a.isAdopting,this.registerBeforeSendHook(a.recordActivity);let{initialSession:o,lifecycleType:s}=this.createInitialSession(i,t,e);i.storeUserSession(o);let c=o.sessionMeta;this.notifiedSession=c,this.api.setSession(c),this.captureListener=()=>{this.transports.isPaused()||a.updateSession({refreshActivity:!1})},(n=(r=this.metas).addCaptureListener)==null||n.call(r,this.captureListener),s===`session_start`&&this.api.pushEvent(Nt,{},void 0,{skipDedupe:!0}),s===`session_resume`&&this.api.pushEvent(Pt,{},void 0,{skipDedupe:!0})}this.sessionStartListener=this.sendSessionStartEvent.bind(this),this.metas.addListener(this.sessionStartListener)}destroy(){var e;if((e=this.prerenderSession)==null||e.destroy(),this.captureListener){var t,n;(t=(n=this.metas).removeCaptureListener)==null||t.call(n,this.captureListener),this.captureListener=void 0}this.beforeSendHook&&=(this.transports.removeBeforeSendHooks(this.beforeSendHook),void 0),this.sessionStartListener&&=(this.metas.removeListener(this.sessionStartListener),void 0)}},pn=/^\s*at (?:(?![a-z]+:\/\/)([^(]+?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,mn=/\((\S*)(?::(\d+))(?::(\d+))\)/,hn=/^(?=[\s\S]*?(?:\/|bundle|\.js|\[native code]))\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|safari-extension|safari-web-extension|capacitor)?:\/.*?|\[native code]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,gn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_n=`safari-extension`,vn=`safari-web-extension`,yn=/Minified React error #\d+;/i;function bn(e,t,n,r){let i={filename:e||document.location.href,function:t||`?`};return n!==void 0&&(i.lineno=n),r!==void 0&&(i.colno=r),i}function xn(e,t){let n=e?.includes(_n),r=!n&&e?.includes(`safari-web-extension`);return!n&&!r?[e,t]:[e?.includes(`@`)?e.split(`@`)[0]:e,n?`${_n}:${t}`:`${vn}:${t}`]}var Sn=1024;function Cn(e){let t=[];e.stacktrace?t=e.stacktrace.split(`
19
19
  `).filter((e,t)=>t%2==0):e.stack&&(t=e.stack.split(`
20
- `));let n=t.reduce((t,n,r)=>{if(n.length>Sn)return t;let i,a,o,s,c;if(i=pn.exec(n)){if(a=i[1],o=i[2],s=i[3],c=i[4],o?.startsWith(`eval`)){let e=mn.exec(o);e&&(o=e[1],s=e[2],c=e[3])}o=o?.startsWith(`address at `)?o.substring(11):o,[a,o]=xn(a,o)}else if(i=hn.exec(n)){if(a=i[1],o=i[3],s=i[4],c=i[5],o&&o.includes(` > eval`)){let e=gn.exec(o);e&&(a||=`eval`,o=e[1],s=e[2])}else r===0&&!c&&re(e.columnNumber)&&(c=String(e.columnNumber+1));[a,o]=xn(a,o)}return(o||a)&&t.push(bn(o,a,s?Number(s):void 0,c?Number(c):void 0)),t},[]);return yn.test(e.message)?n.slice(1):n}function wn(e){return{frames:Cn(e)}}var Tn=`resource-entry`,En=`http-request-start`,Dn=`http-request-end`,On=`dom-mutation`,kn=`console`,An,jn=!1;function Mn(e){if(An||=new N,!jn){let t=e??je;_e.forEach(e=>{console[e]=(...n)=>{var r;An.notify({type:kn,level:e,args:n}),(r=t[e])==null||r.apply(console,n)}}),jn=!0}return An}var Nn=`Non-Error promise rejection captured with value:`,Pn=`UnhandledRejection`,Fn=`DOMError`,In=`DOMException`,Ln=`Non-Error exception captured with keys:`,Rn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function zn(e){let t=e.match(Rn),n=t?.[1]??Ke;return[t?.[2]??e,n]}function Bn(e){let t,n,r=[],i,a;if(ue(e)&&e.error)t=e.error.message,n=e.error.name,r=Cn(e.error);else if((i=de(e))||fe(e)){let{name:r,message:a}=e;n=r??(i?Fn:In),t=a?`${n}: ${a}`:n}else le(e)?(n=e.name,t=e.message,r=Cn(e)):(w(e)||(a=se(e)))&&(n=a?e.constructor.name:void 0,t=`${Ln} ${Object.keys(e)}`);return[t,n,r]}function Vn(e){let[t,n,r,i,a]=e,o,s,c=[],l=ne(t),u=bn(n,`?`,r,i);return a||!l?([o,s,c]=Bn(a??t),c.length===0&&(c=[u])):l&&([o,s]=zn(t),c=[u]),{value:o,type:s,stackFrames:c}}function Hn(e,t){return le(e[0])?Vn(e):{value:t(e)}}var Un=class e extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-console`,this.version=F,this.errorSerializer=Je}initialize(){let t=this.config.consoleInstrumentation,n=t?.serializeErrors||!!t?.errorSerializer;this.errorSerializer=n?t?.errorSerializer??qe:Je;let r=t?.disabledLevels??e.defaultDisabledLevels,i=Mn(this.unpatchedConsole);this.subscription=i.subscribe(({level:n,args:i})=>{if(!r.includes(n))try{if(n===ge.ERROR&&!t?.consoleErrorAsLog){let{value:t,type:n,stackFrames:r}=Hn(i,this.errorSerializer);if(t&&!n&&!r){this.api.pushError(Error(e.consoleErrorPrefix+t));return}this.api.pushError(Error(e.consoleErrorPrefix+t),{type:n,stackFrames:r})}else if(n===ge.ERROR&&t?.consoleErrorAsLog){let{value:t,type:r,stackFrames:a}=Hn(i,this.errorSerializer);this.api.pushLog(t?[e.consoleErrorPrefix+t]:i,{level:n,context:{value:t??``,type:r??``,stackFrames:a?.length?qe(a):``}})}else this.api.pushLog(i,{level:n})}catch(e){this.logError(e)}})}destroy(){var e;(e=this.subscription)==null||e.unsubscribe(),this.subscription=void 0}};Un.defaultDisabledLevels=[ge.DEBUG,ge.TRACE,ge.LOG],Un.consoleErrorPrefix=`console.error: `;function Wn(e){let t=window.onerror;window.onerror=(...n)=>{try{let{value:t,type:r,stackFrames:i}=Vn(n),a=n[4];if(t){let n={type:r,stackFrames:i};a!=null&&(n.originalError=a),e.pushError(Error(t),n)}}finally{t?.apply(window,n)}}}var Gn=[];function Kn(e){let t=t=>{let n=t;n.reason?n=t.reason:t.detail?.reason&&(n=t.detail?.reason);let r,i,a=[];ae(n)?(r=`${Nn} ${String(n)}`,i=Pn):[r,i,a]=Bn(n),r&&e.pushError(Error(r),{type:i,stackFrames:a})};window.addEventListener(`unhandledrejection`,t),Gn.push(t)}var qn=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-errors`,this.version=F}initialize(){this.logDebug(`Initializing`),Wn(this.api),Kn(this.api)}},Jn=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-view`,this.version=F,this.waitingForActivation=!1,this.sendViewChangedEvent=e=>{if(this.waitingForActivation||document.prerendering)return;let t=e.view;if(t&&t.name!==this.notifiedView?.name){let e=this.notifiedView?.name??b;this.notifiedView=t,this.api.pushEvent(Mt,{fromView:e,toView:t.name??b},void 0,{skipDedupe:!0})}},this.prerenderListener=()=>{window.queueMicrotask(()=>{this.waitingForActivation&&(this.waitingForActivation=!1,this.sendViewChangedEvent(this.metas.value))})}}initialize(){this.metas.addListener(this.sendViewChangedEvent),document.prerendering&&(this.waitingForActivation=!0,document.addEventListener(`prerenderingchange`,this.prerenderListener,{once:!0}))}destroy(){this.waitingForActivation=!1,this.metas.removeListener(this.sendViewChangedEvent),document.removeEventListener(`prerenderingchange`,this.prerenderListener)}},Yn=`com.grafana.faro.lastNavigationId`,Xn=class{t;o=0;i=[];l(e){if(e.hadRecentInput)return;let t=this.i[0],n=this.i.at(-1);this.o&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),this.t?.(e)}},Zn=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Qn=e=>{if(document.readyState===`loading`)return`loading`;let t=Zn();if(t){if(e<t.domInteractive)return`loading`;if(t.domContentLoadedEventStart===0||e<t.domContentLoadedEventStart)return`dom-interactive`;if(t.domComplete===0||e<t.domComplete)return`dom-content-loaded`}return`complete`},$n=e=>{let t=e.nodeName;return e.nodeType===1?t.toLowerCase():t.toUpperCase().replace(/^#/,``)},er=e=>{let t=``;try{for(;e?.nodeType!==9;){let n=e,r=n.id?`#`+n.id:[$n(n),...Array.from(n.classList??[]).sort()].join(`.`);if(t.length+r.length>99)return t||r;if(t=t?r+`>`+t:r,n.id)break;e=n.parentNode}}catch{}return t},tr=new WeakMap;function nr(e,t){let n=tr.get(t);return n||(n=new WeakMap,tr.set(t,n)),n.get(e)||n.set(e,new t),n.get(e)}var rr=-1,ir=()=>rr,ar=e=>{addEventListener(`pageshow`,t=>{t.persisted&&(rr=t.timeStamp,e(t))},!0)},G=(e,t,n,r)=>{let i,a;return o=>{t.value>=0&&(o||r)&&(a=t.value-(i??0),(a||i===void 0)&&(i=t.value,t.delta=a,t.rating=((e,t)=>e>t[1]?`poor`:e>t[0]?`needs-improvement`:`good`)(t.value,n),e(t)))}},or=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},sr=()=>Zn()?.activationStart??0,cr=-1,lr=new Set,ur=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,dr=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of lr)e();isFinite(cr)||(cr=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,dr,!0))}},fr=(e=!1)=>{if(e&&(cr=1/0),cr<0){let e=sr();cr=(document.prerendering?void 0:globalThis.performance.getEntriesByType(`visibility-state`).find(t=>t.name===`hidden`&&t.startTime>=e)?.startTime)??ur(),addEventListener(`visibilitychange`,dr,!0),addEventListener(`prerenderingchange`,dr,!0),ar(()=>{setTimeout(()=>{cr=ur()})})}return{get firstHiddenTime(){return cr},onHidden(e){lr.add(e)}}},K=(e,t=-1,n,r=0,i,a,o)=>{let s=Zn(),c=s?.navigationId||0,l=`navigate`;return n?l=n:ir()>=0?l=`back-forward-cache`:s&&(document.prerendering||sr()>0?l=`prerender`:document.wasDiscarded?l=`restore`:s.type&&(l=s.type.replace(/_/g,`-`))),{name:e,value:t,rating:`good`,delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+0xe8d4a51000}`,navigationType:l,navigationId:r||c,navigationInteractionId:i,navigationURL:a||s?.name,navigationStartTime:o||0}},q=(e,t,n={})=>{try{let r=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(r.length>0){let e=new PerformanceObserver(e=>{queueMicrotask(()=>{let n=e.getEntries();r.length>1&&n.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(n)})});for(let t of r)e.observe({type:t,buffered:!0,...n});return e}}catch{}},pr=e=>globalThis.PerformanceObserver?.supportedEntryTypes?.includes(`soft-navigation`)&&typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint==`function`&&e&&e.reportSoftNavs,mr=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){let t=e.keys().next().value;t!==void 0&&e.delete(t)}},hr=e=>{let t=!1;return()=>{t||=(e(),!0)}},gr=class{u},_r=e=>{document.prerendering?addEventListener(`prerenderingchange`,e,!0):e()},vr=[1800,3e3],yr=(e,t={})=>{let n=pr(t);_r(()=>{let r=nr(t,gr),i=fr(),a,o=K(`FCP`),s=q([`paint`],e=>{for(let t of e)t.name===`first-contentful-paint`&&(s.disconnect(),t.startTime<i.firstHiddenTime&&(o.value=Math.max(t.startTime-sr(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,a(!0)))});s&&(a=G(e,o,vr,t.reportAllChanges),ar(n=>{o=K(`FCP`,-1,`back-forward-cache`,o.navigationId,o.navigationInteractionId,o.navigationURL,ir()),a=G(e,o,vr,t.reportAllChanges),or(()=>{o.value=performance.now()-n.timeStamp,a(!0)})})),n&&q([`soft-navigation`],n=>{n.forEach(n=>{r.u&&n.navigationId&&mr(r.u,n),o=K(`FCP`,Math.max((n.presentationTime||n.paintTime||0)-n.startTime,0),`soft-navigation`,n.navigationId,n.interactionId,n.name,n.startTime),a=G(e,o,vr,t.reportAllChanges),a(!0)})},t)})},br=[.1,.25],xr=e=>e.find(e=>e.node?.nodeType===1)||e[0],Sr=(e,t={})=>{let n=nr(t=Object.assign({},t),Xn),r=new WeakMap;n.t=e=>{if(e?.sources?.length){let n=xr(e.sources),i=n?.node;if(i){let e=t.generateTarget?.(i)??er(i);r.set(n,e)}}},((e,t={})=>{let n=fr();yr(hr(()=>{let r,i=K(`CLS`,0),a=nr(t,Xn),o=(n,o,s,c,l)=>{i=K(`CLS`,0,n,o,s,c,l),a.o=0,r=G(e,i,br,t.reportAllChanges)},s=(e=!1)=>{a.o>i.value&&(i.value=a.o,i.entries=a.i),r(e)},c=e=>{s(!0),o(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime)},l=e=>{for(let t of e)t.entryType===`soft-navigation`?c(t):a.l(t);s()},u=[`layout-shift`];pr(t)&&u.push(`soft-navigation`);let d=q(u,l);d&&(r=G(e,i,br,t.reportAllChanges),n.onHidden(()=>{l(d.takeRecords()),r(!0)}),ar(()=>{o(`back-forward-cache`,i.navigationId,i.navigationInteractionId,i.navigationURL,ir()),or(r)}),setTimeout(r))}))})(t=>{e((e=>{let t={};if(e.entries.length){let n=e.entries.reduce((e,t)=>e.value>t.value?e:t);if(n?.sources?.length){let e=xr(n.sources);e&&(t={largestShiftTarget:r.get(e),largestShiftTime:n.startTime,largestShiftValue:n.value,largestShiftSource:e,largestShiftEntry:n,loadState:Qn(n.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},Cr=(e,t={})=>{let n=nr(t=Object.assign({},t),gr);pr(t)&&(n.u=new Map),yr(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:Qn(ir())};if(e.navigationType!==`soft-navigation`){if(e.entries.length){let n=Zn(),r=e.entries.at(-1);if(n){let i=n.responseStart,a=n.activationStart||0,o=Math.max(0,i-a);t={timeToFirstByte:o,firstByteToFCP:e.value-o,loadState:Qn(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}}else{let r=n.u?.get(e.navigationId);r&&(t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:`complete`,navigationEntry:r})}return Object.assign(e,{attribution:t})})(t))},t)},wr=0,Tr=1/0,Er=0,Dr=e=>{for(let t of e)t.interactionId&&(Tr=Math.min(Tr,t.interactionId),Er=Math.max(Er,t.interactionId),wr=Er?(Er-Tr)/7+1:0)},Or,kr=()=>Or?wr:performance.interactionCount??0,Ar=()=>{`interactionCount`in performance||Or||(Or=q([`event`],Dr,{durationThreshold:0}))},jr=class{h=0;v=[];p=new Map;m;M;T(){return kr()-this.h}D(){this.h=kr(),this.v.length=0,this.p.clear()}S(e){let t=this.T(),n=Math.min(this.v.length-1,Math.floor(t/50));return!t||n!==-1||e!==`soft-navigation`&&e!==`back-forward-cache`?this.v[n]:{k:8,id:-1,entries:[]}}l(e){if(this.m?.(e),!e.interactionId)return;let t=this.v.at(-1),n=this.p.get(e.interactionId);if(n||this.v.length<10||e.duration>t.k){if(n?e.duration>n.k?(n.entries=[e],n.k=e.duration):e.duration===n.k&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],k:e.duration},this.p.set(n.id,n),this.v.push(n)),this.v.sort((e,t)=>t.k-e.k),this.v.length>10){let e=this.v.splice(10);for(let t of e)this.p.delete(t.id)}this.M?.(n)}}},Mr=e=>{let t=`requestIdleCallback`in globalThis?1e3:0,n=globalThis.requestIdleCallback||setTimeout,r=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState===`hidden`)e();else{let i=hr(e),a=-1,o=()=>{r(a),i()};addEventListener(`visibilitychange`,o,{once:!0,capture:!0}),a=n(()=>{removeEventListener(`visibilitychange`,o,{capture:!0}),i()},{timeout:t})}},Nr=[200,500],Pr=(e,t={})=>{let n=nr(t=Object.assign({},t),jr),r=[],i=[],a=0,o=new WeakMap,s=new WeakMap,c=!1,l=()=>{c||(c=!0,Mr(u))},u=()=>{let e=new Set(n.v.map(e=>o.get(e.entries[0]))),t=i.length-10;i=i.filter((n,r)=>r>=t||e.has(n));let s=new Set;for(let e of i){let t=d(e.startTime,e.processingEnd);for(let e of t)s.add(e)}let l=r.length-10;r=r.filter((e,t)=>s.has(e)||t>=l&&e.startTime>a),c=!1};n.m=e=>{let n=e.startTime+e.duration,r;a=Math.max(a,e.processingEnd);for(let a=i.length-1;a>=0;a--){let o=i[a];if(Math.abs(n-o.renderTime)<=8){r=o,r.startTime=Math.min(e.startTime,r.startTime),r.processingStart=Math.min(e.processingStart,r.processingStart),r.processingEnd=Math.max(e.processingEnd,r.processingEnd),t.includeProcessedEventEntries&&r.entries.push(e);break}}r||(r={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:n,entries:t.includeProcessedEventEntries?[e]:[]},i.push(r)),e.interactionId&&o.set(e,r),l()},n.M=e=>{if(!s.get(e)){let n=e.entries.find(e=>e.target)?.target;if(n){let r=t.generateTarget?.(n)??er(n);s.set(e,r)}else{let t=e.entries.find(e=>e.targetSelector)?.targetSelector;t&&s.set(e,t)}}};let d=(e,t)=>{let n=[];for(let i of r)if(!(i.startTime+i.duration<e)){if(i.startTime>t)break;n.push(i)}return n},f=e=>{if(e.entries.length===0){let t=e.navigationStartTime||0,n={processedEventEntries:[],longAnimationFrameEntries:[],inputDelay:0,processingDuration:0,presentationDelay:e.value,loadState:Qn(t)};return Object.assign(e,{attribution:n})}let t=e.entries[0],r=o.get(t),i=Math.max(r.processingStart,t.startTime),a=Math.max(t.startTime+t.duration,i),c=Math.min(r.processingEnd,a),l=r.entries.sort((e,t)=>e.processingStart-t.processingStart),u=d(t.startTime,c),f=n.p.get(t.interactionId),p={interactionTarget:s.get(f),interactionType:t.name.startsWith(`key`)?`keyboard`:`pointer`,interactionTime:t.startTime,nextPaintTime:a,processedEventEntries:l,longAnimationFrameEntries:u,inputDelay:i-t.startTime,processingDuration:c-i,presentationDelay:a-c,loadState:Qn(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{let t=e.interactionTime,n=e.nextPaintTime;if(!e.longAnimationFrameEntries?.length||!t||!n)return;let r=e.inputDelay,i=e.processingDuration,a,o,s=0,c=0,l=0,u=0;for(let n of e.longAnimationFrameEntries){c=c+n.startTime+n.duration-n.styleAndLayoutStart;for(let e of n.scripts){let n=e.startTime+e.duration;if(n<t)continue;let l=n-Math.max(t,e.startTime),d=e.duration?l/e.duration*e.forcedStyleAndLayoutDuration:0;s+=l-d,c+=d,l>u&&(o=e.startTime<t+r?`input-delay`:e.startTime>=t+r+i?`presentation-delay`:`processing-duration`,a=e,u=l)}}let d=e.longAnimationFrameEntries.at(-1),f=d?d.startTime+d.duration:0;f>=t+r+i&&(l=n-f),a&&o&&(e.longestScript={entry:a,subpart:o,intersectingDuration:u}),e.totalScriptDuration=s,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=l,e.totalUnattributedDuration=n-t-s-c-l})(p),Object.assign(e,{attribution:p})};q([`long-animation-frame`],e=>{r=r.concat(e),l()},t),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=fr();_r(()=>{Ar();let r,i=K(`INP`),a=nr(t,jr),o=(n,o,s,c,l)=>{a.D(),i=K(`INP`,-1,n,o,s,c,l),r=G(e,i,Nr,t.reportAllChanges)},s=()=>{let e=a.S(i.navigationType);e&&e.k!==i.value&&(i.value=e.k,i.entries=e.entries,r())},c=e=>{s(),r(!0),o(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime)},l=(e,t=!1)=>{Mr(()=>{for(let t of e)t.entryType===`soft-navigation`?c(t):a.l(t);s(),t&&r(!0)})},u=[`event`,`first-input`];pr(t)&&u.push(`soft-navigation`);let d=q(u,l,{...t,durationThreshold:t.durationThreshold??40});r=G(e,i,Nr,t.reportAllChanges),d&&(n.onHidden(()=>{l(d.takeRecords(),!0)}),ar(()=>{o(`back-forward-cache`,i.navigationId,i.navigationInteractionId,i.navigationURL,ir())}))})})(t=>{e(f(t))},t)},Fr=class{m;u;l(e){this.m?.(e)}},Ir=[2500,4e3],Lr=50,Rr=[];q([`resource`],e=>{for(let t of e)Rr.push(t),Rr.length>Lr&&Rr.shift()});var zr=(e,t={})=>{(t=Object.assign({},t)).resourceBufferSize!=null&&(Lr=t.resourceBufferSize);let n=nr(t,Fr),r=new WeakMap;pr(t)&&(n.u=new Map),n.m=e=>{let n=e.element;if(n){let i=t.generateTarget?.(n)??er(n);r.set(e,i)}else e.id&&r.set(e,`#${e.id}`)},((e,t={})=>{let n=!1,r=pr(t);_r(()=>{let i,a=fr(),o=K(`LCP`),s=nr(t,Fr),c=(r,s,c,l,u)=>{o=K(`LCP`,-1,r,s,c,l,u),i=G(e,o,Ir,t.reportAllChanges),n=!1,r===`soft-navigation`&&(a=fr(!0))},l=e=>{s.u&&e.navigationId&&mr(s.u,e),n||i(!0),c(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime);let t=e.getLargestInteractionContentfulPaint?.();t&&u([t])},u=e=>{t.reportAllChanges||r||(e=e.slice(-1));for(let t of e){if(!t)continue;if(t.entryType===`soft-navigation`){l(t);continue}let e=0,n=[],r=t.startTime;if(t.entryType===`largest-contentful-paint`)e=Math.max(t.startTime-sr(),0),s.l(t),n=[t];else if(t.entryType===`interaction-contentful-paint`){let i=t;if(!o.navigationId||`interactionId`in i&&i.interactionId!=o.navigationInteractionId)continue;r=i.largestContentfulPaint?.renderTime||0,e=Math.max(r-t.startTime,0),i.largestContentfulPaint&&(s.l(i.largestContentfulPaint),n=[i.largestContentfulPaint])}r<a.firstHiddenTime&&(o.value=e,o.entries=n,i())}},d=[`largest-contentful-paint`];r&&d.push(`interaction-contentful-paint`,`soft-navigation`);let f=q(d,u);if(f){i=G(e,o,Ir,t.reportAllChanges);let a=[`keydown`,`click`,`visibilitychange`],s=e=>{if(e.isTrusted&&!n){let e=o.id;Mr(()=>{if(!n){if(!r){f.disconnect();for(let e of a)removeEventListener(e,s,{capture:!0})}e===o.id&&(n=!0,i(!0))}})}};for(let e of a)addEventListener(e,s,{capture:!0});ar(r=>{c(`back-forward-cache`,o.navigationId,o.navigationInteractionId,o.navigationURL,ir()),i=G(e,o,Ir,t.reportAllChanges),or(()=>{o.value=performance.now()-r.timeStamp,n=!0,i(!0)})})}})})(t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){let i=e.entries.at(-1),a=e=>e.name===i.url&&(e.requestStart||e.startTime)<=i.startTime,o=i.url&&(Rr.findLast(a)||performance.getEntriesByType(`resource`).findLast(a)),s;t.target=r.get(i),t.lcpEntry=i,i.url&&(t.url=i.url),o&&(t.lcpResourceEntry=o);let c=0,l=0;if(e.navigationType===`soft-navigation`?(c=e.navigationStartTime||0,s=n.u?.get(e.navigationId)):(s=Zn(),c=s?.activationStart??0,l=s?.responseStart??0),s){let n=Math.max(0,l-c),r=Math.max(n,o?(o.requestStart||o.startTime)-c:0),i=Math.min(e.value,Math.max(r,o?o.responseEnd-c:0));t={...t,timeToFirstByte:n,resourceLoadDelay:r-n,resourceLoadDuration:i-r,elementRenderDelay:e.value-i,navigationEntry:s}}}return Object.assign(e,{attribution:t})})(t))},t)},Br=[800,1800],Vr=e=>{document.prerendering?_r(()=>Vr(e)):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,()=>Vr(e),!0)},Hr=(e,t={})=>{((e,t={})=>{let n=pr(t),r=K(`TTFB`),i=G(e,r,Br,t.reportAllChanges);Vr(()=>{let a=Zn();if(a){let o=a.responseStart;r.value=Math.max(o-sr(),0),r.entries=[a],i(!0),ar(()=>{r=K(`TTFB`,0,`back-forward-cache`,r.navigationId,r.navigationInteractionId,r.navigationURL,ir()),i=G(e,r,Br,t.reportAllChanges),i(!0)}),n&&q([`soft-navigation`],n=>{n.forEach(n=>{n.navigationId&&(r=K(`TTFB`,0,`soft-navigation`,n.navigationId,n.interactionId,n.name,n.startTime),r.entries=[n],i=G(e,r,Br,t.reportAllChanges),i(!0))})},t)}})})(t=>{e((e=>{let t=e.entries[0],n={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0,navigationEntry:t};if(e.entries.length&&t instanceof PerformanceNavigationTiming){let r=t.activationStart||0,i=Math.max((t.workerStart||t.fetchStart||0)-r,0),a=Math.max(t.domainLookupStart-r,0),o=Math.max(t.connectStart-r,0),s=Math.max(t.connectEnd-r,0);n={waitingDuration:i,cacheDuration:a-i,dnsDuration:o-a,connectionDuration:s-o,requestDuration:e.value-s,navigationEntry:t}}return Object.assign(e,{attribution:n})})(t))},t)},Ur=`load_state`,Wr=`time_to_first_byte`,Gr=class{constructor(e,t){this.corePushMeasurement=e,this.webVitalConfig=t}initialize(){this.measureCLS(),this.measureFCP(),this.measureINP(),this.measureLCP(),this.measureTTFB()}measureCLS(){Sr(e=>{let{loadState:t,largestShiftValue:n,largestShiftTime:r,largestShiftTarget:i}=e.attribution,a=this.buildInitialValues(e);this.addIfPresent(a,`largest_shift_value`,n),this.addIfPresent(a,`largest_shift_time`,r);let o=this.buildInitialContext(e);this.addIfPresent(o,Ur,t),this.addIfPresent(o,`largest_shift_target`,i),this.pushMeasurement(a,o)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}measureFCP(){Cr(e=>{let{firstByteToFCP:t,timeToFirstByte:n,loadState:r}=e.attribution,i=this.buildInitialValues(e);this.addIfPresent(i,`first_byte_to_fcp`,t),this.addIfPresent(i,Wr,n);let a=this.buildInitialContext(e);this.addIfPresent(a,Ur,r),this.pushMeasurement(i,a)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}measureINP(){Pr(e=>{let{interactionTime:t,presentationDelay:n,inputDelay:r,processingDuration:i,nextPaintTime:a,loadState:o,interactionTarget:s,interactionType:c,totalScriptDuration:l,totalStyleAndLayoutDuration:u,totalPaintDuration:d,totalUnattributedDuration:f,longestScript:p}=e.attribution,m=this.buildInitialValues(e);this.addIfPresent(m,`interaction_time`,t),this.addIfPresent(m,`presentation_delay`,n),this.addIfPresent(m,`input_delay`,r),this.addIfPresent(m,`processing_duration`,i),this.addIfPresent(m,`next_paint_time`,a),this.addNumberIfDefined(m,`total_script_duration`,l),this.addNumberIfDefined(m,`total_style_and_layout_duration`,u),this.addNumberIfDefined(m,`total_paint_duration`,d),this.addNumberIfDefined(m,`total_unattributed_duration`,f),this.addNumberIfDefined(m,`longest_script_intersecting_duration`,p?.intersectingDuration);let h=this.buildInitialContext(e);this.addIfPresent(h,Ur,o),this.addIfPresent(h,`interaction_target`,s),this.addIfPresent(h,`interaction_type`,c),this.addIfPresent(h,`longest_script_subpart`,p?.subpart),this.addIfPresent(h,`longest_script_invoker_type`,p?.entry.invokerType),this.webVitalConfig?.trackAttributionSources&&(this.addIfPresent(h,`longest_script_invoker`,p?.entry.invoker),this.addIfPresent(h,`longest_script_source_url`,p?.entry.sourceURL),this.addIfPresent(h,`longest_script_source_function_name`,p?.entry.sourceFunctionName),this.addIfPresent(h,`longest_script_source_char_position`,p?.entry.sourceCharPosition===void 0?void 0:String(p.entry.sourceCharPosition))),this.pushMeasurement(m,h)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}measureLCP(){zr(e=>{let{elementRenderDelay:t,resourceLoadDelay:n,resourceLoadDuration:r,timeToFirstByte:i,target:a,url:o,lcpResourceEntry:s}=e.attribution,c=this.buildInitialValues(e);this.addIfPresent(c,`element_render_delay`,t),this.addIfPresent(c,`resource_load_delay`,n),this.addIfPresent(c,`resource_load_duration`,r),this.addIfPresent(c,Wr,i);let l=this.buildInitialContext(e);this.addIfPresent(l,`element`,a),this.webVitalConfig?.trackAttributionSources&&(this.addIfPresent(l,`resource_url`,o),this.addIfPresent(l,`resource_delivery_type`,s?.deliveryType),this.addIfPresent(l,`resource_initiator_type`,s?.initiatorType)),this.pushMeasurement(c,l)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}measureTTFB(){Hr(e=>{let{dnsDuration:t,connectionDuration:n,requestDuration:r,waitingDuration:i,cacheDuration:a}=e.attribution,o=this.buildInitialValues(e);this.addIfPresent(o,`dns_duration`,t),this.addIfPresent(o,`connection_duration`,n),this.addIfPresent(o,`request_duration`,r),this.addIfPresent(o,`waiting_duration`,i),this.addIfPresent(o,`cache_duration`,a);let s=this.buildInitialContext(e);this.pushMeasurement(o,s)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}buildInitialValues(e){return{[e.name.toLowerCase()]:e.value,delta:e.delta}}buildInitialContext(e){let t=Vt(`com.grafana.faro.lastNavigationId`,U.session)??b;return{id:e.id,rating:e.rating,navigation_type:e.navigationType,navigation_entry_id:t}}pushMeasurement(e,t){this.corePushMeasurement({type:`web-vitals`,values:e},{context:t})}addIfPresent(e,t,n){n&&(e[t]=n)}addNumberIfDefined(e,t,n){n!==void 0&&(e[t]=n)}},Kr=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-web-vitals`,this.version=F}initialize(){this.logDebug(`Initializing`),new Gr(this.api.pushMeasurement,this.config.webVitalsInstrumentation).initialize()}},qr=/^00-[a-f0-9]{32}-[a-f0-9]{16}-[0-9]{1,2}$/;function Jr(e=[]){for(let t of e)if(t.name===`traceparent`){if(!qr.test(t.description))continue;let[,e,n]=t.description.split(`-`);if(e!=null&&n!=null)return{traceId:e,spanId:n};break}}function Yr(e,t={wallNow:Date.now(),monoNow:performance.now()}){let{wallNow:n,monoNow:r}=t;return Math.min(n,n-(r-e))}function Xr(){return`PerformanceObserver`in window}function Zr(e){if(document.readyState===`complete`)e();else{let t=()=>{document.readyState===`complete`&&(e(),document.removeEventListener(`readystatechange`,t))};document.addEventListener(`readystatechange`,t)}}function Qr(e,t={}){for(let[n,r]of Object.entries(t)){let t=e[n];return t==null?!1:E(r)?r.includes(t):t===r}return!0}function $r(e){let{connectEnd:t,connectStart:n,decodedBodySize:r,domainLookupEnd:i,domainLookupStart:a,duration:o,encodedBodySize:s,fetchStart:c,initiatorType:l,name:u,nextHopProtocol:d,redirectEnd:f,redirectStart:p,renderBlockingStatus:m,requestStart:h,responseEnd:g,responseStart:_,responseStatus:v,secureConnectionStart:y,transferSize:b,workerStart:x}=e;return{name:u,httpHost:ni(u),duration:J(o),tcpHandshakeTime:J(t-n),dnsLookupTime:J(i-a),tlsNegotiationTime:J(t-y),responseStatus:J(v),redirectTime:J(f-p),requestTime:J(_-h),responseTime:J(g-_),fetchTime:J(g-c),serviceWorkerTime:J(x>0?c-x:0),decodedBodySize:J(r),encodedBodySize:J(s),cacheHitStatus:S(),renderBlockingStatus:J(m),protocol:d,initiatorType:l,visibilityState:document.visibilityState,ttfb:J(_-h),transferSize:J(b)};function S(){let e=`fullLoad`;return b===0?r>0&&(e=`cache`):v==null?s>0&&b<s&&(e=`conditionalFetch`):v===304&&(e=`conditionalFetch`),e}}function ei(e){let{activationStart:t,domComplete:n,domContentLoadedEventEnd:r,domContentLoadedEventStart:i,domInteractive:a,fetchStart:o,loadEventEnd:s,loadEventStart:c,responseStart:l,type:u}=e,d=ti();return W(W({},$r(e)),{},{pageLoadTime:J(n-o),documentParsingTime:J(d?a-d:null),domProcessingTime:J(n-a),domContentLoadHandlerTime:J(r-i),onLoadTime:J(s-c),ttfb:J(Math.max(l-(t??0),0)),type:u})}function ti(){return performance.timing?.domLoading==null?null:performance.timing.domLoading-performance.timeOrigin}function ni(e){try{return new URL(e).host||`unknown`}catch{return b}}function J(e){return e==null?b:typeof e==`number`?Math.round(e>0?e:0).toString():e.toString()}var ri=`navigation`,ii=`resource`;function ai(e){let t,n=new Promise(e=>{t=e});return new PerformanceObserver(n=>{let[r]=n.getEntries();if(r==null||Rt(r.name))return;let i=r.toJSON(),a=Jr(i?.serverTiming),o=Vt(`com.grafana.faro.lastNavigationId`,U.session)??b,s=W(W({},ei(i)),{},{faroNavigationId:be(),faroPreviousNavigationId:o});Ht(Yn,s.faroNavigationId,U.session),e(`faro.performance.navigation`,s,void 0,{spanContext:a,timestampOverwriteMs:Yr(i.startTime)}),t(s)}).observe({type:ri,buffered:!0}),n}var oi={initiatorType:[`xmlhttprequest`,`fetch`]};function si(e,t,n,r){let i=r.trackResources;new PerformanceObserver(r=>{let a=r.getEntries(),o={wallNow:Date.now(),monoNow:performance.now()};for(let r of a){if(Rt(r.name))continue;n?.notify({type:`resource`});let a=r.toJSON(),s=Jr(a?.serverTiming);(i==null&&Qr(a,oi)||i)&&t(`faro.performance.resource`,W(W({},$r(a)),{},{faroNavigationId:e,faroResourceId:be()}),void 0,{spanContext:s,timestampOverwriteMs:Yr(a.startTime,o)})}}).observe({type:ii,buffered:!0})}function ci(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Y(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){ci(a,r,i,o,s,`next`,e)}function s(e){ci(a,r,i,o,s,`throw`,e)}o(void 0)})}}var li=new N,ui=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-performance`,this.version=F}initialize(){var e=this;if(!Xr()){this.logDebug(`performance observer not supported. Disable performance instrumentation.`);return}let t=!1,n=()=>{Zr(Y(function*(){if(t)return;let n=e.api.pushEvent,{faroNavigationId:r}=yield ai(n);!t&&r!=null&&si(r,n,li,e.config)}))};this.cancelInitialization=()=>{t=!0,document.removeEventListener(`prerenderingchange`,n)},document.prerendering?document.addEventListener(`prerenderingchange`,n,{once:!0}):n()}destroy(){var e;(e=this.cancelInitialization)==null||e.call(this),this.cancelInitialization=void 0}},di=`data-faro-user-action-name`;di.replace(/-name$/,`-timeout`);var fi=1e3;function pi(e){return`data-${(e.startsWith(`data-`)?e.slice(5):e).replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}`}function mi(e){let t=pi(e);return t.endsWith(`-name`)?`${t.slice(0,-5)}-timeout`:`${t}-timeout`}function hi(e,t=100,n=A){if(e===void 0)return t;let r=NaN;try{r=typeof e==`string`&&e.trim()===``?NaN:Number(e)}catch{}return!Number.isFinite(r)||r<=0?(n(`initialActivityTimeout must be a finite number greater than zero; using ${t} ms`),t):r>1e3?(n(`initialActivityTimeout cannot exceed ${fi} ms; clamping to the maximum`),fi):r}function gi(e){return pi(e).slice(5).replace(/-(.)/g,(e,t)=>t.toUpperCase())}function _i(e,t,n){return e!==void 0&&window.clearTimeout(e),window.setTimeout(()=>{t()},n)}function vi(e){return e.type===En}function yi(e){return e.type===Dn}var bi,xi;function Si(){return bi||=new N,xi||(xi=new MutationObserver((e,t)=>{bi.notify({type:On})}),xi.observe(document,{attributes:!0,childList:!0,subtree:!0,characterData:!0})),bi}var Ci=`fetch`,wi=`xhr`,Ti,Ei=!1,Di,Oi;function ki(){if(Ti)return Ti;Ti=new N;function e(e){Ti.notify({type:En,request:e})}function t(e){Ti.notify({type:Dn,request:e})}return Ei||=(ji({onRequestStart:e,onRequestEnd:t}),Ai({onRequestStart:e,onRequestEnd:t}),!0),Ti}function Ai({onRequestStart:e,onRequestEnd:t}){Di||=XMLHttpRequest.prototype.open,XMLHttpRequest.prototype.open=function(){let n=arguments[1],r=Rt(n),i=arguments[0],a=be();this.addEventListener(`loadstart`,function(){r||e({url:n,method:i,requestId:a,apiType:wi})}),this.addEventListener(`load`,function(){r||t({url:n,method:i,requestId:a,apiType:wi})}),this.addEventListener(`error`,function(){r||t({url:n,method:i,requestId:a,apiType:wi})}),this.addEventListener(`abort`,function(){r||t({url:n,method:i,requestId:a,apiType:wi})}),Di.apply(this,arguments)}}function ji({onRequestEnd:e,onRequestStart:t}){Oi||=window.fetch,window.fetch=function(){let n=zt(arguments[0])??``,r=Rt(n),i=(arguments[1]??{}).method,a=be();return r||t({url:n,method:i,requestId:a,apiType:Ci}),Oi.apply(this,arguments).then(t=>(r||e({url:n,method:i,requestId:a,apiType:Ci}),t)).catch(t=>{throw r||e({url:n,method:i,requestId:a,apiType:Ci}),t})}}var Mi,Ni=!1;function Pi(){return Mi||=new N,Ni||=(li.subscribe(e=>{e.type===`resource`&&Mi.notify({type:Tn})}),!0),Mi}var Fi=100,Ii=1e4,Li=class{constructor(e,t,n=100){this.userAction=e,this.logDebug=t,this.initialActivityTimeout=n,this.http=ki(),this.dom=Si(),this.perf=Pi(),this.isValid=!1,this.runningRequests=new Map}attach(){this.allMonitorsSub=new N().merge(this.http,this.dom,this.perf).takeWhile(()=>[z.Started,z.Halted].includes(this.userAction.getState())).filter(e=>!(this.userAction.getState()===z.Halted&&!(yi(e)&&this.runningRequests.has(e.request.requestId)))).subscribe(e=>{vi(e)&&this.runningRequests.set(e.request.requestId,e.request),yi(e)&&this.runningRequests.delete(e.request.requestId),yi(e)?this.userAction.getState()===z.Halted&&this.runningRequests.size===0&&this.endAction():(this.isValid||(this.isValid=!0,this.clearTimer(this.startupTid)),this.scheduleFollowUp())}),this.stateSub=this.userAction.filter(e=>[z.Ended,z.Cancelled].includes(e)).first().subscribe(()=>this.cleanup()),this.startupTid=_i(this.startupTid,()=>{this.logDebug(`User action not sent; no DOM, resource, or HTTP activity:`,this.userAction.name),this.cancelAction()},this.initialActivityTimeout)}scheduleFollowUp(){this.clearTimer(this.followUpTid),this.followUpTid=window.setTimeout(()=>{if(this.userAction.getState()===z.Started&&this.runningRequests.size>0){this.haltAction();return}if(this.isValid){this.endAction();return}this.cancelAction()},Fi)}haltAction(){this.userAction.getState()===z.Started&&(this.userAction.halt(),this.startHaltTimeout())}startHaltTimeout(){this.clearTimer(this.haltTid),this.haltTid=_i(this.haltTid,()=>{this.userAction.getState()===z.Halted&&this.endAction()},Ii)}endAction(){this.userAction.end(),this.cleanup()}cancelAction(){this.userAction.cancel(),this.cleanup()}cleanup(){var e,t;this.clearTimer(this.startupTid),this.clearTimer(this.followUpTid),this.clearTimer(this.haltTid),(e=this.allMonitorsSub)==null||e.unsubscribe(),(t=this.stateSub)==null||t.unsubscribe(),this.allMonitorsSub=void 0,this.stateSub=void 0,this.runningRequests.clear()}clearTimer(e){e!==void 0&&window.clearTimeout(e)}};function Ri(e,t=A){let{api:n,config:r,internalLogger:i}=e,a=hi(r.userActionsInstrumentation?.initialActivityTimeout,100,t);function o(e){let t=r.userActionsInstrumentation?.dataAttributeName??di,i=e.target;if(!(i instanceof Element))return;let a=zi(i,pi(t)),o=Vi(a,t);if(!a||!o)return;let s=Bi(a,t);n.startUserAction(o,{},{triggerName:e.type,initialActivityTimeout:s})}function s(e,n){let r=e,o=hi(n,a,t);new Li(r,i.debug,o).attach()}return{processUserEvent:o,processUserActionStarted:s}}function zi(e,t){let n=e;for(;n;){if(n.hasAttribute(t))return n;n=n.parentElement}return null}function Bi(e,t){let n=e.getAttribute(mi(t));return n===null?void 0:Number(n)}function Vi(e,t){if(!e)return;let n=gi(t),r=e.dataset;for(let e in r)if(e===n)return r[e]}var Hi=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-user-action`,this.version=F}initialize(){let{processUserEvent:e,processUserActionStarted:t}=Ri(V,e=>this.logWarn(e));this._processUserEvent=e,this._processKeydown=t=>{[` `,`Enter`].includes(t.key)&&e(t)},window.addEventListener(`pointerdown`,this._processUserEvent),window.addEventListener(`keydown`,this._processKeydown),this._userActionSub=Ue.subscribe(({type:e,userAction:n,initialActivityTimeout:r})=>{e===`user_action_start`&&t(n,r)})}destroy(){var e;this._processUserEvent&&window.removeEventListener(`pointerdown`,this._processUserEvent),this._processKeydown&&window.removeEventListener(`keydown`,this._processKeydown),(e=this._userActionSub)==null||e.unsubscribe()}},Ui=class extends B{constructor(){super(),this.name=`@grafana/faro-web-sdk:instrumentation-csp`,this.version=F,this.boundSecuritypolicyviolationHandler=this.securitypolicyviolationHandler.bind(this)}initialize(){document.addEventListener(`securitypolicyviolation`,this.boundSecuritypolicyviolationHandler)}destroy(){document.removeEventListener(`securitypolicyviolation`,this.boundSecuritypolicyviolationHandler)}securitypolicyviolationHandler(e){let t={blockedURI:e.blockedURI,columnNumber:e.columnNumber,disposition:e.disposition,documentURI:e.documentURI,effectiveDirective:e.effectiveDirective,lineNumber:e.lineNumber,originalPolicy:e.originalPolicy,referrer:e.referrer,sample:e.sample,sourceFile:e.sourceFile,statusCode:e.statusCode,violatedDirective:e.violatedDirective};this.api.pushEvent(`securitypolicyviolation`,Se(t))}};function Wi(e){return e.type===En}function Gi(e){return e.type===Dn}var Ki=class extends N{constructor(e,t){super(),this._tracking=!1,this.eventsObservable=e,this._options={inactivityMs:t?.inactivityMs??100,drainTimeoutMs:t?.drainTimeoutMs??1e4,isOperationStart:t?.isOperationStart??(()=>void 0),isOperationEnd:t?.isOperationEnd??(()=>void 0)},this._initialize()}_initialize(){this.eventsObservable.filter(()=>this._tracking).subscribe(e=>{var t;this._lastEventTime=pe(),(t=this._currentEvents)==null||t.push(e);let n=this._options.isOperationStart(e);if(n){var r;(r=this._activeOperations)==null||r.set(n,!0)}let i=this._options.isOperationEnd(e);if(i){var a;(a=this._activeOperations)==null||a.delete(i)}this._scheduleInactivityCheck()})}startTracking(){this._tracking||(this._tracking=!0,this._startTime=pe(),this._lastEventTime=this._startTime,this.notify({message:`tracking-started`}),this._currentEvents=[],this._activeOperations=new Map,this._scheduleInactivityCheck())}stopTracking(){this._tracking=!1,this._clearTimer(this._inactivityTid),this._clearTimer(this._drainTid);let e;e=this.hasActiveOperations()?pe()-this._startTime:this._lastEventTime?this._lastEventTime-this._startTime:0,this.notify({message:`tracking-ended`,events:this._currentEvents,duration:e})}_scheduleInactivityCheck(){this._inactivityTid=qi(this._inactivityTid,()=>{this.hasActiveOperations()?this._startDrainTimeout():this.stopTracking()},this._options.inactivityMs)}_startDrainTimeout(){this._drainTid=qi(this._drainTid,()=>{this.stopTracking()},this._options.drainTimeoutMs)}hasActiveOperations(){return!!this._activeOperations&&this._activeOperations.size>0}_clearTimer(e){e&&clearTimeout(e)}};function qi(e,t,n){return e&&clearTimeout(e),e=setTimeout(()=>{t()},n),e}var Ji=`interaction`,Yi,Xi=new Set,Zi=new Map;function Qi(e){return Yi||=new N,e.forEach(e=>{if(!Xi.has(e)){let t=()=>{Yi.notify({type:Ji,name:e})};window.addEventListener(e,t),Xi.add(e),Zi.set(e,t)}}),Yi}var $i=`url-change`,ea,ta=!1,na,ra,ia,aa,oa,sa,ca;function la(){ea||(ea=new N,na=location.href);function e(e,t){let n=t??location.href;n!==na&&(ea.notify({type:$i,from:na,to:n,trigger:e}),na=n)}if(!ta){if(`navigation`in window&&`NavigateEvent`in window){sa=t=>{try{let n=t?.destination;n?.sameDocument&&typeof n.url==`string`&&e(`navigate`,n.url)}catch{}},window.navigation.addEventListener(`navigate`,sa);let t=window.NavigateEvent;t&&t.prototype&&typeof t.prototype.intercept==`function`&&(ca||=t.prototype.intercept,t.prototype.intercept=function(t){try{let t=!!this?.canIntercept,n=this?.destination;t&&n&&n.sameDocument===!1&&typeof n.url==`string`&&e(`navigate-intercept`,n.url)}catch{}return ca.call(this,t)}),ta=!0}else ra||=window.history.pushState,window.history.pushState=function(...t){let n=ra.apply(window.history,t);return e(`pushState`),n},ia||=window.history.replaceState,window.history.replaceState=function(...t){let n=ia.apply(window.history,t);return e(`replaceState`),n},aa=()=>e(`popstate`),oa=()=>e(`hashchange`),window.addEventListener(`popstate`,aa),window.addEventListener(`hashchange`,oa),ta=!0}return ea}var ua=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-navigation`,this.version=F}initialize(){let e=ki(),t=Si(),n=la(),r=Qi([`pointerdown`,`keydown`]),i=new Ki(new N().merge(e,t,n),{inactivityMs:100,drainTimeoutMs:1e4,isOperationStart:e=>Wi(e)?e.request.requestId:void 0,isOperationEnd:e=>Gi(e)?e.request.requestId:void 0});i.filter(e=>e.message===`tracking-ended`).subscribe(e=>{if(e.events?.some(e=>e.type===`url-change`)&&e.events?.some(e=>e.type===`dom-mutation`)){let t=e.events?.find(e=>e.type===`url-change`);V.api.pushEvent(`faro.navigation`,{fromUrl:t?.from,toUrl:t?.to,sameDocument:`true`,duration:e.duration})}}),r.subscribe(()=>{i.startTracking()})}};function da(e={}){let t=[new Hi,new qn,new Kr,new fn,new Jn,new ua];return e.enablePerformanceInstrumentation!==!1&&t.unshift(new ui),e.enableContentSecurityPolicyInstrumentation!==!1&&t.push(new Ui),e.captureConsole!==!1&&t.push(new Un),t}var fa=e(((e,t)=>{(function(n,r){var i=`1.0.41`,a=``,o=`function`,s=`undefined`,c=`object`,l=`string`,u=`major`,d=`model`,f=`name`,p=`type`,m=`vendor`,h=`version`,g=`architecture`,_=`console`,v=`mobile`,y=`tablet`,b=`smarttv`,x=`wearable`,S=`embedded`,C=`Amazon`,ee=`Apple`,te=`ASUS`,ne=`BlackBerry`,re=`Browser`,ie=`Chrome`,w=`Edge`,T=`Firefox`,E=`Google`,ae=`Honor`,oe=`Huawei`,se=`Lenovo`,ce=`LG`,le=`Microsoft`,ue=`Motorola`,de=`Nvidia`,fe=`OnePlus`,D=`Opera`,O=`OPPO`,k=`Samsung`,pe=`Sharp`,me=`Sony`,he=`Xiaomi`,ge=`Zebra`,_e=`Facebook`,A=`Chromium OS`,ve=`Mac OS`,ye=` Browser`,be=function(e,t){var n={};for(var r in e)n[r]=t[r]&&t[r].length%2==0?t[r].concat(e[r]):e[r];return n},j=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},xe=function(e,t){return typeof e==l&&M(t).indexOf(M(e))!==-1},M=function(e){return e.toLowerCase()},Se=function(e){return typeof e==l?e.replace(/[^\d\.]/g,a).split(`.`)[0]:r},N=function(e,t){if(typeof e==l)return e=e.replace(/^\s\s*/,a),typeof t===s?e:e.substring(0,500)},Ce=function(e,t){for(var n=0,i,a,s,l,u,d;n<t.length&&!u;){var f=t[n],p=t[n+1];for(i=a=0;i<f.length&&!u&&f[i];)if(u=f[i++].exec(e),u)for(s=0;s<p.length;s++)d=u[++a],l=p[s],typeof l==c&&l.length>0?l.length===2?typeof l[1]==o?this[l[0]]=l[1].call(this,d):this[l[0]]=l[1]:l.length===3?typeof l[1]===o&&!(l[1].exec&&l[1].test)?this[l[0]]=d?l[1].call(this,d,l[2]):r:this[l[0]]=d?d.replace(l[1],l[2]):r:l.length===4&&(this[l[0]]=d?l[3].call(this,d.replace(l[1],l[2])):r):this[l]=d||r;n+=2}},P=function(e,t){for(var n in t)if(typeof t[n]==c&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(xe(t[n][i],e))return n===`?`?r:n}else if(xe(t[n],e))return n===`?`?r:n;return t.hasOwnProperty(`*`)?t[`*`]:e},we={"1.0":`/8`,"1.2":`/1`,"1.3":`/3`,"2.0":`/412`,"2.0.2":`/416`,"2.0.3":`/417`,"2.0.4":`/419`,"?":`/`},Te={ME:`4.90`,"NT 3.11":`NT3.51`,"NT 4.0":`NT4.0`,2e3:`NT 5.0`,XP:[`NT 5.1`,`NT 5.2`],Vista:`NT 6.0`,7:`NT 6.1`,8:`NT 6.2`,"8.1":`NT 6.3`,10:[`NT 6.4`,`NT 10.0`],RT:`ARM`},F={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[h,[f,`Chrome`]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[h,[f,`Edge`]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[f,h],[/opios[\/ ]+([\w\.]+)/i],[h,[f,D+` Mini`]],[/\bop(?:rg)?x\/([\w\.]+)/i],[h,[f,D+` GX`]],[/\bopr\/([\w\.]+)/i],[h,[f,D]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[h,[f,`Baidu`]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[h,[f,`Maxthon`]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[f,h],[/quark(?:pc)?\/([-\w\.]+)/i],[h,[f,`Quark`]],[/\bddg\/([\w\.]+)/i],[h,[f,`DuckDuckGo`]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[h,[f,`UC`+re]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[h,[f,`WeChat`]],[/konqueror\/([\w\.]+)/i],[h,[f,`Konqueror`]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[h,[f,`IE`]],[/ya(?:search)?browser\/([\w\.]+)/i],[h,[f,`Yandex`]],[/slbrowser\/([\w\.]+)/i],[h,[f,`Smart Lenovo `+re]],[/(avast|avg)\/([\w\.]+)/i],[[f,/(.+)/,`$1 Secure `+re],h],[/\bfocus\/([\w\.]+)/i],[h,[f,T+` Focus`]],[/\bopt\/([\w\.]+)/i],[h,[f,D+` Touch`]],[/coc_coc\w+\/([\w\.]+)/i],[h,[f,`Coc Coc`]],[/dolfin\/([\w\.]+)/i],[h,[f,`Dolphin`]],[/coast\/([\w\.]+)/i],[h,[f,D+` Coast`]],[/miuibrowser\/([\w\.]+)/i],[h,[f,`MIUI`+ye]],[/fxios\/([\w\.-]+)/i],[h,[f,T]],[/\bqihoobrowser\/?([\w\.]*)/i],[h,[f,`360`]],[/\b(qq)\/([\w\.]+)/i],[[f,/(.+)/,`$1Browser`],h],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[f,/(.+)/,`$1`+ye],h],[/samsungbrowser\/([\w\.]+)/i],[h,[f,k+` Internet`]],[/metasr[\/ ]?([\d\.]+)/i],[h,[f,`Sogou Explorer`]],[/(sogou)mo\w+\/([\d\.]+)/i],[[f,`Sogou Mobile`],h],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[f,h],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[f],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[h,f],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[f,_e],h],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[f,h],[/\bgsa\/([\w\.]+) .*safari\//i],[h,[f,`GSA`]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[h,[f,`TikTok`]],[/headlesschrome(?:\/([\w\.]+)| )/i],[h,[f,ie+` Headless`]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[f,ie+` WebView`],h],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[h,[f,`Android `+re]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[f,h],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[h,[f,`Mobile Safari`]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[h,f],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[f,[h,P,we]],[/(webkit|khtml)\/([\w\.]+)/i],[f,h],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[f,`Netscape`],h],[/(wolvic|librewolf)\/([\w\.]+)/i],[f,h],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[h,[f,T+` Reality`]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[f,[h,/_/g,`.`]],[/(cobalt)\/([\w\.]+)/i],[f,[h,/master.|lts./,``]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[g,`amd64`]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[g,`ia32`]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[g,`arm64`]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[g,`armhf`]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[g,`arm`]],[/((ppc|powerpc)(64)?)( mac|;|\))/i],[[g,/ower/,a,M]],[/ sun4\w[;\)]/i],[[g,`sparc`]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i],[[g,M]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[m,k],[p,y]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[d,[m,k],[p,v]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[m,ee],[p,v]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[m,ee],[p,y]],[/(macintosh);/i],[d,[m,ee]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[m,pe],[p,v]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[d,[m,ae],[p,y]],[/honor([-\w ]+)[;\)]/i],[d,[m,ae],[p,v]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[d,[m,oe],[p,y]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[m,oe],[p,v]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[d,/_/g,` `],[m,he],[p,y]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[d,/_/g,` `],[m,he],[p,v]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[m,O],[p,v]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[d,[m,P,{OnePlus:[`304`,`403`,`203`],"*":O}],[p,y]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[m,`Vivo`],[p,v]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[m,`Realme`],[p,v]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto(?! 360)[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[m,ue],[p,v]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[m,ue],[p,y]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[m,ce],[p,y]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv|watch)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[m,ce],[p,v]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[d,[m,se],[p,y]],[/(nokia) (t[12][01])/i],[m,d,[p,y]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*))/i],[[d,/_/g,` `],[p,v],[m,`Nokia`]],[/(pixel (c|tablet))\b/i],[d,[m,E],[p,y]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[m,E],[p,v]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[m,me],[p,v]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,`Xperia Tablet`],[m,me],[p,y]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[m,fe],[p,v]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[m,C],[p,y]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,`Fire Phone $1`],[m,C],[p,v]],[/(playbook);[-\w\),; ]+(rim)/i],[d,m,[p,y]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[m,ne],[p,v]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[m,te],[p,y]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[m,te],[p,v]],[/(nexus 9)/i],[d,[m,`HTC`],[p,y]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[m,[d,/_/g,` `],[p,v]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[d,[m,`TCL`],[p,y]],[/(itel) ((\w+))/i],[[m,M],d,[p,P,{tablet:[`p10001l`,`w7001`],"*":`mobile`}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[m,`Acer`],[p,y]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[m,`Meizu`],[p,v]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[m,`Ulefone`],[p,v]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[m,`Energizer`],[p,v]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[m,`Cat`],[p,v]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[m,`Smartfren`],[p,v]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[m,`Nothing`],[p,v]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[d,[m,`Archos`],[p,y]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[d,[m,`Archos`],[p,v]],[/(imo) (tab \w+)/i,/(infinix) (x1101b?)/i],[m,d,[p,y]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (hmd|imo) ([\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,/(oppo) ?([\w ]+) bui/i],[m,d,[p,v]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[m,d,[p,y]],[/(surface duo)/i],[d,[m,le],[p,y]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[m,`Fairphone`],[p,v]],[/(u304aa)/i],[d,[m,`AT&T`],[p,v]],[/\bsie-(\w*)/i],[d,[m,`Siemens`],[p,v]],[/\b(rct\w+) b/i],[d,[m,`RCA`],[p,y]],[/\b(venue[\d ]{2,7}) b/i],[d,[m,`Dell`],[p,y]],[/\b(q(?:mv|ta)\w+) b/i],[d,[m,`Verizon`],[p,y]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[m,`Barnes & Noble`],[p,y]],[/\b(tm\d{3}\w+) b/i],[d,[m,`NuVision`],[p,y]],[/\b(k88) b/i],[d,[m,`ZTE`],[p,y]],[/\b(nx\d{3}j) b/i],[d,[m,`ZTE`],[p,v]],[/\b(gen\d{3}) b.+49h/i],[d,[m,`Swiss`],[p,v]],[/\b(zur\d{3}) b/i],[d,[m,`Swiss`],[p,y]],[/\b((zeki)?tb.*\b) b/i],[d,[m,`Zeki`],[p,y]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[m,`Dragon Touch`],d,[p,y]],[/\b(ns-?\w{0,9}) b/i],[d,[m,`Insignia`],[p,y]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[m,`NextBook`],[p,y]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[m,`Voice`],d,[p,v]],[/\b(lvtel\-)?(v1[12]) b/i],[[m,`LvTel`],d,[p,v]],[/\b(ph-1) /i],[d,[m,`Essential`],[p,v]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[m,`Envizen`],[p,y]],[/\b(trio[-\w\. ]+) b/i],[d,[m,`MachSpeed`],[p,y]],[/\btu_(1491) b/i],[d,[m,`Rotor`],[p,y]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[d,[m,de],[p,y]],[/(sprint) (\w+)/i],[m,d,[p,v]],[/(kin\.[onetw]{3})/i],[[d,/\./g,` `],[m,le],[p,v]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[m,ge],[p,y]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[m,ge],[p,v]],[/smart-tv.+(samsung)/i],[m,[p,b]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,`SmartTV`],[m,k],[p,b]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[m,ce],[p,b]],[/(apple) ?tv/i],[m,[d,ee+` TV`],[p,b]],[/crkey/i],[[d,ie+`cast`],[m,E],[p,b]],[/droid.+aft(\w+)( bui|\))/i],[d,[m,C],[p,b]],[/(shield \w+ tv)/i],[d,[m,de],[p,b]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[m,pe],[p,b]],[/(bravia[\w ]+)( bui|\))/i],[d,[m,me],[p,b]],[/(mi(tv|box)-?\w+) bui/i],[d,[m,he],[p,b]],[/Hbbtv.*(technisat) (.*);/i],[m,d,[p,b]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[m,N],[d,N],[p,b]],[/droid.+; ([\w- ]+) (?:android tv|smart[- ]?tv)/i],[d,[p,b]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[p,b]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[m,d,[p,_]],[/droid.+; (shield)( bui|\))/i],[d,[m,de],[p,_]],[/(playstation \w+)/i],[d,[m,me],[p,_]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[m,le],[p,_]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[d,[m,k],[p,x]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[m,d,[p,x]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[d,[m,O],[p,x]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[m,ee],[p,x]],[/(opwwe\d{3})/i],[d,[m,fe],[p,x]],[/(moto 360)/i],[d,[m,ue],[p,x]],[/(smartwatch 3)/i],[d,[m,me],[p,x]],[/(g watch r)/i],[d,[m,ce],[p,x]],[/droid.+; (wt63?0{2,3})\)/i],[d,[m,ge],[p,x]],[/droid.+; (glass) \d/i],[d,[m,E],[p,x]],[/(pico) (4|neo3(?: link|pro)?)/i],[m,d,[p,x]],[/; (quest( \d| pro)?)/i],[d,[m,_e],[p,x]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[m,[p,S]],[/(aeobc)\b/i],[d,[m,C],[p,S]],[/(homepod).+mac os/i],[d,[m,ee],[p,S]],[/windows iot/i],[[p,S]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[p,v]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[p,y]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[p,y]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[p,v]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[d,[m,`Generic`]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[h,[f,w+`HTML`]],[/(arkweb)\/([\w\.]+)/i],[f,h],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[h,[f,`Blink`]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[f,h],[/ladybird\//i],[[f,`LibWeb`]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[h,f]],os:[[/microsoft (windows) (vista|xp)/i],[f,h],[/(windows (?:phone(?: os)?|mobile|iot))[\/ ]?([\d\.\w ]*)/i],[f,[h,P,Te]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[h,P,Te],[f,`Windows`]],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[h,/_/g,`.`],[f,`iOS`]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[f,ve],[h,/_/g,`.`]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[h,f],[/(ubuntu) ([\w\.]+) like android/i],[[f,/(.+)/,`$1 Touch`],h],[/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen|webos)\w*[-\/; ]?([\d\.]*)/i],[f,h],[/\(bb(10);/i],[h,[f,ne]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[h,[f,`Symbian`]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[h,[f,T+` OS`]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[h,[f,`webOS`]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[h,[f,`watchOS`]],[/crkey\/([\d\.]+)/i],[h,[f,ie+`cast`]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[f,A],h],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux)(?: arm\w*| x86\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[f,h],[/(sunos) ?([\w\.\d]*)/i],[[f,`Solaris`],h],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[f,h]]},I=function(e,t){if(typeof e==c&&(t=e,e=r),!(this instanceof I))return new I(e,t).getResult();var i=typeof n!==s&&n.navigator?n.navigator:r,_=e||(i&&i.userAgent?i.userAgent:a),b=i&&i.userAgentData?i.userAgentData:r,x=t?be(F,t):F,S=i&&i.userAgent==_;return this.getBrowser=function(){var e={};return e[f]=r,e[h]=r,Ce.call(e,_,x.browser),e[u]=Se(e[h]),S&&i&&i.brave&&typeof i.brave.isBrave==o&&(e[f]=`Brave`),e},this.getCPU=function(){var e={};return e[g]=r,Ce.call(e,_,x.cpu),e},this.getDevice=function(){var e={};return e[m]=r,e[d]=r,e[p]=r,Ce.call(e,_,x.device),S&&!e[p]&&b&&b.mobile&&(e[p]=v),S&&e[d]==`Macintosh`&&i&&typeof i.standalone!==s&&i.maxTouchPoints&&i.maxTouchPoints>2&&(e[d]=`iPad`,e[p]=y),e},this.getEngine=function(){var e={};return e[f]=r,e[h]=r,Ce.call(e,_,x.engine),e},this.getOS=function(){var e={};return e[f]=r,e[h]=r,Ce.call(e,_,x.os),S&&!e[f]&&b&&b.platform&&b.platform!=`Unknown`&&(e[f]=b.platform.replace(/chrome os/i,A).replace(/macos/i,ve)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return _},this.setUA=function(e){return _=typeof e==l&&e.length>500?N(e,500):e,this},this.setUA(_),this};I.VERSION=i,I.BROWSER=j([f,h,u]),I.CPU=j([g]),I.DEVICE=j([d,m,p,_,v,b,y,x,S]),I.ENGINE=I.OS=j([f,h]),typeof e===s?typeof define===o&&define.amd?define(function(){return I}):typeof n!==s&&(n.UAParser=I):(typeof t!==s&&t.exports&&(e=t.exports=I),e.UAParser=I);var Ee=typeof n!==s&&(n.jQuery||n.Zepto);if(Ee&&!Ee.ua){var L=new I;Ee.ua=L.getResult(),Ee.ua.get=function(){return L.getUA()},Ee.ua.set=function(e){L.setUA(e);var t=L.getResult();for(var n in t)Ee.ua[n]=t[n]}}})(typeof window==`object`?window:e)}))(),pa,ma;function ha(){let e=typeof navigator<`u`?navigator.userAgent:``;return(pa!==e||!ma)&&(ma=new fa.UAParser(e).getResult(),pa=e),ma}var ga=()=>{let{browser:e,os:t,ua:n}=ha(),{name:r,version:i}=e,{name:a,version:o}=t,s=navigator.language,c=n.includes(`Mobi`),l=u();return{browser:{name:r??b,version:i??b,os:`${a??b} ${o??b}`,userAgent:n??b,language:s??b,mobile:c,brands:l??b,viewportWidth:`${window.innerWidth}`,viewportHeight:`${window.innerHeight}`}};function u(){if(r&&i&&`userAgentData`in navigator&&navigator.userAgentData)return navigator.userAgentData.brands}},_a=()=>{let{name:e,version:t}=ha().os;if(!e&&!t)return{};let n={};return e&&(n.name=e),t&&(n.version=t),{os:n}},va=()=>({sdk:{name:`faro-web`,version:F}}),ya=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0-9]{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT$/,ba=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), ([0-9]{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT$/,xa=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?:(?:([0-9]{2}))|(?: ([0-9]))) ([0-9]{2}):([0-9]{2}):([0-9]{2}) ([0-9]{4})$/,Sa=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Ca=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],wa=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Ta({weekday:e,day:t,month:n,year:r,hour:i,minute:a,second:o}){if(r<1900||t<1||i>23||a>59||o>60)return;let s=o===60,c=new Date(0);if(c.setUTCFullYear(r,n,t),c.setUTCHours(i,a,s?59:o,0),c.getUTCDay()===e&&c.getUTCDate()===t&&c.getUTCMonth()===n&&c.getUTCFullYear()===r&&c.getUTCHours()===i&&c.getUTCMinutes()===a&&c.getUTCSeconds()===(s?59:o))return c.getTime()+(s?1e3:0)}function Ea(e,t){return e.month-t.month||e.day-t.day||e.hour-t.hour||e.minute-t.minute||e.second-t.second||e.millisecond-t.millisecond}function Da(e,t){let n=ya.exec(e);if(n){let[,e,t,r,i,a,o,s]=n;return Ta({weekday:Sa.indexOf(e),day:Number(t),month:wa.indexOf(r),year:Number(i),hour:Number(a),minute:Number(o),second:Number(s)})}let r=ba.exec(e);if(r){let[,e,n,i,a,o,s,c]=r,l=new Date(t);if(Number.isNaN(l.getTime()))return;let u=l.getUTCFullYear(),d=Math.floor(u/100)*100+Number(a);d<u&&(d+=100);let f=wa.indexOf(i),p={month:f,day:Number(n),hour:Number(o),minute:Number(s),second:Number(c),millisecond:0},m={month:l.getUTCMonth(),day:l.getUTCDate(),hour:l.getUTCHours(),minute:l.getUTCMinutes(),second:l.getUTCSeconds(),millisecond:l.getUTCMilliseconds()};return(d>u+50||d===u+50&&Ea(p,m)>0)&&(d-=100),Ta({weekday:Ca.indexOf(e),day:Number(n),month:f,year:d,hour:Number(o),minute:Number(s),second:Number(c)})}let i=xa.exec(e);if(!i)return;let[,a,o,s,c,l,u,d,f]=i;return Ta({weekday:Sa.indexOf(a),day:Number(s??c),month:wa.indexOf(o),year:Number(f),hour:Number(l),minute:Number(u),second:Number(d)})}var Oa=class{constructor(e){this.options=e,this.admitted=0,this.inProgress=0,this.sequence=0,this.nextSendAt=0,this.attemptQueue=[],this.waiting=[],this.unloading=!1}reserve(){var e=this;if(this.admitted>=this.options.bufferSize)return;this.admitted++;let t=this.sequence++,n=!1;return{deliver:function(){var n=Y(function*(n){let r=e.options.getNow(),i=0,a;for(;;){var o,s;let c=e.options.retry.maxAttempts-i,l=yield e.runAttempt(()=>n(c,e.unloading),i>0);if(i+=l.attemptsMade,l.kind===`success`)return{kind:`success`,attempts:i,elapsedTimeMs:e.options.getNow()-r};if(a=l.failure,l.kind===`terminal`||e.unloading)return{kind:`terminal`,attempts:i,elapsedTimeMs:e.options.getNow()-r,failure:a};if(i>=e.options.retry.maxAttempts)return{kind:`terminal`,attempts:i,elapsedTimeMs:e.options.getNow()-r,failure:a,reason:`retries-exhausted`};if(l.retryAfterMs!=null&&l.retryAfterMs>e.options.retry.maxBackoffMs)return{kind:`terminal`,attempts:i,elapsedTimeMs:e.options.getNow()-r,failure:a,reason:`retry-after-too-long`};let u=Math.min(l.retryAfterMs??e.options.retry.initialBackoffMs*e.options.retry.backoffMultiplier**(i-1),e.options.retry.maxBackoffMs);if((o=(s=e.options).onRetry)==null||o.call(s,u,i+1),yield e.waitForTurn(t,u)){let t=e.options.retry.maxAttempts-i,a=yield e.runAttempt(()=>n(t,!0));return i+=a.attemptsMade,{kind:a.kind===`success`?`success`:`terminal`,attempts:i,elapsedTimeMs:e.options.getNow()-r,failure:a.kind===`success`?void 0:a.failure}}}});return function(e){return n.apply(this,arguments)}}(),release:()=>{n||(n=!0,this.admitted--)}}}flush(){this.unloading=!0,this.nextSendAt=0;let e=this.waiting.splice(0);this.redeliveryTimer!=null&&(clearTimeout(this.redeliveryTimer),this.redeliveryTimer=void 0),this.waitingTimer!=null&&(clearTimeout(this.waitingTimer),this.waitingTimer=void 0);for(let t of e)t.resolve(!0);this.runNextAttempt()}resume(){this.unloading=!1}runAttempt(e,t=!1){return new Promise((n,r)=>{this.attemptQueue.push({run:()=>{this.inProgress++;let t=()=>{this.inProgress--,this.runNextAttempt()};e().then(e=>{t(),n(e)},e=>{t(),r(e)})},isRedelivery:t}),this.runNextAttempt()})}runNextAttempt(){for(this.redeliveryTimer!=null&&(clearTimeout(this.redeliveryTimer),this.redeliveryTimer=void 0);this.inProgress<this.options.concurrency&&this.attemptQueue.length>0;){let e=this.options.getNow(),t=this.attemptQueue.findIndex(({isRedelivery:t})=>this.unloading||!t||e>=this.nextSendAt);if(t<0){this.redeliveryTimer=setTimeout(()=>{this.redeliveryTimer=void 0,this.runNextAttempt()},Math.max(0,this.nextSendAt-e));return}let[n]=this.attemptQueue.splice(t,1);n.isRedelivery&&!this.unloading&&(this.nextSendAt=e+1),n.run()}}waitForTurn(e,t){let n=Math.min(t*(1+this.options.getRandom()*.2),this.options.retry.maxBackoffMs);return new Promise(t=>{this.waiting.push({sequence:e,readyAt:this.options.getNow()+n,resolve:t}),this.waiting.sort((e,t)=>e.readyAt===t.readyAt?e.sequence-t.sequence:e.readyAt-t.readyAt),this.waitingTimer!=null&&(clearTimeout(this.waitingTimer),this.waitingTimer=void 0),this.scheduleNext()})}scheduleNext(){if(this.waitingTimer!=null||this.waiting.length===0)return;let e=this.waiting[0],t=e.readyAt;this.waitingTimer=setTimeout(()=>{this.waitingTimer=void 0;let t=this.waiting.indexOf(e);t>=0&&this.waiting.splice(t,1),e.resolve(!1),this.scheduleNext()},Math.max(0,t-this.options.getNow()))}};function ka(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function Aa(e,t){if(e==null)return{};var n,r,i=ka(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var ja=[`headers`],Ma=[`keepalive`,`signal`],Na=30,Pa=5,Fa=3,Ia=1e3,La=3e4,Ra=2,za=1e4,Ba=new Set([408,425,429,500,502,503,504]),Va=new Set([429,503]),Ha=6e4,Ua=9,Wa=202,Ga=0,Ka=0,qa=class extends Error{};function Ja(e){return typeof TextEncoder>`u`?e.length:new TextEncoder().encode(e).byteLength}var Ya=class extends Pe{constructor(e){super(),this.options=e,this.name=`@grafana/faro-web-sdk:transport-fetch`,this.version=F,this.pendingCustomSends=0,this.getNow=e.getNow??Date.now,this.requestTimeoutMs=e.requestTimeoutMs??za,this.compressionEnabled=(e.requestCompression??!1)&&typeof CompressionStream<`u`,e.requestCompression&&!this.compressionEnabled&&this.logWarn(`requestCompression is enabled but CompressionStream is not available. Falling back to uncompressed.`),this.requestTimeoutMs>0&&typeof AbortController>`u`&&this.logWarn(`AbortController is unavailable. Requests will be sent without the configured timeout.`),this.deliveryQueue=new Oa({bufferSize:e.bufferSize??Na,concurrency:e.concurrency??Pa,retry:{maxAttempts:e.retry?.maxAttempts??Fa,initialBackoffMs:e.retry?.initialBackoffMs??e.defaultRateLimitBackoffMs??Ia,maxBackoffMs:e.retry?.maxBackoffMs??La,backoffMultiplier:e.retry?.backoffMultiplier??Ra},getNow:this.getNow,getRandom:e.getRandom??Math.random,onRetry:(e,t)=>{this.logDebug(`Retrying failed request after ${e}ms. Attempt ${t}.`)}}),this.customPromiseBuffer=ve({size:e.bufferSize??Na,concurrency:e.concurrency??Pa}),this.defaultPromiseBuffer={add:e=>{if(this.promiseBuffer!==this.defaultPromiseBuffer||this.promiseBuffer.add!==this.defaultBufferAdd||this.pendingCustomSends>0)return this.customPromiseBuffer.add(e);let t=this.deliveryQueue.reserve();if(!t)throw Error(`Task buffer full`);return this.runBufferedTask(t,e)}},this.defaultBufferAdd=this.defaultPromiseBuffer.add,this.promiseBuffer=this.defaultPromiseBuffer,typeof window<`u`&&(window.addEventListener(`pagehide`,()=>this.deliveryQueue.flush()),window.addEventListener(`pageshow`,e=>{e.persisted&&this.deliveryQueue.resume()}))}send(e){var t=this;return Y(function*(){let n=t.promiseBuffer;if(n===t.defaultPromiseBuffer&&n.add===t.defaultBufferAdd){yield t.deliver(e);return}t.pendingCustomSends++;try{yield n.add(()=>t.deliver(e))}catch(e){t.logError(`Permanent delivery failure`,{error:e,attempts:0,elapsedTimeMs:0})}finally{t.pendingCustomSends--}})()}runBufferedTask(e,t){return Y(function*(){let n;try{return yield e.deliver(Y(function*(){return n=yield t(),{kind:`success`,attemptsMade:1}})),n}finally{e.release()}})()}deliver(e){var t=this;return Y(function*(){let n=t.deliveryQueue.reserve();if(!n){t.logError(`Permanent delivery failure`,{error:`Reliable delivery queue is full`,attempts:0,elapsedTimeMs:0});return}try{let r=yield t.prepareRequest(e),i=yield n.deliver((e,n)=>t.performAttempt(r,e,n));i.kind===`terminal`&&t.logError(i.reason===`retries-exhausted`?`Delivery retries exhausted`:`Permanent delivery failure`,W(W({},i.failure),{},{reason:i.reason,attempts:i.attempts,elapsedTimeMs:i.elapsedTimeMs}))}catch(e){t.logError(`Permanent delivery failure`,{error:e,attempts:0,elapsedTimeMs:0})}finally{n.release()}})()}getIgnoreUrls(){return[this.options.url].concat(this.config.ignoreUrls??[])}isBatched(){return!0}prepareRequest(e){var t=this;return Y(function*(){let n=Ie(e),r=n.meta.session?.id,i=JSON.stringify(n),a=t.options.requestOptions??{},{headers:o={}}=a,s=Aa(a,ja),{keepalive:c,signal:l}=s,u=Aa(s,Ma),d={};for(let[e,t]of Object.entries(o))d[e]=typeof t==`function`?yield t():t;let f=i,p=Ja(i),m={};return t.compressionEnabled&&(f=yield t.compress(i),p=f.size,m[`Content-Encoding`]=`gzip`),{bodySize:p,sessionId:r,requestInit:W({method:`POST`,headers:W(W(W(W(W({"Content-Type":`application/json`},m),d),t.options.apiKey?{"x-api-key":t.options.apiKey}:{}),r?{"x-faro-session-id":r}:{}),{},{"Idempotency-Key":be(20)}),body:f},u)}})()}performAttempt(e,t,n){var r=this;return Y(function*(){let i=r.options.requestOptions?.signal;if(i?.aborted)return{kind:`terminal`,failure:{error:i.reason},attemptsMade:0};let a=0;try{let i=yield r.fetchWithKeepaliveFallback(e.requestInit,e.bodySize,n?!0:r.options.requestOptions?.keepalive,t,()=>a++);if(r.handleResponse(i,e.sessionId),i.status>=200&&i.status<300)return{kind:`success`,attemptsMade:a};let o={status:i.status};return!Ba.has(i.status)||n?{kind:`terminal`,failure:o,attemptsMade:a}:{kind:`retry`,failure:o,attemptsMade:a,retryAfterMs:Va.has(i.status)?r.getRetryAfterDelayMs(i):void 0}}catch(e){let t={error:e};return i?.aborted||!r.isFetchNetworkError(e)||n?{kind:`terminal`,failure:t,attemptsMade:a}:{kind:`retry`,failure:t,attemptsMade:a}}})()}fetchWithKeepaliveFallback(e,t,n,r,i){var a=this;return Y(function*(){let o=a.getNow(),s=a.reserveKeepalive(t,n);try{return yield a.fetchWithTimeout(W(W({},e),{},{keepalive:s.keepalive}),a.requestTimeoutMs,i)}catch(t){var c;if(s.keepalive&&r>1&&a.isFetchNetworkError(t)&&!(t instanceof qa)&&!((c=a.options.requestOptions)!=null&&(c=c.signal)!=null&&c.aborted)){a.logDebug(`Retrying failed keepalive request with keepalive disabled.`);let t=a.requestTimeoutMs-(a.getNow()-o);return a.fetchWithTimeout(W(W({},e),{},{keepalive:!1}),t,i)}throw t}finally{s.release()}})()}fetchWithTimeout(e,t,n){var r=this;return Y(function*(){let i=r.options.requestOptions?.signal;if(r.requestTimeoutMs<=0||typeof AbortController>`u`)return n(),fetch(r.options.url,W(W({},e),{},{signal:i}));if(t<=0)throw new qa(`Request timed out`);let a=new AbortController,o=()=>a.abort(i?.reason);i?.addEventListener(`abort`,o,{once:!0});let s=!1,c=setTimeout(()=>{s=!0,a.abort()},t);try{return n(),yield fetch(r.options.url,W(W({},e),{},{signal:a.signal}))}catch(e){throw s&&!i?.aborted?new qa(`Request timed out`):e}finally{clearTimeout(c),i?.removeEventListener(`abort`,o)}})()}getRetryAfterDelayMs(e){let t=e.headers.get(`Retry-After`);if(!t)return;if(/^\d+$/.test(t)){let e=Number(t)*1e3;return Number.isFinite(e)?e:1/0}let n=this.getNow(),r=Da(t,n);return r==null?void 0:Math.max(0,r-n)}reserveKeepalive(e,t){if(t===!1||e>Ha||Ga+e>Ha||Ka>=Ua)return{keepalive:!1,release:A};Ga+=e,Ka++;let n=!1;return{keepalive:!0,release:()=>{n||(n=!0,Ga-=e,Ka--)}}}handleResponse(e,t){e.status===Wa&&e.headers.get(`X-Faro-Session-Status`)===`invalid`&&this.extendFaroSession(this.config,this.logDebug.bind(this),t),e.text().catch(A)}isFetchNetworkError(e){return e instanceof TypeError||e instanceof qa||e instanceof DOMException&&e.name===`AbortError`}compress(e){return Y(function*(){let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}).pipeThrough(new CompressionStream(`gzip`)),n=[],r=t.getReader();for(;;){let{done:e,value:t}=yield r.read();if(e)return new Blob(n);n.push(t)}})()}extendFaroSession(e,t,n){let r=e.sessionTracking;if(!r?.enabled){t(`Session expired.`);return}let{fetchUserSession:i,storeUserSession:a}=dn(r),o=this.metas.value.session?.id,s=i()?.sessionId;if(!n||n!==o||n!==s){t(`Ignoring stale or cross-tab session-invalid response; request session no longer current.`);return}tn({fetchUserSession:i,storeUserSession:a})({forceSessionExtend:!0}),t(`Session expired; created new session.`)}},Xa=()=>{let e=window.k6;return{k6:W({isK6Browser:!0},e?.testRunId&&{testRunId:e?.testRunId})}},Za,Qa;function $a({generatePageId:e,initialPageMeta:t}={}){return()=>{let n=location.href;return T(e)&&Za!==n&&(Za=n,Qa=e(location)),{page:W(W({url:n},Qa?{id:Qa}:{}),t)}}}var eo=[`dedupe`,`eventDomain`,`globalObjectKey`,`instrumentations`,`internalLoggerLevel`,`isolate`,`logArgsSerializer`,`metas`,`paused`,`preventGlobalExposure`,`unpatchedConsole`,`url`,`experimental`];function to(e){let t=[],n=Me(e.unpatchedConsole,e.internalLoggerLevel);e.transports?((e.url||e.apiKey)&&n.error(`if "transports" is defined, "url" and "apiKey" should not be defined`),t.push(...e.transports)):e.url?t.push(new Ya({url:e.url,apiKey:e.apiKey,requestCompression:e.requestCompression})):n.error(`either "url" or "transports" must be defined`);let{dedupe:r=!0,eventDomain:i=m,globalObjectKey:a=At,instrumentations:o=da(),internalLoggerLevel:s=1,isolate:c=!1,logArgsSerializer:l=Je,metas:u=ro(e),paused:d=!1,preventGlobalExposure:f=!1,unpatchedConsole:p=je,url:h,experimental:g}=e,_=Aa(e,eo),v=g?.trackNavigation??!1,b={dataAttributeName:pi(e.userActionsInstrumentation?.dataAttributeName??di),excludeItem:e.userActionsInstrumentation?.excludeItem,initialActivityTimeout:hi(e.userActionsInstrumentation?.initialActivityTimeout,100,e=>n.warn(e))};return W(W({},_),{},{batching:W(W({},jt),e.batching),dedupe:r,globalObjectKey:a,instrumentations:no(o,e),internalLoggerLevel:s,isolate:c,logArgsSerializer:l,metas:u,parseStacktrace:wn,paused:d,preventGlobalExposure:f,transports:t,unpatchedConsole:p,eventDomain:i,ignoreUrls:[...e.ignoreUrls??[],...h?[h]:[],/\/collect(?:\/[\w]*)?$/],sessionTracking:W(W(W({},y),e.sessionTracking),io({trackGeolocation:e.trackGeolocation,sessionTracking:e.sessionTracking})),userActionsInstrumentation:b,experimental:{trackNavigation:v}})}function no(e,{experimental:t}){let n=t?.trackNavigation??!1;return e.filter(e=>!(e.name===`@grafana/faro-web-sdk:instrumentation-navigation`&&!n))}function ro(e){let{page:t,generatePageId:n}=e?.pageTracking??{},r=[ga,_a,$a({generatePageId:n,initialPageMeta:t}),...e.metas??[],va];return w(window?.k6)?[...r,Xa]:r}function io({trackGeolocation:e,sessionTracking:t}){let n={};return ie(e)&&(n.geoLocationTrackingEnabled=e),D(n)?{}:{session:W(W({},t?.session??{}),{},{overrides:n})}}function ao(e){let t=to(e);if(t)return kt(t)}var X=null;function oo(e={}){if(typeof window>`u`)return null;if(X)return X;try{let t=e.collectorUrl||typeof process<`u`&&{}.PUBLIC_FARO_URL||``;X=ao({url:t||`http://127.0.0.1:12347/collect`,app:{name:e.appName||`mcard-studio`,version:e.appVersion||`0.2.0`,environment:e.environment||`development`},paused:!t,isolate:!1});let n=[],r=[],i=X.api.pushMeasurement.bind(X.api);X.api.pushMeasurement=e=>(r.push(e),i(e));let a=X.api.pushError.bind(X.api);X.api.pushError=(e,t)=>(n.push({err:e,options:t}),a(e,t)),X.api.getErrors=()=>n,X.api.getMeasurements=()=>r;try{window.__CLM_CLS_METRIC__=0}catch{}try{window.__CLM_FARO_INITIALIZED__=!0}catch{}try{window.__FARO__=X}catch{}return console.log(`[Faro] Telemetry initialized cleanly in browser context`),X}catch(e){console.warn(`[Faro] Failed to initialize Grafana Faro SDK, falling back to mock:`,e);let t=[],n=[],r={api:{pushMeasurement:e=>{n.push(e)},pushError:e=>{t.push(e)},getErrors:()=>t,getMeasurements:()=>n}};try{window.__CLM_CLS_METRIC__=0}catch{}try{window.__FARO__=r}catch{}return r}}function so(){return!X&&typeof window<`u`?oo():X}var co=n([]);function Z(e,t,n,...r){let i=so(),a=typeof performance<`u`?performance.now():Date.now(),o=`span_${Date.now()}_${Math.random().toString(36).slice(2,7)}`;try{let s=n(...r),c=(typeof performance<`u`?performance.now():Date.now())-a;if(i)try{i.api.pushMeasurement({type:`flux_action_latency`,values:{duration_ms:c},context:{action:e}})}catch{}let l=co.get(),u=[{id:o,action:e,payload:t,durationMs:c,timestamp:Date.now()},...l].slice(0,100);return co.set(u),s}catch(n){let r=(typeof performance<`u`?performance.now():Date.now())-a;if(i)try{i.api.pushError(n instanceof Error?n:Error(String(n)),{context:{action:e,payload:JSON.stringify(t)}})}catch{}let s=co.get(),c=[{id:o,action:e,payload:t,durationMs:r,timestamp:Date.now(),error:n?.message||String(n)},...s].slice(0,100);throw co.set(c),n}}var lo=n(`card`);function uo(e){Z(`setEditorMode`,{mode:typeof e==`function`?`functional`:e},()=>{typeof e==`function`?lo.set(e(lo.get())):lo.set(e)})}var Q=p({}),fo=f(Q,e=>Object.keys(e).length);function po(e){Z(`closeTab`,{handle:e},()=>{let t={...Q.get()};if(delete t[e],Q.set(t),$.get()?.handle===e){let e=Object.keys(t);if(e.length>0){let t=e[e.length-1],n=So.get()[t];$.set(n||null)}else $.set(null)}})}function mo(){Z(`closeAllTabs`,{},()=>{Q.set({}),$.set(null)})}function ho(e){Z(`closeOtherTabs`,{keepHandle:e},()=>{let t=Q.get();if(t[e]&&(Q.set({[e]:t[e]}),$.get()?.handle!==e)){let t=So.get()[e];$.set(t||null)}})}function go(e){Z(`closeTabsToTheRight`,{targetHandle:e},()=>{let t=Q.get(),n=Object.keys(t),r=n.indexOf(e);if(r>=0){let i=n.slice(0,r+1),a={};for(let e of i)a[e]=t[e];Q.set(a);let o=$.get();if(o&&!a[o.handle]){let t=So.get()[e];$.set(t||null)}}})}var _o=n([]),vo=n(-1);function yo(e){Z(`scrubTimeMachine`,{targetIndex:e},()=>{let t=_o.get();if(e>=0&&e<t.length){vo.set(e);let n=t[e],r=Object.values(So.get()).find(e=>e.hash===n.snapshotHash);r&&$.set(r),console.log(`[TimeMachine] Replaying state to snapshot index ${e} (${n.snapshotHash})`)}})}function bo(e){if(e.coreCard)return e.coreCard;let t=e.content??(e.payloadCas?JSON.stringify(e.payloadCas):``),n=r.create(`did:clm:agent:studio`);return i.create(`mcard:${e.handle}`,t,n,1,new Map([[`path`,e.path],[`name`,e.name],[`mimeType`,e.mimeType],[`detectedType`,e.detectedType],[`epistemicStatus`,e.epistemicStatus]]))}function xo(e,t=``){let n=e.metadata;return{handle:e.uri.replace(/^mcard:/,``),hash:e.hash.asHex(),path:String(n.get(`path`)||t),name:String(n.get(`name`)||e.uri.split(`/`).pop()||`unnamed`),mimeType:String(n.get(`mimeType`)||`text/plain`),detectedType:n.get(`detectedType`)||`specification`,epistemicStatus:n.get(`epistemicStatus`)||`proposition`,readOnly:!1,content:e.payload.kind===`text`?e.payload.value:JSON.stringify(e.payload),coreCard:e}}var So=p({}),$=n(null),Co=n(0);function wo(){Co.set(Co.get()+1)}function To(e){Z(`openMCardFile`,{handle:e.handle,hash:e.hash},()=>{$.set(e);let t=So.get();for(let n of Object.keys(t))n.startsWith(`panel:`)&&(t[n]?.handle===e.handle||t[n]?.path===e.path)&&So.setKey(n,e);Q.setKey(e.handle,{title:e.name||e.handle,hash:e.hash,path:e.path,handle:e.handle,detectedType:e.detectedType,readOnly:e.readOnly??!1,scope:e.scope});let n=[..._o.get(),{timestamp:Date.now(),action:`open:${e.handle}`,snapshotHash:e.hash}];_o.set(n),vo.set(n.length-1)})}typeof window<`u`&&(window.__CLM_MCARD_TREE__=So,window.__CLM_ACTIVE_MCARD__=$,window.$mcardTree=So,window.$activeMCard=$,window.openMCardFile=To);var Eo=e=>e,Do={},Oo={addEventListener(){},removeEventListener(){}};function ko(){try{return typeof localStorage<`u`}catch{return!1}}ko()&&(Do=localStorage),typeof window<`u`&&(Oo={addEventListener(e,t,n){window.addEventListener(`storage`,t),window.addEventListener(`pageshow`,n)},removeEventListener(e,t,n){window.removeEventListener(`storage`,t),window.removeEventListener(`pageshow`,n)}});function Ao(e,t,r={}){let i=r.encode||Eo,a=r.decode||Eo,o=Do[e],s=n(e in Do?a(o):t),c=s.set;s.set=t=>{o=i(t),o===void 0?delete Do[e]:Do[e]=o,c(t)};function l(n){n.key===e?n.newValue===null?c(t):c(a(n.newValue)):e in Do||c(t)}function d(){o!==Do[e]&&s.set(e in Do?a(Do[e]):t)}return u(s,()=>{if(d(),r.listen!==!1)return Oo.addEventListener(e,l,d),()=>{Oo.removeEventListener(e,l,d)}}),s}var jo=n(`abstract`);function Mo(e){Z(`setDimension`,{dimension:e},()=>{jo.set(e)})}var No=Ao(`clm:dockview:layout:v1`,null,{encode:JSON.stringify,decode:e=>{try{return e?JSON.parse(e):null}catch{return null}}}),Po=n(!0);function Fo(){Po.set(!0)}function Io(){Po.set(!1)}typeof window<`u`&&(window.addEventListener(`clm:depress-dockview`,()=>{Fo()}),window.addEventListener(`clm:restore-dockview`,()=>{Io()}));var Lo=`browser:smollm2-360m`;function Ro(){if(typeof window>`u`)return Lo;let e=localStorage.getItem(`clm:chat:active_model`);if(e)return e;let t=localStorage.getItem(`clm:chat:provider`),n=localStorage.getItem(`clm:chat:model`),r=localStorage.getItem(`clm:llm_config:google_api_key`)||localStorage.getItem(`clm:gemini_api_key`);return t===`google`||r?n&&n.startsWith(`gemini`)?`gemini:${n}`:`gemini:gemini-3.8-flash`:t===`ollama`&&n?`ollama:${n}`:Lo}var zo=n(Ro()),Bo=n({online:!1,latencyMs:0,models:[]}),Vo=n({provider:`ollama`,baseUrl:`http://127.0.0.1:11434`,apiKey:``,temperature:.7,providerEoaDid:`did:pkc:eoa:local:ollama-daemon`});function Ho(e){let t=zo.get();t.startsWith(`gemini:`)||t.startsWith(`remote:`)||(!e.online||e.models.length===0?t.startsWith(`ollama:`)&&zo.set(Lo):t===`browser:smollm2-360m`&&e.models.length>0&&zo.set(`ollama:${e.models[0]}`))}function Uo(e){Z(`setOllamaStatus`,{online:e.online,modelCount:e.models.length},()=>{Bo.set(e),Ho(e)})}function Wo(e){Z(`updateLlmConfig`,e,()=>{Vo.set({...Vo.get(),...e})})}var Go=n({backendType:`memory`,cardCount:0,totalBytes:0,isPersistent:!1,lastSavedIso:null,supervisorState:`idle`});function Ko(e){Go.set({...Go.get(),...e})}var qo=n({online:!1,peerCount:0,peers:[],localDid:`did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK`});function Jo(e){qo.set({...qo.get(),...e})}var Yo=typeof window<`u`&&localStorage.getItem(`clm_sync_mode`)===`client`?`client`:`server`,Xo=n(Yo);typeof window<`u`&&(window.__CLM_SYNC_MODE__=Xo,window.$syncMode=Xo);export{Q as A,To as C,yo as D,vo as E,uo as F,so as I,oo as L,ho as M,po as N,fo as O,go as P,p as R,wo as S,_o as T,Ao as _,Ko as a,Co as b,Bo as c,jo as d,No as f,Mo as g,Io as h,Jo as i,mo as j,lo as k,Uo as l,Fo as m,Go as n,zo as o,Po as p,Xo as r,Vo as s,qo as t,Wo as u,$ as v,bo as w,xo as x,So as y};
20
+ `));let n=t.reduce((t,n,r)=>{if(n.length>Sn)return t;let i,a,o,s,c;if(i=pn.exec(n)){if(a=i[1],o=i[2],s=i[3],c=i[4],o?.startsWith(`eval`)){let e=mn.exec(o);e&&(o=e[1],s=e[2],c=e[3])}o=o?.startsWith(`address at `)?o.substring(11):o,[a,o]=xn(a,o)}else if(i=hn.exec(n)){if(a=i[1],o=i[3],s=i[4],c=i[5],o&&o.includes(` > eval`)){let e=gn.exec(o);e&&(a||=`eval`,o=e[1],s=e[2])}else r===0&&!c&&re(e.columnNumber)&&(c=String(e.columnNumber+1));[a,o]=xn(a,o)}return(o||a)&&t.push(bn(o,a,s?Number(s):void 0,c?Number(c):void 0)),t},[]);return yn.test(e.message)?n.slice(1):n}function wn(e){return{frames:Cn(e)}}var Tn=`resource-entry`,En=`http-request-start`,Dn=`http-request-end`,On=`dom-mutation`,kn=`console`,An,jn=!1;function Mn(e){if(An||=new N,!jn){let t=e??je;_e.forEach(e=>{console[e]=(...n)=>{var r;An.notify({type:kn,level:e,args:n}),(r=t[e])==null||r.apply(console,n)}}),jn=!0}return An}var Nn=`Non-Error promise rejection captured with value:`,Pn=`UnhandledRejection`,Fn=`DOMError`,In=`DOMException`,Ln=`Non-Error exception captured with keys:`,Rn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function zn(e){let t=e.match(Rn),n=t?.[1]??Ke;return[t?.[2]??e,n]}function Bn(e){let t,n,r=[],i,a;if(ue(e)&&e.error)t=e.error.message,n=e.error.name,r=Cn(e.error);else if((i=de(e))||fe(e)){let{name:r,message:a}=e;n=r??(i?Fn:In),t=a?`${n}: ${a}`:n}else le(e)?(n=e.name,t=e.message,r=Cn(e)):(w(e)||(a=se(e)))&&(n=a?e.constructor.name:void 0,t=`${Ln} ${Object.keys(e)}`);return[t,n,r]}function Vn(e){let[t,n,r,i,a]=e,o,s,c=[],l=ne(t),u=bn(n,`?`,r,i);return a||!l?([o,s,c]=Bn(a??t),c.length===0&&(c=[u])):l&&([o,s]=zn(t),c=[u]),{value:o,type:s,stackFrames:c}}function Hn(e,t){return le(e[0])?Vn(e):{value:t(e)}}var Un=class e extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-console`,this.version=F,this.errorSerializer=Je}initialize(){let t=this.config.consoleInstrumentation,n=t?.serializeErrors||!!t?.errorSerializer;this.errorSerializer=n?t?.errorSerializer??qe:Je;let r=t?.disabledLevels??e.defaultDisabledLevels,i=Mn(this.unpatchedConsole);this.subscription=i.subscribe(({level:n,args:i})=>{if(!r.includes(n))try{if(n===ge.ERROR&&!t?.consoleErrorAsLog){let{value:t,type:n,stackFrames:r}=Hn(i,this.errorSerializer);if(t&&!n&&!r){this.api.pushError(Error(e.consoleErrorPrefix+t));return}this.api.pushError(Error(e.consoleErrorPrefix+t),{type:n,stackFrames:r})}else if(n===ge.ERROR&&t?.consoleErrorAsLog){let{value:t,type:r,stackFrames:a}=Hn(i,this.errorSerializer);this.api.pushLog(t?[e.consoleErrorPrefix+t]:i,{level:n,context:{value:t??``,type:r??``,stackFrames:a?.length?qe(a):``}})}else this.api.pushLog(i,{level:n})}catch(e){this.logError(e)}})}destroy(){var e;(e=this.subscription)==null||e.unsubscribe(),this.subscription=void 0}};Un.defaultDisabledLevels=[ge.DEBUG,ge.TRACE,ge.LOG],Un.consoleErrorPrefix=`console.error: `;function Wn(e){let t=window.onerror;window.onerror=(...n)=>{try{let{value:t,type:r,stackFrames:i}=Vn(n),a=n[4];if(t){let n={type:r,stackFrames:i};a!=null&&(n.originalError=a),e.pushError(Error(t),n)}}finally{t?.apply(window,n)}}}var Gn=[];function Kn(e){let t=t=>{let n=t;n.reason?n=t.reason:t.detail?.reason&&(n=t.detail?.reason);let r,i,a=[];ae(n)?(r=`${Nn} ${String(n)}`,i=Pn):[r,i,a]=Bn(n),r&&e.pushError(Error(r),{type:i,stackFrames:a})};window.addEventListener(`unhandledrejection`,t),Gn.push(t)}var qn=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-errors`,this.version=F}initialize(){this.logDebug(`Initializing`),Wn(this.api),Kn(this.api)}},Jn=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-view`,this.version=F,this.waitingForActivation=!1,this.sendViewChangedEvent=e=>{if(this.waitingForActivation||document.prerendering)return;let t=e.view;if(t&&t.name!==this.notifiedView?.name){let e=this.notifiedView?.name??b;this.notifiedView=t,this.api.pushEvent(Mt,{fromView:e,toView:t.name??b},void 0,{skipDedupe:!0})}},this.prerenderListener=()=>{window.queueMicrotask(()=>{this.waitingForActivation&&(this.waitingForActivation=!1,this.sendViewChangedEvent(this.metas.value))})}}initialize(){this.metas.addListener(this.sendViewChangedEvent),document.prerendering&&(this.waitingForActivation=!0,document.addEventListener(`prerenderingchange`,this.prerenderListener,{once:!0}))}destroy(){this.waitingForActivation=!1,this.metas.removeListener(this.sendViewChangedEvent),document.removeEventListener(`prerenderingchange`,this.prerenderListener)}},Yn=`com.grafana.faro.lastNavigationId`,Xn=class{t;o=0;i=[];l(e){if(e.hadRecentInput)return;let t=this.i[0],n=this.i.at(-1);this.o&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),this.t?.(e)}},Zn=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Qn=e=>{if(document.readyState===`loading`)return`loading`;let t=Zn();if(t){if(e<t.domInteractive)return`loading`;if(t.domContentLoadedEventStart===0||e<t.domContentLoadedEventStart)return`dom-interactive`;if(t.domComplete===0||e<t.domComplete)return`dom-content-loaded`}return`complete`},$n=e=>{let t=e.nodeName;return e.nodeType===1?t.toLowerCase():t.toUpperCase().replace(/^#/,``)},er=e=>{let t=``;try{for(;e?.nodeType!==9;){let n=e,r=n.id?`#`+n.id:[$n(n),...Array.from(n.classList??[]).sort()].join(`.`);if(t.length+r.length>99)return t||r;if(t=t?r+`>`+t:r,n.id)break;e=n.parentNode}}catch{}return t},tr=new WeakMap;function nr(e,t){let n=tr.get(t);return n||(n=new WeakMap,tr.set(t,n)),n.get(e)||n.set(e,new t),n.get(e)}var rr=-1,ir=()=>rr,ar=e=>{addEventListener(`pageshow`,t=>{t.persisted&&(rr=t.timeStamp,e(t))},!0)},G=(e,t,n,r)=>{let i,a;return o=>{t.value>=0&&(o||r)&&(a=t.value-(i??0),(a||i===void 0)&&(i=t.value,t.delta=a,t.rating=((e,t)=>e>t[1]?`poor`:e>t[0]?`needs-improvement`:`good`)(t.value,n),e(t)))}},or=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},sr=()=>Zn()?.activationStart??0,cr=-1,lr=new Set,ur=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,dr=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of lr)e();isFinite(cr)||(cr=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,dr,!0))}},fr=(e=!1)=>{if(e&&(cr=1/0),cr<0){let e=sr();cr=(document.prerendering?void 0:globalThis.performance.getEntriesByType(`visibility-state`).find(t=>t.name===`hidden`&&t.startTime>=e)?.startTime)??ur(),addEventListener(`visibilitychange`,dr,!0),addEventListener(`prerenderingchange`,dr,!0),ar(()=>{setTimeout(()=>{cr=ur()})})}return{get firstHiddenTime(){return cr},onHidden(e){lr.add(e)}}},K=(e,t=-1,n,r=0,i,a,o)=>{let s=Zn(),c=s?.navigationId||0,l=`navigate`;return n?l=n:ir()>=0?l=`back-forward-cache`:s&&(document.prerendering||sr()>0?l=`prerender`:document.wasDiscarded?l=`restore`:s.type&&(l=s.type.replace(/_/g,`-`))),{name:e,value:t,rating:`good`,delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+0xe8d4a51000}`,navigationType:l,navigationId:r||c,navigationInteractionId:i,navigationURL:a||s?.name,navigationStartTime:o||0}},q=(e,t,n={})=>{try{let r=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(r.length>0){let e=new PerformanceObserver(e=>{queueMicrotask(()=>{let n=e.getEntries();r.length>1&&n.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(n)})});for(let t of r)e.observe({type:t,buffered:!0,...n});return e}}catch{}},pr=e=>globalThis.PerformanceObserver?.supportedEntryTypes?.includes(`soft-navigation`)&&typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint==`function`&&e&&e.reportSoftNavs,mr=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){let t=e.keys().next().value;t!==void 0&&e.delete(t)}},hr=e=>{let t=!1;return()=>{t||=(e(),!0)}},gr=class{u},_r=e=>{document.prerendering?addEventListener(`prerenderingchange`,e,!0):e()},vr=[1800,3e3],yr=(e,t={})=>{let n=pr(t);_r(()=>{let r=nr(t,gr),i=fr(),a,o=K(`FCP`),s=q([`paint`],e=>{for(let t of e)t.name===`first-contentful-paint`&&(s.disconnect(),t.startTime<i.firstHiddenTime&&(o.value=Math.max(t.startTime-sr(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,a(!0)))});s&&(a=G(e,o,vr,t.reportAllChanges),ar(n=>{o=K(`FCP`,-1,`back-forward-cache`,o.navigationId,o.navigationInteractionId,o.navigationURL,ir()),a=G(e,o,vr,t.reportAllChanges),or(()=>{o.value=performance.now()-n.timeStamp,a(!0)})})),n&&q([`soft-navigation`],n=>{n.forEach(n=>{r.u&&n.navigationId&&mr(r.u,n),o=K(`FCP`,Math.max((n.presentationTime||n.paintTime||0)-n.startTime,0),`soft-navigation`,n.navigationId,n.interactionId,n.name,n.startTime),a=G(e,o,vr,t.reportAllChanges),a(!0)})},t)})},br=[.1,.25],xr=e=>e.find(e=>e.node?.nodeType===1)||e[0],Sr=(e,t={})=>{let n=nr(t=Object.assign({},t),Xn),r=new WeakMap;n.t=e=>{if(e?.sources?.length){let n=xr(e.sources),i=n?.node;if(i){let e=t.generateTarget?.(i)??er(i);r.set(n,e)}}},((e,t={})=>{let n=fr();yr(hr(()=>{let r,i=K(`CLS`,0),a=nr(t,Xn),o=(n,o,s,c,l)=>{i=K(`CLS`,0,n,o,s,c,l),a.o=0,r=G(e,i,br,t.reportAllChanges)},s=(e=!1)=>{a.o>i.value&&(i.value=a.o,i.entries=a.i),r(e)},c=e=>{s(!0),o(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime)},l=e=>{for(let t of e)t.entryType===`soft-navigation`?c(t):a.l(t);s()},u=[`layout-shift`];pr(t)&&u.push(`soft-navigation`);let d=q(u,l);d&&(r=G(e,i,br,t.reportAllChanges),n.onHidden(()=>{l(d.takeRecords()),r(!0)}),ar(()=>{o(`back-forward-cache`,i.navigationId,i.navigationInteractionId,i.navigationURL,ir()),or(r)}),setTimeout(r))}))})(t=>{e((e=>{let t={};if(e.entries.length){let n=e.entries.reduce((e,t)=>e.value>t.value?e:t);if(n?.sources?.length){let e=xr(n.sources);e&&(t={largestShiftTarget:r.get(e),largestShiftTime:n.startTime,largestShiftValue:n.value,largestShiftSource:e,largestShiftEntry:n,loadState:Qn(n.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},Cr=(e,t={})=>{let n=nr(t=Object.assign({},t),gr);pr(t)&&(n.u=new Map),yr(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:Qn(ir())};if(e.navigationType!==`soft-navigation`){if(e.entries.length){let n=Zn(),r=e.entries.at(-1);if(n){let i=n.responseStart,a=n.activationStart||0,o=Math.max(0,i-a);t={timeToFirstByte:o,firstByteToFCP:e.value-o,loadState:Qn(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}}else{let r=n.u?.get(e.navigationId);r&&(t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:`complete`,navigationEntry:r})}return Object.assign(e,{attribution:t})})(t))},t)},wr=0,Tr=1/0,Er=0,Dr=e=>{for(let t of e)t.interactionId&&(Tr=Math.min(Tr,t.interactionId),Er=Math.max(Er,t.interactionId),wr=Er?(Er-Tr)/7+1:0)},Or,kr=()=>Or?wr:performance.interactionCount??0,Ar=()=>{`interactionCount`in performance||Or||(Or=q([`event`],Dr,{durationThreshold:0}))},jr=class{h=0;v=[];p=new Map;m;M;T(){return kr()-this.h}D(){this.h=kr(),this.v.length=0,this.p.clear()}S(e){let t=this.T(),n=Math.min(this.v.length-1,Math.floor(t/50));return!t||n!==-1||e!==`soft-navigation`&&e!==`back-forward-cache`?this.v[n]:{k:8,id:-1,entries:[]}}l(e){if(this.m?.(e),!e.interactionId)return;let t=this.v.at(-1),n=this.p.get(e.interactionId);if(n||this.v.length<10||e.duration>t.k){if(n?e.duration>n.k?(n.entries=[e],n.k=e.duration):e.duration===n.k&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],k:e.duration},this.p.set(n.id,n),this.v.push(n)),this.v.sort((e,t)=>t.k-e.k),this.v.length>10){let e=this.v.splice(10);for(let t of e)this.p.delete(t.id)}this.M?.(n)}}},Mr=e=>{let t=`requestIdleCallback`in globalThis?1e3:0,n=globalThis.requestIdleCallback||setTimeout,r=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState===`hidden`)e();else{let i=hr(e),a=-1,o=()=>{r(a),i()};addEventListener(`visibilitychange`,o,{once:!0,capture:!0}),a=n(()=>{removeEventListener(`visibilitychange`,o,{capture:!0}),i()},{timeout:t})}},Nr=[200,500],Pr=(e,t={})=>{let n=nr(t=Object.assign({},t),jr),r=[],i=[],a=0,o=new WeakMap,s=new WeakMap,c=!1,l=()=>{c||(c=!0,Mr(u))},u=()=>{let e=new Set(n.v.map(e=>o.get(e.entries[0]))),t=i.length-10;i=i.filter((n,r)=>r>=t||e.has(n));let s=new Set;for(let e of i){let t=d(e.startTime,e.processingEnd);for(let e of t)s.add(e)}let l=r.length-10;r=r.filter((e,t)=>s.has(e)||t>=l&&e.startTime>a),c=!1};n.m=e=>{let n=e.startTime+e.duration,r;a=Math.max(a,e.processingEnd);for(let a=i.length-1;a>=0;a--){let o=i[a];if(Math.abs(n-o.renderTime)<=8){r=o,r.startTime=Math.min(e.startTime,r.startTime),r.processingStart=Math.min(e.processingStart,r.processingStart),r.processingEnd=Math.max(e.processingEnd,r.processingEnd),t.includeProcessedEventEntries&&r.entries.push(e);break}}r||(r={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:n,entries:t.includeProcessedEventEntries?[e]:[]},i.push(r)),e.interactionId&&o.set(e,r),l()},n.M=e=>{if(!s.get(e)){let n=e.entries.find(e=>e.target)?.target;if(n){let r=t.generateTarget?.(n)??er(n);s.set(e,r)}else{let t=e.entries.find(e=>e.targetSelector)?.targetSelector;t&&s.set(e,t)}}};let d=(e,t)=>{let n=[];for(let i of r)if(!(i.startTime+i.duration<e)){if(i.startTime>t)break;n.push(i)}return n},f=e=>{if(e.entries.length===0){let t=e.navigationStartTime||0,n={processedEventEntries:[],longAnimationFrameEntries:[],inputDelay:0,processingDuration:0,presentationDelay:e.value,loadState:Qn(t)};return Object.assign(e,{attribution:n})}let t=e.entries[0],r=o.get(t),i=Math.max(r.processingStart,t.startTime),a=Math.max(t.startTime+t.duration,i),c=Math.min(r.processingEnd,a),l=r.entries.sort((e,t)=>e.processingStart-t.processingStart),u=d(t.startTime,c),f=n.p.get(t.interactionId),p={interactionTarget:s.get(f),interactionType:t.name.startsWith(`key`)?`keyboard`:`pointer`,interactionTime:t.startTime,nextPaintTime:a,processedEventEntries:l,longAnimationFrameEntries:u,inputDelay:i-t.startTime,processingDuration:c-i,presentationDelay:a-c,loadState:Qn(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{let t=e.interactionTime,n=e.nextPaintTime;if(!e.longAnimationFrameEntries?.length||!t||!n)return;let r=e.inputDelay,i=e.processingDuration,a,o,s=0,c=0,l=0,u=0;for(let n of e.longAnimationFrameEntries){c=c+n.startTime+n.duration-n.styleAndLayoutStart;for(let e of n.scripts){let n=e.startTime+e.duration;if(n<t)continue;let l=n-Math.max(t,e.startTime),d=e.duration?l/e.duration*e.forcedStyleAndLayoutDuration:0;s+=l-d,c+=d,l>u&&(o=e.startTime<t+r?`input-delay`:e.startTime>=t+r+i?`presentation-delay`:`processing-duration`,a=e,u=l)}}let d=e.longAnimationFrameEntries.at(-1),f=d?d.startTime+d.duration:0;f>=t+r+i&&(l=n-f),a&&o&&(e.longestScript={entry:a,subpart:o,intersectingDuration:u}),e.totalScriptDuration=s,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=l,e.totalUnattributedDuration=n-t-s-c-l})(p),Object.assign(e,{attribution:p})};q([`long-animation-frame`],e=>{r=r.concat(e),l()},t),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=fr();_r(()=>{Ar();let r,i=K(`INP`),a=nr(t,jr),o=(n,o,s,c,l)=>{a.D(),i=K(`INP`,-1,n,o,s,c,l),r=G(e,i,Nr,t.reportAllChanges)},s=()=>{let e=a.S(i.navigationType);e&&e.k!==i.value&&(i.value=e.k,i.entries=e.entries,r())},c=e=>{s(),r(!0),o(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime)},l=(e,t=!1)=>{Mr(()=>{for(let t of e)t.entryType===`soft-navigation`?c(t):a.l(t);s(),t&&r(!0)})},u=[`event`,`first-input`];pr(t)&&u.push(`soft-navigation`);let d=q(u,l,{...t,durationThreshold:t.durationThreshold??40});r=G(e,i,Nr,t.reportAllChanges),d&&(n.onHidden(()=>{l(d.takeRecords(),!0)}),ar(()=>{o(`back-forward-cache`,i.navigationId,i.navigationInteractionId,i.navigationURL,ir())}))})})(t=>{e(f(t))},t)},Fr=class{m;u;l(e){this.m?.(e)}},Ir=[2500,4e3],Lr=50,Rr=[];q([`resource`],e=>{for(let t of e)Rr.push(t),Rr.length>Lr&&Rr.shift()});var zr=(e,t={})=>{(t=Object.assign({},t)).resourceBufferSize!=null&&(Lr=t.resourceBufferSize);let n=nr(t,Fr),r=new WeakMap;pr(t)&&(n.u=new Map),n.m=e=>{let n=e.element;if(n){let i=t.generateTarget?.(n)??er(n);r.set(e,i)}else e.id&&r.set(e,`#${e.id}`)},((e,t={})=>{let n=!1,r=pr(t);_r(()=>{let i,a=fr(),o=K(`LCP`),s=nr(t,Fr),c=(r,s,c,l,u)=>{o=K(`LCP`,-1,r,s,c,l,u),i=G(e,o,Ir,t.reportAllChanges),n=!1,r===`soft-navigation`&&(a=fr(!0))},l=e=>{s.u&&e.navigationId&&mr(s.u,e),n||i(!0),c(`soft-navigation`,e.navigationId,e.interactionId,e.name,e.startTime);let t=e.getLargestInteractionContentfulPaint?.();t&&u([t])},u=e=>{t.reportAllChanges||r||(e=e.slice(-1));for(let t of e){if(!t)continue;if(t.entryType===`soft-navigation`){l(t);continue}let e=0,n=[],r=t.startTime;if(t.entryType===`largest-contentful-paint`)e=Math.max(t.startTime-sr(),0),s.l(t),n=[t];else if(t.entryType===`interaction-contentful-paint`){let i=t;if(!o.navigationId||`interactionId`in i&&i.interactionId!=o.navigationInteractionId)continue;r=i.largestContentfulPaint?.renderTime||0,e=Math.max(r-t.startTime,0),i.largestContentfulPaint&&(s.l(i.largestContentfulPaint),n=[i.largestContentfulPaint])}r<a.firstHiddenTime&&(o.value=e,o.entries=n,i())}},d=[`largest-contentful-paint`];r&&d.push(`interaction-contentful-paint`,`soft-navigation`);let f=q(d,u);if(f){i=G(e,o,Ir,t.reportAllChanges);let a=[`keydown`,`click`,`visibilitychange`],s=e=>{if(e.isTrusted&&!n){let e=o.id;Mr(()=>{if(!n){if(!r){f.disconnect();for(let e of a)removeEventListener(e,s,{capture:!0})}e===o.id&&(n=!0,i(!0))}})}};for(let e of a)addEventListener(e,s,{capture:!0});ar(r=>{c(`back-forward-cache`,o.navigationId,o.navigationInteractionId,o.navigationURL,ir()),i=G(e,o,Ir,t.reportAllChanges),or(()=>{o.value=performance.now()-r.timeStamp,n=!0,i(!0)})})}})})(t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){let i=e.entries.at(-1),a=e=>e.name===i.url&&(e.requestStart||e.startTime)<=i.startTime,o=i.url&&(Rr.findLast(a)||performance.getEntriesByType(`resource`).findLast(a)),s;t.target=r.get(i),t.lcpEntry=i,i.url&&(t.url=i.url),o&&(t.lcpResourceEntry=o);let c=0,l=0;if(e.navigationType===`soft-navigation`?(c=e.navigationStartTime||0,s=n.u?.get(e.navigationId)):(s=Zn(),c=s?.activationStart??0,l=s?.responseStart??0),s){let n=Math.max(0,l-c),r=Math.max(n,o?(o.requestStart||o.startTime)-c:0),i=Math.min(e.value,Math.max(r,o?o.responseEnd-c:0));t={...t,timeToFirstByte:n,resourceLoadDelay:r-n,resourceLoadDuration:i-r,elementRenderDelay:e.value-i,navigationEntry:s}}}return Object.assign(e,{attribution:t})})(t))},t)},Br=[800,1800],Vr=e=>{document.prerendering?_r(()=>Vr(e)):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,()=>Vr(e),!0)},Hr=(e,t={})=>{((e,t={})=>{let n=pr(t),r=K(`TTFB`),i=G(e,r,Br,t.reportAllChanges);Vr(()=>{let a=Zn();if(a){let o=a.responseStart;r.value=Math.max(o-sr(),0),r.entries=[a],i(!0),ar(()=>{r=K(`TTFB`,0,`back-forward-cache`,r.navigationId,r.navigationInteractionId,r.navigationURL,ir()),i=G(e,r,Br,t.reportAllChanges),i(!0)}),n&&q([`soft-navigation`],n=>{n.forEach(n=>{n.navigationId&&(r=K(`TTFB`,0,`soft-navigation`,n.navigationId,n.interactionId,n.name,n.startTime),r.entries=[n],i=G(e,r,Br,t.reportAllChanges),i(!0))})},t)}})})(t=>{e((e=>{let t=e.entries[0],n={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0,navigationEntry:t};if(e.entries.length&&t instanceof PerformanceNavigationTiming){let r=t.activationStart||0,i=Math.max((t.workerStart||t.fetchStart||0)-r,0),a=Math.max(t.domainLookupStart-r,0),o=Math.max(t.connectStart-r,0),s=Math.max(t.connectEnd-r,0);n={waitingDuration:i,cacheDuration:a-i,dnsDuration:o-a,connectionDuration:s-o,requestDuration:e.value-s,navigationEntry:t}}return Object.assign(e,{attribution:n})})(t))},t)},Ur=`load_state`,Wr=`time_to_first_byte`,Gr=class{constructor(e,t){this.corePushMeasurement=e,this.webVitalConfig=t}initialize(){this.measureCLS(),this.measureFCP(),this.measureINP(),this.measureLCP(),this.measureTTFB()}measureCLS(){Sr(e=>{let{loadState:t,largestShiftValue:n,largestShiftTime:r,largestShiftTarget:i}=e.attribution,a=this.buildInitialValues(e);this.addIfPresent(a,`largest_shift_value`,n),this.addIfPresent(a,`largest_shift_time`,r);let o=this.buildInitialContext(e);this.addIfPresent(o,Ur,t),this.addIfPresent(o,`largest_shift_target`,i),this.pushMeasurement(a,o)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}measureFCP(){Cr(e=>{let{firstByteToFCP:t,timeToFirstByte:n,loadState:r}=e.attribution,i=this.buildInitialValues(e);this.addIfPresent(i,`first_byte_to_fcp`,t),this.addIfPresent(i,Wr,n);let a=this.buildInitialContext(e);this.addIfPresent(a,Ur,r),this.pushMeasurement(i,a)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}measureINP(){Pr(e=>{let{interactionTime:t,presentationDelay:n,inputDelay:r,processingDuration:i,nextPaintTime:a,loadState:o,interactionTarget:s,interactionType:c,totalScriptDuration:l,totalStyleAndLayoutDuration:u,totalPaintDuration:d,totalUnattributedDuration:f,longestScript:p}=e.attribution,m=this.buildInitialValues(e);this.addIfPresent(m,`interaction_time`,t),this.addIfPresent(m,`presentation_delay`,n),this.addIfPresent(m,`input_delay`,r),this.addIfPresent(m,`processing_duration`,i),this.addIfPresent(m,`next_paint_time`,a),this.addNumberIfDefined(m,`total_script_duration`,l),this.addNumberIfDefined(m,`total_style_and_layout_duration`,u),this.addNumberIfDefined(m,`total_paint_duration`,d),this.addNumberIfDefined(m,`total_unattributed_duration`,f),this.addNumberIfDefined(m,`longest_script_intersecting_duration`,p?.intersectingDuration);let h=this.buildInitialContext(e);this.addIfPresent(h,Ur,o),this.addIfPresent(h,`interaction_target`,s),this.addIfPresent(h,`interaction_type`,c),this.addIfPresent(h,`longest_script_subpart`,p?.subpart),this.addIfPresent(h,`longest_script_invoker_type`,p?.entry.invokerType),this.webVitalConfig?.trackAttributionSources&&(this.addIfPresent(h,`longest_script_invoker`,p?.entry.invoker),this.addIfPresent(h,`longest_script_source_url`,p?.entry.sourceURL),this.addIfPresent(h,`longest_script_source_function_name`,p?.entry.sourceFunctionName),this.addIfPresent(h,`longest_script_source_char_position`,p?.entry.sourceCharPosition===void 0?void 0:String(p.entry.sourceCharPosition))),this.pushMeasurement(m,h)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}measureLCP(){zr(e=>{let{elementRenderDelay:t,resourceLoadDelay:n,resourceLoadDuration:r,timeToFirstByte:i,target:a,url:o,lcpResourceEntry:s}=e.attribution,c=this.buildInitialValues(e);this.addIfPresent(c,`element_render_delay`,t),this.addIfPresent(c,`resource_load_delay`,n),this.addIfPresent(c,`resource_load_duration`,r),this.addIfPresent(c,Wr,i);let l=this.buildInitialContext(e);this.addIfPresent(l,`element`,a),this.webVitalConfig?.trackAttributionSources&&(this.addIfPresent(l,`resource_url`,o),this.addIfPresent(l,`resource_delivery_type`,s?.deliveryType),this.addIfPresent(l,`resource_initiator_type`,s?.initiatorType)),this.pushMeasurement(c,l)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}measureTTFB(){Hr(e=>{let{dnsDuration:t,connectionDuration:n,requestDuration:r,waitingDuration:i,cacheDuration:a}=e.attribution,o=this.buildInitialValues(e);this.addIfPresent(o,`dns_duration`,t),this.addIfPresent(o,`connection_duration`,n),this.addIfPresent(o,`request_duration`,r),this.addIfPresent(o,`waiting_duration`,i),this.addIfPresent(o,`cache_duration`,a);let s=this.buildInitialContext(e);this.pushMeasurement(o,s)},{reportAllChanges:this.webVitalConfig?.reportAllChanges})}buildInitialValues(e){return{[e.name.toLowerCase()]:e.value,delta:e.delta}}buildInitialContext(e){let t=Vt(`com.grafana.faro.lastNavigationId`,U.session)??b;return{id:e.id,rating:e.rating,navigation_type:e.navigationType,navigation_entry_id:t}}pushMeasurement(e,t){this.corePushMeasurement({type:`web-vitals`,values:e},{context:t})}addIfPresent(e,t,n){n&&(e[t]=n)}addNumberIfDefined(e,t,n){n!==void 0&&(e[t]=n)}},Kr=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-web-vitals`,this.version=F}initialize(){this.logDebug(`Initializing`),new Gr(this.api.pushMeasurement,this.config.webVitalsInstrumentation).initialize()}},qr=/^00-[a-f0-9]{32}-[a-f0-9]{16}-[0-9]{1,2}$/;function Jr(e=[]){for(let t of e)if(t.name===`traceparent`){if(!qr.test(t.description))continue;let[,e,n]=t.description.split(`-`);if(e!=null&&n!=null)return{traceId:e,spanId:n};break}}function Yr(e,t={wallNow:Date.now(),monoNow:performance.now()}){let{wallNow:n,monoNow:r}=t;return Math.min(n,n-(r-e))}function Xr(){return`PerformanceObserver`in window}function Zr(e){if(document.readyState===`complete`)e();else{let t=()=>{document.readyState===`complete`&&(e(),document.removeEventListener(`readystatechange`,t))};document.addEventListener(`readystatechange`,t)}}function Qr(e,t={}){for(let[n,r]of Object.entries(t)){let t=e[n];return t==null?!1:E(r)?r.includes(t):t===r}return!0}function $r(e){let{connectEnd:t,connectStart:n,decodedBodySize:r,domainLookupEnd:i,domainLookupStart:a,duration:o,encodedBodySize:s,fetchStart:c,initiatorType:l,name:u,nextHopProtocol:d,redirectEnd:f,redirectStart:p,renderBlockingStatus:m,requestStart:h,responseEnd:g,responseStart:_,responseStatus:v,secureConnectionStart:y,transferSize:b,workerStart:x}=e;return{name:u,httpHost:ni(u),duration:J(o),tcpHandshakeTime:J(t-n),dnsLookupTime:J(i-a),tlsNegotiationTime:J(t-y),responseStatus:J(v),redirectTime:J(f-p),requestTime:J(_-h),responseTime:J(g-_),fetchTime:J(g-c),serviceWorkerTime:J(x>0?c-x:0),decodedBodySize:J(r),encodedBodySize:J(s),cacheHitStatus:S(),renderBlockingStatus:J(m),protocol:d,initiatorType:l,visibilityState:document.visibilityState,ttfb:J(_-h),transferSize:J(b)};function S(){let e=`fullLoad`;return b===0?r>0&&(e=`cache`):v==null?s>0&&b<s&&(e=`conditionalFetch`):v===304&&(e=`conditionalFetch`),e}}function ei(e){let{activationStart:t,domComplete:n,domContentLoadedEventEnd:r,domContentLoadedEventStart:i,domInteractive:a,fetchStart:o,loadEventEnd:s,loadEventStart:c,responseStart:l,type:u}=e,d=ti();return W(W({},$r(e)),{},{pageLoadTime:J(n-o),documentParsingTime:J(d?a-d:null),domProcessingTime:J(n-a),domContentLoadHandlerTime:J(r-i),onLoadTime:J(s-c),ttfb:J(Math.max(l-(t??0),0)),type:u})}function ti(){return performance.timing?.domLoading==null?null:performance.timing.domLoading-performance.timeOrigin}function ni(e){try{return new URL(e).host||`unknown`}catch{return b}}function J(e){return e==null?b:typeof e==`number`?Math.round(e>0?e:0).toString():e.toString()}var ri=`navigation`,ii=`resource`;function ai(e){let t,n=new Promise(e=>{t=e});return new PerformanceObserver(n=>{let[r]=n.getEntries();if(r==null||Rt(r.name))return;let i=r.toJSON(),a=Jr(i?.serverTiming),o=Vt(`com.grafana.faro.lastNavigationId`,U.session)??b,s=W(W({},ei(i)),{},{faroNavigationId:be(),faroPreviousNavigationId:o});Ht(Yn,s.faroNavigationId,U.session),e(`faro.performance.navigation`,s,void 0,{spanContext:a,timestampOverwriteMs:Yr(i.startTime)}),t(s)}).observe({type:ri,buffered:!0}),n}var oi={initiatorType:[`xmlhttprequest`,`fetch`]};function si(e,t,n,r){let i=r.trackResources;new PerformanceObserver(r=>{let a=r.getEntries(),o={wallNow:Date.now(),monoNow:performance.now()};for(let r of a){if(Rt(r.name))continue;n?.notify({type:`resource`});let a=r.toJSON(),s=Jr(a?.serverTiming);(i==null&&Qr(a,oi)||i)&&t(`faro.performance.resource`,W(W({},$r(a)),{},{faroNavigationId:e,faroResourceId:be()}),void 0,{spanContext:s,timestampOverwriteMs:Yr(a.startTime,o)})}}).observe({type:ii,buffered:!0})}function ci(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Y(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){ci(a,r,i,o,s,`next`,e)}function s(e){ci(a,r,i,o,s,`throw`,e)}o(void 0)})}}var li=new N,ui=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-performance`,this.version=F}initialize(){var e=this;if(!Xr()){this.logDebug(`performance observer not supported. Disable performance instrumentation.`);return}let t=!1,n=()=>{Zr(Y(function*(){if(t)return;let n=e.api.pushEvent,{faroNavigationId:r}=yield ai(n);!t&&r!=null&&si(r,n,li,e.config)}))};this.cancelInitialization=()=>{t=!0,document.removeEventListener(`prerenderingchange`,n)},document.prerendering?document.addEventListener(`prerenderingchange`,n,{once:!0}):n()}destroy(){var e;(e=this.cancelInitialization)==null||e.call(this),this.cancelInitialization=void 0}},di=`data-faro-user-action-name`;di.replace(/-name$/,`-timeout`);var fi=1e3;function pi(e){return`data-${(e.startsWith(`data-`)?e.slice(5):e).replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}`}function mi(e){let t=pi(e);return t.endsWith(`-name`)?`${t.slice(0,-5)}-timeout`:`${t}-timeout`}function hi(e,t=100,n=A){if(e===void 0)return t;let r=NaN;try{r=typeof e==`string`&&e.trim()===``?NaN:Number(e)}catch{}return!Number.isFinite(r)||r<=0?(n(`initialActivityTimeout must be a finite number greater than zero; using ${t} ms`),t):r>1e3?(n(`initialActivityTimeout cannot exceed ${fi} ms; clamping to the maximum`),fi):r}function gi(e){return pi(e).slice(5).replace(/-(.)/g,(e,t)=>t.toUpperCase())}function _i(e,t,n){return e!==void 0&&window.clearTimeout(e),window.setTimeout(()=>{t()},n)}function vi(e){return e.type===En}function yi(e){return e.type===Dn}var bi,xi;function Si(){return bi||=new N,xi||(xi=new MutationObserver((e,t)=>{bi.notify({type:On})}),xi.observe(document,{attributes:!0,childList:!0,subtree:!0,characterData:!0})),bi}var Ci=`fetch`,wi=`xhr`,Ti,Ei=!1,Di,Oi;function ki(){if(Ti)return Ti;Ti=new N;function e(e){Ti.notify({type:En,request:e})}function t(e){Ti.notify({type:Dn,request:e})}return Ei||=(ji({onRequestStart:e,onRequestEnd:t}),Ai({onRequestStart:e,onRequestEnd:t}),!0),Ti}function Ai({onRequestStart:e,onRequestEnd:t}){Di||=XMLHttpRequest.prototype.open,XMLHttpRequest.prototype.open=function(){let n=arguments[1],r=Rt(n),i=arguments[0],a=be();this.addEventListener(`loadstart`,function(){r||e({url:n,method:i,requestId:a,apiType:wi})}),this.addEventListener(`load`,function(){r||t({url:n,method:i,requestId:a,apiType:wi})}),this.addEventListener(`error`,function(){r||t({url:n,method:i,requestId:a,apiType:wi})}),this.addEventListener(`abort`,function(){r||t({url:n,method:i,requestId:a,apiType:wi})}),Di.apply(this,arguments)}}function ji({onRequestEnd:e,onRequestStart:t}){Oi||=window.fetch,window.fetch=function(){let n=zt(arguments[0])??``,r=Rt(n),i=(arguments[1]??{}).method,a=be();return r||t({url:n,method:i,requestId:a,apiType:Ci}),Oi.apply(this,arguments).then(t=>(r||e({url:n,method:i,requestId:a,apiType:Ci}),t)).catch(t=>{throw r||e({url:n,method:i,requestId:a,apiType:Ci}),t})}}var Mi,Ni=!1;function Pi(){return Mi||=new N,Ni||=(li.subscribe(e=>{e.type===`resource`&&Mi.notify({type:Tn})}),!0),Mi}var Fi=100,Ii=1e4,Li=class{constructor(e,t,n=100){this.userAction=e,this.logDebug=t,this.initialActivityTimeout=n,this.http=ki(),this.dom=Si(),this.perf=Pi(),this.isValid=!1,this.runningRequests=new Map}attach(){this.allMonitorsSub=new N().merge(this.http,this.dom,this.perf).takeWhile(()=>[z.Started,z.Halted].includes(this.userAction.getState())).filter(e=>!(this.userAction.getState()===z.Halted&&!(yi(e)&&this.runningRequests.has(e.request.requestId)))).subscribe(e=>{vi(e)&&this.runningRequests.set(e.request.requestId,e.request),yi(e)&&this.runningRequests.delete(e.request.requestId),yi(e)?this.userAction.getState()===z.Halted&&this.runningRequests.size===0&&this.endAction():(this.isValid||(this.isValid=!0,this.clearTimer(this.startupTid)),this.scheduleFollowUp())}),this.stateSub=this.userAction.filter(e=>[z.Ended,z.Cancelled].includes(e)).first().subscribe(()=>this.cleanup()),this.startupTid=_i(this.startupTid,()=>{this.logDebug(`User action not sent; no DOM, resource, or HTTP activity:`,this.userAction.name),this.cancelAction()},this.initialActivityTimeout)}scheduleFollowUp(){this.clearTimer(this.followUpTid),this.followUpTid=window.setTimeout(()=>{if(this.userAction.getState()===z.Started&&this.runningRequests.size>0){this.haltAction();return}if(this.isValid){this.endAction();return}this.cancelAction()},Fi)}haltAction(){this.userAction.getState()===z.Started&&(this.userAction.halt(),this.startHaltTimeout())}startHaltTimeout(){this.clearTimer(this.haltTid),this.haltTid=_i(this.haltTid,()=>{this.userAction.getState()===z.Halted&&this.endAction()},Ii)}endAction(){this.userAction.end(),this.cleanup()}cancelAction(){this.userAction.cancel(),this.cleanup()}cleanup(){var e,t;this.clearTimer(this.startupTid),this.clearTimer(this.followUpTid),this.clearTimer(this.haltTid),(e=this.allMonitorsSub)==null||e.unsubscribe(),(t=this.stateSub)==null||t.unsubscribe(),this.allMonitorsSub=void 0,this.stateSub=void 0,this.runningRequests.clear()}clearTimer(e){e!==void 0&&window.clearTimeout(e)}};function Ri(e,t=A){let{api:n,config:r,internalLogger:i}=e,a=hi(r.userActionsInstrumentation?.initialActivityTimeout,100,t);function o(e){let t=r.userActionsInstrumentation?.dataAttributeName??di,i=e.target;if(!(i instanceof Element))return;let a=zi(i,pi(t)),o=Vi(a,t);if(!a||!o)return;let s=Bi(a,t);n.startUserAction(o,{},{triggerName:e.type,initialActivityTimeout:s})}function s(e,n){let r=e,o=hi(n,a,t);new Li(r,i.debug,o).attach()}return{processUserEvent:o,processUserActionStarted:s}}function zi(e,t){let n=e;for(;n;){if(n.hasAttribute(t))return n;n=n.parentElement}return null}function Bi(e,t){let n=e.getAttribute(mi(t));return n===null?void 0:Number(n)}function Vi(e,t){if(!e)return;let n=gi(t),r=e.dataset;for(let e in r)if(e===n)return r[e]}var Hi=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-user-action`,this.version=F}initialize(){let{processUserEvent:e,processUserActionStarted:t}=Ri(V,e=>this.logWarn(e));this._processUserEvent=e,this._processKeydown=t=>{[` `,`Enter`].includes(t.key)&&e(t)},window.addEventListener(`pointerdown`,this._processUserEvent),window.addEventListener(`keydown`,this._processKeydown),this._userActionSub=Ue.subscribe(({type:e,userAction:n,initialActivityTimeout:r})=>{e===`user_action_start`&&t(n,r)})}destroy(){var e;this._processUserEvent&&window.removeEventListener(`pointerdown`,this._processUserEvent),this._processKeydown&&window.removeEventListener(`keydown`,this._processKeydown),(e=this._userActionSub)==null||e.unsubscribe()}},Ui=class extends B{constructor(){super(),this.name=`@grafana/faro-web-sdk:instrumentation-csp`,this.version=F,this.boundSecuritypolicyviolationHandler=this.securitypolicyviolationHandler.bind(this)}initialize(){document.addEventListener(`securitypolicyviolation`,this.boundSecuritypolicyviolationHandler)}destroy(){document.removeEventListener(`securitypolicyviolation`,this.boundSecuritypolicyviolationHandler)}securitypolicyviolationHandler(e){let t={blockedURI:e.blockedURI,columnNumber:e.columnNumber,disposition:e.disposition,documentURI:e.documentURI,effectiveDirective:e.effectiveDirective,lineNumber:e.lineNumber,originalPolicy:e.originalPolicy,referrer:e.referrer,sample:e.sample,sourceFile:e.sourceFile,statusCode:e.statusCode,violatedDirective:e.violatedDirective};this.api.pushEvent(`securitypolicyviolation`,Se(t))}};function Wi(e){return e.type===En}function Gi(e){return e.type===Dn}var Ki=class extends N{constructor(e,t){super(),this._tracking=!1,this.eventsObservable=e,this._options={inactivityMs:t?.inactivityMs??100,drainTimeoutMs:t?.drainTimeoutMs??1e4,isOperationStart:t?.isOperationStart??(()=>void 0),isOperationEnd:t?.isOperationEnd??(()=>void 0)},this._initialize()}_initialize(){this.eventsObservable.filter(()=>this._tracking).subscribe(e=>{var t;this._lastEventTime=pe(),(t=this._currentEvents)==null||t.push(e);let n=this._options.isOperationStart(e);if(n){var r;(r=this._activeOperations)==null||r.set(n,!0)}let i=this._options.isOperationEnd(e);if(i){var a;(a=this._activeOperations)==null||a.delete(i)}this._scheduleInactivityCheck()})}startTracking(){this._tracking||(this._tracking=!0,this._startTime=pe(),this._lastEventTime=this._startTime,this.notify({message:`tracking-started`}),this._currentEvents=[],this._activeOperations=new Map,this._scheduleInactivityCheck())}stopTracking(){this._tracking=!1,this._clearTimer(this._inactivityTid),this._clearTimer(this._drainTid);let e;e=this.hasActiveOperations()?pe()-this._startTime:this._lastEventTime?this._lastEventTime-this._startTime:0,this.notify({message:`tracking-ended`,events:this._currentEvents,duration:e})}_scheduleInactivityCheck(){this._inactivityTid=qi(this._inactivityTid,()=>{this.hasActiveOperations()?this._startDrainTimeout():this.stopTracking()},this._options.inactivityMs)}_startDrainTimeout(){this._drainTid=qi(this._drainTid,()=>{this.stopTracking()},this._options.drainTimeoutMs)}hasActiveOperations(){return!!this._activeOperations&&this._activeOperations.size>0}_clearTimer(e){e&&clearTimeout(e)}};function qi(e,t,n){return e&&clearTimeout(e),e=setTimeout(()=>{t()},n),e}var Ji=`interaction`,Yi,Xi=new Set,Zi=new Map;function Qi(e){return Yi||=new N,e.forEach(e=>{if(!Xi.has(e)){let t=()=>{Yi.notify({type:Ji,name:e})};window.addEventListener(e,t),Xi.add(e),Zi.set(e,t)}}),Yi}var $i=`url-change`,ea,ta=!1,na,ra,ia,aa,oa,sa,ca;function la(){ea||(ea=new N,na=location.href);function e(e,t){let n=t??location.href;n!==na&&(ea.notify({type:$i,from:na,to:n,trigger:e}),na=n)}if(!ta){if(`navigation`in window&&`NavigateEvent`in window){sa=t=>{try{let n=t?.destination;n?.sameDocument&&typeof n.url==`string`&&e(`navigate`,n.url)}catch{}},window.navigation.addEventListener(`navigate`,sa);let t=window.NavigateEvent;t&&t.prototype&&typeof t.prototype.intercept==`function`&&(ca||=t.prototype.intercept,t.prototype.intercept=function(t){try{let t=!!this?.canIntercept,n=this?.destination;t&&n&&n.sameDocument===!1&&typeof n.url==`string`&&e(`navigate-intercept`,n.url)}catch{}return ca.call(this,t)}),ta=!0}else ra||=window.history.pushState,window.history.pushState=function(...t){let n=ra.apply(window.history,t);return e(`pushState`),n},ia||=window.history.replaceState,window.history.replaceState=function(...t){let n=ia.apply(window.history,t);return e(`replaceState`),n},aa=()=>e(`popstate`),oa=()=>e(`hashchange`),window.addEventListener(`popstate`,aa),window.addEventListener(`hashchange`,oa),ta=!0}return ea}var ua=class extends B{constructor(...e){super(...e),this.name=`@grafana/faro-web-sdk:instrumentation-navigation`,this.version=F}initialize(){let e=ki(),t=Si(),n=la(),r=Qi([`pointerdown`,`keydown`]),i=new Ki(new N().merge(e,t,n),{inactivityMs:100,drainTimeoutMs:1e4,isOperationStart:e=>Wi(e)?e.request.requestId:void 0,isOperationEnd:e=>Gi(e)?e.request.requestId:void 0});i.filter(e=>e.message===`tracking-ended`).subscribe(e=>{if(e.events?.some(e=>e.type===`url-change`)&&e.events?.some(e=>e.type===`dom-mutation`)){let t=e.events?.find(e=>e.type===`url-change`);V.api.pushEvent(`faro.navigation`,{fromUrl:t?.from,toUrl:t?.to,sameDocument:`true`,duration:e.duration})}}),r.subscribe(()=>{i.startTracking()})}};function da(e={}){let t=[new Hi,new qn,new Kr,new fn,new Jn,new ua];return e.enablePerformanceInstrumentation!==!1&&t.unshift(new ui),e.enableContentSecurityPolicyInstrumentation!==!1&&t.push(new Ui),e.captureConsole!==!1&&t.push(new Un),t}var fa=e(((e,t)=>{(function(n,r){var i=`1.0.41`,a=``,o=`function`,s=`undefined`,c=`object`,l=`string`,u=`major`,d=`model`,f=`name`,p=`type`,m=`vendor`,h=`version`,g=`architecture`,_=`console`,v=`mobile`,y=`tablet`,b=`smarttv`,x=`wearable`,S=`embedded`,C=`Amazon`,ee=`Apple`,te=`ASUS`,ne=`BlackBerry`,re=`Browser`,ie=`Chrome`,w=`Edge`,T=`Firefox`,E=`Google`,ae=`Honor`,oe=`Huawei`,se=`Lenovo`,ce=`LG`,le=`Microsoft`,ue=`Motorola`,de=`Nvidia`,fe=`OnePlus`,D=`Opera`,O=`OPPO`,k=`Samsung`,pe=`Sharp`,me=`Sony`,he=`Xiaomi`,ge=`Zebra`,_e=`Facebook`,A=`Chromium OS`,ve=`Mac OS`,ye=` Browser`,be=function(e,t){var n={};for(var r in e)n[r]=t[r]&&t[r].length%2==0?t[r].concat(e[r]):e[r];return n},j=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},xe=function(e,t){return typeof e==l&&M(t).indexOf(M(e))!==-1},M=function(e){return e.toLowerCase()},Se=function(e){return typeof e==l?e.replace(/[^\d\.]/g,a).split(`.`)[0]:r},N=function(e,t){if(typeof e==l)return e=e.replace(/^\s\s*/,a),typeof t===s?e:e.substring(0,500)},Ce=function(e,t){for(var n=0,i,a,s,l,u,d;n<t.length&&!u;){var f=t[n],p=t[n+1];for(i=a=0;i<f.length&&!u&&f[i];)if(u=f[i++].exec(e),u)for(s=0;s<p.length;s++)d=u[++a],l=p[s],typeof l==c&&l.length>0?l.length===2?typeof l[1]==o?this[l[0]]=l[1].call(this,d):this[l[0]]=l[1]:l.length===3?typeof l[1]===o&&!(l[1].exec&&l[1].test)?this[l[0]]=d?l[1].call(this,d,l[2]):r:this[l[0]]=d?d.replace(l[1],l[2]):r:l.length===4&&(this[l[0]]=d?l[3].call(this,d.replace(l[1],l[2])):r):this[l]=d||r;n+=2}},P=function(e,t){for(var n in t)if(typeof t[n]==c&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(xe(t[n][i],e))return n===`?`?r:n}else if(xe(t[n],e))return n===`?`?r:n;return t.hasOwnProperty(`*`)?t[`*`]:e},we={"1.0":`/8`,"1.2":`/1`,"1.3":`/3`,"2.0":`/412`,"2.0.2":`/416`,"2.0.3":`/417`,"2.0.4":`/419`,"?":`/`},Te={ME:`4.90`,"NT 3.11":`NT3.51`,"NT 4.0":`NT4.0`,2e3:`NT 5.0`,XP:[`NT 5.1`,`NT 5.2`],Vista:`NT 6.0`,7:`NT 6.1`,8:`NT 6.2`,"8.1":`NT 6.3`,10:[`NT 6.4`,`NT 10.0`],RT:`ARM`},F={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[h,[f,`Chrome`]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[h,[f,`Edge`]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[f,h],[/opios[\/ ]+([\w\.]+)/i],[h,[f,D+` Mini`]],[/\bop(?:rg)?x\/([\w\.]+)/i],[h,[f,D+` GX`]],[/\bopr\/([\w\.]+)/i],[h,[f,D]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[h,[f,`Baidu`]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[h,[f,`Maxthon`]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[f,h],[/quark(?:pc)?\/([-\w\.]+)/i],[h,[f,`Quark`]],[/\bddg\/([\w\.]+)/i],[h,[f,`DuckDuckGo`]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[h,[f,`UC`+re]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[h,[f,`WeChat`]],[/konqueror\/([\w\.]+)/i],[h,[f,`Konqueror`]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[h,[f,`IE`]],[/ya(?:search)?browser\/([\w\.]+)/i],[h,[f,`Yandex`]],[/slbrowser\/([\w\.]+)/i],[h,[f,`Smart Lenovo `+re]],[/(avast|avg)\/([\w\.]+)/i],[[f,/(.+)/,`$1 Secure `+re],h],[/\bfocus\/([\w\.]+)/i],[h,[f,T+` Focus`]],[/\bopt\/([\w\.]+)/i],[h,[f,D+` Touch`]],[/coc_coc\w+\/([\w\.]+)/i],[h,[f,`Coc Coc`]],[/dolfin\/([\w\.]+)/i],[h,[f,`Dolphin`]],[/coast\/([\w\.]+)/i],[h,[f,D+` Coast`]],[/miuibrowser\/([\w\.]+)/i],[h,[f,`MIUI`+ye]],[/fxios\/([\w\.-]+)/i],[h,[f,T]],[/\bqihoobrowser\/?([\w\.]*)/i],[h,[f,`360`]],[/\b(qq)\/([\w\.]+)/i],[[f,/(.+)/,`$1Browser`],h],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[f,/(.+)/,`$1`+ye],h],[/samsungbrowser\/([\w\.]+)/i],[h,[f,k+` Internet`]],[/metasr[\/ ]?([\d\.]+)/i],[h,[f,`Sogou Explorer`]],[/(sogou)mo\w+\/([\d\.]+)/i],[[f,`Sogou Mobile`],h],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[f,h],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[f],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[h,f],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[f,_e],h],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[f,h],[/\bgsa\/([\w\.]+) .*safari\//i],[h,[f,`GSA`]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[h,[f,`TikTok`]],[/headlesschrome(?:\/([\w\.]+)| )/i],[h,[f,ie+` Headless`]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[f,ie+` WebView`],h],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[h,[f,`Android `+re]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[f,h],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[h,[f,`Mobile Safari`]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[h,f],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[f,[h,P,we]],[/(webkit|khtml)\/([\w\.]+)/i],[f,h],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[f,`Netscape`],h],[/(wolvic|librewolf)\/([\w\.]+)/i],[f,h],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[h,[f,T+` Reality`]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[f,[h,/_/g,`.`]],[/(cobalt)\/([\w\.]+)/i],[f,[h,/master.|lts./,``]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[g,`amd64`]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[g,`ia32`]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[g,`arm64`]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[g,`armhf`]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[g,`arm`]],[/((ppc|powerpc)(64)?)( mac|;|\))/i],[[g,/ower/,a,M]],[/ sun4\w[;\)]/i],[[g,`sparc`]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i],[[g,M]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[m,k],[p,y]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[d,[m,k],[p,v]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[m,ee],[p,v]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[m,ee],[p,y]],[/(macintosh);/i],[d,[m,ee]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[m,pe],[p,v]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[d,[m,ae],[p,y]],[/honor([-\w ]+)[;\)]/i],[d,[m,ae],[p,v]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[d,[m,oe],[p,y]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[m,oe],[p,v]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[d,/_/g,` `],[m,he],[p,y]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[d,/_/g,` `],[m,he],[p,v]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[m,O],[p,v]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[d,[m,P,{OnePlus:[`304`,`403`,`203`],"*":O}],[p,y]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[m,`Vivo`],[p,v]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[m,`Realme`],[p,v]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto(?! 360)[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[m,ue],[p,v]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[m,ue],[p,y]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[m,ce],[p,y]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv|watch)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[m,ce],[p,v]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[d,[m,se],[p,y]],[/(nokia) (t[12][01])/i],[m,d,[p,y]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*))/i],[[d,/_/g,` `],[p,v],[m,`Nokia`]],[/(pixel (c|tablet))\b/i],[d,[m,E],[p,y]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[m,E],[p,v]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[m,me],[p,v]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,`Xperia Tablet`],[m,me],[p,y]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[m,fe],[p,v]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[m,C],[p,y]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,`Fire Phone $1`],[m,C],[p,v]],[/(playbook);[-\w\),; ]+(rim)/i],[d,m,[p,y]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[m,ne],[p,v]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[m,te],[p,y]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[m,te],[p,v]],[/(nexus 9)/i],[d,[m,`HTC`],[p,y]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[m,[d,/_/g,` `],[p,v]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[d,[m,`TCL`],[p,y]],[/(itel) ((\w+))/i],[[m,M],d,[p,P,{tablet:[`p10001l`,`w7001`],"*":`mobile`}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[m,`Acer`],[p,y]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[m,`Meizu`],[p,v]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[m,`Ulefone`],[p,v]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[m,`Energizer`],[p,v]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[m,`Cat`],[p,v]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[m,`Smartfren`],[p,v]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[m,`Nothing`],[p,v]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[d,[m,`Archos`],[p,y]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[d,[m,`Archos`],[p,v]],[/(imo) (tab \w+)/i,/(infinix) (x1101b?)/i],[m,d,[p,y]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (hmd|imo) ([\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,/(oppo) ?([\w ]+) bui/i],[m,d,[p,v]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[m,d,[p,y]],[/(surface duo)/i],[d,[m,le],[p,y]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[m,`Fairphone`],[p,v]],[/(u304aa)/i],[d,[m,`AT&T`],[p,v]],[/\bsie-(\w*)/i],[d,[m,`Siemens`],[p,v]],[/\b(rct\w+) b/i],[d,[m,`RCA`],[p,y]],[/\b(venue[\d ]{2,7}) b/i],[d,[m,`Dell`],[p,y]],[/\b(q(?:mv|ta)\w+) b/i],[d,[m,`Verizon`],[p,y]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[m,`Barnes & Noble`],[p,y]],[/\b(tm\d{3}\w+) b/i],[d,[m,`NuVision`],[p,y]],[/\b(k88) b/i],[d,[m,`ZTE`],[p,y]],[/\b(nx\d{3}j) b/i],[d,[m,`ZTE`],[p,v]],[/\b(gen\d{3}) b.+49h/i],[d,[m,`Swiss`],[p,v]],[/\b(zur\d{3}) b/i],[d,[m,`Swiss`],[p,y]],[/\b((zeki)?tb.*\b) b/i],[d,[m,`Zeki`],[p,y]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[m,`Dragon Touch`],d,[p,y]],[/\b(ns-?\w{0,9}) b/i],[d,[m,`Insignia`],[p,y]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[m,`NextBook`],[p,y]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[m,`Voice`],d,[p,v]],[/\b(lvtel\-)?(v1[12]) b/i],[[m,`LvTel`],d,[p,v]],[/\b(ph-1) /i],[d,[m,`Essential`],[p,v]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[m,`Envizen`],[p,y]],[/\b(trio[-\w\. ]+) b/i],[d,[m,`MachSpeed`],[p,y]],[/\btu_(1491) b/i],[d,[m,`Rotor`],[p,y]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[d,[m,de],[p,y]],[/(sprint) (\w+)/i],[m,d,[p,v]],[/(kin\.[onetw]{3})/i],[[d,/\./g,` `],[m,le],[p,v]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[m,ge],[p,y]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[m,ge],[p,v]],[/smart-tv.+(samsung)/i],[m,[p,b]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,`SmartTV`],[m,k],[p,b]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[m,ce],[p,b]],[/(apple) ?tv/i],[m,[d,ee+` TV`],[p,b]],[/crkey/i],[[d,ie+`cast`],[m,E],[p,b]],[/droid.+aft(\w+)( bui|\))/i],[d,[m,C],[p,b]],[/(shield \w+ tv)/i],[d,[m,de],[p,b]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[m,pe],[p,b]],[/(bravia[\w ]+)( bui|\))/i],[d,[m,me],[p,b]],[/(mi(tv|box)-?\w+) bui/i],[d,[m,he],[p,b]],[/Hbbtv.*(technisat) (.*);/i],[m,d,[p,b]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[m,N],[d,N],[p,b]],[/droid.+; ([\w- ]+) (?:android tv|smart[- ]?tv)/i],[d,[p,b]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[p,b]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[m,d,[p,_]],[/droid.+; (shield)( bui|\))/i],[d,[m,de],[p,_]],[/(playstation \w+)/i],[d,[m,me],[p,_]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[m,le],[p,_]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[d,[m,k],[p,x]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[m,d,[p,x]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[d,[m,O],[p,x]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[m,ee],[p,x]],[/(opwwe\d{3})/i],[d,[m,fe],[p,x]],[/(moto 360)/i],[d,[m,ue],[p,x]],[/(smartwatch 3)/i],[d,[m,me],[p,x]],[/(g watch r)/i],[d,[m,ce],[p,x]],[/droid.+; (wt63?0{2,3})\)/i],[d,[m,ge],[p,x]],[/droid.+; (glass) \d/i],[d,[m,E],[p,x]],[/(pico) (4|neo3(?: link|pro)?)/i],[m,d,[p,x]],[/; (quest( \d| pro)?)/i],[d,[m,_e],[p,x]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[m,[p,S]],[/(aeobc)\b/i],[d,[m,C],[p,S]],[/(homepod).+mac os/i],[d,[m,ee],[p,S]],[/windows iot/i],[[p,S]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[p,v]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[p,y]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[p,y]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[p,v]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[d,[m,`Generic`]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[h,[f,w+`HTML`]],[/(arkweb)\/([\w\.]+)/i],[f,h],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[h,[f,`Blink`]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[f,h],[/ladybird\//i],[[f,`LibWeb`]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[h,f]],os:[[/microsoft (windows) (vista|xp)/i],[f,h],[/(windows (?:phone(?: os)?|mobile|iot))[\/ ]?([\d\.\w ]*)/i],[f,[h,P,Te]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[h,P,Te],[f,`Windows`]],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[h,/_/g,`.`],[f,`iOS`]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[f,ve],[h,/_/g,`.`]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[h,f],[/(ubuntu) ([\w\.]+) like android/i],[[f,/(.+)/,`$1 Touch`],h],[/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen|webos)\w*[-\/; ]?([\d\.]*)/i],[f,h],[/\(bb(10);/i],[h,[f,ne]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[h,[f,`Symbian`]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[h,[f,T+` OS`]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[h,[f,`webOS`]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[h,[f,`watchOS`]],[/crkey\/([\d\.]+)/i],[h,[f,ie+`cast`]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[f,A],h],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux)(?: arm\w*| x86\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[f,h],[/(sunos) ?([\w\.\d]*)/i],[[f,`Solaris`],h],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[f,h]]},I=function(e,t){if(typeof e==c&&(t=e,e=r),!(this instanceof I))return new I(e,t).getResult();var i=typeof n!==s&&n.navigator?n.navigator:r,_=e||(i&&i.userAgent?i.userAgent:a),b=i&&i.userAgentData?i.userAgentData:r,x=t?be(F,t):F,S=i&&i.userAgent==_;return this.getBrowser=function(){var e={};return e[f]=r,e[h]=r,Ce.call(e,_,x.browser),e[u]=Se(e[h]),S&&i&&i.brave&&typeof i.brave.isBrave==o&&(e[f]=`Brave`),e},this.getCPU=function(){var e={};return e[g]=r,Ce.call(e,_,x.cpu),e},this.getDevice=function(){var e={};return e[m]=r,e[d]=r,e[p]=r,Ce.call(e,_,x.device),S&&!e[p]&&b&&b.mobile&&(e[p]=v),S&&e[d]==`Macintosh`&&i&&typeof i.standalone!==s&&i.maxTouchPoints&&i.maxTouchPoints>2&&(e[d]=`iPad`,e[p]=y),e},this.getEngine=function(){var e={};return e[f]=r,e[h]=r,Ce.call(e,_,x.engine),e},this.getOS=function(){var e={};return e[f]=r,e[h]=r,Ce.call(e,_,x.os),S&&!e[f]&&b&&b.platform&&b.platform!=`Unknown`&&(e[f]=b.platform.replace(/chrome os/i,A).replace(/macos/i,ve)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return _},this.setUA=function(e){return _=typeof e==l&&e.length>500?N(e,500):e,this},this.setUA(_),this};I.VERSION=i,I.BROWSER=j([f,h,u]),I.CPU=j([g]),I.DEVICE=j([d,m,p,_,v,b,y,x,S]),I.ENGINE=I.OS=j([f,h]),typeof e===s?typeof define===o&&define.amd?define(function(){return I}):typeof n!==s&&(n.UAParser=I):(typeof t!==s&&t.exports&&(e=t.exports=I),e.UAParser=I);var Ee=typeof n!==s&&(n.jQuery||n.Zepto);if(Ee&&!Ee.ua){var L=new I;Ee.ua=L.getResult(),Ee.ua.get=function(){return L.getUA()},Ee.ua.set=function(e){L.setUA(e);var t=L.getResult();for(var n in t)Ee.ua[n]=t[n]}}})(typeof window==`object`?window:e)}))(),pa,ma;function ha(){let e=typeof navigator<`u`?navigator.userAgent:``;return(pa!==e||!ma)&&(ma=new fa.UAParser(e).getResult(),pa=e),ma}var ga=()=>{let{browser:e,os:t,ua:n}=ha(),{name:r,version:i}=e,{name:a,version:o}=t,s=navigator.language,c=n.includes(`Mobi`),l=u();return{browser:{name:r??b,version:i??b,os:`${a??b} ${o??b}`,userAgent:n??b,language:s??b,mobile:c,brands:l??b,viewportWidth:`${window.innerWidth}`,viewportHeight:`${window.innerHeight}`}};function u(){if(r&&i&&`userAgentData`in navigator&&navigator.userAgentData)return navigator.userAgentData.brands}},_a=()=>{let{name:e,version:t}=ha().os;if(!e&&!t)return{};let n={};return e&&(n.name=e),t&&(n.version=t),{os:n}},va=()=>({sdk:{name:`faro-web`,version:F}}),ya=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0-9]{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT$/,ba=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), ([0-9]{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT$/,xa=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?:(?:([0-9]{2}))|(?: ([0-9]))) ([0-9]{2}):([0-9]{2}):([0-9]{2}) ([0-9]{4})$/,Sa=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Ca=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],wa=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Ta({weekday:e,day:t,month:n,year:r,hour:i,minute:a,second:o}){if(r<1900||t<1||i>23||a>59||o>60)return;let s=o===60,c=new Date(0);if(c.setUTCFullYear(r,n,t),c.setUTCHours(i,a,s?59:o,0),c.getUTCDay()===e&&c.getUTCDate()===t&&c.getUTCMonth()===n&&c.getUTCFullYear()===r&&c.getUTCHours()===i&&c.getUTCMinutes()===a&&c.getUTCSeconds()===(s?59:o))return c.getTime()+(s?1e3:0)}function Ea(e,t){return e.month-t.month||e.day-t.day||e.hour-t.hour||e.minute-t.minute||e.second-t.second||e.millisecond-t.millisecond}function Da(e,t){let n=ya.exec(e);if(n){let[,e,t,r,i,a,o,s]=n;return Ta({weekday:Sa.indexOf(e),day:Number(t),month:wa.indexOf(r),year:Number(i),hour:Number(a),minute:Number(o),second:Number(s)})}let r=ba.exec(e);if(r){let[,e,n,i,a,o,s,c]=r,l=new Date(t);if(Number.isNaN(l.getTime()))return;let u=l.getUTCFullYear(),d=Math.floor(u/100)*100+Number(a);d<u&&(d+=100);let f=wa.indexOf(i),p={month:f,day:Number(n),hour:Number(o),minute:Number(s),second:Number(c),millisecond:0},m={month:l.getUTCMonth(),day:l.getUTCDate(),hour:l.getUTCHours(),minute:l.getUTCMinutes(),second:l.getUTCSeconds(),millisecond:l.getUTCMilliseconds()};return(d>u+50||d===u+50&&Ea(p,m)>0)&&(d-=100),Ta({weekday:Ca.indexOf(e),day:Number(n),month:f,year:d,hour:Number(o),minute:Number(s),second:Number(c)})}let i=xa.exec(e);if(!i)return;let[,a,o,s,c,l,u,d,f]=i;return Ta({weekday:Sa.indexOf(a),day:Number(s??c),month:wa.indexOf(o),year:Number(f),hour:Number(l),minute:Number(u),second:Number(d)})}var Oa=class{constructor(e){this.options=e,this.admitted=0,this.inProgress=0,this.sequence=0,this.nextSendAt=0,this.attemptQueue=[],this.waiting=[],this.unloading=!1}reserve(){var e=this;if(this.admitted>=this.options.bufferSize)return;this.admitted++;let t=this.sequence++,n=!1;return{deliver:function(){var n=Y(function*(n){let r=e.options.getNow(),i=0,a;for(;;){var o,s;let c=e.options.retry.maxAttempts-i,l=yield e.runAttempt(()=>n(c,e.unloading),i>0);if(i+=l.attemptsMade,l.kind===`success`)return{kind:`success`,attempts:i,elapsedTimeMs:e.options.getNow()-r};if(a=l.failure,l.kind===`terminal`||e.unloading)return{kind:`terminal`,attempts:i,elapsedTimeMs:e.options.getNow()-r,failure:a};if(i>=e.options.retry.maxAttempts)return{kind:`terminal`,attempts:i,elapsedTimeMs:e.options.getNow()-r,failure:a,reason:`retries-exhausted`};if(l.retryAfterMs!=null&&l.retryAfterMs>e.options.retry.maxBackoffMs)return{kind:`terminal`,attempts:i,elapsedTimeMs:e.options.getNow()-r,failure:a,reason:`retry-after-too-long`};let u=Math.min(l.retryAfterMs??e.options.retry.initialBackoffMs*e.options.retry.backoffMultiplier**(i-1),e.options.retry.maxBackoffMs);if((o=(s=e.options).onRetry)==null||o.call(s,u,i+1),yield e.waitForTurn(t,u)){let t=e.options.retry.maxAttempts-i,a=yield e.runAttempt(()=>n(t,!0));return i+=a.attemptsMade,{kind:a.kind===`success`?`success`:`terminal`,attempts:i,elapsedTimeMs:e.options.getNow()-r,failure:a.kind===`success`?void 0:a.failure}}}});return function(e){return n.apply(this,arguments)}}(),release:()=>{n||(n=!0,this.admitted--)}}}flush(){this.unloading=!0,this.nextSendAt=0;let e=this.waiting.splice(0);this.redeliveryTimer!=null&&(clearTimeout(this.redeliveryTimer),this.redeliveryTimer=void 0),this.waitingTimer!=null&&(clearTimeout(this.waitingTimer),this.waitingTimer=void 0);for(let t of e)t.resolve(!0);this.runNextAttempt()}resume(){this.unloading=!1}runAttempt(e,t=!1){return new Promise((n,r)=>{this.attemptQueue.push({run:()=>{this.inProgress++;let t=()=>{this.inProgress--,this.runNextAttempt()};e().then(e=>{t(),n(e)},e=>{t(),r(e)})},isRedelivery:t}),this.runNextAttempt()})}runNextAttempt(){for(this.redeliveryTimer!=null&&(clearTimeout(this.redeliveryTimer),this.redeliveryTimer=void 0);this.inProgress<this.options.concurrency&&this.attemptQueue.length>0;){let e=this.options.getNow(),t=this.attemptQueue.findIndex(({isRedelivery:t})=>this.unloading||!t||e>=this.nextSendAt);if(t<0){this.redeliveryTimer=setTimeout(()=>{this.redeliveryTimer=void 0,this.runNextAttempt()},Math.max(0,this.nextSendAt-e));return}let[n]=this.attemptQueue.splice(t,1);n.isRedelivery&&!this.unloading&&(this.nextSendAt=e+1),n.run()}}waitForTurn(e,t){let n=Math.min(t*(1+this.options.getRandom()*.2),this.options.retry.maxBackoffMs);return new Promise(t=>{this.waiting.push({sequence:e,readyAt:this.options.getNow()+n,resolve:t}),this.waiting.sort((e,t)=>e.readyAt===t.readyAt?e.sequence-t.sequence:e.readyAt-t.readyAt),this.waitingTimer!=null&&(clearTimeout(this.waitingTimer),this.waitingTimer=void 0),this.scheduleNext()})}scheduleNext(){if(this.waitingTimer!=null||this.waiting.length===0)return;let e=this.waiting[0],t=e.readyAt;this.waitingTimer=setTimeout(()=>{this.waitingTimer=void 0;let t=this.waiting.indexOf(e);t>=0&&this.waiting.splice(t,1),e.resolve(!1),this.scheduleNext()},Math.max(0,t-this.options.getNow()))}};function ka(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function Aa(e,t){if(e==null)return{};var n,r,i=ka(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var ja=[`headers`],Ma=[`keepalive`,`signal`],Na=30,Pa=5,Fa=3,Ia=1e3,La=3e4,Ra=2,za=1e4,Ba=new Set([408,425,429,500,502,503,504]),Va=new Set([429,503]),Ha=6e4,Ua=9,Wa=202,Ga=0,Ka=0,qa=class extends Error{};function Ja(e){return typeof TextEncoder>`u`?e.length:new TextEncoder().encode(e).byteLength}var Ya=class extends Pe{constructor(e){super(),this.options=e,this.name=`@grafana/faro-web-sdk:transport-fetch`,this.version=F,this.pendingCustomSends=0,this.getNow=e.getNow??Date.now,this.requestTimeoutMs=e.requestTimeoutMs??za,this.compressionEnabled=(e.requestCompression??!1)&&typeof CompressionStream<`u`,e.requestCompression&&!this.compressionEnabled&&this.logWarn(`requestCompression is enabled but CompressionStream is not available. Falling back to uncompressed.`),this.requestTimeoutMs>0&&typeof AbortController>`u`&&this.logWarn(`AbortController is unavailable. Requests will be sent without the configured timeout.`),this.deliveryQueue=new Oa({bufferSize:e.bufferSize??Na,concurrency:e.concurrency??Pa,retry:{maxAttempts:e.retry?.maxAttempts??Fa,initialBackoffMs:e.retry?.initialBackoffMs??e.defaultRateLimitBackoffMs??Ia,maxBackoffMs:e.retry?.maxBackoffMs??La,backoffMultiplier:e.retry?.backoffMultiplier??Ra},getNow:this.getNow,getRandom:e.getRandom??Math.random,onRetry:(e,t)=>{this.logDebug(`Retrying failed request after ${e}ms. Attempt ${t}.`)}}),this.customPromiseBuffer=ve({size:e.bufferSize??Na,concurrency:e.concurrency??Pa}),this.defaultPromiseBuffer={add:e=>{if(this.promiseBuffer!==this.defaultPromiseBuffer||this.promiseBuffer.add!==this.defaultBufferAdd||this.pendingCustomSends>0)return this.customPromiseBuffer.add(e);let t=this.deliveryQueue.reserve();if(!t)throw Error(`Task buffer full`);return this.runBufferedTask(t,e)}},this.defaultBufferAdd=this.defaultPromiseBuffer.add,this.promiseBuffer=this.defaultPromiseBuffer,typeof window<`u`&&(window.addEventListener(`pagehide`,()=>this.deliveryQueue.flush()),window.addEventListener(`pageshow`,e=>{e.persisted&&this.deliveryQueue.resume()}))}send(e){var t=this;return Y(function*(){let n=t.promiseBuffer;if(n===t.defaultPromiseBuffer&&n.add===t.defaultBufferAdd){yield t.deliver(e);return}t.pendingCustomSends++;try{yield n.add(()=>t.deliver(e))}catch(e){t.logError(`Permanent delivery failure`,{error:e,attempts:0,elapsedTimeMs:0})}finally{t.pendingCustomSends--}})()}runBufferedTask(e,t){return Y(function*(){let n;try{return yield e.deliver(Y(function*(){return n=yield t(),{kind:`success`,attemptsMade:1}})),n}finally{e.release()}})()}deliver(e){var t=this;return Y(function*(){let n=t.deliveryQueue.reserve();if(!n){t.logError(`Permanent delivery failure`,{error:`Reliable delivery queue is full`,attempts:0,elapsedTimeMs:0});return}try{let r=yield t.prepareRequest(e),i=yield n.deliver((e,n)=>t.performAttempt(r,e,n));i.kind===`terminal`&&t.logError(i.reason===`retries-exhausted`?`Delivery retries exhausted`:`Permanent delivery failure`,W(W({},i.failure),{},{reason:i.reason,attempts:i.attempts,elapsedTimeMs:i.elapsedTimeMs}))}catch(e){t.logError(`Permanent delivery failure`,{error:e,attempts:0,elapsedTimeMs:0})}finally{n.release()}})()}getIgnoreUrls(){return[this.options.url].concat(this.config.ignoreUrls??[])}isBatched(){return!0}prepareRequest(e){var t=this;return Y(function*(){let n=Ie(e),r=n.meta.session?.id,i=JSON.stringify(n),a=t.options.requestOptions??{},{headers:o={}}=a,s=Aa(a,ja),{keepalive:c,signal:l}=s,u=Aa(s,Ma),d={};for(let[e,t]of Object.entries(o))d[e]=typeof t==`function`?yield t():t;let f=i,p=Ja(i),m={};return t.compressionEnabled&&(f=yield t.compress(i),p=f.size,m[`Content-Encoding`]=`gzip`),{bodySize:p,sessionId:r,requestInit:W({method:`POST`,headers:W(W(W(W(W({"Content-Type":`application/json`},m),d),t.options.apiKey?{"x-api-key":t.options.apiKey}:{}),r?{"x-faro-session-id":r}:{}),{},{"Idempotency-Key":be(20)}),body:f},u)}})()}performAttempt(e,t,n){var r=this;return Y(function*(){let i=r.options.requestOptions?.signal;if(i?.aborted)return{kind:`terminal`,failure:{error:i.reason},attemptsMade:0};let a=0;try{let i=yield r.fetchWithKeepaliveFallback(e.requestInit,e.bodySize,n?!0:r.options.requestOptions?.keepalive,t,()=>a++);if(r.handleResponse(i,e.sessionId),i.status>=200&&i.status<300)return{kind:`success`,attemptsMade:a};let o={status:i.status};return!Ba.has(i.status)||n?{kind:`terminal`,failure:o,attemptsMade:a}:{kind:`retry`,failure:o,attemptsMade:a,retryAfterMs:Va.has(i.status)?r.getRetryAfterDelayMs(i):void 0}}catch(e){let t={error:e};return i?.aborted||!r.isFetchNetworkError(e)||n?{kind:`terminal`,failure:t,attemptsMade:a}:{kind:`retry`,failure:t,attemptsMade:a}}})()}fetchWithKeepaliveFallback(e,t,n,r,i){var a=this;return Y(function*(){let o=a.getNow(),s=a.reserveKeepalive(t,n);try{return yield a.fetchWithTimeout(W(W({},e),{},{keepalive:s.keepalive}),a.requestTimeoutMs,i)}catch(t){var c;if(s.keepalive&&r>1&&a.isFetchNetworkError(t)&&!(t instanceof qa)&&!((c=a.options.requestOptions)!=null&&(c=c.signal)!=null&&c.aborted)){a.logDebug(`Retrying failed keepalive request with keepalive disabled.`);let t=a.requestTimeoutMs-(a.getNow()-o);return a.fetchWithTimeout(W(W({},e),{},{keepalive:!1}),t,i)}throw t}finally{s.release()}})()}fetchWithTimeout(e,t,n){var r=this;return Y(function*(){let i=r.options.requestOptions?.signal;if(r.requestTimeoutMs<=0||typeof AbortController>`u`)return n(),fetch(r.options.url,W(W({},e),{},{signal:i}));if(t<=0)throw new qa(`Request timed out`);let a=new AbortController,o=()=>a.abort(i?.reason);i?.addEventListener(`abort`,o,{once:!0});let s=!1,c=setTimeout(()=>{s=!0,a.abort()},t);try{return n(),yield fetch(r.options.url,W(W({},e),{},{signal:a.signal}))}catch(e){throw s&&!i?.aborted?new qa(`Request timed out`):e}finally{clearTimeout(c),i?.removeEventListener(`abort`,o)}})()}getRetryAfterDelayMs(e){let t=e.headers.get(`Retry-After`);if(!t)return;if(/^\d+$/.test(t)){let e=Number(t)*1e3;return Number.isFinite(e)?e:1/0}let n=this.getNow(),r=Da(t,n);return r==null?void 0:Math.max(0,r-n)}reserveKeepalive(e,t){if(t===!1||e>Ha||Ga+e>Ha||Ka>=Ua)return{keepalive:!1,release:A};Ga+=e,Ka++;let n=!1;return{keepalive:!0,release:()=>{n||(n=!0,Ga-=e,Ka--)}}}handleResponse(e,t){e.status===Wa&&e.headers.get(`X-Faro-Session-Status`)===`invalid`&&this.extendFaroSession(this.config,this.logDebug.bind(this),t),e.text().catch(A)}isFetchNetworkError(e){return e instanceof TypeError||e instanceof qa||e instanceof DOMException&&e.name===`AbortError`}compress(e){return Y(function*(){let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}).pipeThrough(new CompressionStream(`gzip`)),n=[],r=t.getReader();for(;;){let{done:e,value:t}=yield r.read();if(e)return new Blob(n);n.push(t)}})()}extendFaroSession(e,t,n){let r=e.sessionTracking;if(!r?.enabled){t(`Session expired.`);return}let{fetchUserSession:i,storeUserSession:a}=dn(r),o=this.metas.value.session?.id,s=i()?.sessionId;if(!n||n!==o||n!==s){t(`Ignoring stale or cross-tab session-invalid response; request session no longer current.`);return}tn({fetchUserSession:i,storeUserSession:a})({forceSessionExtend:!0}),t(`Session expired; created new session.`)}},Xa=()=>{let e=window.k6;return{k6:W({isK6Browser:!0},e?.testRunId&&{testRunId:e?.testRunId})}},Za,Qa;function $a({generatePageId:e,initialPageMeta:t}={}){return()=>{let n=location.href;return T(e)&&Za!==n&&(Za=n,Qa=e(location)),{page:W(W({url:n},Qa?{id:Qa}:{}),t)}}}var eo=[`dedupe`,`eventDomain`,`globalObjectKey`,`instrumentations`,`internalLoggerLevel`,`isolate`,`logArgsSerializer`,`metas`,`paused`,`preventGlobalExposure`,`unpatchedConsole`,`url`,`experimental`];function to(e){let t=[],n=Me(e.unpatchedConsole,e.internalLoggerLevel);e.transports?((e.url||e.apiKey)&&n.error(`if "transports" is defined, "url" and "apiKey" should not be defined`),t.push(...e.transports)):e.url?t.push(new Ya({url:e.url,apiKey:e.apiKey,requestCompression:e.requestCompression})):n.error(`either "url" or "transports" must be defined`);let{dedupe:r=!0,eventDomain:i=m,globalObjectKey:a=At,instrumentations:o=da(),internalLoggerLevel:s=1,isolate:c=!1,logArgsSerializer:l=Je,metas:u=ro(e),paused:d=!1,preventGlobalExposure:f=!1,unpatchedConsole:p=je,url:h,experimental:g}=e,_=Aa(e,eo),v=g?.trackNavigation??!1,b={dataAttributeName:pi(e.userActionsInstrumentation?.dataAttributeName??di),excludeItem:e.userActionsInstrumentation?.excludeItem,initialActivityTimeout:hi(e.userActionsInstrumentation?.initialActivityTimeout,100,e=>n.warn(e))};return W(W({},_),{},{batching:W(W({},jt),e.batching),dedupe:r,globalObjectKey:a,instrumentations:no(o,e),internalLoggerLevel:s,isolate:c,logArgsSerializer:l,metas:u,parseStacktrace:wn,paused:d,preventGlobalExposure:f,transports:t,unpatchedConsole:p,eventDomain:i,ignoreUrls:[...e.ignoreUrls??[],...h?[h]:[],/\/collect(?:\/[\w]*)?$/],sessionTracking:W(W(W({},y),e.sessionTracking),io({trackGeolocation:e.trackGeolocation,sessionTracking:e.sessionTracking})),userActionsInstrumentation:b,experimental:{trackNavigation:v}})}function no(e,{experimental:t}){let n=t?.trackNavigation??!1;return e.filter(e=>!(e.name===`@grafana/faro-web-sdk:instrumentation-navigation`&&!n))}function ro(e){let{page:t,generatePageId:n}=e?.pageTracking??{},r=[ga,_a,$a({generatePageId:n,initialPageMeta:t}),...e.metas??[],va];return w(window?.k6)?[...r,Xa]:r}function io({trackGeolocation:e,sessionTracking:t}){let n={};return ie(e)&&(n.geoLocationTrackingEnabled=e),D(n)?{}:{session:W(W({},t?.session??{}),{},{overrides:n})}}function ao(e){let t=to(e);if(t)return kt(t)}var X=null;function oo(e={}){if(typeof window>`u`)return null;if(X)return X;try{let t=e.collectorUrl||typeof process<`u`&&{}.PUBLIC_FARO_URL||``;X=ao({url:t||`http://127.0.0.1:12347/collect`,app:{name:e.appName||`mcard-studio`,version:e.appVersion||`0.2.0`,environment:e.environment||`development`},paused:!t,isolate:!1});let n=[],r=[],i=X.api.pushMeasurement.bind(X.api);X.api.pushMeasurement=e=>(r.push(e),i(e));let a=X.api.pushError.bind(X.api);X.api.pushError=(e,t)=>(n.push({err:e,options:t}),a(e,t)),X.api.getErrors=()=>n,X.api.getMeasurements=()=>r;try{window.__CLM_CLS_METRIC__=0}catch{}try{window.__CLM_FARO_INITIALIZED__=!0}catch{}try{window.__FARO__=X}catch{}return console.log(`[Faro] Telemetry initialized cleanly in browser context`),X}catch(e){console.warn(`[Faro] Failed to initialize Grafana Faro SDK, falling back to mock:`,e);let t=[],n=[],r={api:{pushMeasurement:e=>{n.push(e)},pushError:e=>{t.push(e)},getErrors:()=>t,getMeasurements:()=>n}};try{window.__CLM_CLS_METRIC__=0}catch{}try{window.__FARO__=r}catch{}return r}}function so(){return!X&&typeof window<`u`?oo():X}var co=i([]);function Z(e,t,n,...r){let i=so(),a=typeof performance<`u`?performance.now():Date.now(),o=`span_${Date.now()}_${Math.random().toString(36).slice(2,7)}`;try{let s=n(...r),c=(typeof performance<`u`?performance.now():Date.now())-a;if(i)try{i.api.pushMeasurement({type:`flux_action_latency`,values:{duration_ms:c},context:{action:e}})}catch{}let l=co.get(),u=[{id:o,action:e,payload:t,durationMs:c,timestamp:Date.now()},...l].slice(0,100);return co.set(u),s}catch(n){let r=(typeof performance<`u`?performance.now():Date.now())-a;if(i)try{i.api.pushError(n instanceof Error?n:Error(String(n)),{context:{action:e,payload:JSON.stringify(t)}})}catch{}let s=co.get(),c=[{id:o,action:e,payload:t,durationMs:r,timestamp:Date.now(),error:n?.message||String(n)},...s].slice(0,100);throw co.set(c),n}}var lo=i(`card`);function uo(e){Z(`setEditorMode`,{mode:typeof e==`function`?`functional`:e},()=>{typeof e==`function`?lo.set(e(lo.get())):lo.set(e)})}var Q=p({}),fo=f(Q,e=>Object.keys(e).length);function po(e){Z(`closeTab`,{handle:e},()=>{let t={...Q.get()};if(delete t[e],Q.set(t),$.get()?.handle===e){let e=Object.keys(t);if(e.length>0){let t=e[e.length-1],n=So.get()[t];$.set(n||null)}else $.set(null)}})}function mo(){Z(`closeAllTabs`,{},()=>{Q.set({}),$.set(null)})}function ho(e){Z(`closeOtherTabs`,{keepHandle:e},()=>{let t=Q.get();if(t[e]&&(Q.set({[e]:t[e]}),$.get()?.handle!==e)){let t=So.get()[e];$.set(t||null)}})}function go(e){Z(`closeTabsToTheRight`,{targetHandle:e},()=>{let t=Q.get(),n=Object.keys(t),r=n.indexOf(e);if(r>=0){let i=n.slice(0,r+1),a={};for(let e of i)a[e]=t[e];Q.set(a);let o=$.get();if(o&&!a[o.handle]){let t=So.get()[e];$.set(t||null)}}})}var _o=i([]),vo=i(-1);function yo(e){Z(`scrubTimeMachine`,{targetIndex:e},()=>{let t=_o.get();if(e>=0&&e<t.length){vo.set(e);let n=t[e],r=Object.values(So.get()).find(e=>e.hash===n.snapshotHash);r&&$.set(r),console.log(`[TimeMachine] Replaying state to snapshot index ${e} (${n.snapshotHash})`)}})}function bo(e){if(e.coreCard)return e.coreCard;let r=e.content??(e.payloadCas?JSON.stringify(e.payloadCas):``),i=t.create(`did:clm:agent:studio`);return n.create(`mcard:${e.handle}`,r,i,1,new Map([[`path`,e.path],[`name`,e.name],[`mimeType`,e.mimeType],[`detectedType`,e.detectedType],[`epistemicStatus`,e.epistemicStatus]]))}function xo(e,t=``){let n=e.metadata;return{handle:e.uri.replace(/^mcard:/,``),hash:e.hash.asHex(),path:String(n.get(`path`)||t),name:String(n.get(`name`)||e.uri.split(`/`).pop()||`unnamed`),mimeType:String(n.get(`mimeType`)||`text/plain`),detectedType:n.get(`detectedType`)||`specification`,epistemicStatus:n.get(`epistemicStatus`)||`proposition`,readOnly:!1,content:e.payload.kind===`text`?e.payload.value:JSON.stringify(e.payload),coreCard:e}}var So=p({}),$=i(null),Co=i(0);function wo(){Co.set(Co.get()+1)}function To(e){Z(`openMCardFile`,{handle:e.handle,hash:e.hash},()=>{$.set(e);let t=So.get();for(let n of Object.keys(t))n.startsWith(`panel:`)&&(t[n]?.handle===e.handle||t[n]?.path===e.path)&&So.setKey(n,e);Q.setKey(e.handle,{title:e.name||e.handle,hash:e.hash,path:e.path,handle:e.handle,detectedType:e.detectedType,readOnly:e.readOnly??!1,scope:e.scope});let n=[..._o.get(),{timestamp:Date.now(),action:`open:${e.handle}`,snapshotHash:e.hash}];_o.set(n),vo.set(n.length-1)})}typeof window<`u`&&(window.__CLM_MCARD_TREE__=So,window.__CLM_ACTIVE_MCARD__=$,window.$mcardTree=So,window.$activeMCard=$,window.openMCardFile=To);var Eo=e=>e,Do={},Oo={addEventListener(){},removeEventListener(){}};function ko(){try{return typeof localStorage<`u`}catch{return!1}}ko()&&(Do=localStorage),typeof window<`u`&&(Oo={addEventListener(e,t,n){window.addEventListener(`storage`,t),window.addEventListener(`pageshow`,n)},removeEventListener(e,t,n){window.removeEventListener(`storage`,t),window.removeEventListener(`pageshow`,n)}});function Ao(e,t,n={}){let r=n.encode||Eo,a=n.decode||Eo,o=Do[e],s=i(e in Do?a(o):t),c=s.set;s.set=t=>{o=r(t),o===void 0?delete Do[e]:Do[e]=o,c(t)};function l(n){n.key===e?n.newValue===null?c(t):c(a(n.newValue)):e in Do||c(t)}function d(){o!==Do[e]&&s.set(e in Do?a(Do[e]):t)}return u(s,()=>{if(d(),n.listen!==!1)return Oo.addEventListener(e,l,d),()=>{Oo.removeEventListener(e,l,d)}}),s}var jo=i(`abstract`);function Mo(e){Z(`setDimension`,{dimension:e},()=>{jo.set(e)})}var No=Ao(`clm:dockview:layout:v1`,null,{encode:JSON.stringify,decode:e=>{try{return e?JSON.parse(e):null}catch{return null}}}),Po=i(!0);function Fo(){Po.set(!0)}function Io(){Po.set(!1)}typeof window<`u`&&(window.addEventListener(`clm:depress-dockview`,()=>{Fo()}),window.addEventListener(`clm:restore-dockview`,()=>{Io()}));var Lo=`browser:smollm2-360m`;function Ro(){if(typeof window>`u`)return Lo;let e=localStorage.getItem(`clm:chat:active_model`);if(e)return e;let t=localStorage.getItem(`clm:chat:provider`),n=localStorage.getItem(`clm:chat:model`),r=localStorage.getItem(`clm:llm_config:google_api_key`)||localStorage.getItem(`clm:gemini_api_key`);return t===`google`||r?n&&n.startsWith(`gemini`)?`gemini:${n}`:`gemini:gemini-3.8-flash`:t===`ollama`&&n?`ollama:${n}`:Lo}var zo=i(Ro()),Bo=i({online:!1,latencyMs:0,models:[]}),Vo=i({provider:`ollama`,baseUrl:`http://127.0.0.1:11434`,apiKey:``,temperature:.7,providerEoaDid:`did:pkc:eoa:local:ollama-daemon`});function Ho(e){let t=zo.get();t.startsWith(`gemini:`)||t.startsWith(`remote:`)||(!e.online||e.models.length===0?t.startsWith(`ollama:`)&&zo.set(Lo):t===`browser:smollm2-360m`&&e.models.length>0&&zo.set(`ollama:${e.models[0]}`))}function Uo(e){Z(`setOllamaStatus`,{online:e.online,modelCount:e.models.length},()=>{Bo.set(e),Ho(e)})}function Wo(e){Z(`updateLlmConfig`,e,()=>{Vo.set({...Vo.get(),...e})})}var Go=i({backendType:`memory`,cardCount:0,totalBytes:0,isPersistent:!1,lastSavedIso:null,supervisorState:`idle`});function Ko(e){Go.set({...Go.get(),...e})}var qo=i({online:!1,peerCount:0,peers:[],localDid:`did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK`});function Jo(e){qo.set({...qo.get(),...e})}var Yo=typeof window<`u`&&localStorage.getItem(`clm_sync_mode`)===`client`?`client`:`server`,Xo=i(Yo);typeof window<`u`&&(window.__CLM_SYNC_MODE__=Xo,window.$syncMode=Xo);export{Q as A,To as C,yo as D,vo as E,uo as F,so as I,oo as L,ho as M,po as N,fo as O,go as P,p as R,wo as S,_o as T,Ao as _,Ko as a,Co as b,Bo as c,jo as d,No as f,Mo as g,Io as h,Jo as i,mo as j,lo as k,Uo as l,Fo as m,Go as n,zo as o,Po as p,Xo as r,Vo as s,qo as t,Wo as u,$ as v,bo as w,xo as x,So as y};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/vendor-clm-kernel.Bvk3XHk2.js","_astro/rolldown-runtime.Dd_uD5pT.js","_astro/preload-helper.oCYlU9a4.js"])))=>i.map(i=>d[i]);
2
+ import{E as e,F as t,I as n,L as r,M as i,N as a}from"./vendor-clm-kernel.Bvk3XHk2.js";import{t as o}from"./preload-helper.oCYlU9a4.js";import{h as s}from"./themeStore.CEt0e54l.js";import{A as c,C as l,S as u,T as d,v as f,y as p}from"./mcardStore.CT-ollfl.js";import{r as m,t as h}from"./pathsConfig.D0hV34p7.js";import{t as g}from"./workspaceStore.CD0kAVAl.js";import{n as _,t as v}from"./cardTypeDetector.Ci4APwhX.js";import{r as y,t as b}from"./vfsPersistence.BuhXYeSb.js";import{n as x,r as S,t as C}from"./vfsHandles.IX_wTpw_.js";var w=class extends Error{path;expectedHash;actualHash;constructor(e,t,n){super(`Data transfer integrity violation: payload hash does not match server manifest for ${e} (expected ${t.slice(0,12)}, received ${n.slice(0,12)})`),this.name=`DataTransferIntegrityError`,this.path=e,this.expectedHash=t,this.actualHash=n}};async function T(e){if(typeof window<`u`)try{let n=x(e.path,e.hash),r=await fetch(n);if(!r.ok){console.warn(`[MCardVFS] Failed to fetch content for ${e.path}: HTTP ${r.status}`);return}let a=await r.text(),o=t.create(`did:clm:agent:vfs`),c=typeof e.content==`string`&&e.content.startsWith(`Content-addressed MCard:`);if(e.hash&&!c){let t=i.create(e.path||e.handle||`pinned`,a,o,0);if(t.hash.asHex()!==e.hash)throw new w(e.path,e.hash,t.hash.asHex());s.storageBackend?.put?.(t.hash,t);let n={...e,content:a,hash:e.hash,coreCard:t},r=p.get()[e.handle];r&&r.hash===e.hash&&p.setKey(e.handle,n);let c=f.get();return c&&c.hash===e.hash&&(c.handle===e.handle||c.path===e.path)&&f.set(n),y(),a}let l=s.writeFile(e.path,a,o),u={...e,content:a,hash:l.hash.asHex(),coreCard:l};p.get()[e.handle]&&p.setKey(e.handle,u);let d=f.get();return d&&(d.handle===e.handle||d.path===e.path)&&f.set(u),y(),a}catch(t){if(t instanceof w)throw t;console.warn(`[MCardVFS] Error fetching content for ${e.path}:`,t);return}}function E(n,r){let i=t.create(`did:clm:agent:studio`),a=p.get(),o=C(n,null,a),c=(o?.path||n).replace(/^mcard:/,``).replace(/:/g,`/`).replace(/^\/+/,``),l=o?.handle||c.replace(/\//g,`:`),u=o?.mimeType||_(c),d=v({path:c,mimeType:u,content:r}),m=o?.name||c.split(`/`).pop()||l,h=s.writeFile(c,r,i),g={handle:l,hash:h.hash.asHex(),path:c,name:m,mimeType:u,detectedType:d.detectedType,epistemicStatus:o?.epistemicStatus||e(c),readOnly:!1,subclass:d.subclass,content:r,coreCard:h};p.setKey(l,g),p.setKey(c,g);let b=f.get();return b&&(b.handle===l||b.path===c)&&f.set(g),y(),g}async function D(n,r){let i=t.create(`did:clm:agent:studio`),a=p.get(),o=typeof n==`string`?n:n.handle||n.path,c=typeof n==`object`&&n&&`handle`in n?n:C(o,null,a),d=(c?.path||o).replace(/^mcard:/,``).replace(/:/g,`/`).replace(/^\/+/,``),f=c?.handle||d.replace(/\//g,`:`),m=c?.mimeType||_(d),h=v({path:d,mimeType:m,content:r}),g=c?.name||d.split(`/`).pop()||f,b=s.writeFile(d,r,i),x={handle:f,hash:b.hash.asHex(),path:d,name:g,mimeType:m,detectedType:h.detectedType,epistemicStatus:c?.epistemicStatus||e(d),readOnly:!1,scope:`local-db`,subclass:h.subclass,content:r,coreCard:b};return p.setKey(f,x),d&&d!==f&&p.setKey(d,x),y(),l(x),u(),x}async function O(n,r,i){let a=t.create(`did:clm:agent:studio`),o=p.get(),c=typeof n==`string`?n:n.handle||n.path,d=typeof n==`object`&&n&&`handle`in n?n:C(c,null,o),f=(d?.path||c).replace(/^mcard:/,``).replace(/:/g,`/`).replace(/^\/+/,``),m=d?.handle||f.replace(/\//g,`:`),h=i||d?.mimeType||_(f),g=v({path:f,mimeType:h}),b=d?.name||f.split(`/`).pop()||m,x=s.writeFile(f,r,a),S={handle:m,hash:x.hash.asHex(),path:f,name:b,mimeType:h,detectedType:g.detectedType,epistemicStatus:d?.epistemicStatus||e(f),readOnly:!1,scope:`local-db`,subclass:g.subclass,content:r,coreCard:x};return p.setKey(m,S),f&&f!==m&&p.setKey(f,S),y(),l(S),u(),S}async function ee(e){let t=e.content===void 0?await T(e).catch(()=>void 0):e.content,n=`cards/forked_${e.name}`.replace(/\//g,`:`),r;return r=t instanceof Uint8Array?await O(n,t,e.mimeType):await D(n,typeof t==`string`?t:``),r={...r,detectedType:e.detectedType||r.detectedType,epistemicStatus:e.epistemicStatus||r.epistemicStatus,subclass:e.subclass||r.subclass,scope:`local-db`,readOnly:!1},p.setKey(r.handle,r),l(r),console.info(`[MCardVFS] Card forked into Local Database as '${r.name}'`),r}function k(e){return typeof e==`string`?e:new TextDecoder(`utf-8`).decode(e)}function A(e){return e.kind===`text`?e.value:e.kind===`binary`?new TextDecoder(`utf-8`).decode(e.data):e.kind===`scalar`?String(e.value??``):e.kind===`satori`?e.value.content:JSON.stringify(e.value??``)}async function j(e,t){if(!e||typeof e!=`string`)return null;let n=e.trim();if(n.startsWith(`mcard:`)||n.startsWith(`hash:`)){let e=n.match(/^(?:mcard:(?:blake3|sha256):|hash:)?([a-fA-F0-9]{32,64})$/),t=e?e[1]:n.replace(/^(mcard:[^:]+:|hash:)/,``);try{let e=s.readFileByHash(t);if(e&&e.payload)return{content:A(e.payload),hash:e.hash.asHex(),handle:e.uri,path:e.uri.replace(/:/g,`/`),sourceType:`cas-hash`}}catch{let e=p.get(),n=Object.values(e).find(e=>e.hash.toLowerCase()===t.toLowerCase());if(n&&n.content)return{content:k(n.content),hash:n.hash,handle:n.handle,path:n.path,sourceType:`cas-hash`}}}let r=n.startsWith(`handle:`),i=r?n.slice(7).trim():n,a=i;if(t&&(i.startsWith(`./`)||i.startsWith(`../`))){let e=t.split(`/`).slice(0,-1).join(`/`),n=(e?`${e}/${i}`:i).split(`/`),r=[];for(let e of n)e&&e!==`.`&&(e===`..`?r.pop():r.push(e));a=r.join(`/`)}let c=p.get(),l=C(i,null,c)||C(a,null,c);if(l){let e=l.content;if(!e&&typeof window<`u`&&(e=await T(l).catch(()=>void 0)),e)return{content:k(e),hash:l.hash,handle:l.handle,path:l.path,sourceType:r?`handle`:i.includes(`/`)?`vfs-path`:`handle`}}try{let e=s.readFile(i)||s.readFile(a);if(e&&e.payload)return{content:A(e.payload),hash:e.hash.asHex(),handle:e.uri,path:e.uri.replace(/:/g,`/`),sourceType:r?`handle`:`vfs-path`}}catch{}if(typeof process<`u`&&process.versions?.node)try{let e=await o(()=>import(`./vendor-clm-kernel.Bvk3XHk2.js`).then(e=>e.k),__vite__mapDeps([0,1,2])),t=await o(()=>import(`./vendor-clm-kernel.Bvk3XHk2.js`).then(e=>e.O),__vite__mapDeps([0,1,2])),n={}.MCARD_WORKSPACE_ROOT||t.resolve(process.cwd(),h.paths.workspace_dirname),i=process.cwd(),s=[a,t.resolve(n,a),t.resolve(i,a),t.resolve(i,h.paths.assets_dirname,a)];for(let t of s)if(e.existsSync(t)&&!e.statSync(t).isDirectory())return{content:e.readFileSync(t,`utf8`),path:a,handle:a.replace(/\//g,`:`),sourceType:r?`handle`:`vfs-path`}}catch{}if(typeof window<`u`)try{let e=x(a),t=await fetch(e);if(t.ok)return{content:await t.text(),path:a,handle:a.replace(/\//g,`:`),sourceType:r?`handle`:`vfs-path`}}catch{}let u=await S(i);return u&&u.content?{content:k(u.content),hash:u.hash,handle:u.handle,path:u.path,sourceType:`handle`}:null}var M={},N={},P=`local-db`;async function F(e=!1,t){let n=t||g.get();if(P===`local-db`&&n!==`local-db`&&(N={...p.get()}),n===`local-db`){let e=N;return Object.keys(e).length===0?(typeof window<`u`&&await b(),e={...p.get()},N=e):p.set(e),P=n,e}if(!e&&M[n])return p.set(M[n]),P=n,M[n];if(typeof fetch!=`function`)return p.get();try{let e=m(`vfs_tree`),t=await fetch(`${e}?scope=${encodeURIComponent(n)}&t=${Date.now()}`);if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();if(!r.success||!Array.isArray(r.files))throw Error(`Malformed tree response`);let i={};for(let e of r.files)i[e.handle||e.path]={...e,scope:n,readOnly:!0};return M[n]=i,p.set(i),P=n,i}catch(e){return console.warn(`[vfsSync] Failed to sync read-only scope ${n}:`,e),p.get()}}var I=h.paths.workspace_dirname;async function L(e=!1){if(typeof fetch!=`function`)return p.get();try{let t=m(`vfs_tree`),n=await fetch(`${t}?t=${Date.now()}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(!r.success||!Array.isArray(r.files))throw Error(`Malformed tree response`);let i={...p.get()};for(let t of r.files){let n=t.handle||t.path,r=t.scope||h.paths.assets_dirname,a=i[n];!e&&a&&typeof a.content==`string`&&a.content.length>0||(i[n]={...t,scope:r,readOnly:r!==I})}return p.set(i),y(),i}catch(e){return console.warn(`[vfsSync] Multi-scope federation failed:`,e),p.get()}}var R={version:1,note:"Canonical boot-time seed registry. Each entry is a content-addressed MCard identified by handle; `locator` is a tokenized ingest target (paths are locators, not operands — Program PC §1.4). Tokens are resolved against paths.* at bootstrap. `content`, when present, is the canonical payload; otherwise the bootstrap derives a stable placeholder from the handle.",tokens:{"{assets}":`paths.assets_dirname`,"{knowledge}":`paths.knowledge_dirname`},entries:[{handle:`assets:media:documents:sample.pdf`,locator:`{assets}/media/documents/sample.pdf`,readOnly:!0},{handle:`assets:media:documents:sample.txt`,locator:`{assets}/media/documents/sample.txt`,readOnly:!0},{handle:`assets:media:documents:sample.xml`,locator:`{assets}/media/documents/sample.xml`,readOnly:!0},{handle:`assets:media:documents:sample.csv`,locator:`{assets}/media/documents/sample.csv`,readOnly:!0},{handle:`assets:media:documents:sample.json`,locator:`{assets}/media/documents/sample.json`,readOnly:!0},{handle:`assets:media:documents:sample.md`,locator:`{assets}/media/documents/sample.md`,readOnly:!0},{handle:`assets:media:documents:categorical_logic.md`,locator:`{assets}/media/documents/categorical_logic.md`,readOnly:!0},{handle:`assets:media:documents:homotopy_type_theory.md`,locator:`{assets}/media/documents/homotopy_type_theory.md`,readOnly:!0},{handle:`assets:media:documents:mcard_specification.md`,locator:`{assets}/media/documents/mcard_specification.md`,readOnly:!0},{handle:`assets:media:documents:sample.html`,locator:`{assets}/media/documents/sample.html`,readOnly:!0},{handle:`assets:media:images:sample.png`,locator:`{assets}/media/images/sample.png`,readOnly:!0},{handle:`assets:media:images:sample.jpeg`,locator:`{assets}/media/images/sample.jpeg`,readOnly:!0},{handle:`assets:media:images:sample.webp`,locator:`{assets}/media/images/sample.webp`,readOnly:!0},{handle:`assets:media:images:sample.svg`,locator:`{assets}/media/images/sample.svg`,readOnly:!0},{handle:`assets:media:images:sample.gif`,locator:`{assets}/media/images/sample.gif`,readOnly:!0},{handle:`assets:media:models:sample.3ds`,locator:`{assets}/media/models/sample.3ds`,readOnly:!0},{handle:`assets:media:models:sample.obj`,locator:`{assets}/media/models/sample.obj`,readOnly:!0},{handle:`assets:media:models:sample.stl`,locator:`{assets}/media/models/sample.stl`,readOnly:!0},{handle:`assets:media:models:sample.gltf`,locator:`{assets}/media/models/sample.gltf`,readOnly:!0},{handle:`assets:media:models:sample.glb`,locator:`{assets}/media/models/sample.glb`,readOnly:!0},{handle:`assets:media:audio:sample.wav`,locator:`{assets}/media/audio/sample.wav`,readOnly:!0},{handle:`assets:media:audio:sample.mp3`,locator:`{assets}/media/audio/sample.mp3`,readOnly:!0},{handle:`assets:media:audio:spotify_track.txt`,locator:`{assets}/media/audio/spotify_track.txt`,readOnly:!0,content:`https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT`},{handle:`assets:media:videos:sample.mp4`,locator:`{assets}/media/videos/sample.mp4`,readOnly:!0},{handle:`assets:media:videos:youtube_stream.txt`,locator:`{assets}/media/videos/youtube_stream.txt`,readOnly:!0,content:`https://www.youtube.com/watch?v=M7lc1UVf-VE`},{handle:`assets:webapps:plane.url`,locator:`{assets}/webapps/plane.url`,readOnly:!0,content:`http://plane.pkc.pub`},{handle:`assets:webapps:plane.txt`,locator:`{assets}/webapps/plane.txt`,readOnly:!0,content:`http://plane.pkc.pub`},{handle:`assets:webapps:so.url`,locator:`{assets}/webapps/so.url`,readOnly:!0,content:`http://so.pkc.pub`},{handle:`assets:webapps:so.txt`,locator:`{assets}/webapps/so.txt`,readOnly:!0,content:`http://so.pkc.pub`},{handle:`assets:webapps:gev.url`,locator:`{assets}/webapps/gev.url`,readOnly:!0,content:`http://gev.pkc.pub`},{handle:`assets:webapps:gev.txt`,locator:`{assets}/webapps/gev.txt`,readOnly:!0,content:`http://gev.pkc.pub`},{handle:`assets:webapps:pkc.url`,locator:`{assets}/webapps/pkc.url`,readOnly:!0,content:`http://pkc.pub`},{handle:`assets:webapps:pkc.txt`,locator:`{assets}/webapps/pkc.txt`,readOnly:!0,content:`http://pkc.pub`},{handle:`assets:webapps:osirisai.url`,locator:`{assets}/webapps/osirisai.url`,readOnly:!0,content:`https://osirisai.live`},{handle:`assets:webapps:osirisai.txt`,locator:`{assets}/webapps/osirisai.txt`,readOnly:!0,content:`https://osirisai.live`},{handle:`assets:media:apps:gods_eye_view.url`,locator:`{assets}/media/apps/gods_eye_view.url`,readOnly:!0,content:`http://gev.pkc.pub`},{handle:`assets:media:apps:osirisai.url`,locator:`{assets}/media/apps/osirisai.url`,readOnly:!0,content:`https://osirisai.live`},{handle:`assets:clm:configs:network_mesh.yaml`,locator:`{assets}/clm/configs/network_mesh.yaml`,readOnly:!0},{handle:`assets:clm:configs:observability.yaml`,locator:`{assets}/clm/configs/observability.yaml`,readOnly:!0},{handle:`assets:clm:configs:backup_params.yaml`,locator:`{assets}/clm/configs/backup_params.yaml`,readOnly:!0},{handle:`assets:clm:schemas:mcard_sample_schema.yaml`,locator:`{assets}/clm/schemas/mcard_sample_schema.yaml`,readOnly:!0},{handle:`assets:personal:profiles:sample_did_profile.json`,locator:`{assets}/personal/profiles/sample_did_profile.json`,readOnly:!0},{handle:`computable_knowledge:Abstract:e2e:playwright_spec.yaml`,locator:`{knowledge}/Abstract/e2e/playwright_spec.yaml`,readOnly:!0},{handle:`computable_knowledge:Balanced:e2e:test_studio_workbench_witness.yaml`,locator:`{knowledge}/Balanced/e2e/test_studio_workbench_witness.yaml`,readOnly:!0},{handle:`computable_knowledge:Concrete:e2e:clm_arithmetic_pcard.yaml`,locator:`{knowledge}/Concrete/e2e/clm_arithmetic_pcard.yaml`,readOnly:!0},{handle:`computable_knowledge:Concrete:e2e:test_studio_workbench.ts`,locator:`{knowledge}/Concrete/e2e/test_studio_workbench.ts`,readOnly:!0},{handle:`computable_knowledge:Concrete:e2e:test_card_panel_media.ts`,locator:`{knowledge}/Concrete/e2e/test_card_panel_media.ts`,readOnly:!0},{handle:`computable_knowledge:Concrete:e2e:test_faro_rum_observability.ts`,locator:`{knowledge}/Concrete/e2e/test_faro_rum_observability.ts`,readOnly:!0},{handle:`computable_knowledge:Concrete:e2e:test_chatbot_multimodal.ts`,locator:`{knowledge}/Concrete/e2e/test_chatbot_multimodal.ts`,readOnly:!0}]}.entries.map(e=>({path:e.locator.replace(`{assets}`,h.paths.assets_dirname).replace(`{knowledge}`,h.paths.knowledge_dirname),handle:e.handle,contentSnippet:e.content,readOnly:e.readOnly??!0}));function z(){let n={},r=t.create(`did:clm:agent:vfs`);for(let t of R){let i=_(t.path),a=v({path:t.path,mimeType:i}),o=t.path.split(`/`).pop()||t.handle,c=t.contentSnippet||`Content-addressed MCard: ${t.handle}\nPath: ${t.path}`,l=e(t.path),u=s.writeFile(t.path,c,r),d={handle:t.handle,hash:u.hash.asHex(),path:t.path,name:o,mimeType:i,detectedType:a.detectedType,epistemicStatus:l,readOnly:!0,subclass:a.subclass,content:c,coreCard:u};n[t.handle]=d}return p.set(n),y(),typeof window<`u`&&b().then(()=>F()).then(()=>L()).catch(e=>{console.warn(`[MCardVFS] Initial server sync error:`,e)}),n}function B(e){let t=e;if(t.startsWith(`data:`)){let e=t.indexOf(`,`);e!==-1&&(t=t.slice(e+1))}if(typeof Buffer<`u`)return new Uint8Array(Buffer.from(t,`base64`));let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function V(e){if(typeof Buffer<`u`)return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`);let t=``,n=e.byteLength,r=8192;for(let i=0;i<n;i+=r){let a=e.subarray(i,Math.min(i+r,n));t+=String.fromCharCode.apply(null,a)}return btoa(t)}function H(e,t=0,n=e.length){let r=[],i=Math.min(t+n,e.length);for(let n=t;n<i;n+=16){let t=n.toString(16).padStart(8,`0`).toUpperCase(),i=e.slice(n,n+16),a=[],o=[],s=``;for(let e=0;e<16;e++)if(e<i.length){let t=i[e],n=t.toString(16).padStart(2,`0`).toUpperCase();e<8?a.push(n):o.push(n),s+=t>=32&&t<=126?String.fromCharCode(t):`.`}else e<8?a.push(` `):o.push(` `),s+=` `;r.push({offset:t,hex1:a.join(` `),hex2:o.join(` `),ascii:s})}return r}async function U(e,n){let r=n;if(!r){let t=e.trim().split(`
3
+ `)[0].replace(/^[#\s*`]+/,``).trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,30),n=Date.now().toString().slice(-6);r=t?`response-${t}-${n}.md`:`response-${Date.now()}.md`}r.endsWith(`.md`)||(r+=`.md`);let i=`${h.paths.assets_dirname}/${r}`,a=i.replace(/\//g,`:`),o=`text/markdown`,c=v({path:i,mimeType:o}),u=t.create(`did:clm:agent:studio`),d=s.writeFile(i,e,u),f={handle:a,hash:d.hash.asHex(),path:i,name:r,mimeType:o,detectedType:c.detectedType,epistemicStatus:`definition`,readOnly:!1,subclass:c.subclass,content:e,coreCard:d};if(typeof window<`u`)try{let t=await fetch(m(`vfs_raw`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i,content:e})});if(t.ok){let n=await t.json();n.success&&n.file&&(f={...f,...n.file,content:e,coreCard:d})}}catch(e){console.warn(`[MCardVFS] Failed to persist new MCard to server disk; retained in local VFS:`,e)}return p.setKey(a,f),y(),l(f),typeof window<`u`&&setTimeout(()=>{F(!0).catch(()=>{})},500),f}var W=new Set(`a.an.the.of.in.on.at.to.for.with.and.or.by.from.as.is.are.was.were.it.its.this.that.illustration.image.picture.photo.style.generate.draw.depict`.split(`.`));function G(e,t,n){let r=`.jpg`;if(t){let e=t.toLowerCase();e.includes(`png`)?r=`.png`:e.includes(`webp`)&&(r=`.webp`)}if(n&&n.trim())return(n.trim().replace(/\.(png|jpe?g|webp)$/i,``).toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)||`custom-image`)+r;let i=``;e&&e.trim()&&(i=e.toLowerCase().replace(/[^a-z0-9]+/g,` `).trim().split(/\s+/).filter(e=>e.length>1&&!W.has(e)).slice(0,6).join(`-`).slice(0,36).replace(/-+$/,``));let a=Date.now().toString().slice(-6);return i?`image-${i}-${a}${r}`:`image-${a}${r}`}async function K(e){let n=e.mimeType||`image/jpeg`,r=G(e.prompt,n,e.preferredName),i=`${h.paths.assets_dirname}/${r}`,o=i.replace(/\//g,`:`),c=e.authorDid||t.create(`did:clm:agent:studio`),u=B(e.base64Data),d=a(n,u),f=s.writeFile(i,d,c),g=e.base64Data;if(g.startsWith(`data:`)){let e=g.indexOf(`,`);g=e===-1?g:g.slice(e+1)}let _=`data:${n};base64,${g}`,v={handle:o,hash:f.hash.asHex(),path:i,name:r,mimeType:n,detectedType:`image`,epistemicStatus:`empirical`,readOnly:!1,subclass:`MCard`,content:_,coreCard:f,sizeBytes:u.length};if(typeof window<`u`)try{let e=await fetch(m(`vfs_raw`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i,content:_,encoding:`base64`})});if(e.ok){let t=await e.json();t.success&&t.file&&(v={...v,...t.file,hash:f.hash.asHex(),content:_,coreCard:f})}}catch(e){console.warn(`[MCardVFS] Failed to persist image to server disk; retained in local VFS:`,e)}return p.setKey(o,v),p.setKey(i,v),y(),l(v),typeof window<`u`&&setTimeout(()=>{F(!0).catch(()=>{})},500),v}function q(e){v({path:e.path,mimeType:e.mimeType});let t={handle:e.id,hash:e.hash,path:e.path,name:e.name,mimeType:e.mimeType,detectedType:`image`,epistemicStatus:`empirical`,readOnly:!0,content:e.content,subclass:`MCard`,sizeBytes:e.sizeBytes};return p.setKey(e.id,t),p.setKey(e.path,t),t}function J(e,t){if(!t)return e;let n=t.toLowerCase(),r=``;return n.includes(`png`)?r=`.png`:n.includes(`jpeg`)||n.includes(`jpg`)?r=`.jpg`:n.includes(`webp`)?r=`.webp`:n.includes(`svg`)?r=`.svg`:n.includes(`gif`)?r=`.gif`:n.includes(`markdown`)||n.includes(`md`)?r=`.md`:n.includes(`json`)?r=`.json`:n.includes(`yaml`)||n.includes(`yml`)?r=`.yaml`:n.includes(`typescript`)||n.includes(`x-typescript`)?r=`.ts`:n.includes(`javascript`)&&(r=`.js`),!r||e.toLowerCase().endsWith(r)?e:`${e.replace(/\.[^.]+$/,``)}${r}`}function Y(e,t){let n=p.get(),r=C(e,null,n),i=r?.path||e,a=r?.handle||i.replace(/\//g,`:`),o=r?.hash;try{let e=s.readFile(i);e&&(o=e.hash.asHex())}catch{try{let e=s.readFile(a);e&&(o=e.hash.asHex())}catch{}}let c=s.history(i).concat(s.history(a)),l=new Set,u=[];for(let e of c){let t=e.previousHash.asHex(),n=`${t}:${e.changedAt}`;!l.has(n)&&t!==o&&(l.add(n),u.push({hash:t,changedAt:e.changedAt}))}let d=[];if(u.forEach((e,n)=>{d.push({version:n+1,hash:e.hash,changedAt:e.changedAt,isHead:!1,isCurrentView:t?t===e.hash:!1})}),o){let e=!t||t===o,n=`—`;try{n=s.statFile(i).updatedAt}catch{try{n=s.statFile(a).updatedAt}catch{let e=r?.coreCard?.metadata.get(`updatedAt`)||r?.coreCard?.metadata.get(`timestamp`);e&&(typeof e==`string`||typeof e==`number`)&&(n=new Date(e).toISOString())}}d.push({version:d.length+1,hash:o,changedAt:n,isHead:!0,isCurrentView:e})}return d.reverse()}function X(e,t){try{return{versions:Y(e,t),degraded:!1}}catch(e){return console.warn(`[MCardVFS] Failed to compute version list:`,e),{versions:[],degraded:!0,reason:e?.message||String(e)}}}async function Z(e,n,r){try{let a=p.get(),o=C(e,null,a);if(!o)return null;let c=o.content,l;try{l=s.readFileByHash(n),c=l.payload.kind===`text`?l.payload.value:l.payload.kind===`binary`||l.payload.data?l.payload.data:l.payload}catch(e){if(console.warn(`[MCardVFS] Local CAS read for hash ${n} missed:`,e),typeof window<`u`)try{let e=x(o.path||o.handle,n),r=await fetch(e);if(r.ok){let e=(o.mimeType||``).startsWith(`text/`)||o.mimeType===`application/json`||(o.path||``).endsWith(`.md`)||(o.path||``).endsWith(`.txt`),n=t.create(`did:clm:agent:vfs`),a=o.path||o.handle;if(e){let e=await r.text();c=e;try{l=i.create(a,e,n,0),s.storageBackend?.put(l.hash,l)}catch(e){console.warn(`[MCardVFS] Failed to ingest fetched text version to CAS:`,e)}}else{let e=await r.arrayBuffer(),t=new Uint8Array(e);c=t;try{l=i.create(a,t,n,0),s.storageBackend?.put(l.hash,l)}catch(e){console.warn(`[MCardVFS] Failed to ingest fetched binary version to CAS:`,e)}}}}catch(e){console.warn(`[MCardVFS] Network fallback for historical version failed:`,e)}}let m={...o,hash:n,content:c,coreCard:l||o.coreCard};f.set(m),o.handle&&p.setKey(o.handle,m),o.path&&o.path!==o.handle&&p.setKey(o.path,m),r&&r!==`workspace-primary`&&p.setKey(r,m);let h=d.get();return d.set([...h,{timestamp:Date.now(),action:`version:${n.slice(0,8)}`,snapshotHash:n}]),u(),m}catch(e){return console.error(`[MCardVFS] Failed to switch MCard version:`,e),null}}async function te(e,n){try{let r=p.get(),i=C(e,null,r);if(!i)return null;let a;try{a=s.readFileByHash(n)}catch{if(typeof window<`u`)try{let e=x(i.path||i.handle,n),r=await fetch(e);if(r.ok){let e=(i.mimeType||``).startsWith(`text/`)||i.mimeType===`application/json`||(i.path||``).endsWith(`.md`)||(i.path||``).endsWith(`.txt`),n=t.create(`did:clm:agent:vfs`);if(e){let e=await r.text();a=s.writeFile(i.path||i.handle,e,n)}else{let e=await r.arrayBuffer();a=s.writeFile(i.path||i.handle,new Uint8Array(e),n)}}}catch{}}let o=i.path||i.handle;if(a){if(a.payload.kind===`text`)return await D(o,a.payload.value);if(a.payload.kind===`binary`||a.payload.data){let e=a.payload.data;return await O(o,e instanceof Uint8Array?e:new Uint8Array(e),a.payload.mimeType||i.mimeType)}}return typeof i.content==`string`?await D(o,i.content):i.content instanceof Uint8Array?await O(o,i.content,i.mimeType):null}catch(e){return console.error(`[MCardVFS] Failed to restore MCard version:`,e),null}}function Q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ne(e,t,n,r){let i=p.get(),a=[],o=new Map;for(let e of Object.values(i))e&&e.handle&&o.set(e.handle,e);let s=new RegExp(Q(e),`g`),c=new RegExp(Q(n),`g`);for(let i of o.values())if(i.handle!==e&&i.handle!==t&&i.path!==n&&i.path!==r&&typeof i.content==`string`){let o=i.content,l=!1;o.includes(e)&&(o=o.replace(s,t),l=!0),o.includes(n)&&(o=o.replace(c,r),l=!0),l&&(E(i.handle,o),a.push(i.handle))}return{referencingCardsUpdated:a.length,updatedHandles:a}}async function $(e,t){let i=C(e);if(!i){let n=p.get(),r=e.endsWith(`/`)?e:`${e}/`,i=Object.values(n).filter((e,t,n)=>e.path.startsWith(r)&&n.findIndex(t=>t.path===e.path)===t);if(i.length===0)throw Error(`MCard not found for target: ${e}`);let a;if(t.includes(`/`))a=t.replace(/^\/+/,``);else{let n=e.lastIndexOf(`/`),r=n===-1?``:e.substring(0,n);a=r?`${r}/${t}`:t}let o=i[0];for(let e of i){let t=e.path.slice(r.length),n=`${a}/${t}`,i=await $(e.path,n);i.node&&(o=i.node)}return{success:!0,oldPath:e,newPath:a,oldHandle:e.replace(/\//g,`:`),newHandle:a.replace(/\//g,`:`),node:o}}let a=i.path,o=i.handle,l;if(t.includes(`/`))l=t.replace(/^\/+/,``);else{let e=a.lastIndexOf(`/`),n=e===-1?``:a.substring(0,e);l=n?`${n}/${t}`:t}let u=l.lastIndexOf(`/`),d=u===-1?``:l.substring(0,u),m=J(u===-1?l:l.substring(u+1),i.mimeType);if(l=d?`${d}/${m}`:m,a===l)return{success:!0,oldPath:a,newPath:l,oldHandle:o,newHandle:o,node:i};let h=l.replace(/\//g,`:`),g={...i,handle:h,path:l,name:m};try{let e=r.parse(h),t=n.parse(i.hash);s.storageBackend.registerHandle(e,t);let a=r.parse(l);s.storageBackend.registerHandle(a,t)}catch{}let _={...p.get()};delete _[a],delete _[o],_[l]=g,_[h]=g,p.set(_);let v=f.get();v&&(v.handle===o||v.path===a)&&f.set(g);let b={...c.get()};if(b[o]){let e=b[o];delete b[o],b[h]={...e,title:g.name,handle:h,path:l},c.set(b)}let x=ne(o,h,a,l);return y(),{success:!0,oldPath:a,newPath:l,oldHandle:o,newHandle:h,node:g,propagatedUpdates:x}}async function re(e,t){let n=t.replace(/\/+$/,``),r=C(e);if(r)return await $(e,`${n}/${r.name}`);let i=p.get(),a=e.endsWith(`/`)?e:`${e}/`,o=Object.values(i).filter((e,t,n)=>e.path.startsWith(a)&&n.findIndex(t=>t.path===e.path)===t);if(o.length===0)throw Error(`Directory or file not found: ${e}`);if(n===e||n.startsWith(a))throw Error(`Cannot move directory '${e}' into itself or its child '${n}'`);let s=`${n}/${e.split(`/`).filter(Boolean).pop()||`folder`}`,c=0;for(let e of o){let t=`${s}/${e.path.slice(a.length)}`;await $(e.path,t),c++}return{success:!0,movedCount:c}}async function ie(e,t,n){let r=e.replace(/^\/+/,``).replace(/\/+/g,`/`),i=await D(r,t),a=n||`mcard:${r.replace(/[^a-zA-Z0-9_.-]/g,`:`)}`;return a!==i.handle&&p.setKey(a,{...i,handle:a}),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`clm:card-created`,{detail:{path:r,handle:a,hash:i.hash}})),{node:i,handle:a,hash:i.hash}}export{j as _,te as a,D as b,K as c,B as d,H as f,F as g,L as h,X as i,U as l,z as m,re as n,Z as o,V as p,$ as r,G as s,ie as t,q as u,T as v,ee as y};