@pluno/product-agent-web 0.1.75 → 0.1.76

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.
@@ -2,10 +2,10 @@ import { PlunoProductAgent as ti, getProductAgentOriginAccessErrorMessage as ni
2
2
  const oi = "#7c3aed", mt = "M547 151 C516 151 493 169 485 199 L382 606 C373 641 396 666 431 666 L523 666 C552 666 568 684 563 713 L491 1028 C486 1054 510 1067 527 1044 L894 487 C915 455 894 432 856 432 L815 432 C784 432 773 411 789 382 L904 205 C922 171 901 145 859 145 Z", ft = "#2c2a1e", Pn = [253, 250, 241], Tn = 3.5;
3
3
  function lo(e) {
4
4
  const t = po(e);
5
- if (In(ot(t), Pn) >= Tn)
5
+ if (In(nt(t), Pn) >= Tn)
6
6
  return t;
7
- let o = ot(t);
8
- const i = ot(ft);
7
+ let o = nt(t);
8
+ const i = nt(ft);
9
9
  for (let r = 0; r < 6; r += 1)
10
10
  if (o = ri(o, i, 0.22), In(o, Pn) >= Tn)
11
11
  return Xt(o);
@@ -20,7 +20,7 @@ function ii() {
20
20
  return n;
21
21
  }
22
22
  function ai(e) {
23
- const t = po(e), n = Zt(ot(t));
23
+ const t = po(e), n = Zt(nt(t));
24
24
  return n > 0.86 ? {
25
25
  top: "#ffffff",
26
26
  middle: "#f6f6f6",
@@ -60,7 +60,7 @@ function po(e) {
60
60
  const t = e.trim();
61
61
  return /^#[0-9a-f]{6}$/i.test(t) ? t.toLowerCase() : /^#[0-9a-f]{3}$/i.test(t) ? `#${t.slice(1).split("").map((n) => n + n).join("").toLowerCase()}` : oi;
62
62
  }
63
- function ot(e) {
63
+ function nt(e) {
64
64
  return [
65
65
  Number.parseInt(e.slice(1, 3), 16),
66
66
  Number.parseInt(e.slice(3, 5), 16),
@@ -91,7 +91,7 @@ function ri(e, t, n) {
91
91
  ];
92
92
  }
93
93
  function ie(e, t, n) {
94
- const [o, i, r] = li(ot(e));
94
+ const [o, i, r] = li(nt(e));
95
95
  return Xt(pi(o, Jt(i + n), Jt(r + t)));
96
96
  }
97
97
  function li([e, t, n]) {
@@ -379,11 +379,11 @@ async function ia(e = {}) {
379
379
  ".pluno-pa-widget__attachment-error"
380
380
  ), xe = i.querySelector(
381
381
  ".pluno-pa-widget__billing-status"
382
- ), We = i.querySelector(
382
+ ), He = i.querySelector(
383
383
  ".pluno-pa-widget__attachments"
384
384
  ), z = i.querySelector(
385
385
  ".pluno-pa-widget__attachment-input"
386
- ), Ge = i.querySelector(
386
+ ), We = i.querySelector(
387
387
  ".pluno-pa-widget__attach"
388
388
  ), w = i.querySelector(
389
389
  ".pluno-pa-widget__input"
@@ -397,7 +397,7 @@ async function ia(e = {}) {
397
397
  ".pluno-pa-widget__history-panel"
398
398
  ), V = i.querySelector(
399
399
  ".pluno-pa-widget__history-list"
400
- ), it = i.querySelector(
400
+ ), ot = i.querySelector(
401
401
  ".pluno-pa-widget__history-close"
402
402
  ), ne = i.querySelector(
403
403
  ".pluno-pa-widget__history-status"
@@ -418,7 +418,7 @@ async function ia(e = {}) {
418
418
  ), Uo = i.querySelector(
419
419
  ".pluno-pa-widget__notify-suggestion-never"
420
420
  );
421
- if (!v || !C || !y || !A || !N || !q || !xe || !We || !z || !Ge || !w || !U || !ye || !ve || !Ae || !V || !it || !ne || !x || !M || !T || !oe)
421
+ if (!v || !C || !y || !A || !N || !q || !xe || !He || !z || !We || !w || !U || !ye || !ve || !Ae || !V || !ot || !ne || !x || !M || !T || !oe)
422
422
  throw new Error("Failed to mount Pluno widget");
423
423
  if (t.movableLauncher && !D)
424
424
  throw new Error("Failed to mount Pluno widget drag handle");
@@ -426,7 +426,7 @@ async function ia(e = {}) {
426
426
  let j = [], se = null;
427
427
  const Ne = () => {
428
428
  ja(
429
- We,
429
+ He,
430
430
  j,
431
431
  (a) => {
432
432
  j = j.filter(
@@ -475,10 +475,10 @@ async function ia(e = {}) {
475
475
  );
476
476
  const vt = new Set(l.openToolGroupKeys), Re = new Set(
477
477
  l.seenShareCandidateIds
478
- ), at = new Set(Re);
479
- let Ct = l.sharePromptsDisabled || await Er(t), J = null, de = !1, De = !(t.loginRequired || t.signupRequired), he = !1, Ce = {
478
+ ), it = new Set(Re);
479
+ let Ct = l.sharePromptsDisabled || await Er(t), J = null, de = !1, at = !(t.loginRequired || t.signupRequired), he = !1, Ce = {
480
480
  enabled: !0
481
- }, Se = 0, hn = "", me = !1, ce = !1, fe = [], St = null, $e = null;
481
+ }, Se = 0, hn = "", me = !1, ce = !1, fe = [], St = null, Ge = null;
482
482
  const Q = (a, d) => {
483
483
  Ce = { enabled: a, reason: d };
484
484
  }, ee = () => {
@@ -486,7 +486,7 @@ async function ia(e = {}) {
486
486
  }, Fo = () => {
487
487
  x.hidden = !1;
488
488
  }, Ho = (a = "jump") => {
489
- Q(!0, a), ee(), nt(T, () => Ce.enabled), Se = T.scrollTop;
489
+ Q(!0, a), ee(), tt(T, () => Ce.enabled), Se = T.scrollTop;
490
490
  }, Ee = () => {
491
491
  if (ve.hidden = t.loginRequired, Ae.hidden = !me, ve.setAttribute("aria-expanded", String(me)), V.classList.toggle(
492
492
  "pluno-pa-widget__history-list--center",
@@ -507,17 +507,17 @@ async function ia(e = {}) {
507
507
  );
508
508
  const O = document.createElement("small");
509
509
  O.className = "pluno-pa-widget__history-path", O.textContent = Ea(a), d.append(_, P, O), d.addEventListener("click", () => {
510
- me = !1, $e = null, Ee(), Q(!0, "newSession"), ee(), b.loadSession(a.id), H(b.getState());
510
+ me = !1, Ge = null, Ee(), Q(!0, "newSession"), ee(), b.loadSession(a.id), H(b.getState());
511
511
  }), V.appendChild(d);
512
512
  }
513
513
  if (ce && fe.length > 0) {
514
514
  const a = document.createElement("p");
515
515
  a.className = "pluno-pa-widget__history-loading pluno-pa-widget__history-loading--inline", a.textContent = "Loading...", V.appendChild(a);
516
516
  }
517
- ne.textContent = $e ?? (!ce && fe.length === 0 ? "No recent chats for this page yet." : ""), ne.hidden = ne.textContent.length === 0;
517
+ ne.textContent = Ge ?? (!ce && fe.length === 0 ? "No recent chats for this page yet." : ""), ne.hidden = ne.textContent.length === 0;
518
518
  }, mn = async (a) => {
519
519
  if (!ce) {
520
- ce = !0, $e = null, Ee();
520
+ ce = !0, Ge = null, Ee();
521
521
  try {
522
522
  const d = await b.listSessions({ cursor: a, limit: 20 });
523
523
  fe = a ? [...fe, ...d.sessions] : d.sessions, St = d.nextCursor;
@@ -528,7 +528,7 @@ async function ia(e = {}) {
528
528
  {
529
529
  message: d instanceof Error ? d.message : String(d)
530
530
  }
531
- ), $e = Wi;
531
+ ), Ge = Wi;
532
532
  } finally {
533
533
  ce = !1, Ee();
534
534
  }
@@ -542,7 +542,7 @@ async function ia(e = {}) {
542
542
  childList: !0,
543
543
  subtree: !0
544
544
  }), fn();
545
- const qe = (a = !0) => {
545
+ const $e = (a = !0) => {
546
546
  const d = wt(i, a);
547
547
  return on(
548
548
  i,
@@ -570,9 +570,9 @@ async function ia(e = {}) {
570
570
  });
571
571
  }, rt = (a) => {
572
572
  t.onDisplayStateChange?.(a);
573
- }, je = (a, d = !0) => {
573
+ }, qe = (a, d = !0) => {
574
574
  if (a === "shown") {
575
- i.classList.remove("pluno-pa-widget--minimized"), v.removeAttribute("tabindex"), !i.classList.contains("pluno-pa-widget--open") && !i.classList.contains("pluno-pa-widget--closing") && Ve(!1), d && rt("shown");
575
+ i.classList.remove("pluno-pa-widget--minimized"), v.removeAttribute("tabindex"), !i.classList.contains("pluno-pa-widget--open") && !i.classList.contains("pluno-pa-widget--closing") && je(!1), d && rt("shown");
576
576
  return;
577
577
  }
578
578
  J !== null && (window.clearTimeout(J), J = null), i.classList.remove("pluno-pa-widget--open"), i.classList.remove("pluno-pa-widget--closing"), i.classList.add("pluno-pa-widget--minimized"), v.hidden = !1, y.hidden = !0, A.hidden = !0, v.tabIndex = 0, w.value = "", Te(
@@ -602,10 +602,10 @@ async function ia(e = {}) {
602
602
  closeHidden: A.hidden,
603
603
  ...d
604
604
  });
605
- }, Ve = (a = !0) => {
605
+ }, je = (a = !0) => {
606
606
  if (!p)
607
- return Te(i, null), qe(a);
608
- const d = qe(a);
607
+ return Te(i, null), $e(a);
608
+ const d = $e(a);
609
609
  return Te(i, d), ke("Applied stored closed launcher position", {
610
610
  visibleLauncherPosition: d
611
611
  }), d;
@@ -630,10 +630,10 @@ async function ia(e = {}) {
630
630
  );
631
631
  return;
632
632
  }
633
- const a = Ve();
633
+ const a = je();
634
634
  if (i.classList.contains("pluno-pa-widget--open") || i.classList.contains("pluno-pa-widget--closing")) {
635
635
  Ht(i, c);
636
- const d = He(c);
636
+ const d = Fe(c);
637
637
  jt(
638
638
  h,
639
639
  d.width
@@ -658,11 +658,11 @@ async function ia(e = {}) {
658
658
  };
659
659
  let _n = () => {
660
660
  };
661
- window.addEventListener("resize", bn), t.movableLauncher && D ? (Ve(), _n = sa({
661
+ window.addEventListener("resize", bn), t.movableLauncher && D ? (je(), _n = sa({
662
662
  root: i,
663
663
  launcher: v,
664
664
  launcherDragHandle: D,
665
- getPosition: () => qe(),
665
+ getPosition: () => $e(),
666
666
  setPosition: (a) => {
667
667
  const d = a, _ = wt(i), P = on(
668
668
  i,
@@ -681,7 +681,7 @@ async function ia(e = {}) {
681
681
  }
682
682
  })) : Te(i, null), Ht(i, c);
683
683
  const Go = () => {
684
- const a = He(c), d = qe();
684
+ const a = Fe(c), d = $e();
685
685
  return {
686
686
  position: ht(
687
687
  u ?? Gt(
@@ -697,12 +697,12 @@ async function ia(e = {}) {
697
697
  }, $o = (a) => {
698
698
  c = _t(a.size), Ht(i, c), jt(
699
699
  h,
700
- He(c).width
700
+ Fe(c).width
701
701
  ), u = ht(
702
702
  a.position,
703
- He(c)
703
+ Fe(c)
704
704
  );
705
- const d = qe();
705
+ const d = $e();
706
706
  Et(u, d);
707
707
  }, qo = S.length > 0 ? da({
708
708
  root: i,
@@ -732,11 +732,11 @@ async function ia(e = {}) {
732
732
  }
733
733
  }
734
734
  }, we = (a = "", d = !0) => {
735
- xn(), Xe && (Xe = !1, Tt()), i.classList.contains("pluno-pa-widget--open") || (u = null), J !== null && (window.clearTimeout(J), J = null), je("shown", !1), y.hidden = !1, A.hidden = !1, jt(
735
+ xn(), Ye && (Ye = !1, Tt()), i.classList.contains("pluno-pa-widget--open") || (u = null), J !== null && (window.clearTimeout(J), J = null), qe("shown", !1), y.hidden = !1, A.hidden = !1, jt(
736
736
  h,
737
- He(c).width
737
+ Fe(c).width
738
738
  ), i.classList.remove("pluno-pa-widget--closing");
739
- const _ = Ve(), P = Gt(
739
+ const _ = je(), P = Gt(
740
740
  i,
741
741
  _,
742
742
  t.position,
@@ -746,16 +746,16 @@ async function ia(e = {}) {
746
746
  openPanelPosition: P,
747
747
  visibleLauncherPosition: _
748
748
  }), Q(!0, "open"), ee(), !d) {
749
- i.classList.add("pluno-pa-widget--open"), v.hidden = !0, a && (w.value = a, tt(w)), nt(T, () => Ce.enabled), Se = T.scrollTop, w.focus(), w.setSelectionRange(w.value.length, w.value.length), F(), rt("shown"), t.onPanelOpenChange?.(!0);
749
+ i.classList.add("pluno-pa-widget--open"), v.hidden = !0, a && (w.value = a, et(w)), tt(T, () => Ce.enabled), Se = T.scrollTop, w.focus(), w.setSelectionRange(w.value.length, w.value.length), F(), rt("shown"), t.onPanelOpenChange?.(!0);
750
750
  return;
751
751
  }
752
752
  window.requestAnimationFrame(() => {
753
- i.classList.add("pluno-pa-widget--open"), a && (w.value = a, tt(w)), nt(T, () => Ce.enabled), Se = T.scrollTop, w.focus(), w.setSelectionRange(w.value.length, w.value.length), F(), rt("shown"), t.onPanelOpenChange?.(!0), J = window.setTimeout(() => {
754
- v.hidden = !0, nt(T, () => Ce.enabled), Se = T.scrollTop;
753
+ i.classList.add("pluno-pa-widget--open"), a && (w.value = a, et(w)), tt(T, () => Ce.enabled), Se = T.scrollTop, w.focus(), w.setSelectionRange(w.value.length, w.value.length), F(), rt("shown"), t.onPanelOpenChange?.(!0), J = window.setTimeout(() => {
754
+ v.hidden = !0, tt(T, () => Ce.enabled), Se = T.scrollTop;
755
755
  }, 220);
756
756
  });
757
757
  }, Lt = () => {
758
- J !== null && (window.clearTimeout(J), J = null), v.hidden = !1, p && (Ve(!1), ke("Closing launcher at stored position")), i.classList.remove("pluno-pa-widget--open"), i.classList.add("pluno-pa-widget--closing"), F(), t.onPanelOpenChange?.(!1), J = window.setTimeout(() => {
758
+ J !== null && (window.clearTimeout(J), J = null), v.hidden = !1, p && (je(!1), ke("Closing launcher at stored position")), i.classList.remove("pluno-pa-widget--open"), i.classList.add("pluno-pa-widget--closing"), F(), t.onPanelOpenChange?.(!1), J = window.setTimeout(() => {
759
759
  y.hidden = !0, A.hidden = !0, u = null, i.classList.remove("pluno-pa-widget--closing");
760
760
  }, 220);
761
761
  };
@@ -798,8 +798,8 @@ async function ia(e = {}) {
798
798
  const d = window.getComputedStyle(a);
799
799
  return d.display !== "none" && d.visibility !== "hidden";
800
800
  }, vn = (a) => {
801
- Ye !== a && (Ye = a, i.classList.toggle("pluno-pa-widget--host-modal-conflict", a !== null), Pe(), a !== null ? Le = window.setInterval(() => {
802
- const d = Ye;
801
+ Ke !== a && (Ke = a, i.classList.toggle("pluno-pa-widget--host-modal-conflict", a !== null), Pe(), a !== null ? Le = window.setInterval(() => {
802
+ const d = Ke;
803
803
  (!d || !Vo(d)) && vn(null);
804
804
  }, Hi) : Le !== null && (window.clearInterval(Le), Le = null, lt = null));
805
805
  }, Ko = () => {
@@ -808,7 +808,7 @@ async function ia(e = {}) {
808
808
  i.addEventListener("focusin", (a) => {
809
809
  yn(a.target) && (Pt = Date.now(), F());
810
810
  }), i.addEventListener("focusout", (a) => {
811
- if (!yn(a.target) || Ye !== null)
811
+ if (!yn(a.target) || Ke !== null)
812
812
  return;
813
813
  const d = Pt;
814
814
  if (Pt = null, d === null || Date.now() - d > Bi)
@@ -827,7 +827,7 @@ async function ia(e = {}) {
827
827
  }), g?.addEventListener("pointerdown", (a) => {
828
828
  a.stopPropagation();
829
829
  }), g?.addEventListener("click", (a) => {
830
- a.preventDefault(), a.stopPropagation(), je("minimized");
830
+ a.preventDefault(), a.stopPropagation(), qe("minimized");
831
831
  }), A.addEventListener("click", Lt), T.addEventListener("scroll", () => {
832
832
  T.scrollTop < Se - 1 && Q(!1, "userScroll"), Se = T.scrollTop;
833
833
  }), x.addEventListener("click", () => {
@@ -840,30 +840,30 @@ async function ia(e = {}) {
840
840
  { root: T, threshold: 0 }
841
841
  );
842
842
  Cn?.observe(oe);
843
- const Ke = () => t.loginRequired || t.signupRequired;
844
- let Ye = null, Xe = !1;
845
- const K = () => De || b.getState().status !== "connected", Pe = () => {
846
- const a = Ke(), d = Ye !== null, _ = !a && K();
847
- C.readOnly = a || d || _, w.readOnly = d || _, C.placeholder = d ? zn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : _ ? De ? "Connecting..." : "Connection unavailable" : Xe ? "New update" : t.launcherLabel, w.placeholder = d ? zn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : _ ? De ? "Connecting..." : "Connection unavailable" : ae.launcherLabel, N.hidden = a;
843
+ const Ve = () => t.loginRequired || t.signupRequired;
844
+ let Ke = null, Ye = !1;
845
+ const K = () => at || b.getState().status !== "connected", Pe = () => {
846
+ const a = Ve(), d = Ke !== null, _ = !a && K();
847
+ C.readOnly = a || d || _, w.readOnly = d || _, C.placeholder = d ? zn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : Ye ? "New update" : t.launcherLabel, w.placeholder = d ? zn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : ae.launcherLabel, N.hidden = a;
848
848
  }, G = () => {
849
- U.disabled = K() || le(t.billingStatus) || !b.getState().isThinking && w.value.trim().length === 0 && j.length === 0, Ge.disabled = Ke() || K() || le(t.billingStatus);
849
+ U.disabled = K() || le(t.billingStatus) || !b.getState().isThinking && w.value.trim().length === 0 && j.length === 0, We.disabled = Ve() || K() || le(t.billingStatus);
850
850
  };
851
851
  Pe();
852
852
  const Tt = () => {
853
853
  const a = b.getState().isThinking;
854
854
  i.classList.toggle("pluno-pa-widget--thinking", a), i.classList.toggle(
855
855
  "pluno-pa-widget--unread",
856
- !a && Xe
856
+ !a && Ye
857
857
  ), Pe();
858
858
  };
859
859
  Tt();
860
860
  const It = () => {
861
- Ke() || de || (De = !0, Pe(), G(), b.connect().then(
861
+ Ve() || de || (at = !0, Pe(), G(), b.connect().then(
862
862
  () => {
863
- de || (De = !1, Pe(), G());
863
+ de || (at = !1, Pe(), G());
864
864
  },
865
865
  (a) => {
866
- de || (De = !1, Pe(), G(), te(
866
+ de || (at = !1, Pe(), G(), te(
867
867
  "web-sdk.widget",
868
868
  "Failed to connect Product Agent widget",
869
869
  {
@@ -888,9 +888,9 @@ async function ia(e = {}) {
888
888
  j
889
889
  ), Ne(), G());
890
890
  });
891
- let Ze = 0;
891
+ let Xe = 0;
892
892
  const Yo = () => {
893
- Ze = 0, i.classList.remove("pluno-pa-widget--drag-over");
893
+ Xe = 0, i.classList.remove("pluno-pa-widget--drag-over");
894
894
  }, At = (a) => {
895
895
  se !== null && window.clearTimeout(se), q.textContent = a, q.hidden = !1, se = window.setTimeout(() => {
896
896
  q.textContent = "", q.hidden = !0, se = null;
@@ -903,7 +903,7 @@ async function ia(e = {}) {
903
903
  const d = Ya(b, a);
904
904
  j = [...j, ...d], Ne(), Xo(), G(), H(b.getState()), i.classList.contains("pluno-pa-widget--open") || we();
905
905
  };
906
- Ge.addEventListener("click", () => {
906
+ We.addEventListener("click", () => {
907
907
  t.loginRequired || K() || le(t.billingStatus) || z.click();
908
908
  }), z.addEventListener("change", () => {
909
909
  const a = Array.from(z.files ?? []);
@@ -915,12 +915,12 @@ async function ia(e = {}) {
915
915
  });
916
916
  });
917
917
  }), i.addEventListener("dragenter", (a) => {
918
- !ct(a.dataTransfer) || t.loginRequired || K() || (a.preventDefault(), a.stopPropagation(), Ze += 1, i.classList.add("pluno-pa-widget--drag-over"));
918
+ !ct(a.dataTransfer) || t.loginRequired || K() || (a.preventDefault(), a.stopPropagation(), Xe += 1, i.classList.add("pluno-pa-widget--drag-over"));
919
919
  }), i.addEventListener("dragover", (a) => {
920
920
  const d = a.dataTransfer;
921
921
  !ct(d) || t.loginRequired || K() || (a.preventDefault(), a.stopPropagation(), d.dropEffect = "copy");
922
922
  }), i.addEventListener("dragleave", (a) => {
923
- ct(a.dataTransfer) && (a.stopPropagation(), Ze = Math.max(0, Ze - 1), Ze === 0 && i.classList.remove("pluno-pa-widget--drag-over"));
923
+ ct(a.dataTransfer) && (a.stopPropagation(), Xe = Math.max(0, Xe - 1), Xe === 0 && i.classList.remove("pluno-pa-widget--drag-over"));
924
924
  }), i.addEventListener("drop", (a) => {
925
925
  const d = a.dataTransfer;
926
926
  !ct(d) || t.loginRequired || K() || (a.preventDefault(), a.stopPropagation(), Yo(), Nt(d.files).catch((_) => {
@@ -955,11 +955,11 @@ async function ia(e = {}) {
955
955
  j
956
956
  ), Ne(), G(), H(b.getState()));
957
957
  }), ve.addEventListener("click", () => {
958
- me = !me, $e = null, Ee(), me && fe.length === 0 && mn(null);
959
- }), it.addEventListener("click", () => {
958
+ me = !me, Ge = null, Ee(), me && fe.length === 0 && mn(null);
959
+ }), ot.addEventListener("click", () => {
960
960
  me = !1, Ee();
961
961
  }), V.addEventListener("scroll", Wo), w.addEventListener("input", () => {
962
- tt(w), F(), G(), Qo();
962
+ et(w), F(), G(), Qo();
963
963
  }), w.addEventListener("keydown", (a) => {
964
964
  if (!(a.key !== "Enter" || a.shiftKey)) {
965
965
  if (a.preventDefault(), t.loginRequired) {
@@ -974,60 +974,60 @@ async function ia(e = {}) {
974
974
  }
975
975
  }), i.addEventListener("click", (a) => {
976
976
  (a.target instanceof Element ? a.target : null)?.closest("a[href]") && F();
977
- }), l.composerValue && (w.value = l.composerValue, tt(w)), t.initialDisplayState === "minimized" ? je("minimized", !1) : t.initialDisplayState === void 0 && l.isOpen && we(w.value, !1), xa(l, i, C, w);
977
+ }), l.composerValue && (w.value = l.composerValue, et(w)), t.initialDisplayState === "minimized" ? qe("minimized", !1) : t.initialDisplayState === void 0 && l.isOpen && we(w.value, !1), xa(l, i, C, w);
978
978
  const pt = () => r;
979
- let Rt = b.getState().appearance !== null, st = null, Je = null, Me = null, Sn = b.getState().isThinking, ze = null;
980
- const Qe = t.taskNotifications;
981
- let Oe = null, Ue = !1;
979
+ let Rt = b.getState().appearance !== null, st = null, Ze = null, De = null, Sn = b.getState().isThinking, Me = null;
980
+ const Je = t.taskNotifications;
981
+ let ze = null, Oe = !1;
982
982
  const En = () => {
983
- Oe !== null && (window.clearTimeout(Oe), Oe = null);
983
+ ze !== null && (window.clearTimeout(ze), ze = null);
984
984
  }, dt = () => {
985
985
  W && (W.hidden = !0);
986
986
  }, kn = () => b.getState().assistantDraft.trim().length > 0, Zo = async () => {
987
- if (!Qe || !W || Ue || de || !b.getState().isThinking || kn())
987
+ if (!Je || !W || Oe || de || !b.getState().isThinking || kn())
988
988
  return;
989
989
  let a;
990
990
  try {
991
- a = await Qe.getState();
991
+ a = await Je.getState();
992
992
  } catch {
993
993
  return;
994
994
  }
995
- a.enabled || a.neverSuggest || !b.getState().isThinking || kn() || Ue || de || (W.hidden = !1);
995
+ a.enabled || a.neverSuggest || !b.getState().isThinking || kn() || Oe || de || (W.hidden = !1);
996
996
  };
997
997
  L?.addEventListener("click", () => {
998
- Ue = !0, dt(), Qe?.enable().catch(() => {
998
+ Oe = !0, dt(), Je?.enable().catch(() => {
999
999
  });
1000
1000
  }), R?.addEventListener("click", () => {
1001
- Ue = !0, dt();
1001
+ Oe = !0, dt();
1002
1002
  }), Uo?.addEventListener("click", () => {
1003
- Ue = !0, dt(), Qe?.dismissForever().catch(() => {
1003
+ Oe = !0, dt(), Je?.dismissForever().catch(() => {
1004
1004
  });
1005
1005
  });
1006
- let Be = null, Ln = () => {
1006
+ let Ue = null, Ln = () => {
1007
1007
  };
1008
1008
  const Jo = !!t.socialPostDraftHandler, Dt = /* @__PURE__ */ new Map(), Mt = () => w.value.trim().length > 0 || j.length > 0, Qo = () => {
1009
- const a = Be !== null && Yt(b.getState(), Mt());
1010
- M.hidden = !a, a && Be !== null && Co(M, Be);
1009
+ const a = Ue !== null && Yt(b.getState(), Mt());
1010
+ M.hidden = !a, a && Ue !== null && Co(M, Ue);
1011
1011
  };
1012
- let Fe = null;
1012
+ let Be = null;
1013
1013
  const zt = (a = {}) => {
1014
- he = !0, Q(!0, "newSession"), ee(), me = !1, Ee(), b.startNewSession(a), vt.clear(), w.value = "", j = [], Ne(), tt(w), F(), G(), w.focus(), H(b.getState());
1014
+ he = !0, Q(!0, "newSession"), ee(), me = !1, Ee(), b.startNewSession(a), vt.clear(), w.value = "", j = [], Ne(), et(w), F(), G(), w.focus(), H(b.getState());
1015
1015
  }, Ot = (a) => {
1016
1016
  if (!a) {
1017
- Fe?.remove(), Fe = null;
1017
+ Be?.remove(), Be = null;
1018
1018
  return;
1019
1019
  }
1020
- Fe || (Fe = xt(
1020
+ Be || (Be = xt(
1021
1021
  "pluno-pa-widget__new-chat",
1022
1022
  "New chat",
1023
1023
  Ua(),
1024
1024
  !1
1025
- ), Fe.addEventListener("click", () => zt()), ye.insertBefore(Fe, ve));
1025
+ ), Be.addEventListener("click", () => zt()), ye.insertBefore(Be, ve));
1026
1026
  }, H = (a) => {
1027
- if (Ee(), un(a.lastErrorCode) ? ze = a.lastErrorCode : t.billingStatus?.creditsUsed !== null && !le(t.billingStatus) && (ze = null), Kt(
1027
+ if (Ee(), un(a.lastErrorCode) ? Me = a.lastErrorCode : t.billingStatus?.creditsUsed !== null && !le(t.billingStatus) && (Me = null), Kt(
1028
1028
  xe,
1029
1029
  t.billingStatus,
1030
- ze
1030
+ Me
1031
1031
  ), t.loginRequired) {
1032
1032
  Dt.clear(), to(
1033
1033
  T,
@@ -1064,8 +1064,8 @@ async function ia(e = {}) {
1064
1064
  Ot,
1065
1065
  M,
1066
1066
  a,
1067
- Be,
1068
- Be !== null && Yt(a, Mt()),
1067
+ Ue,
1068
+ Ue !== null && Yt(a, Mt()),
1069
1069
  P,
1070
1070
  () => Ce.enabled,
1071
1071
  vt,
@@ -1075,8 +1075,8 @@ async function ia(e = {}) {
1075
1075
  (O) => {
1076
1076
  if (K())
1077
1077
  return;
1078
- const et = t.morningReport !== null;
1079
- t.morningReport = null, et && (t.onMorningReportTaskStart?.(), zt()), he = !0, Q(!0, "send"), ee(), b.sendMessage(O);
1078
+ const Qe = t.morningReport !== null;
1079
+ t.morningReport = null, Qe && (t.onMorningReportTaskStart?.(), zt()), he = !0, Q(!0, "send"), ee(), b.sendMessage(O);
1080
1080
  },
1081
1081
  () => {
1082
1082
  he = !0, Q(!0, "send"), ee(), b.retryLastMessage();
@@ -1087,9 +1087,9 @@ async function ia(e = {}) {
1087
1087
  },
1088
1088
  It,
1089
1089
  Jo && !Ct ? {
1090
- dismissedCandidateIds: at,
1090
+ dismissedCandidateIds: it,
1091
1091
  draftingCandidateId: st,
1092
- error: Je,
1092
+ error: Ze,
1093
1093
  characterIconOptions: pt(),
1094
1094
  onSeen: (O) => {
1095
1095
  Re.add(O.id), F();
@@ -1098,17 +1098,17 @@ async function ia(e = {}) {
1098
1098
  ei(O);
1099
1099
  },
1100
1100
  onDismiss: (O) => {
1101
- Re.add(O.id), at.add(O.id), F(), Je = null, H(b.getState());
1101
+ Re.add(O.id), it.add(O.id), F(), Ze = null, H(b.getState());
1102
1102
  },
1103
1103
  onDisable: (O) => {
1104
- Ct = !0, Re.add(O.id), at.add(O.id), F(), kr(t, !0), Je = null, H(b.getState());
1104
+ Ct = !0, Re.add(O.id), it.add(O.id), F(), kr(t, !0), Ze = null, H(b.getState());
1105
1105
  }
1106
1106
  } : void 0
1107
1107
  ), P ? (Se = T.scrollTop, ee()) : _ && Ca(a) && Fo();
1108
1108
  };
1109
1109
  return Ln = _i(
1110
1110
  (a) => {
1111
- Be = a, !de && Yt(b.getState(), Mt()) && H(b.getState());
1111
+ Ue = a, !de && Yt(b.getState(), Mt()) && H(b.getState());
1112
1112
  },
1113
1113
  {
1114
1114
  backendUrl: t.backendUrl,
@@ -1117,9 +1117,9 @@ async function ia(e = {}) {
1117
1117
  }
1118
1118
  ), b.on("state", (a) => {
1119
1119
  const d = Sn && !a.isThinking;
1120
- Sn = a.isThinking, a.isThinking && !a.assistantDraft.trim() && Qe && !Ue && Oe === null && W?.hidden !== !1 && (Oe = window.setTimeout(() => {
1121
- Oe = null, Zo();
1122
- }, Si)), (!a.isThinking || a.assistantDraft.trim()) && (En(), dt()), d && !i.classList.contains("pluno-pa-widget--open") && (Xe = !0), Tt(), a.appearance ? (Rt = !0, te(
1120
+ Sn = a.isThinking, a.isThinking && !a.assistantDraft.trim() && Je && !Oe && ze === null && W?.hidden !== !1 && (ze = window.setTimeout(() => {
1121
+ ze = null, Zo();
1122
+ }, Si)), (!a.isThinking || a.assistantDraft.trim()) && (En(), dt()), d && !i.classList.contains("pluno-pa-widget--open") && (Ye = !0), Tt(), a.appearance ? (Rt = !0, te(
1123
1123
  "web-sdk.widget",
1124
1124
  "Agent state supplied appearance",
1125
1125
  {
@@ -1146,16 +1146,16 @@ async function ia(e = {}) {
1146
1146
  Zn(
1147
1147
  t.billingStatus,
1148
1148
  d,
1149
- ze
1150
- ) && (t.billingStatus = d, t.billingStatus?.creditsUsed !== null && !le(t.billingStatus) && (ze = null), Kt(
1149
+ Me
1150
+ ) && (t.billingStatus = d, t.billingStatus?.creditsUsed !== null && !le(t.billingStatus) && (Me = null), Kt(
1151
1151
  i.querySelector(".pluno-pa-widget__billing-status"),
1152
1152
  t.billingStatus,
1153
- ze
1153
+ Me
1154
1154
  ), G());
1155
1155
  },
1156
1156
  updateAuthGate: (a) => {
1157
- const d = Ke();
1158
- t.loginRequired = a.loginRequired === !0, t.signupRequired = a.signupRequired === !0, a.loginButtonLabel !== void 0 && (t.loginButtonLabel = a.loginButtonLabel), a.loginUrl !== void 0 && (t.loginUrl = a.loginUrl), a.signupButtonLabel !== void 0 && (t.signupButtonLabel = a.signupButtonLabel), a.signupUrl !== void 0 && (t.signupUrl = a.signupUrl), Pe(), H(b.getState()), G(), d && !Ke() && It();
1157
+ const d = Ve();
1158
+ t.loginRequired = a.loginRequired === !0, t.signupRequired = a.signupRequired === !0, a.loginButtonLabel !== void 0 && (t.loginButtonLabel = a.loginButtonLabel), a.loginUrl !== void 0 && (t.loginUrl = a.loginUrl), a.signupButtonLabel !== void 0 && (t.signupButtonLabel = a.signupButtonLabel), a.signupUrl !== void 0 && (t.signupUrl = a.signupUrl), Pe(), H(b.getState()), G(), d && !Ve() && It();
1159
1159
  },
1160
1160
  openPanel: () => {
1161
1161
  we(w.value, !1);
@@ -1163,57 +1163,57 @@ async function ia(e = {}) {
1163
1163
  closePanel: Lt,
1164
1164
  updateDisplayState: (a) => {
1165
1165
  if (a === "shown") {
1166
- je("shown", !1);
1166
+ qe("shown", !1);
1167
1167
  return;
1168
1168
  }
1169
- je("minimized", !1);
1169
+ qe("minimized", !1);
1170
1170
  },
1171
1171
  updateMorningReport: (a) => {
1172
1172
  t.morningReport = a ?? null, H(b.getState());
1173
1173
  },
1174
1174
  destroy: () => {
1175
- de || (F(), de = !0, wn.disconnect(), Cn?.disconnect(), Ko(), window.removeEventListener("resize", bn), _n(), qo(), se !== null && window.clearTimeout(se), En(), Ln(), Me?.remove(), b.destroy(), yt.release(), n.remove());
1175
+ de || (F(), de = !0, wn.disconnect(), Cn?.disconnect(), Ko(), window.removeEventListener("resize", bn), _n(), qo(), se !== null && window.clearTimeout(se), En(), Ln(), De?.remove(), b.destroy(), yt.release(), n.remove());
1176
1176
  }
1177
1177
  };
1178
1178
  async function ei(a) {
1179
1179
  if (!st) {
1180
- st = a.id, Je = null, H(b.getState());
1180
+ st = a.id, Ze = null, H(b.getState());
1181
1181
  try {
1182
1182
  if (!t.socialPostDraftHandler)
1183
1183
  throw new Error("Social post drafting is not available here.");
1184
1184
  const d = await t.socialPostDraftHandler(a);
1185
1185
  if (!d.linkedinPost || !d.xPost)
1186
1186
  throw new Error("Pluno did not return a complete social post draft.");
1187
- Re.add(a.id), at.add(a.id), F(), Me?.remove(), Me = dr(d, {
1187
+ Re.add(a.id), it.add(a.id), F(), De?.remove(), De = dr(d, {
1188
1188
  socialPostRewardsUrl: t.socialPostRewardsUrl,
1189
1189
  onClose: () => {
1190
- Me?.remove(), Me = null;
1190
+ De?.remove(), De = null;
1191
1191
  }
1192
- }), i.appendChild(Me);
1192
+ }), i.appendChild(De);
1193
1193
  } catch (d) {
1194
- Je = d instanceof Error ? d.message : "Could not draft social post.";
1194
+ Ze = d instanceof Error ? d.message : "Could not draft social post.";
1195
1195
  } finally {
1196
1196
  st = null, H(b.getState());
1197
1197
  }
1198
1198
  }
1199
1199
  }
1200
1200
  function Ut(a, d) {
1201
- const _ = a.accentColor ?? t.accentColor, P = a.colorScheme ?? t.colorScheme, O = a.fontFamily ?? t.fontFamily, et = a.scribbleStyle ?? t.scribbleStyle;
1201
+ const _ = a.accentColor ?? t.accentColor, P = a.colorScheme ?? t.colorScheme, O = a.fontFamily ?? t.fontFamily, Qe = a.scribbleStyle ?? t.scribbleStyle;
1202
1202
  r = Hn(
1203
1203
  _,
1204
- et
1204
+ Qe
1205
1205
  ), Wn(i, r, {
1206
1206
  accentColor: _,
1207
1207
  colorScheme: P,
1208
1208
  fontFamily: O,
1209
- scribbleStyle: et
1209
+ scribbleStyle: Qe
1210
1210
  }), te("web-sdk.widget", "Updated widget appearance", {
1211
1211
  source: d,
1212
1212
  inputAppearance: a,
1213
1213
  appliedAccentColor: _,
1214
1214
  appliedColorScheme: P,
1215
1215
  appliedFontFamily: O,
1216
- appliedScribbleStyle: et,
1216
+ appliedScribbleStyle: Qe,
1217
1217
  cssAccent: i.style.getPropertyValue("--pluno-pa-accent")
1218
1218
  });
1219
1219
  }
@@ -1470,7 +1470,7 @@ function ca() {
1470
1470
  )
1471
1471
  };
1472
1472
  }
1473
- function He(e = null) {
1473
+ function Fe(e = null) {
1474
1474
  return e ? _t(e) : ca();
1475
1475
  }
1476
1476
  function _t(e) {
@@ -1580,7 +1580,7 @@ function fa(e) {
1580
1580
  return e.classList.contains("pluno-pa-widget--scribble") ? ta : ea;
1581
1581
  }
1582
1582
  function Gt(e, t, n, o = null) {
1583
- const i = wt(e), r = He(o), l = {
1583
+ const i = wt(e), r = Fe(o), l = {
1584
1584
  x: n === "bottom-left" ? t.x : t.x + i.width - r.width,
1585
1585
  y: t.y + i.height - r.height
1586
1586
  };
@@ -1675,12 +1675,12 @@ function xa(e, t, n, o) {
1675
1675
  function ya(e) {
1676
1676
  return e;
1677
1677
  }
1678
- function tt(e) {
1678
+ function et(e) {
1679
1679
  e.style.height = "0px";
1680
1680
  const t = Math.max(22, Math.min(e.scrollHeight, 140));
1681
1681
  e.style.height = `${t}px`, e.style.overflowY = e.scrollHeight > 140 ? "auto" : "hidden";
1682
1682
  }
1683
- function nt(e, t = () => !0) {
1683
+ function tt(e, t = () => !0) {
1684
1684
  e.scrollTop = e.scrollHeight, window.requestAnimationFrame(() => {
1685
1685
  t() && (e.scrollTop = e.scrollHeight);
1686
1686
  });
@@ -2686,12 +2686,12 @@ function Yt(e, t) {
2686
2686
  function nr(e, t, n, o, i, r, l, p, s, c, u, m, k, v, D, C, g, y, h, S) {
2687
2687
  const A = rr(r), N = A.filter(
2688
2688
  (x) => !Ao(x)
2689
- ), q = e.scrollTop, xe = [], We = /* @__PURE__ */ new Set(), z = (x) => {
2689
+ ), q = e.scrollTop, xe = [], He = /* @__PURE__ */ new Set(), z = (x) => {
2690
2690
  xe.push(x);
2691
2691
  };
2692
2692
  Ro(n, r.isThinking), i.hidden = !p, p && l !== null && Co(i, l);
2693
- const Ge = N.length > 0 || !!r.assistantDraft || r.isThinking;
2694
- if (o(Ge), g || N.length === 0 && !r.assistantDraft && !r.lastError && !r.isThinking) {
2693
+ const We = N.length > 0 || !!r.assistantDraft || r.isThinking;
2694
+ if (o(We), g || N.length === 0 && !r.assistantDraft && !r.lastError && !r.isThinking) {
2695
2695
  const x = document.createElement("div");
2696
2696
  x.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter" + (g ? " pluno-pa-widget__empty-state--morning-report" : "");
2697
2697
  const M = document.createElement("div");
@@ -2763,11 +2763,11 @@ function nr(e, t, n, o, i, r, l, p, s, c, u, m, k, v, D, C, g, y, h, S) {
2763
2763
  const L = No(v());
2764
2764
  z(L), w = null, U = L;
2765
2765
  }
2766
- const W = or(M, oe, m, We);
2766
+ const W = or(M, oe, m, He);
2767
2767
  z(W), w = W, U = null;
2768
2768
  }
2769
- const V = Ae(), it = N[N.length - 1]?.id === "assistant-draft";
2770
- if (r.isThinking && !it && !ve)
2769
+ const V = Ae(), ot = N[N.length - 1]?.id === "assistant-draft";
2770
+ if (r.isThinking && !ot && !ve)
2771
2771
  if (V) {
2772
2772
  const x = bt();
2773
2773
  z(x), w = null, U = x;
@@ -2800,7 +2800,7 @@ function nr(e, t, n, o, i, r, l, p, s, c, u, m, k, v, D, C, g, y, h, S) {
2800
2800
  });
2801
2801
  z(x), S.onSeen(ne), w = null, U = x;
2802
2802
  }
2803
- w?.classList.add("pluno-pa-widget__message--bottom-reserve"), U?.classList.add("pluno-pa-widget__bottom-reserve-compact"), z(t), ar(m, We), Qn(e, xe), s ? nt(e, c) : e.scrollTop = q;
2803
+ w?.classList.add("pluno-pa-widget__message--bottom-reserve"), U?.classList.add("pluno-pa-widget__bottom-reserve-compact"), z(t), ar(m, He), Qn(e, xe), s ? tt(e, c) : e.scrollTop = q;
2804
2804
  }
2805
2805
  function or(e, t, n, o) {
2806
2806
  const i = ir(e, t), r = i ? n.get(i) : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluno/product-agent-web",
3
- "version": "0.1.75",
3
+ "version": "0.1.76",
4
4
  "description": "Browser SDK and default widget for embedding Pluno Product Agent into customer web apps.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",