@rekayasa/erica-bubble 1.2.1 → 1.2.3

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.mjs CHANGED
@@ -14511,19 +14511,53 @@ var qy = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e)
14511
14511
  rx: "1",
14512
14512
  key: "q5h2i8"
14513
14513
  }]
14514
- ]), ab = nb("square-pen", [["path", {
14514
+ ]), ab = nb("maximize-2", [
14515
+ ["path", {
14516
+ d: "M15 3h6v6",
14517
+ key: "1q9fwt"
14518
+ }],
14519
+ ["path", {
14520
+ d: "m21 3-7 7",
14521
+ key: "1l2asr"
14522
+ }],
14523
+ ["path", {
14524
+ d: "m3 21 7-7",
14525
+ key: "tjx5ai"
14526
+ }],
14527
+ ["path", {
14528
+ d: "M9 21H3v-6",
14529
+ key: "wtvkvv"
14530
+ }]
14531
+ ]), ob = nb("minimize-2", [
14532
+ ["path", {
14533
+ d: "m14 10 7-7",
14534
+ key: "oa77jy"
14535
+ }],
14536
+ ["path", {
14537
+ d: "M20 10h-6V4",
14538
+ key: "mjg0md"
14539
+ }],
14540
+ ["path", {
14541
+ d: "m3 21 7-7",
14542
+ key: "tjx5ai"
14543
+ }],
14544
+ ["path", {
14545
+ d: "M4 14h6v6",
14546
+ key: "rmj7iw"
14547
+ }]
14548
+ ]), sb = nb("square-pen", [["path", {
14515
14549
  d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",
14516
14550
  key: "1m0v6g"
14517
14551
  }], ["path", {
14518
14552
  d: "M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",
14519
14553
  key: "ohrbg2"
14520
- }]]), ob = nb("x", [["path", {
14554
+ }]]), cb = nb("x", [["path", {
14521
14555
  d: "M18 6 6 18",
14522
14556
  key: "1bl5f8"
14523
14557
  }], ["path", {
14524
14558
  d: "m6 6 12 12",
14525
14559
  key: "d8bk6v"
14526
- }]]), sb = { downloadGenerated: async (e, t) => {
14560
+ }]]), lb = { downloadGenerated: async (e, t) => {
14527
14561
  let { data: n } = await Pe.get({
14528
14562
  url: `/templates/generated/${encodeURIComponent(e)}/download`,
14529
14563
  parseAs: "blob",
@@ -14533,7 +14567,7 @@ var qy = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e)
14533
14567
  } };
14534
14568
  //#endregion
14535
14569
  //#region src/components/artifacts/FilledTemplateCard.tsx
14536
- function cb({ templateName: e, outputFilename: t, s3Path: n }) {
14570
+ function ub({ templateName: e, outputFilename: t, s3Path: n }) {
14537
14571
  let [r, i] = u(!1), [a, o] = u(null), s = c(() => n.split("/").pop()?.replace(/\.docx$/i, "") ?? "", [n]), l = async () => {
14538
14572
  if (!s) {
14539
14573
  o("Generated file id is missing");
@@ -14541,7 +14575,7 @@ function cb({ templateName: e, outputFilename: t, s3Path: n }) {
14541
14575
  }
14542
14576
  i(!0), o(null);
14543
14577
  try {
14544
- await sb.downloadGenerated(s, t || `${s}.docx`);
14578
+ await lb.downloadGenerated(s, t || `${s}.docx`);
14545
14579
  } catch (e) {
14546
14580
  o(e instanceof Error ? e.message : "Download failed");
14547
14581
  } finally {
@@ -14585,19 +14619,19 @@ function cb({ templateName: e, outputFilename: t, s3Path: n }) {
14585
14619
  }
14586
14620
  //#endregion
14587
14621
  //#region src/components/Tools.tsx
14588
- function lb({ name: e }) {
14622
+ function db({ name: e }) {
14589
14623
  let t = a(xn);
14590
14624
  return o(() => {
14591
14625
  t && t.setStep(e);
14592
14626
  }, [e, t]), null;
14593
14627
  }
14594
- function ub() {
14628
+ function fb() {
14595
14629
  return b({
14596
- name: "showChart",
14630
+ name: "show_chart",
14597
14631
  parameters: fc,
14598
14632
  render: ({ parameters: e }) => e.compiled_chart?.path ? /* @__PURE__ */ S(Gc, { path: e.compiled_chart.path }) : /* @__PURE__ */ S("div", { children: "No chart path provided" })
14599
14633
  }, []), b({
14600
- name: "showReport",
14634
+ name: "show_report",
14601
14635
  parameters: pc,
14602
14636
  render: ({ parameters: e }) => e.compiled_report?.path ? /* @__PURE__ */ S(Hy, {
14603
14637
  path: e.compiled_report.path,
@@ -14608,13 +14642,13 @@ function ub() {
14608
14642
  parameters: mc,
14609
14643
  render: ({ parameters: e }) => {
14610
14644
  let { filled_template: t } = e;
14611
- return t?.s3_path ? /* @__PURE__ */ S(cb, {
14645
+ return t?.s3_path ? /* @__PURE__ */ S(ub, {
14612
14646
  templateName: t.template_name,
14613
14647
  outputFilename: t.output_filename,
14614
14648
  s3Path: t.s3_path
14615
14649
  }) : /* @__PURE__ */ S("div", { children: "No template path provided" });
14616
14650
  }
14617
- }, []), v({ render: ({ name: e }) => /* @__PURE__ */ S(lb, { name: e }) }, []), y({ render: ({ event: e, resolve: t }) => {
14651
+ }, []), v({ render: ({ name: e }) => /* @__PURE__ */ S(db, { name: e }) }, []), y({ render: ({ event: e, resolve: t }) => {
14618
14652
  let n = {};
14619
14653
  try {
14620
14654
  n = typeof e.value == "string" ? JSON.parse(e.value) : e.value;
@@ -14657,7 +14691,7 @@ function ub() {
14657
14691
  }
14658
14692
  //#endregion
14659
14693
  //#region src/lib/resource-api.ts
14660
- var db = { search: async (e, t = yn) => {
14694
+ var pb = { search: async (e, t = yn) => {
14661
14695
  let { data: n } = await Pe.get({
14662
14696
  security: [{
14663
14697
  scheme: "bearer",
@@ -14671,11 +14705,11 @@ var db = { search: async (e, t = yn) => {
14671
14705
  throwOnError: !0
14672
14706
  });
14673
14707
  return n.data ?? [];
14674
- } }, fb = {
14708
+ } }, mb = {
14675
14709
  dataset: "dataset",
14676
14710
  document: "document",
14677
14711
  template: "template"
14678
- }, pb = r(({ items: e, command: t, isLoading: n = !1 }, r) => {
14712
+ }, hb = r(({ items: e, command: t, isLoading: n = !1 }, r) => {
14679
14713
  let [i, a] = u(0), c = l(null);
14680
14714
  return o(() => {
14681
14715
  a(0);
@@ -14711,22 +14745,22 @@ var db = { search: async (e, t = yn) => {
14711
14745
  children: e.label
14712
14746
  }), e.description && /* @__PURE__ */ S("span", {
14713
14747
  className: ["erica-mention-badge", `erica-mention-badge-${e.description}`].join(" "),
14714
- children: fb[e.description] ?? e.description
14748
+ children: mb[e.description] ?? e.description
14715
14749
  })]
14716
14750
  }, e.id))
14717
14751
  })]
14718
14752
  });
14719
14753
  });
14720
- pb.displayName = "MentionSuggestionList";
14754
+ hb.displayName = "MentionSuggestionList";
14721
14755
  //#endregion
14722
14756
  //#region src/components/ChatEditor.tsx
14723
- function mb(e) {
14724
- return e.nodeType === Node.TEXT_NODE ? e.textContent ?? "" : e instanceof HTMLElement ? e.dataset.resourceUid && e.dataset.resourceType ? `:resource[${e.dataset.resourceLabel ?? e.textContent?.replace(/^@/, "") ?? ""}]{uid="${e.dataset.resourceUid}" type="${e.dataset.resourceType}"}` : e.tagName === "BR" ? "\n" : Array.from(e.childNodes).map(mb).join("") : Array.from(e.childNodes).map(mb).join("");
14757
+ function gb(e) {
14758
+ return e.nodeType === Node.TEXT_NODE ? e.textContent ?? "" : e instanceof HTMLElement ? e.dataset.resourceUid && e.dataset.resourceType ? `:resource[${e.dataset.resourceLabel ?? e.textContent?.replace(/^@/, "") ?? ""}]{uid="${e.dataset.resourceUid}" type="${e.dataset.resourceType}"}` : e.tagName === "BR" ? "\n" : Array.from(e.childNodes).map(gb).join("") : Array.from(e.childNodes).map(gb).join("");
14725
14759
  }
14726
- function hb(e) {
14727
- return Array.from(e.childNodes).map(mb).join("");
14760
+ function _b(e) {
14761
+ return Array.from(e.childNodes).map(gb).join("");
14728
14762
  }
14729
- function gb() {
14763
+ function vb() {
14730
14764
  let e = window.getSelection();
14731
14765
  if (!e || e.rangeCount === 0) return null;
14732
14766
  let t = e.getRangeAt(0);
@@ -14739,13 +14773,13 @@ function gb() {
14739
14773
  query: i[1]
14740
14774
  } : null;
14741
14775
  }
14742
- function _b(e, t) {
14776
+ function yb(e, t) {
14743
14777
  let n = document.createRange();
14744
14778
  n.setStart(e, Math.min(t, e.data.length)), n.collapse(!0);
14745
14779
  let r = window.getSelection();
14746
14780
  r?.removeAllRanges(), r?.addRange(n);
14747
14781
  }
14748
- function vb({ value: e, onChange: t, onSubmit: n, agentIdentifier: r, placeholder: i = "Ketik pertanyaan Anda di sini..." }) {
14782
+ function bb({ value: e, onChange: t, onSubmit: n, agentIdentifier: r, placeholder: i = "Ketik pertanyaan Anda di sini..." }) {
14749
14783
  let a = l(null), s = l(null), c = l(null), d = l(null), f = l(null), p = l(null), m = l(0), h = l(n), g = l(t), _ = l(r), [v, y] = u(!0);
14750
14784
  o(() => {
14751
14785
  h.current = n;
@@ -14762,13 +14796,13 @@ function vb({ value: e, onChange: t, onSubmit: n, agentIdentifier: r, placeholde
14762
14796
  function x() {
14763
14797
  let e = a.current;
14764
14798
  if (!e) return;
14765
- let t = hb(e);
14799
+ let t = _b(e);
14766
14800
  y(t.trim().length === 0), g.current(t);
14767
14801
  }
14768
14802
  function w(e, t) {
14769
14803
  let n = f.current;
14770
14804
  if (!n) return;
14771
- s.current || (s.current = document.createElement("div"), s.current.className = "erica-mention-popup", s.current.setAttribute("data-mention-suggestion", ""), document.body.appendChild(s.current), c.current = T(s.current)), c.current.render(/* @__PURE__ */ S(pb, {
14805
+ s.current || (s.current = document.createElement("div"), s.current.className = "erica-mention-popup", s.current.setAttribute("data-mention-suggestion", ""), document.body.appendChild(s.current), c.current = T(s.current)), c.current.render(/* @__PURE__ */ S(hb, {
14772
14806
  ref: d,
14773
14807
  items: e,
14774
14808
  isLoading: t,
@@ -14784,7 +14818,7 @@ function vb({ value: e, onChange: t, onSubmit: n, agentIdentifier: r, placeholde
14784
14818
  w([], !0), p.current && clearTimeout(p.current), p.current = setTimeout(async () => {
14785
14819
  p.current = null;
14786
14820
  try {
14787
- let n = await db.search(e.query, _.current);
14821
+ let n = await pb.search(e.query, _.current);
14788
14822
  if (t !== m.current) return;
14789
14823
  w(n.filter((e) => [
14790
14824
  "dataset",
@@ -14802,7 +14836,7 @@ function vb({ value: e, onChange: t, onSubmit: n, agentIdentifier: r, placeholde
14802
14836
  }, 300);
14803
14837
  }
14804
14838
  function D() {
14805
- let e = gb();
14839
+ let e = vb();
14806
14840
  if (f.current = e, !e) {
14807
14841
  b();
14808
14842
  return;
@@ -14817,7 +14851,7 @@ function vb({ value: e, onChange: t, onSubmit: n, agentIdentifier: r, placeholde
14817
14851
  let c = document.createElement("span");
14818
14852
  c.className = "erica-resource-tag erica-editor-resource-tag", c.contentEditable = "false", c.dataset.resourceType = n, c.dataset.resourceUid = r, c.dataset.resourceLabel = e.label, c.textContent = `@${e.label}`;
14819
14853
  let l = document.createTextNode(a), u = document.createTextNode(` ${o}`);
14820
- s.insertBefore(l, i), s.insertBefore(c, i), s.insertBefore(u, i), s.removeChild(i), b(), _b(u, 1), x();
14854
+ s.insertBefore(l, i), s.insertBefore(c, i), s.insertBefore(u, i), s.removeChild(i), b(), yb(u, 1), x();
14821
14855
  }
14822
14856
  return /* @__PURE__ */ C("div", {
14823
14857
  className: "erica-editor-wrap",
@@ -14858,7 +14892,7 @@ function vb({ value: e, onChange: t, onSubmit: n, agentIdentifier: r, placeholde
14858
14892
  }
14859
14893
  //#endregion
14860
14894
  //#region src/components/DocumentAttachmentPicker.tsx
14861
- function yb({ hasAttachments: e, disabled: t, onFilesSelected: n }) {
14895
+ function xb({ hasAttachments: e, disabled: t, onFilesSelected: n }) {
14862
14896
  let r = l(null);
14863
14897
  function i(e) {
14864
14898
  let t = Array.from(e.target.files ?? []);
@@ -14893,7 +14927,7 @@ function yb({ hasAttachments: e, disabled: t, onFilesSelected: n }) {
14893
14927
  }
14894
14928
  //#endregion
14895
14929
  //#region src/components/AgentAwareInput.tsx
14896
- function bb(e) {
14930
+ function Sb(e) {
14897
14931
  let t = a(xn), [n, r] = u(!1), i = l(0);
14898
14932
  if (!t) return /* @__PURE__ */ S(f, { ...e });
14899
14933
  let { attachedFiles: o, addFiles: s, removeFile: c, inputValue: d, setInputValue: p, handleSubmit: m, threadId: h } = t, g = yn;
@@ -14961,7 +14995,7 @@ function bb(e) {
14961
14995
  }),
14962
14996
  /* @__PURE__ */ S("div", {
14963
14997
  className: "erica-aware-input-main",
14964
- children: u === "transcribe" ? a : /* @__PURE__ */ S(vb, {
14998
+ children: u === "transcribe" ? a : /* @__PURE__ */ S(bb, {
14965
14999
  value: d,
14966
15000
  onChange: p,
14967
15001
  onSubmit: w,
@@ -14972,7 +15006,7 @@ function bb(e) {
14972
15006
  /* @__PURE__ */ C("div", {
14973
15007
  className: "erica-aware-input-toolbar",
14974
15008
  children: [
14975
- /* @__PURE__ */ S(yb, {
15009
+ /* @__PURE__ */ S(xb, {
14976
15010
  hasAttachments: o.length > 0,
14977
15011
  disabled: !h,
14978
15012
  onFilesSelected: s
@@ -14988,10 +15022,10 @@ function bb(e) {
14988
15022
  }
14989
15023
  //#endregion
14990
15024
  //#region src/components/ChatMessageSpinner.tsx
14991
- var xb = (e) => e.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").replace(/[_-]/g, " ").toLowerCase().trim().replace(/\s+/g, " ");
14992
- function Sb() {
15025
+ var Cb = (e) => e.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").replace(/[_-]/g, " ").toLowerCase().trim().replace(/\s+/g, " ");
15026
+ function wb() {
14993
15027
  let e = a(xn), t = "digesting";
14994
- return e?.step && (t = e.step === "ls" ? "listing files" : xb(e.step)), /* @__PURE__ */ C("div", {
15028
+ return e?.step && (t = e.step === "ls" ? "listing files" : Cb(e.step)), /* @__PURE__ */ C("div", {
14995
15029
  className: "chat-message-spinner-container",
14996
15030
  children: [/* @__PURE__ */ S("div", { className: "chat-message-spinner-icon" }), /* @__PURE__ */ C("div", {
14997
15031
  className: "chat-message-spinner-text",
@@ -15017,7 +15051,7 @@ function Sb() {
15017
15051
  }
15018
15052
  //#endregion
15019
15053
  //#region src/components/LoadingMessage.tsx
15020
- function Cb({ message: e }) {
15054
+ function Tb({ message: e }) {
15021
15055
  return /* @__PURE__ */ C("div", {
15022
15056
  className: "loading-message-container",
15023
15057
  children: [/* @__PURE__ */ S("div", { className: "loading-message-spinner" }), /* @__PURE__ */ C("div", {
@@ -15044,28 +15078,28 @@ function Cb({ message: e }) {
15044
15078
  }
15045
15079
  //#endregion
15046
15080
  //#region src/components/EricaChatHeader.tsx
15047
- function wb(e) {
15081
+ function Eb(e) {
15048
15082
  if (!e) return "";
15049
15083
  let t = e.split(":");
15050
15084
  return (t.length > 1 ? t.slice(1).join(" ") : e).replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
15051
15085
  }
15052
- function Tb(e) {
15086
+ function Db(e) {
15053
15087
  if (!e) return "";
15054
15088
  let t = Date.now() - new Date(e).getTime(), n = Math.floor(t / 6e4), r = Math.floor(n / 60), i = Math.floor(r / 24);
15055
15089
  return n < 1 ? "just now" : n < 60 ? `${n}m ago` : r < 24 ? `${r}h ago` : i < 7 ? `${i}d ago` : new Date(e).toLocaleDateString();
15056
15090
  }
15057
- function Eb({ onNewChat: e, onThreadSelect: t }) {
15058
- let [n, r] = u(!1), i = l(null), a = g(), { data: s = [], isLoading: c } = gn();
15091
+ function Ob({ onNewChat: e, onThreadSelect: t, isMaximized: n = !1, onToggleMaximize: r }) {
15092
+ let [i, a] = u(!1), s = l(null), c = g(), { data: d = [], isLoading: f } = gn();
15059
15093
  o(() => {
15060
15094
  function e(e) {
15061
- i.current && !i.current.contains(e.target) && r(!1);
15095
+ s.current && !s.current.contains(e.target) && a(!1);
15062
15096
  }
15063
- if (n) return document.addEventListener("mousedown", e), () => {
15097
+ if (i) return document.addEventListener("mousedown", e), () => {
15064
15098
  document.removeEventListener("mousedown", e);
15065
15099
  };
15066
- }, [n]);
15067
- function d(e) {
15068
- r(!1), t?.(e);
15100
+ }, [i]);
15101
+ function p(e) {
15102
+ a(!1), t?.(e);
15069
15103
  }
15070
15104
  return /* @__PURE__ */ C("div", {
15071
15105
  className: "erica-header",
@@ -15077,30 +15111,36 @@ function Eb({ onNewChat: e, onThreadSelect: t }) {
15077
15111
  })]
15078
15112
  }), /* @__PURE__ */ C("div", {
15079
15113
  className: "erica-header-controls",
15080
- ref: i,
15114
+ ref: s,
15081
15115
  children: [
15082
15116
  /* @__PURE__ */ S("button", {
15083
15117
  onClick: e,
15084
15118
  className: "erica-new-chat-button",
15085
15119
  title: "Start new chat",
15086
- children: /* @__PURE__ */ S(ab, { className: "erica-icon-sm" })
15120
+ children: /* @__PURE__ */ S(sb, { className: "erica-icon-sm" })
15087
15121
  }),
15088
15122
  /* @__PURE__ */ C("button", {
15089
- onClick: () => r(!n),
15123
+ onClick: () => a(!i),
15090
15124
  className: "erica-threads-toggle",
15091
15125
  title: "Recent threads",
15092
15126
  children: [/* @__PURE__ */ C("span", {
15093
15127
  className: "erica-threads-toggle-text",
15094
- children: ["Riwayat ", s.length > 0 && `(${s.length})`]
15095
- }), /* @__PURE__ */ S(rb, { className: `erica-threads-toggle-icon ${n ? "erica-threads-toggle-icon--open" : ""}` })]
15128
+ children: ["Riwayat ", d.length > 0 && `(${d.length})`]
15129
+ }), /* @__PURE__ */ S(rb, { className: `erica-threads-toggle-icon ${i ? "erica-threads-toggle-icon--open" : ""}` })]
15096
15130
  }),
15097
- a?.setModalOpen && /* @__PURE__ */ S("button", {
15098
- onClick: () => a.setModalOpen(!1),
15131
+ r && /* @__PURE__ */ S("button", {
15132
+ onClick: r,
15133
+ className: "erica-maximize-button",
15134
+ title: n ? "Restore chat" : "Maximize chat",
15135
+ children: S(n ? ob : ab, { className: "erica-icon-sm" })
15136
+ }),
15137
+ c?.setModalOpen && /* @__PURE__ */ S("button", {
15138
+ onClick: () => c.setModalOpen(!1),
15099
15139
  className: "erica-close-button",
15100
15140
  title: "Close sidebar",
15101
- children: /* @__PURE__ */ S(ob, { className: "erica-icon-sm" })
15141
+ children: /* @__PURE__ */ S(cb, { className: "erica-icon-sm" })
15102
15142
  }),
15103
- n && /* @__PURE__ */ S("div", {
15143
+ i && /* @__PURE__ */ S("div", {
15104
15144
  className: "erica-threads-dropdown",
15105
15145
  children: /* @__PURE__ */ C("div", {
15106
15146
  className: "erica-threads-dropdown-content",
@@ -15109,18 +15149,18 @@ function Eb({ onNewChat: e, onThreadSelect: t }) {
15109
15149
  className: "erica-threads-dropdown-header",
15110
15150
  children: "Riwayat Terakhir"
15111
15151
  }),
15112
- c && /* @__PURE__ */ S("div", {
15152
+ f && /* @__PURE__ */ S("div", {
15113
15153
  className: "erica-threads-empty",
15114
15154
  children: "Loading threads..."
15115
15155
  }),
15116
- !c && s.length === 0 && /* @__PURE__ */ S("div", {
15156
+ !f && d.length === 0 && /* @__PURE__ */ S("div", {
15117
15157
  className: "erica-threads-empty",
15118
15158
  children: "No conversations yet"
15119
15159
  }),
15120
- !c && s.map((e) => {
15121
- let t = wb(e.agent), n = Tb(e.last_run_at ?? e.created_at);
15160
+ !f && d.map((e) => {
15161
+ let t = Eb(e.agent), n = Db(e.last_run_at ?? e.created_at);
15122
15162
  return /* @__PURE__ */ S("button", {
15123
- onClick: () => d(e.uid),
15163
+ onClick: () => p(e.uid ?? ""),
15124
15164
  className: "erica-thread-item",
15125
15165
  children: /* @__PURE__ */ C("div", {
15126
15166
  className: "erica-thread-item-content",
@@ -15149,7 +15189,7 @@ function Eb({ onNewChat: e, onThreadSelect: t }) {
15149
15189
  }
15150
15190
  //#endregion
15151
15191
  //#region src/components/AttachmentItem.tsx
15152
- function Db({ attachment: e }) {
15192
+ function kb({ attachment: e }) {
15153
15193
  let [t, n] = u(!1);
15154
15194
  async function r() {
15155
15195
  n(!0);
@@ -15198,7 +15238,7 @@ function Db({ attachment: e }) {
15198
15238
  }
15199
15239
  //#endregion
15200
15240
  //#region src/components/AttachmentBlock.tsx
15201
- function Ob({ children: e }) {
15241
+ function Ab({ children: e }) {
15202
15242
  let t = String(e).trim(), n = [];
15203
15243
  try {
15204
15244
  n = JSON.parse(t);
@@ -15207,12 +15247,12 @@ function Ob({ children: e }) {
15207
15247
  }
15208
15248
  return n.length === 0 ? null : /* @__PURE__ */ S("div", {
15209
15249
  className: "flex flex-wrap gap-1.5 mt-1.5 py-1",
15210
- children: n.map((e, t) => /* @__PURE__ */ S(Db, { attachment: e }, t))
15250
+ children: n.map((e, t) => /* @__PURE__ */ S(kb, { attachment: e }, t))
15211
15251
  });
15212
15252
  }
15213
15253
  //#endregion
15214
15254
  //#region src/components/ChatToggleGreeting.tsx
15215
- function kb({ message: e = "Hai! Saya SPP AI, siap membantu Anda!", isOpen: t = !1, initialDelay: n = 1e4 }) {
15255
+ function jb({ message: e = "Hai! Saya SPP AI, siap membantu Anda!", isOpen: t = !1, initialDelay: n = 1e4 }) {
15216
15256
  let [r, i] = u(!1), [a, s] = u(!1);
15217
15257
  return o(() => {
15218
15258
  let e = setTimeout(() => {
@@ -15229,29 +15269,29 @@ function kb({ message: e = "Hai! Saya SPP AI, siap membantu Anda!", isOpen: t =
15229
15269
  },
15230
15270
  className: "chat-toggle-greeting-close",
15231
15271
  "aria-label": "Dismiss greeting",
15232
- children: /* @__PURE__ */ S(ob, {})
15272
+ children: /* @__PURE__ */ S(cb, {})
15233
15273
  })]
15234
15274
  })
15235
15275
  });
15236
15276
  }
15237
15277
  //#endregion
15238
15278
  //#region node_modules/mdast-util-newline-to-break/lib/index.js
15239
- function Ab(e) {
15240
- Dh(e, [/\r?\n|\r/g, jb]);
15279
+ function Mb(e) {
15280
+ Dh(e, [/\r?\n|\r/g, Nb]);
15241
15281
  }
15242
- function jb() {
15282
+ function Nb() {
15243
15283
  return { type: "break" };
15244
15284
  }
15245
15285
  //#endregion
15246
15286
  //#region node_modules/remark-breaks/lib/index.js
15247
- function Mb() {
15287
+ function Pb() {
15248
15288
  return function(e) {
15249
- Ab(e);
15289
+ Mb(e);
15250
15290
  };
15251
15291
  }
15252
15292
  //#endregion
15253
15293
  //#region src/components/EricaChat.tsx
15254
- var Nb = () => (e) => {
15294
+ var Fb = () => (e) => {
15255
15295
  let t = (e) => {
15256
15296
  [
15257
15297
  "containerDirective",
@@ -15260,128 +15300,135 @@ var Nb = () => (e) => {
15260
15300
  ].includes(e.type) && e.name === "tool_call_content" && (e.data = e.data || {}, e.data.hName = e.name, e.data.hProperties = e.attributes || {}, e.children = []), e.children && e.children.forEach(t);
15261
15301
  };
15262
15302
  t(e);
15263
- }, Pb = () => (e) => {
15303
+ }, Ib = () => (e) => {
15264
15304
  let t = (e) => {
15265
15305
  e.type === "textDirective" && e.name === "resource" && (e.data = e.data || {}, e.data.hName = "resource", e.data.hProperties = e.attributes || {}), e.children && e.children.forEach(t);
15266
15306
  };
15267
15307
  t(e);
15268
15308
  };
15269
- function Fb({ runtimeUrl: e, widgetToken: t, requiresSandbox: n = !1 }) {
15270
- let [r, a] = u(void 0), [s, l] = u(!0), [f, h] = u(!1), [g, _] = u(0), [v, y] = u(!0), [b, w] = u(!1), T = c(() => {
15309
+ function Lb({ threadId: e, isLoadingThreadId: t, isLoadingSandbox: n, isSandboxReady: r, isNewThread: a, handleNewChat: o, handleThreadSelect: s, requiresSandbox: c, isModalOpen: l, isMaximized: u, setIsMaximized: d }) {
15310
+ let f = "Halo! Saya asisten AI SPP, ada yg bisa saya bantu?";
15311
+ t ? f = /* @__PURE__ */ S(Tb, { message: "Initializing conversation" }) : c && a && n ? f = /* @__PURE__ */ S(Tb, { message: "Preparing workspace" }) : c && a && !r && (f = /* @__PURE__ */ S(Tb, { message: "Setting up environment" }));
15312
+ let p = i(() => /* @__PURE__ */ S(Ob, {
15313
+ onNewChat: o,
15314
+ onThreadSelect: s,
15315
+ isMaximized: u,
15316
+ onToggleMaximize: () => d((e) => !e)
15317
+ }), [
15318
+ o,
15319
+ s,
15320
+ u,
15321
+ d
15322
+ ]);
15323
+ return /* @__PURE__ */ C("div", {
15324
+ className: `erica-chat-container${u ? " erica-chat-maximized" : ""}`,
15325
+ children: [
15326
+ /* @__PURE__ */ S(fb, {}),
15327
+ /* @__PURE__ */ S(jb, {
15328
+ message: "Hai! Saya SPP AI, siap membantu Anda!",
15329
+ isOpen: l,
15330
+ initialDelay: 1e4
15331
+ }),
15332
+ /* @__PURE__ */ S(m, {
15333
+ welcomeScreen: !0,
15334
+ header: p,
15335
+ labels: {
15336
+ chatInputPlaceholder: "Ketik pertanyaan Anda di sini...",
15337
+ welcomeMessageText: f,
15338
+ chatDisclaimerText: "AI dapat membuat kesalahan. Harap verifikasi informasi penting."
15339
+ },
15340
+ threadId: e,
15341
+ input: Sb,
15342
+ messageView: {
15343
+ cursor: wb,
15344
+ userMessage: { messageRenderer: ({ content: e, className: t }) => /* @__PURE__ */ S("div", {
15345
+ className: ["cpk:prose cpk:dark:prose-invert cpk:bg-smi cpk:relative cpk:max-w-[80%] cpk:rounded-[18px] cpk:px-4 cpk:py-1.5 cpk:data-[multiline]:py-3 cpk:inline-block", t].filter(Boolean).join(" "),
15346
+ children: /* @__PURE__ */ S(bh, {
15347
+ remarkPlugins: [
15348
+ Pb,
15349
+ wv,
15350
+ zy,
15351
+ Ib
15352
+ ],
15353
+ components: {
15354
+ pre: ({ children: e }) => /* @__PURE__ */ S(x, { children: e }),
15355
+ code({ children: e, className: t }) {
15356
+ return /language-(\w+)/.exec(t || "")?.[1] === "attachments" ? /* @__PURE__ */ S(Ab, { children: e }) : /* @__PURE__ */ S("code", {
15357
+ className: t,
15358
+ style: {
15359
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
15360
+ fontSize: "0.85em"
15361
+ },
15362
+ children: e
15363
+ });
15364
+ },
15365
+ resource: ({ children: e }) => /* @__PURE__ */ C("span", {
15366
+ className: "erica-resource-tag",
15367
+ children: ["@", e]
15368
+ }),
15369
+ table: ({ children: e }) => /* @__PURE__ */ S("div", {
15370
+ className: "markdown-table-wrapper",
15371
+ children: /* @__PURE__ */ S("table", { children: e })
15372
+ })
15373
+ },
15374
+ children: e
15375
+ })
15376
+ }) },
15377
+ assistantMessage: {
15378
+ className: "prose lg:prose-xl",
15379
+ toolbarVisible: !1,
15380
+ markdownRenderer: ({ content: e }) => !e || e.trim() === "" ? /* @__PURE__ */ S(x, {}) : /* @__PURE__ */ S(bh, {
15381
+ remarkPlugins: [
15382
+ Pb,
15383
+ wv,
15384
+ zy,
15385
+ Fb
15386
+ ],
15387
+ components: {
15388
+ tool_call_content: ({ children: e, ...t }) => /* @__PURE__ */ S("div", {
15389
+ className: "tool-call-content",
15390
+ ...t,
15391
+ children: e
15392
+ }),
15393
+ table: ({ children: e }) => /* @__PURE__ */ S("div", {
15394
+ className: "markdown-table-wrapper",
15395
+ children: /* @__PURE__ */ S("table", { children: e })
15396
+ })
15397
+ },
15398
+ children: e
15399
+ })
15400
+ }
15401
+ },
15402
+ defaultOpen: l
15403
+ })
15404
+ ]
15405
+ });
15406
+ }
15407
+ function Rb({ runtimeUrl: e, widgetToken: t, requiresSandbox: n = !1 }) {
15408
+ let [r, a] = u(void 0), [s, l] = u(!0), [f, m] = u(!1), [h, g] = u(0), [_, v] = u(!0), [y, b] = u(!1), [x, C] = u(!1), w = c(() => {
15271
15409
  let t = new URL(e), n = t.pathname.split("/").filter(Boolean);
15272
15410
  return n.length > 2 && n.pop(), t.pathname = "/" + n.join("/"), t.toString();
15273
15411
  }, [e]);
15274
15412
  c(() => {
15275
- Fe(T, t);
15276
- }, [T, t]);
15277
- let { data: E, isLoading: D } = _n(s, g), { isLoading: O, isSuccess: ee } = vn(r || "", f);
15413
+ Fe(w, t);
15414
+ }, [w, t]);
15415
+ let { data: T, isLoading: E } = _n(s, h), { isLoading: D, isSuccess: O } = vn(r || "", f);
15278
15416
  o(() => {
15279
- ee && v && b && w(!0);
15417
+ O && _ && y && b(!0);
15280
15418
  }, [
15281
- ee,
15282
- v,
15283
- b
15419
+ O,
15420
+ _,
15421
+ y
15284
15422
  ]), o(() => {
15285
- E && (a(E), l(!1), h(n), y(!0));
15286
- }, [E, n]), o(() => () => {
15287
- r && v && mn.deleteSandbox(r).catch(() => {});
15288
- }, [r, v]);
15289
- let te = i(() => {
15290
- a(void 0), l(!0), h(!1), _((e) => e + 1), y(!0), w(!0);
15291
- }, []), ne = i((e) => {
15292
- a(e), l(!1), h(!1), y(!1), w(!0);
15423
+ T && (a(T), l(!1), m(n), v(!0));
15424
+ }, [T, n]), o(() => () => {
15425
+ r && _ && mn.deleteSandbox(r).catch(() => {});
15426
+ }, [r, _]);
15427
+ let ee = i(() => {
15428
+ a(void 0), l(!0), m(!1), g((e) => e + 1), v(!0), b(!0);
15429
+ }, []), te = i((e) => {
15430
+ a(e), l(!1), m(!1), v(!1), b(!0);
15293
15431
  }, []);
15294
- function k({ threadId: e, isLoadingThreadId: t, isLoadingSandbox: r, isSandboxReady: a, isNewThread: o, handleNewChat: s, handleThreadSelect: c }) {
15295
- let l = "Halo! Saya asisten AI SPP, ada yg bisa saya bantu?";
15296
- t ? l = /* @__PURE__ */ S(Cb, { message: "Initializing conversation" }) : n && o && r ? l = /* @__PURE__ */ S(Cb, { message: "Preparing workspace" }) : n && o && !a && (l = /* @__PURE__ */ S(Cb, { message: "Setting up environment" }));
15297
- let u = i(() => /* @__PURE__ */ S(Eb, {
15298
- onNewChat: s,
15299
- onThreadSelect: c
15300
- }), [s, c]);
15301
- return /* @__PURE__ */ C("div", {
15302
- className: "erica-chat-container",
15303
- children: [
15304
- /* @__PURE__ */ S(ub, {}),
15305
- /* @__PURE__ */ S(kb, {
15306
- message: "Hai! Saya SPP AI, siap membantu Anda!",
15307
- isOpen: b,
15308
- initialDelay: 1e4
15309
- }),
15310
- /* @__PURE__ */ S(m, {
15311
- welcomeScreen: !0,
15312
- header: u,
15313
- labels: {
15314
- chatInputPlaceholder: "Ketik pertanyaan Anda di sini...",
15315
- welcomeMessageText: l,
15316
- chatDisclaimerText: "AI dapat membuat kesalahan. Harap verifikasi informasi penting."
15317
- },
15318
- threadId: e,
15319
- input: bb,
15320
- messageView: {
15321
- cursor: Sb,
15322
- userMessage: { messageRenderer: ({ content: e, className: t }) => /* @__PURE__ */ S("div", {
15323
- className: ["cpk:prose cpk:dark:prose-invert cpk:bg-smi cpk:relative cpk:max-w-[80%] cpk:rounded-[18px] cpk:px-4 cpk:py-1.5 cpk:data-[multiline]:py-3 cpk:inline-block", t].filter(Boolean).join(" "),
15324
- children: /* @__PURE__ */ S(bh, {
15325
- remarkPlugins: [
15326
- Mb,
15327
- wv,
15328
- zy,
15329
- Pb
15330
- ],
15331
- components: {
15332
- pre: ({ children: e }) => /* @__PURE__ */ S(x, { children: e }),
15333
- code({ children: e, className: t }) {
15334
- return /language-(\w+)/.exec(t || "")?.[1] === "attachments" ? /* @__PURE__ */ S(Ob, { children: e }) : /* @__PURE__ */ S("code", {
15335
- className: t,
15336
- style: {
15337
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
15338
- fontSize: "0.85em"
15339
- },
15340
- children: e
15341
- });
15342
- },
15343
- resource: ({ children: e }) => /* @__PURE__ */ C("span", {
15344
- className: "erica-resource-tag",
15345
- children: ["@", e]
15346
- }),
15347
- table: ({ children: e }) => /* @__PURE__ */ S("div", {
15348
- className: "markdown-table-wrapper",
15349
- children: /* @__PURE__ */ S("table", { children: e })
15350
- })
15351
- },
15352
- children: e
15353
- })
15354
- }) },
15355
- assistantMessage: {
15356
- className: "prose lg:prose-xl",
15357
- toolbarVisible: !1,
15358
- markdownRenderer: ({ content: e }) => !e || e.trim() === "" ? /* @__PURE__ */ S(x, {}) : /* @__PURE__ */ S(bh, {
15359
- remarkPlugins: [
15360
- Mb,
15361
- wv,
15362
- zy,
15363
- Nb
15364
- ],
15365
- components: {
15366
- tool_call_content: ({ children: e, ...t }) => /* @__PURE__ */ S("div", {
15367
- className: "tool-call-content",
15368
- ...t,
15369
- children: e
15370
- }),
15371
- table: ({ children: e }) => /* @__PURE__ */ S("div", {
15372
- className: "markdown-table-wrapper",
15373
- children: /* @__PURE__ */ S("table", { children: e })
15374
- })
15375
- },
15376
- children: e
15377
- })
15378
- }
15379
- },
15380
- defaultOpen: b
15381
- })
15382
- ]
15383
- });
15384
- }
15385
15432
  return /* @__PURE__ */ S(d, { children: /* @__PURE__ */ S(p, {
15386
15433
  runtimeUrl: e,
15387
15434
  headers: { Authorization: `Bearer ${t}` },
@@ -15391,38 +15438,42 @@ function Fb({ runtimeUrl: e, widgetToken: t, requiresSandbox: n = !1 }) {
15391
15438
  children: /* @__PURE__ */ S(Cn, {
15392
15439
  threadId: r,
15393
15440
  agentIdentifier: yn,
15394
- children: /* @__PURE__ */ S(k, {
15441
+ children: /* @__PURE__ */ S(Lb, {
15395
15442
  threadId: r,
15396
- isLoadingThreadId: D,
15397
- isLoadingSandbox: O,
15398
- isSandboxReady: ee,
15399
- isNewThread: v,
15400
- handleNewChat: te,
15401
- handleThreadSelect: ne
15443
+ isLoadingThreadId: E,
15444
+ isLoadingSandbox: D,
15445
+ isSandboxReady: O,
15446
+ isNewThread: _,
15447
+ handleNewChat: ee,
15448
+ handleThreadSelect: te,
15449
+ requiresSandbox: n,
15450
+ isModalOpen: y,
15451
+ isMaximized: x,
15452
+ setIsMaximized: C
15402
15453
  })
15403
15454
  })
15404
15455
  }) });
15405
15456
  }
15406
15457
  //#endregion
15407
15458
  //#region src/contexts/AccountContext.tsx
15408
- var Ib = t(void 0);
15409
- function Lb({ accountUid: e, children: t }) {
15410
- return /* @__PURE__ */ S(Ib.Provider, {
15459
+ var zb = t(void 0);
15460
+ function Bb({ accountUid: e, children: t }) {
15461
+ return /* @__PURE__ */ S(zb.Provider, {
15411
15462
  value: { accountUid: e },
15412
15463
  children: t
15413
15464
  });
15414
15465
  }
15415
15466
  //#endregion
15416
15467
  //#region src/contexts/EricaProvider.tsx
15417
- var Rb = new Vt({ defaultOptions: { queries: {
15468
+ var Vb = new Vt({ defaultOptions: { queries: {
15418
15469
  refetchOnWindowFocus: !1,
15419
15470
  retry: 1,
15420
15471
  staleTime: 3e4
15421
15472
  } } });
15422
- function zb({ accountUid: e, children: t }) {
15473
+ function Hb({ accountUid: e, children: t }) {
15423
15474
  return /* @__PURE__ */ S(Wt, {
15424
- client: Rb,
15425
- children: /* @__PURE__ */ S(Lb, {
15475
+ client: Vb,
15476
+ children: /* @__PURE__ */ S(Bb, {
15426
15477
  accountUid: e,
15427
15478
  children: /* @__PURE__ */ S(qc, { children: t })
15428
15479
  })
@@ -15430,7 +15481,7 @@ function zb({ accountUid: e, children: t }) {
15430
15481
  }
15431
15482
  //#endregion
15432
15483
  //#region src/components/EricaDrawer.tsx
15433
- function Bb() {
15484
+ function Ub() {
15434
15485
  let { isOpen: e, onClose: t, content: n, title: r } = Jc(), [i, a] = u(!1);
15435
15486
  return o(() => {
15436
15487
  e ? setTimeout(() => a(!0), 10) : a(!1);
@@ -15450,7 +15501,7 @@ function Bb() {
15450
15501
  onClick: t,
15451
15502
  className: "erica-artifact-close-button",
15452
15503
  "aria-label": "Close drawer",
15453
- children: /* @__PURE__ */ S(ob, { className: "erica-icon-md" })
15504
+ children: /* @__PURE__ */ S(cb, { className: "erica-icon-md" })
15454
15505
  })]
15455
15506
  }), /* @__PURE__ */ S("div", {
15456
15507
  className: "erica-artifact-body",
@@ -15460,6 +15511,6 @@ function Bb() {
15460
15511
  }) : null;
15461
15512
  }
15462
15513
  //#endregion
15463
- export { qc as ArtifactProvider, Fb as EricaChat, Bb as EricaDrawer, zb as EricaProvider };
15514
+ export { qc as ArtifactProvider, Rb as EricaChat, Ub as EricaDrawer, Hb as EricaProvider };
15464
15515
 
15465
15516
  //# sourceMappingURL=index.mjs.map