@takeshape/purchase-order-chat 1.63.0 → 1.64.1

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,43 +1,42 @@
1
- import { useState as R, useEffect as F, createElement as Mr, useRef as D, useLayoutEffect as yt, useCallback as M, createContext as Or, useContext as Fr, useMemo as ee, forwardRef as Dr, useImperativeHandle as Rr } from "react";
1
+ import { useState as R, useEffect as F, createElement as $r, useRef as D, useLayoutEffect as gt, useCallback as M, createContext as Mr, useContext as Or, useMemo as ee, forwardRef as Fr, useImperativeHandle as Dr } from "react";
2
2
  import { jsxs as h, jsx as a, Fragment as Ce } from "react/jsx-runtime";
3
- import { GraphQLClient as at, ClientError as _r } from "graphql-request";
4
- import { initGraphQLTada as Wt, readFragment as Ee } from "gql.tada";
5
- import { useChat as Vt } from "@ai-sdk/react";
6
- import { QueryClientProvider as Lr, QueryClient as Ur } from "@tanstack/react-query";
7
- import { parseJsonEventStream as qr, uiMessageChunkSchema as jr, DefaultChatTransport as zt, isToolUIPart as Wr } from "ai";
8
- import { create as it } from "zustand";
9
- import { clsx as Vr } from "clsx";
10
- import { twMerge as zr } from "tailwind-merge";
11
- import { devtools as Hr, persist as Ht } from "zustand/middleware";
3
+ import { GraphQLClient as st, ClientError as Rr } from "graphql-request";
4
+ import { initGraphQLTada as jt, readFragment as Ee } from "gql.tada";
5
+ import { useChat as Wt } from "@ai-sdk/react";
6
+ import { QueryClientProvider as _r, QueryClient as Lr } from "@tanstack/react-query";
7
+ import { parseJsonEventStream as Ur, uiMessageChunkSchema as qr, DefaultChatTransport as Vt, isToolUIPart as jr } from "ai";
8
+ import { create as at } from "zustand";
9
+ import { clsx as Wr } from "clsx";
10
+ import { twMerge as Vr } from "tailwind-merge";
11
+ import { devtools as zr, persist as zt } from "zustand/middleware";
12
12
  import { Streamdown as He } from "streamdown";
13
- import { z as xt } from "zod";
14
- import { get as Xe } from "lodash";
15
- import Qr from "p-map";
16
- function ke(...t) {
17
- return zr(Vr(t));
13
+ import { z as yt } from "zod";
14
+ import Hr from "p-map";
15
+ function Pe(...t) {
16
+ return Vr(Wr(t));
18
17
  }
19
- function ji(t, e) {
18
+ function Wi(t, e) {
20
19
  return t.replace(/:(\w+)/g, (r, n) => {
21
20
  const i = e[n];
22
21
  return i != null ? String(i) : "";
23
22
  });
24
23
  }
25
- const Gr = "__vite_c_css_pos_initial_5760f583c58d40af9dee51cdfad89390", bt = "__vite_c_css_pos_update_5760f583c58d40af9dee51cdfad89390", Ct = () => typeof window < "u" ? window[Gr] : void 0, Wi = (t) => {
26
- const [e, r] = R(() => Ct() || /* @__PURE__ */ new Map()), [n, i] = R(0);
24
+ const Qr = "__vite_c_css_pos_initial_2d6e636c35f8408d82e22d360c298aeb", xt = "__vite_c_css_pos_update_2d6e636c35f8408d82e22d360c298aeb", bt = () => typeof window < "u" ? window[Qr] : void 0, Vi = (t) => {
25
+ const [e, r] = R(() => bt() || /* @__PURE__ */ new Map()), [n, i] = R(0);
27
26
  return F(() => {
28
27
  const s = (o) => {
29
- const c = Ct() || /* @__PURE__ */ new Map();
28
+ const c = bt() || /* @__PURE__ */ new Map();
30
29
  r(c), i((l) => l + 1), t.onChange?.(c);
31
30
  };
32
- return window.addEventListener(bt, s), s(), () => {
33
- window.removeEventListener(bt, s);
31
+ return window.addEventListener(xt, s), s(), () => {
32
+ window.removeEventListener(xt, s);
34
33
  };
35
34
  }, [t.onChange]), Array.from(e?.keys() || []).map((s) => {
36
35
  const o = e.get(s);
37
- return o ? /* @__PURE__ */ Mr("style", { ...o.attributes, key: `${s}-${n}` }, o.css) : null;
36
+ return o ? /* @__PURE__ */ $r("style", { ...o.attributes, key: `${s}-${n}` }, o.css) : null;
38
37
  });
39
- }, Qe = "bigcommercePurchaseOrderAgent", vt = "https://api.takeshape.io", Qt = "https://api-b2b.bigcommerce.com/graphql", Kr = "dl7c39mdpul6hyc489yk0vzxl6jesyx", ot = "[client is providing tool response]", be = "__po_address__", Se = "__po_billing_address__", le = "__checkout_address__", ct = "purchase-order-chat-session", Gt = 3;
40
- function Jr() {
38
+ }, Qe = "bigcommercePurchaseOrderAgent", Ct = "https://api.takeshape.io", Ht = "https://api-b2b.bigcommerce.com/graphql", Gr = "dl7c39mdpul6hyc489yk0vzxl6jesyx", it = "[client is providing tool response]", be = "__po_address__", Se = "__po_billing_address__", le = "__checkout_address__", ot = "purchase-order-chat-session", Qt = 3;
39
+ function Kr() {
41
40
  if (typeof document < "u")
42
41
  try {
43
42
  const t = document.createElement("iframe");
@@ -50,13 +49,13 @@ function Jr() {
50
49
  }
51
50
  return fetch;
52
51
  }
53
- const Yr = Jr(), Ne = Yr, ve = Wt(), lt = ve(`
52
+ const Jr = Kr(), Ne = Jr, ve = jt(), ct = ve(`
54
53
  fragment UserAuthorizationFragment on UserAuthorization {
55
54
  result {
56
55
  token
57
56
  }
58
57
  }
59
- `), Kt = ve(
58
+ `), Gt = ve(
60
59
  `
61
60
  mutation Authorization($authData: UserAuthType!) {
62
61
  authorization(authData: $authData) {
@@ -64,14 +63,14 @@ const Yr = Jr(), Ne = Yr, ve = Wt(), lt = ve(`
64
63
  }
65
64
  }
66
65
  `,
67
- [lt]
68
- ), Jt = ve(`
66
+ [ct]
67
+ ), Kt = ve(`
69
68
  fragment UserFragment on UserType {
70
69
  companyInfo {
71
70
  companyId
72
71
  }
73
72
  }
74
- `), Zr = ve(
73
+ `), Yr = ve(
75
74
  `
76
75
  query CurrentUser {
77
76
  currentUser {
@@ -79,8 +78,8 @@ const Yr = Jr(), Ne = Yr, ve = Wt(), lt = ve(`
79
78
  }
80
79
  }
81
80
  `,
82
- [Jt]
83
- ), Yt = ve(`
81
+ [Kt]
82
+ ), Jt = ve(`
84
83
  fragment CompanyAddressFragment on AddressType {
85
84
  id
86
85
  firstName
@@ -100,7 +99,7 @@ const Yr = Jr(), Ne = Yr, ve = Wt(), lt = ve(`
100
99
  isBilling
101
100
  label
102
101
  }
103
- `), Xr = ve(
102
+ `), Zr = ve(
104
103
  `
105
104
  query CompanyAddressesQuery(
106
105
  $companyId: Int!
@@ -121,14 +120,14 @@ const Yr = Jr(), Ne = Yr, ve = Wt(), lt = ve(`
121
120
  }
122
121
  }
123
122
  `,
124
- [Yt]
123
+ [Jt]
125
124
  );
126
125
  ve(`
127
126
  fragment CheckoutResultFragment on CheckoutLoginResultType {
128
127
  redirectUrl
129
128
  }
130
129
  `);
131
- const en = ve(
130
+ const Xr = ve(
132
131
  `
133
132
  mutation CheckoutLoginMutation(
134
133
  $cartData: CheckoutLoginType!
@@ -140,7 +139,7 @@ const en = ve(
140
139
  }
141
140
  }
142
141
  `
143
- ), V = Wt(), Be = V(`
142
+ ), V = jt(), $e = V(`
144
143
  fragment CartFields on Cart {
145
144
  id
146
145
  entityId
@@ -215,7 +214,7 @@ const en = ve(
215
214
  utc
216
215
  }
217
216
  }
218
- `), tn = V(
217
+ `), en = V(
219
218
  `
220
219
  query GetCart($cartEntityId: String) {
221
220
  site {
@@ -225,8 +224,8 @@ const en = ve(
225
224
  }
226
225
  }
227
226
  `,
228
- [Be]
229
- ), rn = V(
227
+ [$e]
228
+ ), tn = V(
230
229
  `
231
230
  mutation CreateCart($input: CreateCartInput!) {
232
231
  cart {
@@ -238,8 +237,8 @@ const en = ve(
238
237
  }
239
238
  }
240
239
  `,
241
- [Be]
242
- ), nn = V(
240
+ [$e]
241
+ ), rn = V(
243
242
  `
244
243
  mutation AddCartLineItems($input: AddCartLineItemsInput!) {
245
244
  cart {
@@ -251,8 +250,8 @@ const en = ve(
251
250
  }
252
251
  }
253
252
  `,
254
- [Be]
255
- ), sn = V(
253
+ [$e]
254
+ ), nn = V(
256
255
  `
257
256
  mutation UpdateCartLineItem($input: UpdateCartLineItemInput!) {
258
257
  cart {
@@ -264,8 +263,8 @@ const en = ve(
264
263
  }
265
264
  }
266
265
  `,
267
- [Be]
268
- ), an = V(
266
+ [$e]
267
+ ), sn = V(
269
268
  `
270
269
  mutation DeleteCartLineItem($input: DeleteCartLineItemInput!) {
271
270
  cart {
@@ -277,8 +276,8 @@ const en = ve(
277
276
  }
278
277
  }
279
278
  `,
280
- [Be]
281
- ), on = V(`
279
+ [$e]
280
+ ), an = V(`
282
281
  mutation DeleteCart($input: DeleteCartInput!) {
283
282
  cart {
284
283
  deleteCart(input: $input) {
@@ -286,7 +285,7 @@ const en = ve(
286
285
  }
287
286
  }
288
287
  }
289
- `), cn = V(`
288
+ `), on = V(`
290
289
  mutation CreateCartRedirectUrls($input: CreateCartRedirectUrlsInput) {
291
290
  cart {
292
291
  createCartRedirectUrls(input: $input) {
@@ -296,7 +295,7 @@ const en = ve(
296
295
  }
297
296
  }
298
297
  }
299
- `), ln = V(`
298
+ `), cn = V(`
300
299
  mutation CreateCartMetafield($input: CreateCartMetafieldInput!) {
301
300
  cart {
302
301
  createCartMetafield(input: $input) {
@@ -307,7 +306,7 @@ const en = ve(
307
306
  }
308
307
  }
309
308
  }
310
- `), $e = V(`
309
+ `), Me = V(`
311
310
  fragment CheckoutFields on Checkout {
312
311
  entityId
313
312
  subtotal {
@@ -383,7 +382,7 @@ const en = ve(
383
382
  lineItemIds
384
383
  }
385
384
  }
386
- `), dn = V(
385
+ `), ln = V(
387
386
  `
388
387
  query GetCheckout($checkoutEntityId: String) {
389
388
  site {
@@ -393,8 +392,8 @@ const en = ve(
393
392
  }
394
393
  }
395
394
  `,
396
- [$e]
397
- ), un = V(
395
+ [Me]
396
+ ), dn = V(
398
397
  `
399
398
  mutation AddCheckoutShippingConsignments($input: AddCheckoutShippingConsignmentsInput!) {
400
399
  checkout {
@@ -406,8 +405,8 @@ const en = ve(
406
405
  }
407
406
  }
408
407
  `,
409
- [$e]
410
- ), pn = V(
408
+ [Me]
409
+ ), un = V(
411
410
  `
412
411
  mutation AddCheckoutBillingAddressMutation($input: AddCheckoutBillingAddressInput!) {
413
412
  checkout {
@@ -419,7 +418,7 @@ const en = ve(
419
418
  }
420
419
  }
421
420
  `,
422
- [$e]
421
+ [Me]
423
422
  );
424
423
  V(
425
424
  `
@@ -433,9 +432,9 @@ V(
433
432
  }
434
433
  }
435
434
  `,
436
- [$e]
435
+ [Me]
437
436
  );
438
- const hn = V(
437
+ const pn = V(
439
438
  `
440
439
  mutation UpdateCheckoutCustomerMessage($input: UpdateCheckoutCustomerMessageInput!) {
441
440
  checkout {
@@ -447,8 +446,8 @@ const hn = V(
447
446
  }
448
447
  }
449
448
  `,
450
- [$e]
451
- ), It = V(`
449
+ [Me]
450
+ ), vt = V(`
452
451
  query GetProductDisplayData($entityIds: [Int!], $variantEntityIds: [Int!], $first: Int = 50) {
453
452
  site {
454
453
  products(entityIds: $entityIds, first: $first) {
@@ -540,7 +539,7 @@ const hn = V(
540
539
  }
541
540
  }
542
541
  }
543
- `), fn = V(`
542
+ `), hn = V(`
544
543
  query GetVariantByOptions($productEntityId: Int!, $optionValueIds: [OptionValueId!]!) {
545
544
  site {
546
545
  product(entityId: $productEntityId) {
@@ -588,7 +587,7 @@ const hn = V(
588
587
  }
589
588
  }
590
589
  }
591
- `), mn = V(`
590
+ `), fn = V(`
592
591
  query GetProductVariantDetails($entityIds: [Int!], $first: Int = 50) {
593
592
  site {
594
593
  products(entityIds: $entityIds, first: $first) {
@@ -674,7 +673,7 @@ const hn = V(
674
673
  }
675
674
  }
676
675
  }
677
- `), Zt = V(`
676
+ `), Yt = V(`
678
677
  fragment CustomerAddressFields on CustomerAddress {
679
678
  entityId
680
679
  firstName
@@ -688,7 +687,7 @@ const hn = V(
688
687
  country
689
688
  phone
690
689
  }
691
- `), wt = V(
690
+ `), It = V(
692
691
  `
693
692
  query GetCustomerAddresses($first: Int = 50, $after: String) {
694
693
  customer {
@@ -710,8 +709,8 @@ const hn = V(
710
709
  }
711
710
  }
712
711
  `,
713
- [Zt]
714
- ), gn = V(`
712
+ [Yt]
713
+ ), mn = V(`
715
714
  query GetProductVariantsPage($entityId: Int!, $first: Int = 50, $after: String!) {
716
715
  site {
717
716
  product(entityId: $entityId) {
@@ -762,7 +761,7 @@ const hn = V(
762
761
  }
763
762
  }
764
763
  }
765
- `), yn = V(`
764
+ `), gn = V(`
766
765
  query GetProductOptionsPage($entityId: Int!, $first: Int = 50, $after: String!) {
767
766
  site {
768
767
  product(entityId: $entityId) {
@@ -799,7 +798,7 @@ const hn = V(
799
798
  }
800
799
  }
801
800
  }
802
- `), xn = V(`
801
+ `), yn = V(`
803
802
  query GetProductOptionValuesPage($entityId: Int!, $optionEntityId: Int!, $first: Int = 50, $after: String!) {
804
803
  site {
805
804
  product(entityId: $entityId) {
@@ -842,8 +841,8 @@ V(`
842
841
  }
843
842
  }
844
843
  `);
845
- function bn(t) {
846
- const e = Ee(Yt, t);
844
+ function xn(t) {
845
+ const e = Ee(Jt, t);
847
846
  return {
848
847
  source: "b2b",
849
848
  id: `${e.id}`,
@@ -864,8 +863,8 @@ function bn(t) {
864
863
  label: e.label || void 0
865
864
  };
866
865
  }
867
- function Cn(t, e = 0) {
868
- const r = Ee(Zt, t);
866
+ function bn(t, e = 0) {
867
+ const r = Ee(Yt, t);
869
868
  return {
870
869
  source: "storefront",
871
870
  id: `${r.entityId}`,
@@ -907,11 +906,11 @@ function je(t, e) {
907
906
  label: "PO Address"
908
907
  };
909
908
  }
910
- const vn = 20;
909
+ const Cn = 20;
911
910
  async function We(t, e, r, n) {
912
911
  const i = [];
913
912
  let s, o = 0;
914
- for (; o < vn; ) {
913
+ for (; o < Cn; ) {
915
914
  const c = s !== void 0 ? { ...r, after: s } : { ...r }, l = await t.request({
916
915
  document: e,
917
916
  variables: c
@@ -923,16 +922,16 @@ async function We(t, e, r, n) {
923
922
  return i;
924
923
  }
925
924
  const xe = 20;
926
- function De(t) {
927
- return Ee(Be, t);
925
+ function Re(t) {
926
+ return Ee($e, t);
928
927
  }
929
928
  function Ve(t) {
930
- return Ee($e, t);
929
+ return Ee(Me, t);
931
930
  }
932
- function In(t) {
931
+ function vn(t) {
933
932
  return t.startsWith("http://") || t.startsWith("https://") ? t : typeof window < "u" && window.location?.origin ? `${window.location.origin}${t.startsWith("/") ? "" : "/"}${t}` : t;
934
933
  }
935
- class wn {
934
+ class In {
936
935
  endpoint;
937
936
  storefrontToken;
938
937
  graphQLClient;
@@ -941,12 +940,12 @@ class wn {
941
940
  requestQueue = [];
942
941
  channelId;
943
942
  constructor(e) {
944
- this.endpoint = In(e.endpoint), this.storefrontToken = e.storefrontToken, this.channelId = e.channelId ?? 1;
943
+ this.endpoint = vn(e.endpoint), this.storefrontToken = e.storefrontToken, this.channelId = e.channelId ?? 1;
945
944
  const r = {
946
945
  "content-type": "application/json",
947
946
  accept: "application/json"
948
947
  };
949
- this.storefrontToken && (r.authorization = `Bearer ${this.storefrontToken}`), this.graphQLClient = new at(this.endpoint, {
948
+ this.storefrontToken && (r.authorization = `Bearer ${this.storefrontToken}`), this.graphQLClient = new st(this.endpoint, {
950
949
  fetch: Ne,
951
950
  credentials: "same-origin",
952
951
  headers: r
@@ -980,7 +979,7 @@ class wn {
980
979
  * These are errors like "out of stock", "invalid product", etc. that won't succeed on retry.
981
980
  */
982
981
  isGraphQLBusinessError(e) {
983
- return e instanceof _r && e.response.status === 200;
982
+ return e instanceof Rr && e.response.status === 200;
984
983
  }
985
984
  /**
986
985
  * Extract a clean error message from a GraphQL error or generic error.
@@ -1022,12 +1021,12 @@ class wn {
1022
1021
  */
1023
1022
  async getCart(e) {
1024
1023
  const n = (await this.request({
1025
- document: tn,
1024
+ document: en,
1026
1025
  variables: {
1027
1026
  cartEntityId: e
1028
1027
  }
1029
1028
  })).site.cart;
1030
- return n ? De(n) : null;
1029
+ return n ? Re(n) : null;
1031
1030
  }
1032
1031
  /**
1033
1032
  * Create a new cart with line items
@@ -1098,7 +1097,7 @@ class wn {
1098
1097
  async addBatchToCart(e, r, { retry: n = !0 } = {}) {
1099
1098
  const s = (await this.request(
1100
1099
  {
1101
- document: nn,
1100
+ document: rn,
1102
1101
  variables: {
1103
1102
  input: {
1104
1103
  cartEntityId: e,
@@ -1114,7 +1113,7 @@ class wn {
1114
1113
  },
1115
1114
  { retry: n }
1116
1115
  )).cart.addCartLineItems?.cart;
1117
- return s ? De(s) : null;
1116
+ return s ? Re(s) : null;
1118
1117
  }
1119
1118
  /**
1120
1119
  * Try to add a batch to cart, isolating failures if needed.
@@ -1155,7 +1154,7 @@ class wn {
1155
1154
  async createCartBatch(e, { retry: r = !0 } = {}) {
1156
1155
  const i = (await this.request(
1157
1156
  {
1158
- document: rn,
1157
+ document: tn,
1159
1158
  variables: {
1160
1159
  input: {
1161
1160
  lineItems: e.map((s) => ({
@@ -1168,7 +1167,7 @@ class wn {
1168
1167
  },
1169
1168
  { retry: r }
1170
1169
  )).cart.createCart?.cart;
1171
- return i ? De(i) : null;
1170
+ return i ? Re(i) : null;
1172
1171
  }
1173
1172
  /**
1174
1173
  * Try to create a cart with a batch, isolating failures if needed.
@@ -1241,7 +1240,7 @@ class wn {
1241
1240
  */
1242
1241
  async updateCartLineItem(e, r, n, i, s) {
1243
1242
  const c = (await this.request({
1244
- document: sn,
1243
+ document: nn,
1245
1244
  variables: {
1246
1245
  input: {
1247
1246
  cartEntityId: e,
@@ -1256,14 +1255,14 @@ class wn {
1256
1255
  }
1257
1256
  }
1258
1257
  })).cart.updateCartLineItem?.cart;
1259
- return c ? De(c) : null;
1258
+ return c ? Re(c) : null;
1260
1259
  }
1261
1260
  /**
1262
1261
  * Remove a line item from the cart
1263
1262
  */
1264
1263
  async deleteCartLineItem(e, r) {
1265
1264
  const i = (await this.request({
1266
- document: an,
1265
+ document: sn,
1267
1266
  variables: {
1268
1267
  input: {
1269
1268
  cartEntityId: e,
@@ -1271,14 +1270,14 @@ class wn {
1271
1270
  }
1272
1271
  }
1273
1272
  })).cart.deleteCartLineItem?.cart;
1274
- return i ? De(i) : null;
1273
+ return i ? Re(i) : null;
1275
1274
  }
1276
1275
  /**
1277
1276
  * Delete an entire cart
1278
1277
  */
1279
1278
  async deleteCart(e) {
1280
1279
  return (await this.request({
1281
- document: on,
1280
+ document: an,
1282
1281
  variables: {
1283
1282
  input: {
1284
1283
  cartEntityId: e
@@ -1300,7 +1299,7 @@ class wn {
1300
1299
  */
1301
1300
  async createCartRedirectUrls(e) {
1302
1301
  return (await this.request({
1303
- document: cn,
1302
+ document: on,
1304
1303
  variables: {
1305
1304
  input: {
1306
1305
  cartEntityId: e
@@ -1313,7 +1312,7 @@ class wn {
1313
1312
  */
1314
1313
  async createCartMetafield(e, r, n) {
1315
1314
  await this.executeWithRetry({
1316
- document: ln,
1315
+ document: cn,
1317
1316
  variables: {
1318
1317
  input: {
1319
1318
  cartEntityId: e,
@@ -1331,7 +1330,7 @@ class wn {
1331
1330
  */
1332
1331
  async getCheckout(e) {
1333
1332
  const n = (await this.request({
1334
- document: dn,
1333
+ document: ln,
1335
1334
  variables: {
1336
1335
  checkoutEntityId: e
1337
1336
  }
@@ -1344,7 +1343,7 @@ class wn {
1344
1343
  */
1345
1344
  async setCheckoutShippingAddress(e, r, n) {
1346
1345
  const s = (await this.request({
1347
- document: un,
1346
+ document: dn,
1348
1347
  variables: {
1349
1348
  input: {
1350
1349
  checkoutEntityId: e,
@@ -1367,7 +1366,7 @@ class wn {
1367
1366
  */
1368
1367
  async setCheckoutBillingAddress(e, r) {
1369
1368
  const i = (await this.request({
1370
- document: pn,
1369
+ document: un,
1371
1370
  variables: {
1372
1371
  input: {
1373
1372
  checkoutEntityId: e,
@@ -1386,7 +1385,7 @@ class wn {
1386
1385
  */
1387
1386
  async getCustomerAddresses() {
1388
1387
  const e = await this.request({
1389
- document: wt
1388
+ document: It
1390
1389
  });
1391
1390
  if (!e.customer)
1392
1391
  return {
@@ -1402,14 +1401,14 @@ class wn {
1402
1401
  if (e.customer.addresses.pageInfo.hasNextPage) {
1403
1402
  const s = await We(
1404
1403
  this,
1405
- wt,
1404
+ It,
1406
1405
  { after: e.customer.addresses.pageInfo.endCursor },
1407
1406
  (o) => o.customer?.addresses ?? null
1408
1407
  );
1409
1408
  n.push(...s);
1410
1409
  }
1411
1410
  const i = n.map(
1412
- (s, o) => Cn(s.node, o)
1411
+ (s, o) => bn(s.node, o)
1413
1412
  );
1414
1413
  return {
1415
1414
  customerInfo: r,
@@ -1425,7 +1424,7 @@ class wn {
1425
1424
  r.purchaseOrderNumber && (n += `PO Number: ${r.purchaseOrderNumber}, `), r.threadId && (n && (n += `
1426
1425
  `), n += `Thread ID: ${r.threadId}`);
1427
1426
  const s = (await this.request({
1428
- document: hn,
1427
+ document: pn,
1429
1428
  variables: {
1430
1429
  input: {
1431
1430
  checkoutEntityId: e,
@@ -1444,7 +1443,7 @@ class wn {
1444
1443
  */
1445
1444
  async getProductVariantDetails(e) {
1446
1445
  const r = await this.request({
1447
- document: mn,
1446
+ document: fn,
1448
1447
  variables: {
1449
1448
  entityIds: e
1450
1449
  }
@@ -1454,7 +1453,7 @@ class wn {
1454
1453
  if (s.variants.pageInfo.hasNextPage) {
1455
1454
  const d = await We(
1456
1455
  this,
1457
- gn,
1456
+ mn,
1458
1457
  {
1459
1458
  entityId: s.entityId,
1460
1459
  after: s.variants.pageInfo.endCursor
@@ -1467,7 +1466,7 @@ class wn {
1467
1466
  if (s.productOptions.pageInfo.hasNextPage) {
1468
1467
  const d = await We(
1469
1468
  this,
1470
- yn,
1469
+ gn,
1471
1470
  {
1472
1471
  entityId: s.entityId,
1473
1472
  after: s.productOptions.pageInfo.endCursor
@@ -1482,7 +1481,7 @@ class wn {
1482
1481
  if (p.values?.pageInfo.hasNextPage && p.values.pageInfo.endCursor) {
1483
1482
  const u = await We(
1484
1483
  this,
1485
- xn,
1484
+ yn,
1486
1485
  {
1487
1486
  entityId: s.entityId,
1488
1487
  optionEntityId: p.entityId,
@@ -1547,7 +1546,7 @@ class wn {
1547
1546
  const i = [];
1548
1547
  if (e.length <= 50) {
1549
1548
  const c = await this.request({
1550
- document: It,
1549
+ document: vt,
1551
1550
  variables: {
1552
1551
  entityIds: e,
1553
1552
  variantEntityIds: r?.length ? r : void 0
@@ -1561,7 +1560,7 @@ class wn {
1561
1560
  const o = await Promise.all(
1562
1561
  s.map(
1563
1562
  (c) => this.request({
1564
- document: It,
1563
+ document: vt,
1565
1564
  variables: {
1566
1565
  entityIds: c,
1567
1566
  variantEntityIds: r?.length ? r : void 0
@@ -1634,7 +1633,7 @@ class wn {
1634
1633
  */
1635
1634
  async getVariantByOptions(e, r) {
1636
1635
  const i = (await this.request({
1637
- document: fn,
1636
+ document: hn,
1638
1637
  variables: {
1639
1638
  productEntityId: e,
1640
1639
  optionValueIds: r
@@ -1660,33 +1659,33 @@ class wn {
1660
1659
  };
1661
1660
  }
1662
1661
  }
1663
- function Vi(t) {
1662
+ function zi(t) {
1664
1663
  return `https://store-${t}.mybigcommerce.com/graphql`;
1665
1664
  }
1666
- function Sn(t) {
1667
- return new wn(t);
1665
+ function wn(t) {
1666
+ return new In(t);
1668
1667
  }
1669
- const Re = it((t) => ({
1668
+ const _e = at((t) => ({
1670
1669
  isExpanded: !1,
1671
1670
  setExpanded: (e) => t({ isExpanded: e }),
1672
1671
  toggleExpanded: () => t((e) => ({ isExpanded: !e.isExpanded })),
1673
1672
  reset: () => t({ isExpanded: !1 })
1674
1673
  }));
1675
- function En({ children: t }) {
1676
- const e = Re((i) => i.isExpanded), r = Re((i) => i.setExpanded), n = D(null);
1674
+ function Sn({ children: t }) {
1675
+ const e = _e((i) => i.isExpanded), r = _e((i) => i.setExpanded), n = D(null);
1677
1676
  return F(() => {
1678
1677
  if (!e) return;
1679
1678
  const i = (s) => {
1680
1679
  s.key === "Escape" && r(!1);
1681
1680
  };
1682
1681
  return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
1683
- }, [e, r]), yt(() => {
1682
+ }, [e, r]), gt(() => {
1684
1683
  if (!e) return;
1685
1684
  const i = window.scrollY, s = document.body.style.overflow, o = document.body.style.position, c = document.body.style.top, l = document.body.style.width;
1686
1685
  return document.body.style.overflow = "hidden", document.body.style.position = "fixed", document.body.style.top = `-${i}px`, document.body.style.width = "100%", () => {
1687
1686
  document.body.style.overflow = s, document.body.style.position = o, document.body.style.top = c, document.body.style.width = l, window.scrollTo(0, i);
1688
1687
  };
1689
- }, [e]), yt(() => {
1688
+ }, [e]), gt(() => {
1690
1689
  if (!e || !n.current) return;
1691
1690
  const i = n.current.getRootNode();
1692
1691
  if (!(i instanceof ShadowRoot)) return;
@@ -1722,31 +1721,31 @@ function En({ children: t }) {
1722
1721
  }
1723
1722
  ) : null;
1724
1723
  }
1725
- const Nn = /* @__PURE__ */ new Set(["image/heic", "image/heif"]), kn = /* @__PURE__ */ new Set([".heic", ".heif"]);
1726
- function Pn(t) {
1724
+ const En = /* @__PURE__ */ new Set(["image/heic", "image/heif"]), Nn = /* @__PURE__ */ new Set([".heic", ".heif"]);
1725
+ function kn(t) {
1727
1726
  const e = t.lastIndexOf(".");
1728
1727
  return e === -1 ? "" : t.slice(e).toLowerCase();
1729
1728
  }
1730
- function Xt(t) {
1731
- return Nn.has(t.type) ? !0 : t.type !== "" && t.type !== "application/octet-stream" ? !1 : kn.has(Pn(t.name));
1729
+ function Zt(t) {
1730
+ return En.has(t.type) ? !0 : t.type !== "" && t.type !== "application/octet-stream" ? !1 : Nn.has(kn(t.name));
1732
1731
  }
1733
- function er(t) {
1732
+ function Xt(t) {
1734
1733
  return t.replace(/\.heic$/i, ".jpg").replace(/\.heif$/i, ".jpg");
1735
1734
  }
1736
- async function Tn(t, e) {
1735
+ async function Pn(t, e) {
1737
1736
  try {
1738
1737
  const r = await createImageBitmap(t), n = new OffscreenCanvas(r.width, r.height);
1739
1738
  n.getContext("2d").drawImage(r, 0, 0), r.close();
1740
1739
  const s = await n.convertToBlob({ type: "image/jpeg", quality: e });
1741
- return new File([s], er(t.name), { type: "image/jpeg" });
1740
+ return new File([s], Xt(t.name), { type: "image/jpeg" });
1742
1741
  } catch {
1743
1742
  return null;
1744
1743
  }
1745
1744
  }
1746
- async function An(t, e) {
1747
- const { HeifDecoder: r } = await import("libheif-js/wasm-bundle"), n = await new Promise((v, b) => {
1745
+ async function Tn(t, e) {
1746
+ const { HeifDecoder: r } = await import("libheif-js/wasm-bundle"), n = await new Promise((C, b) => {
1748
1747
  const x = new FileReader();
1749
- x.onload = () => v(new Uint8Array(x.result)), x.onerror = () => b(new Error("Failed to read file")), x.readAsArrayBuffer(t);
1748
+ x.onload = () => C(new Uint8Array(x.result)), x.onerror = () => b(new Error("Failed to read file")), x.readAsArrayBuffer(t);
1750
1749
  }), o = new r().decode(n)[0];
1751
1750
  if (!o)
1752
1751
  throw new Error("HEIF processing error");
@@ -1754,22 +1753,22 @@ async function An(t, e) {
1754
1753
  if (!p)
1755
1754
  throw new Error("Failed to get canvas context");
1756
1755
  const u = p.createImageData(c, l);
1757
- await new Promise((v, b) => {
1756
+ await new Promise((C, b) => {
1758
1757
  o.display(u, (x) => {
1759
1758
  if (!x) return b(new Error("HEIF processing error"));
1760
- v();
1759
+ C();
1761
1760
  });
1762
1761
  }), p.putImageData(u, 0, 0);
1763
1762
  const m = await d.convertToBlob({ type: "image/jpeg", quality: e });
1764
- return new File([m], er(t.name), { type: "image/jpeg" });
1763
+ return new File([m], Xt(t.name), { type: "image/jpeg" });
1765
1764
  }
1766
- async function Bn(t) {
1767
- if (!Xt(t)) return t;
1765
+ async function An(t) {
1766
+ if (!Zt(t)) return t;
1768
1767
  console.debug("heic file detected, attempting to convert");
1769
- const e = 0.9, r = await Tn(t, e);
1770
- return r ? (console.debug("native heic conversion successful"), r) : (console.debug("falling back to libheif conversion"), An(t, e));
1768
+ const e = 0.9, r = await Pn(t, e);
1769
+ return r ? (console.debug("native heic conversion successful"), r) : (console.debug("falling back to libheif conversion"), Tn(t, e));
1771
1770
  }
1772
- const tr = {
1771
+ const er = {
1773
1772
  "application/pdf": ".pdf",
1774
1773
  "text/csv": ".csv",
1775
1774
  "application/vnd.ms-excel": ".xls",
@@ -1782,9 +1781,9 @@ const tr = {
1782
1781
  "image/webp": ".webp",
1783
1782
  "image/heic": ".heic",
1784
1783
  "image/heif": ".heif"
1785
- }, $n = Object.keys(tr), Mn = Object.values(tr).flatMap(
1784
+ }, Bn = Object.keys(er), $n = Object.values(er).flatMap(
1786
1785
  (t) => t.split(",")
1787
- ), On = [
1786
+ ), Mn = [
1788
1787
  ".png",
1789
1788
  ".jpg",
1790
1789
  ".jpeg",
@@ -1797,40 +1796,40 @@ const tr = {
1797
1796
  ".tif",
1798
1797
  ".svg",
1799
1798
  ".avif"
1800
- ], rr = Mn.join(","), nr = "image/png,image/jpeg,image/gif,image/webp", Fn = "PDF, Excel, CSV, text, or image files", Dn = "PNG, JPEG, GIF, or WebP", sr = ["PDF", "Excel", "CSV", "Images"], Rn = 10 * 1024 * 1024;
1801
- function _n(t) {
1802
- if (t.size > Rn)
1799
+ ], tr = $n.join(","), rr = "image/png,image/jpeg,image/gif,image/webp", On = "PDF, Excel, CSV, text, or image files", Fn = "PNG, JPEG, GIF, or WebP", nr = ["PDF", "Excel", "CSV", "Images"], Dn = 10 * 1024 * 1024;
1800
+ function Rn(t) {
1801
+ if (t.size > Dn)
1803
1802
  return {
1804
1803
  valid: !1,
1805
1804
  error: "File size exceeds 10MB limit. Please choose a smaller file."
1806
1805
  };
1807
- if (!$n.includes(t.type)) {
1806
+ if (!Bn.includes(t.type)) {
1808
1807
  const e = t.name.includes(".") ? `.${t.name.split(".").pop()?.toLowerCase()}` : void 0;
1809
- return t.type.startsWith("image/") || e && On.includes(e) ? {
1808
+ return t.type.startsWith("image/") || e && Mn.includes(e) ? {
1810
1809
  valid: !1,
1811
- error: `Image type not supported. Please upload ${Dn} images.`
1810
+ error: `Image type not supported. Please upload ${Fn} images.`
1812
1811
  } : {
1813
1812
  valid: !1,
1814
- error: `File type not supported. Please upload ${Fn}.`
1813
+ error: `File type not supported. Please upload ${On}.`
1815
1814
  };
1816
1815
  }
1817
1816
  return { valid: !0 };
1818
1817
  }
1819
- function ar({ onFile: t, onBeforeValidate: e }) {
1818
+ function sr({ onFile: t, onBeforeValidate: e }) {
1820
1819
  const [r, n] = R(!1), [i, s] = R(null), o = D(null), c = D(null), l = M(
1821
1820
  async (x) => {
1822
1821
  e?.(), s(null);
1823
1822
  let I = x;
1824
- if (Xt(x))
1823
+ if (Zt(x))
1825
1824
  try {
1826
- I = await Bn(x);
1825
+ I = await An(x);
1827
1826
  } catch {
1828
1827
  s(
1829
1828
  "Failed to convert HEIC image. Please convert to JPEG and try again."
1830
1829
  );
1831
1830
  return;
1832
1831
  }
1833
- const w = _n(I);
1832
+ const w = Rn(I);
1834
1833
  if (!w.valid) {
1835
1834
  s(w.error ?? null);
1836
1835
  return;
@@ -1855,7 +1854,7 @@ function ar({ onFile: t, onBeforeValidate: e }) {
1855
1854
  I && l(I), x.target && (x.target.value = "");
1856
1855
  },
1857
1856
  [l]
1858
- ), v = M(() => {
1857
+ ), C = M(() => {
1859
1858
  o.current?.click();
1860
1859
  }, []), b = M(() => {
1861
1860
  c.current?.click();
@@ -1871,11 +1870,11 @@ function ar({ onFile: t, onBeforeValidate: e }) {
1871
1870
  onDrop: u
1872
1871
  },
1873
1872
  handleFileChange: m,
1874
- openFilePicker: v,
1873
+ openFilePicker: C,
1875
1874
  openCamera: b
1876
1875
  };
1877
1876
  }
1878
- const Ln = () => /* @__PURE__ */ h(
1877
+ const _n = () => /* @__PURE__ */ h(
1879
1878
  "svg",
1880
1879
  {
1881
1880
  width: "18",
@@ -1905,7 +1904,7 @@ const Ln = () => /* @__PURE__ */ h(
1905
1904
  /* @__PURE__ */ a("polyline", { points: "20 6 9 17 4 12" })
1906
1905
  ]
1907
1906
  }
1908
- ), ir = ({ size: t = 12 }) => /* @__PURE__ */ h(
1907
+ ), ar = ({ size: t = 12 }) => /* @__PURE__ */ h(
1909
1908
  "svg",
1910
1909
  {
1911
1910
  width: t,
@@ -1922,7 +1921,7 @@ const Ln = () => /* @__PURE__ */ h(
1922
1921
  /* @__PURE__ */ a("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
1923
1922
  ]
1924
1923
  }
1925
- ), or = ({ size: t = 16 }) => /* @__PURE__ */ h(
1924
+ ), ir = ({ size: t = 16 }) => /* @__PURE__ */ h(
1926
1925
  "svg",
1927
1926
  {
1928
1927
  width: t,
@@ -1941,7 +1940,7 @@ const Ln = () => /* @__PURE__ */ h(
1941
1940
  /* @__PURE__ */ a("line", { x1: "3", y1: "21", x2: "10", y2: "14" })
1942
1941
  ]
1943
1942
  }
1944
- ), cr = ({ size: t = 16 }) => /* @__PURE__ */ h(
1943
+ ), or = ({ size: t = 16 }) => /* @__PURE__ */ h(
1945
1944
  "svg",
1946
1945
  {
1947
1946
  width: t,
@@ -1960,7 +1959,7 @@ const Ln = () => /* @__PURE__ */ h(
1960
1959
  /* @__PURE__ */ a("line", { x1: "3", y1: "21", x2: "10", y2: "14" })
1961
1960
  ]
1962
1961
  }
1963
- ), Un = ({
1962
+ ), Ln = ({
1964
1963
  size: t = 12,
1965
1964
  title: e = "Error"
1966
1965
  }) => /* @__PURE__ */ h(
@@ -1979,7 +1978,7 @@ const Ln = () => /* @__PURE__ */ h(
1979
1978
  /* @__PURE__ */ a("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
1980
1979
  ]
1981
1980
  }
1982
- ), Me = ({ size: t = 12 }) => /* @__PURE__ */ h(
1981
+ ), Oe = ({ size: t = 12 }) => /* @__PURE__ */ h(
1983
1982
  "svg",
1984
1983
  {
1985
1984
  width: t,
@@ -1995,7 +1994,7 @@ const Ln = () => /* @__PURE__ */ h(
1995
1994
  ]
1996
1995
  }
1997
1996
  );
1998
- function qn({
1997
+ function Un({
1999
1998
  addresses: t,
2000
1999
  selectedAddressId: e,
2001
2000
  addressUpdateStatus: r = "idle",
@@ -2010,13 +2009,13 @@ function qn({
2010
2009
  return /* @__PURE__ */ h(
2011
2010
  "div",
2012
2011
  {
2013
- className: ke(
2012
+ className: Pe(
2014
2013
  "grid gap-2",
2015
2014
  s ? "grid-cols-2" : "grid-cols-1"
2016
2015
  ),
2017
2016
  children: [
2018
2017
  s && /* @__PURE__ */ a(
2019
- St,
2018
+ wt,
2020
2019
  {
2021
2020
  label: "Bill to",
2022
2021
  onAddressChange: l,
@@ -2030,7 +2029,7 @@ function qn({
2030
2029
  }
2031
2030
  ),
2032
2031
  /* @__PURE__ */ a(
2033
- St,
2032
+ wt,
2034
2033
  {
2035
2034
  label: "Ship to",
2036
2035
  onAddressChange: n,
@@ -2047,7 +2046,7 @@ function qn({
2047
2046
  }
2048
2047
  );
2049
2048
  }
2050
- function St(t) {
2049
+ function wt(t) {
2051
2050
  const {
2052
2051
  label: e,
2053
2052
  addresses: r,
@@ -2061,7 +2060,7 @@ function St(t) {
2061
2060
  } = t, p = n === le, u = r.find(c);
2062
2061
  let m = d && !!n && !p;
2063
2062
  m && u && (m = u.id !== n);
2064
- const v = r.filter(l);
2063
+ const C = r.filter(l);
2065
2064
  return /* @__PURE__ */ h(
2066
2065
  "div",
2067
2066
  {
@@ -2070,7 +2069,7 @@ function St(t) {
2070
2069
  /* @__PURE__ */ h("div", { className: "flex justify-between items-center mb-0.5", children: [
2071
2070
  /* @__PURE__ */ a("span", { className: "text-2xs text-text-tertiary uppercase tracking-[0.05em]", children: e }),
2072
2071
  i === "updating" && /* @__PURE__ */ h("span", { className: "flex items-center gap-1 text-2xs font-medium text-text-tertiary uppercase tracking-[0.025em]", children: [
2073
- /* @__PURE__ */ a(Me, { size: 10 }),
2072
+ /* @__PURE__ */ a(Oe, { size: 10 }),
2074
2073
  "Updating..."
2075
2074
  ] }),
2076
2075
  i === "success" && /* @__PURE__ */ h("span", { className: "flex items-center gap-0.5 text-2xs font-semibold text-success-text uppercase tracking-[0.025em]", children: [
@@ -2078,7 +2077,7 @@ function St(t) {
2078
2077
  "Updated"
2079
2078
  ] }),
2080
2079
  i === "error" && /* @__PURE__ */ h("span", { className: "flex items-center gap-0.5 text-2xs font-semibold text-error-text uppercase tracking-[0.025em]", children: [
2081
- /* @__PURE__ */ a(Un, { size: 12, title: "Failed" }),
2080
+ /* @__PURE__ */ a(Ln, { size: 12, title: "Failed" }),
2082
2081
  "Failed to update"
2083
2082
  ] })
2084
2083
  ] }),
@@ -2091,28 +2090,28 @@ function St(t) {
2091
2090
  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",
2092
2091
  children: [
2093
2092
  o && /* @__PURE__ */ h(Ce, { children: [
2094
- /* @__PURE__ */ a("option", { value: o.id, children: /* @__PURE__ */ a(Et, { address: o }) }, o.id),
2093
+ /* @__PURE__ */ a("option", { value: o.id, children: /* @__PURE__ */ a(St, { address: o }) }, o.id),
2095
2094
  /* @__PURE__ */ a("option", { disabled: !0, children: "---" })
2096
2095
  ] }),
2097
- v.map((b) => /* @__PURE__ */ a("option", { value: b.id, children: /* @__PURE__ */ a(
2098
- Et,
2096
+ C.map((b) => /* @__PURE__ */ a("option", { value: b.id, children: /* @__PURE__ */ a(
2097
+ St,
2099
2098
  {
2100
2099
  address: b,
2101
2100
  isDefault: c
2102
2101
  }
2103
2102
  ) }, b.id)),
2104
- v.length > 0 && /* @__PURE__ */ a("option", { disabled: !0, children: "---" }),
2103
+ C.length > 0 && /* @__PURE__ */ a("option", { disabled: !0, children: "---" }),
2105
2104
  /* @__PURE__ */ a("option", { value: le, children: "Enter an address at checkout" }, le)
2106
2105
  ]
2107
2106
  }
2108
2107
  ),
2109
- o && /* @__PURE__ */ a(Wn, { address: o }),
2108
+ o && /* @__PURE__ */ a(jn, { address: o }),
2110
2109
  m && /* @__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." })
2111
2110
  ]
2112
2111
  }
2113
2112
  );
2114
2113
  }
2115
- function Et(t) {
2114
+ function St(t) {
2116
2115
  const { address: e, isDefault: r } = t;
2117
2116
  return /* @__PURE__ */ h(Ce, { children: [
2118
2117
  r?.(e) ? "[DEFAULT] " : "",
@@ -2131,18 +2130,18 @@ function Et(t) {
2131
2130
  e.postalCode
2132
2131
  ] });
2133
2132
  }
2134
- function jn(t) {
2133
+ function qn(t) {
2135
2134
  const e = [t.address1];
2136
2135
  t.address2 && e.push(t.address2), t.city && e.push(t.city), t.stateOrProvince && e.push(t.stateOrProvince);
2137
2136
  const r = e.pop();
2138
2137
  return t.postalCode ? e.push(`${r} ${t.postalCode}`) : r && e.push(r), e.join(", ");
2139
2138
  }
2140
- function Wn({ address: t }) {
2139
+ function jn({ address: t }) {
2141
2140
  const [e, r] = R(!1), n = D(void 0);
2142
2141
  F(() => () => {
2143
2142
  n.current && clearTimeout(n.current);
2144
2143
  }, []);
2145
- const i = jn(t), s = M(async () => {
2144
+ const i = qn(t), s = M(async () => {
2146
2145
  try {
2147
2146
  await navigator.clipboard.writeText(i), r(!0), n.current && clearTimeout(n.current), n.current = setTimeout(() => r(!1), 1500);
2148
2147
  } catch {
@@ -2161,25 +2160,25 @@ function Wn({ address: t }) {
2161
2160
  " ",
2162
2161
  i
2163
2162
  ] }),
2164
- /* @__PURE__ */ a("span", { className: "shrink-0 mt-0.5", children: e ? /* @__PURE__ */ a(Ue, { size: 12, title: "Copied" }) : /* @__PURE__ */ a(ir, { size: 12 }) })
2163
+ /* @__PURE__ */ a("span", { className: "shrink-0 mt-0.5", children: e ? /* @__PURE__ */ a(Ue, { size: 12, title: "Copied" }) : /* @__PURE__ */ a(ar, { size: 12 }) })
2165
2164
  ]
2166
2165
  }
2167
2166
  );
2168
2167
  }
2169
- const Ae = (t, e = "USD") => new Intl.NumberFormat("en-US", {
2168
+ const Be = (t, e = "USD") => new Intl.NumberFormat("en-US", {
2170
2169
  style: "currency",
2171
2170
  currency: e
2172
2171
  }).format(t);
2173
- function et({ label: t, value: e }) {
2172
+ function Xe({ label: t, value: e }) {
2174
2173
  return /* @__PURE__ */ h("div", { className: "flex justify-between py-0.5", children: [
2175
2174
  /* @__PURE__ */ a("span", { className: "text-sm text-text-tertiary", children: t }),
2176
2175
  /* @__PURE__ */ a("span", { className: "text-sm text-text", children: e })
2177
2176
  ] });
2178
2177
  }
2179
- function tt(t, e) {
2180
- return t != null ? Ae(t, e) : "...";
2178
+ function et(t, e) {
2179
+ return t != null ? Be(t, e) : "...";
2181
2180
  }
2182
- function Vn({
2181
+ function Wn({
2183
2182
  subtotal: t,
2184
2183
  tax: e,
2185
2184
  shipping: r,
@@ -2193,23 +2192,23 @@ function Vn({
2193
2192
  }) {
2194
2193
  return /* @__PURE__ */ h("div", { className: "px-4 py-2.5 shrink-0 bg-surface-secondary", children: [
2195
2194
  /* @__PURE__ */ a(
2196
- et,
2195
+ Xe,
2197
2196
  {
2198
2197
  label: "Subtotal",
2199
- value: Ae(t, i)
2198
+ value: Be(t, i)
2200
2199
  }
2201
2200
  ),
2202
- /* @__PURE__ */ a(et, { label: "Tax", value: tt(e, i) }),
2201
+ /* @__PURE__ */ a(Xe, { label: "Tax", value: et(e, i) }),
2203
2202
  /* @__PURE__ */ a(
2204
- et,
2203
+ Xe,
2205
2204
  {
2206
2205
  label: "Shipping",
2207
- value: tt(r, i)
2206
+ value: et(r, i)
2208
2207
  }
2209
2208
  ),
2210
2209
  /* @__PURE__ */ h("div", { className: "flex justify-between mt-1 pt-1.5 border-t border-border", children: [
2211
2210
  /* @__PURE__ */ a("span", { className: "text-sm font-semibold text-text", children: "Total" }),
2212
- /* @__PURE__ */ a("span", { className: "text-sm font-semibold text-text", children: tt(n, i) })
2211
+ /* @__PURE__ */ a("span", { className: "text-sm font-semibold text-text", children: et(n, i) })
2213
2212
  ] }),
2214
2213
  /* @__PURE__ */ a(
2215
2214
  "button",
@@ -2245,7 +2244,7 @@ function Vn({
2245
2244
  )
2246
2245
  ] });
2247
2246
  }
2248
- const dt = () => /* @__PURE__ */ h(
2247
+ const lt = () => /* @__PURE__ */ h(
2249
2248
  "svg",
2250
2249
  {
2251
2250
  width: "14",
@@ -2260,8 +2259,8 @@ const dt = () => /* @__PURE__ */ h(
2260
2259
  /* @__PURE__ */ a("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
2261
2260
  ]
2262
2261
  }
2263
- ), Nt = "w-8 h-8 p-0 flex items-center justify-center bg-surface-tertiary border border-border rounded-sm text-text-tertiary cursor-pointer transition-all duration-150 hover:bg-surface-disabled hover:border-border-strong hover:text-text-secondary disabled:opacity-50 disabled:cursor-not-allowed";
2264
- function kt({
2262
+ ), Et = "w-8 h-8 p-0 flex items-center justify-center bg-surface-tertiary border border-border rounded-sm text-text-tertiary cursor-pointer transition-all duration-150 hover:bg-surface-disabled hover:border-border-strong hover:text-text-secondary disabled:opacity-50 disabled:cursor-not-allowed";
2263
+ function Nt({
2265
2264
  children: t,
2266
2265
  className: e,
2267
2266
  ...r
@@ -2270,13 +2269,13 @@ function kt({
2270
2269
  "button",
2271
2270
  {
2272
2271
  type: "button",
2273
- className: e ? ke(Nt, e) : Nt,
2272
+ className: e ? Pe(Et, e) : Et,
2274
2273
  ...r,
2275
2274
  children: t
2276
2275
  }
2277
2276
  );
2278
2277
  }
2279
- function lr({
2278
+ function cr({
2280
2279
  value: t,
2281
2280
  onChange: e,
2282
2281
  min: r = 1,
@@ -2309,7 +2308,7 @@ function lr({
2309
2308
  e(A);
2310
2309
  }
2311
2310
  }
2312
- }, v = async () => {
2311
+ }, C = async () => {
2313
2312
  const N = Number.parseInt(c, 10);
2314
2313
  if (s)
2315
2314
  if (!Number.isNaN(N) && N >= r && N !== t) {
@@ -2351,7 +2350,7 @@ function lr({
2351
2350
  }, I = t <= r, w = n !== void 0 && t >= n, k = d === "saving";
2352
2351
  return /* @__PURE__ */ h("span", { className: `inline-flex items-center gap-0.5 ${i}`, children: [
2353
2352
  /* @__PURE__ */ a(
2354
- kt,
2353
+ Nt,
2355
2354
  {
2356
2355
  onClick: () => x(-1),
2357
2356
  disabled: I || k,
@@ -2380,14 +2379,14 @@ function lr({
2380
2379
  value: c,
2381
2380
  disabled: k,
2382
2381
  onChange: m,
2383
- onBlur: v,
2382
+ onBlur: C,
2384
2383
  onKeyDown: b,
2385
2384
  "data-testid": o,
2386
2385
  className: `w-8 h-8 px-0.5 py-0.5 text-xs text-center focus:outline-none focus:border-border-focus text-text border border-solid ${k ? "border-border bg-surface-tertiary opacity-60" : "border-border"}`
2387
2386
  }
2388
2387
  ),
2389
2388
  /* @__PURE__ */ a(
2390
- kt,
2389
+ Nt,
2391
2390
  {
2392
2391
  onClick: () => x(1),
2393
2392
  disabled: w || k,
@@ -2410,12 +2409,12 @@ function lr({
2410
2409
  )
2411
2410
  }
2412
2411
  ),
2413
- k && /* @__PURE__ */ a("span", { className: "text-text-tertiary ml-0.5", children: /* @__PURE__ */ a(Me, {}) }),
2412
+ k && /* @__PURE__ */ a("span", { className: "text-text-tertiary ml-0.5", children: /* @__PURE__ */ a(Oe, {}) }),
2414
2413
  d === "success" && /* @__PURE__ */ a("span", { className: "text-success ml-0.5", children: /* @__PURE__ */ a(Ue, {}) }),
2415
2414
  d === "error" && /* @__PURE__ */ a("span", { className: "text-error text-xs ml-0.5", children: "Failed" })
2416
2415
  ] });
2417
2416
  }
2418
- function zn(t) {
2417
+ function Vn(t) {
2419
2418
  const {
2420
2419
  item: e,
2421
2420
  onUpdateQuantity: r,
@@ -2452,7 +2451,7 @@ function zn(t) {
2452
2451
  ] }),
2453
2452
  /* @__PURE__ */ h("div", { className: "flex items-center gap-2 shrink-0", children: [
2454
2453
  /* @__PURE__ */ a(
2455
- lr,
2454
+ cr,
2456
2455
  {
2457
2456
  value: e.quantity,
2458
2457
  onChange: (p) => r(e.id, p),
@@ -2467,7 +2466,7 @@ function zn(t) {
2467
2466
  onClick: () => n(e.id),
2468
2467
  className: "p-2 text-text-quaternary hover:text-text-secondary shrink-0",
2469
2468
  "aria-label": "Remove item",
2470
- children: /* @__PURE__ */ a(dt, {})
2469
+ children: /* @__PURE__ */ a(lt, {})
2471
2470
  }
2472
2471
  )
2473
2472
  ] })
@@ -2480,10 +2479,10 @@ function zn(t) {
2480
2479
  d ? "Catalog price lower" : "Catalog price higher",
2481
2480
  " · ",
2482
2481
  "PO: ",
2483
- Ae(o, e.poPriceCurrencyCode),
2482
+ Be(o, e.poPriceCurrencyCode),
2484
2483
  " → Catalog:",
2485
2484
  " ",
2486
- Ae(e.price ?? 0, e.catalogPriceCurrencyCode)
2485
+ Be(e.price ?? 0, e.catalogPriceCurrencyCode)
2487
2486
  ] })
2488
2487
  }
2489
2488
  ),
@@ -2491,12 +2490,12 @@ function zn(t) {
2491
2490
  e.status === "pending" && /* @__PURE__ */ a("span", { className: "inline-block text-xs font-medium px-1.5 py-0.5 rounded mt-1 bg-warning/20 text-warning-text", children: "Pending" }),
2492
2491
  /* @__PURE__ */ h("div", { className: "flex items-center justify-between mt-2", children: [
2493
2492
  /* @__PURE__ */ a("div", { className: "flex items-center gap-1.5", children: /* @__PURE__ */ a(
2494
- Hn,
2493
+ zn,
2495
2494
  {
2496
2495
  onClick: () => i(e.name, e.sku)
2497
2496
  }
2498
2497
  ) }),
2499
- e.price !== void 0 && /* @__PURE__ */ a("span", { className: "text-sm font-semibold text-text", children: Ae(
2498
+ e.price !== void 0 && /* @__PURE__ */ a("span", { className: "text-sm font-semibold text-text", children: Be(
2500
2499
  e.price * e.quantity,
2501
2500
  e.catalogPriceCurrencyCode
2502
2501
  ) })
@@ -2504,7 +2503,7 @@ function zn(t) {
2504
2503
  ] })
2505
2504
  ] });
2506
2505
  }
2507
- function Hn(t) {
2506
+ function zn(t) {
2508
2507
  return /* @__PURE__ */ a(
2509
2508
  "button",
2510
2509
  {
@@ -2515,8 +2514,8 @@ function Hn(t) {
2515
2514
  }
2516
2515
  );
2517
2516
  }
2518
- const Pt = "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";
2519
- function _e({
2517
+ const kt = "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";
2518
+ function Le({
2520
2519
  children: t,
2521
2520
  className: e,
2522
2521
  ...r
@@ -2525,13 +2524,13 @@ function _e({
2525
2524
  "button",
2526
2525
  {
2527
2526
  type: "button",
2528
- className: e ? ke(Pt, e) : Pt,
2527
+ className: e ? Pe(kt, e) : kt,
2529
2528
  ...r,
2530
2529
  children: t
2531
2530
  }
2532
2531
  );
2533
2532
  }
2534
- function dr({ onNewOrder: t }) {
2533
+ function lr({ onNewOrder: t }) {
2535
2534
  const [e, r] = R(!1), [n, i] = R(!1), s = D(!0), o = D(
2536
2535
  void 0
2537
2536
  ), c = () => {
@@ -2584,7 +2583,7 @@ function dr({ onNewOrder: t }) {
2584
2583
  children: "No"
2585
2584
  }
2586
2585
  )
2587
- ] }) : /* @__PURE__ */ h(_e, { onClick: c, title: "Start a new order", children: [
2586
+ ] }) : /* @__PURE__ */ h(Le, { onClick: c, title: "Start a new order", children: [
2588
2587
  /* @__PURE__ */ a(
2589
2588
  "svg",
2590
2589
  {
@@ -2601,7 +2600,7 @@ function dr({ onNewOrder: t }) {
2601
2600
  "New Order"
2602
2601
  ] });
2603
2602
  }
2604
- const Qn = () => /* @__PURE__ */ h(
2603
+ const Hn = () => /* @__PURE__ */ h(
2605
2604
  "svg",
2606
2605
  {
2607
2606
  width: "48",
@@ -2621,7 +2620,7 @@ const Qn = () => /* @__PURE__ */ h(
2621
2620
  ]
2622
2621
  }
2623
2622
  );
2624
- function Gn({
2623
+ function Qn({
2625
2624
  className: t = "",
2626
2625
  isDragging: e = !1,
2627
2626
  onNewOrder: r,
@@ -2632,25 +2631,25 @@ function Gn({
2632
2631
  return /* @__PURE__ */ h(
2633
2632
  "div",
2634
2633
  {
2635
- className: ke(
2634
+ className: Pe(
2636
2635
  "rounded-lg flex flex-col h-full bg-surface-secondary relative transition-colors duration-200",
2637
2636
  e && "bg-surface-tertiary",
2638
2637
  t
2639
2638
  ),
2640
2639
  children: [
2641
2640
  s && /* @__PURE__ */ h("div", { className: "absolute top-0 right-0 px-4 py-3 z-10 flex items-center gap-2", children: [
2642
- r && /* @__PURE__ */ a(dr, { onNewOrder: r }),
2643
- n && /* @__PURE__ */ h(_e, { onClick: n, "aria-label": "Expand", children: [
2644
- /* @__PURE__ */ a(or, { size: 14 }),
2641
+ r && /* @__PURE__ */ a(lr, { onNewOrder: r }),
2642
+ n && /* @__PURE__ */ h(Le, { onClick: n, "aria-label": "Expand", children: [
2643
+ /* @__PURE__ */ a(ir, { size: 14 }),
2645
2644
  "Expand"
2646
2645
  ] }),
2647
- i && /* @__PURE__ */ h(_e, { onClick: i, "aria-label": "Minimize", children: [
2648
- /* @__PURE__ */ a(cr, { size: 14 }),
2646
+ i && /* @__PURE__ */ h(Le, { onClick: i, "aria-label": "Minimize", children: [
2647
+ /* @__PURE__ */ a(or, { size: 14 }),
2649
2648
  "Minimize"
2650
2649
  ] })
2651
2650
  ] }),
2652
2651
  /* @__PURE__ */ h("div", { className: "flex flex-col flex-1 items-center justify-center gap-4 py-3 px-8", children: [
2653
- /* @__PURE__ */ a("div", { className: "flex items-center justify-center w-16 h-16 rounded-2xl p-1 text-text", children: /* @__PURE__ */ a(Qn, {}) }),
2652
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-center w-16 h-16 rounded-2xl p-1 text-text", children: /* @__PURE__ */ a(Hn, {}) }),
2654
2653
  /* @__PURE__ */ a("h3", { className: "m-0 text-base font-semibold text-text", children: "Your cart will appear here" }),
2655
2654
  /* @__PURE__ */ a("div", { className: "h-[50px]", "aria-hidden": "true" })
2656
2655
  ] }),
@@ -2659,11 +2658,11 @@ function Gn({
2659
2658
  }
2660
2659
  );
2661
2660
  }
2662
- const ur = {
2661
+ const dr = {
2663
2662
  pendingMessage: null,
2664
2663
  shouldScroll: !0
2665
- }, Kn = (t) => ({
2666
- ai: { ...ur },
2664
+ }, Gn = (t) => ({
2665
+ ai: { ...dr },
2667
2666
  sendMessage: (e, r) => t(
2668
2667
  (n) => ({
2669
2668
  ai: {
@@ -2690,7 +2689,7 @@ const ur = {
2690
2689
  toolCalls: [],
2691
2690
  revealedCount: 0,
2692
2691
  threadIds: []
2693
- }, Jn = (t) => ({
2692
+ }, Kn = (t) => ({
2694
2693
  batchProcessing: { ...Ge },
2695
2694
  setBatchProcessingStatus: (e) => t(
2696
2695
  (r) => ({ batchProcessing: { ...r.batchProcessing, status: e } }),
@@ -2748,14 +2747,14 @@ const ur = {
2748
2747
  !1,
2749
2748
  "batchProcessing/reset"
2750
2749
  )
2751
- }), Tt = {
2750
+ }), Pt = {
2752
2751
  bcCart: null,
2753
2752
  checkout: null,
2754
2753
  isLoading: !1,
2755
2754
  productCache: {},
2756
2755
  variantCache: {}
2757
- }, Yn = (t, e) => ({
2758
- bcSession: { ...Tt },
2756
+ }, Jn = (t, e) => ({
2757
+ bcSession: { ...Pt },
2759
2758
  setBcCart: (r) => t(
2760
2759
  (n) => ({ bcSession: { ...n.bcSession, bcCart: r } }),
2761
2760
  !1,
@@ -2809,15 +2808,15 @@ const ur = {
2809
2808
  "bcSession/cacheVariant"
2810
2809
  ),
2811
2810
  clearBcSession: () => t(
2812
- () => ({ bcSession: { ...Tt } }),
2811
+ () => ({ bcSession: { ...Pt } }),
2813
2812
  !1,
2814
2813
  "bcSession/clearBcSession"
2815
2814
  )
2816
2815
  });
2817
- function At(t, e) {
2816
+ function Tt(t, e) {
2818
2817
  return `${t}-${e}`;
2819
2818
  }
2820
- const pr = {
2819
+ const ur = {
2821
2820
  cartEntityId: null,
2822
2821
  poItemPrices: {},
2823
2822
  orderId: null,
@@ -2826,8 +2825,8 @@ const pr = {
2826
2825
  billingAddress: null,
2827
2826
  poMetadataSet: !1,
2828
2827
  itemWarnings: []
2829
- }, Zn = (t) => ({
2830
- cartifact: { ...pr },
2828
+ }, Yn = (t) => ({
2829
+ cartifact: { ...ur },
2831
2830
  setCartEntityId: (e) => t(
2832
2831
  (r) => ({ cartifact: { ...r.cartifact, cartEntityId: e } }),
2833
2832
  !1,
@@ -2839,7 +2838,7 @@ const pr = {
2839
2838
  ...s.cartifact,
2840
2839
  poItemPrices: {
2841
2840
  ...s.cartifact.poItemPrices,
2842
- [At(e, r)]: {
2841
+ [Tt(e, r)]: {
2843
2842
  productEntityId: e,
2844
2843
  variantEntityId: r,
2845
2844
  poPrice: n,
@@ -2854,7 +2853,7 @@ const pr = {
2854
2853
  removePoItemPrice: (e, r) => t(
2855
2854
  (n) => {
2856
2855
  const i = { ...n.cartifact.poItemPrices };
2857
- return delete i[At(e, r)], { cartifact: { ...n.cartifact, poItemPrices: i } };
2856
+ return delete i[Tt(e, r)], { cartifact: { ...n.cartifact, poItemPrices: i } };
2858
2857
  },
2859
2858
  !1,
2860
2859
  "cartifact/removePoItemPrice"
@@ -2957,13 +2956,13 @@ const pr = {
2957
2956
  !1,
2958
2957
  "cartifact/applyPoMetadata"
2959
2958
  )
2960
- }), Xn = {
2959
+ }), Zn = {
2961
2960
  messages: [],
2962
2961
  input: "",
2963
2962
  threadId: null,
2964
2963
  toolCallErrors: {}
2965
- }, es = (t) => ({
2966
- chat: { ...Xn },
2964
+ }, Xn = (t) => ({
2965
+ chat: { ...Zn },
2967
2966
  setMessages: (e) => t(
2968
2967
  (r) => ({ chat: { ...r.chat, messages: e } }),
2969
2968
  !1,
@@ -3012,11 +3011,11 @@ const pr = {
3012
3011
  !1,
3013
3012
  "chat/clearChat"
3014
3013
  )
3015
- }), ts = {
3014
+ }), es = {
3016
3015
  customerInfo: null,
3017
3016
  customerAddresses: []
3018
- }, rs = (t) => ({
3019
- customer: { ...ts },
3017
+ }, ts = (t) => ({
3018
+ customer: { ...es },
3020
3019
  setCustomerInfo: (e) => {
3021
3020
  t(
3022
3021
  (r) => ({
@@ -3034,13 +3033,13 @@ const pr = {
3034
3033
  !1,
3035
3034
  "customer/setCustomerAddresses"
3036
3035
  )
3037
- }), hr = {
3036
+ }), pr = {
3038
3037
  uploadedFileName: null,
3039
3038
  parsedContent: null,
3040
3039
  hasProcessedDocument: !1,
3041
3040
  threadId: null
3042
- }, ns = (t) => ({
3043
- parser: { ...hr },
3041
+ }, rs = (t) => ({
3042
+ parser: { ...pr },
3044
3043
  setUploadedFileName: (e) => t(
3045
3044
  (r) => ({ parser: { ...r.parser, uploadedFileName: e } }),
3046
3045
  !1,
@@ -3074,15 +3073,15 @@ const pr = {
3074
3073
  !1,
3075
3074
  "parser/clearParser"
3076
3075
  )
3077
- }), ss = {
3076
+ }), ns = {
3078
3077
  projectId: "",
3079
3078
  apiKey: "",
3080
3079
  origin: "",
3081
3080
  sseOrigin: ""
3082
- }, as = (t) => ({
3083
- takeshapeConfig: { ...ss },
3081
+ }, ss = (t) => ({
3082
+ takeshapeConfig: { ...ns },
3084
3083
  setTakeShapeConfig: (e) => t({ takeshapeConfig: e }, !1, "setTakeShapeConfig")
3085
- }), is = {
3084
+ }), as = {
3086
3085
  initStatus: "pending",
3087
3086
  initError: null,
3088
3087
  existingCart: null,
@@ -3091,8 +3090,8 @@ const pr = {
3091
3090
  addressUpdateStatus: "idle",
3092
3091
  selectedBillingAddressId: null,
3093
3092
  billingAddressUpdateStatus: "idle"
3094
- }, os = (t) => ({
3095
- ui: { ...is },
3093
+ }, is = (t) => ({
3094
+ ui: { ...as },
3096
3095
  toggleMessageExpanded: (e) => t(
3097
3096
  (r) => {
3098
3097
  const n = r.ui.expandedMessageIds, i = n.includes(e);
@@ -3140,12 +3139,12 @@ const pr = {
3140
3139
  "ui/clearAddressSelections"
3141
3140
  )
3142
3141
  });
3143
- function cs() {
3142
+ function os() {
3144
3143
  return {
3145
3144
  appState: "upload",
3146
3145
  customerEntityId: null,
3147
3146
  fatalError: null,
3148
- ai: { ...ur },
3147
+ ai: { ...dr },
3149
3148
  chat: {
3150
3149
  messages: [],
3151
3150
  input: "",
@@ -3192,20 +3191,20 @@ function cs() {
3192
3191
  batchProcessing: { ...Ge }
3193
3192
  };
3194
3193
  }
3195
- const g = it()(
3196
- Hr(
3197
- Ht(
3194
+ const g = at()(
3195
+ zr(
3196
+ zt(
3198
3197
  (t, e) => ({
3199
3198
  // Combine all slices
3200
- ...Kn(t),
3201
- ...es(t),
3202
- ...Zn(t),
3203
- ...rs(t),
3199
+ ...Gn(t),
3200
+ ...Xn(t),
3204
3201
  ...Yn(t),
3205
- ...ns(t),
3206
- ...os(t),
3202
+ ...ts(t),
3207
3203
  ...Jn(t),
3208
- ...as(t),
3204
+ ...rs(t),
3205
+ ...is(t),
3206
+ ...Kn(t),
3207
+ ...ss(t),
3209
3208
  // Top-level state
3210
3209
  appState: "upload",
3211
3210
  customerEntityId: null,
@@ -3276,7 +3275,7 @@ const g = it()(
3276
3275
  failValidation: (r) => {
3277
3276
  t(
3278
3277
  {
3279
- ...cs(),
3278
+ ...os(),
3280
3279
  appState: "upload",
3281
3280
  ui: {
3282
3281
  initStatus: "ready",
@@ -3328,11 +3327,11 @@ const g = it()(
3328
3327
  toolCallErrors: r.chat?.toolCallErrors ?? {}
3329
3328
  },
3330
3329
  cartifact: {
3331
- ...pr,
3330
+ ...ur,
3332
3331
  ...r.cartifact
3333
3332
  },
3334
3333
  parser: {
3335
- ...hr,
3334
+ ...pr,
3336
3335
  ...r.parser ?? {}
3337
3336
  },
3338
3337
  batchProcessing: {
@@ -3346,8 +3345,8 @@ const g = it()(
3346
3345
  }
3347
3346
  }),
3348
3347
  {
3349
- name: ct,
3350
- version: Gt,
3348
+ name: ot,
3349
+ version: Qt,
3351
3350
  partialize: (t) => ({
3352
3351
  // Persist customer ID for validation
3353
3352
  customerEntityId: t.customerEntityId,
@@ -3385,10 +3384,10 @@ const g = it()(
3385
3384
  }
3386
3385
  )
3387
3386
  );
3388
- function rt({ productName: t, productSku: e }) {
3387
+ function tt({ productName: t, productSku: e }) {
3389
3388
  return t && e ? `${t} (${e})` : t || e || "Unknown Product";
3390
3389
  }
3391
- function ls({
3390
+ function cs({
3392
3391
  item: t,
3393
3392
  onSuggestAlternatives: e
3394
3393
  }) {
@@ -3400,7 +3399,7 @@ function ls({
3400
3399
  /* @__PURE__ */ h("div", { className: "flex-1 min-w-0", children: [
3401
3400
  /* @__PURE__ */ h("div", { className: "flex items-start justify-between gap-2", children: [
3402
3401
  /* @__PURE__ */ h("div", { className: "flex-1 min-w-0", children: [
3403
- (t.productName || t.productSku) && /* @__PURE__ */ a("p", { className: "text-sm font-medium text-text-secondary m-0 truncate", children: rt(t) }),
3402
+ (t.productName || t.productSku) && /* @__PURE__ */ a("p", { className: "text-sm font-medium text-text-secondary m-0 truncate", children: tt(t) }),
3404
3403
  /* @__PURE__ */ a("div", { className: "flex items-center gap-1.5 mt-1", children: /* @__PURE__ */ h("span", { className: "inline-flex items-center gap-1 text-2xs font-medium px-1.5 py-0.5 rounded bg-surface-tertiary text-text-secondary", children: [
3405
3404
  /* @__PURE__ */ a("span", { className: "w-1.5 h-1.5 bg-text-secondary rounded-full animate-pulse" }),
3406
3405
  t.status
@@ -3413,7 +3412,7 @@ function ls({
3413
3412
  onClick: () => r(t),
3414
3413
  className: "p-1 text-text-quaternary hover:text-text-secondary shrink-0",
3415
3414
  "aria-label": "Dismiss warning",
3416
- children: /* @__PURE__ */ a(dt, {})
3415
+ children: /* @__PURE__ */ a(lt, {})
3417
3416
  }
3418
3417
  )
3419
3418
  ] }),
@@ -3421,7 +3420,7 @@ function ls({
3421
3420
  "button",
3422
3421
  {
3423
3422
  type: "button",
3424
- onClick: () => e(rt(t)),
3423
+ onClick: () => e(tt(t)),
3425
3424
  className: "text-xs px-1.5 py-1 rounded text-warning-text bg-warning/20 hover:bg-warning/30",
3426
3425
  children: "Suggest alternatives"
3427
3426
  }
@@ -3429,7 +3428,7 @@ function ls({
3429
3428
  ] })
3430
3429
  ] });
3431
3430
  }
3432
- function ds({
3431
+ function ls({
3433
3432
  items: t,
3434
3433
  itemWarnings: e = [],
3435
3434
  onUpdateQuantity: r,
@@ -3443,7 +3442,7 @@ function ds({
3443
3442
  addresses: p = [],
3444
3443
  selectedAddressId: u,
3445
3444
  addressUpdateStatus: m,
3446
- onAddressChange: v,
3445
+ onAddressChange: C,
3447
3446
  selectedBillingAddressId: b,
3448
3447
  billingAddressUpdateStatus: x,
3449
3448
  onBillingAddressChange: I,
@@ -3468,7 +3467,7 @@ function ds({
3468
3467
  (L) => L.catalogPriceCurrencyCode
3469
3468
  )?.catalogPriceCurrencyCode, q = N?.tax, oe = N?.shipping, Ie = N?.grandTotal ?? (q !== null ? ie + (q ?? 0) + (oe ?? 0) : null);
3470
3469
  return t.length === 0 && e.length === 0 && !y ? /* @__PURE__ */ a(
3471
- Gn,
3470
+ Qn,
3472
3471
  {
3473
3472
  className: l,
3474
3473
  isDragging: A,
@@ -3488,13 +3487,13 @@ function ds({
3488
3487
  /* @__PURE__ */ h("div", { className: "flex items-center justify-between mb-2", children: [
3489
3488
  /* @__PURE__ */ a("h2", { className: "text-lg font-normal text-text m-0", children: "Cart" }),
3490
3489
  /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
3491
- $ && /* @__PURE__ */ a(dr, { onNewOrder: $ }),
3492
- B && /* @__PURE__ */ h(_e, { onClick: B, "aria-label": "Expand", children: [
3493
- /* @__PURE__ */ a(or, { size: 14 }),
3490
+ $ && /* @__PURE__ */ a(lr, { onNewOrder: $ }),
3491
+ B && /* @__PURE__ */ h(Le, { onClick: B, "aria-label": "Expand", children: [
3492
+ /* @__PURE__ */ a(ir, { size: 14 }),
3494
3493
  "Expand"
3495
3494
  ] }),
3496
- Q && /* @__PURE__ */ h(_e, { onClick: Q, "aria-label": "Minimize", children: [
3497
- /* @__PURE__ */ a(cr, { size: 14 }),
3495
+ Q && /* @__PURE__ */ h(Le, { onClick: Q, "aria-label": "Minimize", children: [
3496
+ /* @__PURE__ */ a(or, { size: 14 }),
3498
3497
  "Minimize"
3499
3498
  ] })
3500
3499
  ] })
@@ -3511,7 +3510,7 @@ function ds({
3511
3510
  title: te ? "Copied!" : "Copy PO Number",
3512
3511
  children: [
3513
3512
  d,
3514
- /* @__PURE__ */ a("span", { className: "text-text-tertiary", children: te ? /* @__PURE__ */ a(Ue, { size: 12, title: "Copied" }) : /* @__PURE__ */ a(ir, { size: 12 }) })
3513
+ /* @__PURE__ */ a("span", { className: "text-text-tertiary", children: te ? /* @__PURE__ */ a(Ue, { size: 12, title: "Copied" }) : /* @__PURE__ */ a(ar, { size: 12 }) })
3515
3514
  ]
3516
3515
  }
3517
3516
  )
@@ -3522,12 +3521,12 @@ function ds({
3522
3521
  ] })
3523
3522
  ] }),
3524
3523
  /* @__PURE__ */ a(
3525
- qn,
3524
+ Un,
3526
3525
  {
3527
3526
  addresses: p,
3528
3527
  selectedAddressId: u,
3529
3528
  addressUpdateStatus: m,
3530
- onAddressChange: v,
3529
+ onAddressChange: C,
3531
3530
  selectedBillingAddressId: b,
3532
3531
  billingAddressUpdateStatus: x,
3533
3532
  onBillingAddressChange: I,
@@ -3539,22 +3538,22 @@ function ds({
3539
3538
  /* @__PURE__ */ a("div", { className: "h-px shrink-0 bg-border" }),
3540
3539
  /* @__PURE__ */ a("div", { className: "flex-1 min-h-0 overflow-y-auto flex flex-col", children: /* @__PURE__ */ h("div", { className: "flex-1 min-h-0 overflow-y-auto p-2 bg-surface", children: [
3541
3540
  t.length === 0 && e.length === 0 && /* @__PURE__ */ h("div", { className: "flex flex-col items-center justify-center h-full text-center", children: [
3542
- /* @__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(Ln, {}) }),
3541
+ /* @__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(_n, {}) }),
3543
3542
  /* @__PURE__ */ a("p", { className: "text-sm text-text-quaternary m-0", children: "No items in cart yet" })
3544
3543
  ] }),
3545
3544
  e.length > 0 && /* @__PURE__ */ h(Ce, { children: [
3546
3545
  e.map((L) => /* @__PURE__ */ a(
3547
- ls,
3546
+ cs,
3548
3547
  {
3549
3548
  item: L,
3550
3549
  onSuggestAlternatives: (W) => s(W)
3551
3550
  },
3552
- `${rt(L)}-${L.status}`
3551
+ `${tt(L)}-${L.status}`
3553
3552
  )),
3554
3553
  t.length > 0 && /* @__PURE__ */ a("div", { className: "border-b border-border mb-2" })
3555
3554
  ] }),
3556
3555
  t.map((L) => /* @__PURE__ */ a(
3557
- zn,
3556
+ Vn,
3558
3557
  {
3559
3558
  item: L,
3560
3559
  onUpdateQuantity: r,
@@ -3567,7 +3566,7 @@ function ds({
3567
3566
  ] }) }),
3568
3567
  /* @__PURE__ */ a("div", { className: "h-px shrink-0 bg-border" }),
3569
3568
  /* @__PURE__ */ a(
3570
- Vn,
3569
+ Wn,
3571
3570
  {
3572
3571
  subtotal: ie,
3573
3572
  tax: q,
@@ -3585,7 +3584,7 @@ function ds({
3585
3584
  }
3586
3585
  );
3587
3586
  }
3588
- const us = [
3587
+ const ds = [
3589
3588
  "failed to fetch",
3590
3589
  "networkerror",
3591
3590
  "network request failed",
@@ -3594,16 +3593,16 @@ const us = [
3594
3593
  "net::err_internet_disconnected",
3595
3594
  "net::err_network_changed"
3596
3595
  ];
3597
- function ps(t) {
3596
+ function us(t) {
3598
3597
  if (typeof navigator < "u" && !navigator.onLine)
3599
3598
  return !0;
3600
3599
  const e = t.message.toLowerCase();
3601
- return us.some((r) => e.includes(r));
3600
+ return ds.some((r) => e.includes(r));
3602
3601
  }
3603
- function hs({ error: t, onRetry: e }) {
3602
+ function ps({ error: t, onRetry: e }) {
3604
3603
  if (!t)
3605
3604
  return null;
3606
- const r = ps(t);
3605
+ const r = us(t);
3607
3606
  return /* @__PURE__ */ h("div", { className: "mx-4 my-3 px-4 py-3 bg-error-bg border border-error/30 rounded-lg", children: [
3608
3607
  /* @__PURE__ */ a("p", { className: "text-sm text-error-text", children: r ? "You're offline. Please check your internet connection and try again." : "Something went wrong. Please try again." }),
3609
3608
  e && /* @__PURE__ */ a(
@@ -3617,7 +3616,7 @@ function hs({ error: t, onRetry: e }) {
3617
3616
  )
3618
3617
  ] });
3619
3618
  }
3620
- const fs = () => /* @__PURE__ */ h(
3619
+ const hs = () => /* @__PURE__ */ h(
3621
3620
  "svg",
3622
3621
  {
3623
3622
  width: "18",
@@ -3633,7 +3632,7 @@ const fs = () => /* @__PURE__ */ h(
3633
3632
  ]
3634
3633
  }
3635
3634
  );
3636
- function ms({
3635
+ function fs({
3637
3636
  input: t,
3638
3637
  onInputChange: e,
3639
3638
  onSubmit: r,
@@ -3670,28 +3669,28 @@ function ms({
3670
3669
  className: "w-10 h-10 mr-1.5 border-none rounded-lg bg-surface-invert text-text-invert cursor-pointer flex items-center justify-center transition-colors shrink-0 hover:bg-surface-invert-hover disabled:bg-surface-disabled disabled:cursor-not-allowed",
3671
3670
  disabled: !t.trim() || n,
3672
3671
  "aria-label": "Send message",
3673
- children: /* @__PURE__ */ a(fs, {})
3672
+ children: /* @__PURE__ */ a(hs, {})
3674
3673
  }
3675
3674
  )
3676
3675
  ]
3677
3676
  }
3678
3677
  ) });
3679
3678
  }
3680
- const fr = "showProducts", gs = "searchProducts", ys = "searchProductsFromChat", xs = "searchProductsBySku", Oe = "addToCart", mr = "updateCart", gr = "removeFromCart", yr = "clearCart", xr = "getCart", ut = "getPurchaseOrderData", Ye = "setPoMetadata", br = "setItemWarnings", Cr = "removeItemWarnings", pt = "addProcessingFailures", bs = /* @__PURE__ */ new Set([fr]);
3681
- function Cs(t) {
3682
- return t.type === "tool" && !bs.has(t.toolName);
3679
+ const hr = "showProducts", ms = "searchProducts", gs = "searchProductsFromChat", ys = "searchProductsBySku", Fe = "addToCart", fr = "updateCart", mr = "removeFromCart", gr = "clearCart", yr = "getCart", dt = "getPurchaseOrderData", Ye = "setPoMetadata", xr = "setItemWarnings", br = "removeItemWarnings", ut = "addProcessingFailures", xs = /* @__PURE__ */ new Set([hr]);
3680
+ function bs(t) {
3681
+ return t.type === "tool" && !xs.has(t.toolName);
3683
3682
  }
3684
- function vs(t) {
3683
+ function Cs(t) {
3685
3684
  const e = [];
3686
3685
  let r = [];
3687
3686
  function n() {
3688
3687
  r.length >= 2 ? e.push({ type: "tool-group", tools: r }) : r.length === 1 && e.push(r[0]), r = [];
3689
3688
  }
3690
3689
  for (const i of t)
3691
- Cs(i) ? r.push(i) : (n(), e.push(i));
3690
+ bs(i) ? r.push(i) : (n(), e.push(i));
3692
3691
  return n(), e;
3693
3692
  }
3694
- const Bt = () => /* @__PURE__ */ h(
3693
+ const At = () => /* @__PURE__ */ h(
3695
3694
  "svg",
3696
3695
  {
3697
3696
  width: "14",
@@ -3706,7 +3705,7 @@ const Bt = () => /* @__PURE__ */ h(
3706
3705
  /* @__PURE__ */ a("polyline", { points: "14 2 14 8 20 8" })
3707
3706
  ]
3708
3707
  }
3709
- ), vr = () => /* @__PURE__ */ h(
3708
+ ), Cr = () => /* @__PURE__ */ h(
3710
3709
  "svg",
3711
3710
  {
3712
3711
  width: "12",
@@ -3740,7 +3739,7 @@ function ae({
3740
3739
  }
3741
3740
  );
3742
3741
  }
3743
- function ht(t) {
3742
+ function vs(t) {
3744
3743
  if (t)
3745
3744
  try {
3746
3745
  return typeof t == "string" ? JSON.parse(t) : t;
@@ -3748,6 +3747,20 @@ function ht(t) {
3748
3747
  return;
3749
3748
  }
3750
3749
  }
3750
+ function pt(t, e) {
3751
+ const r = vs(t);
3752
+ if (!r || typeof r != "object") return;
3753
+ const n = r.data;
3754
+ if (!n || typeof n != "object") return;
3755
+ const i = n;
3756
+ if (e)
3757
+ for (const s of e) {
3758
+ const o = i[s];
3759
+ if (o && typeof o == "object")
3760
+ return o;
3761
+ }
3762
+ return i;
3763
+ }
3751
3764
  function Is({
3752
3765
  toolCallId: t,
3753
3766
  toolInput: e,
@@ -3764,7 +3777,7 @@ function Is({
3764
3777
  successMessage: ""
3765
3778
  }
3766
3779
  );
3767
- const c = ht(r)?.data?.searchProductsBySku?.total ?? 0;
3780
+ const c = pt(r, ["searchProductsBySku"])?.total ?? 0;
3768
3781
  return /* @__PURE__ */ a(
3769
3782
  ae,
3770
3783
  {
@@ -3790,30 +3803,33 @@ function ws({
3790
3803
  successMessage: ""
3791
3804
  }
3792
3805
  );
3793
- const c = ht(r)?.data, l = c?.searchProducts?.total ?? c?.searchProductsFromChat?.total ?? 0;
3806
+ const c = pt(r, [
3807
+ "searchProducts",
3808
+ "searchProductsFromChat"
3809
+ ])?.total ?? 0;
3794
3810
  return /* @__PURE__ */ a(
3795
3811
  ae,
3796
3812
  {
3797
3813
  toolCallId: t,
3798
- successMessage: `Found ${l} product${l !== 1 ? "s" : ""} for '${i}'`,
3814
+ successMessage: `Found ${c} product${c !== 1 ? "s" : ""} for '${i}'`,
3799
3815
  toolOutput: r
3800
3816
  }
3801
3817
  );
3802
3818
  }
3803
- const Ir = Or(
3819
+ const vr = Mr(
3804
3820
  null
3805
3821
  );
3806
3822
  function Ss({
3807
3823
  client: t,
3808
3824
  children: e
3809
3825
  }) {
3810
- return /* @__PURE__ */ a(Ir.Provider, { value: t, children: e });
3826
+ return /* @__PURE__ */ a(vr.Provider, { value: t, children: e });
3811
3827
  }
3812
- function ft() {
3813
- return Fr(Ir);
3828
+ function ht() {
3829
+ return Or(vr);
3814
3830
  }
3815
3831
  function Es(t, e) {
3816
- const r = ft(), n = g(
3832
+ const r = ht(), n = g(
3817
3833
  (d) => d.bcSession.productCache
3818
3834
  ), i = g((d) => d.cacheProducts), s = D(/* @__PURE__ */ new Set()), o = ee(() => t.filter(
3819
3835
  (d) => !n[d] && !s.current.has(d)
@@ -3927,7 +3943,7 @@ const As = 10;
3927
3943
  function Bs(t, e, r) {
3928
3944
  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";
3929
3945
  }
3930
- function $t({
3946
+ function Bt({
3931
3947
  product: t,
3932
3948
  onAddToCart: e,
3933
3949
  cart: r = [],
@@ -3938,7 +3954,7 @@ function $t({
3938
3954
  selections: c,
3939
3955
  onSelectionChange: l
3940
3956
  }) {
3941
- const [d, p] = R(1), [u, m] = R(!1), [v, b] = R(!1), x = i === "horizontal", I = g(
3957
+ const [d, p] = R(1), [u, m] = R(!1), [C, b] = R(!1), x = i === "horizontal", I = g(
3942
3958
  (q) => t.productEntityId !== void 0 ? q.bcSession.variantCache[t.productEntityId] : void 0
3943
3959
  ), w = ee(() => !o || !c || c.size === 0 ? o?.defaultVariant ?? null : ks(
3944
3960
  t.productEntityId,
@@ -4029,7 +4045,7 @@ function $t({
4029
4045
  }
4030
4046
  ),
4031
4047
  /* @__PURE__ */ a("p", { className: "text-xs text-text-quaternary m-0 mt-0.5", children: A }),
4032
- $ !== void 0 && /* @__PURE__ */ a("p", { className: "text-sm font-semibold text-text m-0 mt-1", children: Ae($) }),
4048
+ $ !== void 0 && /* @__PURE__ */ a("p", { className: "text-sm font-semibold text-text m-0 mt-1", children: Be($) }),
4033
4049
  j && /* @__PURE__ */ a("p", { className: "text-xs text-error m-0 mt-1 font-medium", children: "Out of Stock" }),
4034
4050
  !x && !j && B !== void 0 && B > 0 && /* @__PURE__ */ h("p", { className: "text-2xs text-success font-medium m-0 mt-0.5", children: [
4035
4051
  B,
@@ -4063,7 +4079,7 @@ function $t({
4063
4079
  className: x ? "flex items-center gap-2 flex-wrap" : "flex flex-col gap-2",
4064
4080
  children: [
4065
4081
  /* @__PURE__ */ a(
4066
- lr,
4082
+ cr,
4067
4083
  {
4068
4084
  value: d,
4069
4085
  onChange: p,
@@ -4077,9 +4093,9 @@ function $t({
4077
4093
  {
4078
4094
  type: "button",
4079
4095
  onClick: re,
4080
- disabled: u || v || !!Y || j,
4081
- className: `py-1.5 px-3 text-xs font-medium rounded border-none ${x ? "" : "w-full"} ${Bs(u, v, !!Y || j)}`,
4082
- children: u ? "Adding..." : v ? "✓ Added" : "Add to cart"
4096
+ disabled: u || C || !!Y || j,
4097
+ className: `py-1.5 px-3 text-xs font-medium rounded border-none ${x ? "" : "w-full"} ${Bs(u, C, !!Y || j)}`,
4098
+ children: u ? "Adding..." : C ? "✓ Added" : "Add to cart"
4083
4099
  }
4084
4100
  )
4085
4101
  ]
@@ -4105,7 +4121,7 @@ function $s({
4105
4121
  loadingText: o = "Searching for products...",
4106
4122
  className: c = ""
4107
4123
  }) {
4108
- const l = ft(), d = ee(() => {
4124
+ const l = ht(), d = ee(() => {
4109
4125
  const I = /* @__PURE__ */ new Map();
4110
4126
  if (i)
4111
4127
  for (const w of i)
@@ -4125,7 +4141,7 @@ function $s({
4125
4141
  return w;
4126
4142
  });
4127
4143
  }, [i, d, t]);
4128
- const v = (I, w, k) => {
4144
+ const C = (I, w, k) => {
4129
4145
  const N = m.current.get(I) ?? /* @__PURE__ */ new Map(), T = new Map(N);
4130
4146
  T.set(w, k), u((A) => {
4131
4147
  const $ = new Map(A);
@@ -4161,7 +4177,7 @@ function $s({
4161
4177
  if (b.length === 1 && x) {
4162
4178
  const I = x.productEntityId !== void 0 ? d.get(x.productEntityId) : void 0, w = p.get(x.id);
4163
4179
  return /* @__PURE__ */ a("div", { className: `py-2 ${c}`, children: /* @__PURE__ */ a(
4164
- $t,
4180
+ Bt,
4165
4181
  {
4166
4182
  layout: "horizontal",
4167
4183
  product: x,
@@ -4170,14 +4186,14 @@ function $s({
4170
4186
  cart: n,
4171
4187
  cachedProduct: I,
4172
4188
  selections: w,
4173
- onSelectionChange: I && I.productOptions.length > 0 ? (k, N) => v(x.id, k, N) : void 0
4189
+ onSelectionChange: I && I.productOptions.length > 0 ? (k, N) => C(x.id, k, N) : void 0
4174
4190
  }
4175
4191
  ) });
4176
4192
  }
4177
4193
  return /* @__PURE__ */ a("div", { className: `flex flex-wrap gap-3 py-2 ${c}`, children: b.map((I) => {
4178
4194
  const w = I.productEntityId !== void 0 ? d.get(I.productEntityId) : void 0, k = p.get(I.id);
4179
4195
  return /* @__PURE__ */ a(
4180
- $t,
4196
+ Bt,
4181
4197
  {
4182
4198
  product: I,
4183
4199
  onAddToCart: e,
@@ -4185,7 +4201,7 @@ function $s({
4185
4201
  cart: n,
4186
4202
  cachedProduct: w,
4187
4203
  selections: k,
4188
- onSelectionChange: w && w.productOptions.length > 0 ? (N, T) => v(I.id, N, T) : void 0
4204
+ onSelectionChange: w && w.productOptions.length > 0 ? (N, T) => C(I.id, N, T) : void 0
4189
4205
  },
4190
4206
  I.id
4191
4207
  );
@@ -4201,27 +4217,27 @@ function Ms({
4201
4217
  const s = e !== "output-available", { productEntityIds: o, variantEntityIds: c } = ee(() => {
4202
4218
  if (!t?.products?.length)
4203
4219
  return { productEntityIds: [], variantEntityIds: [] };
4204
- const u = [...new Set(t.products.map((v) => v.entityId))], m = t.products.map((v) => v.variantEntityId).filter((v) => v !== void 0);
4220
+ const u = [...new Set(t.products.map((C) => C.entityId))], m = t.products.map((C) => C.variantEntityId).filter((C) => C !== void 0);
4205
4221
  return { productEntityIds: u, variantEntityIds: m };
4206
4222
  }, [t]), { products: l, isLoading: d } = Es(o, c), p = ee(() => {
4207
4223
  if (!t?.products?.length) return [];
4208
4224
  const u = [];
4209
4225
  for (const m of t.products) {
4210
- const v = l.find(
4226
+ const C = l.find(
4211
4227
  (x) => x.entityId === m.entityId
4212
4228
  );
4213
- if (!v) continue;
4214
- const b = v.defaultVariant;
4229
+ if (!C) continue;
4230
+ const b = C.defaultVariant;
4215
4231
  b && u.push({
4216
- id: `${v.entityId}-${b.entityId}`,
4232
+ id: `${C.entityId}-${b.entityId}`,
4217
4233
  sku: b.sku,
4218
- name: v.name,
4219
- path: v.path,
4234
+ name: C.name,
4235
+ path: C.path,
4220
4236
  price: b.price,
4221
- imageUrl: b.defaultImage?.replace("{:size}", "200w") ?? v.defaultImage?.replace("{:size}", "200w"),
4237
+ imageUrl: b.defaultImage?.replace("{:size}", "200w") ?? C.defaultImage?.replace("{:size}", "200w"),
4222
4238
  availableQuantity: b.availableToSell,
4223
4239
  isInStock: b.isInStock,
4224
- productEntityId: v.entityId,
4240
+ productEntityId: C.entityId,
4225
4241
  variantEntityId: b.entityId
4226
4242
  });
4227
4243
  }
@@ -4240,7 +4256,7 @@ function Ms({
4240
4256
  }
4241
4257
  );
4242
4258
  }
4243
- function wr({
4259
+ function Ir({
4244
4260
  toolCallId: t,
4245
4261
  toolName: e,
4246
4262
  toolInput: r,
@@ -4250,7 +4266,7 @@ function wr({
4250
4266
  onAddToCart: o,
4251
4267
  onViewProduct: c
4252
4268
  }) {
4253
- return e === fr ? /* @__PURE__ */ a("div", { className: "mt-3", children: /* @__PURE__ */ a(
4269
+ return e === hr ? /* @__PURE__ */ a("div", { className: "mt-3", children: /* @__PURE__ */ a(
4254
4270
  Ms,
4255
4271
  {
4256
4272
  toolInput: r,
@@ -4260,7 +4276,7 @@ function wr({
4260
4276
  onAddToCart: o,
4261
4277
  onViewProduct: c
4262
4278
  }
4263
- ) }) : e === gs || e === ys ? /* @__PURE__ */ a(
4279
+ ) }) : e === ms || e === gs ? /* @__PURE__ */ a(
4264
4280
  ws,
4265
4281
  {
4266
4282
  toolCallId: t,
@@ -4268,7 +4284,7 @@ function wr({
4268
4284
  toolOutput: n,
4269
4285
  toolState: i ?? ""
4270
4286
  }
4271
- ) : e === xs ? /* @__PURE__ */ a(
4287
+ ) : e === ys ? /* @__PURE__ */ a(
4272
4288
  Is,
4273
4289
  {
4274
4290
  toolCallId: t,
@@ -4276,7 +4292,7 @@ function wr({
4276
4292
  toolOutput: n,
4277
4293
  toolState: i ?? ""
4278
4294
  }
4279
- ) : e === Oe ? /* @__PURE__ */ a(
4295
+ ) : e === Fe ? /* @__PURE__ */ a(
4280
4296
  ae,
4281
4297
  {
4282
4298
  toolCallId: t,
@@ -4285,7 +4301,7 @@ function wr({
4285
4301
  successMessage: "Added to cart",
4286
4302
  toolOutput: n
4287
4303
  }
4288
- ) : e === mr ? /* @__PURE__ */ a(
4304
+ ) : e === fr ? /* @__PURE__ */ a(
4289
4305
  ae,
4290
4306
  {
4291
4307
  toolCallId: t,
@@ -4294,7 +4310,7 @@ function wr({
4294
4310
  successMessage: "Updated cart",
4295
4311
  toolOutput: n
4296
4312
  }
4297
- ) : e === gr ? /* @__PURE__ */ a(
4313
+ ) : e === mr ? /* @__PURE__ */ a(
4298
4314
  ae,
4299
4315
  {
4300
4316
  toolCallId: t,
@@ -4303,7 +4319,7 @@ function wr({
4303
4319
  successMessage: "Removed from cart",
4304
4320
  toolOutput: n
4305
4321
  }
4306
- ) : e === yr ? /* @__PURE__ */ a(
4322
+ ) : e === gr ? /* @__PURE__ */ a(
4307
4323
  ae,
4308
4324
  {
4309
4325
  toolCallId: t,
@@ -4312,7 +4328,7 @@ function wr({
4312
4328
  successMessage: "Cart cleared",
4313
4329
  toolOutput: n
4314
4330
  }
4315
- ) : e === xr ? /* @__PURE__ */ a(
4331
+ ) : e === yr ? /* @__PURE__ */ a(
4316
4332
  ae,
4317
4333
  {
4318
4334
  toolCallId: t,
@@ -4320,7 +4336,7 @@ function wr({
4320
4336
  successMessage: "Retrieved cart",
4321
4337
  toolOutput: n
4322
4338
  }
4323
- ) : e === ut ? /* @__PURE__ */ a(
4339
+ ) : e === dt ? /* @__PURE__ */ a(
4324
4340
  ae,
4325
4341
  {
4326
4342
  toolCallId: t,
@@ -4336,7 +4352,7 @@ function wr({
4336
4352
  successMessage: "Saved metadata",
4337
4353
  toolOutput: n
4338
4354
  }
4339
- ) : e === br ? /* @__PURE__ */ a(
4355
+ ) : e === xr ? /* @__PURE__ */ a(
4340
4356
  ae,
4341
4357
  {
4342
4358
  toolCallId: t,
@@ -4344,7 +4360,7 @@ function wr({
4344
4360
  successMessage: "Warnings updated",
4345
4361
  toolOutput: n
4346
4362
  }
4347
- ) : e === Cr ? /* @__PURE__ */ a(
4363
+ ) : e === br ? /* @__PURE__ */ a(
4348
4364
  ae,
4349
4365
  {
4350
4366
  toolCallId: t,
@@ -4377,7 +4393,7 @@ function Os({
4377
4393
  {
4378
4394
  className: `transition-transform duration-200 ${s ? "rotate-90" : ""}`,
4379
4395
  "aria-hidden": "true",
4380
- children: /* @__PURE__ */ a(vr, {})
4396
+ children: /* @__PURE__ */ a(Cr, {})
4381
4397
  }
4382
4398
  ),
4383
4399
  /* @__PURE__ */ h("span", { className: "flex-1 text-left", children: [
@@ -4395,7 +4411,7 @@ function Os({
4395
4411
  "data-testid": "collapsible-panel",
4396
4412
  className: `collapsible-panel ${s ? "collapsible-panel-open" : ""}`,
4397
4413
  children: /* @__PURE__ */ a("div", { className: "overflow-hidden", children: /* @__PURE__ */ a("div", { className: "pl-2.5 border-l border-gray-200 ml-[1px] my-2", children: t.map((c) => /* @__PURE__ */ a(
4398
- wr,
4414
+ Ir,
4399
4415
  {
4400
4416
  toolCallId: c.toolCallId,
4401
4417
  toolName: c.toolName,
@@ -4412,17 +4428,17 @@ function Os({
4412
4428
  )
4413
4429
  ] });
4414
4430
  }
4415
- const Fs = xt.object({
4416
- id: xt.string()
4431
+ const Fs = yt.object({
4432
+ id: yt.string()
4417
4433
  });
4418
4434
  async function Ds(t, e) {
4419
4435
  if (!t.body)
4420
4436
  throw new Error("No response body");
4421
4437
  const r = [], n = /* @__PURE__ */ new Set(), i = [];
4422
4438
  let s = null, o = null;
4423
- const l = qr({
4439
+ const l = Ur({
4424
4440
  stream: t.body,
4425
- schema: jr
4441
+ schema: qr
4426
4442
  }).getReader();
4427
4443
  try {
4428
4444
  for (; ; ) {
@@ -4449,7 +4465,7 @@ async function Ds(t, e) {
4449
4465
  case "tool-output-available": {
4450
4466
  n.add(u.toolCallId);
4451
4467
  const m = r.find(
4452
- (v) => v.toolCallId === u.toolCallId
4468
+ (C) => C.toolCallId === u.toolCallId
4453
4469
  );
4454
4470
  m && (m.output = u.output, e?.onToolOutput?.(m));
4455
4471
  break;
@@ -4474,7 +4490,7 @@ async function Ds(t, e) {
4474
4490
  errorMessage: o
4475
4491
  };
4476
4492
  }
4477
- async function Sr(t, e) {
4493
+ async function wr(t, e) {
4478
4494
  const { origin: r, projectId: n, apiKey: i } = t, s = await Ne(
4479
4495
  `${r}/project/${n}/agents/threads`,
4480
4496
  {
@@ -4588,15 +4604,21 @@ const Us = {
4588
4604
  setAttribute: () => {
4589
4605
  }
4590
4606
  };
4591
- let Le = null;
4592
- function zi(t) {
4593
- Le = t;
4607
+ let ke = null;
4608
+ function Hi(t) {
4609
+ ke = t;
4594
4610
  }
4595
- function nt(t) {
4596
- return Le ? Le.startInactiveSpan(t) : Us;
4611
+ function rt(t) {
4612
+ return ke ? ke.startInactiveSpan(t) : Us;
4597
4613
  }
4598
4614
  function qs(t, e) {
4599
- Le && Le.captureFeedback(
4615
+ ke && ke.captureException(t, {
4616
+ tags: e?.tags,
4617
+ extra: e?.extra
4618
+ });
4619
+ }
4620
+ function js(t, e) {
4621
+ ke && ke.captureFeedback(
4600
4622
  t,
4601
4623
  e?.tags ? {
4602
4624
  captureContext: {
@@ -4605,12 +4627,12 @@ function qs(t, e) {
4605
4627
  } : void 0
4606
4628
  );
4607
4629
  }
4608
- function Mt({
4630
+ function $t({
4609
4631
  messageId: t,
4610
4632
  isOpen: e,
4611
4633
  onClose: r
4612
4634
  }) {
4613
- const [n, i] = R(""), [s, o] = R(""), [c, l] = R(""), [d, p] = R("idle"), [u, m] = R(""), v = D(null), b = g(
4635
+ const [n, i] = R(""), [s, o] = R(""), [c, l] = R(""), [d, p] = R("idle"), [u, m] = R(""), C = D(null), b = g(
4614
4636
  (N) => N.takeshapeConfig
4615
4637
  ), x = g((N) => N.chat.threadId), I = g(
4616
4638
  (N) => N.parser.threadId
@@ -4618,7 +4640,7 @@ function Mt({
4618
4640
  (N) => N.batchProcessing.threadIds
4619
4641
  );
4620
4642
  F(() => {
4621
- e && (i(""), o(""), l(""), p("idle"), m(""), v.current?.focus());
4643
+ e && (i(""), o(""), l(""), p("idle"), m(""), C.current?.focus());
4622
4644
  }, [e]), F(() => {
4623
4645
  if (!e) return;
4624
4646
  const N = (T) => {
@@ -4630,7 +4652,7 @@ function Mt({
4630
4652
  if (N.preventDefault(), !(!n.trim() || !c.trim())) {
4631
4653
  p("submitting"), m("");
4632
4654
  try {
4633
- qs(
4655
+ js(
4634
4656
  {
4635
4657
  name: n.trim(),
4636
4658
  email: s.trim() || void 0,
@@ -4695,7 +4717,7 @@ function Mt({
4695
4717
  onClick: r,
4696
4718
  className: "p-1 rounded-md hover:bg-surface-secondary transition-colors",
4697
4719
  "aria-label": "Close dialog",
4698
- children: /* @__PURE__ */ a(dt, {})
4720
+ children: /* @__PURE__ */ a(lt, {})
4699
4721
  }
4700
4722
  )
4701
4723
  ] }),
@@ -4713,7 +4735,7 @@ function Mt({
4713
4735
  /* @__PURE__ */ a(
4714
4736
  "input",
4715
4737
  {
4716
- ref: v,
4738
+ ref: C,
4717
4739
  id: "feedback-name",
4718
4740
  type: "text",
4719
4741
  value: n,
@@ -4782,7 +4804,7 @@ function Mt({
4782
4804
  disabled: !n.trim() || !c.trim() || d === "submitting" || d === "success",
4783
4805
  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",
4784
4806
  children: d === "submitting" ? /* @__PURE__ */ h(Ce, { children: [
4785
- /* @__PURE__ */ a(Me, { size: 16 }),
4807
+ /* @__PURE__ */ a(Oe, { size: 16 }),
4786
4808
  "Sending..."
4787
4809
  ] }) : d === "success" ? "Sent!" : "Send Feedback"
4788
4810
  }
@@ -4795,7 +4817,7 @@ function Mt({
4795
4817
  }
4796
4818
  ) : null;
4797
4819
  }
4798
- const Ot = ({ size: t = 12 }) => /* @__PURE__ */ h(
4820
+ const Mt = ({ size: t = 12 }) => /* @__PURE__ */ h(
4799
4821
  "svg",
4800
4822
  {
4801
4823
  width: t,
@@ -4813,7 +4835,7 @@ const Ot = ({ size: t = 12 }) => /* @__PURE__ */ h(
4813
4835
  ]
4814
4836
  }
4815
4837
  );
4816
- function js({
4838
+ function Ws({
4817
4839
  messagePartId: t,
4818
4840
  messageId: e,
4819
4841
  isLatestAssistantMessage: r,
@@ -4834,11 +4856,11 @@ function js({
4834
4856
  className: "shrink-0 p-1 rounded text-text-tertiary hover:text-text hover:bg-surface-secondary transition-colors",
4835
4857
  "aria-label": "Send feedback",
4836
4858
  title: "Send feedback",
4837
- children: /* @__PURE__ */ a(Ot, { size: 14 })
4859
+ children: /* @__PURE__ */ a(Mt, { size: 14 })
4838
4860
  }
4839
4861
  ),
4840
4862
  /* @__PURE__ */ a(
4841
- Mt,
4863
+ $t,
4842
4864
  {
4843
4865
  messageId: e,
4844
4866
  isOpen: l,
@@ -4862,7 +4884,7 @@ function js({
4862
4884
  {
4863
4885
  className: `transition-transform duration-200 ${c ? "rotate-90" : ""}`,
4864
4886
  "aria-hidden": "true",
4865
- children: /* @__PURE__ */ a(vr, {})
4887
+ children: /* @__PURE__ */ a(Cr, {})
4866
4888
  }
4867
4889
  ),
4868
4890
  /* @__PURE__ */ a("span", { className: "flex-1 text-left truncate", children: c ? "Hide message" : i })
@@ -4894,12 +4916,12 @@ function js({
4894
4916
  className: "shrink-0 p-1 rounded text-text-tertiary hover:text-text hover:bg-surface-secondary transition-colors",
4895
4917
  "aria-label": "Send feedback",
4896
4918
  title: "Send feedback",
4897
- children: /* @__PURE__ */ a(Ot, { size: 14 })
4919
+ children: /* @__PURE__ */ a(Mt, { size: 14 })
4898
4920
  }
4899
4921
  )
4900
4922
  ] }),
4901
4923
  /* @__PURE__ */ a(
4902
- Mt,
4924
+ $t,
4903
4925
  {
4904
4926
  messageId: e,
4905
4927
  isOpen: l,
@@ -4908,12 +4930,12 @@ function js({
4908
4930
  )
4909
4931
  ] });
4910
4932
  }
4911
- function Ws(t) {
4933
+ function Vs(t) {
4912
4934
  if (!t.parts)
4913
4935
  return [];
4914
4936
  const e = [];
4915
4937
  for (const r of t.parts)
4916
- if (r.type === "text" && r.text !== ot)
4938
+ if (r.type === "text" && r.text !== it)
4917
4939
  e.push({
4918
4940
  type: "text",
4919
4941
  text: r.text
@@ -4931,11 +4953,11 @@ function Ws(t) {
4931
4953
  }
4932
4954
  return e;
4933
4955
  }
4934
- function Vs(t) {
4956
+ function zs(t) {
4935
4957
  const e = t?.find((r) => r.type === "file");
4936
4958
  return e && "filename" in e && typeof e.filename == "string" ? e.filename : "Attachment";
4937
4959
  }
4938
- function zs({
4960
+ function Hs({
4939
4961
  message: t,
4940
4962
  isFirstUserMessage: e,
4941
4963
  isLatestAssistantMessage: r,
@@ -4946,7 +4968,7 @@ function zs({
4946
4968
  onAddToCart: c,
4947
4969
  onViewProduct: l
4948
4970
  }) {
4949
- const d = t.role === "assistant", p = Ws(t);
4971
+ const d = t.role === "assistant", p = Vs(t);
4950
4972
  return p.length === 0 ? null : /* @__PURE__ */ a(
4951
4973
  "div",
4952
4974
  {
@@ -4959,7 +4981,7 @@ function zs({
4959
4981
  onClick: i,
4960
4982
  className: "flex items-center gap-2 px-3 py-2 bg-surface hover:bg-surface-secondary rounded-lg transition-colors border border-border text-left w-full",
4961
4983
  children: [
4962
- /* @__PURE__ */ a(Bt, {}),
4984
+ /* @__PURE__ */ a(At, {}),
4963
4985
  /* @__PURE__ */ a("span", { className: "text-sm text-text font-medium truncate min-w-0", children: s || "Uploaded Document" }),
4964
4986
  /* @__PURE__ */ h(
4965
4987
  "svg",
@@ -4990,7 +5012,7 @@ function zs({
4990
5012
  `text-${t.id}-${m}`
4991
5013
  ) : null) })
4992
5014
  ] }) : /* @__PURE__ */ h(Ce, { children: [
4993
- vs(p).map((u, m) => u.type === "tool-group" ? /* @__PURE__ */ a(
5015
+ Cs(p).map((u, m) => u.type === "tool-group" ? /* @__PURE__ */ a(
4994
5016
  Os,
4995
5017
  {
4996
5018
  tools: u.tools,
@@ -5001,7 +5023,7 @@ function zs({
5001
5023
  },
5002
5024
  `group-${t.id}-${m}`
5003
5025
  ) : u.type === "text" ? d ? /* @__PURE__ */ a(
5004
- js,
5026
+ Ws,
5005
5027
  {
5006
5028
  messagePartId: `${t.id}-${m}`,
5007
5029
  messageId: t.id,
@@ -5024,7 +5046,7 @@ function zs({
5024
5046
  },
5025
5047
  `text-${t.id}-${m}`
5026
5048
  ) : u.type === "tool" ? /* @__PURE__ */ a("div", { className: "ml-5", children: /* @__PURE__ */ a(
5027
- wr,
5049
+ Ir,
5028
5050
  {
5029
5051
  toolCallId: u.toolCallId,
5030
5052
  toolName: u.toolName,
@@ -5037,14 +5059,14 @@ function zs({
5037
5059
  }
5038
5060
  ) }, u.toolCallId) : null),
5039
5061
  !d && t.parts?.some((u) => u.type === "file") && /* @__PURE__ */ h("div", { className: "flex items-center gap-1.5 mt-2 text-xs text-text-tertiary", children: [
5040
- /* @__PURE__ */ a(Bt, {}),
5041
- /* @__PURE__ */ a("span", { children: Vs(t.parts) })
5062
+ /* @__PURE__ */ a(At, {}),
5063
+ /* @__PURE__ */ a("span", { children: zs(t.parts) })
5042
5064
  ] })
5043
5065
  ] }) })
5044
5066
  }
5045
5067
  );
5046
5068
  }
5047
- function Er() {
5069
+ function Sr() {
5048
5070
  const [t, e] = R(!1);
5049
5071
  return F(() => {
5050
5072
  if (typeof window.matchMedia != "function") {
@@ -5059,7 +5081,7 @@ function Er() {
5059
5081
  return r.addEventListener("change", n), () => r.removeEventListener("change", n);
5060
5082
  }, []), t;
5061
5083
  }
5062
- const Nr = () => /* @__PURE__ */ h(
5084
+ const Er = () => /* @__PURE__ */ h(
5063
5085
  "svg",
5064
5086
  {
5065
5087
  width: "48",
@@ -5076,7 +5098,7 @@ const Nr = () => /* @__PURE__ */ h(
5076
5098
  /* @__PURE__ */ a("polyline", { points: "9 15 12 12 15 15" })
5077
5099
  ]
5078
5100
  }
5079
- ), Hs = () => /* @__PURE__ */ h(
5101
+ ), Qs = () => /* @__PURE__ */ h(
5080
5102
  "svg",
5081
5103
  {
5082
5104
  width: "16",
@@ -5094,7 +5116,7 @@ const Nr = () => /* @__PURE__ */ h(
5094
5116
  ]
5095
5117
  }
5096
5118
  );
5097
- function kr({ onClick: t }) {
5119
+ function Nr({ onClick: t }) {
5098
5120
  return /* @__PURE__ */ h(
5099
5121
  "button",
5100
5122
  {
@@ -5102,13 +5124,13 @@ function kr({ onClick: t }) {
5102
5124
  className: "flex items-center gap-2 min-h-11 py-2.5 px-5 bg-surface border border-border-strong rounded-full text-sm font-medium text-text cursor-pointer transition-colors hover:bg-surface-secondary focus-visible:outline-2 focus-visible:outline-border-focus focus-visible:outline-offset-2",
5103
5125
  onClick: t,
5104
5126
  children: [
5105
- /* @__PURE__ */ a(Hs, {}),
5127
+ /* @__PURE__ */ a(Qs, {}),
5106
5128
  "Take a photo"
5107
5129
  ]
5108
5130
  }
5109
5131
  );
5110
5132
  }
5111
- function Qs({
5133
+ function Gs({
5112
5134
  isDragging: t = !1,
5113
5135
  fileInputRef: e,
5114
5136
  cameraInputRef: r,
@@ -5117,7 +5139,7 @@ function Qs({
5117
5139
  onDropZoneClick: s,
5118
5140
  onCameraClick: o
5119
5141
  }) {
5120
- const c = Er();
5142
+ const c = Sr();
5121
5143
  return /* @__PURE__ */ a("div", { className: "flex-1 flex items-center justify-center animate-fade-in-up", children: /* @__PURE__ */ h("div", { className: "flex flex-col items-center gap-4", children: [
5122
5144
  /* @__PURE__ */ h(
5123
5145
  "button",
@@ -5133,7 +5155,7 @@ function Qs({
5133
5155
  type: "file",
5134
5156
  className: "hidden",
5135
5157
  onChange: i,
5136
- accept: rr
5158
+ accept: tr
5137
5159
  }
5138
5160
  ),
5139
5161
  /* @__PURE__ */ a(
@@ -5143,23 +5165,23 @@ function Qs({
5143
5165
  type: "file",
5144
5166
  className: "hidden",
5145
5167
  onChange: i,
5146
- accept: nr,
5168
+ accept: rr,
5147
5169
  capture: "environment"
5148
5170
  }
5149
5171
  ),
5150
5172
  /* @__PURE__ */ a(
5151
5173
  "div",
5152
5174
  {
5153
- className: ke(
5175
+ className: Pe(
5154
5176
  "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",
5155
5177
  t && "animate-icon-bounce"
5156
5178
  ),
5157
- children: /* @__PURE__ */ a(Nr, {})
5179
+ children: /* @__PURE__ */ a(Er, {})
5158
5180
  }
5159
5181
  ),
5160
5182
  /* @__PURE__ */ a("h3", { className: "m-0 text-base font-semibold text-text text-center", children: "Upload your Order" }),
5161
5183
  /* @__PURE__ */ a("p", { className: "m-0 text-sm text-text-tertiary text-center", children: "Your Order Assistant will match products and check stock availability" }),
5162
- /* @__PURE__ */ a("div", { className: "flex flex-wrap justify-center gap-2", children: sr.map((l) => /* @__PURE__ */ a(
5184
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap justify-center gap-2", children: nr.map((l) => /* @__PURE__ */ a(
5163
5185
  "span",
5164
5186
  {
5165
5187
  className: "py-1 px-3 bg-surface-invert/5 border border-border-strong rounded-full text-xs font-medium text-text",
@@ -5170,11 +5192,11 @@ function Qs({
5170
5192
  ]
5171
5193
  }
5172
5194
  ),
5173
- c && /* @__PURE__ */ a(kr, { onClick: o }),
5195
+ c && /* @__PURE__ */ a(Nr, { onClick: o }),
5174
5196
  n && /* @__PURE__ */ a("div", { className: "flex items-center gap-2 py-3 px-4 bg-error-bg border border-error/30 rounded-lg text-error-text text-sm max-w-[400px] text-center", children: n })
5175
5197
  ] }) });
5176
5198
  }
5177
- function Gs() {
5199
+ function Ks() {
5178
5200
  return /* @__PURE__ */ a("div", { className: "flex justify-start px-5 py-2", children: /* @__PURE__ */ h("div", { className: "flex flex-col gap-2 w-3/4", children: [
5179
5201
  /* @__PURE__ */ a("div", { className: "h-3 rounded-full animate-shimmer" }),
5180
5202
  /* @__PURE__ */ a(
@@ -5186,7 +5208,7 @@ function Gs() {
5186
5208
  )
5187
5209
  ] }) });
5188
5210
  }
5189
- const Ks = Dr(
5211
+ const Js = Fr(
5190
5212
  function({
5191
5213
  messages: e,
5192
5214
  input: r,
@@ -5200,7 +5222,7 @@ const Ks = Dr(
5200
5222
  error: p = null,
5201
5223
  onRetry: u,
5202
5224
  hasProcessedDocument: m = !1,
5203
- uploadedFileName: v = null,
5225
+ uploadedFileName: C = null,
5204
5226
  fileDrop: b
5205
5227
  }, x) {
5206
5228
  const I = D(null), w = D(!0), [k, N] = R(!1), T = ee(() => {
@@ -5211,7 +5233,7 @@ const Ks = Dr(
5211
5233
  }
5212
5234
  return null;
5213
5235
  }, [e]);
5214
- return Rr(x, () => ({
5236
+ return Dr(x, () => ({
5215
5237
  scrollToBottom: () => {
5216
5238
  const y = I.current;
5217
5239
  y && (y.scrollHeight - y.scrollTop - y.clientHeight > 500 || !y.scrollTo ? y.scrollTop = y.scrollHeight : y.scrollTo({
@@ -5243,7 +5265,7 @@ const Ks = Dr(
5243
5265
  className: "flex-1 min-h-0 overflow-y-auto py-3 flex flex-col",
5244
5266
  children: [
5245
5267
  e.length === 0 && !s && b && /* @__PURE__ */ a(
5246
- Qs,
5268
+ Gs,
5247
5269
  {
5248
5270
  isDragging: b.isDragging,
5249
5271
  fileInputRef: b.fileInputRef,
@@ -5257,14 +5279,14 @@ const Ks = Dr(
5257
5279
  e.map((y, A) => {
5258
5280
  const $ = m && y.role !== "assistant" && A === 0, B = y.role === "assistant" && y.id === T;
5259
5281
  return /* @__PURE__ */ a(
5260
- zs,
5282
+ Hs,
5261
5283
  {
5262
5284
  message: y,
5263
5285
  isFirstUserMessage: $,
5264
5286
  isLatestAssistantMessage: B,
5265
5287
  isDocumentExpanded: k,
5266
5288
  onToggleDocument: () => N(!k),
5267
- uploadedFileName: v,
5289
+ uploadedFileName: C,
5268
5290
  cart: o,
5269
5291
  onAddToCart: c,
5270
5292
  onViewProduct: l
@@ -5272,13 +5294,13 @@ const Ks = Dr(
5272
5294
  y.id
5273
5295
  );
5274
5296
  }),
5275
- s && /* @__PURE__ */ a(Gs, {}),
5276
- /* @__PURE__ */ a(hs, { error: p, onRetry: u })
5297
+ s && /* @__PURE__ */ a(Ks, {}),
5298
+ /* @__PURE__ */ a(ps, { error: p, onRetry: u })
5277
5299
  ]
5278
5300
  }
5279
5301
  ),
5280
5302
  /* @__PURE__ */ a(
5281
- ms,
5303
+ fs,
5282
5304
  {
5283
5305
  input: r,
5284
5306
  onInputChange: n,
@@ -5288,19 +5310,19 @@ const Ks = Dr(
5288
5310
  )
5289
5311
  ] });
5290
5312
  }
5291
- ), Js = "purchase-order-chat-user-settings", Ys = 25, Ft = it()(
5292
- Ht(
5313
+ ), Ys = "purchase-order-chat-user-settings", Zs = 25, Ot = at()(
5314
+ zt(
5293
5315
  (t) => ({
5294
- panelWidth: Ys,
5316
+ panelWidth: Zs,
5295
5317
  setPanelWidth: (e) => t({ panelWidth: e })
5296
5318
  }),
5297
5319
  {
5298
- name: Js
5320
+ name: Ys
5299
5321
  }
5300
5322
  )
5301
5323
  );
5302
- function Zs() {
5303
- const t = Ft((m) => m.panelWidth), e = Ft((m) => m.setPanelWidth), [r, n] = R(
5324
+ function Xs() {
5325
+ const t = Ot((m) => m.panelWidth), e = Ot((m) => m.setPanelWidth), [r, n] = R(
5304
5326
  typeof window < "u" && window.innerWidth >= 1024
5305
5327
  ), i = D(null), s = D(!1), o = D(t);
5306
5328
  F(() => {
@@ -5316,7 +5338,7 @@ function Zs() {
5316
5338
  const c = M(
5317
5339
  (m) => {
5318
5340
  if (!s.current || !i.current) return;
5319
- const v = i.current.getBoundingClientRect(), b = (m.clientX - v.left) / v.width * 100, x = Math.min(80, Math.max(20, b));
5341
+ const C = i.current.getBoundingClientRect(), b = (m.clientX - C.left) / C.width * 100, x = Math.min(80, Math.max(20, b));
5320
5342
  o.current = x, e(x);
5321
5343
  },
5322
5344
  [e]
@@ -5353,7 +5375,7 @@ function Zs() {
5353
5375
  handleBlur: u
5354
5376
  };
5355
5377
  }
5356
- function Xs({ activeTab: t, onTabChange: e, hasUnread: r }) {
5378
+ function ea({ activeTab: t, onTabChange: e, hasUnread: r }) {
5357
5379
  const n = r && t !== "chat";
5358
5380
  return /* @__PURE__ */ h("div", { className: "flex border-b border-border-strong shrink-0", role: "tablist", children: [
5359
5381
  /* @__PURE__ */ a(
@@ -5394,7 +5416,7 @@ function Xs({ activeTab: t, onTabChange: e, hasUnread: r }) {
5394
5416
  )
5395
5417
  ] });
5396
5418
  }
5397
- function Dt({
5419
+ function Ft({
5398
5420
  // Chat panel props
5399
5421
  messages: t,
5400
5422
  input: e,
@@ -5410,7 +5432,7 @@ function Dt({
5410
5432
  // Cart panel props
5411
5433
  cartItems: u,
5412
5434
  itemWarnings: m,
5413
- onUpdateQuantity: v,
5435
+ onUpdateQuantity: C,
5414
5436
  onRemove: b,
5415
5437
  onCheckout: x,
5416
5438
  onSuggestAlternatives: I,
@@ -5437,11 +5459,11 @@ function Dt({
5437
5459
  onMinimize: L,
5438
5460
  className: W = ""
5439
5461
  }) {
5440
- const G = Zs(), [K, Pe] = R(
5462
+ const G = Xs(), [K, Te] = R(
5441
5463
  u.length > 0 ? "cart" : "chat"
5442
5464
  ), [fe, me] = R(!1), de = D(t.length), ge = D(K);
5443
5465
  ge.current = K;
5444
- const f = t.length === 0 && u.length === 0 && !!p, S = ar({
5466
+ const f = t.length === 0 && u.length === 0 && !!p, S = sr({
5445
5467
  onFile: p ?? (() => {
5446
5468
  })
5447
5469
  });
@@ -5451,9 +5473,9 @@ function Dt({
5451
5473
  G.isDesktop && me(!1);
5452
5474
  }, [G.isDesktop]);
5453
5475
  const E = M((_) => {
5454
- Pe(_), _ === "chat" && me(!1);
5476
+ Te(_), _ === "chat" && me(!1);
5455
5477
  }, []), P = /* @__PURE__ */ a(
5456
- Ks,
5478
+ Js,
5457
5479
  {
5458
5480
  ref: d,
5459
5481
  messages: t,
@@ -5471,11 +5493,11 @@ function Dt({
5471
5493
  fileDrop: p ? S : void 0
5472
5494
  }
5473
5495
  ), O = /* @__PURE__ */ a(
5474
- ds,
5496
+ ls,
5475
5497
  {
5476
5498
  items: u,
5477
5499
  itemWarnings: m,
5478
- onUpdateQuantity: v,
5500
+ onUpdateQuantity: C,
5479
5501
  onRemove: b,
5480
5502
  onCheckout: x,
5481
5503
  onSuggestAlternatives: I,
@@ -5558,7 +5580,7 @@ function Dt({
5558
5580
  ...U,
5559
5581
  children: [
5560
5582
  /* @__PURE__ */ a(
5561
- Xs,
5583
+ ea,
5562
5584
  {
5563
5585
  activeTab: K,
5564
5586
  onTabChange: E,
@@ -5580,8 +5602,8 @@ function Dt({
5580
5602
  )
5581
5603
  );
5582
5604
  }
5583
- function ea() {
5584
- const t = ft(), e = g((c) => c.ui.existingCart), r = g(
5605
+ function ta() {
5606
+ const t = ht(), e = g((c) => c.ui.existingCart), r = g(
5585
5607
  (c) => c.confirmClearExistingCart
5586
5608
  ), [n, i] = R(!1), s = ee(
5587
5609
  () => e?.lineItems.physicalItems.reduce(
@@ -5609,14 +5631,14 @@ function ea() {
5609
5631
  disabled: n,
5610
5632
  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",
5611
5633
  children: n ? /* @__PURE__ */ h("span", { className: "flex items-center gap-2", children: [
5612
- /* @__PURE__ */ a(Me, { size: 14 }),
5634
+ /* @__PURE__ */ a(Oe, { size: 14 }),
5613
5635
  "Clearing cart…"
5614
5636
  ] }) : "Clear Cart & Continue"
5615
5637
  }
5616
5638
  )
5617
5639
  ] }) });
5618
5640
  }
5619
- function ta({ message: t }) {
5641
+ function ra({ message: t }) {
5620
5642
  return /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full w-full bg-surface-secondary", children: /* @__PURE__ */ h("div", { className: "text-center max-w-md px-4", children: [
5621
5643
  /* @__PURE__ */ a("p", { className: "text-lg text-text-secondary mb-2", children: "Something went wrong" }),
5622
5644
  /* @__PURE__ */ a("p", { className: "text-sm text-text-tertiary mb-6", children: t || "An unexpected error occurred. Please refresh the page to try again." }),
@@ -5633,7 +5655,7 @@ function ta({ message: t }) {
5633
5655
  )
5634
5656
  ] }) });
5635
5657
  }
5636
- function Pr() {
5658
+ function kr() {
5637
5659
  const t = g((n) => n.appState), e = g(
5638
5660
  (n) => n.parser.parsedContent
5639
5661
  ), r = g(
@@ -5641,19 +5663,19 @@ function Pr() {
5641
5663
  );
5642
5664
  return ee(() => t !== "processing" ? null : e ? r === "idle" || r === "processing" ? "matching" : "building" : "reading", [t, e, r]);
5643
5665
  }
5644
- const ra = [
5666
+ const na = [
5645
5667
  { label: "Upload", number: 1 },
5646
5668
  { label: "Match", number: 2 },
5647
5669
  { label: "Checkout", number: 3 }
5648
5670
  ];
5649
- function na(t = {}) {
5650
- return /* @__PURE__ */ a("div", { className: "flex items-center justify-center gap-0 p-4 md:py-1 md:px-0", children: ra.map((e, r) => /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
5671
+ function sa(t = {}) {
5672
+ return /* @__PURE__ */ a("div", { className: "flex items-center justify-center gap-0 p-4 md:py-1 md:px-0", children: na.map((e, r) => /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
5651
5673
  r > 0 && /* @__PURE__ */ a("div", { className: "w-6 md:w-10 h-px mx-2 md:mx-3 rounded-[1px] bg-border" }),
5652
5674
  /* @__PURE__ */ a("div", { className: "flex items-center justify-center w-5 h-5 rounded-full shrink-0 bg-transparent border-[1.5px] border-border-strong text-text-quaternary", children: /* @__PURE__ */ a("span", { className: "text-xs font-medium", children: e.number }) }),
5653
5675
  /* @__PURE__ */ a("span", { className: "text-s font-normal whitespace-nowrap text-text-quaternary", children: e.label })
5654
5676
  ] }, e.label)) });
5655
5677
  }
5656
- function sa({
5678
+ function aa({
5657
5679
  isDragging: t,
5658
5680
  fileInputRef: e,
5659
5681
  cameraInputRef: r,
@@ -5685,23 +5707,23 @@ function sa({
5685
5707
  type: "file",
5686
5708
  className: "hidden",
5687
5709
  onChange: s,
5688
- accept: nr,
5710
+ accept: rr,
5689
5711
  capture: "environment"
5690
5712
  }
5691
5713
  ),
5692
5714
  /* @__PURE__ */ a(
5693
5715
  "div",
5694
5716
  {
5695
- className: ke(
5717
+ className: Pe(
5696
5718
  "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",
5697
5719
  t && "animate-icon-bounce"
5698
5720
  ),
5699
- children: /* @__PURE__ */ a(Nr, {})
5721
+ children: /* @__PURE__ */ a(Er, {})
5700
5722
  }
5701
5723
  ),
5702
5724
  /* @__PURE__ */ a("h2", { className: "m-0 text-2xl max-md:text-xl font-semibold text-text text-center", children: "Upload your Order" }),
5703
5725
  /* @__PURE__ */ a("p", { className: "m-0 px-8 text-sm text-text-tertiary text-center", children: "Your Order Assistant will match products and check stock availability" }),
5704
- /* @__PURE__ */ a("div", { className: "flex flex-wrap justify-center gap-2 mt-2", children: sr.map((o) => /* @__PURE__ */ a(
5726
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap justify-center gap-2 mt-2", children: nr.map((o) => /* @__PURE__ */ a(
5705
5727
  "span",
5706
5728
  {
5707
5729
  className: "py-1 px-3 bg-surface-invert/5 border border-border-strong rounded-full text-xs font-medium text-text backdrop-blur",
@@ -5713,7 +5735,7 @@ function sa({
5713
5735
  }
5714
5736
  );
5715
5737
  }
5716
- function aa({
5738
+ function ia({
5717
5739
  isDragging: t,
5718
5740
  fileInputRef: e,
5719
5741
  acceptedExtensions: r,
@@ -5722,20 +5744,20 @@ function aa({
5722
5744
  onFileChange: s,
5723
5745
  onSkip: o
5724
5746
  }) {
5725
- const c = Er(), l = D(null), d = M(() => {
5747
+ const c = Sr(), l = D(null), d = M(() => {
5726
5748
  l.current?.click();
5727
5749
  }, []);
5728
5750
  return /* @__PURE__ */ h(
5729
5751
  "div",
5730
5752
  {
5731
- className: ke(
5753
+ className: Pe(
5732
5754
  "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",
5733
5755
  t && "ring-2 ring-border-focus border-border-focus bg-surface-tertiary shadow-upload-active"
5734
5756
  ),
5735
5757
  children: [
5736
- /* @__PURE__ */ a("div", { className: "upload-zone-steps mb-3 py-4 px-8 border-b border-solid border-border-strong", children: /* @__PURE__ */ a(na, {}) }),
5758
+ /* @__PURE__ */ a("div", { className: "upload-zone-steps mb-3 py-4 px-8 border-b border-solid border-border-strong", children: /* @__PURE__ */ a(sa, {}) }),
5737
5759
  /* @__PURE__ */ a(
5738
- sa,
5760
+ aa,
5739
5761
  {
5740
5762
  isDragging: t,
5741
5763
  fileInputRef: e,
@@ -5745,7 +5767,7 @@ function aa({
5745
5767
  onFileChange: s
5746
5768
  }
5747
5769
  ),
5748
- c && /* @__PURE__ */ a(kr, { onClick: d }),
5770
+ c && /* @__PURE__ */ a(Nr, { onClick: d }),
5749
5771
  n && /* @__PURE__ */ a("div", { className: "flex items-center gap-2 py-3 px-4 bg-error-bg border border-error/30 rounded-lg text-error-text text-sm max-w-[400px] text-center", children: n }),
5750
5772
  /* @__PURE__ */ a("div", { className: "upload-zone-steps px-8 border-b border-solid border-border-strong" }),
5751
5773
  /* @__PURE__ */ a(
@@ -5761,7 +5783,7 @@ function aa({
5761
5783
  }
5762
5784
  );
5763
5785
  }
5764
- function ia({
5786
+ function oa({
5765
5787
  items: t,
5766
5788
  orderId: e,
5767
5789
  parsedContent: r,
@@ -5853,23 +5875,23 @@ function ia({
5853
5875
  ] })
5854
5876
  ] });
5855
5877
  }
5856
- const oa = 3e3, Rt = 200;
5857
- function ca(t) {
5858
- return t <= 0 ? Rt : Math.max(Rt, Math.round(oa / t));
5878
+ const ca = 3e3, Dt = 200;
5879
+ function la(t) {
5880
+ return t <= 0 ? Dt : Math.max(Dt, Math.round(ca / t));
5859
5881
  }
5860
- function la() {
5882
+ function da() {
5861
5883
  const t = g(
5862
5884
  (o) => o.batchProcessing.toolCalls
5863
5885
  ), r = g(
5864
5886
  (o) => o.batchProcessing.status
5865
5887
  ) === "complete", n = t.reduce((o, c) => {
5866
- if (c.toolName !== Oe) return o;
5888
+ if (c.toolName !== Fe) return o;
5867
5889
  const l = c.input;
5868
5890
  return l && typeof l == "object" && "value" in l && Array.isArray(l.value) ? o + l.value.length : o;
5869
5891
  }, 0), [i, s] = R(0);
5870
5892
  return F(() => {
5871
5893
  if (!r || n === 0 || i >= n) return;
5872
- const o = ca(n), c = setTimeout(() => {
5894
+ const o = la(n), c = setTimeout(() => {
5873
5895
  s((l) => Math.min(l + 1, n));
5874
5896
  }, o);
5875
5897
  return () => clearTimeout(c);
@@ -5879,8 +5901,8 @@ function la() {
5879
5901
  isRevealing: n > 0 && i < n
5880
5902
  };
5881
5903
  }
5882
- const da = 1e3;
5883
- function ua() {
5904
+ const ua = 1e3;
5905
+ function pa() {
5884
5906
  const t = g(
5885
5907
  (s) => s.batchProcessing.toolCalls
5886
5908
  ), e = g(
@@ -5891,7 +5913,7 @@ function ua() {
5891
5913
  F(() => {
5892
5914
  if (e >= t.length)
5893
5915
  return;
5894
- const s = setTimeout(r, da);
5916
+ const s = setTimeout(r, ua);
5895
5917
  return () => clearTimeout(s);
5896
5918
  }, [t.length, e, r]);
5897
5919
  const n = t.slice(0, e);
@@ -5901,23 +5923,24 @@ function ua() {
5901
5923
  isRevealing: e < t.length
5902
5924
  };
5903
5925
  }
5904
- const _t = ["reading", "matching", "building"];
5905
- function pa(t, e) {
5926
+ const Rt = ["reading", "matching", "building"];
5927
+ function ha(t, e) {
5906
5928
  if (!e) return "pending";
5907
- const r = _t.indexOf(e), n = _t.indexOf(t);
5929
+ const r = Rt.indexOf(e), n = Rt.indexOf(t);
5908
5930
  return n < r ? "complete" : n === r ? "active" : "pending";
5909
5931
  }
5910
- function ha(t, e) {
5932
+ function fa(t, e) {
5911
5933
  return t.length >= 2 && e !== "submitted" && e !== "streaming";
5912
5934
  }
5913
- function fa(t) {
5914
- if (t === void 0) return null;
5915
- const e = ht(t);
5916
- if (e === void 0) return null;
5917
- const r = Xe(e, "data.searchProductsBySku") ?? Xe(e, "data.searchProducts");
5918
- return Xe(r, "total", 0);
5935
+ function ma(t) {
5936
+ if (t == null) return null;
5937
+ const e = pt(t, [
5938
+ "searchProductsBySku",
5939
+ "searchProducts"
5940
+ ]);
5941
+ return e === void 0 ? null : e.total ?? 0;
5919
5942
  }
5920
- const ma = {
5943
+ const ga = {
5921
5944
  searchProductsBySku: (t, { resultCount: e }) => {
5922
5945
  const r = t.sku ?? "";
5923
5946
  return e === null ? `Looking up SKU ${r}` : /* @__PURE__ */ h(Ce, { children: [
@@ -5946,18 +5969,18 @@ const ma = {
5946
5969
  ] });
5947
5970
  }
5948
5971
  };
5949
- function ga(t, e) {
5950
- const r = ma[t.toolName];
5972
+ function ya(t, e) {
5973
+ const r = ga[t.toolName];
5951
5974
  return r ? r(t.input, {
5952
5975
  visibleToolCalls: e,
5953
- resultCount: fa(t.output)
5976
+ resultCount: ma(t.output)
5954
5977
  }) : null;
5955
5978
  }
5956
- const ya = [
5979
+ const xa = [
5957
5980
  { id: "reading", label: "Reading document..." },
5958
5981
  { id: "matching", label: "Matching products..." },
5959
5982
  { id: "building", label: "Building cart..." }
5960
- ], Lt = {
5983
+ ], _t = {
5961
5984
  pending: {
5962
5985
  row: "opacity-40",
5963
5986
  icon: "bg-surface-secondary border-2 border-border-strong"
@@ -5971,28 +5994,28 @@ const ya = [
5971
5994
  icon: "bg-surface border-2 border-success text-success"
5972
5995
  }
5973
5996
  };
5974
- function xa({
5997
+ function ba({
5975
5998
  currentStep: t
5976
5999
  }) {
5977
- const { currentToolCall: e, visibleToolCalls: r } = ua(), { revealedCount: n, totalItems: i } = la(), s = g(
6000
+ const { currentToolCall: e, visibleToolCalls: r } = pa(), { revealedCount: n, totalItems: i } = da(), s = g(
5978
6001
  (o) => o.parser.uploadedFileName
5979
6002
  );
5980
- return /* @__PURE__ */ a("div", { className: "flex flex-col gap-6 w-64", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-6", children: ya.map((o) => {
5981
- const c = pa(o.id, t), l = o.id === "reading" && (c === "active" || c === "complete") && s ? s : null, d = o.id === "matching" && c === "active" && e ? ga(e, r) : null, p = o.id === "building" && c === "active" && i > 0 ? n >= i ? `Added ${i} item${i !== 1 ? "s" : ""}` : `Adding item ${n + 1} of ${i}...` : null;
6003
+ return /* @__PURE__ */ a("div", { className: "flex flex-col gap-6 w-64", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-6", children: xa.map((o) => {
6004
+ const c = ha(o.id, t), l = o.id === "reading" && (c === "active" || c === "complete") && s ? s : null, d = o.id === "matching" && c === "active" && e ? ya(e, r) : null, p = o.id === "building" && c === "active" && i > 0 ? n >= i ? `Added ${i} item${i !== 1 ? "s" : ""}` : `Adding item ${n + 1} of ${i}...` : null;
5982
6005
  return /* @__PURE__ */ h(
5983
6006
  "div",
5984
6007
  {
5985
6008
  "data-testid": "processing-step-row",
5986
6009
  "data-status": c,
5987
- className: `flex items-center gap-4 transition-opacity duration-300 ${Lt[c].row}`,
6010
+ className: `flex items-center gap-4 transition-opacity duration-300 ${_t[c].row}`,
5988
6011
  children: [
5989
6012
  /* @__PURE__ */ h(
5990
6013
  "div",
5991
6014
  {
5992
- className: `flex items-center justify-center w-8 h-8 rounded-full shrink-0 transition-all duration-300 ${Lt[c].icon}${c === "complete" ? " animate-step-pulse" : ""}${c === "active" ? " bg-surface-invert shadow-step" : ""}`,
6015
+ className: `flex items-center justify-center w-8 h-8 rounded-full shrink-0 transition-all duration-300 ${_t[c].icon}${c === "complete" ? " animate-step-pulse" : ""}${c === "active" ? " bg-surface-invert shadow-step" : ""}`,
5993
6016
  children: [
5994
6017
  c === "complete" && /* @__PURE__ */ a(Ue, { size: 16, title: "Complete" }),
5995
- c === "active" && /* @__PURE__ */ a(Me, { size: 16 }),
6018
+ c === "active" && /* @__PURE__ */ a(Oe, { size: 16 }),
5996
6019
  c === "pending" && /* @__PURE__ */ a("div", { className: "w-2 h-2 rounded-full bg-border-strong" })
5997
6020
  ]
5998
6021
  }
@@ -6029,17 +6052,17 @@ function xa({
6029
6052
  );
6030
6053
  }) }) });
6031
6054
  }
6032
- function ba({
6055
+ function Ca({
6033
6056
  cartItems: t,
6034
6057
  isUploading: e = !1
6035
6058
  }) {
6036
- const r = Pr(), n = g((s) => s.cartifact.orderId), i = g(
6059
+ const r = kr(), n = g((s) => s.cartifact.orderId), i = g(
6037
6060
  (s) => s.parser.parsedContent
6038
6061
  );
6039
6062
  return /* @__PURE__ */ a("div", { className: "animate-fade-in-scale flex flex-col w-full max-w-[900px] gap-10 bg-surface rounded-2xl p-10 max-md:p-6 border border-border-strong border-solid", children: /* @__PURE__ */ h("div", { className: "flex w-full justify-center gap-32 max-md:flex-col max-md:gap-8", children: [
6040
- /* @__PURE__ */ a("div", { className: "shrink-0 flex items-center justify-center", children: /* @__PURE__ */ a(xa, { currentStep: r }) }),
6063
+ /* @__PURE__ */ a("div", { className: "shrink-0 flex items-center justify-center", children: /* @__PURE__ */ a(ba, { currentStep: r }) }),
6041
6064
  /* @__PURE__ */ a("div", { className: "shrink-0 flex items-center justify-center min-w-80", children: /* @__PURE__ */ a(
6042
- ia,
6065
+ oa,
6043
6066
  {
6044
6067
  items: t,
6045
6068
  orderId: n,
@@ -6050,7 +6073,7 @@ function ba({
6050
6073
  ) })
6051
6074
  ] }) });
6052
6075
  }
6053
- function Ca({
6076
+ function va({
6054
6077
  onFileUpload: t,
6055
6078
  onSkip: e,
6056
6079
  onClearError: r,
@@ -6058,7 +6081,7 @@ function Ca({
6058
6081
  isUploading: i = !1,
6059
6082
  parserError: s = null
6060
6083
  }) {
6061
- const c = Pr() !== null, l = ar({
6084
+ const c = kr() !== null, l = sr({
6062
6085
  onFile: t,
6063
6086
  onBeforeValidate: r
6064
6087
  }), d = s || l.fileError, p = M(() => {
@@ -6069,12 +6092,12 @@ function Ca({
6069
6092
  {
6070
6093
  className: `upload-step flex flex-col w-full flex-1 min-h-0 ${l.isDragging ? "upload-step-dragging" : ""} ${c ? "upload-step-processing" : ""}`,
6071
6094
  ...l.dragProps,
6072
- children: /* @__PURE__ */ a("div", { className: "upload-step-content animate-fade-in-up flex-1 flex items-center justify-center min-h-0 relative", children: c ? /* @__PURE__ */ a(ba, { cartItems: n, isUploading: i }) : /* @__PURE__ */ a(
6073
- aa,
6095
+ children: /* @__PURE__ */ a("div", { className: "upload-step-content animate-fade-in-up flex-1 flex items-center justify-center min-h-0 relative", children: c ? /* @__PURE__ */ a(Ca, { cartItems: n, isUploading: i }) : /* @__PURE__ */ a(
6096
+ ia,
6074
6097
  {
6075
6098
  isDragging: l.isDragging,
6076
6099
  fileInputRef: l.fileInputRef,
6077
- acceptedExtensions: rr,
6100
+ acceptedExtensions: tr,
6078
6101
  displayError: d,
6079
6102
  onDropZoneClick: p,
6080
6103
  onFileChange: l.handleFileChange,
@@ -6097,16 +6120,16 @@ function he(t) {
6097
6120
  shouldSaveAddress: !1
6098
6121
  };
6099
6122
  }
6100
- function Ut(t, e) {
6123
+ function Lt(t, e) {
6101
6124
  if (!(!t.address1 || !t.postalCode))
6102
6125
  return e.find(
6103
6126
  (r) => r.address1?.toLowerCase() === t.address1.toLowerCase() && r.postalCode?.toLowerCase() === t.postalCode?.toLowerCase()
6104
6127
  );
6105
6128
  }
6106
- function Tr(t, e) {
6129
+ function Pr(t, e) {
6107
6130
  return t !== void 0 && Math.abs(t - e) > 0.01;
6108
6131
  }
6109
- function va(t, e) {
6132
+ function Ia(t, e) {
6110
6133
  const r = [...t];
6111
6134
  for (const n of e) {
6112
6135
  const i = r.findIndex(
@@ -6116,7 +6139,7 @@ function va(t, e) {
6116
6139
  }
6117
6140
  return r;
6118
6141
  }
6119
- function Ia(t, e) {
6142
+ function wa(t, e) {
6120
6143
  const r = [], n = [];
6121
6144
  for (const i of e) {
6122
6145
  const s = t.find(
@@ -6131,12 +6154,12 @@ function Ia(t, e) {
6131
6154
  }
6132
6155
  return { toAdd: r, toUpdate: n };
6133
6156
  }
6134
- function wa(t, e) {
6157
+ function Sa(t, e) {
6135
6158
  const r = [];
6136
6159
  for (const n of t.lineItems.physicalItems) {
6137
6160
  const i = e.find(
6138
6161
  (l) => l.productEntityId === n.productEntityId && l.variantEntityId === n.variantEntityId
6139
- ), s = i?.poPriceValue, o = n.listPrice.value, c = Tr(s, o);
6162
+ ), s = i?.poPriceValue, o = n.listPrice.value, c = Pr(s, o);
6140
6163
  r.push({
6141
6164
  id: n.entityId,
6142
6165
  sku: n.sku,
@@ -6160,14 +6183,14 @@ function Ke(t) {
6160
6183
  function Je(t) {
6161
6184
  return t.toLowerCase();
6162
6185
  }
6163
- function Sa(t, e) {
6186
+ function Ea(t, e) {
6164
6187
  return t.filter(
6165
6188
  (r) => !e.some(
6166
6189
  (n) => r.productSku && n.sku && Ke(r.productSku) === Ke(n.sku) || r.productName && n.name && Je(r.productName) === Je(n.name)
6167
6190
  )
6168
6191
  );
6169
6192
  }
6170
- function Ea(t) {
6193
+ function Na(t) {
6171
6194
  const { client: e, onError: r } = t, n = D(e), i = D(r);
6172
6195
  i.current = r;
6173
6196
  const s = g((f) => f.bcSession.bcCart), o = g((f) => f.bcSession.checkout), c = g(
@@ -6180,7 +6203,7 @@ function Ea(t) {
6180
6203
  (f) => f.ui.addressUpdateStatus
6181
6204
  ), u = g((f) => f.bcSession.isLoading), m = g(
6182
6205
  (f) => f.bcSession.productCache
6183
- ), v = g(
6206
+ ), C = g(
6184
6207
  (f) => f.cartifact.poItemPrices
6185
6208
  ), b = g((f) => f.setBcCart), x = g((f) => f.setCheckout), I = g(
6186
6209
  (f) => f.setSelectedAddressId
@@ -6201,7 +6224,7 @@ function Ea(t) {
6201
6224
  ), te = g(
6202
6225
  (f) => f.setItemWarnings
6203
6226
  ), j = ee(() => s ? s.lineItems.physicalItems.map((f) => {
6204
- const S = `${f.productEntityId}-${f.variantEntityId}`, E = v[S];
6227
+ const S = `${f.productEntityId}-${f.variantEntityId}`, E = C[S];
6205
6228
  return {
6206
6229
  productEntityId: f.productEntityId,
6207
6230
  variantEntityId: f.variantEntityId ?? void 0,
@@ -6209,7 +6232,7 @@ function Ea(t) {
6209
6232
  poPriceValue: E?.poPrice,
6210
6233
  poPriceCurrencyCode: E?.poCurrency
6211
6234
  };
6212
- }) : [], [s, v]), Y = D(/* @__PURE__ */ new Set()), re = M(
6235
+ }) : [], [s, C]), Y = D(/* @__PURE__ */ new Set()), re = M(
6213
6236
  async (f, S) => {
6214
6237
  if (!n.current)
6215
6238
  return;
@@ -6298,7 +6321,7 @@ function Ea(t) {
6298
6321
  }
6299
6322
  let f;
6300
6323
  if (l.length > 0) {
6301
- const S = Ut(
6324
+ const S = Lt(
6302
6325
  T,
6303
6326
  l
6304
6327
  );
@@ -6330,7 +6353,7 @@ function Ea(t) {
6330
6353
  return;
6331
6354
  let f;
6332
6355
  if (l.length > 0) {
6333
- const S = Ut(
6356
+ const S = Lt(
6334
6357
  y,
6335
6358
  l
6336
6359
  );
@@ -6361,7 +6384,7 @@ function Ea(t) {
6361
6384
  const z = D(void 0), q = D(void 0), oe = ee(() => s ? s.lineItems.physicalItems.map((f) => {
6362
6385
  const S = j.find(
6363
6386
  (_) => _.productEntityId === f.productEntityId && _.variantEntityId === f.variantEntityId
6364
- ), E = S?.poPriceValue, P = f.listPrice.value, O = Tr(E, P), U = m[f.productEntityId];
6387
+ ), E = S?.poPriceValue, P = f.listPrice.value, O = Pr(E, P), U = m[f.productEntityId];
6365
6388
  return {
6366
6389
  id: f.entityId,
6367
6390
  sku: f.sku ?? "",
@@ -6414,11 +6437,11 @@ function Ea(t) {
6414
6437
  return { cart: s, cartItems: [], errors: [] };
6415
6438
  k(!0);
6416
6439
  try {
6417
- const S = va(j, f), E = await n.current.getCart();
6440
+ const S = Ia(j, f), E = await n.current.getCart();
6418
6441
  let P = null;
6419
6442
  const O = [];
6420
6443
  if (E) {
6421
- const { toAdd: H, toUpdate: ce } = Ia(
6444
+ const { toAdd: H, toUpdate: ce } = wa(
6422
6445
  E.lineItems.physicalItems,
6423
6446
  f
6424
6447
  );
@@ -6491,14 +6514,14 @@ function Ea(t) {
6491
6514
  }
6492
6515
  if (!P)
6493
6516
  return { cart: null, cartItems: [], errors: O };
6494
- const { cartItems: _ } = wa(
6517
+ const { cartItems: _ } = Sa(
6495
6518
  P,
6496
6519
  S
6497
- ), qe = g.getState().cartifact.itemWarnings, Fe = Sa(
6520
+ ), qe = g.getState().cartifact.itemWarnings, De = Ea(
6498
6521
  qe,
6499
6522
  _
6500
6523
  );
6501
- return Fe.length !== qe.length && te(Fe), { cart: P, cartItems: _, errors: O };
6524
+ return De.length !== qe.length && te(De), { cart: P, cartItems: _, errors: O };
6502
6525
  } finally {
6503
6526
  k(!1);
6504
6527
  }
@@ -6571,7 +6594,7 @@ function Ea(t) {
6571
6594
  b,
6572
6595
  k
6573
6596
  ]
6574
- ), Pe = M(
6597
+ ), Te = M(
6575
6598
  async (f) => {
6576
6599
  if (!n.current || !s?.entityId)
6577
6600
  return null;
@@ -6773,7 +6796,7 @@ function Ea(t) {
6773
6796
  cartItems: oe,
6774
6797
  addToCart: G,
6775
6798
  updateLineItemQuantity: K,
6776
- removeLineItem: Pe,
6799
+ removeLineItem: Te,
6777
6800
  initiateCheckout: fe,
6778
6801
  setShippingAddressOnCheckout: me,
6779
6802
  setBillingAddressOnCheckout: de,
@@ -6782,7 +6805,7 @@ function Ea(t) {
6782
6805
  setSelectedBillingAddressId: B
6783
6806
  };
6784
6807
  }
6785
- function Na({
6808
+ function ka({
6786
6809
  bcCart: t,
6787
6810
  cartItems: e,
6788
6811
  onCheckoutInitiated: r,
@@ -6802,12 +6825,12 @@ function Na({
6802
6825
  }
6803
6826
  }, [t, r, n]), o = M(
6804
6827
  async (u, m) => {
6805
- const v = e.find((b) => b.id === u);
6806
- !v?.productEntityId || !v?.variantEntityId || await t.updateLineItemQuantity(
6828
+ const C = e.find((b) => b.id === u);
6829
+ !C?.productEntityId || !C?.variantEntityId || await t.updateLineItemQuantity(
6807
6830
  u,
6808
6831
  m,
6809
- v.productEntityId,
6810
- v.variantEntityId
6832
+ C.productEntityId,
6833
+ C.variantEntityId
6811
6834
  );
6812
6835
  },
6813
6836
  [e, t]
@@ -6817,8 +6840,8 @@ function Na({
6817
6840
  },
6818
6841
  [t]
6819
6842
  ), l = M(
6820
- async (u, m, v) => {
6821
- const { productEntityId: b } = u, x = v ?? u.variantEntityId;
6843
+ async (u, m, C) => {
6844
+ const { productEntityId: b } = u, x = C ?? u.variantEntityId;
6822
6845
  if (!b || !x)
6823
6846
  return console.error("Cannot add to cart: missing entity IDs", u), !1;
6824
6847
  const I = u.availableQuantity !== void 0 && u.availableQuantity > 0 ? Math.min(m, u.availableQuantity) : m;
@@ -6837,14 +6860,14 @@ function Na({
6837
6860
  [t]
6838
6861
  ), d = M(
6839
6862
  (u, m) => {
6840
- const v = m ? `Suggest alternatives for "${u}" (SKU: ${m})` : `Suggest alternatives for "${u}"`;
6841
- i(v);
6863
+ const C = m ? `Suggest alternatives for "${u}" (SKU: ${m})` : `Suggest alternatives for "${u}"`;
6864
+ i(C);
6842
6865
  },
6843
6866
  [i]
6844
6867
  ), p = M(
6845
6868
  (u, m) => {
6846
- const v = m ? `Show more products like "${u}" (SKU: ${m})` : `Show more products like "${u}"`;
6847
- i(v);
6869
+ const C = m ? `Show more products like "${u}" (SKU: ${m})` : `Show more products like "${u}"`;
6870
+ i(C);
6848
6871
  },
6849
6872
  [i]
6850
6873
  );
@@ -6857,19 +6880,19 @@ function Na({
6857
6880
  handleShowMoreLikeThis: p
6858
6881
  };
6859
6882
  }
6860
- const st = /* @__PURE__ */ new Set([
6861
- Oe,
6862
- ut,
6883
+ const nt = /* @__PURE__ */ new Set([
6884
+ Fe,
6885
+ dt,
6863
6886
  Ye,
6864
- pt
6865
- ]), ka = "did not produce any output";
6866
- function Pa(t) {
6867
- const e = t.filter((n) => st.has(n.toolName)).map((n) => n.toolName);
6887
+ ut
6888
+ ]), Pa = "did not produce any output";
6889
+ function Ta(t) {
6890
+ const e = t.filter((n) => nt.has(n.toolName)).map((n) => n.toolName);
6868
6891
  return e.length === 0 ? "" : `
6869
6892
 
6870
6893
  Tools called: ${[...new Set(e)].join(", ")}`;
6871
6894
  }
6872
- async function Ta(t, e, r, n, i, s) {
6895
+ async function Aa(t, e, r, n, i, s) {
6873
6896
  const o = [], c = [], l = [], d = [];
6874
6897
  let p = [
6875
6898
  {
@@ -6890,7 +6913,7 @@ async function Ta(t, e, r, n, i, s) {
6890
6913
  onToolCall: s?.onToolCall,
6891
6914
  onToolOutput: s?.onToolOutput
6892
6915
  });
6893
- if (c.push(...y.textParts), o.push(...y.toolCalls), y.finalMessage && l.push(y.finalMessage), y.errorMessage?.includes(ka)) {
6916
+ if (c.push(...y.textParts), o.push(...y.toolCalls), y.finalMessage && l.push(y.finalMessage), y.errorMessage?.includes(Pa)) {
6894
6917
  s?.logger?.debug(
6895
6918
  `Batch ${i}: Exiting loop - no output error`
6896
6919
  );
@@ -6908,10 +6931,10 @@ async function Ta(t, e, r, n, i, s) {
6908
6931
  error: y.errorMessage
6909
6932
  };
6910
6933
  const A = y.toolCalls.filter(
6911
- (B) => st.has(B.toolName) || !y.serverHandledToolCallIds.has(B.toolCallId)
6934
+ (B) => nt.has(B.toolName) || !y.serverHandledToolCallIds.has(B.toolCallId)
6912
6935
  );
6913
6936
  for (const B of A)
6914
- st.has(B.toolName) && d.push(B);
6937
+ nt.has(B.toolName) && d.push(B);
6915
6938
  if (A.length === 0) {
6916
6939
  s?.logger?.debug(
6917
6940
  `Batch ${i}: Exiting loop - no client tool calls to respond to`
@@ -6949,22 +6972,22 @@ async function Ta(t, e, r, n, i, s) {
6949
6972
  },
6950
6973
  {
6951
6974
  role: "user",
6952
- parts: [{ type: "text", text: ot }]
6975
+ parts: [{ type: "text", text: it }]
6953
6976
  }
6954
6977
  ];
6955
6978
  }
6956
6979
  m >= u && s?.logger?.debug(
6957
6980
  `Batch ${i}: WARNING - Hit max iterations limit (${u})`
6958
6981
  );
6959
- const v = l.length > 0 ? l.join(`
6982
+ const C = l.length > 0 ? l.join(`
6960
6983
 
6961
- `) : c.join(""), b = Pa(o), x = v + b, w = d.filter(
6962
- (T) => T.toolName === Oe
6984
+ `) : c.join(""), b = Ta(o), x = C + b, w = d.filter(
6985
+ (T) => T.toolName === Fe
6963
6986
  ).reduce((T, y) => {
6964
6987
  const A = y.input?.value;
6965
6988
  return T + (A?.length ?? 0);
6966
6989
  }, 0), N = d.filter(
6967
- (T) => T.toolName === pt
6990
+ (T) => T.toolName === ut
6968
6991
  ).reduce((T, y) => {
6969
6992
  const A = y.input?.processingFailures;
6970
6993
  return T + (A?.length ?? 0);
@@ -6979,11 +7002,11 @@ async function Ta(t, e, r, n, i, s) {
6979
7002
  pendingClientToolCalls: d
6980
7003
  };
6981
7004
  }
6982
- async function Aa(t, e, r, n) {
7005
+ async function Ba(t, e, r, n) {
6983
7006
  if (r.length === 0)
6984
7007
  return { results: [], hasErrors: !1 };
6985
7008
  const s = (await Promise.allSettled(
6986
- r.map(() => Sr(t, e))
7009
+ r.map(() => wr(t, e))
6987
7010
  )).map((l, d) => {
6988
7011
  if (l.status === "fulfilled")
6989
7012
  return n?.onThreadCreated?.(d, l.value), l.value;
@@ -6992,7 +7015,7 @@ async function Aa(t, e, r, n) {
6992
7015
  `Failed to create thread for batch ${d}`,
6993
7016
  l.reason
6994
7017
  ), n?.onError?.(d, p), null;
6995
- }), o = await Qr(
7018
+ }), o = await Hr(
6996
7019
  r,
6997
7020
  async (l, d) => {
6998
7021
  const p = s[d];
@@ -7006,7 +7029,7 @@ async function Aa(t, e, r, n) {
7006
7029
  error: "Failed to create thread"
7007
7030
  };
7008
7031
  try {
7009
- const u = await Ta(
7032
+ const u = await Aa(
7010
7033
  t,
7011
7034
  e,
7012
7035
  p,
@@ -7031,28 +7054,38 @@ async function Aa(t, e, r, n) {
7031
7054
  ), c = o.some((l) => l.error !== void 0);
7032
7055
  return { results: o, hasErrors: c };
7033
7056
  }
7034
- function Ba(t) {
7057
+ function $a(t) {
7035
7058
  const e = [];
7036
7059
  let r = null;
7037
- const n = [];
7038
- for (const i of t) {
7039
- if (i.error)
7060
+ const n = [], i = [];
7061
+ for (const s of t) {
7062
+ if (s.error) {
7063
+ i.push({
7064
+ batchIndex: s.batchIndex,
7065
+ error: s.error
7066
+ });
7040
7067
  continue;
7041
- let s = 0, o = 0;
7042
- for (const c of i.pendingClientToolCalls)
7043
- if (c.toolName === Oe) {
7044
- const l = c.input;
7045
- l.value && (s += l.value.length, e.push(...l.value));
7046
- } else if (c.toolName === Ye)
7047
- r = c.input;
7048
- else if (c.toolName === pt) {
7049
- const l = c.input;
7050
- l.processingFailures && (o += l.processingFailures.length, n.push(...l.processingFailures));
7068
+ }
7069
+ let o = 0, c = 0;
7070
+ for (const l of s.pendingClientToolCalls)
7071
+ if (l.toolName === Fe) {
7072
+ const d = l.input;
7073
+ d.value && (o += d.value.length, e.push(...d.value));
7074
+ } else if (l.toolName === Ye)
7075
+ r = l.input;
7076
+ else if (l.toolName === ut) {
7077
+ const d = l.input;
7078
+ d.processingFailures && (c += d.processingFailures.length, n.push(...d.processingFailures));
7051
7079
  }
7052
7080
  }
7053
- return { addToCartItems: e, setPoMetadataArgs: r, processingFailures: n };
7081
+ return {
7082
+ addToCartItems: e,
7083
+ setPoMetadataArgs: r,
7084
+ processingFailures: n,
7085
+ batchFailures: i
7086
+ };
7054
7087
  }
7055
- function $a(t) {
7088
+ function Ma(t) {
7056
7089
  if (t.length === 0)
7057
7090
  return "";
7058
7091
  const e = [
@@ -7068,7 +7101,23 @@ function $a(t) {
7068
7101
  return e.join(`
7069
7102
  `);
7070
7103
  }
7071
- function Ma(t) {
7104
+ function Oa(t) {
7105
+ if (t.length === 0)
7106
+ return "";
7107
+ const e = [
7108
+ "",
7109
+ "---",
7110
+ "## Batch Processing Failures",
7111
+ "",
7112
+ `${t.length} batch${t.length > 1 ? "es" : ""} could not be processed. Items from these batches were not added to the cart:`,
7113
+ ""
7114
+ ];
7115
+ for (const r of t)
7116
+ e.push(`- Batch ${r.batchIndex + 1}: ${r.error}`);
7117
+ return e.push(""), e.join(`
7118
+ `);
7119
+ }
7120
+ function Fa(t) {
7072
7121
  if (t.length === 0) return "";
7073
7122
  const e = ["---", "## Failed Tool Calls", ""];
7074
7123
  for (const r of t) {
@@ -7084,8 +7133,8 @@ function Ma(t) {
7084
7133
  return e.join(`
7085
7134
  `);
7086
7135
  }
7087
- async function Oa(t, e) {
7088
- const r = Ba(t);
7136
+ async function Da(t, e) {
7137
+ const r = $a(t);
7089
7138
  if (r.setPoMetadataArgs) {
7090
7139
  const s = r.setPoMetadataArgs;
7091
7140
  g.getState().applyPoMetadata(s.poMetadata);
@@ -7095,20 +7144,17 @@ async function Oa(t, e) {
7095
7144
  const { errors: s } = await e.addToCart(r.addToCartItems);
7096
7145
  n = s, s.length > 0 && console.error("Failed to add some items to cart:", s);
7097
7146
  }
7098
- const i = $a(
7099
- r.processingFailures
7100
- );
7101
- if (n.length > 0) {
7102
- const s = Ma(n);
7103
- return i ? `${i}
7104
- ${s}` : s;
7105
- }
7106
- return i;
7147
+ return [
7148
+ Oa(r.batchFailures),
7149
+ Ma(r.processingFailures),
7150
+ n.length > 0 ? Fa(n) : ""
7151
+ ].filter(Boolean).join(`
7152
+ `);
7107
7153
  }
7108
- async function Fa(t, e) {
7154
+ async function Ra(t, e) {
7109
7155
  if (e.length === 0)
7110
7156
  return { results: [], processingFailuresString: "", hasErrors: !1 };
7111
- const r = await Aa(
7157
+ const r = await Ba(
7112
7158
  t.takeshapeConfig,
7113
7159
  t.agentName,
7114
7160
  e,
@@ -7118,11 +7164,20 @@ async function Fa(t, e) {
7118
7164
  },
7119
7165
  onThreadCreated: (i, s) => {
7120
7166
  g.getState().addBatchThreadId(s);
7167
+ },
7168
+ onError: (i, s) => {
7169
+ qs(
7170
+ new Error(`Batch ${i} failed: ${s}`),
7171
+ {
7172
+ tags: { component: "batch-processor" },
7173
+ extra: { batchIndex: i, errorMessage: s }
7174
+ }
7175
+ );
7121
7176
  }
7122
7177
  }
7123
7178
  );
7124
7179
  let n = "";
7125
- return t.bcCart && (n = await Oa(
7180
+ return t.bcCart && (n = await Da(
7126
7181
  r.results,
7127
7182
  t.bcCart
7128
7183
  )), {
@@ -7131,7 +7186,7 @@ async function Fa(t, e) {
7131
7186
  hasErrors: r.hasErrors
7132
7187
  };
7133
7188
  }
7134
- function Da(t) {
7189
+ function _a(t) {
7135
7190
  const { bcCart: e } = t, r = g(
7136
7191
  (d) => d.takeshapeConfig
7137
7192
  ), n = g(
@@ -7155,19 +7210,28 @@ function Da(t) {
7155
7210
  bcCart: e
7156
7211
  };
7157
7212
  try {
7158
- const u = await Fa(p, d);
7213
+ const u = await Ra(p, d);
7159
7214
  if (s(
7160
7215
  u.results,
7161
7216
  u.processingFailuresString
7162
7217
  ), u.hasErrors) {
7163
7218
  n("error");
7164
- const m = u.results.filter((v) => v.error).length;
7219
+ const m = u.results.filter((C) => C.error).length;
7165
7220
  i(
7166
7221
  `${m} of ${d.length} batches failed to process`
7167
7222
  );
7168
7223
  } else
7169
7224
  n("complete");
7170
- return u.processingFailuresString ? c(u.processingFailuresString) : c("No failures detected."), u;
7225
+ if (u.processingFailuresString)
7226
+ c(u.processingFailuresString);
7227
+ else if (u.hasErrors) {
7228
+ const m = u.results.filter((C) => C.error).length;
7229
+ c(
7230
+ `${m} of ${d.length} batches failed to process. No items were added to the cart.`
7231
+ );
7232
+ } else
7233
+ c("No failures detected.");
7234
+ return u;
7171
7235
  } catch (u) {
7172
7236
  const m = u instanceof Error ? u.message : "Unknown error";
7173
7237
  throw i(m), n("error"), u;
@@ -7185,7 +7249,7 @@ function Da(t) {
7185
7249
  reset: o
7186
7250
  };
7187
7251
  }
7188
- function Ra({
7252
+ function La({
7189
7253
  appState: t,
7190
7254
  setAppState: e,
7191
7255
  parser: r,
@@ -7197,7 +7261,7 @@ function Ra({
7197
7261
  (u) => u.parser.hasProcessedDocument
7198
7262
  ), l = g(
7199
7263
  (u) => u.setHasProcessedDocument
7200
- ), { processBatches: d } = Da({ bcCart: s });
7264
+ ), { processBatches: d } = _a({ bcCart: s });
7201
7265
  return F(() => {
7202
7266
  t === "processing" && r.parserStatus !== "streaming" && r.parserStatus !== "submitted" && r.parsedContent && r.parserMessages.length > 0 && !o.current && (o.current = !0, l(!0), d(r.parsedContent));
7203
7267
  }, [
@@ -7223,30 +7287,30 @@ function Ra({
7223
7287
  }
7224
7288
  };
7225
7289
  }
7226
- const _a = "<!-- BATCH -->";
7227
- function La(t) {
7228
- return t.split(_a).map((e) => e.trim()).filter(Boolean);
7290
+ const Ua = "<!-- BATCH -->";
7291
+ function qa(t) {
7292
+ return t.split(Ua).map((e) => e.trim()).filter(Boolean);
7229
7293
  }
7230
- function Ua(t) {
7294
+ function ja(t) {
7231
7295
  return new Promise((e, r) => {
7232
7296
  const n = new FileReader();
7233
7297
  n.onload = () => e(n.result), n.onerror = () => r(new Error("Failed to read file")), n.readAsText(t);
7234
7298
  });
7235
7299
  }
7236
- function qa(t) {
7300
+ function Wa(t) {
7237
7301
  return new Promise((e, r) => {
7238
7302
  const n = new FileReader();
7239
7303
  n.onload = () => e(n.result), n.onerror = () => r(new Error("Failed to read file")), n.readAsDataURL(t);
7240
7304
  });
7241
7305
  }
7242
- const ja = /* @__PURE__ */ new Set([
7306
+ const Va = /* @__PURE__ */ new Set([
7243
7307
  "application/vnd.ms-excel",
7244
7308
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
7245
7309
  ]);
7246
- function qt(t) {
7247
- return ja.has(t);
7310
+ function Ut(t) {
7311
+ return Va.has(t);
7248
7312
  }
7249
- async function Wa(t) {
7313
+ async function za(t) {
7250
7314
  const e = await import("xlsx"), r = await t.arrayBuffer(), n = e.read(r, { type: "array" });
7251
7315
  if (n.SheetNames.length === 0)
7252
7316
  throw new Error("Workbook contains no sheets");
@@ -7258,27 +7322,27 @@ async function Wa(t) {
7258
7322
  const s = e.utils.json_to_sheet(i);
7259
7323
  return e.utils.sheet_to_csv(s);
7260
7324
  }
7261
- const Va = "%PDF-", za = "%%EOF", Ha = 256;
7262
- function Qa(t) {
7325
+ const Ha = "%PDF-", Qa = "%%EOF", Ga = 256;
7326
+ function Ka(t) {
7263
7327
  return new Promise((e, r) => {
7264
7328
  const n = new FileReader();
7265
7329
  n.onload = () => e(n.result), n.onerror = () => r(n.error), n.readAsArrayBuffer(t);
7266
7330
  });
7267
7331
  }
7268
- async function Ga(t) {
7269
- if (t.size < Ha) return { valid: !1, reason: "invalid" };
7332
+ async function Ja(t) {
7333
+ if (t.size < Ga) return { valid: !1, reason: "invalid" };
7270
7334
  let e;
7271
7335
  try {
7272
- e = new Uint8Array(await Qa(t));
7336
+ e = new Uint8Array(await Ka(t));
7273
7337
  } catch {
7274
7338
  return { valid: !1, reason: "invalid" };
7275
7339
  }
7276
- if (!String.fromCharCode(...e.slice(0, 5)).startsWith(Va))
7340
+ if (!String.fromCharCode(...e.slice(0, 5)).startsWith(Ha))
7277
7341
  return { valid: !1, reason: "invalid" };
7278
7342
  const n = Math.min(1024, e.length);
7279
7343
  if (!String.fromCharCode(
7280
7344
  ...e.slice(e.length - n)
7281
- ).includes(za))
7345
+ ).includes(Qa))
7282
7346
  return { valid: !1, reason: "invalid" };
7283
7347
  const s = Math.max(0, e.length - 8192), o = new TextDecoder().decode(e.slice(s)), c = o.lastIndexOf("<<"), l = o.lastIndexOf(">>");
7284
7348
  if (c !== -1 && l !== -1 && c < l && o.substring(c, l).includes("/Encrypt"))
@@ -7302,24 +7366,24 @@ async function Ga(t) {
7302
7366
  }
7303
7367
  return { valid: !0 };
7304
7368
  }
7305
- const Ka = /* @__PURE__ */ new Set([
7369
+ const Ya = /* @__PURE__ */ new Set([
7306
7370
  "text/csv",
7307
7371
  "text/plain",
7308
7372
  "application/json"
7309
- ]), Ar = "Please parse this document and extract relevant purchase order information.";
7310
- function jt(t, e) {
7373
+ ]), Tr = "Please parse this document and extract relevant purchase order information.";
7374
+ function qt(t, e) {
7311
7375
  return [
7312
7376
  {
7313
7377
  type: "text",
7314
- text: `${Ar.replace("this document", `this ${t} document`)}
7378
+ text: `${Tr.replace("this document", `this ${t} document`)}
7315
7379
 
7316
7380
  ${e}`
7317
7381
  }
7318
7382
  ];
7319
7383
  }
7320
- function Ja(t, e, r) {
7384
+ function Za(t, e, r) {
7321
7385
  return [
7322
- { type: "text", text: Ar },
7386
+ { type: "text", text: Tr },
7323
7387
  {
7324
7388
  type: "file",
7325
7389
  url: t,
@@ -7328,7 +7392,7 @@ function Ja(t, e, r) {
7328
7392
  }
7329
7393
  ];
7330
7394
  }
7331
- function Ya({
7395
+ function Xa({
7332
7396
  createParserThread: t,
7333
7397
  sendParserMessage: e
7334
7398
  }) {
@@ -7336,7 +7400,7 @@ function Ya({
7336
7400
  async (c) => {
7337
7401
  const l = g.getState();
7338
7402
  if (l.setParsedContent(null), n(!0), l.setUploadedFileName(c.name), s(null), c.type === "application/pdf") {
7339
- const d = await Ga(c);
7403
+ const d = await Ja(c);
7340
7404
  if (!d.valid)
7341
7405
  return s(
7342
7406
  d.reason === "password-protected" ? "The PDF appears to be password protected." : "The file does not appear to be a valid PDF."
@@ -7344,20 +7408,20 @@ function Ya({
7344
7408
  }
7345
7409
  await t();
7346
7410
  try {
7347
- if (qt(c.type)) {
7348
- const d = await Wa(c);
7349
- e({ parts: jt(c.name, d) });
7350
- } else if (Ka.has(c.type)) {
7351
- const d = await Ua(c);
7352
- e({ parts: jt(c.name, d) });
7411
+ if (Ut(c.type)) {
7412
+ const d = await za(c);
7413
+ e({ parts: qt(c.name, d) });
7414
+ } else if (Ya.has(c.type)) {
7415
+ const d = await ja(c);
7416
+ e({ parts: qt(c.name, d) });
7353
7417
  } else {
7354
- const d = await qa(c);
7418
+ const d = await Wa(c);
7355
7419
  e({
7356
- parts: Ja(d, c.type, c.name)
7420
+ parts: Za(d, c.type, c.name)
7357
7421
  });
7358
7422
  }
7359
7423
  } catch (d) {
7360
- console.error("Failed to read file:", d), qt(c.type) ? s(
7424
+ console.error("Failed to read file:", d), Ut(c.type) ? s(
7361
7425
  "Failed to read the spreadsheet file. Please try saving it as CSV and uploading again."
7362
7426
  ) : g.getState().setParsedContent(null), n(!1);
7363
7427
  }
@@ -7372,7 +7436,7 @@ function Ya({
7372
7436
  handleFileUpload: o
7373
7437
  };
7374
7438
  }
7375
- function Br(t) {
7439
+ function Ar(t) {
7376
7440
  const {
7377
7441
  agentName: e,
7378
7442
  createOnMount: r,
@@ -7380,32 +7444,32 @@ function Br(t) {
7380
7444
  persist: i = !0,
7381
7445
  onThreadCreated: s
7382
7446
  } = t, { projectId: o, apiKey: c, origin: l } = g(
7383
- (v) => v.takeshapeConfig
7447
+ (C) => C.takeshapeConfig
7384
7448
  ), [d, p] = R(!1), u = D(
7385
7449
  n ? { id: n } : null
7386
7450
  ), m = M(async () => {
7387
7451
  p(!0);
7388
- const v = 2;
7452
+ const C = 2;
7389
7453
  let b = 0;
7390
- for (; b <= v; )
7454
+ for (; b <= C; )
7391
7455
  try {
7392
- const x = await Sr(
7456
+ const x = await wr(
7393
7457
  { origin: l, projectId: o, apiKey: c },
7394
7458
  e
7395
7459
  );
7396
7460
  p(!1), u.current = { id: x }, i && g.getState().setThreadId(x), s?.(x);
7397
7461
  return;
7398
7462
  } catch (x) {
7399
- if (b === v) {
7463
+ if (b === C) {
7400
7464
  p(!1), console.error(
7401
- `Failed to create thread after ${v + 1} attempts:`,
7465
+ `Failed to create thread after ${C + 1} attempts:`,
7402
7466
  x
7403
7467
  );
7404
7468
  return;
7405
7469
  }
7406
7470
  const w = 500 * 2 ** b;
7407
7471
  console.warn(
7408
- `Thread creation failed (attempt ${b + 1}/${v + 1}), retrying in ${w}ms...`,
7472
+ `Thread creation failed (attempt ${b + 1}/${C + 1}), retrying in ${w}ms...`,
7409
7473
  x
7410
7474
  ), await new Promise((k) => setTimeout(k, w)), b++;
7411
7475
  }
@@ -7418,12 +7482,12 @@ function Br(t) {
7418
7482
  createThread: m
7419
7483
  };
7420
7484
  }
7421
- function Za() {
7485
+ function ei() {
7422
7486
  const { sseOrigin: t, projectId: e, apiKey: r } = g(
7423
7487
  (y) => y.takeshapeConfig
7424
7488
  ), n = g(
7425
7489
  (y) => y.setParserThreadId
7426
- ), { thread: i, createThread: s } = Br({
7490
+ ), { thread: i, createThread: s } = Ar({
7427
7491
  agentName: "documentParser",
7428
7492
  createOnMount: !1,
7429
7493
  persist: !1,
@@ -7440,8 +7504,8 @@ function Za() {
7440
7504
  sendMessage: p,
7441
7505
  status: u,
7442
7506
  setMessages: m
7443
- } = Vt({
7444
- transport: new zt({
7507
+ } = Wt({
7508
+ transport: new Vt({
7445
7509
  api: `${t}/project/${e}/agents/messages`,
7446
7510
  headers: {
7447
7511
  Authorization: `Bearer ${r}`
@@ -7471,16 +7535,16 @@ function Za() {
7471
7535
  ), l.current?.setStatus({ code: 2, message: "internal_error" }), l.current?.end(), l.current = null, b(!1);
7472
7536
  }
7473
7537
  }), {
7474
- isUploadingFile: v,
7538
+ isUploadingFile: C,
7475
7539
  setIsUploadingFile: b,
7476
7540
  parserError: x,
7477
7541
  setParserError: I,
7478
7542
  handleFileUpload: w
7479
- } = Ya({
7543
+ } = Xa({
7480
7544
  createParserThread: s,
7481
7545
  sendParserMessage: p
7482
7546
  }), k = M(
7483
- async (y) => (l.current?.end(), l.current = nt({
7547
+ async (y) => (l.current?.end(), l.current = rt({
7484
7548
  name: "document-parser",
7485
7549
  op: "ai.parse",
7486
7550
  attributes: {
@@ -7495,7 +7559,7 @@ function Za() {
7495
7559
  if (d.length > 0) {
7496
7560
  const y = d[d.length - 1];
7497
7561
  if (y?.role === "assistant" && Array.isArray(y.parts)) {
7498
- const A = y.parts.filter((B) => B.type === "text").map((B) => B.text).filter(Boolean), $ = La(A.join(""));
7562
+ const A = y.parts.filter((B) => B.type === "text").map((B) => B.text).filter(Boolean), $ = qa(A.join(""));
7499
7563
  g.getState().setParsedContent($), $ && b(!1);
7500
7564
  }
7501
7565
  }
@@ -7511,7 +7575,7 @@ function Za() {
7511
7575
  }, [m, b, I]);
7512
7576
  return {
7513
7577
  parsedContent: o,
7514
- isUploadingFile: v,
7578
+ isUploadingFile: C,
7515
7579
  uploadedFileName: c,
7516
7580
  parserError: x,
7517
7581
  parserStatus: u,
@@ -7521,7 +7585,7 @@ function Za() {
7521
7585
  reset: T
7522
7586
  };
7523
7587
  }
7524
- class Xa {
7588
+ class ti {
7525
7589
  b2bToken = null;
7526
7590
  companyId = null;
7527
7591
  channelId;
@@ -7529,7 +7593,7 @@ class Xa {
7529
7593
  getB2BJwt;
7530
7594
  initPromise;
7531
7595
  constructor(e) {
7532
- this.channelId = e.channelId, this.getB2BJwt = e.getB2BJwt ?? null, this.graphQLClient = new at(Qt, {
7596
+ this.channelId = e.channelId, this.getB2BJwt = e.getB2BJwt ?? null, this.graphQLClient = new st(Ht, {
7533
7597
  fetch: Ne,
7534
7598
  credentials: "same-origin",
7535
7599
  headers: {
@@ -7584,7 +7648,7 @@ class Xa {
7584
7648
  }
7585
7649
  async getB2BStorefrontToken(e) {
7586
7650
  const r = await this.request({
7587
- document: Kt,
7651
+ document: Gt,
7588
7652
  variables: {
7589
7653
  authData: {
7590
7654
  bcToken: e,
@@ -7595,7 +7659,7 @@ class Xa {
7595
7659
  Authorization: `Bearer ${e}`
7596
7660
  }
7597
7661
  }), i = Ee(
7598
- lt,
7662
+ ct,
7599
7663
  r.authorization
7600
7664
  )?.result?.token;
7601
7665
  if (!i)
@@ -7606,13 +7670,13 @@ class Xa {
7606
7670
  console.debug("[B2BClient] Requesting company ID with customer JWT");
7607
7671
  const r = await this.request(
7608
7672
  {
7609
- document: Zr,
7673
+ document: Yr,
7610
7674
  requestHeaders: {
7611
7675
  Authorization: `Bearer ${e}`
7612
7676
  }
7613
7677
  },
7614
7678
  -1
7615
- ), i = Ee(Jt, r.currentUser)?.companyInfo?.companyId;
7679
+ ), i = Ee(Kt, r.currentUser)?.companyInfo?.companyId;
7616
7680
  if (!i)
7617
7681
  throw new Error("No company ID returned from current user query");
7618
7682
  return console.debug("[B2BClient] Received company ID", i), Number(i);
@@ -7622,7 +7686,7 @@ class Xa {
7622
7686
  return [];
7623
7687
  try {
7624
7688
  const r = (await this.request({
7625
- document: Xr,
7689
+ document: Zr,
7626
7690
  variables: {
7627
7691
  companyId: this.companyId
7628
7692
  },
@@ -7631,7 +7695,7 @@ class Xa {
7631
7695
  }
7632
7696
  }))?.addresses?.edges;
7633
7697
  return r ? r.map(
7634
- (n) => bn(n.node)
7698
+ (n) => xn(n.node)
7635
7699
  ) : [];
7636
7700
  } catch (e) {
7637
7701
  return console.info(
@@ -7645,7 +7709,7 @@ class Xa {
7645
7709
  throw new Error("B2B client is not available");
7646
7710
  try {
7647
7711
  const n = (await this.request({
7648
- document: en,
7712
+ document: Xr,
7649
7713
  variables: {
7650
7714
  cartData: {
7651
7715
  cartId: e
@@ -7667,16 +7731,16 @@ class Xa {
7667
7731
  }
7668
7732
  }
7669
7733
  }
7670
- function ei(t) {
7734
+ function ri(t) {
7671
7735
  return console.debug(
7672
7736
  `[createB2BClient] Initializing B2B client for channelId=${t.channelId}`
7673
- ), new Xa(t);
7737
+ ), new ti(t);
7674
7738
  }
7675
- async function Hi(t) {
7739
+ async function Qi(t) {
7676
7740
  let e = null;
7677
7741
  try {
7678
7742
  const r = await Ne(
7679
- `/customer/current.jwt?app_client_id=${Kr}`,
7743
+ `/customer/current.jwt?app_client_id=${Gr}`,
7680
7744
  {
7681
7745
  method: "GET",
7682
7746
  credentials: "same-origin",
@@ -7696,7 +7760,7 @@ async function Hi(t) {
7696
7760
  console.debug(
7697
7761
  "[stencilB2BJwt] Exchanging customer JWT for B2B storefront token"
7698
7762
  );
7699
- const n = await new at(Qt, {
7763
+ const n = await new st(Ht, {
7700
7764
  fetch: Ne,
7701
7765
  credentials: "same-origin",
7702
7766
  headers: {
@@ -7705,7 +7769,7 @@ async function Hi(t) {
7705
7769
  Authorization: `Bearer ${e}`
7706
7770
  }
7707
7771
  }).request({
7708
- document: Kt,
7772
+ document: Gt,
7709
7773
  variables: {
7710
7774
  authData: {
7711
7775
  bcToken: e,
@@ -7713,7 +7777,7 @@ async function Hi(t) {
7713
7777
  }
7714
7778
  }
7715
7779
  }), s = Ee(
7716
- lt,
7780
+ ct,
7717
7781
  n.authorization
7718
7782
  )?.result?.token;
7719
7783
  return s ? (console.debug("[stencilB2BJwt] Received B2B storefront token"), s) : null;
@@ -7721,7 +7785,7 @@ async function Hi(t) {
7721
7785
  return null;
7722
7786
  }
7723
7787
  }
7724
- async function ti(t, e) {
7788
+ async function ni(t, e) {
7725
7789
  const { setToolCallError: r } = g.getState(), n = t.input;
7726
7790
  let i = "No items provided to add to cart.";
7727
7791
  if (n.value && n.value.length > 0) {
@@ -7733,12 +7797,12 @@ async function ti(t, e) {
7733
7797
  i = `Successfully added ${n.value.length} item(s) to cart.`;
7734
7798
  }
7735
7799
  return {
7736
- tool: Oe,
7800
+ tool: Fe,
7737
7801
  toolCallId: t.toolCallId,
7738
7802
  output: i
7739
7803
  };
7740
7804
  }
7741
- async function ri(t, e) {
7805
+ async function si(t, e) {
7742
7806
  const { setToolCallError: r } = g.getState();
7743
7807
  let n = "Cart cleared successfully.";
7744
7808
  try {
@@ -7748,12 +7812,12 @@ async function ri(t, e) {
7748
7812
  n = `Failed to clear cart: ${s}`, r(t.toolCallId, s);
7749
7813
  }
7750
7814
  return {
7751
- tool: yr,
7815
+ tool: gr,
7752
7816
  toolCallId: t.toolCallId,
7753
7817
  output: n
7754
7818
  };
7755
7819
  }
7756
- function ni(t, e) {
7820
+ function ai(t, e) {
7757
7821
  const r = {
7758
7822
  items: e.cartItems.map((n) => ({
7759
7823
  productEntityId: n.productEntityId,
@@ -7768,23 +7832,23 @@ function ni(t, e) {
7768
7832
  totals: e.checkoutTotals
7769
7833
  };
7770
7834
  return {
7771
- tool: xr,
7835
+ tool: yr,
7772
7836
  toolCallId: t.toolCallId,
7773
7837
  output: JSON.stringify(r)
7774
7838
  };
7775
7839
  }
7776
- function si(t) {
7840
+ function ii(t) {
7777
7841
  const { parser: e } = g.getState(), r = {
7778
7842
  uploadedFileName: e.uploadedFileName,
7779
7843
  parsedContent: e.parsedContent
7780
7844
  };
7781
7845
  return {
7782
- tool: ut,
7846
+ tool: dt,
7783
7847
  toolCallId: t.toolCallId,
7784
7848
  output: JSON.stringify(r)
7785
7849
  };
7786
7850
  }
7787
- async function ai(t, e) {
7851
+ async function oi(t, e) {
7788
7852
  const { setToolCallError: r } = g.getState(), n = t.input;
7789
7853
  let i = "Item removed from cart successfully.";
7790
7854
  try {
@@ -7793,7 +7857,7 @@ async function ai(t, e) {
7793
7857
  ) ?? [];
7794
7858
  if (s.length === 0)
7795
7859
  return {
7796
- tool: gr,
7860
+ tool: mr,
7797
7861
  toolCallId: t.toolCallId,
7798
7862
  output: "Cart item not found."
7799
7863
  };
@@ -7809,7 +7873,7 @@ async function ai(t, e) {
7809
7873
  output: i
7810
7874
  };
7811
7875
  }
7812
- function ii(t) {
7876
+ function ci(t) {
7813
7877
  const {
7814
7878
  cartifact: { itemWarnings: e },
7815
7879
  setItemWarnings: r
@@ -7817,20 +7881,20 @@ function ii(t) {
7817
7881
  (s) => !(n.productSku !== void 0 && s.productSku !== void 0 && Ke(s.productSku) === Ke(n.productSku) || n.productName !== void 0 && s.productName !== void 0 && Je(s.productName) === Je(n.productName))
7818
7882
  );
7819
7883
  return r(i), {
7820
- tool: Cr,
7884
+ tool: br,
7821
7885
  toolCallId: t.toolCallId,
7822
7886
  output: "Item warnings removed successfully."
7823
7887
  };
7824
7888
  }
7825
- function oi(t) {
7889
+ function li(t) {
7826
7890
  const { setItemWarnings: e } = g.getState(), r = t.input;
7827
7891
  return r.itemWarnings && e(r.itemWarnings), {
7828
- tool: br,
7892
+ tool: xr,
7829
7893
  toolCallId: t.toolCallId,
7830
7894
  output: "Item warnings set successfully."
7831
7895
  };
7832
7896
  }
7833
- function ci(t) {
7897
+ function di(t) {
7834
7898
  const e = t.input;
7835
7899
  return g.getState().applyPoMetadata(e.poMetadata), {
7836
7900
  tool: Ye,
@@ -7838,7 +7902,7 @@ function ci(t) {
7838
7902
  output: "PO metadata set successfully."
7839
7903
  };
7840
7904
  }
7841
- async function li(t, e) {
7905
+ async function ui(t, e) {
7842
7906
  const { setToolCallError: r, setPoItemPrice: n } = g.getState(), i = t.input;
7843
7907
  let s = 0;
7844
7908
  try {
@@ -7859,7 +7923,7 @@ async function li(t, e) {
7859
7923
  } catch (o) {
7860
7924
  const c = o instanceof Error ? o.message : "Unknown error";
7861
7925
  return r(t.toolCallId, c), {
7862
- tool: mr,
7926
+ tool: fr,
7863
7927
  toolCallId: t.toolCallId,
7864
7928
  output: `Failed to update cart item: ${c}`
7865
7929
  };
@@ -7870,22 +7934,22 @@ async function li(t, e) {
7870
7934
  output: `${s} cart item(s) updated.`
7871
7935
  };
7872
7936
  }
7873
- const $r = {
7874
- addToCart: ti,
7875
- updateCart: li,
7876
- removeFromCart: ai,
7877
- clearCart: ri,
7878
- getCart: ni,
7879
- getPurchaseOrderData: si,
7880
- setPoMetadata: ci,
7881
- setItemWarnings: oi,
7882
- removeItemWarnings: ii
7883
- }, di = new Set(Object.keys($r));
7884
- async function ui(t, e) {
7885
- const r = $r[t.toolName];
7937
+ const Br = {
7938
+ addToCart: ni,
7939
+ updateCart: ui,
7940
+ removeFromCart: oi,
7941
+ clearCart: si,
7942
+ getCart: ai,
7943
+ getPurchaseOrderData: ii,
7944
+ setPoMetadata: di,
7945
+ setItemWarnings: li,
7946
+ removeItemWarnings: ci
7947
+ }, pi = new Set(Object.keys(Br));
7948
+ async function hi(t, e) {
7949
+ const r = Br[t.toolName];
7886
7950
  return r?.(t, e);
7887
7951
  }
7888
- function pi(t, e) {
7952
+ function fi(t, e) {
7889
7953
  const n = [...t].reverse().find((i) => i.role === "assistant")?.parts?.find(
7890
7954
  (i) => "toolCallId" in i && i.toolCallId === e && "state" in i && (i.state === "output-available" || i.state === "output-error")
7891
7955
  );
@@ -7895,12 +7959,12 @@ function pi(t, e) {
7895
7959
  errorText: "errorText" in n ? String(n.errorText) : void 0
7896
7960
  };
7897
7961
  }
7898
- async function hi(t, e, r) {
7962
+ async function mi(t, e, r) {
7899
7963
  const n = [], i = [];
7900
7964
  for (const s of t) {
7901
- if (!di.has(s.toolName))
7965
+ if (!pi.has(s.toolName))
7902
7966
  continue;
7903
- const o = pi(
7967
+ const o = fi(
7904
7968
  e,
7905
7969
  s.toolCallId
7906
7970
  );
@@ -7919,7 +7983,7 @@ async function hi(t, e, r) {
7919
7983
  continue;
7920
7984
  }
7921
7985
  try {
7922
- const c = await ui(s, r);
7986
+ const c = await hi(s, r);
7923
7987
  c && (n.push(c.toolCallId), i.push(c));
7924
7988
  } catch (c) {
7925
7989
  console.error("[handleToolCall] Error:", { toolCall: s, error: c });
@@ -7929,9 +7993,9 @@ async function hi(t, e, r) {
7929
7993
  }
7930
7994
  return { completedToolCallIds: n, outputs: i };
7931
7995
  }
7932
- function fi() {
7996
+ function gi() {
7933
7997
  try {
7934
- const t = localStorage.getItem(ct);
7998
+ const t = localStorage.getItem(ot);
7935
7999
  if (!t)
7936
8000
  return {
7937
8001
  valid: !0,
@@ -7948,7 +8012,7 @@ function fi() {
7948
8012
  threadId: null,
7949
8013
  cartEntityId: null
7950
8014
  };
7951
- if (r !== Gt)
8015
+ if (r !== Qt)
7952
8016
  return {
7953
8017
  valid: !1,
7954
8018
  error: "The app version has changed. Your previous session is not compatible.",
@@ -7980,12 +8044,12 @@ function fi() {
7980
8044
  }
7981
8045
  function ze() {
7982
8046
  try {
7983
- localStorage.removeItem(ct);
8047
+ localStorage.removeItem(ot);
7984
8048
  } catch (t) {
7985
8049
  console.error("Failed to clear persisted session:", t);
7986
8050
  }
7987
8051
  }
7988
- function mi(t, e) {
8052
+ function yi(t, e) {
7989
8053
  return !t && !e ? { valid: !0 } : t && !e ? {
7990
8054
  valid: !1,
7991
8055
  error: "Your previous session was reset because you signed out."
@@ -7997,20 +8061,20 @@ function mi(t, e) {
7997
8061
  error: "Your previous session was reset because you signed in as a different user."
7998
8062
  } : { valid: !0 };
7999
8063
  }
8000
- async function gi(t, e) {
8064
+ async function xi(t, e) {
8001
8065
  return { valid: !0 };
8002
8066
  }
8003
- function yi(t) {
8067
+ function bi(t) {
8004
8068
  return t ? { valid: !0 } : {
8005
8069
  valid: !1,
8006
8070
  error: "The cart from your previous session is no longer available."
8007
8071
  };
8008
8072
  }
8009
- async function xi(t) {
8073
+ async function Ci(t) {
8010
8074
  const e = g.getState();
8011
8075
  if (e.ui.initStatus !== "pending")
8012
8076
  return;
8013
- const r = fi();
8077
+ const r = gi();
8014
8078
  if (e.setTakeShapeConfig(t.takeShapeConfig), !r.valid) {
8015
8079
  ze(), e.failValidation(r.error ?? "Session validation failed");
8016
8080
  return;
@@ -8020,8 +8084,8 @@ async function xi(t) {
8020
8084
  const m = await t.storefrontClient.getCustomerAddresses();
8021
8085
  if (i = m.customerInfo, n = m.addresses, await t.b2bClient.initPromise, t.b2bClient.isAvailable) {
8022
8086
  console.debug("[BigCommerceClient] Fetching B2B company addresses");
8023
- const v = await t.b2bClient.getCompanyAddresses();
8024
- v.length > 0 && (n = [...v]);
8087
+ const C = await t.b2bClient.getCompanyAddresses();
8088
+ C.length > 0 && (n = [...C]);
8025
8089
  }
8026
8090
  } catch (m) {
8027
8091
  if (console.error("Failed to fetch customer addresses:", m), r.data) {
@@ -8058,12 +8122,12 @@ async function xi(t) {
8058
8122
  const d = [];
8059
8123
  d.push(
8060
8124
  Promise.resolve(
8061
- mi(
8125
+ yi(
8062
8126
  c.customerEntityId ?? null,
8063
8127
  i
8064
8128
  )
8065
8129
  )
8066
- ), s && d.push(gi()), o && d.push(Promise.resolve(yi(l)));
8130
+ ), s && d.push(xi()), o && d.push(Promise.resolve(bi(l)));
8067
8131
  const u = (await Promise.all(d)).find((m) => !m.valid);
8068
8132
  if (u) {
8069
8133
  ze(), e.failValidation(u.error ?? "Session validation failed");
@@ -8071,16 +8135,16 @@ async function xi(t) {
8071
8135
  }
8072
8136
  c && e.restoreSession(c), l && e.setBcCart(l), i && e.setCustomerInfo(i), n.length > 0 && e.setCustomerAddresses(n), e.completeValidation();
8073
8137
  }
8074
- function bi(t) {
8075
- return Wr(t) && "toolCallId" in t && typeof t.toolCallId == "string" && "output" in t && t.output !== void 0 && "state" in t && t.state === "output-available";
8138
+ function vi(t) {
8139
+ return jr(t) && "toolCallId" in t && typeof t.toolCallId == "string" && "output" in t && t.output !== void 0 && "state" in t && t.state === "output-available";
8076
8140
  }
8077
- function Ci(t) {
8078
- return t ? t.filter(bi) : [];
8141
+ function Ii(t) {
8142
+ return t ? t.filter(vi) : [];
8079
8143
  }
8080
- function vi(t) {
8144
+ function wi(t) {
8081
8145
  return t.type === "dynamic-tool" ? t.toolName ?? "unknown" : t.type.slice(5);
8082
8146
  }
8083
- const Ii = new Ur({
8147
+ const Si = new Lr({
8084
8148
  defaultOptions: {
8085
8149
  queries: {
8086
8150
  staleTime: 300 * 1e3
@@ -8088,15 +8152,15 @@ const Ii = new Ur({
8088
8152
  }
8089
8153
  }
8090
8154
  });
8091
- function wi(t) {
8092
- return /* @__PURE__ */ a(Lr, { client: Ii, children: /* @__PURE__ */ a(Ss, { client: t.bigcommerce.client, children: /* @__PURE__ */ a(Si, { ...t }) }) });
8155
+ function Ei(t) {
8156
+ return /* @__PURE__ */ a(_r, { client: Si, children: /* @__PURE__ */ a(Ss, { client: t.bigcommerce.client, children: /* @__PURE__ */ a(Ni, { ...t }) }) });
8093
8157
  }
8094
- function Si(t) {
8158
+ function Ni(t) {
8095
8159
  const e = g((s) => s.ui.initStatus), r = g((s) => s.ui.initError), n = g((s) => s.fatalError), i = g((s) => s.clearInitError);
8096
8160
  return F(() => {
8097
- e === "pending" && xi({
8161
+ e === "pending" && Ci({
8098
8162
  storefrontClient: t.bigcommerce.client,
8099
- b2bClient: ei({
8163
+ b2bClient: ri({
8100
8164
  channelId: t.bigcommerce.client.channelId,
8101
8165
  getB2BJwt: t.bigcommerce.getB2BJwt
8102
8166
  }),
@@ -8106,19 +8170,19 @@ function Si(t) {
8106
8170
  "div",
8107
8171
  {
8108
8172
  className: `flex h-full items-center justify-center ${t.className ?? ""}`,
8109
- children: /* @__PURE__ */ a(ta, { message: n })
8173
+ children: /* @__PURE__ */ a(ra, { message: n })
8110
8174
  }
8111
8175
  ) : e === "pending" ? /* @__PURE__ */ a(
8112
8176
  "div",
8113
8177
  {
8114
8178
  className: `flex h-full items-center justify-center ${t.className ?? ""}`,
8115
- children: /* @__PURE__ */ a("div", { className: "flex items-center", children: /* @__PURE__ */ a(Me, { size: 16 }) })
8179
+ children: /* @__PURE__ */ a("div", { className: "flex items-center", children: /* @__PURE__ */ a(Oe, { size: 16 }) })
8116
8180
  }
8117
8181
  ) : e === "existing-cart" ? /* @__PURE__ */ a(
8118
8182
  "div",
8119
8183
  {
8120
8184
  className: `flex h-full items-center justify-center ${t.className ?? ""}`,
8121
- children: /* @__PURE__ */ a(ea, {})
8185
+ children: /* @__PURE__ */ a(ta, {})
8122
8186
  }
8123
8187
  ) : r ? /* @__PURE__ */ h(
8124
8188
  "div",
@@ -8137,9 +8201,9 @@ function Si(t) {
8137
8201
  )
8138
8202
  ]
8139
8203
  }
8140
- ) : /* @__PURE__ */ a(Ei, { ...t });
8204
+ ) : /* @__PURE__ */ a(ki, { ...t });
8141
8205
  }
8142
- function Ei({
8206
+ function ki({
8143
8207
  className: t = "",
8144
8208
  agentName: e = Qe,
8145
8209
  inputName: r = Qe,
@@ -8147,70 +8211,70 @@ function Ei({
8147
8211
  expandOnReady: i
8148
8212
  }) {
8149
8213
  const { sseOrigin: s, projectId: o, apiKey: c } = g(
8150
- (C) => C.takeshapeConfig
8214
+ (v) => v.takeshapeConfig
8151
8215
  ), l = g(
8152
- (C) => C.chat.threadId
8153
- ), d = g((C) => C.chat.input), p = g(
8154
- (C) => C.chat.messages
8216
+ (v) => v.chat.threadId
8217
+ ), d = g((v) => v.chat.input), p = g(
8218
+ (v) => v.chat.messages
8155
8219
  ), {
8156
8220
  thread: u,
8157
8221
  isCreating: m,
8158
- createThread: v
8159
- } = Br({
8222
+ createThread: C
8223
+ } = Ar({
8160
8224
  agentName: e,
8161
8225
  createOnMount: !l,
8162
8226
  // Only create if no existing thread
8163
8227
  existingThreadId: l
8164
- }), b = g((C) => C.appState), x = g((C) => C.setAppState), I = D(null), w = D(
8228
+ }), b = g((v) => v.appState), x = g((v) => v.setAppState), I = D(null), w = D(
8165
8229
  null
8166
8230
  ), k = D(
8167
8231
  null
8168
- ), N = Re((C) => C.isExpanded), T = Re((C) => C.setExpanded), y = Re((C) => C.reset), A = Za(), $ = Ea({
8232
+ ), N = _e((v) => v.isExpanded), T = _e((v) => v.setExpanded), y = _e((v) => v.reset), A = ei(), $ = Na({
8169
8233
  client: n.client,
8170
- onError: (C) => console.error("BigCommerce error:", C)
8171
- }), B = g((C) => C.cartifact.orderId), Q = g((C) => C.cartifact.buyerInfo), te = g(
8172
- (C) => C.cartifact.shipToAddress
8234
+ onError: (v) => console.error("BigCommerce error:", v)
8235
+ }), B = g((v) => v.cartifact.orderId), Q = g((v) => v.cartifact.buyerInfo), te = g(
8236
+ (v) => v.cartifact.shipToAddress
8173
8237
  ), j = g(
8174
- (C) => C.cartifact.billingAddress
8238
+ (v) => v.cartifact.billingAddress
8175
8239
  ), Y = g(
8176
- (C) => C.cartifact.poMetadataSet
8240
+ (v) => v.cartifact.poMetadataSet
8177
8241
  ), re = g(
8178
- (C) => C.cartifact.itemWarnings
8179
- ), ie = g((C) => C.clearCartifact), Z = g((C) => C.clearBcSession), ne = g(
8180
- (C) => C.clearAddressSelections
8181
- ), z = g((C) => C.clearChat), { cartItems: q } = $, oe = D([]), Ie = M(
8182
- async ({ toolCall: C }) => {
8183
- oe.current.push(C);
8242
+ (v) => v.cartifact.itemWarnings
8243
+ ), ie = g((v) => v.clearCartifact), Z = g((v) => v.clearBcSession), ne = g(
8244
+ (v) => v.clearAddressSelections
8245
+ ), z = g((v) => v.clearChat), { cartItems: q } = $, oe = D([]), Ie = M(
8246
+ async ({ toolCall: v }) => {
8247
+ oe.current.push(v);
8184
8248
  },
8185
8249
  []
8186
- ), L = D(/* @__PURE__ */ new Set()), { messages: W, sendMessage: G, status: K, error: Pe, setMessages: fe, addToolOutput: me } = Vt({
8187
- transport: new zt({
8250
+ ), L = D(/* @__PURE__ */ new Set()), { messages: W, sendMessage: G, status: K, error: Te, setMessages: fe, addToolOutput: me } = Wt({
8251
+ transport: new Vt({
8188
8252
  api: `${s}/project/${o}/agents/messages`,
8189
8253
  headers: {
8190
8254
  Authorization: `Bearer ${c}`
8191
8255
  },
8192
- prepareSendMessagesRequest: async (C) => {
8193
- const se = C.messages[C.messages.length - 1];
8256
+ prepareSendMessagesRequest: async (v) => {
8257
+ const se = v.messages[v.messages.length - 1];
8194
8258
  if (!se)
8195
8259
  throw new Error("No messages to send");
8196
8260
  let we = [se];
8197
- if (se.role === "user" && C.messages.length >= 2) {
8198
- const pe = C.messages[C.messages.length - 2], Ze = L.current;
8261
+ if (se.role === "user" && v.messages.length >= 2) {
8262
+ const pe = v.messages[v.messages.length - 2], Ze = L.current;
8199
8263
  if (pe?.role === "assistant" && Ze.size > 0) {
8200
- const mt = Ci(
8264
+ const ft = Ii(
8201
8265
  pe.parts
8202
8266
  ).filter(
8203
- (gt) => Ze.has(gt.toolCallId)
8267
+ (mt) => Ze.has(mt.toolCallId)
8204
8268
  );
8205
- Ze.clear(), mt.length > 0 && (we = [{
8269
+ Ze.clear(), ft.length > 0 && (we = [{
8206
8270
  ...pe,
8207
- parts: mt.map((Te) => ({
8208
- type: Te.type,
8209
- toolName: vi(Te),
8210
- toolCallId: Te.toolCallId,
8211
- state: Te.state,
8212
- input: Te.input,
8213
- output: Te.output
8271
+ parts: ft.map((Ae) => ({
8272
+ type: Ae.type,
8273
+ toolName: wi(Ae),
8274
+ toolCallId: Ae.toolCallId,
8275
+ state: Ae.state,
8276
+ input: Ae.input,
8277
+ output: Ae.output
8214
8278
  }))
8215
8279
  }, se]);
8216
8280
  }
@@ -8219,10 +8283,10 @@ function Ei({
8219
8283
  body: {
8220
8284
  id: u.current?.id ?? "",
8221
8285
  messages: we,
8222
- trigger: C.trigger,
8223
- messageId: C.messageId,
8286
+ trigger: v.trigger,
8287
+ messageId: v.messageId,
8224
8288
  metadata: {
8225
- ...C.requestMetadata,
8289
+ ...v.requestMetadata,
8226
8290
  custom: {
8227
8291
  inputName: r
8228
8292
  }
@@ -8233,21 +8297,21 @@ function Ei({
8233
8297
  }),
8234
8298
  messages: p,
8235
8299
  onToolCall: Ie,
8236
- onError: (C) => {
8237
- console.error("[useChat onError]", C), w.current?.setStatus({
8300
+ onError: (v) => {
8301
+ console.error("[useChat onError]", v), w.current?.setStatus({
8238
8302
  code: 2,
8239
8303
  message: "internal_error"
8240
8304
  }), w.current?.end(), w.current = null;
8241
8305
  }
8242
8306
  }), de = M(
8243
- (C) => {
8244
- w.current?.end(), w.current = nt({
8307
+ (v) => {
8308
+ w.current?.end(), w.current = rt({
8245
8309
  name: "po-agent-turn",
8246
8310
  op: "ai.agent",
8247
8311
  attributes: {
8248
8312
  "agent.name": r
8249
8313
  }
8250
- }), G(C);
8314
+ }), G(v);
8251
8315
  },
8252
8316
  [G, r]
8253
8317
  );
@@ -8257,11 +8321,11 @@ function Ei({
8257
8321
  w.current?.end(), k.current?.end();
8258
8322
  }, []), F(() => {
8259
8323
  if (K === "ready" && oe.current.length > 0) {
8260
- const C = [...oe.current];
8261
- oe.current = [], hi(C, W, $).then(async (se) => {
8324
+ const v = [...oe.current];
8325
+ oe.current = [], mi(v, W, $).then(async (se) => {
8262
8326
  for (const we of se.outputs)
8263
8327
  L.current.add(we.toolCallId), await me(we);
8264
- se.outputs.length > 0 && de({ text: ot });
8328
+ se.outputs.length > 0 && de({ text: it });
8265
8329
  }).catch((se) => {
8266
8330
  console.error("[executeDeferredToolCalls] Error:", se);
8267
8331
  });
@@ -8270,8 +8334,8 @@ function Ei({
8270
8334
  g.getState().setMessages(W);
8271
8335
  }, [W]);
8272
8336
  const ge = g(
8273
- (C) => C.ai.pendingMessage
8274
- ), f = g((C) => C.ai.shouldScroll), S = g((C) => C.consumeMessage);
8337
+ (v) => v.ai.pendingMessage
8338
+ ), f = g((v) => v.ai.shouldScroll), S = g((v) => v.consumeMessage);
8275
8339
  F(() => {
8276
8340
  ge && (de({ text: ge }), S(), f && requestAnimationFrame(() => {
8277
8341
  I.current?.scrollToBottom();
@@ -8279,58 +8343,58 @@ function Ei({
8279
8343
  }, [ge, f, de, S]), F(() => {
8280
8344
  i && b === "chatting" && T(!0);
8281
8345
  }, [i, b, T]);
8282
- const E = m || K === "submitted" || K === "streaming", P = ee(() => ha(W, K), [W, K]), O = Ra({
8346
+ const E = m || K === "submitted" || K === "streaming", P = ee(() => fa(W, K), [W, K]), O = La({
8283
8347
  appState: b,
8284
8348
  setAppState: x,
8285
8349
  parser: A,
8286
8350
  firstResponseComplete: P,
8287
8351
  chatPanelRef: I,
8288
8352
  bcCart: $
8289
- }), U = Na({
8353
+ }), U = ka({
8290
8354
  bcCart: $,
8291
8355
  cartItems: q,
8292
- onCheckoutInitiated: (C) => {
8293
- C ? k.current?.setStatus({ code: 2, message: C.message }) : k.current?.setStatus({ code: 1, message: "ok" }), k.current?.end(), k.current = null;
8356
+ onCheckoutInitiated: (v) => {
8357
+ v ? k.current?.setStatus({ code: 2, message: v.message }) : k.current?.setStatus({ code: 1, message: "ok" }), k.current?.end(), k.current = null;
8294
8358
  },
8295
8359
  onCheckout: n.onCheckout
8296
- }), _ = (C) => {
8297
- g.getState().setInput(C.target.value);
8298
- }, qe = (C) => {
8299
- C.preventDefault(), d.trim() && (g.getState().sendMessage(d), g.getState().setInput(""));
8300
- }, Fe = async (C) => {
8301
- k.current?.end(), k.current = nt({
8360
+ }), _ = (v) => {
8361
+ g.getState().setInput(v.target.value);
8362
+ }, qe = (v) => {
8363
+ v.preventDefault(), d.trim() && (g.getState().sendMessage(d), g.getState().setInput(""));
8364
+ }, De = async (v) => {
8365
+ k.current?.end(), k.current = rt({
8302
8366
  name: "upload-to-checkout",
8303
8367
  op: "purchase-order.session",
8304
8368
  attributes: {
8305
- "file.name": C.name
8369
+ "file.name": v.name
8306
8370
  }
8307
- }), x("processing"), O.reset(), await A.handleFileUpload(C) === !1 && x("upload");
8371
+ }), x("processing"), O.reset(), await A.handleFileUpload(v) === !1 && x("upload");
8308
8372
  }, H = M(
8309
- (C) => {
8373
+ (v) => {
8310
8374
  n.onViewProduct && n.onViewProduct({
8311
- productEntityId: C.productEntityId,
8312
- sku: C.sku,
8313
- name: C.name,
8314
- path: C.path
8375
+ productEntityId: v.productEntityId,
8376
+ sku: v.sku,
8377
+ name: v.name,
8378
+ path: v.path
8315
8379
  });
8316
8380
  },
8317
8381
  [n.onViewProduct]
8318
8382
  ), ce = M(() => {
8319
- const C = [...W].reverse().find((pe) => pe.role === "user");
8320
- if (!C) return;
8321
- const se = C.parts?.filter(
8383
+ const v = [...W].reverse().find((pe) => pe.role === "user");
8384
+ if (!v) return;
8385
+ const se = v.parts?.filter(
8322
8386
  (pe) => pe.type === "text"
8323
8387
  ).map((pe) => pe.text).join(`
8324
8388
  `);
8325
8389
  if (!se) return;
8326
- const we = W.lastIndexOf(C);
8390
+ const we = W.lastIndexOf(v);
8327
8391
  fe(W.slice(0, we)), g.getState().sendMessage(se);
8328
8392
  }, [W, fe]), J = M(() => {
8329
8393
  x("chatting");
8330
8394
  }, [x]), X = g(
8331
- (C) => C.resetBatchProcessing
8395
+ (v) => v.resetBatchProcessing
8332
8396
  ), ye = M(async () => {
8333
- k.current?.setStatus({ code: 2, message: "cancelled" }), k.current?.end(), k.current = null, await $.clearCart(), ie(), Z(), ne(), z(), fe([]), X(), y(), A.reset(), O.reset(), x("upload"), v();
8397
+ k.current?.setStatus({ code: 2, message: "cancelled" }), k.current?.end(), k.current = null, await $.clearCart(), ie(), Z(), ne(), z(), fe([]), X(), y(), A.reset(), O.reset(), x("upload"), C();
8334
8398
  }, [
8335
8399
  $.clearCart,
8336
8400
  ie,
@@ -8342,14 +8406,14 @@ function Ei({
8342
8406
  y,
8343
8407
  A.reset,
8344
8408
  O.reset,
8345
- v,
8409
+ C,
8346
8410
  x
8347
8411
  ]);
8348
8412
  if (b === "upload" || b === "processing")
8349
8413
  return /* @__PURE__ */ a("div", { className: `flex h-full ${t}`, children: /* @__PURE__ */ a(
8350
- Ca,
8414
+ va,
8351
8415
  {
8352
- onFileUpload: Fe,
8416
+ onFileUpload: De,
8353
8417
  onSkip: J,
8354
8418
  onClearError: A.handleClearError,
8355
8419
  cartItems: q,
@@ -8364,12 +8428,12 @@ function Ei({
8364
8428
  onInputChange: _,
8365
8429
  onSubmit: qe,
8366
8430
  isLoading: E,
8367
- error: Pe,
8368
- onRetry: Pe ? ce : void 0,
8431
+ error: Te,
8432
+ onRetry: Te ? ce : void 0,
8369
8433
  hasProcessedDocument: O.hasProcessedDocument,
8370
8434
  uploadedFileName: A.uploadedFileName,
8371
8435
  chatPanelRef: I,
8372
- onFileUpload: Fe,
8436
+ onFileUpload: De,
8373
8437
  cartItems: q,
8374
8438
  itemWarnings: re,
8375
8439
  onUpdateQuantity: U.handleUpdateQuantity,
@@ -8396,15 +8460,15 @@ function Ei({
8396
8460
  poMetadataSet: Y,
8397
8461
  onNewOrder: ye
8398
8462
  };
8399
- return i && N ? /* @__PURE__ */ a(En, { children: /* @__PURE__ */ a(Dt, { ...ue, onMinimize: () => T(!1) }) }) : /* @__PURE__ */ a("div", { className: "h-full max-w-[1440px] mx-auto", children: /* @__PURE__ */ a(
8400
- Dt,
8463
+ return i && N ? /* @__PURE__ */ a(Sn, { children: /* @__PURE__ */ a(Ft, { ...ue, onMinimize: () => T(!1) }) }) : /* @__PURE__ */ a("div", { className: "h-full max-w-[1440px] mx-auto", children: /* @__PURE__ */ a(
8464
+ Ft,
8401
8465
  {
8402
8466
  ...ue,
8403
8467
  onExpand: i ? () => T(!0) : void 0
8404
8468
  }
8405
8469
  ) });
8406
8470
  }
8407
- function Qi({
8471
+ function Gi({
8408
8472
  takeshape: t,
8409
8473
  bigcommerce: e,
8410
8474
  agentName: r = Qe,
@@ -8415,7 +8479,7 @@ function Qi({
8415
8479
  expandOnReady: c
8416
8480
  }) {
8417
8481
  const l = ee(
8418
- () => Sn({
8482
+ () => wn({
8419
8483
  endpoint: e.endpoint,
8420
8484
  storefrontToken: e.storefrontToken,
8421
8485
  channelId: e.channelId
@@ -8423,7 +8487,7 @@ function Qi({
8423
8487
  [e.endpoint, e.storefrontToken, e.channelId]
8424
8488
  );
8425
8489
  return /* @__PURE__ */ a(
8426
- wi,
8490
+ Ei,
8427
8491
  {
8428
8492
  agentName: r,
8429
8493
  inputName: n,
@@ -8432,8 +8496,8 @@ function Qi({
8432
8496
  takeshape: {
8433
8497
  projectId: t.projectId,
8434
8498
  apiKey: t.apiKey,
8435
- origin: t.origin ?? vt,
8436
- sseOrigin: t.sseOrigin ?? vt
8499
+ origin: t.origin ?? Ct,
8500
+ sseOrigin: t.sseOrigin ?? Ct
8437
8501
  },
8438
8502
  bigcommerce: {
8439
8503
  client: l,
@@ -8445,14 +8509,14 @@ function Qi({
8445
8509
  );
8446
8510
  }
8447
8511
  export {
8448
- Qi as P,
8449
- Wi as S,
8450
- Sn as a,
8451
- Vi as b,
8452
- ei as c,
8453
- wi as d,
8454
- zi as i,
8455
- ji as r,
8456
- Hi as s
8512
+ Gi as P,
8513
+ Vi as S,
8514
+ wn as a,
8515
+ zi as b,
8516
+ ri as c,
8517
+ Ei as d,
8518
+ Hi as i,
8519
+ Wi as r,
8520
+ Qi as s
8457
8521
  };
8458
- //# sourceMappingURL=purchase-order-chat-wrapper-CMOXLHX5.js.map
8522
+ //# sourceMappingURL=purchase-order-chat-wrapper-66JrwtTs.js.map