@takeshape/purchase-order-chat 1.67.0 → 1.69.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.
@@ -1,7 +1,7 @@
1
- import { useState as _, useEffect as O, createElement as Zr, useRef as R, useLayoutEffect as Bt, useCallback as M, createContext as en, useContext as tn, useMemo as te, forwardRef as rn, useImperativeHandle as nn } from "react";
2
- import { jsxs as f, jsx as a, Fragment as we } from "react/jsx-runtime";
1
+ import { useState as _, useEffect as F, createElement as Zr, useRef as O, useLayoutEffect as Bt, useCallback as M, createContext as en, useContext as tn, useMemo as re, forwardRef as rn, useImperativeHandle as nn } from "react";
2
+ import { jsxs as f, jsx as a, Fragment as Pe } from "react/jsx-runtime";
3
3
  import { GraphQLClient as yt, ClientError as sn } from "graphql-request";
4
- import { initGraphQLTada as sr, readFragment as Pe } from "gql.tada";
4
+ import { initGraphQLTada as sr, readFragment as Te } from "gql.tada";
5
5
  import { useChat as ar } from "@ai-sdk/react";
6
6
  import { QueryClientProvider as an, QueryClient as on } from "@tanstack/react-query";
7
7
  import { parseJsonEventStream as cn, uiMessageChunkSchema as ln, DefaultChatTransport as or, isToolUIPart as dn } from "ai";
@@ -12,7 +12,7 @@ import { devtools as pn, persist as ir } from "zustand/middleware";
12
12
  import { Streamdown as Je } from "streamdown";
13
13
  import { z as Mt } from "zod";
14
14
  import fn from "p-map";
15
- function Ae(...t) {
15
+ function $e(...t) {
16
16
  return hn(un(t));
17
17
  }
18
18
  function xi(t, e) {
@@ -21,21 +21,21 @@ function xi(t, e) {
21
21
  return o != null ? String(o) : "";
22
22
  });
23
23
  }
24
- const mn = "__vite_c_css_pos_initial_ad971a190c454cdc942e2bc117b717f3", Ft = "__vite_c_css_pos_update_ad971a190c454cdc942e2bc117b717f3", Ot = () => typeof window < "u" ? window[mn] : void 0, bi = (t) => {
25
- const [e, r] = _(() => Ot() || /* @__PURE__ */ new Map()), [n, o] = _(0);
26
- return O(() => {
24
+ const mn = "__vite_c_css_pos_initial_55dee7656fcc47b0816d7c079eae5250", Rt = "__vite_c_css_pos_update_55dee7656fcc47b0816d7c079eae5250", Ft = () => typeof window < "u" ? window[mn] : void 0, bi = (t) => {
25
+ const [e, r] = _(() => Ft() || /* @__PURE__ */ new Map()), [n, o] = _(0);
26
+ return F(() => {
27
27
  const s = (i) => {
28
- const c = Ot() || /* @__PURE__ */ new Map();
28
+ const c = Ft() || /* @__PURE__ */ new Map();
29
29
  r(c), o((l) => l + 1), t.onChange?.(c);
30
30
  };
31
- return window.addEventListener(Ft, s), s(), () => {
32
- window.removeEventListener(Ft, s);
31
+ return window.addEventListener(Rt, s), s(), () => {
32
+ window.removeEventListener(Rt, s);
33
33
  };
34
34
  }, [t.onChange]), Array.from(e?.keys() || []).map((s) => {
35
35
  const i = e.get(s);
36
36
  return i ? /* @__PURE__ */ Zr("style", { ...i.attributes, key: `${s}-${n}` }, i.css) : null;
37
37
  });
38
- }, Xe = "bigcommercePurchaseOrderAgent", gn = "cartChecker", Rt = "https://api.takeshape.io", cr = "https://api-b2b.bigcommerce.com/graphql", yn = "dl7c39mdpul6hyc489yk0vzxl6jesyx", je = "[client is providing tool response]", ve = "__po_address__", Ne = "__po_billing_address__", ue = "__checkout_address__", xt = "purchase-order-chat-session", lr = 3, Cn = {
38
+ }, Xe = "bigcommercePurchaseOrderAgent", gn = "cartChecker", Ot = "https://api.takeshape.io", cr = "https://api-b2b.bigcommerce.com/graphql", yn = "dl7c39mdpul6hyc489yk0vzxl6jesyx", Ve = "[client is providing tool response]", Ie = "__po_address__", Ne = "__po_billing_address__", pe = "__checkout_address__", xt = "purchase-order-chat-session", lr = 3, Cn = {
39
39
  end: () => {
40
40
  },
41
41
  setStatus: () => {
@@ -43,15 +43,15 @@ const mn = "__vite_c_css_pos_initial_ad971a190c454cdc942e2bc117b717f3", Ft = "__
43
43
  setAttribute: () => {
44
44
  }
45
45
  };
46
- let ee = null;
46
+ let te = null;
47
47
  function vi(t) {
48
- ee = t;
48
+ te = t;
49
49
  }
50
- function Ie(t) {
51
- return ee ? ee.startInactiveSpan(t) : Cn;
50
+ function we(t) {
51
+ return te ? te.startInactiveSpan(t) : Cn;
52
52
  }
53
53
  function Oe(t, e) {
54
- return ee ? ee.withActiveSpan(t, e) : e();
54
+ return te ? te.withActiveSpan(t, e) : e();
55
55
  }
56
56
  let Ze = null;
57
57
  function ce(t) {
@@ -63,9 +63,9 @@ function bt() {
63
63
  function dr(t, e) {
64
64
  const { tracePropagationTargets: r = [], streaming: n = !1 } = e ?? {};
65
65
  return async (o, s) => {
66
- if (!ee)
66
+ if (!te)
67
67
  return t(o, s);
68
- const i = o instanceof Request ? o.url : String(o), c = s?.method ?? (o instanceof Request ? o.method : "GET"), l = ee.getActiveSpan?.(), d = ee.startInactiveSpan({
68
+ const i = o instanceof Request ? o.url : String(o), c = s?.method ?? (o instanceof Request ? o.method : "GET"), l = te.getActiveSpan?.(), d = te.startInactiveSpan({
69
69
  name: `${c} ${i}`,
70
70
  op: "http.client",
71
71
  attributes: {
@@ -75,19 +75,19 @@ function dr(t, e) {
75
75
  ...!l && Ze ? { parentSpan: Ze } : {}
76
76
  });
77
77
  let h = s;
78
- if (r.some((p) => p.test(i))) {
79
- const p = ee.getActiveSpan?.() ?? d;
80
- if (p) {
81
- const g = ee.spanToTraceHeader?.(p), x = ee.spanToBaggageHeader?.(p), m = new Headers(s?.headers);
78
+ if (r.some((u) => u.test(i))) {
79
+ const u = te.getActiveSpan?.() ?? d;
80
+ if (u) {
81
+ const g = te.spanToTraceHeader?.(u), x = te.spanToBaggageHeader?.(u), m = new Headers(s?.headers);
82
82
  g && m.set("sentry-trace", g), x && m.set("baggage", x), h = { ...s, headers: m };
83
83
  }
84
84
  }
85
85
  try {
86
- const p = await t(o, h);
87
- if (d.setAttribute("http.response.status_code", p.status), p.status >= 400)
88
- return d.setStatus({ code: 2, message: `HTTP ${p.status}` }), d.end(), p;
89
- if (n && p.body) {
90
- const g = p.body.getReader(), x = new ReadableStream({
86
+ const u = await t(o, h);
87
+ if (d.setAttribute("http.response.status_code", u.status), u.status >= 400)
88
+ return d.setStatus({ code: 2, message: `HTTP ${u.status}` }), d.end(), u;
89
+ if (n && u.body) {
90
+ const g = u.body.getReader(), x = new ReadableStream({
91
91
  async pull(m) {
92
92
  try {
93
93
  const { done: b, value: v } = await g.read();
@@ -104,28 +104,28 @@ function dr(t, e) {
104
104
  }
105
105
  });
106
106
  return new Response(x, {
107
- status: p.status,
108
- statusText: p.statusText,
109
- headers: p.headers
107
+ status: u.status,
108
+ statusText: u.statusText,
109
+ headers: u.headers
110
110
  });
111
111
  }
112
- return d.setStatus({ code: 1, message: "ok" }), d.end(), p;
113
- } catch (p) {
112
+ return d.setStatus({ code: 1, message: "ok" }), d.end(), u;
113
+ } catch (u) {
114
114
  throw d.setStatus({
115
115
  code: 2,
116
- message: p instanceof Error ? p.message : "unknown error"
117
- }), d.end(), p;
116
+ message: u instanceof Error ? u.message : "unknown error"
117
+ }), d.end(), u;
118
118
  }
119
119
  };
120
120
  }
121
121
  function ft(t, e) {
122
- ee && ee.captureException(t, {
122
+ te && te.captureException(t, {
123
123
  tags: e?.tags,
124
124
  extra: e?.extra
125
125
  });
126
126
  }
127
127
  function xn(t, e) {
128
- ee && ee.captureFeedback(
128
+ te && te.captureFeedback(
129
129
  t,
130
130
  e?.tags ? {
131
131
  captureContext: {
@@ -149,7 +149,7 @@ function bn() {
149
149
  }
150
150
  const vn = bn(), ur = vn;
151
151
  let ct = null;
152
- const Te = (t, e) => (ct || (ct = dr(ur, {
152
+ const Ae = (t, e) => (ct || (ct = dr(ur, {
153
153
  tracePropagationTargets: [/takeshape\.io/]
154
154
  })), ct(t, e));
155
155
  let lt = null;
@@ -246,7 +246,7 @@ const Sn = Se(
246
246
  }
247
247
  }
248
248
  `
249
- ), V = sr(), Re = V(`
249
+ ), V = sr(), _e = V(`
250
250
  fragment CartFields on Cart {
251
251
  id
252
252
  entityId
@@ -331,7 +331,7 @@ const Sn = Se(
331
331
  }
332
332
  }
333
333
  `,
334
- [Re]
334
+ [_e]
335
335
  ), En = V(
336
336
  `
337
337
  mutation CreateCart($input: CreateCartInput!) {
@@ -344,7 +344,7 @@ const Sn = Se(
344
344
  }
345
345
  }
346
346
  `,
347
- [Re]
347
+ [_e]
348
348
  ), Nn = V(
349
349
  `
350
350
  mutation AddCartLineItems($input: AddCartLineItemsInput!) {
@@ -357,7 +357,7 @@ const Sn = Se(
357
357
  }
358
358
  }
359
359
  `,
360
- [Re]
360
+ [_e]
361
361
  ), Pn = V(
362
362
  `
363
363
  mutation UpdateCartLineItem($input: UpdateCartLineItemInput!) {
@@ -370,7 +370,7 @@ const Sn = Se(
370
370
  }
371
371
  }
372
372
  `,
373
- [Re]
373
+ [_e]
374
374
  ), Tn = V(
375
375
  `
376
376
  mutation DeleteCartLineItem($input: DeleteCartLineItemInput!) {
@@ -383,7 +383,7 @@ const Sn = Se(
383
383
  }
384
384
  }
385
385
  `,
386
- [Re]
386
+ [_e]
387
387
  ), An = V(`
388
388
  mutation DeleteCart($input: DeleteCartInput!) {
389
389
  cart {
@@ -413,7 +413,7 @@ const Sn = Se(
413
413
  }
414
414
  }
415
415
  }
416
- `), _e = V(`
416
+ `), De = V(`
417
417
  fragment CheckoutFields on Checkout {
418
418
  entityId
419
419
  subtotal {
@@ -499,8 +499,8 @@ const Sn = Se(
499
499
  }
500
500
  }
501
501
  `,
502
- [_e]
503
- ), Fn = V(
502
+ [De]
503
+ ), Rn = V(
504
504
  `
505
505
  mutation AddCheckoutShippingConsignments($input: AddCheckoutShippingConsignmentsInput!) {
506
506
  checkout {
@@ -512,8 +512,8 @@ const Sn = Se(
512
512
  }
513
513
  }
514
514
  `,
515
- [_e]
516
- ), On = V(
515
+ [De]
516
+ ), Fn = V(
517
517
  `
518
518
  mutation AddCheckoutBillingAddressMutation($input: AddCheckoutBillingAddressInput!) {
519
519
  checkout {
@@ -525,7 +525,7 @@ const Sn = Se(
525
525
  }
526
526
  }
527
527
  `,
528
- [_e]
528
+ [De]
529
529
  );
530
530
  V(
531
531
  `
@@ -539,9 +539,9 @@ V(
539
539
  }
540
540
  }
541
541
  `,
542
- [_e]
542
+ [De]
543
543
  );
544
- const Rn = V(
544
+ const On = V(
545
545
  `
546
546
  mutation UpdateCheckoutCustomerMessage($input: UpdateCheckoutCustomerMessageInput!) {
547
547
  checkout {
@@ -553,7 +553,7 @@ const Rn = V(
553
553
  }
554
554
  }
555
555
  `,
556
- [_e]
556
+ [De]
557
557
  ), _t = V(`
558
558
  query GetProductDisplayData($entityIds: [Int!], $variantEntityIds: [Int!], $first: Int = 50) {
559
559
  site {
@@ -955,7 +955,7 @@ V(`
955
955
  }
956
956
  `);
957
957
  function Vn(t) {
958
- const e = Pe(mr, t);
958
+ const e = Te(mr, t);
959
959
  return {
960
960
  source: "b2b",
961
961
  id: `${e.id}`,
@@ -977,7 +977,7 @@ function Vn(t) {
977
977
  };
978
978
  }
979
979
  function Wn(t, e = 0) {
980
- const r = Pe(gr, t);
980
+ const r = Te(gr, t);
981
981
  return {
982
982
  source: "storefront",
983
983
  id: `${r.entityId}`,
@@ -1012,7 +1012,7 @@ function He(t, e) {
1012
1012
  countryCode: t.countryCode ?? "US",
1013
1013
  postalCode: t.postalCode,
1014
1014
  phone: t.phone,
1015
- isShipping: e.id === ve,
1015
+ isShipping: e.id === Ie,
1016
1016
  isBilling: e.id === Ne,
1017
1017
  isDefaultShipping: !1,
1018
1018
  isDefaultBilling: !1,
@@ -1020,7 +1020,7 @@ function He(t, e) {
1020
1020
  };
1021
1021
  }
1022
1022
  const zn = 20;
1023
- async function Qe(t, e, r, n) {
1023
+ async function Ge(t, e, r, n) {
1024
1024
  const o = [];
1025
1025
  let s, i = 0;
1026
1026
  for (; i < zn; ) {
@@ -1034,17 +1034,17 @@ async function Qe(t, e, r, n) {
1034
1034
  }
1035
1035
  return o;
1036
1036
  }
1037
- const be = 20;
1038
- function Ue(t) {
1039
- return Pe(Re, t);
1037
+ const ve = 20;
1038
+ function qe(t) {
1039
+ return Te(_e, t);
1040
1040
  }
1041
- function Ge(t) {
1042
- return Pe(_e, t);
1041
+ function Qe(t) {
1042
+ return Te(De, t);
1043
1043
  }
1044
1044
  function Hn(t) {
1045
1045
  return t.startsWith("http://") || t.startsWith("https://") ? t : typeof window < "u" && window.location?.origin ? `${window.location.origin}${t.startsWith("/") ? "" : "/"}${t}` : t;
1046
1046
  }
1047
- class Qn {
1047
+ class Gn {
1048
1048
  endpoint;
1049
1049
  storefrontToken;
1050
1050
  graphQLClient;
@@ -1059,7 +1059,7 @@ class Qn {
1059
1059
  accept: "application/json"
1060
1060
  };
1061
1061
  this.storefrontToken && (r.authorization = `Bearer ${this.storefrontToken}`), this.graphQLClient = new yt(this.endpoint, {
1062
- fetch: Te,
1062
+ fetch: Ae,
1063
1063
  credentials: "same-origin",
1064
1064
  headers: r
1065
1065
  });
@@ -1139,7 +1139,7 @@ class Qn {
1139
1139
  cartEntityId: e
1140
1140
  }
1141
1141
  })).site.cart;
1142
- return n ? Ue(n) : null;
1142
+ return n ? qe(n) : null;
1143
1143
  }
1144
1144
  /**
1145
1145
  * Create a new cart with line items
@@ -1153,12 +1153,12 @@ class Qn {
1153
1153
  throw new Error("Cannot create cart with no line items");
1154
1154
  return { cart: null, errors: r };
1155
1155
  }
1156
- const n = [...r], o = e.slice(0, be);
1156
+ const n = [...r], o = e.slice(0, ve);
1157
1157
  try {
1158
1158
  const i = await this.createCartBatch(o);
1159
1159
  if (i) {
1160
- if (e.length > be) {
1161
- const c = e.slice(be), { cart: l, errors: d } = await this.addCartLineItems(i.entityId, c);
1160
+ if (e.length > ve) {
1161
+ const c = e.slice(ve), { cart: l, errors: d } = await this.addCartLineItems(i.entityId, c);
1162
1162
  return {
1163
1163
  cart: l ?? i,
1164
1164
  errors: [...n, ...d]
@@ -1177,14 +1177,14 @@ class Qn {
1177
1177
  else {
1178
1178
  const { cart: c, errors: l } = await this.isolateCartCreation(o);
1179
1179
  if (c) {
1180
- if (e.length > be) {
1181
- const d = e.slice(be), { cart: h, errors: u } = await this.addCartLineItems(
1180
+ if (e.length > ve) {
1181
+ const d = e.slice(ve), { cart: h, errors: p } = await this.addCartLineItems(
1182
1182
  c.entityId,
1183
1183
  d
1184
1184
  );
1185
1185
  return {
1186
1186
  cart: h ?? c,
1187
- errors: [...n, ...l, ...u]
1187
+ errors: [...n, ...l, ...p]
1188
1188
  };
1189
1189
  }
1190
1190
  return {
@@ -1200,7 +1200,7 @@ class Qn {
1200
1200
  message: this.extractErrorMessage(i)
1201
1201
  });
1202
1202
  }
1203
- const s = e.slice(be);
1203
+ const s = e.slice(ve);
1204
1204
  return this.createCart(s, n);
1205
1205
  }
1206
1206
  /**
@@ -1226,7 +1226,7 @@ class Qn {
1226
1226
  },
1227
1227
  { retry: n }
1228
1228
  )).cart.addCartLineItems?.cart;
1229
- return s ? Ue(s) : null;
1229
+ return s ? qe(s) : null;
1230
1230
  }
1231
1231
  /**
1232
1232
  * Try to add a batch to cart, isolating failures if needed.
@@ -1280,7 +1280,7 @@ class Qn {
1280
1280
  },
1281
1281
  { retry: r }
1282
1282
  )).cart.createCart?.cart;
1283
- return o ? Ue(o) : null;
1283
+ return o ? qe(o) : null;
1284
1284
  }
1285
1285
  /**
1286
1286
  * Try to create a cart with a batch, isolating failures if needed.
@@ -1326,8 +1326,8 @@ class Qn {
1326
1326
  async addCartLineItems(e, r) {
1327
1327
  let n = null;
1328
1328
  const o = [];
1329
- for (let s = 0; s < r.length; s += be) {
1330
- const i = r.slice(s, s + be);
1329
+ for (let s = 0; s < r.length; s += ve) {
1330
+ const i = r.slice(s, s + ve);
1331
1331
  try {
1332
1332
  const c = await this.addBatchToCart(e, i);
1333
1333
  c && (n = c);
@@ -1368,7 +1368,7 @@ class Qn {
1368
1368
  }
1369
1369
  }
1370
1370
  })).cart.updateCartLineItem?.cart;
1371
- return c ? Ue(c) : null;
1371
+ return c ? qe(c) : null;
1372
1372
  }
1373
1373
  /**
1374
1374
  * Remove a line item from the cart
@@ -1383,7 +1383,7 @@ class Qn {
1383
1383
  }
1384
1384
  }
1385
1385
  })).cart.deleteCartLineItem?.cart;
1386
- return o ? Ue(o) : null;
1386
+ return o ? qe(o) : null;
1387
1387
  }
1388
1388
  /**
1389
1389
  * Delete an entire cart
@@ -1448,7 +1448,7 @@ class Qn {
1448
1448
  checkoutEntityId: e
1449
1449
  }
1450
1450
  })).site.checkout;
1451
- return n ? Ge(n) : null;
1451
+ return n ? Qe(n) : null;
1452
1452
  }
1453
1453
  /**
1454
1454
  * Add shipping consignments (addresses) to a checkout
@@ -1456,7 +1456,7 @@ class Qn {
1456
1456
  */
1457
1457
  async setCheckoutShippingAddress(e, r, n) {
1458
1458
  const s = (await this.request({
1459
- document: Fn,
1459
+ document: Rn,
1460
1460
  variables: {
1461
1461
  input: {
1462
1462
  checkoutEntityId: e,
@@ -1471,7 +1471,7 @@ class Qn {
1471
1471
  }
1472
1472
  }
1473
1473
  })).checkout.addCheckoutShippingConsignments?.checkout;
1474
- return s ? Ge(s) : null;
1474
+ return s ? Qe(s) : null;
1475
1475
  }
1476
1476
  /**
1477
1477
  * Add shipping consignments (addresses) to a checkout
@@ -1479,7 +1479,7 @@ class Qn {
1479
1479
  */
1480
1480
  async setCheckoutBillingAddress(e, r) {
1481
1481
  const o = (await this.request({
1482
- document: On,
1482
+ document: Fn,
1483
1483
  variables: {
1484
1484
  input: {
1485
1485
  checkoutEntityId: e,
@@ -1489,7 +1489,7 @@ class Qn {
1489
1489
  }
1490
1490
  }
1491
1491
  })).checkout.addCheckoutBillingAddress?.checkout;
1492
- return o ? Ge(o) : null;
1492
+ return o ? Qe(o) : null;
1493
1493
  }
1494
1494
  /**
1495
1495
  * Lightweight check: returns the logged-in customer's entityId, or null if anonymous.
@@ -1521,7 +1521,7 @@ class Qn {
1521
1521
  email: e.customer.email
1522
1522
  }, n = [...e.customer.addresses.edges ?? []];
1523
1523
  if (e.customer.addresses.pageInfo.hasNextPage) {
1524
- const s = await Qe(
1524
+ const s = await Ge(
1525
1525
  this,
1526
1526
  Dt,
1527
1527
  { after: e.customer.addresses.pageInfo.endCursor },
@@ -1546,7 +1546,7 @@ class Qn {
1546
1546
  r.purchaseOrderNumber && (n += `PO Number: ${r.purchaseOrderNumber}, `), r.threadId && (n && (n += `
1547
1547
  `), n += `Thread ID: ${r.threadId}`);
1548
1548
  const s = (await this.request({
1549
- document: Rn,
1549
+ document: On,
1550
1550
  variables: {
1551
1551
  input: {
1552
1552
  checkoutEntityId: e,
@@ -1556,7 +1556,7 @@ class Qn {
1556
1556
  }
1557
1557
  }
1558
1558
  })).checkout.updateCheckoutCustomerMessage?.checkout;
1559
- return s ? Ge(s) : null;
1559
+ return s ? Qe(s) : null;
1560
1560
  }
1561
1561
  /**
1562
1562
  * Get product variant details for multiple products
@@ -1573,7 +1573,7 @@ class Qn {
1573
1573
  for (const o of r.site.products.edges ?? []) {
1574
1574
  const s = o.node, i = [...s.variants.edges ?? []];
1575
1575
  if (s.variants.pageInfo.hasNextPage) {
1576
- const d = await Qe(
1576
+ const d = await Ge(
1577
1577
  this,
1578
1578
  Un,
1579
1579
  {
@@ -1586,7 +1586,7 @@ class Qn {
1586
1586
  }
1587
1587
  const c = [...s.productOptions.edges ?? []];
1588
1588
  if (s.productOptions.pageInfo.hasNextPage) {
1589
- const d = await Qe(
1589
+ const d = await Ge(
1590
1590
  this,
1591
1591
  qn,
1592
1592
  {
@@ -1601,7 +1601,7 @@ class Qn {
1601
1601
  for (const d of c) {
1602
1602
  const h = d.node;
1603
1603
  if (h.values?.pageInfo.hasNextPage && h.values.pageInfo.endCursor) {
1604
- const u = await Qe(
1604
+ const p = await Ge(
1605
1605
  this,
1606
1606
  jn,
1607
1607
  {
@@ -1609,32 +1609,32 @@ class Qn {
1609
1609
  optionEntityId: h.entityId,
1610
1610
  after: h.values.pageInfo.endCursor
1611
1611
  },
1612
- (p) => {
1613
- const x = p.site.product?.productOptions.edges?.[0];
1612
+ (u) => {
1613
+ const x = u.site.product?.productOptions.edges?.[0];
1614
1614
  return x ? x.node.values ?? null : null;
1615
1615
  }
1616
1616
  );
1617
1617
  l.set(h.entityId, {
1618
1618
  ...h.values,
1619
- edges: [...h.values.edges ?? [], ...u]
1619
+ edges: [...h.values.edges ?? [], ...p]
1620
1620
  });
1621
1621
  }
1622
1622
  }
1623
1623
  n.push({
1624
1624
  entityId: s.entityId,
1625
1625
  productOptions: c.filter((d) => d.node.isVariantOption).map((d) => {
1626
- const h = d.node, u = l.get(h.entityId) ?? h.values;
1626
+ const h = d.node, p = l.get(h.entityId) ?? h.values;
1627
1627
  return {
1628
1628
  entityId: h.entityId,
1629
1629
  displayName: h.displayName,
1630
1630
  isRequired: h.isRequired,
1631
1631
  isVariantOption: h.isVariantOption,
1632
1632
  displayStyle: h.displayStyle,
1633
- values: u?.edges?.map(
1634
- (p) => ({
1635
- entityId: p.node.entityId,
1636
- label: p.node.label,
1637
- isDefault: p.node.isDefault
1633
+ values: p?.edges?.map(
1634
+ (u) => ({
1635
+ entityId: u.node.entityId,
1636
+ label: u.node.label,
1637
+ isDefault: u.node.isDefault
1638
1638
  })
1639
1639
  ) ?? []
1640
1640
  };
@@ -1649,9 +1649,9 @@ class Qn {
1649
1649
  options: (d.node.options.edges ?? []).map((h) => ({
1650
1650
  entityId: h.node.entityId,
1651
1651
  displayName: h.node.displayName,
1652
- values: (h.node.values.edges ?? []).map((u) => ({
1653
- entityId: u.node.entityId,
1654
- label: u.node.label
1652
+ values: (h.node.values.edges ?? []).map((p) => ({
1653
+ entityId: p.node.entityId,
1654
+ label: p.node.label
1655
1655
  }))
1656
1656
  }))
1657
1657
  }))
@@ -1721,8 +1721,8 @@ class Qn {
1721
1721
  if (c) {
1722
1722
  const l = c.node, d = {};
1723
1723
  for (const h of l.options.edges ?? []) {
1724
- const u = h.node.values.edges?.[0];
1725
- u && (d[h.node.entityId] = u.node.entityId);
1724
+ const p = h.node.values.edges?.[0];
1725
+ p && (d[h.node.entityId] = p.node.entityId);
1726
1726
  }
1727
1727
  i = {
1728
1728
  entityId: l.entityId,
@@ -1784,18 +1784,18 @@ class Qn {
1784
1784
  function Ii(t) {
1785
1785
  return `https://store-${t}.mybigcommerce.com/graphql`;
1786
1786
  }
1787
- function Gn(t) {
1788
- return new Qn(t);
1787
+ function Qn(t) {
1788
+ return new Gn(t);
1789
1789
  }
1790
- const qe = Ct((t) => ({
1790
+ const je = Ct((t) => ({
1791
1791
  isExpanded: !1,
1792
1792
  setExpanded: (e) => t({ isExpanded: e }),
1793
1793
  toggleExpanded: () => t((e) => ({ isExpanded: !e.isExpanded })),
1794
1794
  reset: () => t({ isExpanded: !1 })
1795
1795
  }));
1796
1796
  function Kn({ children: t }) {
1797
- const e = qe((o) => o.isExpanded), r = qe((o) => o.setExpanded), n = R(null);
1798
- return O(() => {
1797
+ const e = je((o) => o.isExpanded), r = je((o) => o.setExpanded), n = O(null);
1798
+ return F(() => {
1799
1799
  if (!e) return;
1800
1800
  const o = (s) => {
1801
1801
  s.key === "Escape" && r(!1);
@@ -1874,15 +1874,15 @@ async function es(t, e) {
1874
1874
  const c = i.get_width(), l = i.get_height(), d = new OffscreenCanvas(c, l), h = d.getContext("2d");
1875
1875
  if (!h)
1876
1876
  throw new Error("Failed to get canvas context");
1877
- const u = h.createImageData(c, l);
1877
+ const p = h.createImageData(c, l);
1878
1878
  await new Promise((g, x) => {
1879
- i.display(u, (m) => {
1879
+ i.display(p, (m) => {
1880
1880
  if (!m) return x(new Error("HEIF processing error"));
1881
1881
  g();
1882
1882
  });
1883
- }), h.putImageData(u, 0, 0);
1884
- const p = await d.convertToBlob({ type: "image/jpeg", quality: e });
1885
- return new File([p], Cr(t.name), { type: "image/jpeg" });
1883
+ }), h.putImageData(p, 0, 0);
1884
+ const u = await d.convertToBlob({ type: "image/jpeg", quality: e });
1885
+ return new File([u], Cr(t.name), { type: "image/jpeg" });
1886
1886
  }
1887
1887
  async function ts(t) {
1888
1888
  if (!yr(t)) return t;
@@ -1938,7 +1938,7 @@ function cs(t) {
1938
1938
  return { valid: !0 };
1939
1939
  }
1940
1940
  function wr({ onFile: t, onBeforeValidate: e }) {
1941
- const [r, n] = _(!1), [o, s] = _(null), i = R(null), c = R(null), l = M(
1941
+ const [r, n] = _(!1), [o, s] = _(null), i = O(null), c = O(null), l = M(
1942
1942
  async (m) => {
1943
1943
  e?.(), s(null);
1944
1944
  let b = m;
@@ -1963,14 +1963,14 @@ function wr({ onFile: t, onBeforeValidate: e }) {
1963
1963
  m.preventDefault(), m.stopPropagation(), n(!0);
1964
1964
  }, []), h = M((m) => {
1965
1965
  m.preventDefault(), m.stopPropagation(), n(!1);
1966
- }, []), u = M(
1966
+ }, []), p = M(
1967
1967
  (m) => {
1968
1968
  m.preventDefault(), m.stopPropagation(), n(!1);
1969
1969
  const b = m.dataTransfer.files[0];
1970
1970
  b && l(b);
1971
1971
  },
1972
1972
  [l]
1973
- ), p = M(
1973
+ ), u = M(
1974
1974
  (m) => {
1975
1975
  const b = m.target.files?.[0];
1976
1976
  b && l(b), m.target && (m.target.value = "");
@@ -1989,9 +1989,9 @@ function wr({ onFile: t, onBeforeValidate: e }) {
1989
1989
  dragProps: {
1990
1990
  onDragOver: d,
1991
1991
  onDragLeave: h,
1992
- onDrop: u
1992
+ onDrop: p
1993
1993
  },
1994
- handleFileChange: p,
1994
+ handleFileChange: u,
1995
1995
  openFilePicker: g,
1996
1996
  openCamera: x
1997
1997
  };
@@ -2012,7 +2012,7 @@ const ls = () => /* @__PURE__ */ f(
2012
2012
  /* @__PURE__ */ a("path", { d: "M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6" })
2013
2013
  ]
2014
2014
  }
2015
- ), We = ({ size: t = 12, title: e = "Saved" }) => /* @__PURE__ */ f(
2015
+ ), ze = ({ size: t = 12, title: e = "Saved" }) => /* @__PURE__ */ f(
2016
2016
  "svg",
2017
2017
  {
2018
2018
  width: t,
@@ -2100,7 +2100,7 @@ const ls = () => /* @__PURE__ */ f(
2100
2100
  /* @__PURE__ */ a("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
2101
2101
  ]
2102
2102
  }
2103
- ), De = ({ size: t = 12 }) => /* @__PURE__ */ f(
2103
+ ), Le = ({ size: t = 12 }) => /* @__PURE__ */ f(
2104
2104
  "svg",
2105
2105
  {
2106
2106
  width: t,
@@ -2131,7 +2131,7 @@ function us({
2131
2131
  return /* @__PURE__ */ f(
2132
2132
  "div",
2133
2133
  {
2134
- className: Ae(
2134
+ className: $e(
2135
2135
  "grid gap-2",
2136
2136
  s ? "grid-cols-2" : "grid-cols-1"
2137
2137
  ),
@@ -2179,23 +2179,23 @@ function Lt(t) {
2179
2179
  defaultAddressFilter: c = (x) => x.isDefaultShipping,
2180
2180
  addressFilter: l = (x) => x.isShipping,
2181
2181
  canShowDefaultAddressWarning: d
2182
- } = t, h = n === ue, u = r.find(c);
2183
- let p = d && !!n && !h;
2184
- p && u && (p = u.id !== n);
2182
+ } = t, h = n === pe, p = r.find(c);
2183
+ let u = d && !!n && !h;
2184
+ u && p && (u = p.id !== n);
2185
2185
  const g = r.filter(l);
2186
2186
  return /* @__PURE__ */ f(
2187
2187
  "div",
2188
2188
  {
2189
- className: `p-2 px-2.5 rounded border border-solid ${p ? "bg-warning-bg border-warning" : "bg-surface-secondary border-border"}`,
2189
+ className: `p-2 px-2.5 rounded border border-solid ${u ? "bg-warning-bg border-warning" : "bg-surface-secondary border-border"}`,
2190
2190
  children: [
2191
2191
  /* @__PURE__ */ f("div", { className: "flex justify-between items-center mb-0.5", children: [
2192
2192
  /* @__PURE__ */ a("span", { className: "text-2xs text-text-tertiary uppercase tracking-[0.05em]", children: e }),
2193
2193
  o === "updating" && /* @__PURE__ */ f("span", { className: "flex items-center gap-1 text-2xs font-medium text-text-tertiary uppercase tracking-[0.025em]", children: [
2194
- /* @__PURE__ */ a(De, { size: 10 }),
2194
+ /* @__PURE__ */ a(Le, { size: 10 }),
2195
2195
  "Updating..."
2196
2196
  ] }),
2197
2197
  o === "success" && /* @__PURE__ */ f("span", { className: "flex items-center gap-0.5 text-2xs font-semibold text-success-text uppercase tracking-[0.025em]", children: [
2198
- /* @__PURE__ */ a(We, { size: 10, title: "Updated" }),
2198
+ /* @__PURE__ */ a(ze, { size: 10, title: "Updated" }),
2199
2199
  "Updated"
2200
2200
  ] }),
2201
2201
  o === "error" && /* @__PURE__ */ f("span", { className: "flex items-center gap-0.5 text-2xs font-semibold text-error-text uppercase tracking-[0.025em]", children: [
@@ -2211,7 +2211,7 @@ function Lt(t) {
2211
2211
  disabled: o === "updating",
2212
2212
  className: "w-full px-2 py-1.5 text-sm font-medium rounded cursor-pointer transition-colors focus:outline-none focus:border-border-focus disabled:opacity-50 disabled:cursor-not-allowed border border-solid font-[inherit] appearance-auto text-text bg-transparent border-border-strong",
2213
2213
  children: [
2214
- i && /* @__PURE__ */ f(we, { children: [
2214
+ i && /* @__PURE__ */ f(Pe, { children: [
2215
2215
  /* @__PURE__ */ a("option", { value: i.id, children: /* @__PURE__ */ a(Ut, { address: i }) }, i.id),
2216
2216
  /* @__PURE__ */ a("option", { disabled: !0, children: "---" })
2217
2217
  ] }),
@@ -2223,19 +2223,19 @@ function Lt(t) {
2223
2223
  }
2224
2224
  ) }, x.id)),
2225
2225
  g.length > 0 && /* @__PURE__ */ a("option", { disabled: !0, children: "---" }),
2226
- /* @__PURE__ */ a("option", { value: ue, children: "Enter an address at checkout" }, ue)
2226
+ /* @__PURE__ */ a("option", { value: pe, children: "Enter an address at checkout" }, pe)
2227
2227
  ]
2228
2228
  }
2229
2229
  ),
2230
2230
  i && /* @__PURE__ */ a(ps, { address: i }),
2231
- p && /* @__PURE__ */ a("p", { className: "mt-1.5 pt-1.5 m-0 text-xs leading-[1.4]", children: "Your company has a default address set. Verify your address on the checkout page as it may not populate automatically." })
2231
+ u && /* @__PURE__ */ a("p", { className: "mt-1.5 pt-1.5 m-0 text-xs leading-[1.4]", children: "Your company has a default address set. Verify your address on the checkout page as it may not populate automatically." })
2232
2232
  ]
2233
2233
  }
2234
2234
  );
2235
2235
  }
2236
2236
  function Ut(t) {
2237
2237
  const { address: e, isDefault: r } = t;
2238
- return /* @__PURE__ */ f(we, { children: [
2238
+ return /* @__PURE__ */ f(Pe, { children: [
2239
2239
  r?.(e) ? "[DEFAULT] " : "",
2240
2240
  e.label ? `[${e.label.toUpperCase()}] ` : "",
2241
2241
  e.firstName,
@@ -2259,8 +2259,8 @@ function hs(t) {
2259
2259
  return t.postalCode ? e.push(`${r} ${t.postalCode}`) : r && e.push(r), e.join(", ");
2260
2260
  }
2261
2261
  function ps({ address: t }) {
2262
- const [e, r] = _(!1), n = R(void 0);
2263
- O(() => () => {
2262
+ const [e, r] = _(!1), n = O(void 0);
2263
+ F(() => () => {
2264
2264
  n.current && clearTimeout(n.current);
2265
2265
  }, []);
2266
2266
  const o = hs(t), s = M(async () => {
@@ -2282,7 +2282,7 @@ function ps({ address: t }) {
2282
2282
  " ",
2283
2283
  o
2284
2284
  ] }),
2285
- /* @__PURE__ */ a("span", { className: "shrink-0 mt-0.5", children: e ? /* @__PURE__ */ a(We, { size: 12, title: "Copied" }) : /* @__PURE__ */ a(Sr, { size: 12 }) })
2285
+ /* @__PURE__ */ a("span", { className: "shrink-0 mt-0.5", children: e ? /* @__PURE__ */ a(ze, { size: 12, title: "Copied" }) : /* @__PURE__ */ a(Sr, { size: 12 }) })
2286
2286
  ]
2287
2287
  }
2288
2288
  );
@@ -2309,33 +2309,38 @@ function fs({
2309
2309
  totalQuantity: s,
2310
2310
  availableItemCount: i,
2311
2311
  onCheckout: c,
2312
- isLoading: l,
2313
- allowCheckout: d = !0
2312
+ onReviewCart: l,
2313
+ isLoading: d,
2314
+ allowCheckout: h = !0
2314
2315
  }) {
2315
- const [h, u] = _(!1), p = R(!0), g = R(
2316
+ const [p, u] = _(null), g = O(!0), x = O(
2316
2317
  void 0
2317
- ), x = () => {
2318
- g.current = setTimeout(
2319
- () => u(!1),
2318
+ ), m = () => {
2319
+ x.current = setTimeout(
2320
+ () => u(null),
2320
2321
  3e3
2321
2322
  );
2322
- }, m = () => {
2323
- g.current && (clearTimeout(g.current), g.current = void 0);
2324
2323
  }, b = () => {
2325
- h || (u(!0), x());
2324
+ x.current && (clearTimeout(x.current), x.current = void 0);
2326
2325
  }, v = () => {
2327
- m(), u(!1), c();
2326
+ p === null && (u("checkout"), m());
2328
2327
  }, k = () => {
2329
- m(), u(!1);
2328
+ p === null && (u("review"), m());
2330
2329
  }, T = () => {
2331
- m();
2330
+ b();
2331
+ const $ = p;
2332
+ u(null), $ === "checkout" ? c() : $ === "review" && l();
2332
2333
  }, E = () => {
2333
- h && x();
2334
+ b(), u(null);
2335
+ }, I = () => {
2336
+ b();
2337
+ }, S = () => {
2338
+ p !== null && m();
2334
2339
  };
2335
- O(() => () => {
2336
- p.current = !1, g.current && clearTimeout(g.current);
2340
+ F(() => () => {
2341
+ g.current = !1, x.current && clearTimeout(x.current);
2337
2342
  }, []);
2338
- const I = i === 0 || l || !d;
2343
+ const B = i === 0 || d || !h;
2339
2344
  return /* @__PURE__ */ f("div", { className: "px-4 py-2.5 shrink-0 bg-surface-secondary", children: [
2340
2345
  /* @__PURE__ */ a(
2341
2346
  dt,
@@ -2356,29 +2361,33 @@ function fs({
2356
2361
  /* @__PURE__ */ a("span", { className: "text-sm font-semibold text-text", children: "Total" }),
2357
2362
  /* @__PURE__ */ a("span", { className: "text-sm font-semibold text-text", children: ut(n, o) })
2358
2363
  ] }),
2359
- h ? /* @__PURE__ */ f(
2364
+ p !== null ? /* @__PURE__ */ f(
2360
2365
  "fieldset",
2361
2366
  {
2362
2367
  className: "mt-2.5 animate-[fadeIn_0.15s_ease] border-none m-0 p-0",
2363
- onMouseEnter: T,
2364
- onMouseLeave: E,
2368
+ onMouseEnter: I,
2369
+ onMouseLeave: S,
2365
2370
  children: [
2366
2371
  /* @__PURE__ */ a("p", { className: "text-xs text-text-tertiary m-0 mb-2", children: "This cart was generated with AI. I have reviewed the contents and take responsibility for this order." }),
2372
+ p === "review" && /* @__PURE__ */ f("p", { className: "text-xs text-text-tertiary m-0 mb-2", children: [
2373
+ /* @__PURE__ */ a("strong", { children: "Note:" }),
2374
+ " Shipping and billing addresses from your purchase order won't be prefilled if you check out from the cart page."
2375
+ ] }),
2367
2376
  /* @__PURE__ */ f("div", { className: "flex gap-2", children: [
2368
2377
  /* @__PURE__ */ a(
2369
2378
  "button",
2370
2379
  {
2371
2380
  type: "button",
2372
- onClick: v,
2381
+ onClick: T,
2373
2382
  className: "flex-1 min-h-11 px-4 py-2.5 text-sm font-semibold text-text-invert bg-surface-invert rounded-full hover:bg-surface-invert-hover transition-all cursor-pointer",
2374
- children: "Yes, checkout"
2383
+ children: p === "review" ? "Go to cart" : "Yes, checkout"
2375
2384
  }
2376
2385
  ),
2377
2386
  /* @__PURE__ */ a(
2378
2387
  "button",
2379
2388
  {
2380
2389
  type: "button",
2381
- onClick: k,
2390
+ onClick: E,
2382
2391
  className: "flex-1 min-h-11 px-4 py-2.5 text-sm font-semibold text-text-tertiary bg-surface-secondary border border-border rounded-full hover:bg-surface-tertiary transition-all cursor-pointer",
2383
2392
  children: "Cancel"
2384
2393
  }
@@ -2386,38 +2395,47 @@ function fs({
2386
2395
  ] })
2387
2396
  ]
2388
2397
  }
2389
- ) : /* @__PURE__ */ a(
2390
- "button",
2391
- {
2392
- type: "button",
2393
- onClick: b,
2394
- disabled: I,
2395
- className: "bg-surface-invert shadow-button transition-all duration-200 ease-in-out enabled:hover:bg-surface-invert-hover enabled:hover:shadow-button-hover enabled:hover:-translate-y-px relative w-full mt-2.5 px-4 py-2.5 min-h-11 text-text-invert rounded-full text-sm font-semibold flex items-center justify-center gap-1.5 cursor-pointer overflow-hidden disabled:opacity-50 disabled:cursor-not-allowed",
2396
- "aria-label": `Checkout with ${s} items`,
2397
- children: l ? "Loading..." : /* @__PURE__ */ f(we, { children: [
2398
- "Checkout with ",
2399
- s,
2400
- " ",
2401
- s === 1 ? "product" : "products",
2402
- /* @__PURE__ */ f(
2403
- "svg",
2404
- {
2405
- width: "16",
2406
- height: "16",
2407
- viewBox: "0 0 24 24",
2408
- fill: "none",
2409
- stroke: "currentColor",
2410
- strokeWidth: "2.5",
2411
- "aria-hidden": "true",
2412
- children: [
2413
- /* @__PURE__ */ a("title", { children: "Checkout" }),
2414
- /* @__PURE__ */ a("path", { d: "M5 12h14M12 5l7 7-7 7" })
2415
- ]
2416
- }
2417
- )
2418
- ] })
2419
- }
2420
- )
2398
+ ) : /* @__PURE__ */ f("div", { className: "flex flex-col gap-2 mt-2.5", children: [
2399
+ /* @__PURE__ */ f(
2400
+ "button",
2401
+ {
2402
+ type: "button",
2403
+ onClick: k,
2404
+ disabled: B,
2405
+ className: "bg-surface-invert shadow-button transition-all duration-200 ease-in-out enabled:hover:bg-surface-invert-hover enabled:hover:shadow-button-hover enabled:hover:-translate-y-px relative w-full px-4 py-2.5 min-h-11 text-text-invert rounded-full text-sm font-semibold flex items-center justify-center gap-1.5 cursor-pointer overflow-hidden disabled:opacity-50 disabled:cursor-not-allowed",
2406
+ children: [
2407
+ "Review in your cart",
2408
+ /* @__PURE__ */ f(
2409
+ "svg",
2410
+ {
2411
+ width: "16",
2412
+ height: "16",
2413
+ viewBox: "0 0 24 24",
2414
+ fill: "none",
2415
+ stroke: "currentColor",
2416
+ strokeWidth: "2.5",
2417
+ "aria-hidden": "true",
2418
+ children: [
2419
+ /* @__PURE__ */ a("title", { children: "Review in your cart" }),
2420
+ /* @__PURE__ */ a("path", { d: "M5 12h14M12 5l7 7-7 7" })
2421
+ ]
2422
+ }
2423
+ )
2424
+ ]
2425
+ }
2426
+ ),
2427
+ /* @__PURE__ */ a(
2428
+ "button",
2429
+ {
2430
+ type: "button",
2431
+ onClick: v,
2432
+ disabled: B,
2433
+ className: "w-full px-4 py-2.5 min-h-11 text-sm font-semibold text-text bg-surface border border-border-strong rounded-full hover:bg-surface-tertiary transition-all cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",
2434
+ "aria-label": `Checkout with ${s} items`,
2435
+ children: d ? "Loading..." : `Checkout with ${s} ${s === 1 ? "product" : "products"}`
2436
+ }
2437
+ )
2438
+ ] })
2421
2439
  ] });
2422
2440
  }
2423
2441
  const It = () => /* @__PURE__ */ f(
@@ -2445,7 +2463,7 @@ function jt({
2445
2463
  "button",
2446
2464
  {
2447
2465
  type: "button",
2448
- className: e ? Ae(qt, e) : qt,
2466
+ className: e ? $e(qt, e) : qt,
2449
2467
  ...r,
2450
2468
  children: t
2451
2469
  }
@@ -2462,13 +2480,13 @@ function Nr({
2462
2480
  }) {
2463
2481
  const [c, l] = _(String(t)), [d, h] = _(
2464
2482
  "idle"
2465
- ), u = R(null);
2466
- O(() => () => {
2467
- u.current && clearTimeout(u.current);
2468
- }, []), O(() => {
2483
+ ), p = O(null);
2484
+ F(() => () => {
2485
+ p.current && clearTimeout(p.current);
2486
+ }, []), F(() => {
2469
2487
  l(String(t));
2470
2488
  }, [t]);
2471
- const p = (T) => {
2489
+ const u = (T) => {
2472
2490
  const E = T.target.value;
2473
2491
  if (E === "") {
2474
2492
  l("");
@@ -2491,11 +2509,11 @@ function Nr({
2491
2509
  const E = n !== void 0 ? Math.min(T, n) : T;
2492
2510
  h("saving");
2493
2511
  try {
2494
- await e(E), h("success"), u.current = setTimeout(() => {
2512
+ await e(E), h("success"), p.current = setTimeout(() => {
2495
2513
  h((I) => I === "success" ? "idle" : I);
2496
2514
  }, 1500);
2497
2515
  } catch {
2498
- l(String(t)), h("error"), u.current = setTimeout(() => {
2516
+ l(String(t)), h("error"), p.current = setTimeout(() => {
2499
2517
  h((I) => I === "error" ? "idle" : I);
2500
2518
  }, 3e3);
2501
2519
  }
@@ -2511,13 +2529,13 @@ function Nr({
2511
2529
  );
2512
2530
  if (S !== I)
2513
2531
  if (l(String(S)), s) {
2514
- u.current && clearTimeout(u.current), h("saving");
2532
+ p.current && clearTimeout(p.current), h("saving");
2515
2533
  try {
2516
- await e(S), h("success"), u.current = setTimeout(() => {
2534
+ await e(S), h("success"), p.current = setTimeout(() => {
2517
2535
  h((B) => B === "success" ? "idle" : B);
2518
2536
  }, 1500);
2519
2537
  } catch {
2520
- l(String(t)), h("error"), u.current = setTimeout(() => {
2538
+ l(String(t)), h("error"), p.current = setTimeout(() => {
2521
2539
  h((B) => B === "error" ? "idle" : B);
2522
2540
  }, 3e3);
2523
2541
  }
@@ -2554,7 +2572,7 @@ function Nr({
2554
2572
  pattern: "[0-9]*",
2555
2573
  value: c,
2556
2574
  disabled: k,
2557
- onChange: p,
2575
+ onChange: u,
2558
2576
  onBlur: g,
2559
2577
  onKeyDown: x,
2560
2578
  "data-testid": i,
@@ -2585,8 +2603,8 @@ function Nr({
2585
2603
  )
2586
2604
  }
2587
2605
  ),
2588
- k && /* @__PURE__ */ a("span", { className: "text-text-tertiary ml-0.5", children: /* @__PURE__ */ a(De, {}) }),
2589
- d === "success" && /* @__PURE__ */ a("span", { className: "text-success ml-0.5", children: /* @__PURE__ */ a(We, {}) }),
2606
+ k && /* @__PURE__ */ a("span", { className: "text-text-tertiary ml-0.5", children: /* @__PURE__ */ a(Le, {}) }),
2607
+ d === "success" && /* @__PURE__ */ a("span", { className: "text-success ml-0.5", children: /* @__PURE__ */ a(ze, {}) }),
2590
2608
  d === "error" && /* @__PURE__ */ a("span", { className: "text-error text-xs ml-0.5", children: "Failed" })
2591
2609
  ] });
2592
2610
  }
@@ -2691,7 +2709,7 @@ function gs(t) {
2691
2709
  );
2692
2710
  }
2693
2711
  const Vt = "flex items-center gap-1 min-h-11 px-3 py-1 text-xs font-medium text-text bg-surface-secondary border border-border-focus/20 rounded-md hover:bg-surface-tertiary hover:border-border-focus/35 transition-all whitespace-nowrap";
2694
- function Ve({
2712
+ function We({
2695
2713
  children: t,
2696
2714
  className: e,
2697
2715
  ...r
@@ -2700,14 +2718,14 @@ function Ve({
2700
2718
  "button",
2701
2719
  {
2702
2720
  type: "button",
2703
- className: e ? Ae(Vt, e) : Vt,
2721
+ className: e ? $e(Vt, e) : Vt,
2704
2722
  ...r,
2705
2723
  children: t
2706
2724
  }
2707
2725
  );
2708
2726
  }
2709
2727
  function Pr({ onNewOrder: t }) {
2710
- const [e, r] = _(!1), [n, o] = _(!1), s = R(!0), i = R(
2728
+ const [e, r] = _(!1), [n, o] = _(!1), s = O(!0), i = O(
2711
2729
  void 0
2712
2730
  ), c = () => {
2713
2731
  i.current = setTimeout(() => r(!1), 3e3);
@@ -2722,14 +2740,14 @@ function Pr({ onNewOrder: t }) {
2722
2740
  } finally {
2723
2741
  s.current && o(!1);
2724
2742
  }
2725
- }, u = () => {
2726
- l(), r(!1);
2727
2743
  }, p = () => {
2744
+ l(), r(!1);
2745
+ }, u = () => {
2728
2746
  l();
2729
2747
  }, g = () => {
2730
2748
  e && c();
2731
2749
  };
2732
- return O(() => () => {
2750
+ return F(() => () => {
2733
2751
  s.current = !1, i.current && clearTimeout(i.current);
2734
2752
  }, []), n ? /* @__PURE__ */ f("span", { className: "flex items-center gap-1.5 text-xs animate-[fadeIn_0.15s_ease]", children: [
2735
2753
  /* @__PURE__ */ a(
@@ -2751,7 +2769,7 @@ function Pr({ onNewOrder: t }) {
2751
2769
  "fieldset",
2752
2770
  {
2753
2771
  className: "flex items-center gap-1.5 text-xs animate-[fadeIn_0.15s_ease] border-none m-0 p-0",
2754
- onMouseEnter: p,
2772
+ onMouseEnter: u,
2755
2773
  onMouseLeave: g,
2756
2774
  children: [
2757
2775
  /* @__PURE__ */ a("span", { className: "text-text-tertiary font-medium", children: "Reset?" }),
@@ -2768,14 +2786,14 @@ function Pr({ onNewOrder: t }) {
2768
2786
  "button",
2769
2787
  {
2770
2788
  type: "button",
2771
- onClick: u,
2789
+ onClick: p,
2772
2790
  className: "min-h-11 min-w-11 px-3 py-1 text-xs font-semibold text-text-tertiary bg-surface-secondary border border-border rounded hover:bg-surface-tertiary transition-all",
2773
2791
  children: "No"
2774
2792
  }
2775
2793
  )
2776
2794
  ]
2777
2795
  }
2778
- ) : /* @__PURE__ */ f(Ve, { onClick: d, title: "Start a new order", children: [
2796
+ ) : /* @__PURE__ */ f(We, { onClick: d, title: "Start a new order", children: [
2779
2797
  /* @__PURE__ */ a(
2780
2798
  "svg",
2781
2799
  {
@@ -2823,7 +2841,7 @@ function Cs({
2823
2841
  return /* @__PURE__ */ f(
2824
2842
  "div",
2825
2843
  {
2826
- className: Ae(
2844
+ className: $e(
2827
2845
  "rounded-lg flex flex-col h-full bg-surface-secondary relative transition-colors duration-200",
2828
2846
  e && "bg-surface-tertiary",
2829
2847
  t
@@ -2831,11 +2849,11 @@ function Cs({
2831
2849
  children: [
2832
2850
  s && /* @__PURE__ */ f("div", { className: "absolute top-0 right-0 px-4 py-3 z-10 flex items-center gap-2", children: [
2833
2851
  r && /* @__PURE__ */ a(Pr, { onNewOrder: r }),
2834
- n && /* @__PURE__ */ f(Ve, { onClick: n, "aria-label": "Expand", children: [
2852
+ n && /* @__PURE__ */ f(We, { onClick: n, "aria-label": "Expand", children: [
2835
2853
  /* @__PURE__ */ a(kr, { size: 14 }),
2836
2854
  "Expand"
2837
2855
  ] }),
2838
- o && /* @__PURE__ */ f(Ve, { onClick: o, "aria-label": "Minimize", children: [
2856
+ o && /* @__PURE__ */ f(We, { onClick: o, "aria-label": "Minimize", children: [
2839
2857
  /* @__PURE__ */ a(Er, { size: 14 }),
2840
2858
  "Minimize"
2841
2859
  ] })
@@ -3121,7 +3139,7 @@ const Ar = {
3121
3139
  cartifact: {
3122
3140
  ...r.cartifact,
3123
3141
  shipToAddress: e ? He(e, {
3124
- id: ve
3142
+ id: Ie
3125
3143
  }) : null
3126
3144
  }
3127
3145
  }),
@@ -3190,7 +3208,7 @@ const Ar = {
3190
3208
  lastName: e.buyerLastName
3191
3209
  }), e.shipToAddress && (n.shipToAddress = He(
3192
3210
  e.shipToAddress,
3193
- { id: ve }
3211
+ { id: Ie }
3194
3212
  )), e.billingAddress && (n.billingAddress = He(
3195
3213
  e.billingAddress,
3196
3214
  { id: Ne }
@@ -3643,7 +3661,7 @@ const y = Ct()(
3643
3661
  function mt({ productName: t, productSku: e }) {
3644
3662
  return t && e ? `${t} (${e})` : t || e || "Unknown Product";
3645
3663
  }
3646
- function Fs({
3664
+ function Rs({
3647
3665
  item: t,
3648
3666
  onSuggestAlternatives: e
3649
3667
  }) {
@@ -3684,57 +3702,58 @@ function Fs({
3684
3702
  ] })
3685
3703
  ] });
3686
3704
  }
3687
- function Os({
3705
+ function Fs({
3688
3706
  items: t,
3689
3707
  itemWarnings: e = [],
3690
3708
  onUpdateQuantity: r,
3691
3709
  onRemove: n,
3692
3710
  onCheckout: o,
3693
- onSuggestAlternatives: s,
3694
- onShowMoreLikeThis: i,
3695
- onViewProduct: c,
3696
- className: l = "",
3697
- orderId: d,
3698
- addresses: h = [],
3711
+ onReviewCart: s,
3712
+ onSuggestAlternatives: i,
3713
+ onShowMoreLikeThis: c,
3714
+ onViewProduct: l,
3715
+ className: d = "",
3716
+ orderId: h,
3717
+ addresses: p = [],
3699
3718
  selectedAddressId: u,
3700
- addressUpdateStatus: p,
3701
- onAddressChange: g,
3702
- selectedBillingAddressId: x,
3703
- billingAddressUpdateStatus: m,
3704
- onBillingAddressChange: b,
3705
- shipToAddress: v,
3706
- billingAddress: k,
3707
- checkoutTotals: T,
3708
- isLoading: E,
3709
- poMetadataSet: I = !1,
3710
- isDragging: S,
3711
- onNewOrder: B,
3712
- onExpand: $,
3713
- onMinimize: z
3719
+ addressUpdateStatus: g,
3720
+ onAddressChange: x,
3721
+ selectedBillingAddressId: m,
3722
+ billingAddressUpdateStatus: b,
3723
+ onBillingAddressChange: v,
3724
+ shipToAddress: k,
3725
+ billingAddress: T,
3726
+ checkoutTotals: E,
3727
+ isLoading: I,
3728
+ poMetadataSet: S = !1,
3729
+ isDragging: B,
3730
+ onNewOrder: $,
3731
+ onExpand: z,
3732
+ onMinimize: K
3714
3733
  }) {
3715
- const [re, j] = _(!1), J = R(void 0), ne = M(() => {
3716
- d && navigator.clipboard.writeText(d).then(() => {
3717
- j(!0), clearTimeout(J.current), J.current = setTimeout(() => j(!1), 2e3);
3734
+ const [q, Y] = _(!1), J = O(void 0), le = M(() => {
3735
+ h && navigator.clipboard.writeText(h).then(() => {
3736
+ Y(!0), clearTimeout(J.current), J.current = setTimeout(() => Y(!1), 2e3);
3718
3737
  });
3719
- }, [d]), ie = t.filter((L) => L.status !== "unavailable").reduce((L, W) => L + (W.price ?? 0) * W.quantity, 0), X = t.filter((L) => L.status !== "unavailable"), se = X.reduce(
3720
- (L, W) => L + W.quantity,
3738
+ }, [h]), X = t.filter((D) => D.status !== "unavailable").reduce((D, ne) => D + (ne.price ?? 0) * ne.quantity, 0), Z = t.filter((D) => D.status !== "unavailable"), H = Z.reduce(
3739
+ (D, ne) => D + ne.quantity,
3721
3740
  0
3722
- ), H = t.find(
3723
- (L) => L.catalogPriceCurrencyCode
3724
- )?.catalogPriceCurrencyCode, q = T?.tax, le = T?.shipping, ke = T?.grandTotal ?? (q !== null ? ie + (q ?? 0) + (le ?? 0) : null);
3725
- return t.length === 0 && e.length === 0 && !I ? /* @__PURE__ */ a(
3741
+ ), j = t.find(
3742
+ (D) => D.catalogPriceCurrencyCode
3743
+ )?.catalogPriceCurrencyCode, ie = E?.tax, ye = E?.shipping, se = E?.grandTotal ?? (ie !== null ? X + (ie ?? 0) + (ye ?? 0) : null);
3744
+ return t.length === 0 && e.length === 0 && !S ? /* @__PURE__ */ a(
3726
3745
  Cs,
3727
3746
  {
3728
- className: l,
3729
- isDragging: S,
3730
- onNewOrder: B,
3731
- onExpand: $,
3732
- onMinimize: z
3747
+ className: d,
3748
+ isDragging: B,
3749
+ onNewOrder: $,
3750
+ onExpand: z,
3751
+ onMinimize: K
3733
3752
  }
3734
3753
  ) : /* @__PURE__ */ f(
3735
3754
  "div",
3736
3755
  {
3737
- className: `bg-surface-secondary rounded-lg flex flex-col h-full min-h-0 border border-solid border-border-strong ${l}`,
3756
+ className: `bg-surface-secondary rounded-lg flex flex-col h-full min-h-0 border border-solid border-border-strong ${d}`,
3738
3757
  style: {
3739
3758
  boxShadow: "0 2px 8px -2px rgba(0, 0, 0, 0.04), 0 1px 3px -1px rgba(0, 0, 0, 0.03)"
3740
3759
  },
@@ -3743,30 +3762,30 @@ function Os({
3743
3762
  /* @__PURE__ */ f("div", { className: "flex items-center justify-between mb-2", children: [
3744
3763
  /* @__PURE__ */ a("h2", { className: "text-lg font-normal text-text m-0", children: "Cart" }),
3745
3764
  /* @__PURE__ */ f("div", { className: "flex items-center gap-2", children: [
3746
- B && /* @__PURE__ */ a(Pr, { onNewOrder: B }),
3747
- $ && /* @__PURE__ */ f(Ve, { onClick: $, "aria-label": "Expand", children: [
3765
+ $ && /* @__PURE__ */ a(Pr, { onNewOrder: $ }),
3766
+ z && /* @__PURE__ */ f(We, { onClick: z, "aria-label": "Expand", children: [
3748
3767
  /* @__PURE__ */ a(kr, { size: 14 }),
3749
3768
  "Expand"
3750
3769
  ] }),
3751
- z && /* @__PURE__ */ f(Ve, { onClick: z, "aria-label": "Minimize", children: [
3770
+ K && /* @__PURE__ */ f(We, { onClick: K, "aria-label": "Minimize", children: [
3752
3771
  /* @__PURE__ */ a(Er, { size: 14 }),
3753
3772
  "Minimize"
3754
3773
  ] })
3755
3774
  ] })
3756
3775
  ] }),
3757
- d && /* @__PURE__ */ f("div", { className: "flex gap-5 mb-2", children: [
3776
+ h && /* @__PURE__ */ f("div", { className: "flex gap-5 mb-2", children: [
3758
3777
  /* @__PURE__ */ f("div", { className: "flex flex-col gap-0", children: [
3759
3778
  /* @__PURE__ */ a("span", { className: "text-2xs text-text-tertiary uppercase tracking-[0.05em]", children: "PO Number" }),
3760
3779
  /* @__PURE__ */ f(
3761
3780
  "button",
3762
3781
  {
3763
3782
  type: "button",
3764
- onClick: ne,
3783
+ onClick: le,
3765
3784
  className: "flex items-center gap-1 text-sm font-semibold text-text bg-transparent border-none cursor-pointer p-0 hover:opacity-70 transition-opacity",
3766
- title: re ? "Copied!" : "Copy PO Number",
3785
+ title: q ? "Copied!" : "Copy PO Number",
3767
3786
  children: [
3768
- d,
3769
- /* @__PURE__ */ a("span", { className: "text-text-tertiary", children: re ? /* @__PURE__ */ a(We, { size: 12, title: "Copied" }) : /* @__PURE__ */ a(Sr, { size: 12 }) })
3787
+ h,
3788
+ /* @__PURE__ */ a("span", { className: "text-text-tertiary", children: q ? /* @__PURE__ */ a(ze, { size: 12, title: "Copied" }) : /* @__PURE__ */ a(Sr, { size: 12 }) })
3770
3789
  ]
3771
3790
  }
3772
3791
  )
@@ -3779,15 +3798,15 @@ function Os({
3779
3798
  /* @__PURE__ */ a(
3780
3799
  us,
3781
3800
  {
3782
- addresses: h,
3801
+ addresses: p,
3783
3802
  selectedAddressId: u,
3784
- addressUpdateStatus: p,
3785
- onAddressChange: g,
3786
- selectedBillingAddressId: x,
3787
- billingAddressUpdateStatus: m,
3788
- onBillingAddressChange: b,
3789
- shipToAddress: v,
3790
- billingAddress: k
3803
+ addressUpdateStatus: g,
3804
+ onAddressChange: x,
3805
+ selectedBillingAddressId: m,
3806
+ billingAddressUpdateStatus: b,
3807
+ onBillingAddressChange: v,
3808
+ shipToAddress: k,
3809
+ billingAddress: T
3791
3810
  }
3792
3811
  )
3793
3812
  ] }),
@@ -3797,42 +3816,43 @@ function Os({
3797
3816
  /* @__PURE__ */ a("div", { className: "w-12 h-12 mx-auto mb-3 rounded-full bg-surface-tertiary flex items-center justify-center text-text-quaternary", children: /* @__PURE__ */ a(ls, {}) }),
3798
3817
  /* @__PURE__ */ a("p", { className: "text-sm text-text-quaternary m-0", children: "No items in cart yet" })
3799
3818
  ] }),
3800
- e.length > 0 && /* @__PURE__ */ f(we, { children: [
3801
- e.map((L) => /* @__PURE__ */ a(
3802
- Fs,
3819
+ e.length > 0 && /* @__PURE__ */ f(Pe, { children: [
3820
+ e.map((D) => /* @__PURE__ */ a(
3821
+ Rs,
3803
3822
  {
3804
- item: L,
3805
- onSuggestAlternatives: (W) => s(W)
3823
+ item: D,
3824
+ onSuggestAlternatives: (ne) => i(ne)
3806
3825
  },
3807
- `${mt(L)}-${L.status}`
3826
+ `${mt(D)}-${D.status}`
3808
3827
  )),
3809
3828
  t.length > 0 && /* @__PURE__ */ a("div", { className: "border-b border-border mb-2" })
3810
3829
  ] }),
3811
- t.map((L) => /* @__PURE__ */ a(
3830
+ t.map((D) => /* @__PURE__ */ a(
3812
3831
  ms,
3813
3832
  {
3814
- item: L,
3833
+ item: D,
3815
3834
  onUpdateQuantity: r,
3816
3835
  onRemove: n,
3817
- onShowMoreLikeThis: i,
3818
- onViewProduct: c
3836
+ onShowMoreLikeThis: c,
3837
+ onViewProduct: l
3819
3838
  },
3820
- L.id
3839
+ D.id
3821
3840
  ))
3822
3841
  ] }) }),
3823
3842
  /* @__PURE__ */ a("div", { className: "h-px shrink-0 bg-border" }),
3824
3843
  /* @__PURE__ */ a(
3825
3844
  fs,
3826
3845
  {
3827
- subtotal: ie,
3828
- tax: q,
3829
- shipping: le,
3830
- total: ke,
3831
- currencyCode: H,
3832
- totalQuantity: se,
3833
- availableItemCount: X.length,
3846
+ subtotal: X,
3847
+ tax: ie,
3848
+ shipping: ye,
3849
+ total: se,
3850
+ currencyCode: j,
3851
+ totalQuantity: H,
3852
+ availableItemCount: Z.length,
3834
3853
  onCheckout: o,
3835
- isLoading: E,
3854
+ onReviewCart: s,
3855
+ isLoading: I,
3836
3856
  allowCheckout: !!u
3837
3857
  }
3838
3858
  )
@@ -3840,7 +3860,7 @@ function Os({
3840
3860
  }
3841
3861
  );
3842
3862
  }
3843
- const Rs = [
3863
+ const Os = [
3844
3864
  "failed to fetch",
3845
3865
  "networkerror",
3846
3866
  "network request failed",
@@ -3853,7 +3873,7 @@ function _s(t) {
3853
3873
  if (typeof navigator < "u" && !navigator.onLine)
3854
3874
  return !0;
3855
3875
  const e = t.message.toLowerCase();
3856
- return Rs.some((r) => e.includes(r));
3876
+ return Os.some((r) => e.includes(r));
3857
3877
  }
3858
3878
  function Ds({ error: t, onRetry: e }) {
3859
3879
  if (!t)
@@ -3932,7 +3952,7 @@ function Us({
3932
3952
  }
3933
3953
  ) });
3934
3954
  }
3935
- const Br = "showProducts", Mr = "searchProducts", qs = "searchProductsFromChat", Fr = "searchProductsBySku", $e = "addToCart", wt = "updateCart", St = "removeFromCart", Or = "clearCart", kt = "getCart", st = "getPurchaseOrderData", at = "setPoMetadata", Rr = "setItemWarnings", _r = "removeItemWarnings", ot = "addProcessingFailures", js = /* @__PURE__ */ new Set([Br]);
3955
+ const Br = "showProducts", Mr = "searchProducts", qs = "searchProductsFromChat", Rr = "searchProductsBySku", Be = "addToCart", wt = "updateCart", St = "removeFromCart", Fr = "clearCart", kt = "getCart", st = "getPurchaseOrderData", at = "setPoMetadata", Or = "setItemWarnings", _r = "removeItemWarnings", ot = "addProcessingFailures", js = /* @__PURE__ */ new Set([Br]);
3936
3956
  function Vs(t) {
3937
3957
  return t.type === "tool" && !js.has(t.toolName);
3938
3958
  }
@@ -4058,7 +4078,7 @@ function Hs({
4058
4078
  const Lr = en(
4059
4079
  null
4060
4080
  );
4061
- function Qs({
4081
+ function Gs({
4062
4082
  client: t,
4063
4083
  children: e
4064
4084
  }) {
@@ -4067,13 +4087,13 @@ function Qs({
4067
4087
  function Nt() {
4068
4088
  return tn(Lr);
4069
4089
  }
4070
- function Gs(t, e) {
4090
+ function Qs(t, e) {
4071
4091
  const r = Nt(), n = y(
4072
4092
  (d) => d.bcSession.productCache
4073
- ), o = y((d) => d.cacheProducts), s = R(/* @__PURE__ */ new Set()), i = te(() => t.filter(
4093
+ ), o = y((d) => d.cacheProducts), s = O(/* @__PURE__ */ new Set()), i = re(() => t.filter(
4074
4094
  (d) => !n[d] && !s.current.has(d)
4075
4095
  ), [t, n]);
4076
- O(() => {
4096
+ F(() => {
4077
4097
  if (!(i.length === 0 || !r)) {
4078
4098
  for (const d of i)
4079
4099
  s.current.add(d);
@@ -4087,7 +4107,7 @@ function Gs(t, e) {
4087
4107
  });
4088
4108
  }
4089
4109
  }, [i, e, r, o]);
4090
- const c = te(() => t.map((d) => n[d]).filter((d) => d !== void 0), [t, n]), l = c.length < t.length;
4110
+ const c = re(() => t.map((d) => n[d]).filter((d) => d !== void 0), [t, n]), l = c.length < t.length;
4091
4111
  return {
4092
4112
  products: c,
4093
4113
  isLoading: l,
@@ -4182,7 +4202,7 @@ const Zs = 10;
4182
4202
  function ea(t, e, r) {
4183
4203
  return t ? "bg-surface-tertiary text-text cursor-not-allowed" : e ? "bg-success/20 text-success-text cursor-not-allowed" : r ? "bg-surface-disabled text-text-quaternary cursor-not-allowed" : "bg-surface-invert text-text-invert hover:bg-surface-invert-hover cursor-pointer";
4184
4204
  }
4185
- function Qt({
4205
+ function Gt({
4186
4206
  product: t,
4187
4207
  onAddToCart: e,
4188
4208
  cart: r = [],
@@ -4193,24 +4213,24 @@ function Qt({
4193
4213
  selections: c,
4194
4214
  onSelectionChange: l
4195
4215
  }) {
4196
- const [d, h] = _(1), [u, p] = _(!1), [g, x] = _(!1), m = o === "horizontal", b = y(
4197
- (q) => t.productEntityId !== void 0 ? q.bcSession.variantCache[t.productEntityId] : void 0
4198
- ), v = te(() => !i || !c || c.size === 0 ? i?.defaultVariant ?? null : Ys(
4216
+ const [d, h] = _(1), [p, u] = _(!1), [g, x] = _(!1), m = o === "horizontal", b = y(
4217
+ (j) => t.productEntityId !== void 0 ? j.bcSession.variantCache[t.productEntityId] : void 0
4218
+ ), v = re(() => !i || !c || c.size === 0 ? i?.defaultVariant ?? null : Ys(
4199
4219
  t.productEntityId,
4200
4220
  c,
4201
4221
  i,
4202
4222
  b
4203
4223
  ), [i, c, b, t.productEntityId]), k = v?.entityId ?? t.variantEntityId, T = r.find(
4204
- (q) => q.productEntityId === t.productEntityId && q.variantEntityId === k
4205
- ), E = !!T, I = T?.quantity ?? 0, S = v?.sku ?? t.sku, B = v?.price ?? t.price, $ = v?.availableToSell ?? t.availableQuantity, z = $ !== void 0 && $ > 0 && $ < Zs, re = v?.isInStock ?? t.isInStock, j = v !== null ? (
4224
+ (j) => j.productEntityId === t.productEntityId && j.variantEntityId === k
4225
+ ), E = !!T, I = T?.quantity ?? 0, S = v?.sku ?? t.sku, B = v?.price ?? t.price, $ = v?.availableToSell ?? t.availableQuantity, z = $ !== void 0 && $ > 0 && $ < Zs, K = v?.isInStock ?? t.isInStock, q = v !== null ? (
4206
4226
  // Have variant: check variant stock
4207
- !v.isPurchasable || re === !1 || re === void 0 && (v.availableToSell ?? 0) === 0
4227
+ !v.isPurchasable || K === !1 || K === void 0 && (v.availableToSell ?? 0) === 0
4208
4228
  ) : (
4209
4229
  // No variant: check product-level stock
4210
- re === !1 || re === void 0 && t.availableQuantity === 0
4211
- ), J = i && i.productOptions.length > 0 && c && c.size > 0 && !v, ne = M(async () => {
4212
- if (e && !(J || j) && !(d < 1)) {
4213
- p(!0);
4230
+ K === !1 || K === void 0 && t.availableQuantity === 0
4231
+ ), Y = i && i.productOptions.length > 0 && c && c.size > 0 && !v, J = M(async () => {
4232
+ if (e && !(Y || q) && !(d < 1)) {
4233
+ u(!0);
4214
4234
  try {
4215
4235
  await e(
4216
4236
  t,
@@ -4220,7 +4240,7 @@ function Qt({
4220
4240
  x(!1), h(1);
4221
4241
  }, 1500));
4222
4242
  } finally {
4223
- p(!1);
4243
+ u(!1);
4224
4244
  }
4225
4245
  }
4226
4246
  }, [
@@ -4228,12 +4248,12 @@ function Qt({
4228
4248
  t,
4229
4249
  d,
4230
4250
  v,
4231
- J,
4232
- j
4233
- ]), ie = v?.defaultImage?.replace(
4251
+ Y,
4252
+ q
4253
+ ]), le = v?.defaultImage?.replace(
4234
4254
  "{:size}",
4235
4255
  "200w"
4236
- ), X = t.imageUrl ?? t.defaultImage?.urlTemplate?.replace("{:size}", "200w"), se = ie ?? X, H = z && !j && /* @__PURE__ */ f("p", { className: `text-xs text-warning m-0 ${m ? "mt-1" : "mb-2"}`, children: [
4256
+ ), X = t.imageUrl ?? t.defaultImage?.urlTemplate?.replace("{:size}", "200w"), Z = le ?? X, H = z && !q && /* @__PURE__ */ f("p", { className: `text-xs text-warning m-0 ${m ? "mt-1" : "mb-2"}`, children: [
4237
4257
  "Only ",
4238
4258
  $,
4239
4259
  " left"
@@ -4241,22 +4261,22 @@ function Qt({
4241
4261
  return /* @__PURE__ */ f(
4242
4262
  "div",
4243
4263
  {
4244
- className: `bg-surface rounded-xl border overflow-hidden transition-[border-color,box-shadow] duration-150 flex ${m ? "flex-row border-border hover:shadow-md" : `w-[180px] max-w-full shrink-0 flex-col border-border hover:border-border-strong hover:shadow-[0_2px_8px_rgba(0,0,0,0.06)]${j ? " opacity-70" : ""}`} ${n}`,
4264
+ className: `bg-surface rounded-xl border overflow-hidden transition-[border-color,box-shadow] duration-150 flex ${m ? "flex-row border-border hover:shadow-md" : `w-[180px] max-w-full shrink-0 flex-col border-border hover:border-border-strong hover:shadow-[0_2px_8px_rgba(0,0,0,0.06)]${q ? " opacity-70" : ""}`} ${n}`,
4245
4265
  children: [
4246
4266
  /* @__PURE__ */ f(
4247
4267
  "div",
4248
4268
  {
4249
4269
  className: m ? "shrink-0 w-[120px] h-[120px]" : "relative shrink-0 aspect-[4/3] overflow-hidden bg-surface-tertiary",
4250
4270
  children: [
4251
- se ? /* @__PURE__ */ a(
4271
+ Z ? /* @__PURE__ */ a(
4252
4272
  "img",
4253
4273
  {
4254
- src: se,
4274
+ src: Z,
4255
4275
  alt: t.name,
4256
4276
  className: "w-full h-full object-cover"
4257
4277
  }
4258
4278
  ) : /* @__PURE__ */ a(Js, {}),
4259
- !m && j && /* @__PURE__ */ a("div", { className: "absolute top-2 right-2 bg-error text-text-invert text-xs font-semibold px-2 py-0.5 rounded", children: "Out of stock" })
4279
+ !m && q && /* @__PURE__ */ a("div", { className: "absolute top-2 right-2 bg-error text-text-invert text-xs font-semibold px-2 py-0.5 rounded", children: "Out of stock" })
4260
4280
  ]
4261
4281
  }
4262
4282
  ),
@@ -4285,8 +4305,8 @@ function Qt({
4285
4305
  ),
4286
4306
  /* @__PURE__ */ a("p", { className: "text-xs text-text-quaternary m-0 mt-0.5", children: S }),
4287
4307
  B !== void 0 && /* @__PURE__ */ a("p", { className: "text-sm font-semibold text-text m-0 mt-1", children: Fe(B) }),
4288
- j && /* @__PURE__ */ a("p", { className: "text-xs text-error m-0 mt-1 font-medium", children: "Out of Stock" }),
4289
- !m && !j && $ !== void 0 && $ > 0 && /* @__PURE__ */ f("p", { className: "text-2xs text-success font-medium m-0 mt-0.5", children: [
4308
+ q && /* @__PURE__ */ a("p", { className: "text-xs text-error m-0 mt-1 font-medium", children: "Out of Stock" }),
4309
+ !m && !q && $ !== void 0 && $ > 0 && /* @__PURE__ */ f("p", { className: "text-2xs text-success font-medium m-0 mt-0.5", children: [
4290
4310
  $,
4291
4311
  " in stock"
4292
4312
  ] }),
@@ -4331,10 +4351,10 @@ function Qt({
4331
4351
  "button",
4332
4352
  {
4333
4353
  type: "button",
4334
- onClick: ne,
4335
- disabled: u || g || !!J || j,
4336
- className: `py-1.5 px-3 text-xs font-medium rounded border-none ${m ? "" : "w-full"} ${ea(u, g, !!J || j)}`,
4337
- children: u ? "Adding..." : g ? "✓ Added" : "Add to cart"
4354
+ onClick: J,
4355
+ disabled: p || g || !!Y || q,
4356
+ className: `py-1.5 px-3 text-xs font-medium rounded border-none ${m ? "" : "w-full"} ${ea(p, g, !!Y || q)}`,
4357
+ children: p ? "Adding..." : g ? "✓ Added" : "Add to cart"
4338
4358
  }
4339
4359
  )
4340
4360
  ]
@@ -4360,15 +4380,15 @@ function ta({
4360
4380
  loadingText: i = "Searching for products...",
4361
4381
  className: c = ""
4362
4382
  }) {
4363
- const l = Nt(), d = te(() => {
4383
+ const l = Nt(), d = re(() => {
4364
4384
  const b = /* @__PURE__ */ new Map();
4365
4385
  if (o)
4366
4386
  for (const v of o)
4367
4387
  b.set(v.entityId, v);
4368
4388
  return b;
4369
- }, [o]), [h, u] = _(/* @__PURE__ */ new Map()), p = R(h);
4370
- p.current = h, O(() => {
4371
- o?.length && u((b) => {
4389
+ }, [o]), [h, p] = _(/* @__PURE__ */ new Map()), u = O(h);
4390
+ u.current = h, F(() => {
4391
+ o?.length && p((b) => {
4372
4392
  const v = new Map(b);
4373
4393
  for (const k of t) {
4374
4394
  if (k.productEntityId === void 0 || v.has(k.id)) continue;
@@ -4381,8 +4401,8 @@ function ta({
4381
4401
  });
4382
4402
  }, [o, d, t]);
4383
4403
  const g = (b, v, k) => {
4384
- const T = p.current.get(b) ?? /* @__PURE__ */ new Map(), E = new Map(T);
4385
- E.set(v, k), u((S) => {
4404
+ const T = u.current.get(b) ?? /* @__PURE__ */ new Map(), E = new Map(T);
4405
+ E.set(v, k), p((S) => {
4386
4406
  const B = new Map(S);
4387
4407
  return B.set(b, E), B;
4388
4408
  });
@@ -4416,7 +4436,7 @@ function ta({
4416
4436
  if (x.length === 1 && m) {
4417
4437
  const b = m.productEntityId !== void 0 ? d.get(m.productEntityId) : void 0, v = h.get(m.id);
4418
4438
  return /* @__PURE__ */ a("div", { className: `py-2 ${c}`, children: /* @__PURE__ */ a(
4419
- Qt,
4439
+ Gt,
4420
4440
  {
4421
4441
  layout: "horizontal",
4422
4442
  product: m,
@@ -4432,7 +4452,7 @@ function ta({
4432
4452
  return /* @__PURE__ */ a("div", { className: `flex flex-wrap gap-3 py-2 ${c}`, children: x.map((b) => {
4433
4453
  const v = b.productEntityId !== void 0 ? d.get(b.productEntityId) : void 0, k = h.get(b.id);
4434
4454
  return /* @__PURE__ */ a(
4435
- Qt,
4455
+ Gt,
4436
4456
  {
4437
4457
  product: b,
4438
4458
  onAddToCart: e,
@@ -4453,21 +4473,21 @@ function ra({
4453
4473
  onAddToCart: n,
4454
4474
  onViewProduct: o
4455
4475
  }) {
4456
- const s = e !== "output-available", { productEntityIds: i, variantEntityIds: c } = te(() => {
4476
+ const s = e !== "output-available", { productEntityIds: i, variantEntityIds: c } = re(() => {
4457
4477
  if (!t?.products?.length)
4458
4478
  return { productEntityIds: [], variantEntityIds: [] };
4459
- const u = [...new Set(t.products.map((g) => g.entityId))], p = t.products.map((g) => g.variantEntityId).filter((g) => g !== void 0);
4460
- return { productEntityIds: u, variantEntityIds: p };
4461
- }, [t]), { products: l, isLoading: d } = Gs(i, c), h = te(() => {
4479
+ const p = [...new Set(t.products.map((g) => g.entityId))], u = t.products.map((g) => g.variantEntityId).filter((g) => g !== void 0);
4480
+ return { productEntityIds: p, variantEntityIds: u };
4481
+ }, [t]), { products: l, isLoading: d } = Qs(i, c), h = re(() => {
4462
4482
  if (!t?.products?.length) return [];
4463
- const u = [];
4464
- for (const p of t.products) {
4483
+ const p = [];
4484
+ for (const u of t.products) {
4465
4485
  const g = l.find(
4466
- (m) => m.entityId === p.entityId
4486
+ (m) => m.entityId === u.entityId
4467
4487
  );
4468
4488
  if (!g) continue;
4469
4489
  const x = g.defaultVariant;
4470
- x && u.push({
4490
+ x && p.push({
4471
4491
  id: `${g.entityId}-${x.entityId}`,
4472
4492
  sku: x.sku,
4473
4493
  name: g.name,
@@ -4480,7 +4500,7 @@ function ra({
4480
4500
  variantEntityId: x.entityId
4481
4501
  });
4482
4502
  }
4483
- return u;
4503
+ return p;
4484
4504
  }, [t, l]);
4485
4505
  return /* @__PURE__ */ a(
4486
4506
  ta,
@@ -4523,7 +4543,7 @@ function Ur({
4523
4543
  toolOutput: n,
4524
4544
  toolState: o ?? ""
4525
4545
  }
4526
- ) : e === Fr ? /* @__PURE__ */ a(
4546
+ ) : e === Rr ? /* @__PURE__ */ a(
4527
4547
  zs,
4528
4548
  {
4529
4549
  toolCallId: t,
@@ -4531,7 +4551,7 @@ function Ur({
4531
4551
  toolOutput: n,
4532
4552
  toolState: o ?? ""
4533
4553
  }
4534
- ) : e === $e ? /* @__PURE__ */ a(
4554
+ ) : e === Be ? /* @__PURE__ */ a(
4535
4555
  oe,
4536
4556
  {
4537
4557
  toolCallId: t,
@@ -4558,7 +4578,7 @@ function Ur({
4558
4578
  successMessage: "Removed from cart",
4559
4579
  toolOutput: n
4560
4580
  }
4561
- ) : e === Or ? /* @__PURE__ */ a(
4581
+ ) : e === Fr ? /* @__PURE__ */ a(
4562
4582
  oe,
4563
4583
  {
4564
4584
  toolCallId: t,
@@ -4591,7 +4611,7 @@ function Ur({
4591
4611
  successMessage: "Saved metadata",
4592
4612
  toolOutput: n
4593
4613
  }
4594
- ) : e === Rr ? /* @__PURE__ */ a(
4614
+ ) : e === Or ? /* @__PURE__ */ a(
4595
4615
  oe,
4596
4616
  {
4597
4617
  toolCallId: t,
@@ -4687,33 +4707,33 @@ async function qr(t, e) {
4687
4707
  console.warn("Invalid SSE chunk:", h.error);
4688
4708
  continue;
4689
4709
  }
4690
- const u = h.value;
4691
- switch (u.type) {
4710
+ const p = h.value;
4711
+ switch (p.type) {
4692
4712
  case "text-delta":
4693
- o.push(u.delta);
4713
+ o.push(p.delta);
4694
4714
  break;
4695
4715
  case "tool-input-available": {
4696
- const p = {
4697
- toolCallId: u.toolCallId,
4698
- toolName: u.toolName,
4699
- input: u.input
4716
+ const u = {
4717
+ toolCallId: p.toolCallId,
4718
+ toolName: p.toolName,
4719
+ input: p.input
4700
4720
  };
4701
- r.push(p), e?.onToolCall?.(p);
4721
+ r.push(u), e?.onToolCall?.(u);
4702
4722
  break;
4703
4723
  }
4704
4724
  case "tool-output-available": {
4705
- n.add(u.toolCallId);
4706
- const p = r.find(
4707
- (g) => g.toolCallId === u.toolCallId
4725
+ n.add(p.toolCallId);
4726
+ const u = r.find(
4727
+ (g) => g.toolCallId === p.toolCallId
4708
4728
  );
4709
- p && (p.output = u.output, e?.onToolOutput?.(p));
4729
+ u && (u.output = p.output, e?.onToolOutput?.(u));
4710
4730
  break;
4711
4731
  }
4712
4732
  case "error":
4713
- i = u.errorText;
4733
+ i = p.errorText;
4714
4734
  break;
4715
4735
  case "finish":
4716
- s = u.finishReason ?? null;
4736
+ s = p.finishReason ?? null;
4717
4737
  break;
4718
4738
  }
4719
4739
  }
@@ -4730,7 +4750,7 @@ async function qr(t, e) {
4730
4750
  };
4731
4751
  }
4732
4752
  async function Pt(t, e) {
4733
- const { origin: r, projectId: n, apiKey: o } = t, s = await Te(
4753
+ const { origin: r, projectId: n, apiKey: o } = t, s = await Ae(
4734
4754
  `${r}/project/${n}/agents/threads`,
4735
4755
  {
4736
4756
  method: "POST",
@@ -4751,7 +4771,7 @@ async function Pt(t, e) {
4751
4771
  return sa.parse(i).id;
4752
4772
  }
4753
4773
  async function jr(t, e, r, n) {
4754
- const { sseOrigin: o, projectId: s, apiKey: i } = t, c = await Te(
4774
+ const { sseOrigin: o, projectId: s, apiKey: i } = t, c = await Ae(
4755
4775
  `${o}/project/${s}/agents/messages`,
4756
4776
  {
4757
4777
  method: "POST",
@@ -4805,7 +4825,7 @@ const aa = `
4805
4825
  }
4806
4826
  `;
4807
4827
  async function oa(t, e) {
4808
- const { origin: r, projectId: n, apiKey: o } = t, s = await Te(`${r}/project/${n}/graphql`, {
4828
+ const { origin: r, projectId: n, apiKey: o } = t, s = await Ae(`${r}/project/${n}/graphql`, {
4809
4829
  method: "POST",
4810
4830
  headers: {
4811
4831
  "Content-Type": "application/json",
@@ -4835,12 +4855,12 @@ async function oa(t, e) {
4835
4855
  );
4836
4856
  return !0;
4837
4857
  }
4838
- function Gt({
4858
+ function Qt({
4839
4859
  messageId: t,
4840
4860
  isOpen: e,
4841
4861
  onClose: r
4842
4862
  }) {
4843
- const [n, o] = _(""), [s, i] = _(""), [c, l] = _(""), [d, h] = _("idle"), [u, p] = _(""), g = R(null), x = y(
4863
+ const [n, o] = _(""), [s, i] = _(""), [c, l] = _(""), [d, h] = _("idle"), [p, u] = _(""), g = O(null), x = y(
4844
4864
  (E) => E.takeshapeConfig
4845
4865
  ), m = y((E) => E.chat.threadId), b = y(
4846
4866
  (E) => E.parser.threadId
@@ -4849,9 +4869,9 @@ function Gt({
4849
4869
  ), k = y(
4850
4870
  (E) => E.cartChecker.threadId
4851
4871
  );
4852
- O(() => {
4853
- e && (o(""), i(""), l(""), h("idle"), p(""), g.current?.focus());
4854
- }, [e]), O(() => {
4872
+ F(() => {
4873
+ e && (o(""), i(""), l(""), h("idle"), u(""), g.current?.focus());
4874
+ }, [e]), F(() => {
4855
4875
  if (!e) return;
4856
4876
  const E = (I) => {
4857
4877
  I.key === "Escape" && r();
@@ -4860,7 +4880,7 @@ function Gt({
4860
4880
  }, [e, r]);
4861
4881
  const T = async (E) => {
4862
4882
  if (E.preventDefault(), !(!n.trim() || !c.trim())) {
4863
- h("submitting"), p("");
4883
+ h("submitting"), u("");
4864
4884
  try {
4865
4885
  xn(
4866
4886
  {
@@ -4887,7 +4907,7 @@ function Gt({
4887
4907
  text: c.trim()
4888
4908
  }), h("success");
4889
4909
  } catch (I) {
4890
- h("error"), p(
4910
+ h("error"), u(
4891
4911
  I instanceof Error ? I.message : "Failed to send feedback"
4892
4912
  );
4893
4913
  }
@@ -5006,7 +5026,7 @@ function Gt({
5006
5026
  }
5007
5027
  )
5008
5028
  ] }),
5009
- d === "error" && u && /* @__PURE__ */ a("div", { className: "p-3 text-sm bg-error-bg text-error-text rounded-md", children: u }),
5029
+ d === "error" && p && /* @__PURE__ */ a("div", { className: "p-3 text-sm bg-error-bg text-error-text rounded-md", children: p }),
5010
5030
  d === "success" && /* @__PURE__ */ a("div", { className: "p-3 text-sm bg-success-bg text-success-text rounded-md", children: "Thank you for your feedback!" }),
5011
5031
  /* @__PURE__ */ a(
5012
5032
  "button",
@@ -5014,8 +5034,8 @@ function Gt({
5014
5034
  type: "submit",
5015
5035
  disabled: !n.trim() || !c.trim() || d === "submitting" || d === "success",
5016
5036
  className: "w-full flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium text-text-invert bg-surface-invert rounded-md hover:bg-surface-invert-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
5017
- children: d === "submitting" ? /* @__PURE__ */ f(we, { children: [
5018
- /* @__PURE__ */ a(De, { size: 16 }),
5037
+ children: d === "submitting" ? /* @__PURE__ */ f(Pe, { children: [
5038
+ /* @__PURE__ */ a(Le, { size: 16 }),
5019
5039
  "Sending..."
5020
5040
  ] }) : d === "success" ? "Sent!" : "Send Feedback"
5021
5041
  }
@@ -5052,7 +5072,7 @@ function ia({
5052
5072
  isLatestAssistantMessage: r,
5053
5073
  text: n
5054
5074
  }) {
5055
- const o = te(() => n.slice(0, 80), [n]), s = y(
5075
+ const o = re(() => n.slice(0, 80), [n]), s = y(
5056
5076
  (h) => h.ui.expandedMessageIds
5057
5077
  ), i = y(
5058
5078
  (h) => h.toggleMessageExpanded
@@ -5071,7 +5091,7 @@ function ia({
5071
5091
  }
5072
5092
  ),
5073
5093
  /* @__PURE__ */ a(
5074
- Gt,
5094
+ Qt,
5075
5095
  {
5076
5096
  messageId: e,
5077
5097
  isOpen: l,
@@ -5132,7 +5152,7 @@ function ia({
5132
5152
  )
5133
5153
  ] }),
5134
5154
  /* @__PURE__ */ a(
5135
- Gt,
5155
+ Qt,
5136
5156
  {
5137
5157
  messageId: e,
5138
5158
  isOpen: l,
@@ -5146,7 +5166,7 @@ function ca(t) {
5146
5166
  return [];
5147
5167
  const e = [];
5148
5168
  for (const r of t.parts)
5149
- if (r.type === "text" && r.text !== je)
5169
+ if (r.type === "text" && r.text !== Ve)
5150
5170
  e.push({
5151
5171
  type: "text",
5152
5172
  text: r.text
@@ -5213,35 +5233,35 @@ function da({
5213
5233
  ]
5214
5234
  }
5215
5235
  ),
5216
- n && /* @__PURE__ */ a("div", { className: "mt-2 p-3 bg-surface border border-border rounded-lg max-h-96 overflow-y-auto", children: h.map((u, p) => u.type === "text" ? /* @__PURE__ */ a(
5236
+ n && /* @__PURE__ */ a("div", { className: "mt-2 p-3 bg-surface border border-border rounded-lg max-h-96 overflow-y-auto", children: h.map((p, u) => p.type === "text" ? /* @__PURE__ */ a(
5217
5237
  Je,
5218
5238
  {
5219
5239
  className: "text-sm leading-normal text-text",
5220
5240
  plugins: {},
5221
- children: u.text
5241
+ children: p.text
5222
5242
  },
5223
- `text-${t.id}-${p}`
5243
+ `text-${t.id}-${u}`
5224
5244
  ) : null) })
5225
- ] }) : /* @__PURE__ */ f(we, { children: [
5226
- Ws(h).map((u, p) => u.type === "tool-group" ? /* @__PURE__ */ a(
5245
+ ] }) : /* @__PURE__ */ f(Pe, { children: [
5246
+ Ws(h).map((p, u) => p.type === "tool-group" ? /* @__PURE__ */ a(
5227
5247
  na,
5228
5248
  {
5229
- tools: u.tools,
5230
- messageId: `${t.id}-${p}`,
5249
+ tools: p.tools,
5250
+ messageId: `${t.id}-${u}`,
5231
5251
  cart: i,
5232
5252
  onAddToCart: c,
5233
5253
  onViewProduct: l
5234
5254
  },
5235
- `group-${t.id}-${p}`
5236
- ) : u.type === "text" ? d ? /* @__PURE__ */ a(
5255
+ `group-${t.id}-${u}`
5256
+ ) : p.type === "text" ? d ? /* @__PURE__ */ a(
5237
5257
  ia,
5238
5258
  {
5239
- messagePartId: `${t.id}-${p}`,
5259
+ messagePartId: `${t.id}-${u}`,
5240
5260
  messageId: t.id,
5241
5261
  isLatestAssistantMessage: r,
5242
- text: u.text
5262
+ text: p.text
5243
5263
  },
5244
- `text-${t.id}-${p}`
5264
+ `text-${t.id}-${u}`
5245
5265
  ) : /* @__PURE__ */ a(
5246
5266
  "div",
5247
5267
  {
@@ -5251,25 +5271,25 @@ function da({
5251
5271
  {
5252
5272
  className: "text-sm leading-relaxed text-text",
5253
5273
  plugins: {},
5254
- children: u.text
5274
+ children: p.text
5255
5275
  }
5256
5276
  )
5257
5277
  },
5258
- `text-${t.id}-${p}`
5259
- ) : u.type === "tool" ? /* @__PURE__ */ a("div", { className: "ml-5", children: /* @__PURE__ */ a(
5278
+ `text-${t.id}-${u}`
5279
+ ) : p.type === "tool" ? /* @__PURE__ */ a("div", { className: "ml-5", children: /* @__PURE__ */ a(
5260
5280
  Ur,
5261
5281
  {
5262
- toolCallId: u.toolCallId,
5263
- toolName: u.toolName,
5264
- toolInput: u.toolInput,
5265
- toolOutput: u.toolOutput,
5266
- toolState: u.toolState,
5282
+ toolCallId: p.toolCallId,
5283
+ toolName: p.toolName,
5284
+ toolInput: p.toolInput,
5285
+ toolOutput: p.toolOutput,
5286
+ toolState: p.toolState,
5267
5287
  cart: i,
5268
5288
  onAddToCart: c,
5269
5289
  onViewProduct: l
5270
5290
  }
5271
- ) }, u.toolCallId) : null),
5272
- !d && t.parts?.some((u) => u.type === "file") && /* @__PURE__ */ f("div", { className: "flex items-center gap-1.5 mt-2 text-xs text-text-tertiary", children: [
5291
+ ) }, p.toolCallId) : null),
5292
+ !d && t.parts?.some((p) => p.type === "file") && /* @__PURE__ */ f("div", { className: "flex items-center gap-1.5 mt-2 text-xs text-text-tertiary", children: [
5273
5293
  /* @__PURE__ */ a(Ht, {}),
5274
5294
  /* @__PURE__ */ a("span", { children: la(t.parts) })
5275
5295
  ] })
@@ -5279,7 +5299,7 @@ function da({
5279
5299
  }
5280
5300
  function Vr() {
5281
5301
  const [t, e] = _(!1);
5282
- return O(() => {
5302
+ return F(() => {
5283
5303
  if (typeof window.matchMedia != "function") {
5284
5304
  e(
5285
5305
  "ontouchstart" in window || navigator.maxTouchPoints > 0
@@ -5383,7 +5403,7 @@ function ha({
5383
5403
  /* @__PURE__ */ a(
5384
5404
  "div",
5385
5405
  {
5386
- className: Ae(
5406
+ className: $e(
5387
5407
  "flex items-center justify-center w-16 h-16 rounded-2xl p-1 border-2 border-dashed border-border-focus text-text transition-transform duration-200",
5388
5408
  t && "animate-icon-bounce"
5389
5409
  ),
@@ -5431,12 +5451,12 @@ const fa = rn(
5431
5451
  onViewProduct: l,
5432
5452
  className: d = "",
5433
5453
  error: h = null,
5434
- onRetry: u,
5435
- hasProcessedDocument: p = !1,
5454
+ onRetry: p,
5455
+ hasProcessedDocument: u = !1,
5436
5456
  uploadedFileName: g = null,
5437
5457
  fileDrop: x
5438
5458
  }, m) {
5439
- const b = R(null), v = R(!0), [k, T] = _(!1), E = te(() => {
5459
+ const b = O(null), v = O(!0), [k, T] = _(!1), E = re(() => {
5440
5460
  for (let I = e.length - 1; I >= 0; I--) {
5441
5461
  const S = e[I];
5442
5462
  if (S?.role === "assistant")
@@ -5452,7 +5472,7 @@ const fa = rn(
5452
5472
  behavior: "smooth"
5453
5473
  })), v.current = !0;
5454
5474
  }
5455
- })), O(() => {
5475
+ })), F(() => {
5456
5476
  const I = b.current;
5457
5477
  if (!I) return;
5458
5478
  const S = () => {
@@ -5488,7 +5508,7 @@ const fa = rn(
5488
5508
  }
5489
5509
  ),
5490
5510
  e.map((I, S) => {
5491
- const B = p && I.role !== "assistant" && S === 0, $ = I.role === "assistant" && I.id === E;
5511
+ const B = u && I.role !== "assistant" && S === 0, $ = I.role === "assistant" && I.id === E;
5492
5512
  return /* @__PURE__ */ a(
5493
5513
  da,
5494
5514
  {
@@ -5506,7 +5526,7 @@ const fa = rn(
5506
5526
  );
5507
5527
  }),
5508
5528
  s && /* @__PURE__ */ a(pa, {}),
5509
- /* @__PURE__ */ a(Ds, { error: h, onRetry: u })
5529
+ /* @__PURE__ */ a(Ds, { error: h, onRetry: p })
5510
5530
  ]
5511
5531
  }
5512
5532
  ),
@@ -5533,49 +5553,49 @@ const fa = rn(
5533
5553
  )
5534
5554
  );
5535
5555
  function ya() {
5536
- const t = Yt((p) => p.panelWidth), e = Yt((p) => p.setPanelWidth), [r, n] = _(
5556
+ const t = Yt((u) => u.panelWidth), e = Yt((u) => u.setPanelWidth), [r, n] = _(
5537
5557
  typeof window < "u" && window.innerWidth >= 1024
5538
- ), o = R(null), s = R(!1), i = R(t);
5539
- O(() => {
5558
+ ), o = O(null), s = O(!1), i = O(t);
5559
+ F(() => {
5540
5560
  i.current = t;
5541
- }, [t]), O(() => {
5542
- const p = () => {
5561
+ }, [t]), F(() => {
5562
+ const u = () => {
5543
5563
  n(window.innerWidth >= 1024);
5544
5564
  };
5545
- return p(), window.addEventListener("resize", p), () => {
5546
- window.removeEventListener("resize", p);
5565
+ return u(), window.addEventListener("resize", u), () => {
5566
+ window.removeEventListener("resize", u);
5547
5567
  };
5548
5568
  }, []);
5549
5569
  const c = M(
5550
- (p) => {
5570
+ (u) => {
5551
5571
  if (!s.current || !o.current) return;
5552
- const g = o.current.getBoundingClientRect(), x = (p.clientX - g.left) / g.width * 100, m = Math.min(80, Math.max(20, x));
5572
+ const g = o.current.getBoundingClientRect(), x = (u.clientX - g.left) / g.width * 100, m = Math.min(80, Math.max(20, x));
5553
5573
  i.current = m, e(m);
5554
5574
  },
5555
5575
  [e]
5556
5576
  ), l = M(() => {
5557
5577
  s.current = !1, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", c), document.removeEventListener("mouseup", l);
5558
5578
  }, [c]), d = M(
5559
- (p) => {
5560
- p.preventDefault(), s.current = !0, document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", c), document.addEventListener("mouseup", l);
5579
+ (u) => {
5580
+ u.preventDefault(), s.current = !0, document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", c), document.addEventListener("mouseup", l);
5561
5581
  },
5562
5582
  [c, l]
5563
5583
  ), h = M(
5564
- (p) => {
5565
- if (p.key === "ArrowLeft") {
5566
- p.preventDefault();
5584
+ (u) => {
5585
+ if (u.key === "ArrowLeft") {
5586
+ u.preventDefault();
5567
5587
  const x = Math.max(20, i.current - 2);
5568
5588
  i.current = x, e(x);
5569
- } else if (p.key === "ArrowRight") {
5570
- p.preventDefault();
5589
+ } else if (u.key === "ArrowRight") {
5590
+ u.preventDefault();
5571
5591
  const x = Math.min(80, i.current + 2);
5572
5592
  i.current = x, e(x);
5573
5593
  }
5574
5594
  },
5575
5595
  [e]
5576
- ), u = M(() => {
5596
+ ), p = M(() => {
5577
5597
  }, []);
5578
- return O(() => () => {
5598
+ return F(() => () => {
5579
5599
  l();
5580
5600
  }, [l]), {
5581
5601
  leftPanelWidth: t,
@@ -5583,7 +5603,7 @@ function ya() {
5583
5603
  containerRef: o,
5584
5604
  handleMouseDown: d,
5585
5605
  handleKeyDown: h,
5586
- handleBlur: u
5606
+ handleBlur: p
5587
5607
  };
5588
5608
  }
5589
5609
  function Ca({ activeTab: t, onTabChange: e, hasUnread: r }) {
@@ -5641,51 +5661,52 @@ function Jt({
5641
5661
  chatPanelRef: d,
5642
5662
  onFileUpload: h,
5643
5663
  // Cart panel props
5644
- cartItems: u,
5645
- itemWarnings: p,
5664
+ cartItems: p,
5665
+ itemWarnings: u,
5646
5666
  onUpdateQuantity: g,
5647
5667
  onRemove: x,
5648
5668
  onCheckout: m,
5649
- onSuggestAlternatives: b,
5650
- onShowMoreLikeThis: v,
5651
- onViewProduct: k,
5652
- onAddToCart: T,
5653
- orderId: E,
5654
- buyerInfo: I,
5655
- customerInfo: S,
5656
- addresses: B,
5657
- selectedAddressId: $,
5658
- addressUpdateStatus: z,
5659
- onAddressChange: re,
5660
- selectedBillingAddressId: j,
5669
+ onReviewCart: b,
5670
+ onSuggestAlternatives: v,
5671
+ onShowMoreLikeThis: k,
5672
+ onViewProduct: T,
5673
+ onAddToCart: E,
5674
+ orderId: I,
5675
+ buyerInfo: S,
5676
+ customerInfo: B,
5677
+ addresses: $,
5678
+ selectedAddressId: z,
5679
+ addressUpdateStatus: K,
5680
+ onAddressChange: q,
5681
+ selectedBillingAddressId: Y,
5661
5682
  billingAddressUpdateStatus: J,
5662
- onBillingAddressChange: ne,
5663
- shipToAddress: ie,
5664
- billingAddress: X,
5665
- checkoutTotals: se,
5666
- isCartLoading: H,
5667
- poMetadataSet: q,
5668
- onNewOrder: le,
5669
- onExpand: ke,
5670
- onMinimize: L,
5671
- className: W = ""
5683
+ onBillingAddressChange: le,
5684
+ shipToAddress: X,
5685
+ billingAddress: Z,
5686
+ checkoutTotals: H,
5687
+ isCartLoading: j,
5688
+ poMetadataSet: ie,
5689
+ onNewOrder: ye,
5690
+ onExpand: se,
5691
+ onMinimize: D,
5692
+ className: ne = ""
5672
5693
  }) {
5673
- const G = ya(), [K, Be] = _(
5674
- u.length > 0 ? "cart" : "chat"
5675
- ), [ge, ye] = _(!1), he = R(t.length), Ce = R(K);
5676
- Ce.current = K;
5677
- const C = t.length === 0 && u.length === 0 && !!h, N = wr({
5694
+ const W = ya(), [de, Ce] = _(
5695
+ p.length > 0 ? "cart" : "chat"
5696
+ ), [Me, ue] = _(!1), xe = O(t.length), C = O(de);
5697
+ C.current = de;
5698
+ const N = t.length === 0 && p.length === 0 && !!h, P = wr({
5678
5699
  onFile: h ?? (() => {
5679
5700
  })
5680
5701
  });
5681
- O(() => {
5682
- t.length > he.current && Ce.current !== "chat" && ye(!0), he.current = t.length;
5683
- }, [t.length]), O(() => {
5684
- G.isDesktop && ye(!1);
5685
- }, [G.isDesktop]);
5686
- const P = M((D) => {
5687
- Be(D), D === "chat" && ye(!1);
5688
- }, []), A = /* @__PURE__ */ a(
5702
+ F(() => {
5703
+ t.length > xe.current && C.current !== "chat" && ue(!0), xe.current = t.length;
5704
+ }, [t.length]), F(() => {
5705
+ W.isDesktop && ue(!1);
5706
+ }, [W.isDesktop]);
5707
+ const A = M((ke) => {
5708
+ Ce(ke), ke === "chat" && ue(!1);
5709
+ }, []), R = /* @__PURE__ */ a(
5689
5710
  fa,
5690
5711
  {
5691
5712
  ref: d,
@@ -5694,88 +5715,89 @@ function Jt({
5694
5715
  onInputChange: r,
5695
5716
  onSubmit: n,
5696
5717
  isLoading: o,
5697
- cart: u,
5698
- onAddToCart: T,
5699
- onViewProduct: k,
5718
+ cart: p,
5719
+ onAddToCart: E,
5720
+ onViewProduct: T,
5700
5721
  error: s,
5701
5722
  onRetry: i,
5702
5723
  hasProcessedDocument: c,
5703
5724
  uploadedFileName: l,
5704
- fileDrop: h ? N : void 0
5725
+ fileDrop: h ? P : void 0
5705
5726
  }
5706
- ), F = /* @__PURE__ */ a(
5707
- Os,
5727
+ ), L = /* @__PURE__ */ a(
5728
+ Fs,
5708
5729
  {
5709
- items: u,
5710
- itemWarnings: p,
5730
+ items: p,
5731
+ itemWarnings: u,
5711
5732
  onUpdateQuantity: g,
5712
5733
  onRemove: x,
5713
5734
  onCheckout: m,
5714
- onSuggestAlternatives: b,
5715
- onShowMoreLikeThis: v,
5716
- onViewProduct: k,
5717
- orderId: E ?? void 0,
5718
- buyerInfo: I ?? void 0,
5719
- customerInfo: S,
5720
- addresses: B,
5721
- selectedAddressId: $,
5722
- addressUpdateStatus: z,
5723
- onAddressChange: re,
5724
- selectedBillingAddressId: j,
5735
+ onReviewCart: b,
5736
+ onSuggestAlternatives: v,
5737
+ onShowMoreLikeThis: k,
5738
+ onViewProduct: T,
5739
+ orderId: I ?? void 0,
5740
+ buyerInfo: S ?? void 0,
5741
+ customerInfo: B,
5742
+ addresses: $,
5743
+ selectedAddressId: z,
5744
+ addressUpdateStatus: K,
5745
+ onAddressChange: q,
5746
+ selectedBillingAddressId: Y,
5725
5747
  billingAddressUpdateStatus: J,
5726
- onBillingAddressChange: ne,
5727
- shipToAddress: ie ?? void 0,
5728
- billingAddress: X ?? void 0,
5729
- checkoutTotals: se ?? void 0,
5730
- isLoading: H,
5731
- poMetadataSet: q,
5732
- isDragging: C && N.isDragging,
5733
- onNewOrder: le,
5734
- onExpand: ke,
5735
- onMinimize: L,
5736
- className: G.isDesktop ? "rounded-l-none border-0" : ""
5737
- }
5738
- ), U = C ? N.dragProps : void 0;
5739
- return G.isDesktop ? (
5748
+ onBillingAddressChange: le,
5749
+ shipToAddress: X ?? void 0,
5750
+ billingAddress: Z ?? void 0,
5751
+ checkoutTotals: H ?? void 0,
5752
+ isLoading: j,
5753
+ poMetadataSet: ie,
5754
+ isDragging: N && P.isDragging,
5755
+ onNewOrder: ye,
5756
+ onExpand: se,
5757
+ onMinimize: D,
5758
+ className: W.isDesktop ? "rounded-l-none border-0" : ""
5759
+ }
5760
+ ), U = N ? P.dragProps : void 0;
5761
+ return W.isDesktop ? (
5740
5762
  // biome-ignore lint/a11y/noStaticElementInteractions: dnd is optional
5741
5763
  /* @__PURE__ */ f(
5742
5764
  "div",
5743
5765
  {
5744
- ref: G.containerRef,
5745
- className: `flex flex-row h-full ${W}`,
5766
+ ref: W.containerRef,
5767
+ className: `flex flex-row h-full ${ne}`,
5746
5768
  ...U,
5747
5769
  children: [
5748
5770
  /* @__PURE__ */ a(
5749
5771
  "div",
5750
5772
  {
5751
5773
  className: "h-full border border-r-0 border-solid border-border-strong rounded-md rounded-r-none overflow-hidden",
5752
- style: { width: `${G.leftPanelWidth}%`, minWidth: 0 },
5753
- children: A
5774
+ style: { width: `${W.leftPanelWidth}%`, minWidth: 0 },
5775
+ children: R
5754
5776
  }
5755
5777
  ),
5756
5778
  /* @__PURE__ */ a(
5757
5779
  "div",
5758
5780
  {
5759
5781
  className: "w-px cursor-col-resize bg-border shrink-0 z-10 relative transition-colors hover:bg-text-quaternary before:content-[''] before:absolute before:inset-y-0 before:-left-1.5 before:-right-1.5",
5760
- onMouseDown: G.handleMouseDown,
5761
- onKeyDown: G.handleKeyDown,
5762
- onBlur: G.handleBlur,
5782
+ onMouseDown: W.handleMouseDown,
5783
+ onKeyDown: W.handleKeyDown,
5784
+ onBlur: W.handleBlur,
5763
5785
  role: "separator",
5764
5786
  tabIndex: 0,
5765
5787
  "aria-orientation": "vertical",
5766
5788
  "aria-label": "Resize panels",
5767
- "aria-valuenow": G.leftPanelWidth,
5789
+ "aria-valuenow": W.leftPanelWidth,
5768
5790
  "aria-valuemin": 20,
5769
5791
  "aria-valuemax": 80,
5770
- "aria-valuetext": `Chat panel width: ${Math.round(G.leftPanelWidth)}%`
5792
+ "aria-valuetext": `Chat panel width: ${Math.round(W.leftPanelWidth)}%`
5771
5793
  }
5772
5794
  ),
5773
5795
  /* @__PURE__ */ a(
5774
5796
  "div",
5775
5797
  {
5776
5798
  className: "h-full border border-l-0 border-border-strong border-solid rounded-md rounded-l-none overflow-hidden",
5777
- style: { width: `${100 - G.leftPanelWidth}%`, minWidth: 0 },
5778
- children: F
5799
+ style: { width: `${100 - W.leftPanelWidth}%`, minWidth: 0 },
5800
+ children: L
5779
5801
  }
5780
5802
  )
5781
5803
  ]
@@ -5786,16 +5808,16 @@ function Jt({
5786
5808
  /* @__PURE__ */ f(
5787
5809
  "div",
5788
5810
  {
5789
- ref: G.containerRef,
5790
- className: `flex flex-col h-full min-h-0 border border-solid border-border-strong rounded-md overflow-hidden ${W}`,
5811
+ ref: W.containerRef,
5812
+ className: `flex flex-col h-full min-h-0 border border-solid border-border-strong rounded-md overflow-hidden ${ne}`,
5791
5813
  ...U,
5792
5814
  children: [
5793
5815
  /* @__PURE__ */ a(
5794
5816
  Ca,
5795
5817
  {
5796
- activeTab: K,
5797
- onTabChange: P,
5798
- hasUnread: ge
5818
+ activeTab: de,
5819
+ onTabChange: A,
5820
+ hasUnread: Me
5799
5821
  }
5800
5822
  ),
5801
5823
  /* @__PURE__ */ a(
@@ -5803,9 +5825,9 @@ function Jt({
5803
5825
  {
5804
5826
  className: "flex-1 min-h-0 overflow-hidden",
5805
5827
  role: "tabpanel",
5806
- id: `tabpanel-${K}`,
5807
- "aria-labelledby": `tab-${K}`,
5808
- children: K === "cart" ? F : A
5828
+ id: `tabpanel-${de}`,
5829
+ "aria-labelledby": `tab-${de}`,
5830
+ children: de === "cart" ? L : R
5809
5831
  }
5810
5832
  )
5811
5833
  ]
@@ -5816,7 +5838,7 @@ function Jt({
5816
5838
  function xa() {
5817
5839
  const t = Nt(), e = y((c) => c.ui.existingCart), r = y(
5818
5840
  (c) => c.confirmClearExistingCart
5819
- ), [n, o] = _(!1), s = te(
5841
+ ), [n, o] = _(!1), s = re(
5820
5842
  () => e?.lineItems.physicalItems.reduce(
5821
5843
  (c, l) => c + l.quantity,
5822
5844
  0
@@ -5842,7 +5864,7 @@ function xa() {
5842
5864
  disabled: n,
5843
5865
  className: "bg-surface-invert shadow-button transition-all duration-200 ease-in-out hover:bg-surface-invert-hover hover:shadow-button-hover hover:-translate-y-px px-4 py-2 text-text-invert rounded-full font-medium cursor-pointer disabled:opacity-50 disabled:pointer-events-none",
5844
5866
  children: n ? /* @__PURE__ */ f("span", { className: "flex items-center gap-2", children: [
5845
- /* @__PURE__ */ a(De, { size: 14 }),
5867
+ /* @__PURE__ */ a(Le, { size: 14 }),
5846
5868
  "Clearing cart…"
5847
5869
  ] }) : "Clear Cart & Continue"
5848
5870
  }
@@ -5901,7 +5923,7 @@ function Hr() {
5901
5923
  ), r = y(
5902
5924
  (n) => n.batchProcessing.status
5903
5925
  );
5904
- return te(() => t !== "processing" ? null : e ? r === "idle" || r === "processing" ? "matching" : "building" : "reading", [t, e, r]);
5926
+ return re(() => t !== "processing" ? null : e ? r === "idle" || r === "processing" ? "matching" : "building" : "reading", [t, e, r]);
5905
5927
  }
5906
5928
  const Sa = [
5907
5929
  { label: "Upload", number: 1 },
@@ -5954,7 +5976,7 @@ function Ea({
5954
5976
  /* @__PURE__ */ a(
5955
5977
  "div",
5956
5978
  {
5957
- className: Ae(
5979
+ className: $e(
5958
5980
  "flex items-center justify-center w-16 h-16 rounded-2xl p-1 border-2 border-dashed border-border-focus text-text transition-transform duration-200",
5959
5981
  t && "animate-icon-bounce"
5960
5982
  ),
@@ -5984,13 +6006,13 @@ function Na({
5984
6006
  onFileChange: s,
5985
6007
  onSkip: i
5986
6008
  }) {
5987
- const c = Vr(), l = R(null), d = M(() => {
6009
+ const c = Vr(), l = O(null), d = M(() => {
5988
6010
  l.current?.click();
5989
6011
  }, []);
5990
6012
  return /* @__PURE__ */ f(
5991
6013
  "div",
5992
6014
  {
5993
- className: Ae(
6015
+ className: $e(
5994
6016
  "flex flex-col items-center gap-6 border-border border-solid bg-surface border rounded-2xl transition-all duration-[250ms] ease-[cubic-bezier(0.34,1.56,0.64,1)] hover:border-border-strong",
5995
6017
  t && "ring-2 ring-border-focus border-border-focus bg-surface-tertiary shadow-upload-active"
5996
6018
  ),
@@ -6125,11 +6147,11 @@ function $a() {
6125
6147
  ), r = y(
6126
6148
  (i) => i.batchProcessing.status
6127
6149
  ) === "complete", n = t.reduce((i, c) => {
6128
- if (c.toolName !== $e) return i;
6150
+ if (c.toolName !== Be) return i;
6129
6151
  const l = c.input;
6130
6152
  return l && typeof l == "object" && "value" in l && Array.isArray(l.value) ? i + l.value.length : i;
6131
6153
  }, 0), [o, s] = _(0);
6132
- return O(() => {
6154
+ return F(() => {
6133
6155
  if (!r || n === 0 || o >= n) return;
6134
6156
  const i = Aa(n), c = setTimeout(() => {
6135
6157
  s((l) => Math.min(l + 1, n));
@@ -6150,7 +6172,7 @@ function Ma() {
6150
6172
  ), r = y(
6151
6173
  (s) => s.incrementRevealed
6152
6174
  );
6153
- O(() => {
6175
+ F(() => {
6154
6176
  if (e >= t.length)
6155
6177
  return;
6156
6178
  const s = setTimeout(r, Ba);
@@ -6164,15 +6186,15 @@ function Ma() {
6164
6186
  };
6165
6187
  }
6166
6188
  const Zt = ["reading", "matching", "building"];
6167
- function Fa(t, e) {
6189
+ function Ra(t, e) {
6168
6190
  if (!e) return "pending";
6169
6191
  const r = Zt.indexOf(e), n = Zt.indexOf(t);
6170
6192
  return n < r ? "complete" : n === r ? "active" : "pending";
6171
6193
  }
6172
- function Oa(t, e) {
6194
+ function Fa(t, e) {
6173
6195
  return t.length >= 2 && e !== "submitted" && e !== "streaming";
6174
6196
  }
6175
- function Ra(t) {
6197
+ function Oa(t) {
6176
6198
  if (t == null) return null;
6177
6199
  const e = Et(t);
6178
6200
  return e?.data ? e.data.total ?? 0 : null;
@@ -6180,7 +6202,7 @@ function Ra(t) {
6180
6202
  const _a = {
6181
6203
  searchProductsBySku: (t, { resultCount: e }) => {
6182
6204
  const r = t.sku ?? "";
6183
- return e === null ? `Looking up SKU ${r}` : /* @__PURE__ */ f(we, { children: [
6205
+ return e === null ? `Looking up SKU ${r}` : /* @__PURE__ */ f(Pe, { children: [
6184
6206
  "Looked up SKU ",
6185
6207
  r,
6186
6208
  /* @__PURE__ */ a("br", {}),
@@ -6193,7 +6215,7 @@ const _a = {
6193
6215
  },
6194
6216
  searchProducts: (t, { resultCount: e }) => {
6195
6217
  const r = t.terms ?? "products";
6196
- return e === null ? `Searching for "${r}"` : /* @__PURE__ */ f(we, { children: [
6218
+ return e === null ? `Searching for "${r}"` : /* @__PURE__ */ f(Pe, { children: [
6197
6219
  'Searched "',
6198
6220
  r,
6199
6221
  '"',
@@ -6210,7 +6232,7 @@ function Da(t, e) {
6210
6232
  const r = _a[t.toolName];
6211
6233
  return r ? r(t.input, {
6212
6234
  visibleToolCalls: e,
6213
- resultCount: Ra(t.output)
6235
+ resultCount: Oa(t.output)
6214
6236
  }) : null;
6215
6237
  }
6216
6238
  const La = [
@@ -6238,7 +6260,7 @@ function Ua({
6238
6260
  (i) => i.parser.uploadedFileName
6239
6261
  );
6240
6262
  return /* @__PURE__ */ a("div", { className: "flex flex-col gap-6 w-64", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-6", children: La.map((i) => {
6241
- const c = Fa(i.id, t), l = i.id === "reading" && (c === "active" || c === "complete") && s ? s : null, d = i.id === "matching" && c === "active" && e ? Da(e, r) : null, h = i.id === "building" && c === "active" && o > 0 ? n >= o ? `Added ${o} item${o !== 1 ? "s" : ""}` : `Adding item ${n + 1} of ${o}...` : null;
6263
+ const c = Ra(i.id, t), l = i.id === "reading" && (c === "active" || c === "complete") && s ? s : null, d = i.id === "matching" && c === "active" && e ? Da(e, r) : null, h = i.id === "building" && c === "active" && o > 0 ? n >= o ? `Added ${o} item${o !== 1 ? "s" : ""}` : `Adding item ${n + 1} of ${o}...` : null;
6242
6264
  return /* @__PURE__ */ f(
6243
6265
  "div",
6244
6266
  {
@@ -6251,8 +6273,8 @@ function Ua({
6251
6273
  {
6252
6274
  className: `flex items-center justify-center w-8 h-8 rounded-full shrink-0 transition-all duration-300 ${er[c].icon}${c === "complete" ? " animate-step-pulse" : ""}${c === "active" ? " bg-surface-invert shadow-step" : ""}`,
6253
6275
  children: [
6254
- c === "complete" && /* @__PURE__ */ a(We, { size: 16, title: "Complete" }),
6255
- c === "active" && /* @__PURE__ */ a(De, { size: 16 }),
6276
+ c === "complete" && /* @__PURE__ */ a(ze, { size: 16, title: "Complete" }),
6277
+ c === "active" && /* @__PURE__ */ a(Le, { size: 16 }),
6256
6278
  c === "pending" && /* @__PURE__ */ a("div", { className: "w-2 h-2 rounded-full bg-border-strong" })
6257
6279
  ]
6258
6280
  }
@@ -6344,7 +6366,7 @@ function ja({
6344
6366
  }
6345
6367
  );
6346
6368
  }
6347
- function me(t) {
6369
+ function ge(t) {
6348
6370
  return {
6349
6371
  firstName: t.firstName,
6350
6372
  lastName: t.lastName,
@@ -6363,7 +6385,7 @@ function tr(t, e) {
6363
6385
  (r) => r.address1?.toLowerCase() === t.address1.toLowerCase() && r.postalCode?.toLowerCase() === t.postalCode?.toLowerCase()
6364
6386
  );
6365
6387
  }
6366
- function Qr(t, e) {
6388
+ function Gr(t, e) {
6367
6389
  return t !== void 0 && Math.abs(t - e) > 0.01;
6368
6390
  }
6369
6391
  function Va(t, e) {
@@ -6396,7 +6418,7 @@ function za(t, e) {
6396
6418
  for (const n of t.lineItems.physicalItems) {
6397
6419
  const o = e.find(
6398
6420
  (l) => l.productEntityId === n.productEntityId && l.variantEntityId === n.variantEntityId
6399
- ), s = o?.poPriceValue, i = n.listPrice.value, c = Qr(s, i);
6421
+ ), s = o?.poPriceValue, i = n.listPrice.value, c = Gr(s, i);
6400
6422
  r.push({
6401
6423
  id: n.entityId,
6402
6424
  sku: n.sku,
@@ -6427,8 +6449,8 @@ function Ha(t, e) {
6427
6449
  )
6428
6450
  );
6429
6451
  }
6430
- function Qa(t) {
6431
- const { client: e, onError: r } = t, n = R(e), o = R(r);
6452
+ function Ga(t) {
6453
+ const { client: e, onError: r } = t, n = O(e), o = O(r);
6432
6454
  o.current = r;
6433
6455
  const s = y((C) => C.bcSession.bcCart), i = y((C) => C.bcSession.checkout), c = y(
6434
6456
  (C) => C.customer.customerInfo
@@ -6438,7 +6460,7 @@ function Qa(t) {
6438
6460
  (C) => C.ui.selectedAddressId
6439
6461
  ), h = y(
6440
6462
  (C) => C.ui.addressUpdateStatus
6441
- ), u = y((C) => C.bcSession.isLoading), p = y(
6463
+ ), p = y((C) => C.bcSession.isLoading), u = y(
6442
6464
  (C) => C.bcSession.productCache
6443
6465
  ), g = y(
6444
6466
  (C) => C.cartifact.poItemPrices
@@ -6458,9 +6480,9 @@ function Qa(t) {
6458
6480
  (C) => C.setSelectedBillingAddressId
6459
6481
  ), z = y(
6460
6482
  (C) => C.setBillingAddressUpdateStatus
6461
- ), re = y(
6483
+ ), K = y(
6462
6484
  (C) => C.setItemWarnings
6463
- ), j = te(() => s ? s.lineItems.physicalItems.map((C) => {
6485
+ ), q = re(() => s ? s.lineItems.physicalItems.map((C) => {
6464
6486
  const N = `${C.productEntityId}-${C.variantEntityId}`, P = g[N];
6465
6487
  return {
6466
6488
  productEntityId: C.productEntityId,
@@ -6469,7 +6491,7 @@ function Qa(t) {
6469
6491
  poPriceValue: P?.poPrice,
6470
6492
  poPriceCurrencyCode: P?.poCurrency
6471
6493
  };
6472
- }) : [], [s, g]), J = R(/* @__PURE__ */ new Set()), ne = M(
6494
+ }) : [], [s, g]), Y = O(/* @__PURE__ */ new Set()), J = M(
6473
6495
  async (C, N) => {
6474
6496
  if (!n.current)
6475
6497
  return;
@@ -6497,7 +6519,7 @@ function Qa(t) {
6497
6519
  }
6498
6520
  },
6499
6521
  [m]
6500
- ), ie = M(
6522
+ ), le = M(
6501
6523
  async (C, N) => {
6502
6524
  if (n.current)
6503
6525
  try {
@@ -6514,18 +6536,18 @@ function Qa(t) {
6514
6536
  },
6515
6537
  [m]
6516
6538
  );
6517
- O(() => {
6539
+ F(() => {
6518
6540
  if (!s || !n.current) return;
6519
6541
  const N = [
6520
6542
  ...new Set(
6521
6543
  s.lineItems.physicalItems.map((P) => P.productEntityId)
6522
6544
  )
6523
6545
  ].filter(
6524
- (P) => !p[P] && !J.current.has(P)
6546
+ (P) => !u[P] && !Y.current.has(P)
6525
6547
  );
6526
6548
  if (N.length !== 0) {
6527
6549
  for (const P of N)
6528
- J.current.add(P);
6550
+ Y.current.add(P);
6529
6551
  n.current.getProductDisplayData(N).then((P) => {
6530
6552
  P.length > 0 && T(P);
6531
6553
  }).catch((P) => {
@@ -6535,23 +6557,23 @@ function Qa(t) {
6535
6557
  );
6536
6558
  }).finally(() => {
6537
6559
  for (const P of N)
6538
- J.current.delete(P);
6560
+ Y.current.delete(P);
6539
6561
  });
6540
6562
  }
6541
- }, [s, p, T]);
6542
- const X = R(!1), se = R(!1);
6543
- O(() => {
6563
+ }, [s, u, T]);
6564
+ const X = O(!1), Z = O(!1);
6565
+ F(() => {
6544
6566
  if (d)
6545
6567
  return;
6546
6568
  if (!E) {
6547
6569
  if (l.length === 0)
6548
- b(ue);
6570
+ b(pe);
6549
6571
  else {
6550
6572
  const N = l.find(
6551
6573
  (A) => A.isDefaultShipping
6552
6574
  ), P = l.find((A) => A.isShipping);
6553
6575
  b(
6554
- N?.id ?? P?.id ?? ue
6576
+ N?.id ?? P?.id ?? pe
6555
6577
  );
6556
6578
  }
6557
6579
  return;
@@ -6562,30 +6584,30 @@ function Qa(t) {
6562
6584
  E,
6563
6585
  l
6564
6586
  );
6565
- C = N ? N.id : ve;
6587
+ C = N ? N.id : Ie;
6566
6588
  } else
6567
- C = ve;
6589
+ C = Ie;
6568
6590
  X.current = !1, b(C);
6569
6591
  }, [
6570
6592
  l,
6571
6593
  E,
6572
6594
  b,
6573
6595
  d
6574
- ]), O(() => {
6575
- if (X.current || !s || !d || d === ue)
6596
+ ]), F(() => {
6597
+ if (X.current || !s || !d || d === pe)
6576
6598
  return;
6577
6599
  let C;
6578
- d === ve ? C = E ?? void 0 : C = l.find((N) => N.id === d) ?? void 0, C && (X.current = !0, ne(
6600
+ d === Ie ? C = E ?? void 0 : C = l.find((N) => N.id === d) ?? void 0, C && (X.current = !0, J(
6579
6601
  s,
6580
- me(C)
6602
+ ge(C)
6581
6603
  ));
6582
6604
  }, [
6583
6605
  s,
6584
6606
  d,
6585
6607
  l,
6586
6608
  E,
6587
- ne
6588
- ]), O(() => {
6609
+ J
6610
+ ]), F(() => {
6589
6611
  if (!I || S)
6590
6612
  return;
6591
6613
  let C;
@@ -6597,36 +6619,36 @@ function Qa(t) {
6597
6619
  C = N ? N.id : Ne;
6598
6620
  } else
6599
6621
  C = Ne;
6600
- se.current = !1, $(C);
6622
+ Z.current = !1, $(C);
6601
6623
  }, [
6602
6624
  l,
6603
6625
  I,
6604
6626
  $,
6605
6627
  S
6606
- ]), O(() => {
6607
- if (se.current || !s || !S || S === ue)
6628
+ ]), F(() => {
6629
+ if (Z.current || !s || !S || S === pe)
6608
6630
  return;
6609
6631
  let C;
6610
- S === Ne ? C = I ?? void 0 : C = l.find((N) => N.id === S) ?? void 0, C && (se.current = !0, ie(
6632
+ S === Ne ? C = I ?? void 0 : C = l.find((N) => N.id === S) ?? void 0, C && (Z.current = !0, le(
6611
6633
  s,
6612
- me(C)
6634
+ ge(C)
6613
6635
  ));
6614
6636
  }, [
6615
6637
  s,
6616
6638
  S,
6617
6639
  l,
6618
6640
  I,
6619
- ie
6641
+ le
6620
6642
  ]);
6621
- const H = R(void 0), q = R(void 0), le = te(() => s ? s.lineItems.physicalItems.map((C) => {
6622
- const N = j.find(
6623
- (D) => D.productEntityId === C.productEntityId && D.variantEntityId === C.variantEntityId
6624
- ), P = N?.poPriceValue, A = C.listPrice.value, F = Qr(P, A), U = p[C.productEntityId];
6643
+ const H = O(void 0), j = O(void 0), ie = re(() => s ? s.lineItems.physicalItems.map((C) => {
6644
+ const N = q.find(
6645
+ (U) => U.productEntityId === C.productEntityId && U.variantEntityId === C.variantEntityId
6646
+ ), P = N?.poPriceValue, A = C.listPrice.value, R = Gr(P, A), L = u[C.productEntityId];
6625
6647
  return {
6626
6648
  id: C.entityId,
6627
6649
  sku: C.sku ?? "",
6628
6650
  name: C.name,
6629
- path: U?.path,
6651
+ path: L?.path,
6630
6652
  price: A,
6631
6653
  imageUrl: C.imageUrl ?? void 0,
6632
6654
  productEntityId: C.productEntityId,
@@ -6636,9 +6658,9 @@ function Qa(t) {
6636
6658
  poPriceValue: P,
6637
6659
  poPriceCurrencyCode: N?.poPriceCurrencyCode,
6638
6660
  catalogPriceCurrencyCode: C.listPrice.currencyCode,
6639
- status: F ? "price-mismatch" : "matched"
6661
+ status: R ? "price-mismatch" : "matched"
6640
6662
  };
6641
- }) : [], [s, j, p]), ke = te(
6663
+ }) : [], [s, q, u]), ye = re(
6642
6664
  () => ({
6643
6665
  subtotal: s?.amount?.value ?? 0,
6644
6666
  tax: i?.taxTotal?.value ?? null,
@@ -6646,180 +6668,180 @@ function Qa(t) {
6646
6668
  grandTotal: i?.grandTotal?.value ?? null
6647
6669
  }),
6648
6670
  [s, i]
6649
- ), L = M(
6671
+ ), se = M(
6650
6672
  async (C) => {
6651
- if (!n.current || !C || !d || d === ue || C.lineItems.physicalItems.length === 0)
6673
+ if (!n.current || !C || !d || d === pe || C.lineItems.physicalItems.length === 0)
6652
6674
  return;
6653
6675
  let N = null;
6654
- if (d === ve)
6655
- E && (N = me(E));
6676
+ if (d === Ie)
6677
+ E && (N = ge(E));
6656
6678
  else {
6657
6679
  const P = l.find(
6658
6680
  (A) => A.id === d
6659
6681
  );
6660
- P && (N = me(P));
6682
+ P && (N = ge(P));
6661
6683
  }
6662
- N && await ne(C, N);
6684
+ N && await J(C, N);
6663
6685
  },
6664
6686
  [
6665
6687
  d,
6666
6688
  l,
6667
6689
  E,
6668
- ne
6690
+ J
6669
6691
  ]
6670
- ), W = M(
6692
+ ), D = M(
6671
6693
  async (C) => {
6672
6694
  if (!n.current) return { cart: null, cartItems: [], errors: [] };
6673
6695
  if (C.length === 0)
6674
6696
  return { cart: s, cartItems: [], errors: [] };
6675
6697
  k(!0);
6676
6698
  try {
6677
- const N = Va(j, C), P = await n.current.getCart();
6699
+ const N = Va(q, C), P = await n.current.getCart();
6678
6700
  let A = null;
6679
- const F = [];
6701
+ const R = [];
6680
6702
  if (P) {
6681
- const { toAdd: Q, toUpdate: de } = Wa(
6703
+ const { toAdd: G, toUpdate: he } = Wa(
6682
6704
  P.lineItems.physicalItems,
6683
6705
  C
6684
6706
  );
6685
- if (A = P, Q.length > 0) {
6686
- const Y = Q.map((xe) => ({
6687
- productEntityId: xe.productEntityId,
6688
- variantEntityId: xe.variantEntityId,
6689
- quantity: xe.quantity
6690
- })), { cart: Z, errors: pe } = await n.current.addCartLineItems(
6707
+ if (A = P, G.length > 0) {
6708
+ const Q = G.map((be) => ({
6709
+ productEntityId: be.productEntityId,
6710
+ variantEntityId: be.variantEntityId,
6711
+ quantity: be.quantity
6712
+ })), { cart: ee, errors: fe } = await n.current.addCartLineItems(
6691
6713
  P.entityId,
6692
- Y
6714
+ Q
6693
6715
  );
6694
- Z && (A = Z), F.push(...pe);
6716
+ ee && (A = ee), R.push(...fe);
6695
6717
  }
6696
- for (const Y of de)
6718
+ for (const Q of he)
6697
6719
  A = await n.current.updateCartLineItem(
6698
6720
  P.entityId,
6699
- Y.lineItemEntityId,
6700
- Y.newQuantity,
6701
- Y.productEntityId,
6702
- Y.variantEntityId
6721
+ Q.lineItemEntityId,
6722
+ Q.newQuantity,
6723
+ Q.productEntityId,
6724
+ Q.variantEntityId
6703
6725
  ) ?? A;
6704
- (Q.length > 0 || de.length > 0) && await L(A);
6726
+ (G.length > 0 || he.length > 0) && await se(A);
6705
6727
  } else {
6706
- const Q = C.map((Z) => ({
6707
- productEntityId: Z.productEntityId,
6708
- variantEntityId: Z.variantEntityId,
6709
- quantity: Z.quantity
6710
- })), { cart: de, errors: Y } = await n.current.createCart(Q);
6711
- if (A = de, F.push(...Y), A) {
6712
- const Z = y.getState().chat.threadId;
6713
- Z && n.current.createCartMetafield(A.entityId, "thread_id", Z).catch((pe) => {
6728
+ const G = C.map((ee) => ({
6729
+ productEntityId: ee.productEntityId,
6730
+ variantEntityId: ee.variantEntityId,
6731
+ quantity: ee.quantity
6732
+ })), { cart: he, errors: Q } = await n.current.createCart(G);
6733
+ if (A = he, R.push(...Q), A) {
6734
+ const ee = y.getState().chat.threadId;
6735
+ ee && n.current.createCartMetafield(A.entityId, "thread_id", ee).catch((fe) => {
6714
6736
  console.warn(
6715
6737
  "[useBigCommerceCart] Failed to set thread_id metafield:",
6716
- pe
6738
+ fe
6717
6739
  );
6718
6740
  });
6719
6741
  }
6720
6742
  }
6721
6743
  x(A);
6722
- const U = y.getState();
6723
- U.setCartEntityId(A?.entityId ?? null);
6724
- for (const Q of N)
6725
- Q.poPriceValue !== void 0 && Q.poPriceCurrencyCode !== void 0 && U.setPoItemPrice(
6726
- Q.productEntityId,
6727
- Q.variantEntityId,
6728
- Q.poPriceValue,
6729
- Q.poPriceCurrencyCode
6744
+ const L = y.getState();
6745
+ L.setCartEntityId(A?.entityId ?? null);
6746
+ for (const G of N)
6747
+ G.poPriceValue !== void 0 && G.poPriceCurrencyCode !== void 0 && L.setPoItemPrice(
6748
+ G.productEntityId,
6749
+ G.variantEntityId,
6750
+ G.poPriceValue,
6751
+ G.poPriceCurrencyCode
6730
6752
  );
6731
6753
  if (A) {
6732
- const Q = new Set(
6754
+ const G = new Set(
6733
6755
  A.lineItems.physicalItems.map(
6734
- (Y) => `${Y.productEntityId}-${Y.variantEntityId}`
6756
+ (Q) => `${Q.productEntityId}-${Q.variantEntityId}`
6735
6757
  )
6736
- ), de = Object.keys(U.cartifact.poItemPrices);
6737
- for (const Y of de)
6738
- if (!Q.has(Y)) {
6739
- const Z = Y.split("-"), pe = Number(Z[0]), xe = Number(Z[1]);
6740
- !Number.isNaN(pe) && !Number.isNaN(xe) && U.removePoItemPrice(pe, xe);
6758
+ ), he = Object.keys(L.cartifact.poItemPrices);
6759
+ for (const Q of he)
6760
+ if (!G.has(Q)) {
6761
+ const ee = Q.split("-"), fe = Number(ee[0]), be = Number(ee[1]);
6762
+ !Number.isNaN(fe) && !Number.isNaN(be) && L.removePoItemPrice(fe, be);
6741
6763
  }
6742
6764
  }
6743
6765
  if (A && !P && d) {
6744
- const Q = l.find(
6745
- (de) => de.id === d
6766
+ const G = l.find(
6767
+ (he) => he.id === d
6746
6768
  );
6747
- Q && A.lineItems.physicalItems.length > 0 && (X.current = !0, await ne(
6769
+ G && A.lineItems.physicalItems.length > 0 && (X.current = !0, await J(
6748
6770
  A,
6749
- me(Q)
6771
+ ge(G)
6750
6772
  ));
6751
6773
  }
6752
6774
  if (!A)
6753
- return { cart: null, cartItems: [], errors: F };
6754
- const { cartItems: D } = za(
6775
+ return { cart: null, cartItems: [], errors: R };
6776
+ const { cartItems: U } = za(
6755
6777
  A,
6756
6778
  N
6757
- ), ze = y.getState().cartifact.itemWarnings, Le = Ha(
6758
- ze,
6759
- D
6779
+ ), ke = y.getState().cartifact.itemWarnings, Ue = Ha(
6780
+ ke,
6781
+ U
6760
6782
  );
6761
- return Le.length !== ze.length && re(Le), { cart: A, cartItems: D, errors: F };
6783
+ return Ue.length !== ke.length && K(Ue), { cart: A, cartItems: U, errors: R };
6762
6784
  } finally {
6763
6785
  k(!1);
6764
6786
  }
6765
6787
  },
6766
6788
  [
6767
6789
  s,
6768
- j,
6790
+ q,
6769
6791
  d,
6770
6792
  l,
6771
- L,
6793
+ se,
6772
6794
  x,
6773
6795
  k,
6774
- re,
6775
- ne
6796
+ K,
6797
+ J
6776
6798
  ]
6777
- ), G = M(
6799
+ ), ne = M(
6778
6800
  async (C) => {
6779
6801
  if (!n.current) return { errors: [] };
6780
6802
  const N = [];
6781
- for (const F of C) {
6782
- const U = N.findIndex(
6783
- (D) => D.productEntityId === F.productEntityId && D.variantEntityId === F.variantEntityId
6803
+ for (const R of C) {
6804
+ const L = N.findIndex(
6805
+ (U) => U.productEntityId === R.productEntityId && U.variantEntityId === R.variantEntityId
6784
6806
  );
6785
- if (U >= 0) {
6786
- const D = N[U];
6787
- D && (D.quantity += F.quantity, F.poPriceValue !== void 0 && F.poPriceCurrencyCode !== void 0 && (D.poPriceValue = F.poPriceValue, D.poPriceCurrencyCode = F.poPriceCurrencyCode));
6807
+ if (L >= 0) {
6808
+ const U = N[L];
6809
+ U && (U.quantity += R.quantity, R.poPriceValue !== void 0 && R.poPriceCurrencyCode !== void 0 && (U.poPriceValue = R.poPriceValue, U.poPriceCurrencyCode = R.poPriceCurrencyCode));
6788
6810
  } else
6789
- N.push({ ...F });
6811
+ N.push({ ...R });
6790
6812
  }
6791
- const P = [...j];
6792
- for (const F of N) {
6793
- const U = P.findIndex(
6794
- (D) => D.productEntityId === F.productEntityId && D.variantEntityId === F.variantEntityId
6813
+ const P = [...q];
6814
+ for (const R of N) {
6815
+ const L = P.findIndex(
6816
+ (U) => U.productEntityId === R.productEntityId && U.variantEntityId === R.variantEntityId
6795
6817
  );
6796
- if (U >= 0) {
6797
- const D = P[U];
6798
- D && (D.quantity += F.quantity, F.poPriceValue !== void 0 && F.poPriceCurrencyCode !== void 0 && (D.poPriceValue = F.poPriceValue, D.poPriceCurrencyCode = F.poPriceCurrencyCode));
6818
+ if (L >= 0) {
6819
+ const U = P[L];
6820
+ U && (U.quantity += R.quantity, R.poPriceValue !== void 0 && R.poPriceCurrencyCode !== void 0 && (U.poPriceValue = R.poPriceValue, U.poPriceCurrencyCode = R.poPriceCurrencyCode));
6799
6821
  } else
6800
- P.push(F);
6822
+ P.push(R);
6801
6823
  }
6802
- const { errors: A } = await W(P);
6824
+ const { errors: A } = await D(P);
6803
6825
  return { errors: A };
6804
6826
  },
6805
- [W, j]
6806
- ), K = M(
6827
+ [D, q]
6828
+ ), W = M(
6807
6829
  async (C, N, P, A) => {
6808
6830
  if (!n.current || !s?.entityId)
6809
6831
  return null;
6810
6832
  k(!0);
6811
6833
  try {
6812
- const F = await n.current.updateCartLineItem(
6834
+ const R = await n.current.updateCartLineItem(
6813
6835
  s.entityId,
6814
6836
  C,
6815
6837
  N,
6816
6838
  P,
6817
6839
  A
6818
6840
  );
6819
- return F && (x(F), await L(F)), F;
6820
- } catch (F) {
6841
+ return R && (x(R), await se(R)), R;
6842
+ } catch (R) {
6821
6843
  return o.current?.(
6822
- F instanceof Error ? F : new Error("Failed to update quantity")
6844
+ R instanceof Error ? R : new Error("Failed to update quantity")
6823
6845
  ), null;
6824
6846
  } finally {
6825
6847
  k(!1);
@@ -6827,11 +6849,11 @@ function Qa(t) {
6827
6849
  },
6828
6850
  [
6829
6851
  s?.entityId,
6830
- L,
6852
+ se,
6831
6853
  x,
6832
6854
  k
6833
6855
  ]
6834
- ), Be = M(
6856
+ ), de = M(
6835
6857
  async (C) => {
6836
6858
  if (!n.current || !s?.entityId)
6837
6859
  return null;
@@ -6844,17 +6866,17 @@ function Qa(t) {
6844
6866
  x(N);
6845
6867
  const P = y.getState();
6846
6868
  if (N) {
6847
- const A = N.lineItems.physicalItems, F = j.filter(
6848
- (U) => !A.some(
6849
- (D) => D.productEntityId === U.productEntityId && D.variantEntityId === U.variantEntityId
6869
+ const A = N.lineItems.physicalItems, R = q.filter(
6870
+ (L) => !A.some(
6871
+ (U) => U.productEntityId === L.productEntityId && U.variantEntityId === L.variantEntityId
6850
6872
  )
6851
6873
  );
6852
- for (const U of F)
6874
+ for (const L of R)
6853
6875
  P.removePoItemPrice(
6854
- U.productEntityId,
6855
- U.variantEntityId
6876
+ L.productEntityId,
6877
+ L.variantEntityId
6856
6878
  );
6857
- await L(N);
6879
+ await se(N);
6858
6880
  } else
6859
6881
  P.setCartEntityId(null), P.clearPoItemPrices(), m(null);
6860
6882
  return N;
@@ -6868,18 +6890,18 @@ function Qa(t) {
6868
6890
  },
6869
6891
  [
6870
6892
  s?.entityId,
6871
- L,
6893
+ se,
6872
6894
  x,
6873
6895
  k,
6874
6896
  m,
6875
- j
6897
+ q
6876
6898
  ]
6877
- ), ge = M(async () => {
6899
+ ), Ce = M(async () => {
6878
6900
  if (!n.current)
6879
6901
  return console.error("initiateCheckout: No BigCommerce client"), null;
6880
6902
  if (!s?.entityId)
6881
6903
  return console.error("initiateCheckout: No cart entity ID", { bcCart: s }), null;
6882
- const C = Ie({
6904
+ const C = we({
6883
6905
  name: "initiate-checkout",
6884
6906
  op: "purchase-order.checkout",
6885
6907
  attributes: {
@@ -6920,9 +6942,9 @@ function Qa(t) {
6920
6942
  ), k(!1), null;
6921
6943
  }
6922
6944
  });
6923
- }, [s, i, d, S, k]), ye = M(
6945
+ }, [s, i, d, S, k]), Me = M(
6924
6946
  async (C) => {
6925
- if (C === ue) {
6947
+ if (C === pe) {
6926
6948
  b(C);
6927
6949
  return;
6928
6950
  }
@@ -6935,11 +6957,11 @@ function Qa(t) {
6935
6957
  return;
6936
6958
  }
6937
6959
  let N = null;
6938
- if (C === ve)
6939
- E && (N = me(E));
6960
+ if (C === Ie)
6961
+ E && (N = ge(E));
6940
6962
  else {
6941
- const A = l.find((F) => F.id === C);
6942
- A && (N = me(A));
6963
+ const A = l.find((R) => R.id === C);
6964
+ A && (N = ge(A));
6943
6965
  }
6944
6966
  if (!N) {
6945
6967
  console.error(
@@ -6985,9 +7007,9 @@ function Qa(t) {
6985
7007
  m,
6986
7008
  b
6987
7009
  ]
6988
- ), he = M(
7010
+ ), ue = M(
6989
7011
  async (C) => {
6990
- if (C === ue) {
7012
+ if (C === pe) {
6991
7013
  $(C);
6992
7014
  return;
6993
7015
  }
@@ -6995,26 +7017,26 @@ function Qa(t) {
6995
7017
  return;
6996
7018
  let N = null;
6997
7019
  if (C === Ne)
6998
- I && (N = me(I));
7020
+ I && (N = ge(I));
6999
7021
  else {
7000
7022
  const P = l.find((A) => A.id === C);
7001
- P && (N = me(P));
7023
+ P && (N = ge(P));
7002
7024
  }
7003
7025
  if (N) {
7004
- se.current = !0, k(!0), z("updating");
7026
+ Z.current = !0, k(!0), z("updating");
7005
7027
  try {
7006
7028
  const P = await n.current.setCheckoutBillingAddress(
7007
7029
  s.entityId,
7008
7030
  N
7009
7031
  );
7010
- P && m(P), $(C), z("success"), q.current !== void 0 && clearTimeout(q.current), q.current = window.setTimeout(() => {
7011
- z("idle"), q.current = void 0;
7032
+ P && m(P), $(C), z("success"), j.current !== void 0 && clearTimeout(j.current), j.current = window.setTimeout(() => {
7033
+ z("idle"), j.current = void 0;
7012
7034
  }, 1500);
7013
7035
  } catch (P) {
7014
7036
  z("error"), o.current?.(
7015
7037
  P instanceof Error ? P : new Error("Failed to set billing address")
7016
- ), q.current !== void 0 && clearTimeout(q.current), q.current = window.setTimeout(() => {
7017
- z("idle"), q.current = void 0;
7038
+ ), j.current !== void 0 && clearTimeout(j.current), j.current = window.setTimeout(() => {
7039
+ z("idle"), j.current = void 0;
7018
7040
  }, 3e3);
7019
7041
  } finally {
7020
7042
  k(!1);
@@ -7030,13 +7052,13 @@ function Qa(t) {
7030
7052
  m,
7031
7053
  $
7032
7054
  ]
7033
- ), Ce = M(async () => {
7055
+ ), xe = M(async () => {
7034
7056
  if (n.current && s?.entityId)
7035
7057
  try {
7036
7058
  await n.current.deleteCart(s.entityId);
7037
7059
  } catch {
7038
7060
  }
7039
- H.current !== void 0 && (clearTimeout(H.current), H.current = void 0), q.current !== void 0 && (clearTimeout(q.current), q.current = void 0), x(null), m(null);
7061
+ H.current !== void 0 && (clearTimeout(H.current), H.current = void 0), j.current !== void 0 && (clearTimeout(j.current), j.current = void 0), x(null), m(null);
7040
7062
  const C = y.getState();
7041
7063
  C.setCartEntityId(null), C.clearPoItemPrices();
7042
7064
  }, [s?.entityId, x, m]);
@@ -7049,21 +7071,21 @@ function Qa(t) {
7049
7071
  addressUpdateStatus: h,
7050
7072
  selectedBillingAddressId: S,
7051
7073
  billingAddressUpdateStatus: B,
7052
- isLoading: u,
7053
- checkoutTotals: ke,
7054
- cartItems: le,
7055
- addToCart: G,
7056
- updateLineItemQuantity: K,
7057
- removeLineItem: Be,
7058
- initiateCheckout: ge,
7059
- setShippingAddressOnCheckout: ye,
7060
- setBillingAddressOnCheckout: he,
7061
- clearCart: Ce,
7074
+ isLoading: p,
7075
+ checkoutTotals: ye,
7076
+ cartItems: ie,
7077
+ addToCart: ne,
7078
+ updateLineItemQuantity: W,
7079
+ removeLineItem: de,
7080
+ initiateCheckout: Ce,
7081
+ setShippingAddressOnCheckout: Me,
7082
+ setBillingAddressOnCheckout: ue,
7083
+ clearCart: xe,
7062
7084
  setSelectedAddressId: b,
7063
7085
  setSelectedBillingAddressId: $
7064
7086
  };
7065
7087
  }
7066
- function Ga({
7088
+ function Qa({
7067
7089
  bcCart: t,
7068
7090
  cartItems: e,
7069
7091
  onCheckoutInitiated: r,
@@ -7078,17 +7100,17 @@ function Ga({
7078
7100
  if (u?.redirectedCheckoutUrl)
7079
7101
  r?.(), n ? await n(u.redirectedCheckoutUrl) : window.location.href = u.redirectedCheckoutUrl;
7080
7102
  else {
7081
- const p = new Error("Failed to get checkout redirect URL");
7082
- console.error(p.message, { redirectUrls: u, bcCart: t.bcCart }), r?.(p);
7103
+ const g = new Error("Failed to get checkout redirect URL");
7104
+ console.error(g.message, { redirectUrls: u, bcCart: t.bcCart }), r?.(g);
7083
7105
  }
7084
7106
  }, [t, r, n]), i = M(
7085
- async (u, p) => {
7086
- const g = e.find((x) => x.id === u);
7087
- !g?.productEntityId || !g?.variantEntityId || await t.updateLineItemQuantity(
7107
+ async (u, g) => {
7108
+ const x = e.find((m) => m.id === u);
7109
+ !x?.productEntityId || !x?.variantEntityId || await t.updateLineItemQuantity(
7088
7110
  u,
7089
- p,
7090
- g.productEntityId,
7091
- g.variantEntityId
7111
+ g,
7112
+ x.productEntityId,
7113
+ x.variantEntityId
7092
7114
  );
7093
7115
  },
7094
7116
  [e, t]
@@ -7098,39 +7120,42 @@ function Ga({
7098
7120
  },
7099
7121
  [t]
7100
7122
  ), l = M(
7101
- async (u, p, g) => {
7102
- const { productEntityId: x } = u, m = g ?? u.variantEntityId;
7103
- if (!x || !m)
7123
+ async (u, g, x) => {
7124
+ const { productEntityId: m } = u, b = x ?? u.variantEntityId;
7125
+ if (!m || !b)
7104
7126
  return console.error("Cannot add to cart: missing entity IDs", u), !1;
7105
- const b = u.availableQuantity !== void 0 && u.availableQuantity > 0 ? Math.min(p, u.availableQuantity) : p;
7127
+ const v = u.availableQuantity !== void 0 && u.availableQuantity > 0 ? Math.min(g, u.availableQuantity) : g;
7106
7128
  try {
7107
7129
  return await t.addToCart([
7108
7130
  {
7109
- productEntityId: x,
7110
- variantEntityId: m,
7111
- quantity: b
7131
+ productEntityId: m,
7132
+ variantEntityId: b,
7133
+ quantity: v
7112
7134
  }
7113
7135
  ]), !0;
7114
- } catch (v) {
7115
- return console.error("Failed to add to cart:", v), !1;
7136
+ } catch (k) {
7137
+ return console.error("Failed to add to cart:", k), !1;
7116
7138
  }
7117
7139
  },
7118
7140
  [t]
7119
7141
  ), d = M(
7120
- (u, p) => {
7121
- const g = p ? `Suggest alternatives for "${u}" (SKU: ${p})` : `Suggest alternatives for "${u}"`;
7122
- o(g);
7142
+ (u, g) => {
7143
+ const x = g ? `Suggest alternatives for "${u}" (SKU: ${g})` : `Suggest alternatives for "${u}"`;
7144
+ o(x);
7123
7145
  },
7124
7146
  [o]
7125
7147
  ), h = M(
7126
- (u, p) => {
7127
- const g = p ? `Show more products like "${u}" (SKU: ${p})` : `Show more products like "${u}"`;
7128
- o(g);
7148
+ (u, g) => {
7149
+ const x = g ? `Show more products like "${u}" (SKU: ${g})` : `Show more products like "${u}"`;
7150
+ o(x);
7129
7151
  },
7130
7152
  [o]
7131
- );
7153
+ ), p = M(() => {
7154
+ window.location.href = "/cart.php";
7155
+ }, []);
7132
7156
  return {
7133
7157
  handleCheckout: s,
7158
+ handleReviewCart: p,
7134
7159
  handleUpdateQuantity: i,
7135
7160
  handleRemoveItem: c,
7136
7161
  handleAddToCartFromSuggestion: l,
@@ -7154,7 +7179,7 @@ function Ya(t) {
7154
7179
  `) : Ka;
7155
7180
  }
7156
7181
  const gt = /* @__PURE__ */ new Set([
7157
- $e,
7182
+ Be,
7158
7183
  st,
7159
7184
  at,
7160
7185
  ot
@@ -7173,10 +7198,10 @@ async function Za(t, e, r, n, o, s) {
7173
7198
  parts: [{ type: "text", text: n }]
7174
7199
  }
7175
7200
  ];
7176
- const u = 20;
7177
- let p = 0;
7178
- for (; p < u; ) {
7179
- p++;
7201
+ const p = 20;
7202
+ let u = 0;
7203
+ for (; u < p; ) {
7204
+ u++;
7180
7205
  const E = await jr(
7181
7206
  t,
7182
7207
  e,
@@ -7245,17 +7270,17 @@ async function Za(t, e, r, n, o, s) {
7245
7270
  },
7246
7271
  {
7247
7272
  role: "user",
7248
- parts: [{ type: "text", text: je }]
7273
+ parts: [{ type: "text", text: Ve }]
7249
7274
  }
7250
7275
  ];
7251
7276
  }
7252
- p >= u && s?.logger?.debug(
7253
- `Batch ${o}: WARNING - Hit max iterations limit (${u})`
7277
+ u >= p && s?.logger?.debug(
7278
+ `Batch ${o}: WARNING - Hit max iterations limit (${p})`
7254
7279
  );
7255
7280
  const g = l.length > 0 ? l.join(`
7256
7281
 
7257
7282
  `) : c.join(""), x = Xa(i), m = g + x, v = d.filter(
7258
- (E) => E.toolName === $e
7283
+ (E) => E.toolName === Be
7259
7284
  ).reduce((E, I) => {
7260
7285
  const S = I.input?.value;
7261
7286
  return E + (S?.length ?? 0);
@@ -7266,7 +7291,7 @@ async function Za(t, e, r, n, o, s) {
7266
7291
  return E + (S?.length ?? 0);
7267
7292
  }, 0);
7268
7293
  return s?.logger?.debug(
7269
- `Batch ${o}: ${p} iteration(s), ${d.length} client tool call(s), ${v} addToCart item(s), ${T} failure(s)`
7294
+ `Batch ${o}: ${u} iteration(s), ${d.length} client tool call(s), ${v} addToCart item(s), ${T} failure(s)`
7270
7295
  ), m && s?.logger?.debug(`Batch ${o} output: ${m}`), {
7271
7296
  batchIndex: o,
7272
7297
  threadId: r,
@@ -7302,7 +7327,7 @@ async function eo(t, e, r, n) {
7302
7327
  error: "Failed to create thread"
7303
7328
  };
7304
7329
  try {
7305
- const u = await Za(
7330
+ const p = await Za(
7306
7331
  t,
7307
7332
  e,
7308
7333
  h,
@@ -7310,16 +7335,16 @@ async function eo(t, e, r, n) {
7310
7335
  d,
7311
7336
  n
7312
7337
  );
7313
- return n?.onBatchComplete?.(u), u;
7314
- } catch (u) {
7315
- const p = u instanceof Error ? u.message : "Unknown error";
7316
- return n?.onError?.(d, p), {
7338
+ return n?.onBatchComplete?.(p), p;
7339
+ } catch (p) {
7340
+ const u = p instanceof Error ? p.message : "Unknown error";
7341
+ return n?.onError?.(d, u), {
7317
7342
  batchIndex: d,
7318
7343
  threadId: h,
7319
7344
  output: "",
7320
7345
  toolCalls: [],
7321
7346
  pendingClientToolCalls: [],
7322
- error: p
7347
+ error: u
7323
7348
  };
7324
7349
  }
7325
7350
  },
@@ -7340,7 +7365,7 @@ function to(t) {
7340
7365
  continue;
7341
7366
  }
7342
7367
  for (const i of s.pendingClientToolCalls)
7343
- if (i.toolName === $e) {
7368
+ if (i.toolName === Be) {
7344
7369
  const c = i.input;
7345
7370
  c.value && e.push(...c.value);
7346
7371
  } else if (i.toolName === at)
@@ -7462,7 +7487,7 @@ function oo(t) {
7462
7487
  async (l) => {
7463
7488
  if (l.length === 0)
7464
7489
  return { results: [], processingFailuresString: "", hasErrors: !1 };
7465
- const d = bt(), h = Ie({
7490
+ const d = bt(), h = we({
7466
7491
  name: "batch-processing",
7467
7492
  op: "ai.batch",
7468
7493
  attributes: { "batch.count": l.length },
@@ -7472,17 +7497,17 @@ function oo(t) {
7472
7497
  try {
7473
7498
  return await Oe(h, async () => {
7474
7499
  n("processing"), o(null);
7475
- const p = await ao({
7500
+ const u = await ao({
7476
7501
  takeshapeConfig: r,
7477
7502
  agentName: "batchProcessor",
7478
7503
  bcCart: e
7479
7504
  }, l);
7480
7505
  if (s(
7481
- p.results,
7482
- p.processingFailuresString
7483
- ), p.hasErrors) {
7506
+ u.results,
7507
+ u.processingFailuresString
7508
+ ), u.hasErrors) {
7484
7509
  n("error");
7485
- const g = p.results.filter(
7510
+ const g = u.results.filter(
7486
7511
  (x) => x.error
7487
7512
  ).length;
7488
7513
  o(
@@ -7490,11 +7515,11 @@ function oo(t) {
7490
7515
  ), h.setStatus({ code: 2, message: "batch_errors" });
7491
7516
  } else
7492
7517
  n("complete"), h.setStatus({ code: 1, message: "ok" });
7493
- return p;
7518
+ return u;
7494
7519
  });
7495
- } catch (u) {
7496
- const p = u instanceof Error ? u.message : "Unknown error";
7497
- throw o(p), n("error"), h.setStatus({ code: 2, message: p }), u;
7520
+ } catch (p) {
7521
+ const u = p instanceof Error ? p.message : "Unknown error";
7522
+ throw o(u), n("error"), h.setStatus({ code: 2, message: u }), p;
7498
7523
  } finally {
7499
7524
  h.end(), ce(d);
7500
7525
  }
@@ -7513,12 +7538,12 @@ function oo(t) {
7513
7538
  const io = /* @__PURE__ */ new Set([
7514
7539
  kt,
7515
7540
  st,
7516
- $e,
7541
+ Be,
7517
7542
  wt,
7518
7543
  St
7519
7544
  ]), co = /* @__PURE__ */ new Set([
7520
7545
  Mr,
7521
- Fr
7546
+ Rr
7522
7547
  ]), lo = "did not produce any output", ht = 20, pt = {
7523
7548
  heading: "Cart Checker Failures",
7524
7549
  intro: "The following items could not be corrected:"
@@ -7536,12 +7561,12 @@ async function uo(t, e, r, n, o) {
7536
7561
  ], h = 0;
7537
7562
  for (; h < ht; ) {
7538
7563
  h++;
7539
- const p = await jr(
7564
+ const u = await jr(
7540
7565
  t,
7541
7566
  e,
7542
7567
  l,
7543
7568
  d
7544
- ), g = await qr(p, {
7569
+ ), g = await qr(u, {
7545
7570
  onToolCall: o?.onToolCall,
7546
7571
  onToolOutput: o?.onToolOutput
7547
7572
  }), x = g.toolCalls.filter(
@@ -7575,7 +7600,7 @@ async function uo(t, e, r, n, o) {
7575
7600
  d = [
7576
7601
  {
7577
7602
  role: "user",
7578
- parts: [{ type: "text", text: je }]
7603
+ parts: [{ type: "text", text: Ve }]
7579
7604
  }
7580
7605
  ];
7581
7606
  continue;
@@ -7607,19 +7632,19 @@ async function uo(t, e, r, n, o) {
7607
7632
  { role: "assistant", parts: b },
7608
7633
  {
7609
7634
  role: "user",
7610
- parts: [{ type: "text", text: je }]
7635
+ parts: [{ type: "text", text: Ve }]
7611
7636
  }
7612
7637
  ];
7613
7638
  }
7614
7639
  h >= ht && o?.logger?.error(
7615
7640
  `Cart checker hit max iterations limit (${ht})`
7616
7641
  );
7617
- const u = i.length > 0 ? i.join(`
7642
+ const p = i.length > 0 ? i.join(`
7618
7643
 
7619
7644
  `) : s.join("");
7620
7645
  return {
7621
7646
  threadId: l,
7622
- output: u,
7647
+ output: p,
7623
7648
  processingFailuresString: Ye(
7624
7649
  c,
7625
7650
  pt
@@ -7639,7 +7664,7 @@ async function ho(t, e) {
7639
7664
  o = `Successfully added ${n.value.length} item(s) to cart.`;
7640
7665
  }
7641
7666
  return {
7642
- tool: $e,
7667
+ tool: Be,
7643
7668
  toolCallId: t.toolCallId,
7644
7669
  output: o
7645
7670
  };
@@ -7654,7 +7679,7 @@ async function po(t, e) {
7654
7679
  n = `Failed to clear cart: ${s}`, r(t.toolCallId, s);
7655
7680
  }
7656
7681
  return {
7657
- tool: Or,
7682
+ tool: Fr,
7658
7683
  toolCallId: t.toolCallId,
7659
7684
  output: n
7660
7685
  };
@@ -7731,7 +7756,7 @@ function yo(t) {
7731
7756
  function Co(t) {
7732
7757
  const { setItemWarnings: e } = y.getState(), r = t.input;
7733
7758
  return r.itemWarnings && e(r.itemWarnings), {
7734
- tool: Rr,
7759
+ tool: Or,
7735
7760
  toolCallId: t.toolCallId,
7736
7761
  output: "Item warnings set successfully."
7737
7762
  };
@@ -7776,7 +7801,7 @@ async function bo(t, e) {
7776
7801
  output: `${s} cart item(s) updated.`
7777
7802
  };
7778
7803
  }
7779
- const Gr = {
7804
+ const Qr = {
7780
7805
  addToCart: ho,
7781
7806
  updateCart: bo,
7782
7807
  removeFromCart: go,
@@ -7786,37 +7811,37 @@ const Gr = {
7786
7811
  setPoMetadata: xo,
7787
7812
  setItemWarnings: Co,
7788
7813
  removeItemWarnings: yo
7789
- }, vo = new Set(Object.keys(Gr));
7814
+ }, vo = new Set(Object.keys(Qr));
7790
7815
  async function Kr(t, e) {
7791
- const r = Gr[t.toolName];
7816
+ const r = Qr[t.toolName];
7792
7817
  return r?.(t, e);
7793
7818
  }
7794
7819
  function Io(t) {
7795
7820
  const { bcCart: e } = t, r = y(
7796
- (u) => u.takeshapeConfig
7821
+ (p) => p.takeshapeConfig
7797
7822
  ), n = y(
7798
- (u) => u.setCartCheckerStatus
7823
+ (p) => p.setCartCheckerStatus
7799
7824
  ), o = y(
7800
- (u) => u.setCartCheckerThreadId
7825
+ (p) => p.setCartCheckerThreadId
7801
7826
  ), s = y(
7802
- (u) => u.setCartCheckerError
7827
+ (p) => p.setCartCheckerError
7803
7828
  ), i = y(
7804
- (u) => u.setCartCheckerOutput
7829
+ (p) => p.setCartCheckerOutput
7805
7830
  ), c = y(
7806
- (u) => u.resetCartChecker
7831
+ (p) => p.resetCartChecker
7807
7832
  ), l = y(
7808
- (u) => u.setCartCheckerProcessingFailuresString
7833
+ (p) => p.setCartCheckerProcessingFailuresString
7809
7834
  ), d = y(
7810
- (u) => u.addCartCheckerToolCall
7835
+ (p) => p.addCartCheckerToolCall
7811
7836
  );
7812
7837
  return {
7813
7838
  runCartChecker: M(
7814
- async (u) => {
7839
+ async (p) => {
7815
7840
  n("processing"), s(null);
7816
- const p = bt(), g = Ie({
7841
+ const u = bt(), g = we({
7817
7842
  name: "cart-checker",
7818
7843
  op: "ai.check",
7819
- parentSpan: p ?? void 0
7844
+ parentSpan: u ?? void 0
7820
7845
  });
7821
7846
  ce(g);
7822
7847
  const x = async (m) => {
@@ -7832,7 +7857,7 @@ function Io(t) {
7832
7857
  const m = await uo(
7833
7858
  r,
7834
7859
  gn,
7835
- u,
7860
+ p,
7836
7861
  x,
7837
7862
  {
7838
7863
  onThreadCreated: (b) => {
@@ -7866,7 +7891,7 @@ function Io(t) {
7866
7891
  extra: { errorMessage: b }
7867
7892
  }), m;
7868
7893
  } finally {
7869
- g.end(), ce(p);
7894
+ g.end(), ce(u);
7870
7895
  }
7871
7896
  },
7872
7897
  [
@@ -7897,16 +7922,16 @@ function wo({
7897
7922
  (T) => T.setHasProcessedDocument
7898
7923
  ), h = y(
7899
7924
  (T) => T.batchProcessing.status
7900
- ), u = y(
7901
- (T) => T.batchProcessing.processingFailuresString
7902
7925
  ), p = y(
7926
+ (T) => T.batchProcessing.processingFailuresString
7927
+ ), u = y(
7903
7928
  (T) => T.cartChecker.status
7904
7929
  ), g = y(
7905
7930
  (T) => T.cartChecker.error
7906
7931
  ), x = y(
7907
7932
  (T) => T.cartChecker.processingFailuresString
7908
7933
  ), m = y((T) => T.sendMessage), { processBatches: b } = oo({ bcCart: s }), { runCartChecker: v } = Io({ bcCart: s });
7909
- return O(() => {
7934
+ return F(() => {
7910
7935
  t === "processing" && i === "idle" && r.parserStatus !== "streaming" && r.parserStatus !== "submitted" && r.parsedContent && r.parserMessages.length > 0 && (c("batching"), d(!0), b(r.parsedContent));
7911
7936
  }, [
7912
7937
  t,
@@ -7916,31 +7941,31 @@ function wo({
7916
7941
  r.parserMessages.length,
7917
7942
  d,
7918
7943
  b
7919
- ]), O(() => {
7920
- t === "processing" && i === "batching" && (h === "complete" || h === "error") && (c("checking"), v(u));
7944
+ ]), F(() => {
7945
+ t === "processing" && i === "batching" && (h === "complete" || h === "error") && (c("checking"), v(p));
7921
7946
  }, [
7922
7947
  t,
7923
7948
  i,
7924
7949
  h,
7925
- u,
7950
+ p,
7926
7951
  v
7927
- ]), O(() => {
7928
- t === "processing" && i === "checking" && (p === "complete" || p === "error") && (c("emitted"), p === "error" && console.error("[CartChecker] failed:", g), m(
7952
+ ]), F(() => {
7953
+ t === "processing" && i === "checking" && (u === "complete" || u === "error") && (c("emitted"), u === "error" && console.error("[CartChecker] failed:", g), m(
7929
7954
  Ya([
7930
- u,
7955
+ p,
7931
7956
  x
7932
7957
  ])
7933
7958
  ));
7934
7959
  }, [
7935
7960
  t,
7936
7961
  i,
7937
- p,
7938
- g,
7939
7962
  u,
7963
+ g,
7964
+ p,
7940
7965
  x,
7941
7966
  m
7942
- ]), O(() => {
7943
- if (t === "processing" && n && (p === "complete" || p === "error")) {
7967
+ ]), F(() => {
7968
+ if (t === "processing" && n && (u === "complete" || u === "error")) {
7944
7969
  const E = setTimeout(() => {
7945
7970
  e("chatting"), requestAnimationFrame(() => {
7946
7971
  o.current?.scrollToBottom();
@@ -7951,7 +7976,7 @@ function wo({
7951
7976
  }, [
7952
7977
  t,
7953
7978
  n,
7954
- p,
7979
+ u,
7955
7980
  e,
7956
7981
  o
7957
7982
  ]), {
@@ -8052,7 +8077,7 @@ async function To(t) {
8052
8077
  return;
8053
8078
  }
8054
8079
  let n = [], o = null;
8055
- const s = Ie({
8080
+ const s = we({
8056
8081
  name: "load-customer-addresses",
8057
8082
  op: "purchase-order.addresses",
8058
8083
  attributes: {
@@ -8113,9 +8138,9 @@ async function To(t) {
8113
8138
  )
8114
8139
  )
8115
8140
  ), i && h.push(No()), c && h.push(Promise.resolve(Po(d)));
8116
- const p = (await Promise.all(h)).find((g) => !g.valid);
8117
- if (p) {
8118
- Ke(), e.failValidation(p.error ?? "Session validation failed");
8141
+ const u = (await Promise.all(h)).find((g) => !g.valid);
8142
+ if (u) {
8143
+ Ke(), e.failValidation(u.error ?? "Session validation failed");
8119
8144
  return;
8120
8145
  }
8121
8146
  l && e.restoreSession(l), d && e.setBcCart(d), o && e.setCustomerInfo(o), n.length > 0 && e.setCustomerAddresses(n), e.completeValidation();
@@ -8125,18 +8150,18 @@ function $o({
8125
8150
  client: t,
8126
8151
  intervalMs: e = Ao
8127
8152
  }) {
8128
- const r = R(!1);
8129
- O(() => {
8153
+ const r = O(!1);
8154
+ F(() => {
8130
8155
  let n = !1, o = null;
8131
8156
  const s = async () => {
8132
8157
  if (n) return;
8133
- const { authInvalidated: h, customerEntityId: u, ui: p, setAuthInvalidated: g } = y.getState();
8134
- if (!(p.initStatus !== "ready" || h) && !r.current) {
8158
+ const { authInvalidated: h, customerEntityId: p, ui: u, setAuthInvalidated: g } = y.getState();
8159
+ if (!(u.initStatus !== "ready" || h) && !r.current) {
8135
8160
  r.current = !0;
8136
8161
  try {
8137
8162
  const x = await t.getCustomerEntityId();
8138
8163
  if (n) return;
8139
- const m = Yr(u, x);
8164
+ const m = Yr(p, x);
8140
8165
  m.match || g({ reason: m.reason });
8141
8166
  } catch (x) {
8142
8167
  console.error(
@@ -8170,24 +8195,24 @@ const Bo = "<!-- BATCH -->";
8170
8195
  function Mo(t) {
8171
8196
  return t.split(Bo).map((e) => e.trim()).filter(Boolean);
8172
8197
  }
8173
- function Fo(t) {
8198
+ function Ro(t) {
8174
8199
  return new Promise((e, r) => {
8175
8200
  const n = new FileReader();
8176
8201
  n.onload = () => e(n.result), n.onerror = () => r(new Error("Failed to read file")), n.readAsText(t);
8177
8202
  });
8178
8203
  }
8179
- function Oo(t) {
8204
+ function Fo(t) {
8180
8205
  return new Promise((e, r) => {
8181
8206
  const n = new FileReader();
8182
8207
  n.onload = () => e(n.result), n.onerror = () => r(new Error("Failed to read file")), n.readAsDataURL(t);
8183
8208
  });
8184
8209
  }
8185
- const Ro = /* @__PURE__ */ new Set([
8210
+ const Oo = /* @__PURE__ */ new Set([
8186
8211
  "application/vnd.ms-excel",
8187
8212
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
8188
8213
  ]);
8189
8214
  function rr(t) {
8190
- return Ro.has(t);
8215
+ return Oo.has(t);
8191
8216
  }
8192
8217
  async function _o(t) {
8193
8218
  const e = await import("xlsx"), r = await t.arrayBuffer(), n = e.read(r, { type: "array" });
@@ -8231,14 +8256,14 @@ async function jo(t) {
8231
8256
  "pdfjs-dist/legacy/build/pdf.worker.mjs"
8232
8257
  );
8233
8258
  globalThis.pdfjsWorker = d;
8234
- const { getDocument: h } = await import("pdfjs-dist/legacy/build/pdf.mjs"), u = h({
8259
+ const { getDocument: h } = await import("pdfjs-dist/legacy/build/pdf.mjs"), p = h({
8235
8260
  data: e,
8236
8261
  isEvalSupported: !1
8237
8262
  });
8238
8263
  try {
8239
- (await u.promise).destroy();
8240
- } catch (p) {
8241
- return await u.destroy(), p instanceof Error && p.name === "PasswordException" ? { valid: !1, reason: "password-protected" } : { valid: !1, reason: "invalid" };
8264
+ (await p.promise).destroy();
8265
+ } catch (u) {
8266
+ return await p.destroy(), u instanceof Error && u.name === "PasswordException" ? { valid: !1, reason: "password-protected" } : { valid: !1, reason: "invalid" };
8242
8267
  }
8243
8268
  } catch (d) {
8244
8269
  return console.error("PDF validation error:", d), { valid: !1, reason: "invalid" };
@@ -8291,10 +8316,10 @@ function zo({
8291
8316
  const d = await _o(c);
8292
8317
  e({ parts: nr(c.name, d) });
8293
8318
  } else if (Vo.has(c.type)) {
8294
- const d = await Fo(c);
8319
+ const d = await Ro(c);
8295
8320
  e({ parts: nr(c.name, d) });
8296
8321
  } else {
8297
- const d = await Oo(c);
8322
+ const d = await Fo(c);
8298
8323
  e({
8299
8324
  parts: Wo(d, c.type, c.name)
8300
8325
  });
@@ -8324,9 +8349,9 @@ function Xr(t) {
8324
8349
  onThreadCreated: s
8325
8350
  } = t, { projectId: i, apiKey: c, origin: l } = y(
8326
8351
  (g) => g.takeshapeConfig
8327
- ), [d, h] = _(!1), u = R(
8352
+ ), [d, h] = _(!1), p = O(
8328
8353
  n ? { id: n } : null
8329
- ), p = M(async () => {
8354
+ ), u = M(async () => {
8330
8355
  h(!0);
8331
8356
  const g = 2;
8332
8357
  let x = 0;
@@ -8336,7 +8361,7 @@ function Xr(t) {
8336
8361
  { origin: l, projectId: i, apiKey: c },
8337
8362
  e
8338
8363
  );
8339
- h(!1), u.current = { id: m }, o && y.getState().setThreadId(m), s?.(m);
8364
+ h(!1), p.current = { id: m }, o && y.getState().setThreadId(m), s?.(m);
8340
8365
  return;
8341
8366
  } catch (m) {
8342
8367
  if (x === g) {
@@ -8353,12 +8378,12 @@ function Xr(t) {
8353
8378
  ), await new Promise((k) => setTimeout(k, v)), x++;
8354
8379
  }
8355
8380
  }, [e, c, s, l, o, i]);
8356
- return O(() => {
8357
- r && !d && !u.current && p();
8358
- }, [p, r, d]), n && !u.current && (u.current = { id: n }), {
8359
- thread: u,
8381
+ return F(() => {
8382
+ r && !d && !p.current && u();
8383
+ }, [u, r, d]), n && !p.current && (p.current = { id: n }), {
8384
+ thread: p,
8360
8385
  isCreating: d,
8361
- createThread: p
8386
+ createThread: u
8362
8387
  };
8363
8388
  }
8364
8389
  function Ho() {
@@ -8376,12 +8401,12 @@ function Ho() {
8376
8401
  (S) => S.parser.parsedContent
8377
8402
  ), c = y(
8378
8403
  (S) => S.parser.uploadedFileName
8379
- ), l = R(
8404
+ ), l = O(
8380
8405
  null
8381
- ), d = R(null), {
8406
+ ), d = O(null), {
8382
8407
  messages: h,
8383
- sendMessage: u,
8384
- status: p,
8408
+ sendMessage: p,
8409
+ status: u,
8385
8410
  setMessages: g
8386
8411
  } = ar({
8387
8412
  transport: new or({
@@ -8422,9 +8447,9 @@ function Ho() {
8422
8447
  handleFileUpload: k
8423
8448
  } = zo({
8424
8449
  createParserThread: s,
8425
- sendParserMessage: u
8450
+ sendParserMessage: p
8426
8451
  }), T = M(
8427
- async (S) => (l.current?.end(), d.current = bt(), l.current = Ie({
8452
+ async (S) => (l.current?.end(), d.current = bt(), l.current = we({
8428
8453
  name: "document-parser",
8429
8454
  op: "ai.parse",
8430
8455
  attributes: {
@@ -8438,7 +8463,7 @@ function Ho() {
8438
8463
  )),
8439
8464
  [k]
8440
8465
  );
8441
- O(() => {
8466
+ F(() => {
8442
8467
  if (h.length > 0) {
8443
8468
  const S = h[h.length - 1];
8444
8469
  if (S?.role === "assistant" && Array.isArray(S.parts)) {
@@ -8446,11 +8471,11 @@ function Ho() {
8446
8471
  y.getState().setParsedContent($), $ && m(!1);
8447
8472
  }
8448
8473
  }
8449
- }, [h, m]), O(() => () => {
8474
+ }, [h, m]), F(() => () => {
8450
8475
  l.current?.setStatus({ code: 2, message: "cancelled" }), l.current?.end(), l.current = null;
8451
- }, []), O(() => {
8452
- p === "ready" && l.current && i !== null && (l.current.setStatus({ code: 1, message: "ok" }), l.current.end(), l.current = null, ce(d.current));
8453
- }, [p, i]);
8476
+ }, []), F(() => {
8477
+ u === "ready" && l.current && i !== null && (l.current.setStatus({ code: 1, message: "ok" }), l.current.end(), l.current = null, ce(d.current));
8478
+ }, [u, i]);
8454
8479
  const E = M(() => {
8455
8480
  l.current?.setStatus({ code: 2, message: "cancelled" }), l.current?.end(), l.current = null, v(null), g([]), y.getState().setParsedContent(null);
8456
8481
  }, [v, g]), I = M(() => {
@@ -8461,14 +8486,14 @@ function Ho() {
8461
8486
  isUploadingFile: x,
8462
8487
  uploadedFileName: c,
8463
8488
  parserError: b,
8464
- parserStatus: p,
8489
+ parserStatus: u,
8465
8490
  parserMessages: h,
8466
8491
  handleFileUpload: T,
8467
8492
  handleClearError: E,
8468
8493
  reset: I
8469
8494
  };
8470
8495
  }
8471
- class Qo {
8496
+ class Go {
8472
8497
  b2bToken = null;
8473
8498
  companyId = null;
8474
8499
  channelId;
@@ -8477,7 +8502,7 @@ class Qo {
8477
8502
  initPromise;
8478
8503
  constructor(e) {
8479
8504
  this.channelId = e.channelId, this.getB2BJwt = e.getB2BJwt ?? null, this.graphQLClient = new yt(cr, {
8480
- fetch: Te,
8505
+ fetch: Ae,
8481
8506
  credentials: "same-origin",
8482
8507
  headers: {
8483
8508
  "content-type": "application/json",
@@ -8541,7 +8566,7 @@ class Qo {
8541
8566
  requestHeaders: {
8542
8567
  Authorization: `Bearer ${e}`
8543
8568
  }
8544
- }), o = Pe(
8569
+ }), o = Te(
8545
8570
  vt,
8546
8571
  r.authorization
8547
8572
  )?.result?.token;
@@ -8559,7 +8584,7 @@ class Qo {
8559
8584
  }
8560
8585
  },
8561
8586
  -1
8562
- ), o = Pe(fr, r.currentUser)?.companyInfo?.companyId;
8587
+ ), o = Te(fr, r.currentUser)?.companyInfo?.companyId;
8563
8588
  if (!o)
8564
8589
  throw new Error("No company ID returned from current user query");
8565
8590
  return console.debug("[B2BClient] Received company ID", o), Number(o);
@@ -8614,15 +8639,15 @@ class Qo {
8614
8639
  }
8615
8640
  }
8616
8641
  }
8617
- function Go(t) {
8642
+ function Qo(t) {
8618
8643
  return console.debug(
8619
8644
  `[createB2BClient] Initializing B2B client for channelId=${t.channelId}`
8620
- ), new Qo(t);
8645
+ ), new Go(t);
8621
8646
  }
8622
8647
  async function wi(t) {
8623
8648
  let e = null;
8624
8649
  try {
8625
- const r = await Te(
8650
+ const r = await Ae(
8626
8651
  `/customer/current.jwt?app_client_id=${yn}`,
8627
8652
  {
8628
8653
  method: "GET",
@@ -8644,7 +8669,7 @@ async function wi(t) {
8644
8669
  "[stencilB2BJwt] Exchanging customer JWT for B2B storefront token"
8645
8670
  );
8646
8671
  const n = await new yt(cr, {
8647
- fetch: Te,
8672
+ fetch: Ae,
8648
8673
  credentials: "same-origin",
8649
8674
  headers: {
8650
8675
  "content-type": "application/json",
@@ -8659,7 +8684,7 @@ async function wi(t) {
8659
8684
  channelId: t
8660
8685
  }
8661
8686
  }
8662
- }), s = Pe(
8687
+ }), s = Te(
8663
8688
  vt,
8664
8689
  n.authorization
8665
8690
  )?.result?.token;
@@ -8730,16 +8755,16 @@ const ei = new on({
8730
8755
  }
8731
8756
  });
8732
8757
  function ti(t) {
8733
- return /* @__PURE__ */ a(an, { client: ei, children: /* @__PURE__ */ a(Qs, { client: t.bigcommerce.client, children: /* @__PURE__ */ a(ri, { ...t }) }) });
8758
+ return /* @__PURE__ */ a(an, { client: ei, children: /* @__PURE__ */ a(Gs, { client: t.bigcommerce.client, children: /* @__PURE__ */ a(ri, { ...t }) }) });
8734
8759
  }
8735
8760
  function ri(t) {
8736
8761
  const e = y((i) => i.ui.initStatus), r = y((i) => i.ui.initError), n = y((i) => i.fatalError), o = y(
8737
8762
  (i) => i.authInvalidated
8738
8763
  ), s = y((i) => i.clearInitError);
8739
- return O(() => {
8764
+ return F(() => {
8740
8765
  e === "pending" && To({
8741
8766
  storefrontClient: t.bigcommerce.client,
8742
- b2bClient: Go({
8767
+ b2bClient: Qo({
8743
8768
  channelId: t.bigcommerce.client.channelId,
8744
8769
  getB2BJwt: t.bigcommerce.getB2BJwt
8745
8770
  }),
@@ -8761,7 +8786,7 @@ function ri(t) {
8761
8786
  "div",
8762
8787
  {
8763
8788
  className: `flex h-full items-center justify-center ${t.className ?? ""}`,
8764
- children: /* @__PURE__ */ a("div", { className: "flex items-center", children: /* @__PURE__ */ a(De, { size: 16 }) })
8789
+ children: /* @__PURE__ */ a("div", { className: "flex items-center", children: /* @__PURE__ */ a(Le, { size: 16 }) })
8765
8790
  }
8766
8791
  ) : e === "existing-cart" ? /* @__PURE__ */ a(
8767
8792
  "div",
@@ -8802,39 +8827,39 @@ function ni({
8802
8827
  ), d = y((w) => w.chat.input), h = y(
8803
8828
  (w) => w.chat.messages
8804
8829
  ), {
8805
- thread: u,
8806
- isCreating: p,
8830
+ thread: p,
8831
+ isCreating: u,
8807
8832
  createThread: g
8808
8833
  } = Xr({
8809
8834
  agentName: e,
8810
8835
  createOnMount: !l,
8811
8836
  // Only create if no existing thread
8812
8837
  existingThreadId: l
8813
- }), x = y((w) => w.appState), m = y((w) => w.setAppState), b = R(null), v = R(
8838
+ }), x = y((w) => w.appState), m = y((w) => w.setAppState), b = O(null), v = O(
8814
8839
  null
8815
- ), k = R(
8840
+ ), k = O(
8816
8841
  null
8817
- ), T = qe((w) => w.isExpanded), E = qe((w) => w.setExpanded), I = qe((w) => w.reset), S = Ho(), B = Qa({
8842
+ ), T = je((w) => w.isExpanded), E = je((w) => w.setExpanded), I = je((w) => w.reset), S = Ho(), B = Ga({
8818
8843
  client: n.client,
8819
8844
  onError: (w) => console.error("BigCommerce error:", w)
8820
8845
  });
8821
8846
  $o({ client: n.client });
8822
- const $ = y((w) => w.cartifact.orderId), z = y((w) => w.cartifact.buyerInfo), re = y(
8847
+ const $ = y((w) => w.cartifact.orderId), z = y((w) => w.cartifact.buyerInfo), K = y(
8823
8848
  (w) => w.cartifact.shipToAddress
8824
- ), j = y(
8849
+ ), q = y(
8825
8850
  (w) => w.cartifact.billingAddress
8826
- ), J = y(
8851
+ ), Y = y(
8827
8852
  (w) => w.cartifact.poMetadataSet
8828
- ), ne = y(
8853
+ ), J = y(
8829
8854
  (w) => w.cartifact.itemWarnings
8830
- ), ie = y((w) => w.clearCartifact), X = y((w) => w.clearBcSession), se = y(
8855
+ ), le = y((w) => w.clearCartifact), X = y((w) => w.clearBcSession), Z = y(
8831
8856
  (w) => w.clearAddressSelections
8832
- ), H = y((w) => w.clearChat), { cartItems: q } = B, le = R([]), ke = M(
8857
+ ), H = y((w) => w.clearChat), { cartItems: j } = B, ie = O([]), ye = M(
8833
8858
  async ({ toolCall: w }) => {
8834
- le.current.push(w);
8859
+ ie.current.push(w);
8835
8860
  },
8836
8861
  []
8837
- ), L = R(/* @__PURE__ */ new Set()), { messages: W, sendMessage: G, status: K, error: Be, setMessages: ge, addToolOutput: ye } = ar({
8862
+ ), se = O(/* @__PURE__ */ new Set()), { messages: D, sendMessage: ne, status: W, error: de, setMessages: Ce, addToolOutput: Me } = ar({
8838
8863
  transport: new or({
8839
8864
  api: `${s}/project/${i}/agents/messages`,
8840
8865
  fetch: hr,
@@ -8847,29 +8872,29 @@ function ni({
8847
8872
  throw new Error("No messages to send");
8848
8873
  let Ee = [ae];
8849
8874
  if (ae.role === "user" && w.messages.length >= 2) {
8850
- const fe = w.messages[w.messages.length - 2], it = L.current;
8851
- if (fe?.role === "assistant" && it.size > 0) {
8875
+ const me = w.messages[w.messages.length - 2], it = se.current;
8876
+ if (me?.role === "assistant" && it.size > 0) {
8852
8877
  const At = Xo(
8853
- fe.parts
8878
+ me.parts
8854
8879
  ).filter(
8855
8880
  ($t) => it.has($t.toolCallId)
8856
8881
  );
8857
8882
  it.clear(), At.length > 0 && (Ee = [{
8858
- ...fe,
8859
- parts: At.map((Me) => ({
8860
- type: Me.type,
8861
- toolName: Zo(Me),
8862
- toolCallId: Me.toolCallId,
8863
- state: Me.state,
8864
- input: Me.input,
8865
- output: Me.output
8883
+ ...me,
8884
+ parts: At.map((Re) => ({
8885
+ type: Re.type,
8886
+ toolName: Zo(Re),
8887
+ toolCallId: Re.toolCallId,
8888
+ state: Re.state,
8889
+ input: Re.input,
8890
+ output: Re.output
8866
8891
  }))
8867
8892
  }, ae]);
8868
8893
  }
8869
8894
  }
8870
8895
  return {
8871
8896
  body: {
8872
- id: u.current?.id ?? "",
8897
+ id: p.current?.id ?? "",
8873
8898
  messages: Ee,
8874
8899
  trigger: w.trigger,
8875
8900
  messageId: w.messageId,
@@ -8884,91 +8909,91 @@ function ni({
8884
8909
  }
8885
8910
  }),
8886
8911
  messages: h,
8887
- onToolCall: ke,
8912
+ onToolCall: ye,
8888
8913
  onError: (w) => {
8889
8914
  console.error("[useChat onError]", w), v.current?.setStatus({
8890
8915
  code: 2,
8891
8916
  message: "internal_error"
8892
8917
  }), v.current?.end(), v.current = null;
8893
8918
  }
8894
- }), he = M(
8919
+ }), ue = M(
8895
8920
  (w) => {
8896
8921
  v.current?.end(), k.current ? Oe(k.current, () => {
8897
- v.current = Ie({
8922
+ v.current = we({
8898
8923
  name: "po-agent-turn",
8899
8924
  op: "ai.agent",
8900
8925
  attributes: {
8901
8926
  "agent.name": r
8902
8927
  }
8903
8928
  });
8904
- }) : v.current = Ie({
8929
+ }) : v.current = we({
8905
8930
  name: "po-agent-turn",
8906
8931
  op: "ai.agent",
8907
8932
  attributes: {
8908
8933
  "agent.name": r
8909
8934
  }
8910
- }), ce(v.current), G(w);
8935
+ }), ce(v.current), ne(w);
8911
8936
  },
8912
- [G, r]
8937
+ [ne, r]
8913
8938
  );
8914
- O(() => {
8915
- K === "ready" && v.current && (v.current.setStatus({ code: 1, message: "ok" }), v.current.end(), v.current = null, ce(k.current));
8916
- }, [K]), O(() => () => {
8939
+ F(() => {
8940
+ W === "ready" && v.current && (v.current.setStatus({ code: 1, message: "ok" }), v.current.end(), v.current = null, ce(k.current));
8941
+ }, [W]), F(() => () => {
8917
8942
  v.current?.end(), k.current?.end(), ce(null);
8918
- }, []), O(() => {
8919
- if (K === "ready" && le.current.length > 0) {
8920
- const w = [...le.current];
8921
- le.current = [], Yo(w, W, B).then(async (ae) => {
8943
+ }, []), F(() => {
8944
+ if (W === "ready" && ie.current.length > 0) {
8945
+ const w = [...ie.current];
8946
+ ie.current = [], Yo(w, D, B).then(async (ae) => {
8922
8947
  for (const Ee of ae.outputs)
8923
- L.current.add(Ee.toolCallId), await ye(Ee);
8924
- ae.outputs.length > 0 && he({ text: je });
8948
+ se.current.add(Ee.toolCallId), await Me(Ee);
8949
+ ae.outputs.length > 0 && ue({ text: Ve });
8925
8950
  }).catch((ae) => {
8926
8951
  console.error("[executeDeferredToolCalls] Error:", ae);
8927
8952
  });
8928
8953
  }
8929
- }, [K, W, B, ye, he]), O(() => {
8930
- y.getState().setMessages(W);
8931
- }, [W]);
8932
- const Ce = y(
8954
+ }, [W, D, B, Me, ue]), F(() => {
8955
+ y.getState().setMessages(D);
8956
+ }, [D]);
8957
+ const xe = y(
8933
8958
  (w) => w.ai.pendingMessage
8934
8959
  ), C = y((w) => w.ai.shouldScroll), N = y((w) => w.consumeMessage);
8935
- O(() => {
8936
- Ce && (he({ text: Ce }), N(), C && requestAnimationFrame(() => {
8960
+ F(() => {
8961
+ xe && (ue({ text: xe }), N(), C && requestAnimationFrame(() => {
8937
8962
  b.current?.scrollToBottom();
8938
8963
  }));
8939
- }, [Ce, C, he, N]), O(() => {
8964
+ }, [xe, C, ue, N]), F(() => {
8940
8965
  o && x === "chatting" && E(!0);
8941
8966
  }, [o, x, E]);
8942
- const P = p || K === "submitted" || K === "streaming", A = te(() => Oa(W, K), [W, K]), F = wo({
8967
+ const P = u || W === "submitted" || W === "streaming", A = re(() => Fa(D, W), [D, W]), R = wo({
8943
8968
  appState: x,
8944
8969
  setAppState: m,
8945
8970
  parser: S,
8946
8971
  firstResponseComplete: A,
8947
8972
  chatPanelRef: b,
8948
8973
  bcCart: B
8949
- }), U = Ga({
8974
+ }), L = Qa({
8950
8975
  bcCart: B,
8951
- cartItems: q,
8976
+ cartItems: j,
8952
8977
  onCheckoutInitiated: (w) => {
8953
8978
  w ? k.current?.setStatus({ code: 2, message: w.message }) : k.current?.setStatus({ code: 1, message: "ok" }), k.current?.end(), k.current = null, ce(null);
8954
8979
  },
8955
8980
  onCheckout: n.onCheckout
8956
- }), D = (w) => {
8981
+ }), U = (w) => {
8957
8982
  y.getState().setInput(w.target.value);
8958
- }, ze = (w) => {
8983
+ }, ke = (w) => {
8959
8984
  w.preventDefault(), d.trim() && (y.getState().sendMessage(d), y.getState().setInput(""));
8960
- }, Le = async (w) => {
8961
- k.current?.end(), k.current = Ie({
8985
+ }, Ue = async (w) => {
8986
+ k.current?.end(), k.current = we({
8962
8987
  name: "upload-to-checkout",
8963
8988
  op: "purchase-order.session",
8964
8989
  attributes: {
8965
8990
  "file.name": w.name
8966
8991
  }
8967
- }), ce(k.current), m("processing"), F.reset(), await Oe(
8992
+ }), ce(k.current), m("processing"), R.reset(), await Oe(
8968
8993
  k.current,
8969
8994
  () => S.handleFileUpload(w)
8970
8995
  ) === !1 && m("upload");
8971
- }, Q = M(
8996
+ }, G = M(
8972
8997
  (w) => {
8973
8998
  n.onViewProduct && n.onViewProduct({
8974
8999
  productEntityId: w.productEntityId,
@@ -8978,36 +9003,36 @@ function ni({
8978
9003
  });
8979
9004
  },
8980
9005
  [n.onViewProduct]
8981
- ), de = M(() => {
8982
- const w = [...W].reverse().find((fe) => fe.role === "user");
9006
+ ), he = M(() => {
9007
+ const w = [...D].reverse().find((me) => me.role === "user");
8983
9008
  if (!w) return;
8984
9009
  const ae = w.parts?.filter(
8985
- (fe) => fe.type === "text"
8986
- ).map((fe) => fe.text).join(`
9010
+ (me) => me.type === "text"
9011
+ ).map((me) => me.text).join(`
8987
9012
  `);
8988
9013
  if (!ae) return;
8989
- const Ee = W.lastIndexOf(w);
8990
- ge(W.slice(0, Ee)), y.getState().sendMessage(ae);
8991
- }, [W, ge]), Y = M(() => {
9014
+ const Ee = D.lastIndexOf(w);
9015
+ Ce(D.slice(0, Ee)), y.getState().sendMessage(ae);
9016
+ }, [D, Ce]), Q = M(() => {
8992
9017
  m("chatting");
8993
- }, [m]), Z = y(
9018
+ }, [m]), ee = y(
8994
9019
  (w) => w.resetBatchProcessing
8995
- ), pe = y(
9020
+ ), fe = y(
8996
9021
  (w) => w.resetCartChecker
8997
- ), xe = M(async () => {
8998
- k.current?.setStatus({ code: 2, message: "cancelled" }), k.current?.end(), k.current = null, await B.clearCart(), ie(), X(), se(), H(), ge([]), Z(), pe(), I(), S.reset(), F.reset(), m("upload"), g();
9022
+ ), be = M(async () => {
9023
+ k.current?.setStatus({ code: 2, message: "cancelled" }), k.current?.end(), k.current = null, await B.clearCart(), le(), X(), Z(), H(), Ce([]), ee(), fe(), I(), S.reset(), R.reset(), m("upload"), g();
8999
9024
  }, [
9000
9025
  B.clearCart,
9001
- ie,
9026
+ le,
9002
9027
  X,
9003
- se,
9004
- H,
9005
- ge,
9006
9028
  Z,
9007
- pe,
9029
+ H,
9030
+ Ce,
9031
+ ee,
9032
+ fe,
9008
9033
  I,
9009
9034
  S.reset,
9010
- F.reset,
9035
+ R.reset,
9011
9036
  g,
9012
9037
  m
9013
9038
  ]);
@@ -9015,36 +9040,37 @@ function ni({
9015
9040
  return /* @__PURE__ */ a("div", { className: `flex h-full ${t}`, children: /* @__PURE__ */ a(
9016
9041
  ja,
9017
9042
  {
9018
- onFileUpload: Le,
9019
- onSkip: Y,
9043
+ onFileUpload: Ue,
9044
+ onSkip: Q,
9020
9045
  onClearError: S.handleClearError,
9021
- cartItems: q,
9046
+ cartItems: j,
9022
9047
  isUploading: S.isUploadingFile,
9023
9048
  parserError: S.parserError
9024
9049
  }
9025
9050
  ) });
9026
9051
  const Tt = {
9027
9052
  className: t,
9028
- messages: W,
9053
+ messages: D,
9029
9054
  input: d,
9030
- onInputChange: D,
9031
- onSubmit: ze,
9055
+ onInputChange: U,
9056
+ onSubmit: ke,
9032
9057
  isLoading: P,
9033
- error: Be,
9034
- onRetry: Be ? de : void 0,
9035
- hasProcessedDocument: F.hasProcessedDocument,
9058
+ error: de,
9059
+ onRetry: de ? he : void 0,
9060
+ hasProcessedDocument: R.hasProcessedDocument,
9036
9061
  uploadedFileName: S.uploadedFileName,
9037
9062
  chatPanelRef: b,
9038
- onFileUpload: Le,
9039
- cartItems: q,
9040
- itemWarnings: ne,
9041
- onUpdateQuantity: U.handleUpdateQuantity,
9042
- onRemove: U.handleRemoveItem,
9043
- onCheckout: U.handleCheckout,
9044
- onSuggestAlternatives: U.handleSuggestAlternatives,
9045
- onShowMoreLikeThis: U.handleShowMoreLikeThis,
9046
- onViewProduct: n.onViewProduct ? Q : void 0,
9047
- onAddToCart: U.handleAddToCartFromSuggestion,
9063
+ onFileUpload: Ue,
9064
+ cartItems: j,
9065
+ itemWarnings: J,
9066
+ onUpdateQuantity: L.handleUpdateQuantity,
9067
+ onRemove: L.handleRemoveItem,
9068
+ onCheckout: L.handleCheckout,
9069
+ onReviewCart: L.handleReviewCart,
9070
+ onSuggestAlternatives: L.handleSuggestAlternatives,
9071
+ onShowMoreLikeThis: L.handleShowMoreLikeThis,
9072
+ onViewProduct: n.onViewProduct ? G : void 0,
9073
+ onAddToCart: L.handleAddToCartFromSuggestion,
9048
9074
  orderId: $,
9049
9075
  buyerInfo: z,
9050
9076
  customerInfo: B.customerInfo ?? void 0,
@@ -9055,12 +9081,12 @@ function ni({
9055
9081
  selectedBillingAddressId: B.selectedBillingAddressId ?? void 0,
9056
9082
  billingAddressUpdateStatus: B.billingAddressUpdateStatus,
9057
9083
  onBillingAddressChange: B.setBillingAddressOnCheckout,
9058
- shipToAddress: re,
9059
- billingAddress: j ?? void 0,
9084
+ shipToAddress: K,
9085
+ billingAddress: q ?? void 0,
9060
9086
  checkoutTotals: B.checkoutTotals,
9061
9087
  isCartLoading: B.isLoading,
9062
- poMetadataSet: J,
9063
- onNewOrder: xe
9088
+ poMetadataSet: Y,
9089
+ onNewOrder: be
9064
9090
  };
9065
9091
  return o && T ? /* @__PURE__ */ a(Kn, { children: /* @__PURE__ */ a(Jt, { ...Tt, onMinimize: () => E(!1) }) }) : /* @__PURE__ */ a("div", { className: "h-full max-w-[1440px] mx-auto", children: /* @__PURE__ */ a(
9066
9092
  Jt,
@@ -9080,8 +9106,8 @@ function Si({
9080
9106
  className: i,
9081
9107
  expandOnReady: c
9082
9108
  }) {
9083
- const l = te(
9084
- () => Gn({
9109
+ const l = re(
9110
+ () => Qn({
9085
9111
  endpoint: e.endpoint,
9086
9112
  storefrontToken: e.storefrontToken,
9087
9113
  channelId: e.channelId
@@ -9098,8 +9124,8 @@ function Si({
9098
9124
  takeshape: {
9099
9125
  projectId: t.projectId,
9100
9126
  apiKey: t.apiKey,
9101
- origin: t.origin ?? Rt,
9102
- sseOrigin: t.sseOrigin ?? Rt
9127
+ origin: t.origin ?? Ot,
9128
+ sseOrigin: t.sseOrigin ?? Ot
9103
9129
  },
9104
9130
  bigcommerce: {
9105
9131
  client: l,
@@ -9113,12 +9139,12 @@ function Si({
9113
9139
  export {
9114
9140
  Si as P,
9115
9141
  bi as S,
9116
- Gn as a,
9142
+ Qn as a,
9117
9143
  Ii as b,
9118
- Go as c,
9144
+ Qo as c,
9119
9145
  ti as d,
9120
9146
  vi as i,
9121
9147
  xi as r,
9122
9148
  wi as s
9123
9149
  };
9124
- //# sourceMappingURL=purchase-order-chat-wrapper-DkViJTyi.js.map
9150
+ //# sourceMappingURL=purchase-order-chat-wrapper-Bk8hsm7G.js.map