let r = 0;
const s = [], d = (n, t, e) => {
  const i = {
    type: n,
    id: String(++r),
    date: /* @__PURE__ */ new Date()
  };
  t && (i.message = t), e && (i.data = e), h(i);
}, p = ({ type: n, message: t, data: e, context: i }) => {
  const o = {
    type: n,
    id: String(++r),
    date: /* @__PURE__ */ new Date()
  };
  t && (o.message = t), e && (o.data = e), i && (o.context = i), h(o);
};
class c {
  constructor(t, e) {
    this.type = t, this.context = e;
  }
  trace(t, e) {
    p({
      type: this.type,
      message: t,
      data: e,
      context: this.context
    });
  }
  getContext() {
    return this.context;
  }
  setContext(t) {
    this.context = t;
  }
  updateContext(t) {
    this.context = Object.assign(Object.assign({}, this.context), t);
  }
  getType() {
    return this.type;
  }
  setType(t) {
    this.type = t;
  }
  /**
   * Create a new instance of the LocalTracer with an updated `type`
   *
   * It does not mutate the calling instance, but returns a new LocalTracer,
   * following a simple builder pattern.
   */
  withType(t) {
    return new c(t, this.context);
  }
  /**
   * Create a new instance of the LocalTracer with a new `context`
   *
   * It does not mutate the calling instance, but returns a new LocalTracer,
   * following a simple builder pattern.
   *
   * @param context A TraceContext, that can undefined to reset the context
   */
  withContext(t) {
    return new c(this.type, t);
  }
  /**
   * Create a new instance of the LocalTracer with an updated `context`,
   * on which an additional context is merged with the existing one.
   *
   * It does not mutate the calling instance, but returns a new LocalTracer,
   * following a simple builder pattern.
   */
  withUpdatedContext(t) {
    return new c(this.type, Object.assign(Object.assign({}, this.context), t));
  }
}
const x = (n) => (s.push(n), () => {
  const t = s.indexOf(n);
  t !== -1 && (s[t] = s[s.length - 1], s.pop());
});
function h(n) {
  for (let t = 0; t < s.length; t++)
    try {
      s[t](n);
    } catch {
    }
}
typeof window < "u" && (window.__ledgerLogsListen = x);
export {
  c as L,
  d as l
};
//# sourceMappingURL=index-DTBOwGnU.js.map
