@refraction-ui/react 0.9.3 → 0.11.0

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.
package/dist/index.cjs CHANGED
@@ -24668,12 +24668,12 @@ function nr(t2) {
24668
24668
  function Or(t2, e2) {
24669
24669
  var { organization: i2, projectId: r2, prefix: s2, severityAllowList: n2 = ["error"], sendExceptionsToPostHog: o2 = true } = void 0 === e2 ? {} : e2;
24670
24670
  return (e3) => {
24671
- var a2, l2, u2, h2, d2;
24671
+ var a2, l2, u2, h5, d2;
24672
24672
  if ("*" !== n2 && !n2.includes(e3.level) || !t2.__loaded) return e3;
24673
24673
  e3.tags || (e3.tags = {});
24674
24674
  var v2 = t2.requestRouter.endpointFor("ui", "/project/" + t2.config.token + "/person/" + t2.get_distinct_id());
24675
24675
  e3.tags["PostHog Person URL"] = v2, t2.sessionRecordingStarted() && (e3.tags["PostHog Recording URL"] = t2.get_session_replay_url({ withTimestamp: true }));
24676
- var c2, p2 = (null == (a2 = e3.exception) ? void 0 : a2.values) || [], _2 = p2.map(((t3) => f({}, t3, { stacktrace: t3.stacktrace ? f({}, t3.stacktrace, { type: "raw", frames: (t3.stacktrace.frames || []).map(((t4) => f({}, t4, { platform: "web:javascript" }))) }) : void 0 }))), g2 = { $exception_message: (null == (l2 = p2[0]) ? void 0 : l2.value) || e3.message, $exception_type: null == (u2 = p2[0]) ? void 0 : u2.type, $exception_level: e3.level, $exception_list: _2, $sentry_event_id: e3.event_id, $sentry_exception: e3.exception, $sentry_exception_message: (null == (h2 = p2[0]) ? void 0 : h2.value) || e3.message, $sentry_exception_type: null == (d2 = p2[0]) ? void 0 : d2.type, $sentry_tags: e3.tags };
24676
+ var c2, p2 = (null == (a2 = e3.exception) ? void 0 : a2.values) || [], _2 = p2.map(((t3) => f({}, t3, { stacktrace: t3.stacktrace ? f({}, t3.stacktrace, { type: "raw", frames: (t3.stacktrace.frames || []).map(((t4) => f({}, t4, { platform: "web:javascript" }))) }) : void 0 }))), g2 = { $exception_message: (null == (l2 = p2[0]) ? void 0 : l2.value) || e3.message, $exception_type: null == (u2 = p2[0]) ? void 0 : u2.type, $exception_level: e3.level, $exception_list: _2, $sentry_event_id: e3.event_id, $sentry_exception: e3.exception, $sentry_exception_message: (null == (h5 = p2[0]) ? void 0 : h5.value) || e3.message, $sentry_exception_type: null == (d2 = p2[0]) ? void 0 : d2.type, $sentry_tags: e3.tags };
24677
24677
  return i2 && r2 && (g2.$sentry_url = (s2 || "https://sentry.io/organizations/") + i2 + "/issues/?project=" + r2 + "&query=" + e3.event_id), o2 && (null == (c2 = t2.exceptions) || c2.sendExceptionEvent(g2)), e3;
24678
24678
  };
24679
24679
  }
@@ -24756,31 +24756,31 @@ function Zs(t2, e2) {
24756
24756
  i2.p(t2);
24757
24757
  var s2, n2, o2, a2, l2, u2 = (a2 = 10 + ((s2 = e2).filename && s2.filename.length + 1 || 0), l2 = 8, (function(t3, e3, i3, r3, s3, n3) {
24758
24758
  var o3 = t3.length, a3 = new xs(r3 + o3 + 5 * (1 + Math.floor(o3 / 7e3)) + s3), l3 = a3.subarray(r3, a3.length - s3), u3 = 0;
24759
- if (!e3 || 8 > o3) for (var h3 = 0; o3 >= h3; h3 += 65535) {
24760
- var d2 = h3 + 65535;
24761
- o3 > d2 ? u3 = Ys(l3, u3, t3.subarray(h3, d2)) : (l3[h3] = true, u3 = Ys(l3, u3, t3.subarray(h3, o3)));
24759
+ if (!e3 || 8 > o3) for (var h6 = 0; o3 >= h6; h6 += 65535) {
24760
+ var d2 = h6 + 65535;
24761
+ o3 > d2 ? u3 = Ys(l3, u3, t3.subarray(h6, d2)) : (l3[h6] = true, u3 = Ys(l3, u3, t3.subarray(h6, o3)));
24762
24762
  }
24763
24763
  else {
24764
24764
  for (var v2 = Ks[e3 - 1], c2 = v2 >>> 13, p2 = 8191 & v2, f2 = (1 << i3) - 1, _2 = new Es(32768), g2 = new Es(f2 + 1), m2 = Math.ceil(i3 / 3), b2 = 2 * m2, y2 = function(e4) {
24765
24765
  return (t3[e4] ^ t3[e4 + 1] << m2 ^ t3[e4 + 2] << b2) & f2;
24766
- }, w2 = new Ss(25e3), x2 = new Es(288), E2 = new Es(32), S2 = 0, T2 = 0, k2 = (h3 = 0, 0), R2 = 0, P2 = 0; o3 > h3; ++h3) {
24767
- var O2 = y2(h3), I2 = 32767 & h3, C2 = g2[O2];
24768
- if (_2[I2] = C2, g2[O2] = I2, h3 >= R2) {
24769
- var A2 = o3 - h3;
24766
+ }, w2 = new Ss(25e3), x2 = new Es(288), E2 = new Es(32), S2 = 0, T2 = 0, k2 = (h6 = 0, 0), R2 = 0, P2 = 0; o3 > h6; ++h6) {
24767
+ var O2 = y2(h6), I2 = 32767 & h6, C2 = g2[O2];
24768
+ if (_2[I2] = C2, g2[O2] = I2, h6 >= R2) {
24769
+ var A2 = o3 - h6;
24770
24770
  if ((S2 > 7e3 || k2 > 24576) && A2 > 423) {
24771
- u3 = Js(t3, l3, 0, w2, x2, E2, T2, k2, P2, h3 - P2, u3), k2 = S2 = T2 = 0, P2 = h3;
24771
+ u3 = Js(t3, l3, 0, w2, x2, E2, T2, k2, P2, h6 - P2, u3), k2 = S2 = T2 = 0, P2 = h6;
24772
24772
  for (var F3 = 0; 286 > F3; ++F3) x2[F3] = 0;
24773
24773
  for (F3 = 0; 30 > F3; ++F3) E2[F3] = 0;
24774
24774
  }
24775
24775
  var M3 = 2, D2 = 0, U2 = p2, L2 = I2 - C2 & 32767;
24776
- if (A2 > 2 && O2 == y2(h3 - L2)) for (var N2 = Math.min(c2, A2) - 1, j2 = Math.min(32767, h3), z2 = Math.min(258, A2); j2 >= L2 && --U2 && I2 != C2; ) {
24777
- if (t3[h3 + M3] == t3[h3 + M3 - L2]) {
24778
- for (var B2 = 0; z2 > B2 && t3[h3 + B2] == t3[h3 + B2 - L2]; ++B2) ;
24776
+ if (A2 > 2 && O2 == y2(h6 - L2)) for (var N2 = Math.min(c2, A2) - 1, j2 = Math.min(32767, h6), z2 = Math.min(258, A2); j2 >= L2 && --U2 && I2 != C2; ) {
24777
+ if (t3[h6 + M3] == t3[h6 + M3 - L2]) {
24778
+ for (var B2 = 0; z2 > B2 && t3[h6 + B2] == t3[h6 + B2 - L2]; ++B2) ;
24779
24779
  if (B2 > M3) {
24780
24780
  if (M3 = B2, D2 = L2, B2 > N2) break;
24781
24781
  var H2 = Math.min(L2, B2 - 2), q2 = 0;
24782
24782
  for (F3 = 0; H2 > F3; ++F3) {
24783
- var V2 = h3 - L2 + F3 + 32768 & 32767, W2 = V2 - _2[V2] + 32768 & 32767;
24783
+ var V2 = h6 - L2 + F3 + 32768 & 32767, W2 = V2 - _2[V2] + 32768 & 32767;
24784
24784
  W2 > q2 && (q2 = W2, C2 = V2);
24785
24785
  }
24786
24786
  }
@@ -24790,21 +24790,21 @@ function Zs(t2, e2) {
24790
24790
  if (D2) {
24791
24791
  w2[k2++] = 268435456 | Os[M3] << 18 | Is[D2];
24792
24792
  var G2 = 31 & Os[M3], Y2 = 31 & Is[D2];
24793
- T2 += $s[G2] + Ts[Y2], ++x2[257 + G2], ++E2[Y2], R2 = h3 + M3, ++S2;
24794
- } else w2[k2++] = t3[h3], ++x2[t3[h3]];
24793
+ T2 += $s[G2] + Ts[Y2], ++x2[257 + G2], ++E2[Y2], R2 = h6 + M3, ++S2;
24794
+ } else w2[k2++] = t3[h6], ++x2[t3[h6]];
24795
24795
  }
24796
24796
  }
24797
- u3 = Js(t3, l3, true, w2, x2, E2, T2, k2, P2, h3 - P2, u3);
24797
+ u3 = Js(t3, l3, true, w2, x2, E2, T2, k2, P2, h6 - P2, u3);
24798
24798
  }
24799
24799
  return zs(a3, 0, r3 + js(u3) + s3);
24800
- })(n2 = t2, null == (o2 = e2).level ? 6 : o2.level, null == o2.mem ? Math.ceil(1.5 * Math.max(8, Math.min(13, Math.log(n2.length)))) : 12 + o2.mem, a2, l2)), h2 = u2.length;
24800
+ })(n2 = t2, null == (o2 = e2).level ? 6 : o2.level, null == o2.mem ? Math.ceil(1.5 * Math.max(8, Math.min(13, Math.log(n2.length)))) : 12 + o2.mem, a2, l2)), h5 = u2.length;
24801
24801
  return (function(t3, e3) {
24802
24802
  var i3 = e3.filename;
24803
24803
  if (t3[0] = 31, t3[1] = 139, t3[2] = 8, t3[8] = 2 > e3.level ? 4 : 9 == e3.level ? 2 : 0, t3[9] = 3, 0 != e3.mtime && Qs(t3, 4, Math.floor(new Date(e3.mtime || Date.now()) / 1e3)), i3) {
24804
24804
  t3[3] = 8;
24805
24805
  for (var r3 = 0; i3.length >= r3; ++r3) t3[r3 + 10] = i3.charCodeAt(r3);
24806
24806
  }
24807
- })(u2, e2), Qs(u2, h2 - 8, i2.d()), Qs(u2, h2 - 4, r2), u2;
24807
+ })(u2, e2), Qs(u2, h5 - 8, i2.d()), Qs(u2, h5 - 4, r2), u2;
24808
24808
  }
24809
24809
  function Sn(t2, e2, i2) {
24810
24810
  return on({ distinct_id: t2, userPropertiesToSet: e2, userPropertiesToSetOnce: i2 });
@@ -24942,13 +24942,13 @@ function No(t2) {
24942
24942
  function jo(e2, i2) {
24943
24943
  var r2, s2, { e: n2, maskAllElementAttributes: o2, maskAllText: a2, elementAttributeIgnoreList: l2, elementsChainAsString: u2 } = i2;
24944
24944
  if (!so(e2)) return { props: {} };
24945
- for (var h2 = [e2], d2 = e2; d2.parentNode && !no(d2, "body"); ) if (ao(d2.parentNode)) h2.push(d2.parentNode.host), d2 = d2.parentNode.host;
24945
+ for (var h5 = [e2], d2 = e2; d2.parentNode && !no(d2, "body"); ) if (ao(d2.parentNode)) h5.push(d2.parentNode.host), d2 = d2.parentNode.host;
24946
24946
  else {
24947
24947
  if (!so(d2.parentNode)) break;
24948
- h2.push(d2.parentNode), d2 = d2.parentNode;
24948
+ h5.push(d2.parentNode), d2 = d2.parentNode;
24949
24949
  }
24950
24950
  var v2, c2, p2 = [], _2 = {}, g2 = false, m2 = false;
24951
- if (Ki(h2, ((t2) => {
24951
+ if (Ki(h5, ((t2) => {
24952
24952
  var e3 = xo(t2);
24953
24953
  if (no(t2, "a")) {
24954
24954
  var i3 = t2.getAttribute("href");
@@ -25051,7 +25051,7 @@ function sa(t2, e2, i2) {
25051
25051
  return false;
25052
25052
  }
25053
25053
  }
25054
- var t, e, i, r, s, n, o, a, l, u, h, d, v, g, m, b, y, w, x, E, S, k, R, O, I, C, A, F2, M2, D, U, L, N, j, z, B, H, q, V, W, G, Y, Q, Z, tt, it, rt, st, nt, ot, at, lt, ut, ht, dt, vt, ct, pt, ft, _t, gt, mt, bt, yt, wt, xt, Et, St, $t, Tt, kt, Rt, Pt, Ot, It, Ct, At, Ft, Mt, Dt, Ut, Lt, Nt, jt, zt, Bt, Ht, qt, Vt, Wt, Gt, Yt, Jt, Kt, Xt, Qt, Zt, te, ee, ie, re, ae, le, he, de, ve, ce, pe, fe, _e, ge, me, be, ye, we, xe, Ee, Se, Te, ke, Re, Pe, Oe, Ie, Ce, Ae, Me, Ue, Le, Ne, je, ze, Be, He, qe, Ve, We, Ge, Ye, Je, Ke, Xe, Qe, Ze, ti, ei, ii, ri, si, ni, oi, ai, li, ui, hi, di, vi, ci, pi, fi, _i, gi, mi, bi, yi, wi, xi, Ei, Si, $i, Ti, ki, Ri, Pi, Oi, Ii, Ci, Ai, Fi, Mi, Di, Ui, Li, Ni, ji, zi, Bi, Hi, qi, Vi, Wi, Gi, Yi, Xi, Zi, tr, er, ir, or, ar, lr, ur, hr, dr, vr, cr, pr, fr, _r, gr, mr, br, yr, wr, xr, Er, Sr, $r, Tr, kr, Rr, Pr, Ir, Cr, Ar, Fr, Mr, Dr, Ur, Lr, Nr, jr, zr, Br, Hr, Yr, ts, es, is, rs, ss, ns, os, as, ls, us, hs, ds, vs, cs, ps, fs, _s, gs, ms, bs, ys, ws, xs, Es, Ss, $s, Ts, ks, Rs, Ps, Os, Fs, Is, Cs, As, Ms, Ds, Us, Ls, Ns, js, zs, Bs, Hs, qs, Vs, Ws, Gs, Ys, Js, Ks, Xs, Qs, tn, en, rn, sn, nn, on, an, ln, un, hn, dn, vn, cn2, pn, fn, _n, gn, mn, bn, yn, wn, xn, En, $n, Tn, Rn, Pn, On, In, Cn, An, Fn, Mn, Dn, Un, Ln, Nn, jn, zn, Bn, Hn, qn, Vn, Wn, Gn, Yn, Jn, Kn, Xn, Qn, Zn, to, eo, io, fo, mo, bo, yo, wo, So, $o, To, ko, Ro, Po, Mo, Do, Uo, zo, Ho, qo, Vo, Wo, Go, Yo, Jo, Ko, Xo, Qo, ta, ea, ia, ra, na, oa, aa, la, ua, ha, da, va, ca, pa, fa, _a12, ga, ma, ba, ya, wa, xa, Ea, Sa, $a, Ta, ka, Ra, Pa, Oa, Ia, Ca, Aa, Fa, Ma, Da, Ua, La;
25054
+ var t, e, i, r, s, n, o, a, l, u, h4, d, v, g, m, b, y, w, x, E, S, k, R, O, I, C, A, F2, M2, D, U, L, N, j, z, B, H, q, V, W, G, Y, Q, Z, tt, it, rt, st, nt, ot, at, lt, ut, ht, dt, vt, ct, pt, ft, _t, gt, mt, bt, yt, wt, xt, Et, St, $t, Tt, kt, Rt, Pt, Ot, It, Ct, At, Ft, Mt, Dt, Ut, Lt, Nt, jt, zt, Bt, Ht, qt, Vt, Wt, Gt, Yt, Jt, Kt, Xt, Qt, Zt, te, ee, ie, re, ae, le, he, de, ve, ce, pe, fe, _e, ge, me, be, ye, we, xe, Ee, Se, Te, ke, Re, Pe, Oe, Ie, Ce, Ae, Me, Ue, Le, Ne, je, ze, Be, He, qe, Ve, We, Ge, Ye, Je, Ke, Xe, Qe, Ze, ti, ei, ii, ri, si, ni, oi, ai, li, ui, hi, di, vi, ci, pi, fi, _i, gi, mi, bi, yi, wi, xi, Ei, Si, $i, Ti, ki, Ri, Pi, Oi, Ii, Ci, Ai, Fi, Mi, Di, Ui, Li, Ni, ji, zi, Bi, Hi, qi, Vi, Wi, Gi, Yi, Xi, Zi, tr, er, ir, or, ar, lr, ur, hr, dr, vr, cr, pr, fr, _r, gr, mr, br, yr, wr, xr, Er, Sr, $r, Tr, kr, Rr, Pr, Ir, Cr, Ar, Fr, Mr, Dr, Ur, Lr, Nr, jr, zr, Br, Hr, Yr, ts, es, is, rs, ss, ns, os, as, ls, us, hs, ds, vs, cs, ps, fs, _s, gs, ms, bs, ys, ws, xs, Es, Ss, $s, Ts, ks, Rs, Ps, Os, Fs, Is, Cs, As, Ms, Ds, Us, Ls, Ns, js, zs, Bs, Hs, qs, Vs, Ws, Gs, Ys, Js, Ks, Xs, Qs, tn, en, rn, sn, nn, on, an, ln, un, hn, dn, vn, cn2, pn, fn, _n, gn, mn, bn, yn, wn, xn, En, $n, Tn, Rn, Pn, On, In, Cn, An, Fn, Mn, Dn, Un, Ln, Nn, jn, zn, Bn, Hn, qn, Vn, Wn, Gn, Yn, Jn, Kn, Xn, Qn, Zn, to, eo, io, fo, mo, bo, yo, wo, So, $o, To, ko, Ro, Po, Mo, Do, Uo, zo, Ho, qo, Vo, Wo, Go, Yo, Jo, Ko, Xo, Qo, ta, ea, ia, ra, na, oa, aa, la, ua, ha, da, va, ca, pa, fa, _a12, ga, ma, ba, ya, wa, xa, Ea, Sa, $a, Ta, ka, Ra, Pa, Oa, Ia, Ca, Aa, Fa, Ma, Da, Ua, La;
25055
25055
  var init_module = __esm({
25056
25056
  "../../node_modules/.pnpm/posthog-js@1.373.5/node_modules/posthog-js/dist/module.js"() {
25057
25057
  t = "undefined" != typeof window ? window : void 0;
@@ -25066,7 +25066,7 @@ var init_module = __esm({
25066
25066
  a = null == e ? void 0 : e.AbortController;
25067
25067
  l = null == e ? void 0 : e.CompressionStream;
25068
25068
  u = null == i ? void 0 : i.userAgent;
25069
- h = null != t ? t : {};
25069
+ h4 = null != t ? t : {};
25070
25070
  d = "1.373.5";
25071
25071
  v = { DEBUG: false, LIB_VERSION: d, LIB_NAME: "web", JS_SDK_VERSION: d };
25072
25072
  m = (function(t2) {
@@ -25561,7 +25561,7 @@ var init_module = __esm({
25561
25561
  };
25562
25562
  Ue = function(e2, i2) {
25563
25563
  var { debugEnabled: r2 } = void 0 === i2 ? {} : i2, s2 = { k(i3) {
25564
- if (t && (v.DEBUG || h.POSTHOG_DEBUG || r2) && !N(t.console) && t.console) {
25564
+ if (t && (v.DEBUG || h4.POSTHOG_DEBUG || r2) && !N(t.console) && t.console) {
25565
25565
  for (var s3 = ("__rrweb_original__" in t.console[i3]) ? t.console[i3].__rrweb_original__ : t.console[i3], n2 = arguments.length, o2 = new Array(n2 > 1 ? n2 - 1 : 0), a2 = 1; n2 > a2; a2++) o2[a2 - 1] = arguments[a2];
25566
25566
  s3(e2, ...o2);
25567
25567
  }
@@ -25615,7 +25615,7 @@ var init_module = __esm({
25615
25615
  };
25616
25616
  null != r && r.body ? l2() : null == r || r.addEventListener("DOMContentLoaded", l2);
25617
25617
  };
25618
- h.__PosthogExtensions__ = h.__PosthogExtensions__ || {}, h.__PosthogExtensions__.loadExternalDependency = (t2, e2, i2) => {
25618
+ h4.__PosthogExtensions__ = h4.__PosthogExtensions__ || {}, h4.__PosthogExtensions__.loadExternalDependency = (t2, e2, i2) => {
25619
25619
  if ("remote-config" !== e2) {
25620
25620
  var r2;
25621
25621
  if (t2.config.__preview_external_dependency_versioned_paths) r2 = t2.requestRouter.endpointFor("assets", "/static/" + t2.version + "/" + e2 + ".js");
@@ -25632,7 +25632,7 @@ var init_module = __esm({
25632
25632
  var o2 = t2.requestRouter.endpointFor("assets", "/array/" + t2.config.token + "/config.js");
25633
25633
  ze(t2, o2, i2);
25634
25634
  }
25635
- }, h.__PosthogExtensions__.loadSiteApp = (t2, e2, i2) => {
25635
+ }, h4.__PosthogExtensions__.loadSiteApp = (t2, e2, i2) => {
25636
25636
  var r2 = t2.requestRouter.endpointFor("api", e2);
25637
25637
  ze(t2, r2, i2);
25638
25638
  };
@@ -25854,8 +25854,8 @@ var init_module = __esm({
25854
25854
  u2.setTime(u2.getTime() + 864e5 * i2), o2 = "; expires=" + u2.toUTCString();
25855
25855
  }
25856
25856
  n2 && (a2 = "; secure");
25857
- var h2 = t2 + "=" + encodeURIComponent(JSON.stringify(e2)) + o2 + "; SameSite=Lax; path=/" + l2 + a2;
25858
- return h2.length > 3686.4 && Le.warn("cookieStore warning: large cookie, len=" + h2.length), r.cookie = h2, h2;
25857
+ var h5 = t2 + "=" + encodeURIComponent(JSON.stringify(e2)) + o2 + "; SameSite=Lax; path=/" + l2 + a2;
25858
+ return h5.length > 3686.4 && Le.warn("cookieStore warning: large cookie, len=" + h5.length), r.cookie = h5, h5;
25859
25859
  } catch (t3) {
25860
25860
  return;
25861
25861
  }
@@ -26000,7 +26000,7 @@ var init_module = __esm({
26000
26000
  return this.ar;
26001
26001
  }
26002
26002
  rr() {
26003
- return !!this.qt.respect_dnt && [null == i ? void 0 : i.doNotTrack, null == i ? void 0 : i.msDoNotTrack, h.doNotTrack].some(((t2) => Z(t2)));
26003
+ return !!this.qt.respect_dnt && [null == i ? void 0 : i.doNotTrack, null == i ? void 0 : i.msDoNotTrack, h4.doNotTrack].some(((t2) => Z(t2)));
26004
26004
  }
26005
26005
  };
26006
26006
  Sr = Ne("[Dead Clicks]");
@@ -26026,16 +26026,16 @@ var init_module = __esm({
26026
26026
  }
26027
26027
  lr(t2) {
26028
26028
  var e2, i2;
26029
- null != (e2 = h.__PosthogExtensions__) && e2.initDeadClicksAutocapture && t2(), null == (i2 = h.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this.instance, "dead-clicks-autocapture", ((e3) => {
26029
+ null != (e2 = h4.__PosthogExtensions__) && e2.initDeadClicksAutocapture && t2(), null == (i2 = h4.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this.instance, "dead-clicks-autocapture", ((e3) => {
26030
26030
  e3 ? Sr.error("failed to load script", e3) : t2();
26031
26031
  }));
26032
26032
  }
26033
26033
  hr() {
26034
26034
  var t2;
26035
26035
  if (r) {
26036
- if (!this.ur && null != (t2 = h.__PosthogExtensions__) && t2.initDeadClicksAutocapture) {
26036
+ if (!this.ur && null != (t2 = h4.__PosthogExtensions__) && t2.initDeadClicksAutocapture) {
26037
26037
  var e2 = U(this.instance.config.capture_dead_clicks) ? this.instance.config.capture_dead_clicks : {};
26038
- e2.__onCapture = this.onCapture, this.ur = h.__PosthogExtensions__.initDeadClicksAutocapture(this.instance, e2), this.ur.start(r), Sr.info("starting...");
26038
+ e2.__onCapture = this.onCapture, this.ur = h4.__PosthogExtensions__.initDeadClicksAutocapture(this.instance, e2), this.ur.start(r), Sr.info("starting...");
26039
26039
  }
26040
26040
  } else Sr.error("`document` not found. Cannot start.");
26041
26041
  }
@@ -26083,11 +26083,11 @@ var init_module = __esm({
26083
26083
  if (!i2) return { $pageview_id: e2 };
26084
26084
  var r2 = { $pageview_id: e2, $prev_pageview_id: i2.pageViewId }, s2 = this._instance.scrollManager.getContext();
26085
26085
  if (s2 && !this._instance.config.disable_scroll_properties) {
26086
- var { maxScrollHeight: n2, lastScrollY: o2, maxScrollY: a2, maxContentHeight: l2, lastContentY: u2, maxContentY: h2 } = s2;
26087
- if (!(N(n2) || N(o2) || N(a2) || N(l2) || N(u2) || N(h2))) {
26088
- n2 = Math.ceil(n2), o2 = Math.ceil(o2), a2 = Math.ceil(a2), l2 = Math.ceil(l2), u2 = Math.ceil(u2), h2 = Math.ceil(h2);
26089
- var d2 = n2 > 1 ? et(o2 / n2, 0, 1, Le) : 1, v2 = n2 > 1 ? et(a2 / n2, 0, 1, Le) : 1, c2 = l2 > 1 ? et(u2 / l2, 0, 1, Le) : 1, p2 = l2 > 1 ? et(h2 / l2, 0, 1, Le) : 1;
26090
- r2 = Xi(r2, { $prev_pageview_last_scroll: o2, $prev_pageview_last_scroll_percentage: d2, $prev_pageview_max_scroll: a2, $prev_pageview_max_scroll_percentage: v2, $prev_pageview_last_content: u2, $prev_pageview_last_content_percentage: c2, $prev_pageview_max_content: h2, $prev_pageview_max_content_percentage: p2 });
26086
+ var { maxScrollHeight: n2, lastScrollY: o2, maxScrollY: a2, maxContentHeight: l2, lastContentY: u2, maxContentY: h5 } = s2;
26087
+ if (!(N(n2) || N(o2) || N(a2) || N(l2) || N(u2) || N(h5))) {
26088
+ n2 = Math.ceil(n2), o2 = Math.ceil(o2), a2 = Math.ceil(a2), l2 = Math.ceil(l2), u2 = Math.ceil(u2), h5 = Math.ceil(h5);
26089
+ var d2 = n2 > 1 ? et(o2 / n2, 0, 1, Le) : 1, v2 = n2 > 1 ? et(a2 / n2, 0, 1, Le) : 1, c2 = l2 > 1 ? et(u2 / l2, 0, 1, Le) : 1, p2 = l2 > 1 ? et(h5 / l2, 0, 1, Le) : 1;
26090
+ r2 = Xi(r2, { $prev_pageview_last_scroll: o2, $prev_pageview_last_scroll_percentage: d2, $prev_pageview_max_scroll: a2, $prev_pageview_max_scroll_percentage: v2, $prev_pageview_last_content: u2, $prev_pageview_last_content_percentage: c2, $prev_pageview_max_content: h5, $prev_pageview_max_content_percentage: p2 });
26091
26091
  }
26092
26092
  }
26093
26093
  return i2.pathname && (r2.$prev_pageview_pathname = i2.pathname), i2.timestamp && (r2.$prev_pageview_duration = (t2.getTime() - i2.timestamp.getTime()) / 1e3), r2;
@@ -26122,9 +26122,9 @@ var init_module = __esm({
26122
26122
  };
26123
26123
  Ur = function(t2, e2, i2) {
26124
26124
  if (!t2 || !e2 || !e2.length) return t2;
26125
- for (var r2 = t2.split("#"), s2 = r2[1], n2 = (r2[0] || "").split("?"), o2 = n2[1], a2 = n2[0], l2 = (o2 || "").split("&"), u2 = [], h2 = 0; l2.length > h2; h2++) {
26126
- var d2 = l2[h2].split("=");
26127
- M2(d2) && (e2.includes(d2[0]) ? u2.push(d2[0] + "=" + i2) : u2.push(l2[h2]));
26125
+ for (var r2 = t2.split("#"), s2 = r2[1], n2 = (r2[0] || "").split("?"), o2 = n2[1], a2 = n2[0], l2 = (o2 || "").split("&"), u2 = [], h5 = 0; l2.length > h5; h5++) {
26126
+ var d2 = l2[h5].split("=");
26127
+ M2(d2) && (e2.includes(d2[0]) ? u2.push(d2[0] + "=" + i2) : u2.push(l2[h5]));
26128
26128
  }
26129
26129
  var v2 = a2;
26130
26130
  return null != o2 && (v2 += "?" + u2.join("&")), null != s2 && (v2 += "#" + s2), v2;
@@ -26380,11 +26380,11 @@ var init_module = __esm({
26380
26380
  }
26381
26381
  get remoteConfig() {
26382
26382
  var t2;
26383
- return null == (t2 = h._POSTHOG_REMOTE_CONFIG) || null == (t2 = t2[this._instance.config.token]) ? void 0 : t2.config;
26383
+ return null == (t2 = h4._POSTHOG_REMOTE_CONFIG) || null == (t2 = t2[this._instance.config.token]) ? void 0 : t2.config;
26384
26384
  }
26385
26385
  Mr(t2) {
26386
26386
  var e2, i2;
26387
- null != (e2 = h.__PosthogExtensions__) && e2.loadExternalDependency ? null == (i2 = h.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, "remote-config", (() => t2(this.remoteConfig))) : t2();
26387
+ null != (e2 = h4.__PosthogExtensions__) && e2.loadExternalDependency ? null == (i2 = h4.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, "remote-config", (() => t2(this.remoteConfig))) : t2();
26388
26388
  }
26389
26389
  Pr(t2) {
26390
26390
  this._instance._send_request({ method: "GET", url: this._instance.requestRouter.endpointFor("assets", "/array/" + this._instance.config.token + "/config"), callback(e2) {
@@ -26453,7 +26453,7 @@ var init_module = __esm({
26453
26453
  if (i2) {
26454
26454
  o2 = new Es(1 << e2);
26455
26455
  var l2 = 15 - e2;
26456
- for (s2 = 0; r2 > s2; ++s2) if (t2[s2]) for (var u2 = s2 << 4 | t2[s2], h2 = e2 - t2[s2], d2 = a2[t2[s2] - 1]++ << h2, v2 = d2 | (1 << h2) - 1; v2 >= d2; ++d2) o2[Cs[d2] >>> l2] = u2;
26456
+ for (s2 = 0; r2 > s2; ++s2) if (t2[s2]) for (var u2 = s2 << 4 | t2[s2], h5 = e2 - t2[s2], d2 = a2[t2[s2] - 1]++ << h5, v2 = d2 | (1 << h5) - 1; v2 >= d2; ++d2) o2[Cs[d2] >>> l2] = u2;
26457
26457
  } else for (o2 = new Es(r2), s2 = 0; r2 > s2; ++s2) o2[s2] = Cs[a2[t2[s2] - 1]++] >>> 15 - t2[s2];
26458
26458
  return o2;
26459
26459
  };
@@ -26493,11 +26493,11 @@ var init_module = __esm({
26493
26493
  i2.sort((function(t3, e3) {
26494
26494
  return t3.f - e3.f;
26495
26495
  })), i2.push({ s: -1, f: 25001 });
26496
- var a2 = i2[0], l2 = i2[1], u2 = 0, h2 = 1, d2 = 2;
26497
- for (i2[0] = { s: -1, f: a2.f + l2.f, l: a2, r: l2 }; h2 != s2 - 1; ) a2 = i2[i2[d2].f > i2[u2].f ? u2++ : d2++], l2 = i2[u2 != h2 && i2[d2].f > i2[u2].f ? u2++ : d2++], i2[h2++] = { s: -1, f: a2.f + l2.f, l: a2, r: l2 };
26496
+ var a2 = i2[0], l2 = i2[1], u2 = 0, h5 = 1, d2 = 2;
26497
+ for (i2[0] = { s: -1, f: a2.f + l2.f, l: a2, r: l2 }; h5 != s2 - 1; ) a2 = i2[i2[d2].f > i2[u2].f ? u2++ : d2++], l2 = i2[u2 != h5 && i2[d2].f > i2[u2].f ? u2++ : d2++], i2[h5++] = { s: -1, f: a2.f + l2.f, l: a2, r: l2 };
26498
26498
  var v2 = n2[0].s;
26499
26499
  for (r2 = 1; s2 > r2; ++r2) n2[r2].s > v2 && (v2 = n2[r2].s);
26500
- var c2 = new Es(v2 + 1), p2 = Vs(i2[h2 - 1], c2, 0);
26500
+ var c2 = new Es(v2 + 1), p2 = Vs(i2[h5 - 1], c2, 0);
26501
26501
  if (p2 > e2) {
26502
26502
  r2 = 0;
26503
26503
  var f2 = 0, _2 = p2 - e2, g2 = 1 << _2;
@@ -26551,30 +26551,30 @@ var init_module = __esm({
26551
26551
  for (var n2 = 0; r2 > n2; ++n2) t2[s2 + n2 + 4] = i2[n2];
26552
26552
  return 8 * (s2 + 4 + r2);
26553
26553
  };
26554
- Js = function(t2, e2, i2, r2, s2, n2, o2, a2, l2, u2, h2) {
26555
- Bs(e2, h2++, i2), ++s2[256];
26554
+ Js = function(t2, e2, i2, r2, s2, n2, o2, a2, l2, u2, h5) {
26555
+ Bs(e2, h5++, i2), ++s2[256];
26556
26556
  for (var d2 = qs(s2, 15), v2 = d2[0], c2 = d2[1], p2 = qs(n2, 15), f2 = p2[0], _2 = p2[1], g2 = Ws(v2), m2 = g2[0], b2 = g2[1], y2 = Ws(f2), w2 = y2[0], x2 = y2[1], E2 = new Es(19), S2 = 0; m2.length > S2; ++S2) E2[31 & m2[S2]]++;
26557
26557
  for (S2 = 0; w2.length > S2; ++S2) E2[31 & w2[S2]]++;
26558
26558
  for (var T2 = qs(E2, 7), k2 = T2[0], R2 = T2[1], P2 = 19; P2 > 4 && !k2[ks[P2 - 1]]; --P2) ;
26559
26559
  var O2, I2, C2, A2, F3 = u2 + 5 << 3, M3 = Gs(s2, Ds) + Gs(n2, Us) + o2, D2 = Gs(s2, v2) + Gs(n2, f2) + o2 + 14 + 3 * P2 + Gs(E2, k2) + (2 * E2[16] + 3 * E2[17] + 7 * E2[18]);
26560
- if (M3 >= F3 && D2 >= F3) return Ys(e2, h2, t2.subarray(l2, l2 + u2));
26561
- if (Bs(e2, h2, 1 + (M3 > D2)), h2 += 2, M3 > D2) {
26560
+ if (M3 >= F3 && D2 >= F3) return Ys(e2, h5, t2.subarray(l2, l2 + u2));
26561
+ if (Bs(e2, h5, 1 + (M3 > D2)), h5 += 2, M3 > D2) {
26562
26562
  O2 = Ms(v2, c2, 0), I2 = v2, C2 = Ms(f2, _2, 0), A2 = f2;
26563
26563
  var U2 = Ms(k2, R2, 0);
26564
- for (Bs(e2, h2, b2 - 257), Bs(e2, h2 + 5, x2 - 1), Bs(e2, h2 + 10, P2 - 4), h2 += 14, S2 = 0; P2 > S2; ++S2) Bs(e2, h2 + 3 * S2, k2[ks[S2]]);
26565
- h2 += 3 * P2;
26564
+ for (Bs(e2, h5, b2 - 257), Bs(e2, h5 + 5, x2 - 1), Bs(e2, h5 + 10, P2 - 4), h5 += 14, S2 = 0; P2 > S2; ++S2) Bs(e2, h5 + 3 * S2, k2[ks[S2]]);
26565
+ h5 += 3 * P2;
26566
26566
  for (var L2 = [m2, w2], N2 = 0; 2 > N2; ++N2) {
26567
26567
  var j2 = L2[N2];
26568
- for (S2 = 0; j2.length > S2; ++S2) Bs(e2, h2, U2[z2 = 31 & j2[S2]]), h2 += k2[z2], z2 > 15 && (Bs(e2, h2, j2[S2] >>> 5 & 127), h2 += j2[S2] >>> 12);
26568
+ for (S2 = 0; j2.length > S2; ++S2) Bs(e2, h5, U2[z2 = 31 & j2[S2]]), h5 += k2[z2], z2 > 15 && (Bs(e2, h5, j2[S2] >>> 5 & 127), h5 += j2[S2] >>> 12);
26569
26569
  }
26570
26570
  } else O2 = Ls, I2 = Ds, C2 = Ns, A2 = Us;
26571
26571
  for (S2 = 0; a2 > S2; ++S2) if (r2[S2] > 255) {
26572
26572
  var z2;
26573
- Hs(e2, h2, O2[257 + (z2 = r2[S2] >>> 18 & 31)]), h2 += I2[z2 + 257], z2 > 7 && (Bs(e2, h2, r2[S2] >>> 23 & 31), h2 += $s[z2]);
26573
+ Hs(e2, h5, O2[257 + (z2 = r2[S2] >>> 18 & 31)]), h5 += I2[z2 + 257], z2 > 7 && (Bs(e2, h5, r2[S2] >>> 23 & 31), h5 += $s[z2]);
26574
26574
  var B2 = 31 & r2[S2];
26575
- Hs(e2, h2, C2[B2]), h2 += A2[B2], B2 > 3 && (Hs(e2, h2, r2[S2] >>> 5 & 8191), h2 += Ts[B2]);
26576
- } else Hs(e2, h2, O2[r2[S2]]), h2 += I2[r2[S2]];
26577
- return Hs(e2, h2, O2[256]), h2 + I2[256];
26575
+ Hs(e2, h5, C2[B2]), h5 += A2[B2], B2 > 3 && (Hs(e2, h5, r2[S2] >>> 5 & 8191), h5 += Ts[B2]);
26576
+ } else Hs(e2, h5, O2[r2[S2]]), h5 += I2[r2[S2]];
26577
+ return Hs(e2, h5, O2[256]), h5 + I2[256];
26578
26578
  };
26579
26579
  Ks = new Ss([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
26580
26580
  Xs = (function() {
@@ -26669,12 +26669,12 @@ var init_module = __esm({
26669
26669
  Ki(t2.headers, (function(t3, e3) {
26670
26670
  u2.append(e3, t3);
26671
26671
  })), s2 && u2.append("Content-Type", s2);
26672
- var h2 = null;
26672
+ var h5 = null;
26673
26673
  if (a) {
26674
26674
  var d2 = new a();
26675
- h2 = { signal: d2.signal, timeout: setTimeout((() => d2.abort()), t2.timeout) };
26675
+ h5 = { signal: d2.signal, timeout: setTimeout((() => d2.abort()), t2.timeout) };
26676
26676
  }
26677
- n(i2, f({ method: (null == t2 ? void 0 : t2.method) || "GET", headers: u2, keepalive: "POST" === t2.method && 52428.8 > (l2 || 0), body: o2, signal: null == (e2 = h2) ? void 0 : e2.signal }, t2.fetchOptions)).then(((e3) => e3.text().then(((i3) => {
26677
+ n(i2, f({ method: (null == t2 ? void 0 : t2.method) || "GET", headers: u2, keepalive: "POST" === t2.method && 52428.8 > (l2 || 0), body: o2, signal: null == (e2 = h5) ? void 0 : e2.signal }, t2.fetchOptions)).then(((e3) => e3.text().then(((i3) => {
26678
26678
  var r3 = { statusCode: e3.status, text: i3 };
26679
26679
  if (200 === e3.status) try {
26680
26680
  r3.json = JSON.parse(i3);
@@ -26684,7 +26684,7 @@ var init_module = __esm({
26684
26684
  null == t2.callback || t2.callback(r3);
26685
26685
  })))).catch(((e3) => {
26686
26686
  Le.error(e3), null == t2.callback || t2.callback({ statusCode: 0, error: e3 });
26687
- })).finally((() => h2 ? clearTimeout(h2.timeout) : null));
26687
+ })).finally((() => h5 ? clearTimeout(h5.timeout) : null));
26688
26688
  } }), o && dn.push({ transport: "XHR", method(t2) {
26689
26689
  var e2 = new o(), { url: i2, encodedBody: r2 } = ln(t2);
26690
26690
  e2.open(t2.method || "GET", i2, true);
@@ -26950,10 +26950,10 @@ var init_module = __esm({
26950
26950
  }
26951
26951
  checkAndGetSessionAndWindowId(t2, e2) {
26952
26952
  if (void 0 === t2 && (t2 = false), void 0 === e2 && (e2 = null), this.qt.cookieless_mode === Ni) throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');
26953
- var i2 = e2 || (/* @__PURE__ */ new Date()).getTime(), [r2, s2, n2] = this.ki(), o2 = this.Si(), a2 = V(n2) && Math.abs(i2 - n2) > 864e5, l2 = false, u2 = !s2, h2 = !u2 && !t2 && this.hi(i2, r2);
26954
- u2 || h2 || a2 ? (s2 = this.vi(), o2 = this.fi(), yn.info("new session ID generated", { sessionId: s2, windowId: o2, changeReason: { noSessionId: u2, activityTimeout: h2, sessionPastMaximumLength: a2 } }), n2 = i2, l2 = true) : o2 || (o2 = this.fi(), l2 = true);
26953
+ var i2 = e2 || (/* @__PURE__ */ new Date()).getTime(), [r2, s2, n2] = this.ki(), o2 = this.Si(), a2 = V(n2) && Math.abs(i2 - n2) > 864e5, l2 = false, u2 = !s2, h5 = !u2 && !t2 && this.hi(i2, r2);
26954
+ u2 || h5 || a2 ? (s2 = this.vi(), o2 = this.fi(), yn.info("new session ID generated", { sessionId: s2, windowId: o2, changeReason: { noSessionId: u2, activityTimeout: h5, sessionPastMaximumLength: a2 } }), n2 = i2, l2 = true) : o2 || (o2 = this.fi(), l2 = true);
26955
26955
  var d2 = V(r2) && t2 && !a2 ? r2 : i2, v2 = V(n2) ? n2 : (/* @__PURE__ */ new Date()).getTime();
26956
- return this.xi(o2), this.bi(s2, d2, v2), t2 || this.pi(), l2 && this.ui.forEach(((t3) => t3(s2, o2, l2 ? { noSessionId: u2, activityTimeout: h2, sessionPastMaximumLength: a2 } : void 0))), { sessionId: s2, windowId: o2, sessionStartTimestamp: v2, changeReason: l2 ? { noSessionId: u2, activityTimeout: h2, sessionPastMaximumLength: a2 } : void 0, lastActivityTimestamp: r2 };
26956
+ return this.xi(o2), this.bi(s2, d2, v2), t2 || this.pi(), l2 && this.ui.forEach(((t3) => t3(s2, o2, l2 ? { noSessionId: u2, activityTimeout: h5, sessionPastMaximumLength: a2 } : void 0))), { sessionId: s2, windowId: o2, sessionStartTimestamp: v2, changeReason: l2 ? { noSessionId: u2, activityTimeout: h5, sessionPastMaximumLength: a2 } : void 0, lastActivityTimestamp: r2 };
26957
26957
  }
26958
26958
  pi() {
26959
26959
  clearTimeout(this.Ci), this.Ci = setTimeout((() => {
@@ -27054,7 +27054,7 @@ var init_module = __esm({
27054
27054
  }
27055
27055
  lr(t2, e2) {
27056
27056
  var i2;
27057
- null == (i2 = h.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, t2, ((t3) => {
27057
+ null == (i2 = h4.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, t2, ((t3) => {
27058
27058
  if (t3) return Dn.error("failed to load script", t3);
27059
27059
  e2();
27060
27060
  }));
@@ -27062,10 +27062,10 @@ var init_module = __esm({
27062
27062
  startIfEnabledOrStop() {
27063
27063
  var t2 = this, e2 = function(e3) {
27064
27064
  var i3, s3, n2;
27065
- !r2 || null != (i3 = h.__PosthogExtensions__) && null != (i3 = i3.integrations) && i3[e3] || t2.lr(Un[e3], (() => {
27065
+ !r2 || null != (i3 = h4.__PosthogExtensions__) && null != (i3 = i3.integrations) && i3[e3] || t2.lr(Un[e3], (() => {
27066
27066
  var i4;
27067
- null == (i4 = h.__PosthogExtensions__) || null == (i4 = i4.integrations) || null == (i4 = i4[e3]) || i4.start(t2._instance);
27068
- })), !r2 && null != (s3 = h.__PosthogExtensions__) && null != (s3 = s3.integrations) && s3[e3] && (null == (n2 = h.__PosthogExtensions__) || null == (n2 = n2.integrations) || null == (n2 = n2[e3]) || n2.stop());
27067
+ null == (i4 = h4.__PosthogExtensions__) || null == (i4 = i4.integrations) || null == (i4 = i4[e3]) || i4.start(t2._instance);
27068
+ })), !r2 && null != (s3 = h4.__PosthogExtensions__) && null != (s3 = s3.integrations) && s3[e3] && (null == (n2 = h4.__PosthogExtensions__) || null == (n2 = n2.integrations) || null == (n2 = n2[e3]) || n2.stop());
27069
27069
  };
27070
27070
  for (var [i2, r2] of Object.entries(null !== (s2 = this._instance.config.integrations) && void 0 !== s2 ? s2 : {})) {
27071
27071
  var s2;
@@ -27161,12 +27161,12 @@ var init_module = __esm({
27161
27161
  if (u2 || (this.sessionManager = new wn(this), this.sessionPropsManager = new mn(this, this.sessionManager, this.persistence)), this.config.__preview_deferred_init_extensions ? (Le.info("Deferring extension initialization to improve startup performance"), setTimeout((() => {
27162
27162
  this.Vi(u2);
27163
27163
  }), 0)) : (Le.info("Initializing extensions synchronously"), this.Vi(u2)), v.DEBUG = v.DEBUG || this.config.debug, v.DEBUG && Le.info("Starting in debug mode", { this: this, config: i2, thisC: f({}, this.config), p: a2, s: l2 }), !this.config.identity_distinct_id || null != (s2 = i2.bootstrap) && s2.distinctID || (i2.bootstrap = f({}, i2.bootstrap, { distinctID: this.config.identity_distinct_id, isIdentifiedID: true })), void 0 !== (null == (n2 = i2.bootstrap) ? void 0 : n2.distinctID)) {
27164
- var h2 = i2.bootstrap.distinctID, d2 = this.get_distinct_id(), c2 = this.persistence.get_property($i);
27165
- if (i2.bootstrap.isIdentifiedID && null != d2 && d2 !== h2 && c2 === ji) this.identify(h2);
27166
- else if (i2.bootstrap.isIdentifiedID && null != d2 && d2 !== h2 && c2 === zi) Le.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");
27164
+ var h5 = i2.bootstrap.distinctID, d2 = this.get_distinct_id(), c2 = this.persistence.get_property($i);
27165
+ if (i2.bootstrap.isIdentifiedID && null != d2 && d2 !== h5 && c2 === ji) this.identify(h5);
27166
+ else if (i2.bootstrap.isIdentifiedID && null != d2 && d2 !== h5 && c2 === zi) Le.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");
27167
27167
  else {
27168
- var p2 = this.config.get_device_id(dr()), _2 = i2.bootstrap.isIdentifiedID ? p2 : h2;
27169
- this.persistence.set_property($i, i2.bootstrap.isIdentifiedID ? zi : ji), this.register({ distinct_id: h2, $device_id: _2 });
27168
+ var p2 = this.config.get_device_id(dr()), _2 = i2.bootstrap.isIdentifiedID ? p2 : h5;
27169
+ this.persistence.set_property($i, i2.bootstrap.isIdentifiedID ? zi : ji), this.register({ distinct_id: h5, $device_id: _2 });
27170
27170
  }
27171
27171
  }
27172
27172
  if (u2) this.register_once({ distinct_id: Ai, $device_id: null }, "");
@@ -27202,19 +27202,19 @@ var init_module = __esm({
27202
27202
  })(this, (() => this.Wi())) : this.Wi(), D(this.config._onCapture) && this.config._onCapture !== Bn && (Le.warn("onCapture is deprecated. Please use `before_send` instead"), this.on("eventCaptured", ((t2) => this.config._onCapture(t2.event, t2)))), this.config.ip && Le.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'), this;
27203
27203
  }
27204
27204
  Vi(t2) {
27205
- var e2, i2, r2, s2, n2, o2, a2, l2 = performance.now(), u2 = f({}, _Zn.__defaultExtensionClasses, this.config.__extensionClasses), h2 = [];
27206
- u2.featureFlags && this.Pi.push(this.featureFlags = null !== (e2 = this.featureFlags) && void 0 !== e2 ? e2 : new u2.featureFlags(this)), u2.exceptions && this.Pi.push(this.exceptions = null !== (i2 = this.exceptions) && void 0 !== i2 ? i2 : new u2.exceptions(this)), u2.historyAutocapture && this.Pi.push(this.historyAutocapture = new u2.historyAutocapture(this)), u2.tracingHeaders && this.Pi.push(new u2.tracingHeaders(this)), u2.siteApps && this.Pi.push(this.siteApps = new u2.siteApps(this)), u2.sessionRecording && !t2 && this.Pi.push(this.sessionRecording = new u2.sessionRecording(this)), this.config.disable_scroll_properties || h2.push((() => {
27205
+ var e2, i2, r2, s2, n2, o2, a2, l2 = performance.now(), u2 = f({}, _Zn.__defaultExtensionClasses, this.config.__extensionClasses), h5 = [];
27206
+ u2.featureFlags && this.Pi.push(this.featureFlags = null !== (e2 = this.featureFlags) && void 0 !== e2 ? e2 : new u2.featureFlags(this)), u2.exceptions && this.Pi.push(this.exceptions = null !== (i2 = this.exceptions) && void 0 !== i2 ? i2 : new u2.exceptions(this)), u2.historyAutocapture && this.Pi.push(this.historyAutocapture = new u2.historyAutocapture(this)), u2.tracingHeaders && this.Pi.push(new u2.tracingHeaders(this)), u2.siteApps && this.Pi.push(this.siteApps = new u2.siteApps(this)), u2.sessionRecording && !t2 && this.Pi.push(this.sessionRecording = new u2.sessionRecording(this)), this.config.disable_scroll_properties || h5.push((() => {
27207
27207
  this.scrollManager.startMeasuringScrollPosition();
27208
27208
  })), u2.autocapture && this.Pi.push(this.autocapture = new u2.autocapture(this)), u2.surveys && this.Pi.push(this.surveys = null !== (r2 = this.surveys) && void 0 !== r2 ? r2 : new u2.surveys(this)), u2.logs && this.Pi.push(this.logs = null !== (s2 = this.logs) && void 0 !== s2 ? s2 : new u2.logs(this)), u2.conversations && this.Pi.push(this.conversations = null !== (n2 = this.conversations) && void 0 !== n2 ? n2 : new u2.conversations(this)), u2.productTours && this.Pi.push(this.productTours = new u2.productTours(this)), u2.heatmaps && this.Pi.push(this.heatmaps = new u2.heatmaps(this)), u2.webVitalsAutocapture && this.Pi.push(this.webVitalsAutocapture = new u2.webVitalsAutocapture(this)), u2.exceptionObserver && this.Pi.push(this.exceptionObserver = new u2.exceptionObserver(this)), u2.deadClicksAutocapture && this.Pi.push(this.deadClicksAutocapture = new u2.deadClicksAutocapture(this, Tr)), u2.toolbar && this.Pi.push(this.toolbar = null !== (o2 = this.toolbar) && void 0 !== o2 ? o2 : new u2.toolbar(this)), u2.experiments && this.Pi.push(this.experiments = null !== (a2 = this.experiments) && void 0 !== a2 ? a2 : new u2.experiments(this)), this.Pi.forEach(((t3) => {
27209
- t3.initialize && h2.push((() => {
27209
+ t3.initialize && h5.push((() => {
27210
27210
  null == t3.initialize || t3.initialize();
27211
27211
  }));
27212
- })), h2.push((() => {
27212
+ })), h5.push((() => {
27213
27213
  if (this.Zi) {
27214
27214
  var t3 = this.Zi;
27215
27215
  this.Zi = void 0, this.Rr(t3);
27216
27216
  }
27217
- })), this.Gi(h2, l2);
27217
+ })), this.Gi(h5, l2);
27218
27218
  }
27219
27219
  Gi(t2, e2) {
27220
27220
  for (; t2.length > 0; ) {
@@ -27336,7 +27336,7 @@ var init_module = __esm({
27336
27336
  var u2 = null != i2 && i2.skip_client_rate_limiting ? void 0 : this.rateLimiter.clientRateLimitContext();
27337
27337
  if (null == u2 || !u2.isRateLimited) {
27338
27338
  null != e2 && e2.$current_url && !j(null == e2 ? void 0 : e2.$current_url) && (Le.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."), null == e2 || delete e2.$current_url), "$exception" !== t2 || null != i2 && i2.en || Le.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."), this.sessionPersistence.update_search_keyword(), this.config.save_campaign_params && this.sessionPersistence.update_campaign_params(), this.config.save_referrer && this.sessionPersistence.update_referrer_info(), (this.config.save_campaign_params || this.config.save_referrer) && this.persistence.set_initial_person_info();
27339
- var h2 = /* @__PURE__ */ new Date(), d2 = (null == i2 ? void 0 : i2.timestamp) || h2, v2 = (null == i2 ? void 0 : i2.uuid) || dr(), c2 = { uuid: v2, event: t2, properties: this.calculateEventProperties(t2, e2 || {}, d2, v2) };
27339
+ var h5 = /* @__PURE__ */ new Date(), d2 = (null == i2 ? void 0 : i2.timestamp) || h5, v2 = (null == i2 ? void 0 : i2.uuid) || dr(), c2 = { uuid: v2, event: t2, properties: this.calculateEventProperties(t2, e2 || {}, d2, v2) };
27340
27340
  t2 === Vi && this.config.__preview_capture_bot_pageviews && l2 && (c2.event = "$bot_pageview", c2.properties.$browser_type = "bot"), u2 && (c2.properties.$lib_rate_limit_remaining_tokens = u2.remainingTokens), (null == i2 ? void 0 : i2.$set) && (c2.$set = null == i2 ? void 0 : i2.$set);
27341
27341
  var p2, _2, g2, m2 = this.tn(null == i2 ? void 0 : i2.$set_once, t2 !== Yi, t2 === Gi);
27342
27342
  if (m2 && (c2.$set_once = m2), null != i2 && i2._noTruncate || (s2 = this.config.properties_string_max_length, n2 = c2, o2 = (t3) => j(t3) ? t3.slice(0, s2) : t3, a2 = /* @__PURE__ */ new Set(), c2 = (function t3(e3, i3) {
@@ -27346,7 +27346,7 @@ var init_module = __esm({
27346
27346
  a2.has(e4) || (r3[i4] = t3(e4));
27347
27347
  }))), r3);
27348
27348
  var r3;
27349
- })(n2)), c2.timestamp = d2, N(null == i2 ? void 0 : i2.timestamp) || (c2.properties.$event_time_override_provided = true, c2.properties.$event_time_override_system_time = h2), t2 === hs.DISMISSED || t2 === hs.SENT) {
27349
+ })(n2)), c2.timestamp = d2, N(null == i2 ? void 0 : i2.timestamp) || (c2.properties.$event_time_override_provided = true, c2.properties.$event_time_override_system_time = h5), t2 === hs.DISMISSED || t2 === hs.SENT) {
27350
27350
  var b2 = null == e2 ? void 0 : e2[ds.SURVEY_ID], y2 = null == e2 ? void 0 : e2[ds.SURVEY_ITERATION];
27351
27351
  ((t3) => {
27352
27352
  try {
@@ -27385,45 +27385,45 @@ var init_module = __esm({
27385
27385
  }
27386
27386
  calculateEventProperties(e2, i2, n2, o2, a2) {
27387
27387
  if (n2 = n2 || /* @__PURE__ */ new Date(), !this.persistence || !this.sessionPersistence) return i2;
27388
- var l2 = a2 ? void 0 : this.persistence.remove_event_timer(e2), h2 = f({}, i2);
27389
- if (h2.token = this.config.token, h2.$config_defaults = this.config.defaults, this.Ri() && (h2.$cookieless_mode = true), "$snapshot" === e2) {
27388
+ var l2 = a2 ? void 0 : this.persistence.remove_event_timer(e2), h5 = f({}, i2);
27389
+ if (h5.token = this.config.token, h5.$config_defaults = this.config.defaults, this.Ri() && (h5.$cookieless_mode = true), "$snapshot" === e2) {
27390
27390
  var d2 = f({}, this.persistence.properties(), this.sessionPersistence.properties());
27391
- return h2.distinct_id = d2.distinct_id, (!j(h2.distinct_id) && !q(h2.distinct_id) || z(h2.distinct_id)) && Le.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"), h2;
27391
+ return h5.distinct_id = d2.distinct_id, (!j(h5.distinct_id) && !q(h5.distinct_id) || z(h5.distinct_id)) && Le.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"), h5;
27392
27392
  }
27393
27393
  var c2, p2 = (function(e3, i3) {
27394
27394
  var r2, n3, o3, a3;
27395
27395
  if (!u) return {};
27396
- var l3, h3, d3, c3, p3, f2, _3, g3, m3 = e3 ? [...jr, ...i3 || []] : [], [b3, y3] = (function(t2) {
27396
+ var l3, h6, d3, c3, p3, f2, _3, g3, m3 = e3 ? [...jr, ...i3 || []] : [], [b3, y3] = (function(t2) {
27397
27397
  for (var e4 = 0; Zt.length > e4; e4++) {
27398
27398
  var [i4, r3] = Zt[e4], s2 = i4.exec(t2), n4 = s2 && (D(r3) ? r3(s2, t2) : r3);
27399
27399
  if (n4) return n4;
27400
27400
  }
27401
27401
  return ["", ""];
27402
27402
  })(u);
27403
- return Xi(er({ $os: b3, $os_version: y3, $browser: Kt(u, navigator.vendor), $device: te(u), $device_type: (h3 = u, d3 = { userAgentDataPlatform: null == (r2 = navigator) || null == (r2 = r2.userAgentData) ? void 0 : r2.platform, maxTouchPoints: null == (n3 = navigator) ? void 0 : n3.maxTouchPoints, screenWidth: null == t || null == (o3 = t.screen) ? void 0 : o3.width, screenHeight: null == t || null == (a3 = t.screen) ? void 0 : a3.height, devicePixelRatio: null == t ? void 0 : t.devicePixelRatio }, g3 = te(h3), g3 === dt || g3 === ht || "Kobo" === g3 || "Kindle Fire" === g3 || g3 === zt ? ut : g3 === Ot || g3 === Ct || g3 === It || g3 === Lt ? "Console" : g3 === ct ? "Wearable" : g3 ? ot : "Android" === (null == d3 ? void 0 : d3.userAgentDataPlatform) && (null !== (c3 = null == d3 ? void 0 : d3.maxTouchPoints) && void 0 !== c3 ? c3 : 0) > 0 ? 600 > Math.min(null !== (p3 = null == d3 ? void 0 : d3.screenWidth) && void 0 !== p3 ? p3 : 0, null !== (f2 = null == d3 ? void 0 : d3.screenHeight) && void 0 !== f2 ? f2 : 0) / (null !== (_3 = null == d3 ? void 0 : d3.devicePixelRatio) && void 0 !== _3 ? _3 : 1) ? ot : ut : "Desktop"), $timezone: Qr(), $timezone_offset: Zr() }), { $current_url: Ur(null == s ? void 0 : s.href, m3, Br), $host: null == s ? void 0 : s.host, $pathname: null == s ? void 0 : s.pathname, $raw_user_agent: u.length > 1e3 ? u.substring(0, 997) + "..." : u, $browser_version: Qt(u, navigator.vendor), $browser_language: Gr(), $browser_language_prefix: (l3 = Gr(), "string" == typeof l3 ? l3.split("-")[0] : void 0), $screen_height: null == t ? void 0 : t.screen.height, $screen_width: null == t ? void 0 : t.screen.width, $viewport_height: null == t ? void 0 : t.innerHeight, $viewport_width: null == t ? void 0 : t.innerWidth, $lib: v.LIB_NAME, $lib_version: v.LIB_VERSION, $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10), $time: Date.now() / 1e3 });
27403
+ return Xi(er({ $os: b3, $os_version: y3, $browser: Kt(u, navigator.vendor), $device: te(u), $device_type: (h6 = u, d3 = { userAgentDataPlatform: null == (r2 = navigator) || null == (r2 = r2.userAgentData) ? void 0 : r2.platform, maxTouchPoints: null == (n3 = navigator) ? void 0 : n3.maxTouchPoints, screenWidth: null == t || null == (o3 = t.screen) ? void 0 : o3.width, screenHeight: null == t || null == (a3 = t.screen) ? void 0 : a3.height, devicePixelRatio: null == t ? void 0 : t.devicePixelRatio }, g3 = te(h6), g3 === dt || g3 === ht || "Kobo" === g3 || "Kindle Fire" === g3 || g3 === zt ? ut : g3 === Ot || g3 === Ct || g3 === It || g3 === Lt ? "Console" : g3 === ct ? "Wearable" : g3 ? ot : "Android" === (null == d3 ? void 0 : d3.userAgentDataPlatform) && (null !== (c3 = null == d3 ? void 0 : d3.maxTouchPoints) && void 0 !== c3 ? c3 : 0) > 0 ? 600 > Math.min(null !== (p3 = null == d3 ? void 0 : d3.screenWidth) && void 0 !== p3 ? p3 : 0, null !== (f2 = null == d3 ? void 0 : d3.screenHeight) && void 0 !== f2 ? f2 : 0) / (null !== (_3 = null == d3 ? void 0 : d3.devicePixelRatio) && void 0 !== _3 ? _3 : 1) ? ot : ut : "Desktop"), $timezone: Qr(), $timezone_offset: Zr() }), { $current_url: Ur(null == s ? void 0 : s.href, m3, Br), $host: null == s ? void 0 : s.host, $pathname: null == s ? void 0 : s.pathname, $raw_user_agent: u.length > 1e3 ? u.substring(0, 997) + "..." : u, $browser_version: Qt(u, navigator.vendor), $browser_language: Gr(), $browser_language_prefix: (l3 = Gr(), "string" == typeof l3 ? l3.split("-")[0] : void 0), $screen_height: null == t ? void 0 : t.screen.height, $screen_width: null == t ? void 0 : t.screen.width, $viewport_height: null == t ? void 0 : t.innerHeight, $viewport_width: null == t ? void 0 : t.innerWidth, $lib: v.LIB_NAME, $lib_version: v.LIB_VERSION, $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10), $time: Date.now() / 1e3 });
27404
27404
  })(this.config.mask_personal_data_properties, this.config.custom_personal_data_properties);
27405
27405
  if (this.sessionManager) {
27406
27406
  var { sessionId: _2, windowId: g2 } = this.sessionManager.checkAndGetSessionAndWindowId(a2, n2.getTime());
27407
- h2.$session_id = _2, h2.$window_id = g2;
27407
+ h5.$session_id = _2, h5.$window_id = g2;
27408
27408
  }
27409
- this.sessionPropsManager && Xi(h2, this.sessionPropsManager.getSessionProps());
27409
+ this.sessionPropsManager && Xi(h5, this.sessionPropsManager.getSessionProps());
27410
27410
  try {
27411
27411
  var m2;
27412
- this.sessionRecording && Xi(h2, this.sessionRecording.sdkDebugProperties), h2.$sdk_debug_retry_queue_size = null == (m2 = this.zi) ? void 0 : m2.length;
27412
+ this.sessionRecording && Xi(h5, this.sessionRecording.sdkDebugProperties), h5.$sdk_debug_retry_queue_size = null == (m2 = this.zi) ? void 0 : m2.length;
27413
27413
  } catch (t2) {
27414
- h2.$sdk_debug_error_capturing_properties = String(t2);
27414
+ h5.$sdk_debug_error_capturing_properties = String(t2);
27415
27415
  }
27416
- if (this.requestRouter.region === Rn && (h2.$lib_custom_api_host = this.config.api_host), c2 = e2 !== Vi || a2 ? e2 !== Wi || a2 ? this.pageViewManager.doEvent() : this.pageViewManager.doPageLeave(n2) : this.pageViewManager.doPageView(n2, o2), h2 = Xi(h2, c2), e2 === Vi && r && (h2.title = r.title), !N(l2)) {
27416
+ if (this.requestRouter.region === Rn && (h5.$lib_custom_api_host = this.config.api_host), c2 = e2 !== Vi || a2 ? e2 !== Wi || a2 ? this.pageViewManager.doEvent() : this.pageViewManager.doPageLeave(n2) : this.pageViewManager.doPageView(n2, o2), h5 = Xi(h5, c2), e2 === Vi && r && (h5.title = r.title), !N(l2)) {
27417
27417
  var b2 = n2.getTime() - l2;
27418
- h2.$duration = parseFloat((b2 / 1e3).toFixed(3));
27418
+ h5.$duration = parseFloat((b2 / 1e3).toFixed(3));
27419
27419
  }
27420
- u && this.config.opt_out_useragent_filter && (h2.$browser_type = this._is_bot() ? "bot" : "browser"), (h2 = Xi({}, p2, this.persistence.properties(), this.sessionPersistence.properties(), h2)).$is_identified = this._isIdentified(), M2(this.config.property_denylist) ? Ki(this.config.property_denylist, (function(t2) {
27421
- delete h2[t2];
27420
+ u && this.config.opt_out_useragent_filter && (h5.$browser_type = this._is_bot() ? "bot" : "browser"), (h5 = Xi({}, p2, this.persistence.properties(), this.sessionPersistence.properties(), h5)).$is_identified = this._isIdentified(), M2(this.config.property_denylist) ? Ki(this.config.property_denylist, (function(t2) {
27421
+ delete h5[t2];
27422
27422
  })) : Le.error(Wn + this.config.property_denylist + " or property_blacklist config: " + this.config.property_blacklist);
27423
27423
  var y2 = this.config.sanitize_properties;
27424
- y2 && (Le.error(Vn), h2 = y2(h2, e2));
27424
+ y2 && (Le.error(Vn), h5 = y2(h5, e2));
27425
27425
  var w2 = this.nn();
27426
- return h2.$process_person_profile = w2, w2 && !a2 && this.sn("_calculate_event_properties"), h2;
27426
+ return h5.$process_person_profile = w2, w2 && !a2 && this.sn("_calculate_event_properties"), h5;
27427
27427
  }
27428
27428
  tn(t2, e2, i2) {
27429
27429
  var r2;
@@ -27582,8 +27582,8 @@ var init_module = __esm({
27582
27582
  var u2 = this.get_property(He);
27583
27583
  if (this.consent.reset(), null == (e2 = this.persistence) || e2.clear(), null == (i2 = this.sessionPersistence) || i2.clear(), null == (r2 = this.surveys) || r2.reset(), null == (s2 = this.Yi) || s2.stop(), null == (n2 = this.featureFlags) || n2.reset(), null == (o2 = this.conversations) || o2.reset(), null == (a2 = this.persistence) || a2.set_property($i, ji), null == (l2 = this.sessionManager) || l2.resetSessionId(), this.$i = null, this.config.cookieless_mode === Ni) this.register_once({ distinct_id: Ai, $device_id: null }, "");
27584
27584
  else {
27585
- var h2 = this.config.get_device_id(dr());
27586
- this.register_once({ distinct_id: h2, $device_id: t2 ? h2 : u2 }, "");
27585
+ var h5 = this.config.get_device_id(dr());
27586
+ this.register_once({ distinct_id: h5, $device_id: t2 ? h5 : u2 }, "");
27587
27587
  }
27588
27588
  this.register({ $last_posthog_reset: (/* @__PURE__ */ new Date()).toISOString() }, 1), delete this.config.identity_distinct_id, delete this.config.identity_hash, this.reloadFeatureFlags();
27589
27589
  }
@@ -27621,12 +27621,12 @@ var init_module = __esm({
27621
27621
  set_config(t2) {
27622
27622
  var e2 = f({}, this.config);
27623
27623
  if (U(t2)) {
27624
- var i2, r2, s2, n2, o2, a2, l2, u2, h2, d2;
27624
+ var i2, r2, s2, n2, o2, a2, l2, u2, h5, d2;
27625
27625
  Xi(this.config, Xn(t2));
27626
27626
  var c2 = this.Hi();
27627
27627
  null == (i2 = this.persistence) || i2.update_config(this.config, e2, c2), this.sessionPersistence = "sessionStorage" === this.config.persistence || "memory" === this.config.persistence ? this.persistence : new es(f({}, this.config, { persistence: "sessionStorage" }), c2);
27628
27628
  var p2 = this.Di(this.config.debug);
27629
- W(p2) && (this.config.debug = p2), W(this.config.debug) && (this.config.debug ? (v.DEBUG = true, gr.R() && gr.N("ph_debug", true), Le.info("set_config", { config: t2, oldConfig: e2, newConfig: f({}, this.config) })) : (v.DEBUG = false, gr.R() && gr.q("ph_debug"))), null == (r2 = this.exceptionObserver) || r2.onConfigChange(), null == (s2 = this.exceptions) || s2.onConfigChange(), null == (n2 = this.sessionRecording) || n2.startIfEnabledOrStop(), null == (o2 = this.autocapture) || o2.startIfEnabled(), null == (a2 = this.heatmaps) || a2.startIfEnabled(), null == (l2 = this.exceptionObserver) || l2.startIfEnabledOrStop(), null == (u2 = this.deadClicksAutocapture) || u2.startIfEnabledOrStop(), null == (h2 = this.surveys) || h2.loadIfEnabled(), this.cn(), null == (d2 = this.externalIntegrations) || d2.startIfEnabledOrStop();
27629
+ W(p2) && (this.config.debug = p2), W(this.config.debug) && (this.config.debug ? (v.DEBUG = true, gr.R() && gr.N("ph_debug", true), Le.info("set_config", { config: t2, oldConfig: e2, newConfig: f({}, this.config) })) : (v.DEBUG = false, gr.R() && gr.q("ph_debug"))), null == (r2 = this.exceptionObserver) || r2.onConfigChange(), null == (s2 = this.exceptions) || s2.onConfigChange(), null == (n2 = this.sessionRecording) || n2.startIfEnabledOrStop(), null == (o2 = this.autocapture) || o2.startIfEnabled(), null == (a2 = this.heatmaps) || a2.startIfEnabled(), null == (l2 = this.exceptionObserver) || l2.startIfEnabledOrStop(), null == (u2 = this.deadClicksAutocapture) || u2.startIfEnabledOrStop(), null == (h5 = this.surveys) || h5.loadIfEnabled(), this.cn(), null == (d2 = this.externalIntegrations) || d2.startIfEnabledOrStop();
27630
27630
  }
27631
27631
  }
27632
27632
  _overrideSDKInfo(t2, e2) {
@@ -27722,8 +27722,8 @@ var init_module = __esm({
27722
27722
  var a2, l2 = null !== (s2 = null == (n2 = this.config.__extensionClasses) ? void 0 : n2.sessionRecording) && void 0 !== s2 ? s2 : null == (o2 = _Zn.__defaultExtensionClasses) ? void 0 : o2.sessionRecording;
27723
27723
  l2 && (this.sessionRecording = this.Mi(this.sessionRecording, new l2(this)), this.Qi && (null == (a2 = this.sessionRecording) || null == a2.onRemoteConfig || a2.onRemoteConfig(this.Qi)));
27724
27724
  }
27725
- var u2, h2;
27726
- this.consent.optInOut(true), this.cn(), this.Ji(), null == (e2 = this.sessionRecording) || e2.startIfEnabledOrStop(), this.config.cookieless_mode == Li && (null == (u2 = this.surveys) || u2.loadIfEnabled()), (N(null == t2 ? void 0 : t2.captureEventName) || null != t2 && t2.captureEventName) && this.capture(null !== (h2 = null == t2 ? void 0 : t2.captureEventName) && void 0 !== h2 ? h2 : "$opt_in", null == t2 ? void 0 : t2.captureProperties, { send_instantly: true }), this.config.capture_pageview && this.Ki();
27725
+ var u2, h5;
27726
+ this.consent.optInOut(true), this.cn(), this.Ji(), null == (e2 = this.sessionRecording) || e2.startIfEnabledOrStop(), this.config.cookieless_mode == Li && (null == (u2 = this.surveys) || u2.loadIfEnabled()), (N(null == t2 ? void 0 : t2.captureEventName) || null != t2 && t2.captureEventName) && this.capture(null !== (h5 = null == t2 ? void 0 : t2.captureEventName) && void 0 !== h5 ? h5 : "$opt_in", null == t2 ? void 0 : t2.captureProperties, { send_instantly: true }), this.config.capture_pageview && this.Ki();
27727
27727
  } else Le.warn(Hn);
27728
27728
  }
27729
27729
  opt_out_capturing() {
@@ -28018,8 +28018,8 @@ var init_module = __esm({
28018
28018
  r2.info("event matched, removing item from activated items", { event: t2, eventPayload: e2, existingActivatedItems: o2 });
28019
28019
  var u2 = (null == e2 || null == (a2 = e2.properties) ? void 0 : a2.$survey_id) || (null == e2 || null == (l2 = e2.properties) ? void 0 : l2.$product_tour_id);
28020
28020
  if (u2) {
28021
- var h2 = o2.indexOf(u2);
28022
- 0 > h2 || (o2.splice(h2, 1), this.qn(o2));
28021
+ var h5 = o2.indexOf(u2);
28022
+ 0 > h5 || (o2.splice(h5, 1), this.qn(o2));
28023
28023
  }
28024
28024
  } else {
28025
28025
  if (this.En.has(t2)) {
@@ -28188,7 +28188,7 @@ var init_module = __esm({
28188
28188
  if (H(t2.conditions) || H(null == (e2 = t2.conditions) ? void 0 : e2.utm)) return true;
28189
28189
  var i2 = qr();
28190
28190
  if (i2.utm_source) {
28191
- var r2, s2, n2, o2, a2, l2, u2, h2, d2 = null == (r2 = t2.conditions) || null == (r2 = r2.utm) || !r2.utm_campaign || (null == (s2 = t2.conditions) || null == (s2 = s2.utm) ? void 0 : s2.utm_campaign) == i2.utm_campaign, v2 = null == (n2 = t2.conditions) || null == (n2 = n2.utm) || !n2.utm_source || (null == (o2 = t2.conditions) || null == (o2 = o2.utm) ? void 0 : o2.utm_source) == i2.utm_source, c2 = null == (a2 = t2.conditions) || null == (a2 = a2.utm) || !a2.utm_medium || (null == (l2 = t2.conditions) || null == (l2 = l2.utm) ? void 0 : l2.utm_medium) == i2.utm_medium, p2 = null == (u2 = t2.conditions) || null == (u2 = u2.utm) || !u2.utm_term || (null == (h2 = t2.conditions) || null == (h2 = h2.utm) ? void 0 : h2.utm_term) == i2.utm_term;
28191
+ var r2, s2, n2, o2, a2, l2, u2, h5, d2 = null == (r2 = t2.conditions) || null == (r2 = r2.utm) || !r2.utm_campaign || (null == (s2 = t2.conditions) || null == (s2 = s2.utm) ? void 0 : s2.utm_campaign) == i2.utm_campaign, v2 = null == (n2 = t2.conditions) || null == (n2 = n2.utm) || !n2.utm_source || (null == (o2 = t2.conditions) || null == (o2 = o2.utm) ? void 0 : o2.utm_source) == i2.utm_source, c2 = null == (a2 = t2.conditions) || null == (a2 = a2.utm) || !a2.utm_medium || (null == (l2 = t2.conditions) || null == (l2 = l2.utm) ? void 0 : l2.utm_medium) == i2.utm_medium, p2 = null == (u2 = t2.conditions) || null == (u2 = u2.utm) || !u2.utm_term || (null == (h5 = t2.conditions) || null == (h5 = h5.utm) ? void 0 : h5.utm_term) == i2.utm_term;
28192
28192
  return d2 && c2 && p2 && v2;
28193
28193
  }
28194
28194
  return false;
@@ -28256,8 +28256,8 @@ var init_module = __esm({
28256
28256
  updateFlags(t2, e2, i2) {
28257
28257
  var r2 = null != i2 && i2.merge ? this.getFlagVariants() : {}, s2 = null != i2 && i2.merge ? this.getFlagPayloads() : {}, n2 = f({}, r2, t2), o2 = f({}, s2, e2), a2 = {};
28258
28258
  for (var [l2, u2] of Object.entries(n2)) {
28259
- var h2 = "string" == typeof u2;
28260
- a2[l2] = { key: l2, enabled: !!h2 || Boolean(u2), variant: h2 ? u2 : void 0, reason: void 0, metadata: N(null == o2 ? void 0 : o2[l2]) ? void 0 : { id: 0, version: void 0, description: void 0, payload: o2[l2] } };
28259
+ var h5 = "string" == typeof u2;
28260
+ a2[l2] = { key: l2, enabled: !!h5 || Boolean(u2), variant: h5 ? u2 : void 0, reason: void 0, metadata: N(null == o2 ? void 0 : o2[l2]) ? void 0 : { id: 0, version: void 0, description: void 0, payload: o2[l2] } };
28261
28261
  }
28262
28262
  this.receivedFeatureFlags({ flags: a2 });
28263
28263
  }
@@ -28272,8 +28272,8 @@ var init_module = __esm({
28272
28272
  if (!i2 && !e2) return t2 || {};
28273
28273
  var r2 = Xi({}, t2 || {}), s2 = [.../* @__PURE__ */ new Set([...Object.keys(i2 || {}), ...Object.keys(e2 || {})])];
28274
28274
  for (var n2 of s2) {
28275
- var o2, a2, l2 = r2[n2], u2 = null == e2 ? void 0 : e2[n2], h2 = N(u2) ? null !== (o2 = null == l2 ? void 0 : l2.enabled) && void 0 !== o2 && o2 : !!u2, d2 = N(u2) ? l2.variant : "string" == typeof u2 ? u2 : void 0, v2 = null == i2 ? void 0 : i2[n2], c2 = f({}, l2, { enabled: h2, variant: h2 ? null != d2 ? d2 : null == l2 ? void 0 : l2.variant : void 0 });
28276
- h2 !== (null == l2 ? void 0 : l2.enabled) && (c2.original_enabled = null == l2 ? void 0 : l2.enabled), d2 !== (null == l2 ? void 0 : l2.variant) && (c2.original_variant = null == l2 ? void 0 : l2.variant), v2 && (c2.metadata = f({}, null == l2 ? void 0 : l2.metadata, { payload: v2, original_payload: null == l2 || null == (a2 = l2.metadata) ? void 0 : a2.payload })), r2[n2] = c2;
28275
+ var o2, a2, l2 = r2[n2], u2 = null == e2 ? void 0 : e2[n2], h5 = N(u2) ? null !== (o2 = null == l2 ? void 0 : l2.enabled) && void 0 !== o2 && o2 : !!u2, d2 = N(u2) ? l2.variant : "string" == typeof u2 ? u2 : void 0, v2 = null == i2 ? void 0 : i2[n2], c2 = f({}, l2, { enabled: h5, variant: h5 ? null != d2 ? d2 : null == l2 ? void 0 : l2.variant : void 0 });
28276
+ h5 !== (null == l2 ? void 0 : l2.enabled) && (c2.original_enabled = null == l2 ? void 0 : l2.enabled), d2 !== (null == l2 ? void 0 : l2.variant) && (c2.original_variant = null == l2 ? void 0 : l2.variant), v2 && (c2.metadata = f({}, null == l2 ? void 0 : l2.metadata, { payload: v2, original_payload: null == l2 || null == (a2 = l2.metadata) ? void 0 : a2.payload })), r2[n2] = c2;
28277
28277
  }
28278
28278
  return this.Kn || (ca.warn(" Overriding feature flag details!", { flagDetails: t2, overriddenPayloads: i2, finalDetails: r2 }), this.Kn = true), r2;
28279
28279
  }
@@ -28347,8 +28347,8 @@ var init_module = __esm({
28347
28347
  if (!this.ls()) {
28348
28348
  var i2 = this.getFlagVariants(), r2 = t2 in i2, s2 = i2[t2], n2 = this.getFlagPayloads()[t2], o2 = String(s2), a2 = this.os(ci) || void 0, l2 = this.os(Si) || void 0, u2 = this.os(wi) || {};
28349
28349
  if (this.qt.advanced_feature_flags_dedup_per_session) {
28350
- var h2, d2 = this._instance.get_session_id(), v2 = this.os(xi);
28351
- d2 && d2 !== v2 && (u2 = {}, null == (h2 = this.ni) || h2.register({ [wi]: u2, [xi]: d2 }));
28350
+ var h5, d2 = this._instance.get_session_id(), v2 = this.os(xi);
28351
+ d2 && d2 !== v2 && (u2 = {}, null == (h5 = this.ni) || h5.register({ [wi]: u2, [xi]: d2 }));
28352
28352
  }
28353
28353
  if ((e2.send_event || !("send_event" in e2)) && (!(t2 in u2) || !u2[t2].includes(o2))) {
28354
28354
  var c2, p2, f2, _2, g2, m2, b2, y2, w2, x2;
@@ -28413,7 +28413,7 @@ var init_module = __esm({
28413
28413
  })))) : ca.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"), t4;
28414
28414
  })(t3), a2 = o2.flags, l2 = o2.featureFlags, u2 = o2.featureFlagPayloads;
28415
28415
  if (l2) {
28416
- var h2 = t3.requestId, d2 = t3.evaluatedAt;
28416
+ var h5 = t3.requestId, d2 = t3.evaluatedAt;
28417
28417
  if (M2(l2)) {
28418
28418
  ca.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");
28419
28419
  var v2 = {};
@@ -28438,7 +28438,7 @@ var init_module = __esm({
28438
28438
  return m2.has(e4);
28439
28439
  }))));
28440
28440
  } else p2 = f({}, i3, p2), _2 = f({}, r3, _2), g2 = f({}, s3, g2);
28441
- e3 && e3.register(f({ [ui]: Object.keys(ga(p2)), [li]: p2 || {}, [vi]: _2 || {}, [di]: g2 || {} }, h2 ? { [ci]: h2 } : {}, d2 ? { [Si]: d2 } : {}));
28441
+ e3 && e3.register(f({ [ui]: Object.keys(ga(p2)), [li]: p2 || {}, [vi]: _2 || {}, [di]: g2 || {} }, h5 ? { [ci]: h5 } : {}, d2 ? { [Si]: d2 } : {}));
28442
28442
  }
28443
28443
  }
28444
28444
  })(t2, this.ni, r2, s2, n2, i2), e2 || (this.ss = false), this.ps(e2);
@@ -28565,7 +28565,7 @@ var init_module = __esm({
28565
28565
  }
28566
28566
  xs(t2) {
28567
28567
  var e2, i2, r2;
28568
- this.ws && (this.bs !== Yo && this.bs !== Jo && (this.bs = Go), null != h && null != (e2 = h.__PosthogExtensions__) && null != (e2 = e2.rrweb) && e2.record && null != (i2 = h.__PosthogExtensions__) && i2.initSessionRecording ? this.Ss(t2) : null == (r2 = h.__PosthogExtensions__) || null == r2.loadExternalDependency || r2.loadExternalDependency(this._instance, this.ks, ((e3) => {
28568
+ this.ws && (this.bs !== Yo && this.bs !== Jo && (this.bs = Go), null != h4 && null != (e2 = h4.__PosthogExtensions__) && null != (e2 = e2.rrweb) && e2.record && null != (i2 = h4.__PosthogExtensions__) && i2.initSessionRecording ? this.Ss(t2) : null == (r2 = h4.__PosthogExtensions__) || null == r2.loadExternalDependency || r2.loadExternalDependency(this._instance, this.ks, ((e3) => {
28569
28569
  if (e3) return Xo.error("could not load recorder", e3);
28570
28570
  this.Ss(t2);
28571
28571
  })));
@@ -28622,8 +28622,8 @@ var init_module = __esm({
28622
28622
  }
28623
28623
  Ss(t2) {
28624
28624
  var e2, i2;
28625
- if (null == (e2 = h.__PosthogExtensions__) || !e2.initSessionRecording) return Xo.warn("Called on script loaded before session recording is available. This can be caused by adblockers."), void this._instance.register_for_session({ [Di]: true });
28626
- if (this.ys || (this.ys = null == (i2 = h.__PosthogExtensions__) ? void 0 : i2.initSessionRecording(this._instance), this.ys._forceAllowLocalhostNetworkCapture = this._forceAllowLocalhostNetworkCapture), !this.Ms()) {
28625
+ if (null == (e2 = h4.__PosthogExtensions__) || !e2.initSessionRecording) return Xo.warn("Called on script loaded before session recording is available. This can be caused by adblockers."), void this._instance.register_for_session({ [Di]: true });
28626
+ if (this.ys || (this.ys = null == (i2 = h4.__PosthogExtensions__) ? void 0 : i2.initSessionRecording(this._instance), this.ys._forceAllowLocalhostNetworkCapture = this._forceAllowLocalhostNetworkCapture), !this.Ms()) {
28627
28627
  if (this.bs === Jo || this.bs === Yo) return;
28628
28628
  return this.bs = Yo, Xo.info("persisted remote config is stale, requesting fresh config before starting"), void new bs(this._instance).load();
28629
28629
  }
@@ -28747,8 +28747,8 @@ var init_module = __esm({
28747
28747
  if (null != (o3 = r3) && o3.url_allowlist && !uo(r3.url_allowlist)) return false;
28748
28748
  if (null != (a3 = r3) && a3.url_ignorelist && uo(r3.url_ignorelist)) return false;
28749
28749
  if (null != (l3 = r3) && l3.dom_event_allowlist) {
28750
- var h3 = r3.dom_event_allowlist;
28751
- if (h3 && !h3.some(((t2) => i3.type === t2))) return false;
28750
+ var h6 = r3.dom_event_allowlist;
28751
+ if (h6 && !h6.some(((t2) => i3.type === t2))) return false;
28752
28752
  }
28753
28753
  var { parentIsUsefulElement: d3, targetElementList: v2 } = wo(e3, s3);
28754
28754
  if (!(function(t2, e4) {
@@ -28781,9 +28781,9 @@ var init_module = __esm({
28781
28781
  if (a2) return false;
28782
28782
  var l2 = this.getElementSelectors(s2);
28783
28783
  if (l2 && l2.length > 0 && (o2.$element_selectors = l2), i2 === Do) {
28784
- var u2, h2 = vo(null == t || null == (u2 = t.getSelection()) ? void 0 : u2.toString()), d2 = e2.type || "clipboard";
28785
- if (!h2) return false;
28786
- o2.$selected_content = h2, o2.$copy_type = d2;
28784
+ var u2, h5 = vo(null == t || null == (u2 = t.getSelection()) ? void 0 : u2.toString()), d2 = e2.type || "clipboard";
28785
+ if (!h5) return false;
28786
+ o2.$selected_content = h5, o2.$copy_type = d2;
28787
28787
  }
28788
28788
  return this.instance.capture(i2, o2), true;
28789
28789
  }
@@ -28936,7 +28936,7 @@ var init_module = __esm({
28936
28936
  }
28937
28937
  }, this.so = () => {
28938
28938
  if (!this.Ps) {
28939
- var t3, e3, i2, r2, s2 = h.__PosthogExtensions__;
28939
+ var t3, e3, i2, r2, s2 = h4.__PosthogExtensions__;
28940
28940
  N(s2) || N(s2.postHogWebVitalsCallbacks) || ({ onLCP: t3, onCLS: e3, onFCP: i2, onINP: r2 } = s2.postHogWebVitalsCallbacks), t3 && e3 && i2 && r2 ? (this.allowedMetrics.indexOf("LCP") > -1 && t3(this.ht.bind(this)), this.allowedMetrics.indexOf("CLS") > -1 && e3(this.ht.bind(this)), this.allowedMetrics.indexOf("FCP") > -1 && i2(this.ht.bind(this)), this.allowedMetrics.indexOf("INP") > -1 && r2(this.ht.bind(this)), this.Ps = true) : qo.error("web vitals callbacks not loaded - not starting");
28941
28941
  }
28942
28942
  }, this._instance = t2, this.js = !(null == (e2 = this._instance.persistence) || !e2.props[Xe]), this.startIfEnabled();
@@ -28976,7 +28976,7 @@ var init_module = __esm({
28976
28976
  }
28977
28977
  lr(t2) {
28978
28978
  var e2, i2;
28979
- null != (e2 = h.__PosthogExtensions__) && e2.postHogWebVitalsCallbacks ? t2() : null == (i2 = h.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, this.useAttribution ? "web-vitals-with-attribution" : "web-vitals", ((e3) => {
28979
+ null != (e2 = h4.__PosthogExtensions__) && e2.postHogWebVitalsCallbacks ? t2() : null == (i2 = h4.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, this.useAttribution ? "web-vitals-with-attribution" : "web-vitals", ((e3) => {
28980
28980
  e3 ? qo.error("failed to load script", e3) : t2();
28981
28981
  }));
28982
28982
  }
@@ -28994,8 +28994,8 @@ var init_module = __esm({
28994
28994
  var i2, r2, s2;
28995
28995
  this.so = () => {
28996
28996
  var e3;
28997
- if (t && this.isEnabled && null != (e3 = h.__PosthogExtensions__) && e3.errorWrappingFunctions) {
28998
- var i3 = h.__PosthogExtensions__.errorWrappingFunctions.wrapOnError, r3 = h.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection, s3 = h.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;
28997
+ if (t && this.isEnabled && null != (e3 = h4.__PosthogExtensions__) && e3.errorWrappingFunctions) {
28998
+ var i3 = h4.__PosthogExtensions__.errorWrappingFunctions.wrapOnError, r3 = h4.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection, s3 = h4.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;
28999
28999
  try {
29000
29000
  !this.ao && this.qt.capture_unhandled_errors && (this.ao = i3(this.captureException.bind(this))), !this.uo && this.qt.capture_unhandled_rejections && (this.uo = r3(this.captureException.bind(this))), !this.lo && this.qt.capture_console_errors && (this.lo = s3(this.captureException.bind(this)));
29001
29001
  } catch (t2) {
@@ -29016,7 +29016,7 @@ var init_module = __esm({
29016
29016
  }
29017
29017
  lr(t2) {
29018
29018
  var e2, i2;
29019
- null != (e2 = h.__PosthogExtensions__) && e2.errorWrappingFunctions && t2(), null == (i2 = h.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, "exception-autocapture", ((e3) => {
29019
+ null != (e2 = h4.__PosthogExtensions__) && e2.errorWrappingFunctions && t2(), null == (i2 = h4.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, "exception-autocapture", ((e3) => {
29020
29020
  if (e3) return zo.error("failed to load script", e3);
29021
29021
  t2();
29022
29022
  }));
@@ -29048,9 +29048,9 @@ var init_module = __esm({
29048
29048
  var l2 = me.test(a2) ? a2.replace(me, "$1") : a2;
29049
29049
  if (!l2.match(/\S*Error: /)) {
29050
29050
  for (var u2 of i3) {
29051
- var h2 = u2(l2, t3);
29052
- if (h2) {
29053
- s2.push(h2);
29051
+ var h5 = u2(l2, t3);
29052
+ if (h5) {
29053
+ s2.push(h5);
29054
29054
  break;
29055
29055
  }
29056
29056
  }
@@ -29186,13 +29186,13 @@ var init_module = __esm({
29186
29186
  }
29187
29187
  lr(t2) {
29188
29188
  var e2, i2;
29189
- null != (e2 = h.__PosthogExtensions__) && e2.generateProductTours ? t2() : null == (i2 = h.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, "product-tours", ((e3) => {
29189
+ null != (e2 = h4.__PosthogExtensions__) && e2.generateProductTours ? t2() : null == (i2 = h4.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, "product-tours", ((e3) => {
29190
29190
  e3 ? ta.error("Could not load product tours script", e3) : t2();
29191
29191
  }));
29192
29192
  }
29193
29193
  Po() {
29194
29194
  var t2;
29195
- !this.Eo && null != (t2 = h.__PosthogExtensions__) && t2.generateProductTours && (this.Eo = h.__PosthogExtensions__.generateProductTours(this._instance, true));
29195
+ !this.Eo && null != (t2 = h4.__PosthogExtensions__) && t2.generateProductTours && (this.Eo = h4.__PosthogExtensions__.generateProductTours(this._instance, true));
29196
29196
  }
29197
29197
  getProductTours(t2, e2) {
29198
29198
  if (void 0 === e2 && (e2 = false), !M2(this.Mo) || e2) {
@@ -29269,7 +29269,7 @@ var init_module = __esm({
29269
29269
  }
29270
29270
  get siteAppLoaders() {
29271
29271
  var t2;
29272
- return null == (t2 = h._POSTHOG_REMOTE_CONFIG) || null == (t2 = t2[this._instance.config.token]) ? void 0 : t2.siteApps;
29272
+ return null == (t2 = h4._POSTHOG_REMOTE_CONFIG) || null == (t2 = t2[this._instance.config.token]) ? void 0 : t2.siteApps;
29273
29273
  }
29274
29274
  initialize() {
29275
29275
  if (this.isEnabled) {
@@ -29282,8 +29282,8 @@ var init_module = __esm({
29282
29282
  globalsForEvent(t2) {
29283
29283
  var e2, i2, r2, s2, n2, o2, a2;
29284
29284
  if (!t2) throw new Error("Event payload is required");
29285
- var l2 = {}, u2 = this._instance.get_property("$groups") || [], h2 = this._instance.get_property("$stored_group_properties") || {};
29286
- for (var [d2, v2] of Object.entries(h2)) l2[d2] = { id: u2[d2], type: d2, properties: v2 };
29285
+ var l2 = {}, u2 = this._instance.get_property("$groups") || [], h5 = this._instance.get_property("$stored_group_properties") || {};
29286
+ for (var [d2, v2] of Object.entries(h5)) l2[d2] = { id: u2[d2], type: d2, properties: v2 };
29287
29287
  var { $set_once: c2, $set: p2 } = t2;
29288
29288
  return { event: f({}, _(t2, ea), { properties: f({}, t2.properties, p2 ? { $set: f({}, null !== (e2 = null == (i2 = t2.properties) ? void 0 : i2.$set) && void 0 !== e2 ? e2 : {}, p2) } : {}, c2 ? { $set_once: f({}, null !== (r2 = null == (s2 = t2.properties) ? void 0 : s2.$set_once) && void 0 !== r2 ? r2 : {}, c2) } : {}), elements_chain: null !== (n2 = null == (o2 = t2.properties) ? void 0 : o2.$elements_chain) && void 0 !== n2 ? n2 : "", distinct_id: null == (a2 = t2.properties) ? void 0 : a2.distinct_id }), person: { properties: this._instance.get_property("$stored_person_properties") }, groups: l2 };
29289
29289
  }
@@ -29329,7 +29329,7 @@ var init_module = __esm({
29329
29329
  if (null == (i2 = this.Lo) || i2.call(this), null != (r2 = t2.siteApps) && r2.length) if (this.isEnabled) {
29330
29330
  var n2 = function(t3) {
29331
29331
  var e3;
29332
- h["__$$ph_site_app_" + t3] = s2._instance, null == (e3 = h.__PosthogExtensions__) || null == e3.loadSiteApp || e3.loadSiteApp(s2._instance, a2, ((e4) => {
29332
+ h4["__$$ph_site_app_" + t3] = s2._instance, null == (e3 = h4.__PosthogExtensions__) || null == e3.loadSiteApp || e3.loadSiteApp(s2._instance, a2, ((e4) => {
29333
29333
  if (e4) return ia.error(ra + t3, e4);
29334
29334
  }));
29335
29335
  };
@@ -29341,7 +29341,7 @@ var init_module = __esm({
29341
29341
  constructor(t2) {
29342
29342
  this.No = void 0, this.$o = void 0, this.so = () => {
29343
29343
  var t3, e2, i2 = this.Do() || [];
29344
- N(this.No) && (null == (t3 = h.__PosthogExtensions__) || null == (t3 = t3.tracingHeadersPatchFns) || t3._patchXHR(i2, this._instance.get_distinct_id(), this._instance.sessionManager)), N(this.$o) && (null == (e2 = h.__PosthogExtensions__) || null == (e2 = e2.tracingHeadersPatchFns) || e2._patchFetch(i2, this._instance.get_distinct_id(), this._instance.sessionManager));
29344
+ N(this.No) && (null == (t3 = h4.__PosthogExtensions__) || null == (t3 = t3.tracingHeadersPatchFns) || t3._patchXHR(i2, this._instance.get_distinct_id(), this._instance.sessionManager)), N(this.$o) && (null == (e2 = h4.__PosthogExtensions__) || null == (e2 = e2.tracingHeadersPatchFns) || e2._patchFetch(i2, this._instance.get_distinct_id(), this._instance.sessionManager));
29345
29345
  }, this._instance = t2;
29346
29346
  }
29347
29347
  initialize() {
@@ -29349,7 +29349,7 @@ var init_module = __esm({
29349
29349
  }
29350
29350
  lr(t2) {
29351
29351
  var e2, i2;
29352
- null != (e2 = h.__PosthogExtensions__) && e2.tracingHeadersPatchFns && t2(), null == (i2 = h.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, "tracing-headers", ((e3) => {
29352
+ null != (e2 = h4.__PosthogExtensions__) && e2.tracingHeadersPatchFns && t2(), null == (i2 = h4.__PosthogExtensions__) || null == i2.loadExternalDependency || i2.loadExternalDependency(this._instance, "tracing-headers", ((e3) => {
29353
29353
  if (e3) return Ho.error("failed to load script", e3);
29354
29354
  t2();
29355
29355
  }));
@@ -29394,7 +29394,7 @@ var init_module = __esm({
29394
29394
  else if (this.qt.disable_surveys) Cn.info(ua);
29395
29395
  else if (this.qt.cookieless_mode && this._instance.consent.isOptedOut()) Cn.info("Not loading surveys in cookieless mode without consent.");
29396
29396
  else {
29397
- var t2 = null == h ? void 0 : h.__PosthogExtensions__;
29397
+ var t2 = null == h4 ? void 0 : h4.__PosthogExtensions__;
29398
29398
  if (t2) {
29399
29399
  if (!N(this.qo) || this.qt.advanced_enable_surveys) {
29400
29400
  var e2 = this.qo || this.qt.advanced_enable_surveys;
@@ -29456,8 +29456,8 @@ var init_module = __esm({
29456
29456
  return !(null == (e4 = t4.conditions) || null == (e4 = e4.actions) || null == (e4 = e4.values) || !e4.length);
29457
29457
  })(t3))));
29458
29458
  u2.length > 0 && (null == (a2 = this._surveyEventReceiver) || a2.register(u2)), null == (r3 = this._instance.persistence) || r3.register({ [mi]: l2 });
29459
- var h2 = { isLoaded: true };
29460
- t2(l2, h2), null == i2 || i2({ surveys: l2, context: h2 });
29459
+ var h5 = { isLoaded: true };
29460
+ t2(l2, h5), null == i2 || i2({ surveys: l2, context: h5 });
29461
29461
  } }));
29462
29462
  }
29463
29463
  Vo(t2) {
@@ -29544,11 +29544,11 @@ var init_module = __esm({
29544
29544
  this.instance = t2;
29545
29545
  }
29546
29546
  Go(t2) {
29547
- h.ph_toolbar_state = t2;
29547
+ h4.ph_toolbar_state = t2;
29548
29548
  }
29549
29549
  Qo() {
29550
29550
  var t2;
29551
- return null !== (t2 = h.ph_toolbar_state) && void 0 !== t2 ? t2 : 0;
29551
+ return null !== (t2 = h4.ph_toolbar_state) && void 0 !== t2 ? t2 : 0;
29552
29552
  }
29553
29553
  initialize() {
29554
29554
  return this.maybeLoadToolbar();
@@ -29573,7 +29573,7 @@ var init_module = __esm({
29573
29573
  }
29574
29574
  }
29575
29575
  Jo(t2) {
29576
- var e2 = h.ph_load_toolbar || h.ph_load_editor;
29576
+ var e2 = h4.ph_load_toolbar || h4.ph_load_editor;
29577
29577
  !H(e2) && D(e2) ? e2(t2, this.instance) : va.warn("No toolbar load function found");
29578
29578
  }
29579
29579
  loadToolbar(e2) {
@@ -29583,7 +29583,7 @@ var init_module = __esm({
29583
29583
  if (t.localStorage.setItem(da, JSON.stringify(f({}, n2, { source: void 0 }))), 2 === this.Qo()) this.Jo(n2);
29584
29584
  else if (0 === this.Qo()) {
29585
29585
  var o2;
29586
- this.Go(1), null == (o2 = h.__PosthogExtensions__) || null == o2.loadExternalDependency || o2.loadExternalDependency(this.instance, "toolbar", ((t2) => {
29586
+ this.Go(1), null == (o2 = h4.__PosthogExtensions__) || null == o2.loadExternalDependency || o2.loadExternalDependency(this.instance, "toolbar", ((t2) => {
29587
29587
  if (t2) return va.error("[Toolbar] Failed to load", t2), void this.Go(0);
29588
29588
  this.Go(2), this.Jo(n2);
29589
29589
  })), sr(t, "turbolinks:load", (() => {
@@ -29619,7 +29619,7 @@ var init_module = __esm({
29619
29619
  }
29620
29620
  loadIfEnabled() {
29621
29621
  if (!(this._conversationsManager || this.Xo || this._instance.config.disable_conversations || nr(this._instance.config) || this._instance.config.cookieless_mode && this._instance.consent.isOptedOut())) {
29622
- var t2 = null == h ? void 0 : h.__PosthogExtensions__;
29622
+ var t2 = null == h4 ? void 0 : h4.__PosthogExtensions__;
29623
29623
  if (t2 && !N(this.Yo) && this.Yo) if (this.ea && this.ea.token) {
29624
29624
  this.Xo = true;
29625
29625
  try {
@@ -29736,7 +29736,7 @@ var init_module = __esm({
29736
29736
  }
29737
29737
  loadIfEnabled() {
29738
29738
  if (this.ia && !this.na) {
29739
- var t2 = null == h ? void 0 : h.__PosthogExtensions__;
29739
+ var t2 = null == h4 ? void 0 : h4.__PosthogExtensions__;
29740
29740
  if (t2) {
29741
29741
  var e2 = t2.loadExternalDependency;
29742
29742
  e2 ? e2(this._instance, "logs", ((e3) => {
@@ -29752,13 +29752,13 @@ var init_module = __esm({
29752
29752
  var a2 = null !== (e2 = null == (i2 = this._instance.config.logs) ? void 0 : i2.flushIntervalMs) && void 0 !== e2 ? e2 : 3e3, l2 = null !== (r2 = null == (s2 = this._instance.config.logs) ? void 0 : s2.maxLogsPerInterval) && void 0 !== r2 ? r2 : 1e3, u2 = Date.now();
29753
29753
  if (a2 > u2 - this.aa || (this.aa = u2, this.oa = 0, this.ua = false), l2 > this.oa) {
29754
29754
  this.oa++;
29755
- var h2 = (function(t3, e3) {
29755
+ var h5 = (function(t3, e3) {
29756
29756
  var i3 = t3.level || "info", { text: r3, number: s3 } = ie[i3] || re, n3 = String(Date.now()) + "000000", o3 = {};
29757
29757
  e3.distinctId && (o3.posthogDistinctId = e3.distinctId), e3.sessionId && (o3.sessionId = e3.sessionId), e3.currentUrl && (o3["url.full"] = e3.currentUrl), e3.screenName && (o3["screen.name"] = e3.screenName), e3.appState && (o3["app.state"] = e3.appState), e3.activeFeatureFlags && e3.activeFeatureFlags.length > 0 && (o3.feature_flags = e3.activeFeatureFlags);
29758
29758
  var a3 = f({}, o3, t3.attributes || {}), l3 = { timeUnixNano: n3, observedTimeUnixNano: n3, severityNumber: s3, severityText: r3, body: { stringValue: t3.body }, attributes: ne(a3) };
29759
29759
  return t3.trace_id && (l3.traceId = t3.trace_id), t3.span_id && (l3.spanId = t3.span_id), N(t3.trace_flags) || (l3.flags = t3.trace_flags), l3;
29760
29760
  })(t2, this.la());
29761
- this.sa.push({ record: h2 }), (null !== (n2 = null == (o2 = this._instance.config.logs) ? void 0 : o2.maxBufferSize) && void 0 !== n2 ? n2 : 100) > this.sa.length ? this.ha() : this.flushLogs();
29761
+ this.sa.push({ record: h5 }), (null !== (n2 = null == (o2 = this._instance.config.logs) ? void 0 : o2.maxBufferSize) && void 0 !== n2 ? n2 : 100) > this.sa.length ? this.ha() : this.flushLogs();
29762
29762
  } else this.ua || (this.Gt.warn("captureLog dropping logs: exceeded " + l2 + " logs per " + a2 + "ms"), this.ua = true);
29763
29763
  } else this.Gt.warn("captureLog requires a body");
29764
29764
  }
@@ -29787,7 +29787,7 @@ var init_module = __esm({
29787
29787
  var { sessionId: i2 } = this._instance.sessionManager.checkAndGetSessionAndWindowId(true);
29788
29788
  e2.sessionId = i2;
29789
29789
  }
29790
- if (null != h && null != (t2 = h.location) && t2.href && (e2.currentUrl = h.location.href), this._instance.featureFlags) {
29790
+ if (null != h4 && null != (t2 = h4.location) && t2.href && (e2.currentUrl = h4.location.href), this._instance.featureFlags) {
29791
29791
  var r2 = this._instance.featureFlags.getFlags();
29792
29792
  r2 && r2.length > 0 && (e2.activeFeatureFlags = r2);
29793
29793
  }
@@ -32609,239 +32609,1889 @@ var CommandSeparator = React11__namespace.forwardRef(
32609
32609
  );
32610
32610
  CommandSeparator.displayName = "CommandSeparator";
32611
32611
 
32612
- // ../content-protection/dist/index.js
32613
- function createContentProtection(props = {}) {
32614
- const {
32615
- enabled = true,
32616
- disableCopy = true,
32617
- disableContextMenu = true,
32618
- watermarkText
32619
- } = props;
32620
- const eventHandlers = {};
32621
- if (enabled) {
32622
- if (disableCopy) {
32623
- const prevent = (e2) => e2.preventDefault();
32624
- eventHandlers.onCopy = prevent;
32625
- eventHandlers.onCut = prevent;
32626
- eventHandlers.onSelectStart = prevent;
32627
- }
32628
- if (disableContextMenu) {
32629
- eventHandlers.onContextMenu = (e2) => e2.preventDefault();
32630
- }
32631
- }
32632
- const watermarkConfig = watermarkText ? { text: watermarkText, opacity: 0.08, angle: -45 } : null;
32633
- const dataAttributes = {};
32634
- if (enabled) {
32635
- dataAttributes["data-protected"] = "true";
32636
- }
32637
- return {
32638
- eventHandlers,
32639
- watermarkConfig,
32640
- dataAttributes
32641
- };
32642
- }
32643
- var contentProtectionVariants = cva({
32644
- base: "relative select-none"
32645
- });
32646
- var watermarkVariants = cva({
32647
- base: "pointer-events-none absolute inset-0 z-50 overflow-hidden"
32648
- });
32649
- var ContentProtection = React11__namespace.forwardRef(
32650
- ({
32651
- enabled,
32652
- disableCopy,
32653
- disableContextMenu,
32654
- watermarkText,
32655
- className,
32656
- children,
32657
- ...props
32658
- }, ref) => {
32659
- const api = createContentProtection({
32660
- enabled,
32661
- disableCopy,
32662
- disableContextMenu,
32663
- watermarkText
32664
- });
32665
- const classes = cn(contentProtectionVariants(), className);
32666
- return /* @__PURE__ */ jsxRuntime.jsxs(
32667
- "div",
32668
- {
32669
- ref,
32670
- className: classes,
32671
- ...api.dataAttributes,
32672
- onCopy: api.eventHandlers.onCopy,
32673
- onCut: api.eventHandlers.onCut,
32674
- onContextMenu: api.eventHandlers.onContextMenu,
32675
- onSelect: api.eventHandlers.onSelectStart,
32676
- ...props,
32677
- children: [
32678
- children,
32679
- api.watermarkConfig && /* @__PURE__ */ jsxRuntime.jsx(
32680
- "div",
32681
- {
32682
- className: watermarkVariants(),
32683
- "aria-hidden": "true",
32684
- style: {
32685
- opacity: api.watermarkConfig.opacity,
32686
- transform: `rotate(${api.watermarkConfig.angle}deg)`,
32687
- backgroundImage: `repeating-linear-gradient(
32688
- ${api.watermarkConfig.angle}deg,
32689
- transparent,
32690
- transparent 80px,
32691
- currentColor 80px,
32692
- currentColor 80px
32693
- )`
32694
- },
32695
- children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "100%", height: "100%", children: [
32696
- /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx(
32697
- "pattern",
32698
- {
32699
- id: "rfr-watermark",
32700
- x: "0",
32701
- y: "0",
32702
- width: "200",
32703
- height: "200",
32704
- patternUnits: "userSpaceOnUse",
32705
- patternTransform: `rotate(${api.watermarkConfig.angle})`,
32706
- children: /* @__PURE__ */ jsxRuntime.jsx(
32707
- "text",
32708
- {
32709
- x: "0",
32710
- y: "100",
32711
- fill: "currentColor",
32712
- fontSize: "16",
32713
- fontFamily: "sans-serif",
32714
- children: api.watermarkConfig.text
32715
- }
32716
- )
32717
- }
32718
- ) }),
32719
- /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "100%", height: "100%", fill: "url(#rfr-watermark)" })
32720
- ] })
32721
- }
32722
- )
32723
- ]
32724
- }
32725
- );
32726
- }
32727
- );
32728
- ContentProtection.displayName = "ContentProtection";
32729
-
32730
- // ../data-table/dist/index.js
32731
- function createDataTable(props) {
32732
- const {
32733
- columns,
32734
- data,
32735
- sortBy: initialSortBy,
32736
- sortDir: initialSortDir = "asc",
32737
- onSort,
32738
- filters: initialFilters
32739
- } = props;
32740
- let sortBy = initialSortBy ?? null;
32741
- let sortDir = initialSortDir;
32742
- let filters = { ...initialFilters ?? {} };
32743
- function getFilteredData() {
32744
- let result = [...data];
32745
- for (const [columnId, filterValue] of Object.entries(filters)) {
32746
- if (!filterValue) continue;
32747
- const col = columns.find((c2) => c2.id === columnId);
32748
- if (!col) continue;
32749
- const lowerFilter = filterValue.toLowerCase();
32750
- result = result.filter((row) => {
32751
- const cellValue = col.accessor(row);
32752
- return String(cellValue ?? "").toLowerCase().includes(lowerFilter);
32753
- });
32754
- }
32755
- return result;
32612
+ // ../conversation/dist/index.js
32613
+ function byTime(a2, b2) {
32614
+ return a2.timestamp.getTime() - b2.timestamp.getTime();
32615
+ }
32616
+ function findMessage(messages, id) {
32617
+ return messages.find((m2) => m2.id === id);
32618
+ }
32619
+ function rootIdOf(messages, id) {
32620
+ const m2 = findMessage(messages, id);
32621
+ if (!m2) return id;
32622
+ return m2.parentId ?? m2.id;
32623
+ }
32624
+ function selectRoots(messages) {
32625
+ return messages.filter((m2) => !m2.parentId).sort(byTime);
32626
+ }
32627
+ function selectReplies(messages, rootId) {
32628
+ return messages.filter((m2) => m2.parentId === rootId).sort(byTime);
32629
+ }
32630
+ function selectThreadMessages(messages, rootId) {
32631
+ const root = findMessage(messages, rootId);
32632
+ const replies = selectReplies(messages, rootId);
32633
+ return root ? [root, ...replies] : replies;
32634
+ }
32635
+ function getReplyCount(messages, rootId) {
32636
+ return messages.reduce((n2, m2) => m2.parentId === rootId ? n2 + 1 : n2, 0);
32637
+ }
32638
+ function selectMainTimeline(messages, mode) {
32639
+ if (mode === "panel") return selectRoots(messages);
32640
+ return [...messages].sort(byTime);
32641
+ }
32642
+ function selectTimelineFromState(state) {
32643
+ return selectMainTimeline(state.messages, state.threadingMode);
32644
+ }
32645
+ var DEFAULT_ASSISTANT = { id: "assistant", name: "Assistant" };
32646
+ var DEFAULT_USER = { id: "user", name: "You" };
32647
+ var DEFAULT_TITLE = "New conversation";
32648
+ function defaultGenerateTitle(firstMessage) {
32649
+ const firstLine = firstMessage.split("\n", 1)[0].trim();
32650
+ if (firstLine.length <= 48) return firstLine || DEFAULT_TITLE;
32651
+ return `${firstLine.slice(0, 47).trimEnd()}\u2026`;
32652
+ }
32653
+ function createConversation(config = {}) {
32654
+ const assistant = config.assistant ?? DEFAULT_ASSISTANT;
32655
+ const currentUser = config.currentUser ?? DEFAULT_USER;
32656
+ const generateTitle = config.generateTitle ?? defaultGenerateTitle;
32657
+ let transport = config.transport;
32658
+ let threadingMode = config.threadingMode ?? "inline";
32659
+ const conversations = /* @__PURE__ */ new Map();
32660
+ const messagesByConv = /* @__PURE__ */ new Map();
32661
+ let activeConversationId = config.activeConversationId ?? null;
32662
+ let openThreadRootId = null;
32663
+ let replyTarget = null;
32664
+ let status = "idle";
32665
+ let error = null;
32666
+ let abortController = null;
32667
+ for (const c2 of config.conversations ?? []) {
32668
+ conversations.set(c2.id, c2);
32669
+ messagesByConv.set(c2.id, []);
32670
+ }
32671
+ for (const [conversationId, msgs] of Object.entries(config.messages ?? {})) {
32672
+ messagesByConv.set(conversationId, [...msgs]);
32673
+ }
32674
+ if (activeConversationId === null && config.conversations?.length) {
32675
+ activeConversationId = config.conversations[0].id;
32756
32676
  }
32757
- function getSortedData() {
32758
- const filtered = getFilteredData();
32759
- if (!sortBy) return filtered;
32760
- const col = columns.find((c2) => c2.id === sortBy);
32761
- if (!col) return filtered;
32762
- return [...filtered].sort((a2, b2) => {
32763
- const aVal = col.accessor(a2);
32764
- const bVal = col.accessor(b2);
32765
- const aStr = String(aVal ?? "");
32766
- const bStr = String(bVal ?? "");
32767
- const cmp = aStr.localeCompare(bStr, void 0, { numeric: true });
32768
- return sortDir === "asc" ? cmp : -cmp;
32769
- });
32677
+ const listeners = /* @__PURE__ */ new Set();
32678
+ let snapshot = buildSnapshot();
32679
+ function buildSnapshot() {
32680
+ return {
32681
+ conversations: orderedConversations(),
32682
+ activeConversationId,
32683
+ messages: activeConversationId ? messagesByConv.get(activeConversationId) ?? [] : [],
32684
+ openThreadRootId,
32685
+ replyTarget,
32686
+ threadingMode,
32687
+ status,
32688
+ error
32689
+ };
32770
32690
  }
32771
- function sort(columnId) {
32772
- const col = columns.find((c2) => c2.id === columnId);
32773
- if (!col?.sortable) return;
32774
- if (sortBy === columnId) {
32775
- sortDir = sortDir === "asc" ? "desc" : "asc";
32776
- } else {
32777
- sortBy = columnId;
32778
- sortDir = "asc";
32779
- }
32780
- onSort?.(sortBy, sortDir);
32691
+ function emit2() {
32692
+ snapshot = buildSnapshot();
32693
+ for (const l2 of listeners) l2();
32781
32694
  }
32782
- function setFilter(columnId, value) {
32783
- filters = { ...filters, [columnId]: value };
32695
+ function orderedConversations() {
32696
+ return [...conversations.values()].sort(
32697
+ (a2, b2) => b2.updatedAt.getTime() - a2.updatedAt.getTime()
32698
+ );
32784
32699
  }
32785
- function getHeaderProps(col) {
32786
- const props2 = {
32787
- role: "columnheader"
32700
+ function touch(conversationId) {
32701
+ const c2 = conversations.get(conversationId);
32702
+ if (c2) conversations.set(conversationId, { ...c2, updatedAt: /* @__PURE__ */ new Date() });
32703
+ }
32704
+ function ensureActiveConversation(opts) {
32705
+ if (opts?.conversationId) {
32706
+ if (!conversations.has(opts.conversationId)) createConversationInternal({}, opts.conversationId);
32707
+ return opts.conversationId;
32708
+ }
32709
+ if (activeConversationId && conversations.has(activeConversationId)) return activeConversationId;
32710
+ return createConversationInternal({}).id;
32711
+ }
32712
+ function createConversationInternal(opts, id) {
32713
+ const now = /* @__PURE__ */ new Date();
32714
+ const conversation = {
32715
+ id: id ?? generateId("rfr-conv"),
32716
+ title: opts.title ?? DEFAULT_TITLE,
32717
+ createdAt: now,
32718
+ updatedAt: now,
32719
+ metadata: opts.metadata
32788
32720
  };
32789
- if (col.sortable) {
32790
- if (sortBy === col.id) {
32791
- props2["aria-sort"] = sortDir === "asc" ? "ascending" : "descending";
32721
+ conversations.set(conversation.id, conversation);
32722
+ messagesByConv.set(conversation.id, []);
32723
+ activeConversationId = conversation.id;
32724
+ return conversation;
32725
+ }
32726
+ async function streamReply(conversationId, assistantMsg, userMsg, history) {
32727
+ abortController = new AbortController();
32728
+ status = "streaming";
32729
+ emit2();
32730
+ try {
32731
+ const stream = transport.send({
32732
+ conversationId,
32733
+ message: userMsg,
32734
+ history,
32735
+ parentId: assistantMsg.parentId,
32736
+ signal: abortController.signal
32737
+ });
32738
+ for await (const chunk of stream) {
32739
+ if (chunk.content !== void 0) assistantMsg.content = chunk.content;
32740
+ if (chunk.delta) assistantMsg.content += chunk.delta;
32741
+ if (chunk.metadata) {
32742
+ assistantMsg.metadata = { ...assistantMsg.metadata, ...chunk.metadata };
32743
+ }
32744
+ emit2();
32745
+ if (abortController.signal.aborted) break;
32746
+ }
32747
+ assistantMsg.status = "sent";
32748
+ status = "idle";
32749
+ error = null;
32750
+ } catch (err) {
32751
+ if (abortController.signal.aborted) {
32752
+ assistantMsg.status = "sent";
32753
+ status = "idle";
32792
32754
  } else {
32793
- props2["aria-sort"] = "none";
32755
+ const message = err instanceof Error ? err.message : String(err);
32756
+ assistantMsg.status = "error";
32757
+ assistantMsg.error = message;
32758
+ status = "error";
32759
+ error = message;
32794
32760
  }
32761
+ } finally {
32762
+ abortController = null;
32763
+ touch(conversationId);
32764
+ emit2();
32795
32765
  }
32796
- return props2;
32797
32766
  }
32798
- function getCellProps(col, _row) {
32799
- return {
32800
- role: "cell",
32801
- "data-column": col.id
32802
- };
32803
- }
32804
- function getRowProps(_row, index) {
32805
- return {
32806
- role: "row",
32807
- "data-row-index": index
32808
- };
32767
+ function historyFor(list, parentId) {
32768
+ const scope = parentId ? selectThreadMessages(list, parentId) : selectRoots(list);
32769
+ return scope.filter((m2) => m2.status !== "error");
32809
32770
  }
32810
- return {
32811
- get state() {
32812
- return {
32813
- get sortedData() {
32814
- return getSortedData();
32815
- },
32816
- get sortBy() {
32817
- return sortBy;
32818
- },
32819
- get sortDir() {
32820
- return sortDir;
32821
- },
32822
- get filters() {
32823
- return { ...filters };
32824
- }
32771
+ const api = {
32772
+ getState() {
32773
+ return snapshot;
32774
+ },
32775
+ subscribe(listener) {
32776
+ listeners.add(listener);
32777
+ return () => listeners.delete(listener);
32778
+ },
32779
+ newConversation(opts) {
32780
+ const conversation = createConversationInternal(opts ?? {});
32781
+ openThreadRootId = null;
32782
+ replyTarget = null;
32783
+ emit2();
32784
+ return conversation;
32785
+ },
32786
+ selectConversation(conversationId) {
32787
+ if (!conversations.has(conversationId) || activeConversationId === conversationId) return;
32788
+ activeConversationId = conversationId;
32789
+ openThreadRootId = null;
32790
+ replyTarget = null;
32791
+ emit2();
32792
+ },
32793
+ deleteConversation(conversationId) {
32794
+ if (!conversations.has(conversationId)) return;
32795
+ conversations.delete(conversationId);
32796
+ messagesByConv.delete(conversationId);
32797
+ if (activeConversationId === conversationId) {
32798
+ activeConversationId = orderedConversations()[0]?.id ?? null;
32799
+ openThreadRootId = null;
32800
+ replyTarget = null;
32801
+ }
32802
+ emit2();
32803
+ },
32804
+ renameConversation(conversationId, title) {
32805
+ const c2 = conversations.get(conversationId);
32806
+ if (!c2) return;
32807
+ conversations.set(conversationId, { ...c2, title });
32808
+ emit2();
32809
+ },
32810
+ appendMessage(message) {
32811
+ const list = messagesByConv.get(message.conversationId);
32812
+ if (!list) return;
32813
+ list.push(message);
32814
+ touch(message.conversationId);
32815
+ emit2();
32816
+ },
32817
+ editMessage(messageId, content) {
32818
+ if (!activeConversationId) return;
32819
+ const list = messagesByConv.get(activeConversationId);
32820
+ const msg = list.find((m2) => m2.id === messageId);
32821
+ if (!msg) return;
32822
+ msg.content = content;
32823
+ msg.edited = true;
32824
+ emit2();
32825
+ },
32826
+ deleteMessage(messageId) {
32827
+ if (!activeConversationId) return;
32828
+ const list = messagesByConv.get(activeConversationId);
32829
+ const msg = list.find((m2) => m2.id === messageId);
32830
+ if (!msg) return;
32831
+ const removeIds = /* @__PURE__ */ new Set([messageId]);
32832
+ if (!msg.parentId) {
32833
+ for (const r2 of list) if (r2.parentId === messageId) removeIds.add(r2.id);
32834
+ }
32835
+ const next = list.filter((m2) => !removeIds.has(m2.id));
32836
+ messagesByConv.set(activeConversationId, next);
32837
+ if (openThreadRootId && removeIds.has(openThreadRootId)) openThreadRootId = null;
32838
+ if (replyTarget && removeIds.has(replyTarget)) replyTarget = openThreadRootId;
32839
+ emit2();
32840
+ },
32841
+ react(messageId, emoji) {
32842
+ if (!activeConversationId) return;
32843
+ const list = messagesByConv.get(activeConversationId);
32844
+ const msg = list.find((m2) => m2.id === messageId);
32845
+ if (!msg) return;
32846
+ const reactions = [...msg.reactions ?? []];
32847
+ const idx = reactions.findIndex((r2) => r2.emoji === emoji);
32848
+ if (idx === -1) {
32849
+ reactions.push({ emoji, count: 1, userReacted: true });
32850
+ } else {
32851
+ const r2 = reactions[idx];
32852
+ if (r2.userReacted) {
32853
+ const count = r2.count - 1;
32854
+ if (count <= 0) reactions.splice(idx, 1);
32855
+ else reactions[idx] = { ...r2, count, userReacted: false };
32856
+ } else {
32857
+ reactions[idx] = { ...r2, count: r2.count + 1, userReacted: true };
32858
+ }
32859
+ }
32860
+ msg.reactions = reactions;
32861
+ emit2();
32862
+ },
32863
+ async sendMessage(content, opts) {
32864
+ const trimmed = content.trim();
32865
+ if (!trimmed && !opts?.attachments?.length) return;
32866
+ const conversationId = ensureActiveConversation(opts);
32867
+ const list = messagesByConv.get(conversationId);
32868
+ const parentId = opts?.replyTo ? rootIdOf(list, opts.replyTo) : void 0;
32869
+ const replyToId = opts?.replyTo;
32870
+ const isFirstRoot = !parentId && selectRoots(list).length === 0;
32871
+ const userMsg = {
32872
+ id: generateId("rfr-msg"),
32873
+ conversationId,
32874
+ role: "user",
32875
+ author: currentUser,
32876
+ content: trimmed,
32877
+ timestamp: /* @__PURE__ */ new Date(),
32878
+ status: "sent",
32879
+ parentId,
32880
+ replyToId,
32881
+ attachments: opts?.attachments,
32882
+ metadata: opts?.metadata
32883
+ };
32884
+ list.push(userMsg);
32885
+ const conversation = conversations.get(conversationId);
32886
+ if (isFirstRoot && conversation.title === DEFAULT_TITLE) {
32887
+ conversations.set(conversationId, { ...conversation, title: generateTitle(trimmed) });
32888
+ }
32889
+ touch(conversationId);
32890
+ if (!transport) {
32891
+ status = "idle";
32892
+ emit2();
32893
+ return;
32894
+ }
32895
+ const history = historyFor(list, parentId).filter((m2) => m2.id !== userMsg.id);
32896
+ const assistantMsg = {
32897
+ id: generateId("rfr-msg"),
32898
+ conversationId,
32899
+ role: "assistant",
32900
+ author: assistant,
32901
+ content: "",
32902
+ timestamp: /* @__PURE__ */ new Date(),
32903
+ status: "streaming",
32904
+ parentId
32825
32905
  };
32906
+ list.push(assistantMsg);
32907
+ await streamReply(conversationId, assistantMsg, userMsg, history);
32908
+ },
32909
+ async retryLast() {
32910
+ if (!activeConversationId || !transport) return;
32911
+ const list = messagesByConv.get(activeConversationId);
32912
+ const last = list[list.length - 1];
32913
+ const parentId = last?.parentId;
32914
+ if (last && last.role === "assistant" && last.status === "error") list.pop();
32915
+ const scope = parentId ? selectThreadMessages(list, parentId) : selectRoots(list);
32916
+ const lastUser = [...scope].reverse().find((m2) => m2.role === "user");
32917
+ if (!lastUser) return;
32918
+ const history = historyFor(list, parentId);
32919
+ const assistantMsg = {
32920
+ id: generateId("rfr-msg"),
32921
+ conversationId: activeConversationId,
32922
+ role: "assistant",
32923
+ author: assistant,
32924
+ content: "",
32925
+ timestamp: /* @__PURE__ */ new Date(),
32926
+ status: "streaming",
32927
+ parentId
32928
+ };
32929
+ list.push(assistantMsg);
32930
+ await streamReply(activeConversationId, assistantMsg, lastUser, history);
32826
32931
  },
32827
- sort,
32828
- setFilter,
32829
- getHeaderProps,
32830
- getCellProps,
32831
- getRowProps
32932
+ stop() {
32933
+ abortController?.abort();
32934
+ },
32935
+ openThread(rootId) {
32936
+ openThreadRootId = rootId;
32937
+ replyTarget = rootId;
32938
+ emit2();
32939
+ },
32940
+ replyTo(messageId) {
32941
+ if (!activeConversationId) return;
32942
+ const list = messagesByConv.get(activeConversationId);
32943
+ openThreadRootId = rootIdOf(list, messageId);
32944
+ replyTarget = messageId;
32945
+ emit2();
32946
+ },
32947
+ closeThread() {
32948
+ if (openThreadRootId === null && replyTarget === null) return;
32949
+ openThreadRootId = null;
32950
+ replyTarget = null;
32951
+ emit2();
32952
+ },
32953
+ setThreadingMode(mode) {
32954
+ if (threadingMode === mode) return;
32955
+ threadingMode = mode;
32956
+ emit2();
32957
+ },
32958
+ setTransport(next) {
32959
+ transport = next;
32960
+ }
32832
32961
  };
32962
+ return api;
32833
32963
  }
32834
- var tableVariants = cva({
32835
- base: "w-full caption-bottom text-sm border-collapse",
32836
- variants: {
32837
- size: {
32838
- sm: "text-xs",
32839
- md: "text-sm",
32840
- lg: "text-base"
32964
+
32965
+ // ../markdown-renderer/dist/index.js
32966
+ function escapeHtml(text) {
32967
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
32968
+ }
32969
+ function parseInline(text, linkResolver) {
32970
+ let result = escapeHtml(text);
32971
+ result = result.replace(/`([^`]+)`/g, "<code>$1</code>");
32972
+ result = result.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
32973
+ result = result.replace(/__([^_]+)__/g, "<strong>$1</strong>");
32974
+ result = result.replace(/\*([^*]+)\*/g, "<em>$1</em>");
32975
+ result = result.replace(/_([^_]+)_/g, "<em>$1</em>");
32976
+ result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, text2, url) => {
32977
+ if (/^\s*javascript\s*:/i.test(url)) {
32978
+ return text2;
32841
32979
  }
32842
- },
32843
- defaultVariants: {
32844
- size: "md"
32980
+ const resolvedUrl = linkResolver ? linkResolver(url) : url;
32981
+ return `<a href="${resolvedUrl}">${text2}</a>`;
32982
+ });
32983
+ return result;
32984
+ }
32985
+ function parseMarkdown(content, linkResolver) {
32986
+ const lines = content.split("\n");
32987
+ const outputLines = [];
32988
+ let inCodeBlock = false;
32989
+ let codeBlockContent = [];
32990
+ let codeBlockLang = "";
32991
+ let inList = null;
32992
+ let inBlockquote = false;
32993
+ function closeList() {
32994
+ if (inList) {
32995
+ outputLines.push(inList === "ul" ? "</ul>" : "</ol>");
32996
+ inList = null;
32997
+ }
32998
+ }
32999
+ function closeBlockquote() {
33000
+ if (inBlockquote) {
33001
+ outputLines.push("</blockquote>");
33002
+ inBlockquote = false;
33003
+ }
33004
+ }
33005
+ for (let i2 = 0; i2 < lines.length; i2++) {
33006
+ const line = lines[i2];
33007
+ if (line.trimStart().startsWith("```")) {
33008
+ if (inCodeBlock) {
33009
+ outputLines.push(`<pre><code${codeBlockLang ? ` class="language-${escapeHtml(codeBlockLang)}"` : ""}>${escapeHtml(codeBlockContent.join("\n"))}</code></pre>`);
33010
+ codeBlockContent = [];
33011
+ codeBlockLang = "";
33012
+ inCodeBlock = false;
33013
+ } else {
33014
+ closeList();
33015
+ closeBlockquote();
33016
+ inCodeBlock = true;
33017
+ codeBlockLang = line.trimStart().slice(3).trim();
33018
+ }
33019
+ continue;
33020
+ }
33021
+ if (inCodeBlock) {
33022
+ codeBlockContent.push(line);
33023
+ continue;
33024
+ }
33025
+ if (/^(\s*[-*_]\s*){3,}$/.test(line)) {
33026
+ closeList();
33027
+ closeBlockquote();
33028
+ outputLines.push("<hr />");
33029
+ continue;
33030
+ }
33031
+ const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
33032
+ if (headingMatch) {
33033
+ closeList();
33034
+ closeBlockquote();
33035
+ const level = headingMatch[1].length;
33036
+ const text = parseInline(headingMatch[2], linkResolver);
33037
+ outputLines.push(`<h${level}>${text}</h${level}>`);
33038
+ continue;
33039
+ }
33040
+ const blockquoteMatch = line.match(/^>\s?(.*)$/);
33041
+ if (blockquoteMatch) {
33042
+ closeList();
33043
+ if (!inBlockquote) {
33044
+ inBlockquote = true;
33045
+ outputLines.push("<blockquote>");
33046
+ }
33047
+ const text = blockquoteMatch[1].trim();
33048
+ if (text) {
33049
+ outputLines.push(`<p>${parseInline(text, linkResolver)}</p>`);
33050
+ }
33051
+ continue;
33052
+ } else if (inBlockquote) {
33053
+ closeBlockquote();
33054
+ }
33055
+ const ulMatch = line.match(/^[\s]*[-*+]\s+(.+)$/);
33056
+ if (ulMatch) {
33057
+ closeBlockquote();
33058
+ if (inList !== "ul") {
33059
+ closeList();
33060
+ inList = "ul";
33061
+ outputLines.push("<ul>");
33062
+ }
33063
+ outputLines.push(`<li>${parseInline(ulMatch[1], linkResolver)}</li>`);
33064
+ continue;
33065
+ }
33066
+ const olMatch = line.match(/^[\s]*\d+\.\s+(.+)$/);
33067
+ if (olMatch) {
33068
+ closeBlockquote();
33069
+ if (inList !== "ol") {
33070
+ closeList();
33071
+ inList = "ol";
33072
+ outputLines.push("<ol>");
33073
+ }
33074
+ outputLines.push(`<li>${parseInline(olMatch[1], linkResolver)}</li>`);
33075
+ continue;
33076
+ }
33077
+ if (inList) {
33078
+ closeList();
33079
+ }
33080
+ if (line.trim() === "") {
33081
+ continue;
33082
+ }
33083
+ outputLines.push(`<p>${parseInline(line, linkResolver)}</p>`);
33084
+ }
33085
+ if (inCodeBlock) {
33086
+ outputLines.push(`<pre><code${codeBlockLang ? ` class="language-${escapeHtml(codeBlockLang)}"` : ""}>${escapeHtml(codeBlockContent.join("\n"))}</code></pre>`);
33087
+ }
33088
+ closeList();
33089
+ closeBlockquote();
33090
+ return outputLines.join("\n");
33091
+ }
33092
+ function extractComponents(content, components) {
33093
+ if (!components) return [];
33094
+ const extracted = [];
33095
+ for (const [name, def] of Object.entries(components)) {
33096
+ const matches = Array.from(content.matchAll(def.pattern));
33097
+ matches.forEach(() => {
33098
+ extracted.push({
33099
+ name,
33100
+ props: { ...def.props }
33101
+ });
33102
+ });
33103
+ }
33104
+ return extracted;
33105
+ }
33106
+ function createMarkdownRenderer(props) {
33107
+ const { content, components, linkResolver } = props;
33108
+ const html = parseMarkdown(content, linkResolver);
33109
+ const extractedComponents = extractComponents(content, components);
33110
+ const ariaProps = {
33111
+ role: "document",
33112
+ "aria-label": "Rendered markdown content"
33113
+ };
33114
+ return {
33115
+ html,
33116
+ components: extractedComponents,
33117
+ ariaProps
33118
+ };
33119
+ }
33120
+ var markdownRendererTokens = {
33121
+ name: "markdown-renderer",
33122
+ tokens: {
33123
+ bg: { variable: "--rfr-markdown-bg", fallback: "hsl(var(--background))" },
33124
+ fg: { variable: "--rfr-markdown-fg", fallback: "hsl(var(--foreground))" },
33125
+ codeBg: { variable: "--rfr-markdown-code-bg", fallback: "hsl(var(--muted))" },
33126
+ linkColor: { variable: "--rfr-markdown-link", fallback: "hsl(var(--primary))" },
33127
+ borderColor: { variable: "--rfr-markdown-border", fallback: "hsl(var(--border))" }
33128
+ }
33129
+ };
33130
+ var proseVariants = cva({
33131
+ base: "prose max-w-none text-foreground leading-relaxed",
33132
+ variants: {
33133
+ size: {
33134
+ sm: "prose-sm text-sm",
33135
+ default: "prose-base text-base",
33136
+ lg: "prose-lg text-lg"
33137
+ },
33138
+ theme: {
33139
+ light: "bg-white text-gray-900",
33140
+ dark: "bg-gray-900 text-gray-100"
33141
+ }
33142
+ },
33143
+ defaultVariants: {
33144
+ size: "default"
33145
+ }
33146
+ });
33147
+ function sanitizeHtml(html) {
33148
+ let sanitized = html;
33149
+ sanitized = sanitized.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
33150
+ sanitized = sanitized.replace(/<\/?script[^>]*>/gi, "");
33151
+ sanitized = sanitized.replace(/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "");
33152
+ sanitized = sanitized.replace(/(href|src)\s*=\s*["']?\s*javascript\s*:[^"'>]*/gi, '$1=""');
33153
+ return sanitized;
33154
+ }
33155
+ var MarkdownRenderer = React11__namespace.forwardRef(
33156
+ ({ content, components, linkResolver, className, size }, ref) => {
33157
+ const coreProps = { content, components, linkResolver };
33158
+ const api = createMarkdownRenderer(coreProps);
33159
+ const classes = cn(proseVariants({ size }), className);
33160
+ const sanitizedHtml = sanitizeHtml(api.html);
33161
+ return /* @__PURE__ */ jsxRuntime.jsx(
33162
+ "div",
33163
+ {
33164
+ ref,
33165
+ className: classes,
33166
+ ...api.ariaProps,
33167
+ dangerouslySetInnerHTML: { __html: sanitizedHtml }
33168
+ }
33169
+ );
33170
+ }
33171
+ );
33172
+ MarkdownRenderer.displayName = "MarkdownRenderer";
33173
+
33174
+ // ../thread-view/dist/index.js
33175
+ function formatTimestamp(date) {
33176
+ const hours = date.getHours();
33177
+ const minutes = date.getMinutes();
33178
+ const ampm = hours >= 12 ? "PM" : "AM";
33179
+ const displayHours = hours % 12 || 12;
33180
+ const displayMinutes = minutes < 10 ? `0${minutes}` : `${minutes}`;
33181
+ return `${displayHours}:${displayMinutes} ${ampm}`;
33182
+ }
33183
+ function formatRelativeTime(date, now) {
33184
+ const reference = now ?? /* @__PURE__ */ new Date();
33185
+ const diffMs = reference.getTime() - date.getTime();
33186
+ const diffSeconds = Math.floor(diffMs / 1e3);
33187
+ const diffMinutes = Math.floor(diffSeconds / 60);
33188
+ const diffHours = Math.floor(diffMinutes / 60);
33189
+ const diffDays = Math.floor(diffHours / 24);
33190
+ if (diffSeconds < 60) return "just now";
33191
+ if (diffMinutes < 60) return `${diffMinutes} minute${diffMinutes === 1 ? "" : "s"} ago`;
33192
+ if (diffHours < 24) return `${diffHours} hour${diffHours === 1 ? "" : "s"} ago`;
33193
+ if (diffDays < 7) return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
33194
+ return date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
33195
+ }
33196
+ function createThreadView(props) {
33197
+ const { messages, onReply, onReact, currentUserId } = props;
33198
+ let replyingTo = null;
33199
+ const threadId = generateId("rfr-thread");
33200
+ const labelId = generateId("rfr-thread-label");
33201
+ function startReply(messageId) {
33202
+ replyingTo = messageId;
33203
+ }
33204
+ function cancelReply() {
33205
+ replyingTo = null;
33206
+ }
33207
+ function reply(messageId, content) {
33208
+ onReply?.(messageId, content);
33209
+ replyingTo = null;
33210
+ }
33211
+ function react(messageId, emoji) {
33212
+ onReact?.(messageId, emoji);
33213
+ }
33214
+ const ariaProps = {
33215
+ role: "log",
33216
+ "aria-label": "Message thread",
33217
+ "aria-live": "polite",
33218
+ id: threadId
33219
+ };
33220
+ function getMessageAriaProps(message) {
33221
+ const isOwn = currentUserId && message.author.id === currentUserId;
33222
+ return {
33223
+ role: "article",
33224
+ "aria-label": `Message from ${message.author.name}${isOwn ? " (you)" : ""} at ${formatTimestamp(message.timestamp)}`
33225
+ };
33226
+ }
33227
+ function getReplyButtonAriaProps(_messageId) {
33228
+ return {
33229
+ role: "button",
33230
+ "aria-label": `Reply to message`
33231
+ };
33232
+ }
33233
+ return {
33234
+ state: {
33235
+ messages,
33236
+ get replyingTo() {
33237
+ return replyingTo;
33238
+ }
33239
+ },
33240
+ startReply,
33241
+ cancelReply,
33242
+ reply,
33243
+ react,
33244
+ formatTimestamp,
33245
+ formatRelativeTime,
33246
+ ariaProps,
33247
+ getMessageAriaProps,
33248
+ getReplyButtonAriaProps,
33249
+ ids: {
33250
+ thread: threadId,
33251
+ label: labelId
33252
+ }
33253
+ };
33254
+ }
33255
+ var threadContainerStyles = "flex flex-col gap-1";
33256
+ var threadMessageStyles = "flex gap-3 px-4 py-2 hover:bg-accent/50 rounded-md transition-colors group";
33257
+ var threadAvatarStyles = "h-9 w-9 rounded-full bg-muted flex items-center justify-center text-sm font-medium overflow-hidden flex-shrink-0";
33258
+ var threadContentStyles = "flex-1 min-w-0";
33259
+ var threadAuthorStyles = "font-semibold text-sm";
33260
+ var threadTimestampStyles = "text-xs text-muted-foreground ml-2";
33261
+ var threadBodyStyles = "text-sm mt-0.5 whitespace-pre-wrap break-words";
33262
+ var threadReactionsStyles = "flex flex-wrap gap-1 mt-1";
33263
+ var threadReplyIndicatorStyles = "flex items-center gap-1 mt-1 text-xs text-primary cursor-pointer hover:underline";
33264
+ var threadActionsStyles = "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity";
33265
+ var threadAttachmentStyles = "flex items-center gap-2 mt-1 p-2 rounded border text-xs bg-muted/50";
33266
+ var threadEditedStyles = "text-xs text-muted-foreground ml-1";
33267
+
33268
+ // ../react-conversation/dist/index.js
33269
+ function useConversation(config) {
33270
+ const apiRef = React11__namespace.useRef(null);
33271
+ if (apiRef.current === null) {
33272
+ apiRef.current = createConversation(config);
33273
+ }
33274
+ const api = apiRef.current;
33275
+ const state = React11__namespace.useSyncExternalStore(api.subscribe, api.getState, api.getState);
33276
+ const transport = config?.transport;
33277
+ React11__namespace.useEffect(() => {
33278
+ if (transport) api.setTransport(transport);
33279
+ }, [api, transport]);
33280
+ return {
33281
+ state,
33282
+ api,
33283
+ sendMessage: api.sendMessage,
33284
+ newConversation: api.newConversation,
33285
+ selectConversation: api.selectConversation,
33286
+ deleteConversation: api.deleteConversation,
33287
+ renameConversation: api.renameConversation,
33288
+ editMessage: api.editMessage,
33289
+ deleteMessage: api.deleteMessage,
33290
+ react: api.react,
33291
+ retryLast: api.retryLast,
33292
+ stop: api.stop,
33293
+ openThread: api.openThread,
33294
+ replyTo: api.replyTo,
33295
+ closeThread: api.closeThread,
33296
+ setThreadingMode: api.setThreadingMode
33297
+ };
33298
+ }
33299
+ var h = React11__namespace.createElement;
33300
+ var EMOJI = {
33301
+ smile: "\u{1F604}",
33302
+ grin: "\u{1F601}",
33303
+ joy: "\u{1F602}",
33304
+ rofl: "\u{1F923}",
33305
+ wink: "\u{1F609}",
33306
+ heart_eyes: "\u{1F60D}",
33307
+ thinking: "\u{1F914}",
33308
+ neutral: "\u{1F610}",
33309
+ sob: "\u{1F62D}",
33310
+ scream: "\u{1F631}",
33311
+ tada: "\u{1F389}",
33312
+ fire: "\u{1F525}",
33313
+ heart: "\u2764\uFE0F",
33314
+ thumbsup: "\u{1F44D}",
33315
+ thumbsdown: "\u{1F44E}",
33316
+ clap: "\u{1F44F}",
33317
+ pray: "\u{1F64F}",
33318
+ eyes: "\u{1F440}",
33319
+ rocket: "\u{1F680}",
33320
+ sparkles: "\u2728",
33321
+ star: "\u2B50",
33322
+ check: "\u2705",
33323
+ x: "\u274C",
33324
+ warning: "\u26A0\uFE0F",
33325
+ bulb: "\u{1F4A1}",
33326
+ bug: "\u{1F41B}",
33327
+ wave: "\u{1F44B}",
33328
+ ok_hand: "\u{1F44C}",
33329
+ muscle: "\u{1F4AA}",
33330
+ "100": "\u{1F4AF}",
33331
+ poop: "\u{1F4A9}",
33332
+ ghost: "\u{1F47B}",
33333
+ robot: "\u{1F916}",
33334
+ cat: "\u{1F431}",
33335
+ dog: "\u{1F436}",
33336
+ coffee: "\u2615",
33337
+ pizza: "\u{1F355}",
33338
+ beer: "\u{1F37A}",
33339
+ sun: "\u2600\uFE0F",
33340
+ moon: "\u{1F319}",
33341
+ zap: "\u26A1"
33342
+ };
33343
+ function detectTrigger(text, caret) {
33344
+ const before = text.slice(0, caret);
33345
+ const m2 = before.match(/(?:^|\s)([/@:])([\w+-]*)$/);
33346
+ if (!m2) return null;
33347
+ const type = m2[1];
33348
+ const query = m2[2] ?? "";
33349
+ return { type, query, start: caret - query.length - 1, end: caret };
33350
+ }
33351
+ function Composer({
33352
+ placeholder = "Type a message\u2026 (/ commands, @ mentions, : emoji)",
33353
+ busy = false,
33354
+ slashCommands = [],
33355
+ mentions,
33356
+ toolbar = true,
33357
+ emoji = true,
33358
+ attachments = true,
33359
+ onSubmit,
33360
+ onStop,
33361
+ onSlashCommand,
33362
+ autoFocus
33363
+ }) {
33364
+ const [value, setValue2] = React11__namespace.useState("");
33365
+ const [pending, setPending] = React11__namespace.useState([]);
33366
+ const [trigger, setTrigger] = React11__namespace.useState(null);
33367
+ const [active, setActive] = React11__namespace.useState(0);
33368
+ const [mentionItems, setMentionItems] = React11__namespace.useState([]);
33369
+ const ref = React11__namespace.useRef(null);
33370
+ const fileRef = React11__namespace.useRef(null);
33371
+ React11__namespace.useEffect(() => {
33372
+ if (trigger?.type !== "@" || !mentions) {
33373
+ setMentionItems([]);
33374
+ return;
33375
+ }
33376
+ if (Array.isArray(mentions)) {
33377
+ const q2 = trigger.query.toLowerCase();
33378
+ setMentionItems(mentions.filter((m2) => m2.label.toLowerCase().includes(q2)).slice(0, 8));
33379
+ return;
33380
+ }
33381
+ let cancelled = false;
33382
+ Promise.resolve(mentions(trigger.query)).then((res) => {
33383
+ if (!cancelled) setMentionItems(res.slice(0, 8));
33384
+ });
33385
+ return () => {
33386
+ cancelled = true;
33387
+ };
33388
+ }, [trigger, mentions]);
33389
+ const items = React11__namespace.useMemo(() => {
33390
+ if (!trigger) return [];
33391
+ const q2 = trigger.query.toLowerCase();
33392
+ if (trigger.type === "/") {
33393
+ return slashCommands.filter((c2) => c2.label.toLowerCase().includes(q2) || c2.id.toLowerCase().includes(q2)).slice(0, 8).map((c2) => ({ key: c2.id, primary: c2.label, secondary: c2.description, icon: c2.icon, apply: c2.insertText ?? "", runCmd: c2 }));
33394
+ }
33395
+ if (trigger.type === "@") {
33396
+ return mentionItems.map((m2) => ({ key: m2.id, primary: m2.label, icon: m2.avatarUrl ? "" : "@", apply: `@${m2.label} ` }));
33397
+ }
33398
+ if (trigger.type === ":" && emoji) {
33399
+ return Object.entries(EMOJI).filter(([name]) => name.includes(q2)).slice(0, 8).map(([name, char]) => ({ key: name, primary: `${char} :${name}:`, apply: char }));
33400
+ }
33401
+ return [];
33402
+ }, [trigger, slashCommands, mentionItems, emoji]);
33403
+ const menuOpen = trigger !== null && items.length > 0;
33404
+ React11__namespace.useEffect(() => setActive(0), [trigger?.type, trigger?.query]);
33405
+ function syncFromTextarea(el) {
33406
+ setValue2(el.value);
33407
+ setTrigger(detectTrigger(el.value, el.selectionStart ?? el.value.length));
33408
+ }
33409
+ function selectItem(i2) {
33410
+ const item = items[i2];
33411
+ if (!item || !trigger) return;
33412
+ if (trigger.type === "/" && !item.apply && item.runCmd) {
33413
+ const next2 = value.slice(0, trigger.start) + value.slice(trigger.end);
33414
+ setValue2(next2);
33415
+ setTrigger(null);
33416
+ onSlashCommand?.(item.runCmd);
33417
+ queueCaret(trigger.start);
33418
+ return;
33419
+ }
33420
+ const next = value.slice(0, trigger.start) + item.apply + value.slice(trigger.end);
33421
+ setValue2(next);
33422
+ setTrigger(null);
33423
+ queueCaret(trigger.start + item.apply.length);
33424
+ }
33425
+ function queueCaret(pos) {
33426
+ requestAnimationFrame(() => {
33427
+ const el = ref.current;
33428
+ if (!el) return;
33429
+ el.focus();
33430
+ el.setSelectionRange(pos, pos);
33431
+ });
33432
+ }
33433
+ function format(kind) {
33434
+ const el = ref.current;
33435
+ if (!el) return;
33436
+ const start = el.selectionStart ?? 0;
33437
+ const end = el.selectionEnd ?? 0;
33438
+ const sel = value.slice(start, end);
33439
+ let replacement = sel;
33440
+ let caretOffset = 0;
33441
+ if (kind === "bold") replacement = `**${sel || "bold"}**`;
33442
+ else if (kind === "italic") replacement = `*${sel || "italic"}*`;
33443
+ else if (kind === "code") replacement = sel.includes("\n") ? `
33444
+ \`\`\`
33445
+ ${sel}
33446
+ \`\`\`
33447
+ ` : `\`${sel || "code"}\``;
33448
+ else if (kind === "link") {
33449
+ replacement = `[${sel || "text"}](url)`;
33450
+ caretOffset = replacement.length - 4;
33451
+ } else if (kind === "quote" || kind === "ul" || kind === "ol") {
33452
+ const prefix = kind === "quote" ? "> " : kind === "ul" ? "- " : "1. ";
33453
+ const block = (sel || "item").split("\n").map((l2) => prefix + l2).join("\n");
33454
+ replacement = (start > 0 && value[start - 1] !== "\n" ? "\n" : "") + block;
33455
+ }
33456
+ const next = value.slice(0, start) + replacement + value.slice(end);
33457
+ setValue2(next);
33458
+ const caret = caretOffset ? start + caretOffset : start + replacement.length;
33459
+ queueCaret(caret);
33460
+ }
33461
+ function submit() {
33462
+ const text = value.trim();
33463
+ if (!text && pending.length === 0 || busy) return;
33464
+ onSubmit(text, pending.length ? pending : void 0);
33465
+ setValue2("");
33466
+ setPending([]);
33467
+ setTrigger(null);
33468
+ }
33469
+ function onFiles(files) {
33470
+ if (!files) return;
33471
+ setPending((p2) => [
33472
+ ...p2,
33473
+ ...Array.from(files).map((f2) => ({
33474
+ id: `${f2.name}-${f2.size}-${f2.lastModified}`,
33475
+ name: f2.name,
33476
+ url: URL.createObjectURL(f2),
33477
+ type: f2.type || "application/octet-stream",
33478
+ size: f2.size
33479
+ }))
33480
+ ]);
33481
+ }
33482
+ function onKeyDown(e2) {
33483
+ if (menuOpen) {
33484
+ if (e2.key === "ArrowDown") return e2.preventDefault(), setActive((a2) => (a2 + 1) % items.length);
33485
+ if (e2.key === "ArrowUp") return e2.preventDefault(), setActive((a2) => (a2 - 1 + items.length) % items.length);
33486
+ if (e2.key === "Enter" || e2.key === "Tab") return e2.preventDefault(), selectItem(active);
33487
+ if (e2.key === "Escape") return e2.preventDefault(), setTrigger(null);
33488
+ }
33489
+ const mod = e2.metaKey || e2.ctrlKey;
33490
+ if (mod && e2.key.toLowerCase() === "b") return e2.preventDefault(), format("bold");
33491
+ if (mod && e2.key.toLowerCase() === "i") return e2.preventDefault(), format("italic");
33492
+ if (mod && e2.key.toLowerCase() === "e") return e2.preventDefault(), format("code");
33493
+ if (mod && e2.key.toLowerCase() === "k") return e2.preventDefault(), format("link");
33494
+ if (e2.key === "Enter" && !e2.shiftKey) {
33495
+ e2.preventDefault();
33496
+ submit();
33497
+ }
33498
+ }
33499
+ const toolbarBtn = (label, title, kind) => h(
33500
+ "button",
33501
+ {
33502
+ key: kind,
33503
+ type: "button",
33504
+ title,
33505
+ className: "rounded px-1.5 py-0.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",
33506
+ onMouseDown: (e2) => e2.preventDefault(),
33507
+ // keep textarea selection
33508
+ onClick: () => format(kind)
33509
+ },
33510
+ label
33511
+ );
33512
+ return h(
33513
+ "div",
33514
+ { className: "border-t border-border" },
33515
+ // attachment chips
33516
+ pending.length > 0 ? h(
33517
+ "div",
33518
+ { className: "flex flex-wrap gap-2 px-3 pt-2" },
33519
+ ...pending.map(
33520
+ (a2) => h(
33521
+ "span",
33522
+ { key: a2.id, className: "inline-flex items-center gap-1 rounded bg-muted px-2 py-0.5 text-xs" },
33523
+ a2.name,
33524
+ h(
33525
+ "button",
33526
+ {
33527
+ type: "button",
33528
+ className: "text-muted-foreground hover:text-destructive",
33529
+ onClick: () => setPending((p2) => p2.filter((x2) => x2.id !== a2.id))
33530
+ },
33531
+ "\u2715"
33532
+ )
33533
+ )
33534
+ )
33535
+ ) : null,
33536
+ // toolbar
33537
+ toolbar ? h(
33538
+ "div",
33539
+ { className: "flex items-center gap-0.5 px-2 pt-2" },
33540
+ toolbarBtn("B", "Bold (\u2318B)", "bold"),
33541
+ toolbarBtn("\u{1D456}", "Italic (\u2318I)", "italic"),
33542
+ toolbarBtn("</>", "Code (\u2318E)", "code"),
33543
+ toolbarBtn("\u{1F517}", "Link (\u2318K)", "link"),
33544
+ toolbarBtn("\u275D", "Quote", "quote"),
33545
+ toolbarBtn("\u2022", "Bulleted list", "ul"),
33546
+ toolbarBtn("1.", "Numbered list", "ol")
33547
+ ) : null,
33548
+ // input row (relative for the popup menu)
33549
+ h(
33550
+ "div",
33551
+ { className: "relative flex items-end gap-2 p-3" },
33552
+ menuOpen ? h(
33553
+ "div",
33554
+ {
33555
+ className: "absolute bottom-full left-3 z-20 mb-1 w-72 overflow-hidden rounded-lg border border-border bg-popover shadow-lg",
33556
+ role: "listbox"
33557
+ },
33558
+ h(
33559
+ "div",
33560
+ { className: "border-b border-border px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground" },
33561
+ trigger?.type === "/" ? "Commands" : trigger?.type === "@" ? "Mentions" : "Emoji"
33562
+ ),
33563
+ ...items.map(
33564
+ (it2, i2) => h(
33565
+ "button",
33566
+ {
33567
+ key: it2.key,
33568
+ type: "button",
33569
+ role: "option",
33570
+ "aria-selected": i2 === active,
33571
+ className: cn(
33572
+ "flex w-full items-center gap-2 px-2 py-1.5 text-left text-sm",
33573
+ i2 === active ? "bg-accent" : "hover:bg-accent/50"
33574
+ ),
33575
+ onMouseEnter: () => setActive(i2),
33576
+ onMouseDown: (e2) => e2.preventDefault(),
33577
+ onClick: () => selectItem(i2)
33578
+ },
33579
+ it2.icon ? h("span", { className: "w-4 text-center text-muted-foreground" }, it2.icon) : null,
33580
+ h("span", { className: "flex-1 truncate" }, it2.primary),
33581
+ it2.secondary ? h("span", { className: "truncate text-xs text-muted-foreground" }, it2.secondary) : null
33582
+ )
33583
+ )
33584
+ ) : null,
33585
+ attachments ? h(
33586
+ React11__namespace.Fragment,
33587
+ null,
33588
+ h("input", {
33589
+ ref: fileRef,
33590
+ type: "file",
33591
+ accept: "image/*",
33592
+ multiple: true,
33593
+ className: "hidden",
33594
+ onChange: (e2) => {
33595
+ onFiles(e2.target.files);
33596
+ e2.target.value = "";
33597
+ }
33598
+ }),
33599
+ h(
33600
+ "button",
33601
+ {
33602
+ type: "button",
33603
+ className: "rounded-md border border-border px-2 py-2 text-sm hover:bg-accent",
33604
+ "aria-label": "Attach image or GIF",
33605
+ onClick: () => fileRef.current?.click()
33606
+ },
33607
+ "\u{1F4CE}"
33608
+ )
33609
+ ) : null,
33610
+ h("textarea", {
33611
+ ref,
33612
+ className: "max-h-40 flex-1 resize-none rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary",
33613
+ rows: 1,
33614
+ value,
33615
+ placeholder,
33616
+ autoFocus,
33617
+ "aria-label": "Message",
33618
+ onChange: (e2) => syncFromTextarea(e2.target),
33619
+ onClick: (e2) => syncFromTextarea(e2.currentTarget),
33620
+ onKeyUp: (e2) => syncFromTextarea(e2.currentTarget),
33621
+ onKeyDown,
33622
+ onBlur: () => setTimeout(() => setTrigger(null), 120)
33623
+ }),
33624
+ busy ? h(
33625
+ "button",
33626
+ {
33627
+ type: "button",
33628
+ className: "rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground",
33629
+ onClick: () => onStop?.()
33630
+ },
33631
+ "Stop"
33632
+ ) : h(
33633
+ "button",
33634
+ {
33635
+ type: "button",
33636
+ className: "rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",
33637
+ disabled: !value.trim() && pending.length === 0,
33638
+ onClick: submit
33639
+ },
33640
+ "Send"
33641
+ )
33642
+ )
33643
+ );
33644
+ }
33645
+ var h2 = React11__namespace.createElement;
33646
+ var QUICK_EMOJIS = ["\u{1F44D}", "\u2764\uFE0F", "\u{1F602}", "\u{1F389}", "\u{1F440}", "\u{1F64F}"];
33647
+ var chatMd = cn(
33648
+ "max-w-none text-sm",
33649
+ "[&_p]:my-1 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0",
33650
+ "[&_pre]:my-2 [&_pre]:rounded-md [&_pre]:text-xs [&_pre]:leading-relaxed",
33651
+ "[&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5",
33652
+ "[&_h1]:text-base [&_h1]:font-semibold [&_h1]:mt-2 [&_h1]:mb-1",
33653
+ "[&_h2]:text-sm [&_h2]:font-semibold [&_h2]:mt-2 [&_h2]:mb-1",
33654
+ "[&_h3]:text-sm [&_h3]:font-semibold",
33655
+ "[&_blockquote]:my-1 [&_blockquote]:border-l-2 [&_blockquote]:pl-2 [&_blockquote]:not-italic [&_blockquote]:text-muted-foreground",
33656
+ "[&_img]:my-1 [&_img]:max-h-60 [&_img]:rounded-md",
33657
+ "[&_code]:text-[0.85em]"
33658
+ );
33659
+ function Avatar({ name, avatarUrl, size = 8 }) {
33660
+ return h2(
33661
+ "div",
33662
+ {
33663
+ className: cn(
33664
+ "flex-shrink-0 overflow-hidden rounded-full bg-muted flex items-center justify-center text-xs font-medium",
33665
+ size === 8 ? "h-8 w-8" : "h-7 w-7"
33666
+ )
33667
+ },
33668
+ avatarUrl ? h2("img", { src: avatarUrl, alt: name, className: "h-full w-full object-cover" }) : (name.charAt(0) || "?").toUpperCase()
33669
+ );
33670
+ }
33671
+ function TypingDots() {
33672
+ return h2(
33673
+ "div",
33674
+ { className: "flex items-center gap-1 py-1.5", "aria-label": "Assistant is typing" },
33675
+ ...[0, 150, 300].map(
33676
+ (delay) => h2("span", {
33677
+ key: delay,
33678
+ className: "h-1.5 w-1.5 rounded-full bg-muted-foreground/60 animate-bounce",
33679
+ style: { animationDelay: `${delay}ms` }
33680
+ })
33681
+ )
33682
+ );
33683
+ }
33684
+ function Attachments({ attachments }) {
33685
+ return h2(
33686
+ "div",
33687
+ { className: "mt-2 flex flex-wrap gap-2" },
33688
+ ...attachments.map(
33689
+ (a2) => a2.type.startsWith("image/") ? h2("img", { key: a2.id, src: a2.url, alt: a2.name, className: "max-h-60 rounded-md border border-border object-contain" }) : h2(
33690
+ "a",
33691
+ {
33692
+ key: a2.id,
33693
+ href: a2.url,
33694
+ target: "_blank",
33695
+ rel: "noreferrer",
33696
+ className: "inline-flex items-center gap-2 rounded-md border border-border bg-background/60 px-2 py-1 text-xs"
33697
+ },
33698
+ "\u{1F4CE} ",
33699
+ a2.name
33700
+ )
33701
+ )
33702
+ );
33703
+ }
33704
+ function MessageBody({ message }) {
33705
+ if (message.status === "streaming" && message.content === "") return h2(TypingDots);
33706
+ return h2(
33707
+ React11__namespace.Fragment,
33708
+ null,
33709
+ message.content ? h2(MarkdownRenderer, { content: message.content, size: "sm", className: chatMd }) : null,
33710
+ message.attachments && message.attachments.length > 0 ? h2(Attachments, { attachments: message.attachments }) : null,
33711
+ message.status === "error" ? h2("div", { className: "mt-1 text-xs text-destructive", role: "alert" }, message.error ?? "Failed to send.") : null
33712
+ );
33713
+ }
33714
+ function Reactions({ message, onReact, align }) {
33715
+ if (!message.reactions || message.reactions.length === 0) return null;
33716
+ return h2(
33717
+ "div",
33718
+ { className: cn("mt-1 flex flex-wrap gap-1", align === "end" && "justify-end") },
33719
+ ...message.reactions.map(
33720
+ (r2) => h2(
33721
+ "button",
33722
+ {
33723
+ key: r2.emoji,
33724
+ type: "button",
33725
+ onClick: () => onReact(r2.emoji),
33726
+ className: cn(
33727
+ "inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-xs",
33728
+ r2.userReacted ? "border-primary bg-primary/10" : "border-border bg-background"
33729
+ )
33730
+ },
33731
+ `${r2.emoji} ${r2.count}`
33732
+ )
33733
+ )
33734
+ );
33735
+ }
33736
+ function QuotedParent({ parent, onClick }) {
33737
+ const snippet = parent.content.length > 80 ? `${parent.content.slice(0, 80)}\u2026` : parent.content;
33738
+ return h2(
33739
+ "button",
33740
+ {
33741
+ type: "button",
33742
+ onClick,
33743
+ className: "mb-1 flex max-w-full items-start gap-2 rounded-md border-l-2 border-primary/50 bg-muted/50 px-2 py-1 text-left text-xs text-muted-foreground hover:bg-muted"
33744
+ },
33745
+ h2("span", { className: "font-medium" }, parent.author.name),
33746
+ h2("span", { className: "truncate" }, snippet)
33747
+ );
33748
+ }
33749
+ function HoverActions({
33750
+ message,
33751
+ conversation,
33752
+ isOwn,
33753
+ onEdit,
33754
+ onToggleEmojis,
33755
+ align
33756
+ }) {
33757
+ const { replyTo, deleteMessage } = conversation;
33758
+ return h2(
33759
+ "div",
33760
+ {
33761
+ className: cn(
33762
+ "mt-1 flex items-center gap-3 text-xs text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",
33763
+ align === "end" && "justify-end"
33764
+ )
33765
+ },
33766
+ // Reply targets this specific message but groups under the originating root.
33767
+ h2("button", { type: "button", className: "hover:text-foreground", onClick: () => replyTo(message.id) }, "Reply"),
33768
+ h2("button", { type: "button", className: "hover:text-foreground", onClick: onToggleEmojis }, "React"),
33769
+ isOwn ? h2("button", { type: "button", className: "hover:text-foreground", onClick: onEdit }, "Edit") : null,
33770
+ isOwn ? h2("button", { type: "button", className: "hover:text-destructive", onClick: () => deleteMessage(message.id) }, "Delete") : null
33771
+ );
33772
+ }
33773
+ function EmojiRow({ onPick, align }) {
33774
+ return h2(
33775
+ "div",
33776
+ { className: cn("mt-1 flex gap-1", align === "end" && "justify-end") },
33777
+ ...QUICK_EMOJIS.map(
33778
+ (emoji) => h2("button", { key: emoji, type: "button", className: "rounded px-1 text-base hover:bg-accent", onClick: () => onPick(emoji) }, emoji)
33779
+ )
33780
+ );
33781
+ }
33782
+ function EditField({ message, conversation, onDone }) {
33783
+ const [draft, setDraft] = React11__namespace.useState(message.content);
33784
+ function save() {
33785
+ const t2 = draft.trim();
33786
+ if (t2 && t2 !== message.content) conversation.editMessage(message.id, t2);
33787
+ onDone();
33788
+ }
33789
+ return h2(
33790
+ "div",
33791
+ { className: "mt-1" },
33792
+ h2("textarea", {
33793
+ className: "w-full resize-none rounded-md border border-border bg-background px-2 py-1 text-sm",
33794
+ value: draft,
33795
+ autoFocus: true,
33796
+ onChange: (e2) => setDraft(e2.target.value),
33797
+ onKeyDown: (e2) => {
33798
+ if (e2.key === "Enter" && !e2.shiftKey) {
33799
+ e2.preventDefault();
33800
+ save();
33801
+ }
33802
+ if (e2.key === "Escape") onDone();
33803
+ }
33804
+ }),
33805
+ h2(
33806
+ "div",
33807
+ { className: "mt-1 flex gap-2 text-xs" },
33808
+ h2("button", { type: "button", className: "text-primary", onClick: save }, "Save"),
33809
+ h2("button", { type: "button", className: "text-muted-foreground", onClick: onDone }, "Cancel")
33810
+ )
33811
+ );
33812
+ }
33813
+ function MessageRow({
33814
+ message,
33815
+ conversation,
33816
+ currentUserId,
33817
+ showThreadAffordance,
33818
+ quotedParent
33819
+ }) {
33820
+ const { state, react, openThread } = conversation;
33821
+ const [showEmojis, setShowEmojis] = React11__namespace.useState(false);
33822
+ const [editing, setEditing] = React11__namespace.useState(false);
33823
+ const isUser = currentUserId ? message.author.id === currentUserId : message.role === "user";
33824
+ const replyCount = getReplyCount(state.messages, message.id);
33825
+ const align = isUser ? "end" : "start";
33826
+ const inner = h2(
33827
+ React11__namespace.Fragment,
33828
+ null,
33829
+ quotedParent ? h2(QuotedParent, { parent: quotedParent, onClick: () => openThread(rootIdOf(state.messages, quotedParent.id)) }) : null,
33830
+ editing ? h2(EditField, { message, conversation, onDone: () => setEditing(false) }) : isUser ? h2("div", { className: "inline-block rounded-2xl rounded-br-sm bg-primary/10 px-3 py-2 text-left" }, h2(MessageBody, { message })) : h2(MessageBody, { message }),
33831
+ h2(Reactions, { message, onReact: (e2) => react(message.id, e2), align }),
33832
+ showThreadAffordance && replyCount > 0 ? h2(
33833
+ "button",
33834
+ { type: "button", className: cn("mt-1 text-xs font-medium text-primary hover:underline", align === "end" && "self-end"), onClick: () => openThread(message.id) },
33835
+ `\u{1F4AC} ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`
33836
+ ) : null,
33837
+ h2(HoverActions, { message, conversation, isOwn: isUser, onEdit: () => setEditing(true), onToggleEmojis: () => setShowEmojis((v2) => !v2), align }),
33838
+ showEmojis ? h2(EmojiRow, {
33839
+ onPick: (e2) => {
33840
+ react(message.id, e2);
33841
+ setShowEmojis(false);
33842
+ },
33843
+ align
33844
+ }) : null
33845
+ );
33846
+ if (!isUser) {
33847
+ return h2(
33848
+ "div",
33849
+ { className: "group flex gap-3 rounded-md px-3 py-2 hover:bg-accent/30", role: "article", "aria-label": `Message from ${message.author.name}`, "data-message-id": message.id },
33850
+ h2(Avatar, { name: message.author.name, avatarUrl: message.author.avatarUrl }),
33851
+ h2(
33852
+ "div",
33853
+ { className: "min-w-0 flex-1" },
33854
+ h2(
33855
+ "div",
33856
+ { className: "flex items-baseline gap-2" },
33857
+ h2("span", { className: "text-sm font-semibold" }, message.author.name),
33858
+ h2("span", { className: "text-xs text-muted-foreground", title: message.timestamp.toLocaleString() }, formatTimestamp(message.timestamp)),
33859
+ message.edited ? h2("span", { className: "text-xs text-muted-foreground" }, "(edited)") : null
33860
+ ),
33861
+ inner
33862
+ )
33863
+ );
33864
+ }
33865
+ return h2(
33866
+ "div",
33867
+ { className: "group flex flex-col items-end px-3 py-1.5", role: "article", "aria-label": `Message from ${message.author.name}`, "data-message-id": message.id },
33868
+ h2(
33869
+ "div",
33870
+ { className: "flex items-baseline gap-2" },
33871
+ message.edited ? h2("span", { className: "text-xs text-muted-foreground" }, "(edited)") : null,
33872
+ h2("span", { className: "text-xs text-muted-foreground", title: message.timestamp.toLocaleString() }, formatTimestamp(message.timestamp)),
33873
+ h2("span", { className: "text-sm font-semibold" }, message.author.name)
33874
+ ),
33875
+ h2("div", { className: "mt-0.5 flex max-w-[80%] flex-col items-end" }, inner)
33876
+ );
33877
+ }
33878
+ function ConversationSidebar({ conversation }) {
33879
+ const { state, newConversation, selectConversation, deleteConversation } = conversation;
33880
+ return h2(
33881
+ "aside",
33882
+ { className: "flex w-56 flex-col gap-1 overflow-y-auto border-r border-border bg-muted/20 p-2", "aria-label": "Conversations" },
33883
+ h2(
33884
+ "button",
33885
+ { type: "button", className: "mb-1 w-full rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90", onClick: () => newConversation() },
33886
+ "+ New chat"
33887
+ ),
33888
+ ...state.conversations.map(
33889
+ (conv) => h2(
33890
+ "div",
33891
+ {
33892
+ key: conv.id,
33893
+ role: "button",
33894
+ "aria-current": conv.id === state.activeConversationId,
33895
+ onClick: () => selectConversation(conv.id),
33896
+ className: cn(
33897
+ "group flex items-center justify-between gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-accent/60",
33898
+ conv.id === state.activeConversationId && "bg-accent font-medium"
33899
+ )
33900
+ },
33901
+ h2(
33902
+ "div",
33903
+ { className: "min-w-0" },
33904
+ h2("div", { className: "truncate" }, conv.title),
33905
+ h2("div", { className: "truncate text-xs text-muted-foreground" }, formatRelativeTime(conv.updatedAt))
33906
+ ),
33907
+ h2(
33908
+ "button",
33909
+ {
33910
+ type: "button",
33911
+ className: "text-xs text-muted-foreground opacity-0 hover:text-destructive group-hover:opacity-100",
33912
+ "aria-label": `Delete ${conv.title}`,
33913
+ onClick: (e2) => {
33914
+ e2.stopPropagation();
33915
+ deleteConversation(conv.id);
33916
+ }
33917
+ },
33918
+ "\u2715"
33919
+ )
33920
+ )
33921
+ )
33922
+ );
33923
+ }
33924
+ function ThreadPanel({ conversation, currentUserId, composer }) {
33925
+ const { state } = conversation;
33926
+ const rootId = state.openThreadRootId;
33927
+ if (!rootId) return null;
33928
+ const messages = selectThreadMessages(state.messages, rootId);
33929
+ const target = state.replyTarget && state.replyTarget !== rootId ? findMessage(state.messages, state.replyTarget) : void 0;
33930
+ return h2(
33931
+ "aside",
33932
+ { className: "flex w-80 flex-col border-l border-border", "aria-label": "Thread" },
33933
+ h2(
33934
+ "div",
33935
+ { className: "flex items-center justify-between border-b border-border px-3 py-2" },
33936
+ h2("span", { className: "text-sm font-semibold" }, `Thread \xB7 ${messages.length - 1} ${messages.length - 1 === 1 ? "reply" : "replies"}`),
33937
+ h2("button", { type: "button", className: "text-muted-foreground hover:text-foreground", "aria-label": "Close thread", onClick: () => conversation.closeThread() }, "\u2715")
33938
+ ),
33939
+ h2(
33940
+ "div",
33941
+ { className: "flex-1 overflow-y-auto p-1" },
33942
+ ...messages.map((m2) => h2(MessageRow, { key: m2.id, message: m2, conversation, currentUserId, showThreadAffordance: false }))
33943
+ ),
33944
+ target ? h2(
33945
+ "div",
33946
+ { className: "flex items-center justify-between gap-2 border-t border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground" },
33947
+ h2("span", { className: "truncate" }, `\u21B3 Replying to ${target.author.name}`),
33948
+ h2("button", { type: "button", className: "hover:text-foreground", onClick: () => conversation.openThread(rootId) }, "Reply to thread instead")
33949
+ ) : null,
33950
+ composer
33951
+ );
33952
+ }
33953
+ function ModeToggle({ conversation }) {
33954
+ const { state, setThreadingMode } = conversation;
33955
+ const opt = (mode, label) => h2(
33956
+ "button",
33957
+ {
33958
+ type: "button",
33959
+ onClick: () => setThreadingMode(mode),
33960
+ className: cn("rounded px-2 py-0.5 text-xs", state.threadingMode === mode ? "bg-background shadow-sm" : "text-muted-foreground")
33961
+ },
33962
+ label
33963
+ );
33964
+ return h2(
33965
+ "div",
33966
+ { className: "inline-flex rounded-md bg-muted p-0.5", role: "group", "aria-label": "Threading mode" },
33967
+ opt("inline", "Inline"),
33968
+ opt("panel", "Threads")
33969
+ );
33970
+ }
33971
+ function Chat({
33972
+ conversation,
33973
+ showConversationList = true,
33974
+ showModeToggle = true,
33975
+ placeholder,
33976
+ currentUserId,
33977
+ emptyState,
33978
+ className,
33979
+ slashCommands,
33980
+ mentions,
33981
+ onSlashCommand,
33982
+ composerToolbar = true
33983
+ }) {
33984
+ const { state, sendMessage } = conversation;
33985
+ const timeline = selectMainTimeline(state.messages, state.threadingMode);
33986
+ const activeConv = state.conversations.find((c2) => c2.id === state.activeConversationId);
33987
+ const busy = state.status === "sending" || state.status === "streaming";
33988
+ const mainComposer = h2(Composer, {
33989
+ placeholder,
33990
+ busy,
33991
+ slashCommands,
33992
+ mentions,
33993
+ onSlashCommand,
33994
+ toolbar: composerToolbar,
33995
+ onSubmit: (content, atts) => void sendMessage(content, { attachments: atts }),
33996
+ onStop: () => conversation.stop()
33997
+ });
33998
+ const threadComposer = state.openThreadRootId ? h2(Composer, {
33999
+ placeholder: "Reply\u2026",
34000
+ busy,
34001
+ slashCommands,
34002
+ mentions,
34003
+ onSlashCommand,
34004
+ toolbar: composerToolbar,
34005
+ onSubmit: (content, atts) => void sendMessage(content, { replyTo: state.replyTarget ?? state.openThreadRootId, attachments: atts }),
34006
+ onStop: () => conversation.stop()
34007
+ }) : null;
34008
+ const body = timeline.length === 0 ? h2("div", { className: "flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground" }, emptyState ?? "No messages yet. Say hello \u{1F44B}") : h2(
34009
+ "div",
34010
+ { className: "flex-1 space-y-0.5 overflow-y-auto p-2" },
34011
+ ...timeline.map(
34012
+ (m2) => h2(MessageRow, {
34013
+ key: m2.id,
34014
+ message: m2,
34015
+ conversation,
34016
+ currentUserId,
34017
+ // Show the "N replies" count on originating messages in BOTH modes.
34018
+ showThreadAffordance: true,
34019
+ // Inline: quote the specific message replied to (falls back to the root).
34020
+ quotedParent: state.threadingMode === "inline" && m2.parentId ? findMessage(state.messages, m2.replyToId ?? m2.parentId) : void 0
34021
+ })
34022
+ )
34023
+ );
34024
+ return h2(
34025
+ "div",
34026
+ { className: cn("flex h-full min-h-0 overflow-hidden rounded-xl border border-border bg-background", className) },
34027
+ showConversationList ? h2(ConversationSidebar, { conversation }) : null,
34028
+ h2(
34029
+ "div",
34030
+ { className: "flex min-w-0 flex-1 flex-col" },
34031
+ h2(
34032
+ "div",
34033
+ { className: "flex items-center justify-between border-b border-border px-3 py-2" },
34034
+ h2("span", { className: "truncate text-sm font-semibold" }, activeConv?.title ?? "Chat"),
34035
+ showModeToggle ? h2(ModeToggle, { conversation }) : null
34036
+ ),
34037
+ body,
34038
+ mainComposer
34039
+ ),
34040
+ h2(ThreadPanel, { conversation, currentUserId, composer: threadComposer })
34041
+ );
34042
+ }
34043
+
34044
+ // ../content-protection/dist/index.js
34045
+ function createContentProtection(props = {}) {
34046
+ const {
34047
+ enabled = true,
34048
+ disableCopy = true,
34049
+ disableContextMenu = true,
34050
+ watermarkText
34051
+ } = props;
34052
+ const eventHandlers = {};
34053
+ if (enabled) {
34054
+ if (disableCopy) {
34055
+ const prevent = (e2) => e2.preventDefault();
34056
+ eventHandlers.onCopy = prevent;
34057
+ eventHandlers.onCut = prevent;
34058
+ eventHandlers.onSelectStart = prevent;
34059
+ }
34060
+ if (disableContextMenu) {
34061
+ eventHandlers.onContextMenu = (e2) => e2.preventDefault();
34062
+ }
34063
+ }
34064
+ const watermarkConfig = watermarkText ? { text: watermarkText, opacity: 0.08, angle: -45 } : null;
34065
+ const dataAttributes = {};
34066
+ if (enabled) {
34067
+ dataAttributes["data-protected"] = "true";
34068
+ }
34069
+ return {
34070
+ eventHandlers,
34071
+ watermarkConfig,
34072
+ dataAttributes
34073
+ };
34074
+ }
34075
+ var contentProtectionVariants = cva({
34076
+ base: "relative select-none"
34077
+ });
34078
+ var watermarkVariants = cva({
34079
+ base: "pointer-events-none absolute inset-0 z-50 overflow-hidden"
34080
+ });
34081
+ var ContentProtection = React11__namespace.forwardRef(
34082
+ ({
34083
+ enabled,
34084
+ disableCopy,
34085
+ disableContextMenu,
34086
+ watermarkText,
34087
+ className,
34088
+ children,
34089
+ ...props
34090
+ }, ref) => {
34091
+ const api = createContentProtection({
34092
+ enabled,
34093
+ disableCopy,
34094
+ disableContextMenu,
34095
+ watermarkText
34096
+ });
34097
+ const classes = cn(contentProtectionVariants(), className);
34098
+ return /* @__PURE__ */ jsxRuntime.jsxs(
34099
+ "div",
34100
+ {
34101
+ ref,
34102
+ className: classes,
34103
+ ...api.dataAttributes,
34104
+ onCopy: api.eventHandlers.onCopy,
34105
+ onCut: api.eventHandlers.onCut,
34106
+ onContextMenu: api.eventHandlers.onContextMenu,
34107
+ onSelect: api.eventHandlers.onSelectStart,
34108
+ ...props,
34109
+ children: [
34110
+ children,
34111
+ api.watermarkConfig && /* @__PURE__ */ jsxRuntime.jsx(
34112
+ "div",
34113
+ {
34114
+ className: watermarkVariants(),
34115
+ "aria-hidden": "true",
34116
+ style: {
34117
+ opacity: api.watermarkConfig.opacity,
34118
+ transform: `rotate(${api.watermarkConfig.angle}deg)`,
34119
+ backgroundImage: `repeating-linear-gradient(
34120
+ ${api.watermarkConfig.angle}deg,
34121
+ transparent,
34122
+ transparent 80px,
34123
+ currentColor 80px,
34124
+ currentColor 80px
34125
+ )`
34126
+ },
34127
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "100%", height: "100%", children: [
34128
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx(
34129
+ "pattern",
34130
+ {
34131
+ id: "rfr-watermark",
34132
+ x: "0",
34133
+ y: "0",
34134
+ width: "200",
34135
+ height: "200",
34136
+ patternUnits: "userSpaceOnUse",
34137
+ patternTransform: `rotate(${api.watermarkConfig.angle})`,
34138
+ children: /* @__PURE__ */ jsxRuntime.jsx(
34139
+ "text",
34140
+ {
34141
+ x: "0",
34142
+ y: "100",
34143
+ fill: "currentColor",
34144
+ fontSize: "16",
34145
+ fontFamily: "sans-serif",
34146
+ children: api.watermarkConfig.text
34147
+ }
34148
+ )
34149
+ }
34150
+ ) }),
34151
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "100%", height: "100%", fill: "url(#rfr-watermark)" })
34152
+ ] })
34153
+ }
34154
+ )
34155
+ ]
34156
+ }
34157
+ );
34158
+ }
34159
+ );
34160
+ ContentProtection.displayName = "ContentProtection";
34161
+
34162
+ // ../cookie-consent/dist/index.js
34163
+ var DEFAULT_KEY = "rfr-cookie-consent";
34164
+ var DEFAULT_CATEGORIES = [
34165
+ { id: "necessary", label: "Strictly necessary", description: "Required for the site to function. Always on.", required: true },
34166
+ { id: "preferences", label: "Preferences", description: "Remembers your settings and choices." },
34167
+ { id: "analytics", label: "Analytics", description: "Helps us understand how the site is used." },
34168
+ { id: "marketing", label: "Marketing", description: "Used to personalize ads and measure campaigns." }
34169
+ ];
34170
+ function baseline(categories) {
34171
+ const p2 = {};
34172
+ for (const c2 of categories) p2[c2.id] = !!c2.required;
34173
+ return p2;
34174
+ }
34175
+ function createCookieConsent(config = {}) {
34176
+ const categories = config.categories ?? DEFAULT_CATEGORIES;
34177
+ const storage = config.storage;
34178
+ const key = config.storageKey ?? DEFAULT_KEY;
34179
+ const version2 = config.version;
34180
+ let preferences = baseline(categories);
34181
+ let consented = false;
34182
+ const raw = storage?.get(key) ?? null;
34183
+ if (raw) {
34184
+ try {
34185
+ const parsed = JSON.parse(raw);
34186
+ if ((parsed.version ?? void 0) === version2) {
34187
+ preferences = { ...baseline(categories), ...parsed.preferences };
34188
+ for (const c2 of categories) if (c2.required) preferences[c2.id] = true;
34189
+ consented = true;
34190
+ }
34191
+ } catch {
34192
+ }
34193
+ }
34194
+ let open = !consented;
34195
+ const listeners = /* @__PURE__ */ new Set();
34196
+ let snapshot = build();
34197
+ function build() {
34198
+ return { consented, preferences: { ...preferences }, open, categories };
34199
+ }
34200
+ function emit2() {
34201
+ snapshot = build();
34202
+ for (const l2 of listeners) l2();
34203
+ }
34204
+ function persist() {
34205
+ storage?.set(key, JSON.stringify({ version: version2, preferences }));
34206
+ config.onChange?.({ ...preferences });
34207
+ }
34208
+ function save(next) {
34209
+ const merged = { ...baseline(categories), ...next };
34210
+ for (const c2 of categories) if (c2.required) merged[c2.id] = true;
34211
+ preferences = merged;
34212
+ consented = true;
34213
+ open = false;
34214
+ persist();
34215
+ emit2();
34216
+ }
34217
+ return {
34218
+ getState() {
34219
+ return snapshot;
34220
+ },
34221
+ subscribe(listener) {
34222
+ listeners.add(listener);
34223
+ return () => listeners.delete(listener);
34224
+ },
34225
+ acceptAll() {
34226
+ const all = {};
34227
+ for (const c2 of categories) all[c2.id] = true;
34228
+ save(all);
34229
+ },
34230
+ rejectAll() {
34231
+ save(baseline(categories));
34232
+ },
34233
+ savePreferences(prefs) {
34234
+ save(prefs);
34235
+ },
34236
+ setPreference(id, value) {
34237
+ const cat = categories.find((c2) => c2.id === id);
34238
+ if (!cat || cat.required) return;
34239
+ preferences = { ...preferences, [id]: value };
34240
+ emit2();
34241
+ },
34242
+ reset() {
34243
+ storage?.remove(key);
34244
+ preferences = baseline(categories);
34245
+ consented = false;
34246
+ open = true;
34247
+ emit2();
34248
+ },
34249
+ openSettings() {
34250
+ if (open) return;
34251
+ open = true;
34252
+ emit2();
34253
+ },
34254
+ close() {
34255
+ if (!open) return;
34256
+ open = false;
34257
+ emit2();
34258
+ }
34259
+ };
34260
+ }
34261
+
34262
+ // ../react-cookie-consent/dist/index.js
34263
+ var localStorageAdapter = {
34264
+ get(k2) {
34265
+ try {
34266
+ return typeof localStorage !== "undefined" ? localStorage.getItem(k2) : null;
34267
+ } catch {
34268
+ return null;
34269
+ }
34270
+ },
34271
+ set(k2, v2) {
34272
+ try {
34273
+ localStorage?.setItem(k2, v2);
34274
+ } catch {
34275
+ }
34276
+ },
34277
+ remove(k2) {
34278
+ try {
34279
+ localStorage?.removeItem(k2);
34280
+ } catch {
34281
+ }
34282
+ }
34283
+ };
34284
+ function useCookieConsent(config) {
34285
+ const apiRef = React11__namespace.useRef(null);
34286
+ if (apiRef.current === null) {
34287
+ apiRef.current = createCookieConsent({ storage: localStorageAdapter, ...config });
34288
+ }
34289
+ const api = apiRef.current;
34290
+ const state = React11__namespace.useSyncExternalStore(api.subscribe, api.getState, api.getState);
34291
+ return {
34292
+ state,
34293
+ api,
34294
+ acceptAll: api.acceptAll,
34295
+ rejectAll: api.rejectAll,
34296
+ savePreferences: api.savePreferences,
34297
+ setPreference: api.setPreference,
34298
+ reset: api.reset,
34299
+ openSettings: api.openSettings,
34300
+ close: api.close
34301
+ };
34302
+ }
34303
+ var h3 = React11__namespace.createElement;
34304
+ var btnPrimary = "rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:opacity-90";
34305
+ var btnGhost = "rounded-md border border-border px-3 py-1.5 text-sm hover:bg-accent";
34306
+ var btnLink = "text-sm text-muted-foreground underline hover:text-foreground";
34307
+ function CookieConsent({
34308
+ consent,
34309
+ position = "bottom",
34310
+ title = "We use cookies",
34311
+ description = "We use cookies to run the site, remember your preferences, and measure traffic. Choose which categories to allow.",
34312
+ policyUrl,
34313
+ policyLabel = "Cookie policy",
34314
+ className
34315
+ }) {
34316
+ const { state, acceptAll, rejectAll, savePreferences, setPreference } = consent;
34317
+ const [settings, setSettings] = React11__namespace.useState(false);
34318
+ if (!state.open) return null;
34319
+ const wrapper = cn(
34320
+ "fixed inset-x-0 z-50 p-4",
34321
+ position === "bottom" ? "bottom-0" : "top-0",
34322
+ className
34323
+ );
34324
+ const panel = "mx-auto max-w-3xl rounded-xl border border-border bg-background p-4 shadow-lg";
34325
+ const header = h3(
34326
+ "div",
34327
+ null,
34328
+ h3("h2", { className: "text-base font-semibold" }, title),
34329
+ h3("p", { className: "mt-1 text-sm text-muted-foreground" }, description),
34330
+ policyUrl ? h3("a", { href: policyUrl, target: "_blank", rel: "noreferrer", className: cn(btnLink, "mt-1 inline-block") }, policyLabel) : null
34331
+ );
34332
+ const promptActions = h3(
34333
+ "div",
34334
+ { className: "mt-3 flex flex-wrap items-center gap-2" },
34335
+ h3("button", { type: "button", className: btnPrimary, onClick: () => acceptAll() }, "Accept all"),
34336
+ h3("button", { type: "button", className: btnGhost, onClick: () => rejectAll() }, "Reject all"),
34337
+ h3("button", { type: "button", className: cn(btnGhost, "ml-auto"), onClick: () => setSettings(true) }, "Manage preferences")
34338
+ );
34339
+ const settingsView = h3(
34340
+ "div",
34341
+ { className: "mt-3 space-y-2" },
34342
+ ...state.categories.map(
34343
+ (cat) => h3(
34344
+ "label",
34345
+ {
34346
+ key: cat.id,
34347
+ className: "flex items-start justify-between gap-3 rounded-md border border-border p-3"
34348
+ },
34349
+ h3(
34350
+ "span",
34351
+ { className: "min-w-0" },
34352
+ h3("span", { className: "block text-sm font-medium" }, cat.label, cat.required ? " (required)" : ""),
34353
+ cat.description ? h3("span", { className: "block text-xs text-muted-foreground" }, cat.description) : null
34354
+ ),
34355
+ h3("input", {
34356
+ type: "checkbox",
34357
+ className: "mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]",
34358
+ checked: !!state.preferences[cat.id],
34359
+ disabled: cat.required,
34360
+ "aria-label": cat.label,
34361
+ onChange: (e2) => setPreference(cat.id, e2.target.checked)
34362
+ })
34363
+ )
34364
+ ),
34365
+ h3(
34366
+ "div",
34367
+ { className: "flex flex-wrap items-center gap-2 pt-1" },
34368
+ h3("button", { type: "button", className: btnPrimary, onClick: () => savePreferences(state.preferences) }, "Save preferences"),
34369
+ h3("button", { type: "button", className: btnGhost, onClick: () => acceptAll() }, "Accept all"),
34370
+ h3("button", { type: "button", className: cn(btnLink, "ml-auto"), onClick: () => setSettings(false) }, "Back")
34371
+ )
34372
+ );
34373
+ return h3(
34374
+ "div",
34375
+ { className: wrapper, role: "dialog", "aria-label": "Cookie consent", "aria-modal": false },
34376
+ h3("div", { className: panel }, header, settings ? settingsView : promptActions)
34377
+ );
34378
+ }
34379
+
34380
+ // ../data-table/dist/index.js
34381
+ function createDataTable(props) {
34382
+ const {
34383
+ columns,
34384
+ data,
34385
+ sortBy: initialSortBy,
34386
+ sortDir: initialSortDir = "asc",
34387
+ onSort,
34388
+ filters: initialFilters
34389
+ } = props;
34390
+ let sortBy = initialSortBy ?? null;
34391
+ let sortDir = initialSortDir;
34392
+ let filters = { ...initialFilters ?? {} };
34393
+ function getFilteredData() {
34394
+ let result = [...data];
34395
+ for (const [columnId, filterValue] of Object.entries(filters)) {
34396
+ if (!filterValue) continue;
34397
+ const col = columns.find((c2) => c2.id === columnId);
34398
+ if (!col) continue;
34399
+ const lowerFilter = filterValue.toLowerCase();
34400
+ result = result.filter((row) => {
34401
+ const cellValue = col.accessor(row);
34402
+ return String(cellValue ?? "").toLowerCase().includes(lowerFilter);
34403
+ });
34404
+ }
34405
+ return result;
34406
+ }
34407
+ function getSortedData() {
34408
+ const filtered = getFilteredData();
34409
+ if (!sortBy) return filtered;
34410
+ const col = columns.find((c2) => c2.id === sortBy);
34411
+ if (!col) return filtered;
34412
+ return [...filtered].sort((a2, b2) => {
34413
+ const aVal = col.accessor(a2);
34414
+ const bVal = col.accessor(b2);
34415
+ const aStr = String(aVal ?? "");
34416
+ const bStr = String(bVal ?? "");
34417
+ const cmp = aStr.localeCompare(bStr, void 0, { numeric: true });
34418
+ return sortDir === "asc" ? cmp : -cmp;
34419
+ });
34420
+ }
34421
+ function sort(columnId) {
34422
+ const col = columns.find((c2) => c2.id === columnId);
34423
+ if (!col?.sortable) return;
34424
+ if (sortBy === columnId) {
34425
+ sortDir = sortDir === "asc" ? "desc" : "asc";
34426
+ } else {
34427
+ sortBy = columnId;
34428
+ sortDir = "asc";
34429
+ }
34430
+ onSort?.(sortBy, sortDir);
34431
+ }
34432
+ function setFilter(columnId, value) {
34433
+ filters = { ...filters, [columnId]: value };
34434
+ }
34435
+ function getHeaderProps(col) {
34436
+ const props2 = {
34437
+ role: "columnheader"
34438
+ };
34439
+ if (col.sortable) {
34440
+ if (sortBy === col.id) {
34441
+ props2["aria-sort"] = sortDir === "asc" ? "ascending" : "descending";
34442
+ } else {
34443
+ props2["aria-sort"] = "none";
34444
+ }
34445
+ }
34446
+ return props2;
34447
+ }
34448
+ function getCellProps(col, _row) {
34449
+ return {
34450
+ role: "cell",
34451
+ "data-column": col.id
34452
+ };
34453
+ }
34454
+ function getRowProps(_row, index) {
34455
+ return {
34456
+ role: "row",
34457
+ "data-row-index": index
34458
+ };
34459
+ }
34460
+ return {
34461
+ get state() {
34462
+ return {
34463
+ get sortedData() {
34464
+ return getSortedData();
34465
+ },
34466
+ get sortBy() {
34467
+ return sortBy;
34468
+ },
34469
+ get sortDir() {
34470
+ return sortDir;
34471
+ },
34472
+ get filters() {
34473
+ return { ...filters };
34474
+ }
34475
+ };
34476
+ },
34477
+ sort,
34478
+ setFilter,
34479
+ getHeaderProps,
34480
+ getCellProps,
34481
+ getRowProps
34482
+ };
34483
+ }
34484
+ var tableVariants = cva({
34485
+ base: "w-full caption-bottom text-sm border-collapse",
34486
+ variants: {
34487
+ size: {
34488
+ sm: "text-xs",
34489
+ md: "text-sm",
34490
+ lg: "text-base"
34491
+ }
34492
+ },
34493
+ defaultVariants: {
34494
+ size: "md"
32845
34495
  }
32846
34496
  });
32847
34497
  var headerVariants = cva({
@@ -34251,460 +35901,251 @@ Input.displayName = "Input";
34251
35901
  function createInputGroup(props = {}) {
34252
35902
  const { orientation = "horizontal" } = props;
34253
35903
  const id = props.id ?? generateId("rfr-input-group");
34254
- const ariaProps = {
34255
- role: "group"
34256
- };
34257
- if (props["aria-label"]) {
34258
- ariaProps["aria-label"] = props["aria-label"];
34259
- }
34260
- if (props["aria-labelledby"]) {
34261
- ariaProps["aria-labelledby"] = props["aria-labelledby"];
34262
- }
34263
- const dataAttributes = {
34264
- "data-orientation": orientation,
34265
- id
34266
- };
34267
- return {
34268
- ariaProps,
34269
- dataAttributes
34270
- };
34271
- }
34272
- var inputGroupTokens = {
34273
- name: "input-group",
34274
- tokens: {
34275
- bg: { variable: "--rfr-input-group-bg", fallback: "hsl(var(--background))" },
34276
- border: { variable: "--rfr-input-group-border", fallback: "hsl(var(--border))" },
34277
- radius: { variable: "--rfr-input-group-radius", fallback: "var(--radius)" }
34278
- }
34279
- };
34280
- var inputGroupVariants = cva({
34281
- base: "flex items-stretch [&>*:not(:first-child):not(:last-child)]:rounded-none",
34282
- variants: {
34283
- orientation: {
34284
- horizontal: "flex-row [&>*:first-child]:rounded-r-none [&>*:last-child]:rounded-l-none",
34285
- vertical: "flex-col [&>*:first-child]:rounded-b-none [&>*:last-child]:rounded-t-none"
34286
- }
34287
- },
34288
- defaultVariants: {
34289
- orientation: "horizontal"
34290
- }
34291
- });
34292
- var inputGroupAddonVariants = cva({
34293
- base: "flex items-center justify-center border bg-muted px-3 text-sm text-muted-foreground",
34294
- variants: {
34295
- orientation: {
34296
- horizontal: "border-y border-x first:border-r-0 last:border-l-0",
34297
- vertical: "border-x border-y first:border-b-0 last:border-t-0"
34298
- }
34299
- },
34300
- defaultVariants: {
34301
- orientation: "horizontal"
34302
- }
34303
- });
34304
- var inputGroupButtonVariants = cva({
34305
- base: "relative inline-flex items-center justify-center whitespace-nowrap text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
34306
- variants: {
34307
- orientation: {
34308
- horizontal: "",
34309
- vertical: ""
34310
- }
34311
- },
34312
- defaultVariants: {
34313
- orientation: "horizontal"
34314
- }
34315
- });
34316
- var InputGroup = React11__namespace.forwardRef(
34317
- ({ orientation = "horizontal", className, children, ...props }, ref) => {
34318
- const api = createInputGroup({
34319
- orientation,
34320
- id: props.id,
34321
- "aria-label": props["aria-label"],
34322
- "aria-labelledby": props["aria-labelledby"]
34323
- });
34324
- return /* @__PURE__ */ jsxRuntime.jsx(
34325
- "div",
34326
- {
34327
- ref,
34328
- className: cn(inputGroupVariants({ orientation }), className),
34329
- ...api.ariaProps,
34330
- ...api.dataAttributes,
34331
- ...props,
34332
- children
34333
- }
34334
- );
34335
- }
34336
- );
34337
- InputGroup.displayName = "InputGroup";
34338
- var InputGroupAddon = React11__namespace.forwardRef(
34339
- ({ orientation = "horizontal", className, children, ...props }, ref) => {
34340
- return /* @__PURE__ */ jsxRuntime.jsx(
34341
- "div",
34342
- {
34343
- ref,
34344
- className: cn(inputGroupAddonVariants({ orientation }), className),
34345
- ...props,
34346
- children
34347
- }
34348
- );
34349
- }
34350
- );
34351
- InputGroupAddon.displayName = "InputGroupAddon";
34352
- var InputGroupText = React11__namespace.forwardRef(
34353
- ({ className, children, ...props }, ref) => {
34354
- return /* @__PURE__ */ jsxRuntime.jsx(
34355
- "span",
34356
- {
34357
- ref,
34358
- className: cn("flex items-center px-3 text-sm text-muted-foreground", className),
34359
- ...props,
34360
- children
34361
- }
34362
- );
34363
- }
34364
- );
34365
- InputGroupText.displayName = "InputGroupText";
34366
- var InputGroupButton = React11__namespace.forwardRef(
34367
- ({ orientation = "horizontal", className, children, ...props }, ref) => {
34368
- return /* @__PURE__ */ jsxRuntime.jsx(
34369
- "button",
34370
- {
34371
- ref,
34372
- type: props.type ?? "button",
34373
- className: cn(inputGroupButtonVariants({ orientation }), className),
34374
- ...props,
34375
- children
34376
- }
34377
- );
34378
- }
34379
- );
34380
- InputGroupButton.displayName = "InputGroupButton";
34381
-
34382
- // ../install-prompt/dist/index.js
34383
- function createInstallPrompt(props = {}, storage) {
34384
- const { storageKey = "rfr-install-dismissed" } = props;
34385
- const dismissed = storage?.get(storageKey) === "true";
34386
- const state = {
34387
- canShow: false,
34388
- isDismissed: dismissed
34389
- };
34390
- return {
34391
- state,
34392
- show() {
34393
- if (!state.isDismissed) {
34394
- state.canShow = true;
34395
- }
34396
- },
34397
- dismiss() {
34398
- state.canShow = false;
34399
- state.isDismissed = true;
34400
- storage?.set(storageKey, "true");
34401
- },
34402
- install(promptEvent) {
34403
- promptEvent?.prompt();
34404
- state.canShow = false;
34405
- },
34406
- ariaProps: {
34407
- role: "banner",
34408
- "aria-label": "Install application"
34409
- }
34410
- };
34411
- }
34412
- var installPromptVariants = cva({
34413
- base: "fixed bottom-0 left-0 right-0 z-50 flex items-center justify-between gap-4 border-t bg-background px-4 py-3 shadow-lg"
34414
- });
34415
- function createLocalStorage() {
34416
- return {
34417
- get(key) {
34418
- try {
34419
- return localStorage.getItem(key);
34420
- } catch {
34421
- return null;
34422
- }
34423
- },
34424
- set(key, value) {
34425
- try {
34426
- localStorage.setItem(key, value);
34427
- } catch {
34428
- }
34429
- }
34430
- };
34431
- }
34432
- var InstallPrompt = React11__namespace.forwardRef(
34433
- ({
34434
- delay = 3e3,
34435
- storageKey,
34436
- installLabel = "Install",
34437
- dismissLabel = "Dismiss",
34438
- message = "Install this app for a better experience",
34439
- className,
34440
- ...props
34441
- }, ref) => {
34442
- const storageRef = React11__namespace.useRef(void 0);
34443
- if (typeof window !== "undefined" && !storageRef.current) {
34444
- storageRef.current = createLocalStorage();
34445
- }
34446
- const api = createInstallPrompt({ storageKey }, storageRef.current);
34447
- const [visible, setVisible] = React11__namespace.useState(false);
34448
- const promptEventRef = React11__namespace.useRef(null);
34449
- React11__namespace.useEffect(() => {
34450
- if (api.state.isDismissed) return;
34451
- const handleBeforeInstall = (e2) => {
34452
- e2.preventDefault();
34453
- promptEventRef.current = e2;
34454
- };
34455
- window.addEventListener("beforeinstallprompt", handleBeforeInstall);
34456
- const timer = setTimeout(() => {
34457
- if (promptEventRef.current && !api.state.isDismissed) {
34458
- api.show();
34459
- setVisible(true);
34460
- }
34461
- }, delay);
34462
- return () => {
34463
- window.removeEventListener("beforeinstallprompt", handleBeforeInstall);
34464
- clearTimeout(timer);
34465
- };
34466
- }, [delay, api]);
34467
- if (!visible) return null;
34468
- const classes = cn(installPromptVariants(), className);
34469
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: classes, ...api.ariaProps, ...props, children: [
34470
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: message }),
34471
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
34472
- /* @__PURE__ */ jsxRuntime.jsx(
34473
- "button",
34474
- {
34475
- type: "button",
34476
- onClick: () => {
34477
- api.install(promptEventRef.current ?? void 0);
34478
- setVisible(false);
34479
- },
34480
- children: installLabel
34481
- }
34482
- ),
34483
- /* @__PURE__ */ jsxRuntime.jsx(
34484
- "button",
34485
- {
34486
- type: "button",
34487
- onClick: () => {
34488
- api.dismiss();
34489
- setVisible(false);
34490
- },
34491
- children: dismissLabel
34492
- }
34493
- )
34494
- ] })
34495
- ] });
35904
+ const ariaProps = {
35905
+ role: "group"
35906
+ };
35907
+ if (props["aria-label"]) {
35908
+ ariaProps["aria-label"] = props["aria-label"];
34496
35909
  }
34497
- );
34498
- InstallPrompt.displayName = "InstallPrompt";
34499
-
34500
- // ../markdown-renderer/dist/index.js
34501
- function escapeHtml(text) {
34502
- return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
34503
- }
34504
- function parseInline(text, linkResolver) {
34505
- let result = escapeHtml(text);
34506
- result = result.replace(/`([^`]+)`/g, "<code>$1</code>");
34507
- result = result.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
34508
- result = result.replace(/__([^_]+)__/g, "<strong>$1</strong>");
34509
- result = result.replace(/\*([^*]+)\*/g, "<em>$1</em>");
34510
- result = result.replace(/_([^_]+)_/g, "<em>$1</em>");
34511
- result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, text2, url) => {
34512
- if (/^\s*javascript\s*:/i.test(url)) {
34513
- return text2;
34514
- }
34515
- const resolvedUrl = linkResolver ? linkResolver(url) : url;
34516
- return `<a href="${resolvedUrl}">${text2}</a>`;
34517
- });
34518
- return result;
35910
+ if (props["aria-labelledby"]) {
35911
+ ariaProps["aria-labelledby"] = props["aria-labelledby"];
35912
+ }
35913
+ const dataAttributes = {
35914
+ "data-orientation": orientation,
35915
+ id
35916
+ };
35917
+ return {
35918
+ ariaProps,
35919
+ dataAttributes
35920
+ };
34519
35921
  }
34520
- function parseMarkdown(content, linkResolver) {
34521
- const lines = content.split("\n");
34522
- const outputLines = [];
34523
- let inCodeBlock = false;
34524
- let codeBlockContent = [];
34525
- let codeBlockLang = "";
34526
- let inList = null;
34527
- let inBlockquote = false;
34528
- function closeList() {
34529
- if (inList) {
34530
- outputLines.push(inList === "ul" ? "</ul>" : "</ol>");
34531
- inList = null;
34532
- }
35922
+ var inputGroupTokens = {
35923
+ name: "input-group",
35924
+ tokens: {
35925
+ bg: { variable: "--rfr-input-group-bg", fallback: "hsl(var(--background))" },
35926
+ border: { variable: "--rfr-input-group-border", fallback: "hsl(var(--border))" },
35927
+ radius: { variable: "--rfr-input-group-radius", fallback: "var(--radius)" }
34533
35928
  }
34534
- function closeBlockquote() {
34535
- if (inBlockquote) {
34536
- outputLines.push("</blockquote>");
34537
- inBlockquote = false;
35929
+ };
35930
+ var inputGroupVariants = cva({
35931
+ base: "flex items-stretch [&>*:not(:first-child):not(:last-child)]:rounded-none",
35932
+ variants: {
35933
+ orientation: {
35934
+ horizontal: "flex-row [&>*:first-child]:rounded-r-none [&>*:last-child]:rounded-l-none",
35935
+ vertical: "flex-col [&>*:first-child]:rounded-b-none [&>*:last-child]:rounded-t-none"
34538
35936
  }
35937
+ },
35938
+ defaultVariants: {
35939
+ orientation: "horizontal"
34539
35940
  }
34540
- for (let i2 = 0; i2 < lines.length; i2++) {
34541
- const line = lines[i2];
34542
- if (line.trimStart().startsWith("```")) {
34543
- if (inCodeBlock) {
34544
- outputLines.push(`<pre><code${codeBlockLang ? ` class="language-${escapeHtml(codeBlockLang)}"` : ""}>${escapeHtml(codeBlockContent.join("\n"))}</code></pre>`);
34545
- codeBlockContent = [];
34546
- codeBlockLang = "";
34547
- inCodeBlock = false;
34548
- } else {
34549
- closeList();
34550
- closeBlockquote();
34551
- inCodeBlock = true;
34552
- codeBlockLang = line.trimStart().slice(3).trim();
34553
- }
34554
- continue;
34555
- }
34556
- if (inCodeBlock) {
34557
- codeBlockContent.push(line);
34558
- continue;
34559
- }
34560
- if (/^(\s*[-*_]\s*){3,}$/.test(line)) {
34561
- closeList();
34562
- closeBlockquote();
34563
- outputLines.push("<hr />");
34564
- continue;
34565
- }
34566
- const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
34567
- if (headingMatch) {
34568
- closeList();
34569
- closeBlockquote();
34570
- const level = headingMatch[1].length;
34571
- const text = parseInline(headingMatch[2], linkResolver);
34572
- outputLines.push(`<h${level}>${text}</h${level}>`);
34573
- continue;
35941
+ });
35942
+ var inputGroupAddonVariants = cva({
35943
+ base: "flex items-center justify-center border bg-muted px-3 text-sm text-muted-foreground",
35944
+ variants: {
35945
+ orientation: {
35946
+ horizontal: "border-y border-x first:border-r-0 last:border-l-0",
35947
+ vertical: "border-x border-y first:border-b-0 last:border-t-0"
34574
35948
  }
34575
- const blockquoteMatch = line.match(/^>\s?(.*)$/);
34576
- if (blockquoteMatch) {
34577
- closeList();
34578
- if (!inBlockquote) {
34579
- inBlockquote = true;
34580
- outputLines.push("<blockquote>");
34581
- }
34582
- const text = blockquoteMatch[1].trim();
34583
- if (text) {
34584
- outputLines.push(`<p>${parseInline(text, linkResolver)}</p>`);
34585
- }
34586
- continue;
34587
- } else if (inBlockquote) {
34588
- closeBlockquote();
35949
+ },
35950
+ defaultVariants: {
35951
+ orientation: "horizontal"
35952
+ }
35953
+ });
35954
+ var inputGroupButtonVariants = cva({
35955
+ base: "relative inline-flex items-center justify-center whitespace-nowrap text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
35956
+ variants: {
35957
+ orientation: {
35958
+ horizontal: "",
35959
+ vertical: ""
34589
35960
  }
34590
- const ulMatch = line.match(/^[\s]*[-*+]\s+(.+)$/);
34591
- if (ulMatch) {
34592
- closeBlockquote();
34593
- if (inList !== "ul") {
34594
- closeList();
34595
- inList = "ul";
34596
- outputLines.push("<ul>");
35961
+ },
35962
+ defaultVariants: {
35963
+ orientation: "horizontal"
35964
+ }
35965
+ });
35966
+ var InputGroup = React11__namespace.forwardRef(
35967
+ ({ orientation = "horizontal", className, children, ...props }, ref) => {
35968
+ const api = createInputGroup({
35969
+ orientation,
35970
+ id: props.id,
35971
+ "aria-label": props["aria-label"],
35972
+ "aria-labelledby": props["aria-labelledby"]
35973
+ });
35974
+ return /* @__PURE__ */ jsxRuntime.jsx(
35975
+ "div",
35976
+ {
35977
+ ref,
35978
+ className: cn(inputGroupVariants({ orientation }), className),
35979
+ ...api.ariaProps,
35980
+ ...api.dataAttributes,
35981
+ ...props,
35982
+ children
34597
35983
  }
34598
- outputLines.push(`<li>${parseInline(ulMatch[1], linkResolver)}</li>`);
34599
- continue;
34600
- }
34601
- const olMatch = line.match(/^[\s]*\d+\.\s+(.+)$/);
34602
- if (olMatch) {
34603
- closeBlockquote();
34604
- if (inList !== "ol") {
34605
- closeList();
34606
- inList = "ol";
34607
- outputLines.push("<ol>");
35984
+ );
35985
+ }
35986
+ );
35987
+ InputGroup.displayName = "InputGroup";
35988
+ var InputGroupAddon = React11__namespace.forwardRef(
35989
+ ({ orientation = "horizontal", className, children, ...props }, ref) => {
35990
+ return /* @__PURE__ */ jsxRuntime.jsx(
35991
+ "div",
35992
+ {
35993
+ ref,
35994
+ className: cn(inputGroupAddonVariants({ orientation }), className),
35995
+ ...props,
35996
+ children
34608
35997
  }
34609
- outputLines.push(`<li>${parseInline(olMatch[1], linkResolver)}</li>`);
34610
- continue;
34611
- }
34612
- if (inList) {
34613
- closeList();
34614
- }
34615
- if (line.trim() === "") {
34616
- continue;
34617
- }
34618
- outputLines.push(`<p>${parseInline(line, linkResolver)}</p>`);
35998
+ );
34619
35999
  }
34620
- if (inCodeBlock) {
34621
- outputLines.push(`<pre><code${codeBlockLang ? ` class="language-${escapeHtml(codeBlockLang)}"` : ""}>${escapeHtml(codeBlockContent.join("\n"))}</code></pre>`);
36000
+ );
36001
+ InputGroupAddon.displayName = "InputGroupAddon";
36002
+ var InputGroupText = React11__namespace.forwardRef(
36003
+ ({ className, children, ...props }, ref) => {
36004
+ return /* @__PURE__ */ jsxRuntime.jsx(
36005
+ "span",
36006
+ {
36007
+ ref,
36008
+ className: cn("flex items-center px-3 text-sm text-muted-foreground", className),
36009
+ ...props,
36010
+ children
36011
+ }
36012
+ );
34622
36013
  }
34623
- closeList();
34624
- closeBlockquote();
34625
- return outputLines.join("\n");
34626
- }
34627
- function extractComponents(content, components) {
34628
- if (!components) return [];
34629
- const extracted = [];
34630
- for (const [name, def] of Object.entries(components)) {
34631
- const matches = Array.from(content.matchAll(def.pattern));
34632
- matches.forEach(() => {
34633
- extracted.push({
34634
- name,
34635
- props: { ...def.props }
34636
- });
34637
- });
36014
+ );
36015
+ InputGroupText.displayName = "InputGroupText";
36016
+ var InputGroupButton = React11__namespace.forwardRef(
36017
+ ({ orientation = "horizontal", className, children, ...props }, ref) => {
36018
+ return /* @__PURE__ */ jsxRuntime.jsx(
36019
+ "button",
36020
+ {
36021
+ ref,
36022
+ type: props.type ?? "button",
36023
+ className: cn(inputGroupButtonVariants({ orientation }), className),
36024
+ ...props,
36025
+ children
36026
+ }
36027
+ );
34638
36028
  }
34639
- return extracted;
34640
- }
34641
- function createMarkdownRenderer(props) {
34642
- const { content, components, linkResolver } = props;
34643
- const html = parseMarkdown(content, linkResolver);
34644
- const extractedComponents = extractComponents(content, components);
34645
- const ariaProps = {
34646
- role: "document",
34647
- "aria-label": "Rendered markdown content"
36029
+ );
36030
+ InputGroupButton.displayName = "InputGroupButton";
36031
+
36032
+ // ../install-prompt/dist/index.js
36033
+ function createInstallPrompt(props = {}, storage) {
36034
+ const { storageKey = "rfr-install-dismissed" } = props;
36035
+ const dismissed = storage?.get(storageKey) === "true";
36036
+ const state = {
36037
+ canShow: false,
36038
+ isDismissed: dismissed
34648
36039
  };
34649
36040
  return {
34650
- html,
34651
- components: extractedComponents,
34652
- ariaProps
36041
+ state,
36042
+ show() {
36043
+ if (!state.isDismissed) {
36044
+ state.canShow = true;
36045
+ }
36046
+ },
36047
+ dismiss() {
36048
+ state.canShow = false;
36049
+ state.isDismissed = true;
36050
+ storage?.set(storageKey, "true");
36051
+ },
36052
+ install(promptEvent) {
36053
+ promptEvent?.prompt();
36054
+ state.canShow = false;
36055
+ },
36056
+ ariaProps: {
36057
+ role: "banner",
36058
+ "aria-label": "Install application"
36059
+ }
34653
36060
  };
34654
36061
  }
34655
- var markdownRendererTokens = {
34656
- name: "markdown-renderer",
34657
- tokens: {
34658
- bg: { variable: "--rfr-markdown-bg", fallback: "hsl(var(--background))" },
34659
- fg: { variable: "--rfr-markdown-fg", fallback: "hsl(var(--foreground))" },
34660
- codeBg: { variable: "--rfr-markdown-code-bg", fallback: "hsl(var(--muted))" },
34661
- linkColor: { variable: "--rfr-markdown-link", fallback: "hsl(var(--primary))" },
34662
- borderColor: { variable: "--rfr-markdown-border", fallback: "hsl(var(--border))" }
34663
- }
34664
- };
34665
- var proseVariants = cva({
34666
- base: "prose max-w-none text-foreground leading-relaxed",
34667
- variants: {
34668
- size: {
34669
- sm: "prose-sm text-sm",
34670
- default: "prose-base text-base",
34671
- lg: "prose-lg text-lg"
36062
+ var installPromptVariants = cva({
36063
+ base: "fixed bottom-0 left-0 right-0 z-50 flex items-center justify-between gap-4 border-t bg-background px-4 py-3 shadow-lg"
36064
+ });
36065
+ function createLocalStorage() {
36066
+ return {
36067
+ get(key) {
36068
+ try {
36069
+ return localStorage.getItem(key);
36070
+ } catch {
36071
+ return null;
36072
+ }
34672
36073
  },
34673
- theme: {
34674
- light: "bg-white text-gray-900",
34675
- dark: "bg-gray-900 text-gray-100"
36074
+ set(key, value) {
36075
+ try {
36076
+ localStorage.setItem(key, value);
36077
+ } catch {
36078
+ }
34676
36079
  }
34677
- },
34678
- defaultVariants: {
34679
- size: "default"
34680
- }
34681
- });
34682
- function sanitizeHtml(html) {
34683
- let sanitized = html;
34684
- sanitized = sanitized.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
34685
- sanitized = sanitized.replace(/<\/?script[^>]*>/gi, "");
34686
- sanitized = sanitized.replace(/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "");
34687
- sanitized = sanitized.replace(/(href|src)\s*=\s*["']?\s*javascript\s*:[^"'>]*/gi, '$1=""');
34688
- return sanitized;
36080
+ };
34689
36081
  }
34690
- var MarkdownRenderer = React11__namespace.forwardRef(
34691
- ({ content, components, linkResolver, className, size }, ref) => {
34692
- const coreProps = { content, components, linkResolver };
34693
- const api = createMarkdownRenderer(coreProps);
34694
- const classes = cn(proseVariants({ size }), className);
34695
- const sanitizedHtml = sanitizeHtml(api.html);
34696
- return /* @__PURE__ */ jsxRuntime.jsx(
34697
- "div",
34698
- {
34699
- ref,
34700
- className: classes,
34701
- ...api.ariaProps,
34702
- dangerouslySetInnerHTML: { __html: sanitizedHtml }
34703
- }
34704
- );
36082
+ var InstallPrompt = React11__namespace.forwardRef(
36083
+ ({
36084
+ delay = 3e3,
36085
+ storageKey,
36086
+ installLabel = "Install",
36087
+ dismissLabel = "Dismiss",
36088
+ message = "Install this app for a better experience",
36089
+ className,
36090
+ ...props
36091
+ }, ref) => {
36092
+ const storageRef = React11__namespace.useRef(void 0);
36093
+ if (typeof window !== "undefined" && !storageRef.current) {
36094
+ storageRef.current = createLocalStorage();
36095
+ }
36096
+ const api = createInstallPrompt({ storageKey }, storageRef.current);
36097
+ const [visible, setVisible] = React11__namespace.useState(false);
36098
+ const promptEventRef = React11__namespace.useRef(null);
36099
+ React11__namespace.useEffect(() => {
36100
+ if (api.state.isDismissed) return;
36101
+ const handleBeforeInstall = (e2) => {
36102
+ e2.preventDefault();
36103
+ promptEventRef.current = e2;
36104
+ };
36105
+ window.addEventListener("beforeinstallprompt", handleBeforeInstall);
36106
+ const timer = setTimeout(() => {
36107
+ if (promptEventRef.current && !api.state.isDismissed) {
36108
+ api.show();
36109
+ setVisible(true);
36110
+ }
36111
+ }, delay);
36112
+ return () => {
36113
+ window.removeEventListener("beforeinstallprompt", handleBeforeInstall);
36114
+ clearTimeout(timer);
36115
+ };
36116
+ }, [delay, api]);
36117
+ if (!visible) return null;
36118
+ const classes = cn(installPromptVariants(), className);
36119
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: classes, ...api.ariaProps, ...props, children: [
36120
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: message }),
36121
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
36122
+ /* @__PURE__ */ jsxRuntime.jsx(
36123
+ "button",
36124
+ {
36125
+ type: "button",
36126
+ onClick: () => {
36127
+ api.install(promptEventRef.current ?? void 0);
36128
+ setVisible(false);
36129
+ },
36130
+ children: installLabel
36131
+ }
36132
+ ),
36133
+ /* @__PURE__ */ jsxRuntime.jsx(
36134
+ "button",
36135
+ {
36136
+ type: "button",
36137
+ onClick: () => {
36138
+ api.dismiss();
36139
+ setVisible(false);
36140
+ },
36141
+ children: dismissLabel
36142
+ }
36143
+ )
36144
+ ] })
36145
+ ] });
34705
36146
  }
34706
36147
  );
34707
- MarkdownRenderer.displayName = "MarkdownRenderer";
36148
+ InstallPrompt.displayName = "InstallPrompt";
34708
36149
 
34709
36150
  // ../mobile-nav/dist/index.js
34710
36151
  function createMobileNav(props = {}) {
@@ -39522,7 +40963,7 @@ var AvatarContext = React11__namespace.createContext({
39522
40963
  setImageError: () => {
39523
40964
  }
39524
40965
  });
39525
- var Avatar = React11__namespace.forwardRef(
40966
+ var Avatar2 = React11__namespace.forwardRef(
39526
40967
  ({ size = "md", className, children, ...props }, ref) => {
39527
40968
  const [imageLoaded, setImageLoaded] = React11__namespace.useState(false);
39528
40969
  const [imageError, setImageError] = React11__namespace.useState(false);
@@ -39540,7 +40981,7 @@ var Avatar = React11__namespace.forwardRef(
39540
40981
  ) });
39541
40982
  }
39542
40983
  );
39543
- Avatar.displayName = "Avatar";
40984
+ Avatar2.displayName = "Avatar";
39544
40985
  var AvatarImage = React11__namespace.forwardRef(
39545
40986
  ({ className, src, alt = "", onLoad, onError, ...props }, ref) => {
39546
40987
  const { setImageLoaded, setImageError } = React11__namespace.useContext(AvatarContext);
@@ -40133,10 +41574,10 @@ function createDatePicker(props = {}) {
40133
41574
  closePicker();
40134
41575
  }
40135
41576
  }
40136
- function setHours(h2) {
40137
- if (h2 < 0 || h2 > 23) return;
41577
+ function setHours(h5) {
41578
+ if (h5 < 0 || h5 > 23) return;
40138
41579
  const newDate = value ? new Date(value) : /* @__PURE__ */ new Date();
40139
- newDate.setHours(h2);
41580
+ newDate.setHours(h5);
40140
41581
  onChange?.(newDate);
40141
41582
  }
40142
41583
  function setMinutes(m2) {
@@ -40328,10 +41769,10 @@ function DatePicker({
40328
41769
  }
40329
41770
  };
40330
41771
  const handleHoursChange = (e2) => {
40331
- const h2 = parseInt(e2.target.value, 10);
40332
- if (isNaN(h2) || h2 < 0 || h2 > 23) return;
41772
+ const h5 = parseInt(e2.target.value, 10);
41773
+ if (isNaN(h5) || h5 < 0 || h5 > 23) return;
40333
41774
  const newDate = value ? new Date(value) : /* @__PURE__ */ new Date();
40334
- newDate.setHours(h2);
41775
+ newDate.setHours(h5);
40335
41776
  onChange?.(newDate);
40336
41777
  };
40337
41778
  const handleMinutesChange = (e2) => {
@@ -42505,102 +43946,6 @@ var Switch = React11__namespace.forwardRef(
42505
43946
  }
42506
43947
  );
42507
43948
  Switch.displayName = "Switch";
42508
-
42509
- // ../thread-view/dist/index.js
42510
- function formatTimestamp(date) {
42511
- const hours = date.getHours();
42512
- const minutes = date.getMinutes();
42513
- const ampm = hours >= 12 ? "PM" : "AM";
42514
- const displayHours = hours % 12 || 12;
42515
- const displayMinutes = minutes < 10 ? `0${minutes}` : `${minutes}`;
42516
- return `${displayHours}:${displayMinutes} ${ampm}`;
42517
- }
42518
- function formatRelativeTime(date, now) {
42519
- const reference = now ?? /* @__PURE__ */ new Date();
42520
- const diffMs = reference.getTime() - date.getTime();
42521
- const diffSeconds = Math.floor(diffMs / 1e3);
42522
- const diffMinutes = Math.floor(diffSeconds / 60);
42523
- const diffHours = Math.floor(diffMinutes / 60);
42524
- const diffDays = Math.floor(diffHours / 24);
42525
- if (diffSeconds < 60) return "just now";
42526
- if (diffMinutes < 60) return `${diffMinutes} minute${diffMinutes === 1 ? "" : "s"} ago`;
42527
- if (diffHours < 24) return `${diffHours} hour${diffHours === 1 ? "" : "s"} ago`;
42528
- if (diffDays < 7) return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
42529
- return date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
42530
- }
42531
- function createThreadView(props) {
42532
- const { messages, onReply, onReact, currentUserId } = props;
42533
- let replyingTo = null;
42534
- const threadId = generateId("rfr-thread");
42535
- const labelId = generateId("rfr-thread-label");
42536
- function startReply(messageId) {
42537
- replyingTo = messageId;
42538
- }
42539
- function cancelReply() {
42540
- replyingTo = null;
42541
- }
42542
- function reply(messageId, content) {
42543
- onReply?.(messageId, content);
42544
- replyingTo = null;
42545
- }
42546
- function react(messageId, emoji) {
42547
- onReact?.(messageId, emoji);
42548
- }
42549
- const ariaProps = {
42550
- role: "log",
42551
- "aria-label": "Message thread",
42552
- "aria-live": "polite",
42553
- id: threadId
42554
- };
42555
- function getMessageAriaProps(message) {
42556
- const isOwn = currentUserId && message.author.id === currentUserId;
42557
- return {
42558
- role: "article",
42559
- "aria-label": `Message from ${message.author.name}${isOwn ? " (you)" : ""} at ${formatTimestamp(message.timestamp)}`
42560
- };
42561
- }
42562
- function getReplyButtonAriaProps(_messageId) {
42563
- return {
42564
- role: "button",
42565
- "aria-label": `Reply to message`
42566
- };
42567
- }
42568
- return {
42569
- state: {
42570
- messages,
42571
- get replyingTo() {
42572
- return replyingTo;
42573
- }
42574
- },
42575
- startReply,
42576
- cancelReply,
42577
- reply,
42578
- react,
42579
- formatTimestamp,
42580
- formatRelativeTime,
42581
- ariaProps,
42582
- getMessageAriaProps,
42583
- getReplyButtonAriaProps,
42584
- ids: {
42585
- thread: threadId,
42586
- label: labelId
42587
- }
42588
- };
42589
- }
42590
- var threadContainerStyles = "flex flex-col gap-1";
42591
- var threadMessageStyles = "flex gap-3 px-4 py-2 hover:bg-accent/50 rounded-md transition-colors group";
42592
- var threadAvatarStyles = "h-9 w-9 rounded-full bg-muted flex items-center justify-center text-sm font-medium overflow-hidden flex-shrink-0";
42593
- var threadContentStyles = "flex-1 min-w-0";
42594
- var threadAuthorStyles = "font-semibold text-sm";
42595
- var threadTimestampStyles = "text-xs text-muted-foreground ml-2";
42596
- var threadBodyStyles = "text-sm mt-0.5 whitespace-pre-wrap break-words";
42597
- var threadReactionsStyles = "flex flex-wrap gap-1 mt-1";
42598
- var threadReplyIndicatorStyles = "flex items-center gap-1 mt-1 text-xs text-primary cursor-pointer hover:underline";
42599
- var threadActionsStyles = "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity";
42600
- var threadAttachmentStyles = "flex items-center gap-2 mt-1 p-2 rounded border text-xs bg-muted/50";
42601
- var threadEditedStyles = "text-xs text-muted-foreground ml-1";
42602
-
42603
- // ../react-thread-view/dist/index.js
42604
43949
  function MessageComponent({
42605
43950
  message,
42606
43951
  api
@@ -42712,11 +44057,11 @@ ThreadView.displayName = "ThreadView";
42712
44057
  // ../table-of-contents/dist/index.js
42713
44058
  function parseHeadings(container, selectors = "h2, h3, h4") {
42714
44059
  const headings = Array.from(container.querySelectorAll(selectors));
42715
- return headings.map((h2) => ({
42716
- id: h2.id || h2.textContent?.toLowerCase().replace(/\s+/g, "-") || "",
42717
- text: h2.textContent || "",
42718
- level: parseInt(h2.tagName.charAt(1), 10)
42719
- })).filter((h2) => h2.id !== "");
44060
+ return headings.map((h5) => ({
44061
+ id: h5.id || h5.textContent?.toLowerCase().replace(/\s+/g, "-") || "",
44062
+ text: h5.textContent || "",
44063
+ level: parseInt(h5.tagName.charAt(1), 10)
44064
+ })).filter((h5) => h5.id !== "");
42720
44065
  }
42721
44066
  function observeHeadings(headingIds, callback, options) {
42722
44067
  const observer = new IntersectionObserver((entries) => {
@@ -42743,7 +44088,7 @@ var TableOfContents = React11__namespace.forwardRef(
42743
44088
  const parsedHeadings = parseHeadings(container, selectors);
42744
44089
  setHeadings(parsedHeadings);
42745
44090
  if (parsedHeadings.length === 0) return;
42746
- const disconnect = observeHeadings(parsedHeadings.map((h2) => h2.id), (id) => {
44091
+ const disconnect = observeHeadings(parsedHeadings.map((h5) => h5.id), (id) => {
42747
44092
  setActiveId(id);
42748
44093
  onActiveIdChange?.(id);
42749
44094
  });
@@ -43874,7 +45219,7 @@ function resolveStorage(override) {
43874
45219
  return createMemoryStorage();
43875
45220
  }
43876
45221
  var DEFAULT_SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
43877
- var DEFAULT_KEY = "rfx:analytics:session";
45222
+ var DEFAULT_KEY2 = "rfx:analytics:session";
43878
45223
  var CAMPAIGN_PARAMS = [
43879
45224
  "utm_source",
43880
45225
  "utm_medium",
@@ -43905,7 +45250,7 @@ function campaignFingerprint(search) {
43905
45250
  }
43906
45251
  function createSession(config, now = () => Date.now()) {
43907
45252
  const storage = resolveStorage(config?.storage);
43908
- const key = config?.storageKey ?? DEFAULT_KEY;
45253
+ const key = config?.storageKey ?? DEFAULT_KEY2;
43909
45254
  const timeoutMs = config?.timeoutMs ?? DEFAULT_SESSION_TIMEOUT_MS;
43910
45255
  const resetOnCampaign = config?.resetOnCampaign ?? true;
43911
45256
  function read() {
@@ -43974,10 +45319,10 @@ function createSession(config, now = () => Date.now()) {
43974
45319
  }
43975
45320
  };
43976
45321
  }
43977
- var DEFAULT_KEY2 = "rfx:analytics:anon";
45322
+ var DEFAULT_KEY22 = "rfx:analytics:anon";
43978
45323
  function createIdentity(config) {
43979
45324
  const storage = resolveStorage(config?.storage);
43980
- const key = config?.storageKey ?? DEFAULT_KEY2;
45325
+ const key = config?.storageKey ?? DEFAULT_KEY22;
43981
45326
  let userId;
43982
45327
  function loadOrMintAnon() {
43983
45328
  const existing = storage.get(key);
@@ -45466,7 +46811,7 @@ exports.AnimatedText = AnimatedText;
45466
46811
  exports.AppShell = AppShell;
45467
46812
  exports.AuthGuard = AuthGuard;
45468
46813
  exports.AuthProvider = AuthProvider;
45469
- exports.Avatar = Avatar;
46814
+ exports.Avatar = Avatar2;
45470
46815
  exports.AvatarFallback = AvatarFallback;
45471
46816
  exports.AvatarGroup = AvatarGroup;
45472
46817
  exports.AvatarImage = AvatarImage;
@@ -45494,6 +46839,7 @@ exports.Carousel = Carousel;
45494
46839
  exports.CarouselContent = CarouselContent;
45495
46840
  exports.CarouselItem = CarouselItem;
45496
46841
  exports.CarouselTrigger = CarouselTrigger;
46842
+ exports.Chat = Chat;
45497
46843
  exports.Checkbox = Checkbox;
45498
46844
  exports.CodeBlock = CodeBlock;
45499
46845
  exports.CodeBlockContent = CodeBlockContent;
@@ -45516,7 +46862,10 @@ exports.CommandInput = CommandInput;
45516
46862
  exports.CommandItem = CommandItem;
45517
46863
  exports.CommandList = CommandList;
45518
46864
  exports.CommandSeparator = CommandSeparator;
46865
+ exports.Composer = Composer;
45519
46866
  exports.ContentProtection = ContentProtection;
46867
+ exports.CookieConsent = CookieConsent;
46868
+ exports.DEFAULT_CATEGORIES = DEFAULT_CATEGORIES;
45520
46869
  exports.DEFAULT_VOICE_PILL_POSITION = DEFAULT_VOICE_PILL_POSITION;
45521
46870
  exports.DEFAULT_VOICE_PILL_SPEAKER = DEFAULT_VOICE_PILL_SPEAKER;
45522
46871
  exports.DEFAULT_WAVEFORM_BAR_COUNT = DEFAULT_WAVEFORM_BAR_COUNT;
@@ -45691,6 +47040,8 @@ exports.controlsVariants = controlsVariants;
45691
47040
  exports.createAnalytics = createAnalytics;
45692
47041
  exports.createAppInsightsSink = createAppInsightsSink;
45693
47042
  exports.createConsoleSink = createConsoleSink;
47043
+ exports.createConversation = createConversation;
47044
+ exports.createCookieConsent = createCookieConsent;
45694
47045
  exports.createFaroSink = createFaroSink;
45695
47046
  exports.createGA4ClientSdkSink = createGA4ClientSdkSink;
45696
47047
  exports.createGA4HttpSink = createGA4HttpSink;
@@ -45715,6 +47066,7 @@ exports.feedbackDialogVariants = feedbackDialogVariants;
45715
47066
  exports.fileUploadDropZoneVariants = fileUploadDropZoneVariants;
45716
47067
  exports.fileUploadFileItemStyles = fileUploadFileItemStyles;
45717
47068
  exports.fileUploadFileListStyles = fileUploadFileListStyles;
47069
+ exports.findMessage = findMessage;
45718
47070
  exports.footerVariants = footerVariants;
45719
47071
  exports.formatFileSize = formatFileSize;
45720
47072
  exports.formatRelativeTime = formatRelativeTime;
@@ -45723,6 +47075,7 @@ exports.formatTimestamp = formatTimestamp;
45723
47075
  exports.getAssignableRoles = getAssignableRoles;
45724
47076
  exports.getDefaultPortal = getDefaultPortal;
45725
47077
  exports.getInitials = getInitials;
47078
+ exports.getReplyCount = getReplyCount;
45726
47079
  exports.getVoicePillAriaLabel = getVoicePillAriaLabel;
45727
47080
  exports.getVoicePillInitials = getVoicePillInitials;
45728
47081
  exports.getVoicePillPosition = getVoicePillPosition;
@@ -45784,12 +47137,18 @@ exports.resizableDividerVariants = resizableDividerVariants;
45784
47137
  exports.resizableLayoutTokens = resizableLayoutTokens;
45785
47138
  exports.resizableLayoutVariants = resizableLayoutVariants;
45786
47139
  exports.resizablePaneVariants = resizablePaneVariants;
47140
+ exports.rootIdOf = rootIdOf;
45787
47141
  exports.rowVariants = rowVariants;
45788
47142
  exports.scaleWaveformSamples = scaleWaveformSamples;
45789
47143
  exports.searchBarVariants = searchBarVariants;
45790
47144
  exports.searchResultVariants = searchResultVariants;
45791
47145
  exports.selectContentVariants = selectContentVariants;
45792
47146
  exports.selectItemVariants = selectItemVariants;
47147
+ exports.selectMainTimeline = selectMainTimeline;
47148
+ exports.selectReplies = selectReplies;
47149
+ exports.selectRoots = selectRoots;
47150
+ exports.selectThreadMessages = selectThreadMessages;
47151
+ exports.selectTimelineFromState = selectTimelineFromState;
45793
47152
  exports.selectTokens = selectTokens;
45794
47153
  exports.selectTriggerVariants = selectTriggerVariants;
45795
47154
  exports.selectorVariants = selectorVariants;
@@ -45835,6 +47194,8 @@ exports.tooltipContentVariants = tooltipContentVariants;
45835
47194
  exports.typewriterVariants = typewriterVariants;
45836
47195
  exports.useAnalytics = useAnalytics;
45837
47196
  exports.useAuth = useAuth;
47197
+ exports.useConversation = useConversation;
47198
+ exports.useCookieConsent = useCookieConsent;
45838
47199
  exports.useLogger = useLogger;
45839
47200
  exports.useShortcut = useShortcut;
45840
47201
  exports.useSpan = useSpan;